From 57d24e6a8f3e2b7da44dbbda6767484d6e47de7a Mon Sep 17 00:00:00 2001 From: pengjun <158915633@qq.com> Date: Fri, 15 Sep 2023 18:06:13 +0800 Subject: [PATCH] merge --- .../patientRegister/MergeAsbitem.vue | 207 +++++++++++------- .../patientRegister/PatientRegisterItem.vue | 17 +- .../patientRegister/PatientRegisterList.vue | 11 +- .../patientRegisterAsbItem.vue | 24 +- 4 files changed, 162 insertions(+), 97 deletions(-) diff --git a/src/components/patientRegister/MergeAsbitem.vue b/src/components/patientRegister/MergeAsbitem.vue index bedbf95..5c97990 100644 --- a/src/components/patientRegister/MergeAsbitem.vue +++ b/src/components/patientRegister/MergeAsbitem.vue @@ -9,8 +9,9 @@ - + @selection-change="handleSelectionChange" :span-method="spanMethod" ref="tableData" + :row-style="{ height: '30px' }"> + @@ -54,6 +55,7 @@ export default { data() { return { tableData: [], //组合项目数据 过滤后显示的数据 + spanRow: [], //{ startRow: 0, endRow: 0 } 合并行 tableDataAll: [], //组合项目数据(该客户所有数据) itemTypeIds: [], //当前选中的类别及其上级类别ID options: [ @@ -62,6 +64,7 @@ export default { { label: "申请新的条码", value: "new" }, ], //操作方式 selectedData: [], //选中的组合项目 + finalSelected:[], //取消合并时与selectedData一致,合并时要追 其他未勾选合并的项目 }; }, @@ -75,70 +78,99 @@ export default { }, methods: { - handleSelectionChange(v) { - console.log('this.selectedData ,v', this.selectedData,v); + selectable(row, index) { + //console.log(row,index); + let able = true; + if (index == 0) return true; + if (this.tableData[index - 1].registerCheckId == row.registerCheckId) able = false; + return able; + }, - if (!v || v.length < 1) { - this.selectedData = v; - return; + spanMethod({ row, column, rowIndex, columnIndex }) { + //console.log(row, column, rowIndex, columnIndex); + if (columnIndex == 3) { + for (let i = 0; i < this.spanRow.length; i++) { + if (rowIndex == this.spanRow[i].startRow) { + return { + rowspan: Number(this.spanRow[i].endRow - this.spanRow[i].startRow) + 1, + colspan: 1 + }; + } + } } + if (columnIndex == 4) { + for (let i = 0; i < this.spanRow.length; i++) { + if (rowIndex == this.spanRow[i].startRow) { + return { + rowspan: Number(this.spanRow[i].endRow - this.spanRow[i].startRow) + 1, + colspan: 1 + }; + } else if (this.spanRow[i].startRow < rowIndex && rowIndex <= this.spanRow[i].endRow) { + return { + rowspan: 0, + colspan: 0 + } + } + } + } + }, + //分析合并的行数据 + parseSpanRow() { + this.spanRow = []; + let preVal = '', curVal = ''; + let startRow = 0; + for (let i = 0; i < this.tableData.length; i++) { + if (i == 0) { + preVal = this.tableData[i].registerCheckId; + curVal = this.tableData[i].registerCheckId; + } else { + curVal = this.tableData[i].registerCheckId; + if (preVal !== curVal) { + if (startRow !== i - 1) this.spanRow.push({ startRow, endRow: i - 1 }); + startRow = i; + preVal = this.tableData[i].registerCheckId; + } + if (i == this.tableData.length - 1 && preVal === curVal){ + this.spanRow.push({ startRow, endRow: i }); + } + } + } + }, + + handleSelectionChange(v) { this.selectedData = v; - //处理已合并的,要么全勾选,要么全不勾选 - - // let currSelectedIds = []; - // let finalSelected = deepCopy(v); //最终勾选的数据 - - // v.forEach(e => { - // currSelectedIds.push(e.registerAsbitemId); - // }); - // console.log('currSelectedIds', currSelectedIds); - - // //原选择的有,新选的没有,则为取消勾选 - // this.selectedData.forEach(e => { - // //取消勾选 - // if (currSelectedIds.indexOf(e.registerAsbitemId) < 0) { - // for (let i = finalSelected.length - 1; i > -1; i--) { - // if(finalSelected[i].registerCheckId == e.registerCheckId){ - // finalSelected.splice(i,1); - // } - // } - // } - // }); - - // //判断勾选的 合并的有一个勾选,则其他项目也勾选 - // let currMergeIds = []; - // currSelectedIds = []; - // finalSelected.forEach(e => { - // currSelectedIds.push(e.registerAsbitemId); - // if(currMergeIds.indexOf(e.registerCheckId) < 0){ - // currMergeIds.push(e.registerCheckId); - // } - // }); - - // this.tableData.forEach(e =>{ - // if(currMergeIds.indexOf(e.registerCheckId) > - 1){ - // if(currSelectedIds.indexOf(e.registerAsbitemId) < 0){ - // finalSelected.push(e); - // } - // } - // }); - - // this.selectedData = deepCopy(finalSelected); - - // console.log('this.selectedData', this.selectedData); - - // this.$nextTick(function () { - // //this.$refs['tableData'].clearSelection(); - // this.selectedData.forEach(row => { - // this.$refs['tableData'].toggleRowSelection(row,true) - // }) - // }); + }, + //获取合并的项目(不是同一个项目类别不可以合并) + getFinalSelected(){ + let currSelectedCheckIds = []; + let finalSelectedIds = []; - }, + this.finalSelected = deepCopy(this.selectedData); //最终勾选的数据 + this.selectedData.forEach(e => { + if(currSelectedCheckIds.indexOf(e.registerCheckId) < 0) currSelectedCheckIds.push(e.registerCheckId); + finalSelectedIds.push(e.registerAsbitemId); + }); + + console.log('currSelectedCheckIds', currSelectedCheckIds); + console.log('finalSelectedIds', finalSelectedIds); + + // //判断勾选的 合并的有一个勾选,则其他项目也勾选 + this.tableData.forEach(e => { + if(currSelectedCheckIds.indexOf(e.registerCheckId) > -1){ + if(finalSelectedIds.indexOf(e.registerAsbitemId) < 0){ + finalSelectedIds.push(e.registerAsbitemId); + this.finalSelected.push(e); + } + } + }); + console.log('this.selectedData', this.selectedData); + console.log('this.finalSelected', this.finalSelected); + + }, //过滤组合项目 @@ -164,11 +196,12 @@ export default { } }); } + + this.parseSpanRow(); }, getAsbItemList(id) { - this.tableDataAll = []; - this.tableData = []; + this.tableDataAll = []; // /api/app/registerasbitem/getmergeregisterasbitemlist?PatientRegisterId=3fa85f64-5717-4562-b3fc-2c963f66afa6 // "registerAsbitemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", // "asbitemName": "string", @@ -181,27 +214,43 @@ export default { getapi( `/api/app/registerasbitem/getmergeregisterasbitemlist?PatientRegisterId=${id}` ).then((res) => { - this.tableDataAll = res.data; - this.getAsbItemByItemType(); + if(res.code != -1){ + //isItemResultMerger + res.data.forEach(e =>{ + //过滤不能合并的项目 + if(e.isItemResultMerger.toUpperCase() == 'Y'){ + this.tableDataAll.push(e); + } + }); + this.getAsbItemByItemType(); + } }); }, //手动合并项目 mergeSubmit() { let registerAsbitemIds = []; + let itemTypes = []; - this.selectedData.forEach(e =>{ + this.getFinalSelected(); + this.finalSelected.forEach(e => { + if(itemTypes.indexOf(e.itemTypeName) < 0) itemTypes.push(e.itemTypeName); registerAsbitemIds.push(e.registerAsbitemId); }); - if(registerAsbitemIds.length == 0){ - this.$message.warning("请勾选要合并的项目!"); + if(itemTypes.length > 1){ + this.$message.warning("勾选了不同类别的项目,数据校验失败,不可执行此操作!"); return; } - let body={ + if (registerAsbitemIds.length < 2) { + this.$message.warning("请勾选 2 个以上要合并的项目!"); + return; + } + + let body = { registerAsbitemIds, - organizationUnitId:this.organizationUnitId + organizationUnitId: this.organizationUnitId }; @@ -213,29 +262,29 @@ export default { } } ); - + }, //取消合并项目 unMergeSubmit() { let registerCheckIds = []; - this.selectedData.forEach(e =>{ - if(registerCheckIds.indexOf(e.registerCheckId) < 0){ - registerCheckIds.push(e.registerCheckId); - } + this.selectedData.forEach(e => { + if (e.isAsbitemMerger.toUpperCase() == 'Y' && registerCheckIds.indexOf(e.registerCheckId) < 0) { + registerCheckIds.push(e.registerCheckId); + } }); - if(registerCheckIds.length == 0){ - this.$message.warning("未选择已合并的项目,不可执行此操作!"); + if (registerCheckIds.length == 0) { + this.$message.warning("未选择到已合并的项目,不可执行此操作!"); return; } - console.log('registerCheckIds',registerCheckIds); + //console.log('registerCheckIds', registerCheckIds); - let body={ + let body = { registerCheckIds, - organizationUnitId:this.organizationUnitId + organizationUnitId: this.organizationUnitId }; postapi("/api/app/registerasbitem/cancelmergeregisterasbitem", body).then( @@ -246,10 +295,10 @@ export default { } } ); - + }, - + }, //监听事件 diff --git a/src/components/patientRegister/PatientRegisterItem.vue b/src/components/patientRegister/PatientRegisterItem.vue index 4767103..f99ee9a 100644 --- a/src/components/patientRegister/PatientRegisterItem.vue +++ b/src/components/patientRegister/PatientRegisterItem.vue @@ -268,7 +268,7 @@ export default { } //if (body.length > 0 ) await this.batchEditAsb(body, msg); - console.log('111111', msg, body.length, body, insBody.length, insBody); + //console.log('111111', msg, body.length, body, insBody.length, insBody); if (body.length > 0 && insBody.length > 0) { await this.batchEditAsb(body, ''); await this.batchAddAsb(insBody, msg); @@ -288,9 +288,17 @@ export default { }, //批量添加组合项目 - async batchAddAsb(body, msg) { - console.log(`/api/app/registerasbitem/createmany?OrganizationUnitId=${this.patientRegisterForm.organizationUnitId}`, body) - await postapi(`/api/app/registerasbitem/createmany?OrganizationUnitId=${this.patientRegisterForm.organizationUnitId}`, body) + async batchAddAsb(registerAsbitems, msg) { + let body = { + organizationUnitId:this.patientRegisterForm.organizationUnitId, + registerAsbitems + } + + if(this.patientRegisterForm.organizationUnitId.id){ + body.isAutoMerger = 'N' + } + //console.log(`/api/app/registerasbitem/createregisterasbitemmany`, body) + await postapi('/api/app/registerasbitem/createregisterasbitemmany', body) .then((res) => { console.log("batchAddAsb", res); if (res.code == 1) { @@ -849,6 +857,7 @@ export default { /*text-align: center;*/ padding-left: 1px; padding-right: 1px; + /*background-color: rgb(255, 0, 255);*/ } ::v-deep .el-table th.el-table__cell { diff --git a/src/components/patientRegister/PatientRegisterList.vue b/src/components/patientRegister/PatientRegisterList.vue index d3fd899..8631dea 100644 --- a/src/components/patientRegister/PatientRegisterList.vue +++ b/src/components/patientRegister/PatientRegisterList.vue @@ -366,7 +366,7 @@ export default { }, methods: { ...mapActions(["getCustomerOrgGroup", "getPatientRegisterAbs"]), - + // 打印指引单(isPreview) async guidePrint(ReportCode, isPreview) { let token = localStorage.getItem('token'); @@ -1156,4 +1156,11 @@ export default { input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none !important; margin: 0 !important; -} +} + +::v-deep .el-table__body tr.current-row>td { + background-color:#409EFF !important; +} + + + diff --git a/src/components/patientRegister/patientRegisterAsbItem.vue b/src/components/patientRegister/patientRegisterAsbItem.vue index e1721da..e92d368 100644 --- a/src/components/patientRegister/patientRegisterAsbItem.vue +++ b/src/components/patientRegister/patientRegisterAsbItem.vue @@ -7,11 +7,11 @@ ref="patientRegister.patientRegisterAbs"> - - - - - + + + + + - + - + - + - - + +