| | |
| | | <div class="table-header">检验记录</div> |
| | | <div> |
| | | <el-table :data="exaLists" border style="width: 100%" @selection-change="handleSelectionChange" |
| | | :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }" height="350" ref="firstTable"> |
| | | @select-all="handleSelectAll" :header-cell-style="{ background: '#aad8df', fontSize: '14px', color: '#333' }" |
| | | height="350" ref="firstTable"> |
| | | <el-table-column fixed type="selection" align="center" label="选择" width="50" /> |
| | | <el-table-column label="姓名" align="center" prop="name" width="80" /> |
| | | <el-table-column label="性别" align="center" prop="gender" width="80" /> |
| | |
| | | </el-table> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getlisList, getJyTjList, asyncPacs } from "@/api/doctor/pacsCheck"; |
| | | import { getOrderList } from "@/api/hosp/order"; |
| | |
| | | this.exaLists = []; |
| | | this.checkList = []; |
| | | this.infoList = {}; |
| | | this.selectedFirstTable = []; |
| | | this.selectedSecondTable = []; |
| | | }, |
| | | handleSelectionChange(selected) { |
| | | |
| | | // ✅ 分组多选稳固版 |
| | | handleSelectionChange(selection) { |
| | | if (this.isProcessingSelection) return; |
| | | this.isProcessingSelection = true; |
| | | |
| | | // 找到用户刚操作的那一条(对比之前和现在的差异) |
| | | const old = this.selectedFirstTable; |
| | | let changedRow = null; |
| | | // 计算所有被选中的分组 brid |
| | | const allBrids = new Set(); |
| | | selection.forEach(row => allBrids.add(row.brid)); |
| | | |
| | | if (selected.length > old.length) { |
| | | // 新增:找出新增的 |
| | | changedRow = selected.find(row => !old.includes(row)); |
| | | } else { |
| | | // 删除:找出删除的 |
| | | changedRow = old.find(row => !selected.includes(row)); |
| | | } |
| | | // 清空后重选 |
| | | this.$refs.firstTable.clearSelection(); |
| | | this.$nextTick(() => { |
| | | const newSelection = this.exaLists.filter(row => allBrids.has(row.brid)); |
| | | newSelection.forEach(row => { |
| | | this.$refs.firstTable.toggleRowSelection(row, true); |
| | | }); |
| | | this.selectedFirstTable = newSelection; |
| | | this.isProcessingSelection = false; |
| | | this.fetchRightTableData(); |
| | | }); |
| | | }, |
| | | |
| | | if (changedRow) { |
| | | const group = this.exaLists.filter(r => r.brid === changedRow.brid); |
| | | const isAdding = selected.length > old.length; |
| | | handleSelectAll(selection) { |
| | | if (this.isProcessingSelection) return; |
| | | this.isProcessingSelection = true; |
| | | |
| | | if (selection.length === 0) { |
| | | // 取消全选 |
| | | this.$refs.firstTable.clearSelection(); |
| | | if (isAdding) { |
| | | // 添加,整个组选上 + 原有选的 brid 也选上 |
| | | const allBrids = new Set(); |
| | | selected.forEach(row => allBrids.add(row.brid)); |
| | | allBrids.add(changedRow.brid); |
| | | this.selectedFirstTable = []; |
| | | this.isProcessingSelection = false; |
| | | this.fetchRightTableData(); |
| | | } else { |
| | | // 全选所有分组 |
| | | const allBrids = new Set(this.exaLists.map(row => row.brid)); |
| | | this.$refs.firstTable.clearSelection(); |
| | | this.$nextTick(() => { |
| | | const newSelection = this.exaLists.filter(row => allBrids.has(row.brid)); |
| | | newSelection.forEach(row => { |
| | | this.$refs.firstTable.toggleRowSelection(row, true); |
| | | }); |
| | | this.selectedFirstTable = newSelection; |
| | | } else { |
| | | // 删除,整个组取消,再把剩下 brid 分组补回去 |
| | | const remaining = old.filter(row => row.brid !== changedRow.brid); |
| | | const remainBrids = [...new Set(remaining.map(r => r.brid))]; |
| | | const newSelection = this.exaLists.filter(row => remainBrids.includes(row.brid)); |
| | | newSelection.forEach(row => { |
| | | this.$refs.firstTable.toggleRowSelection(row, true); |
| | | }); |
| | | this.selectedFirstTable = newSelection; |
| | | } |
| | | } else { |
| | | this.selectedFirstTable = selected; |
| | | this.isProcessingSelection = false; |
| | | this.fetchRightTableData(); |
| | | }); |
| | | } |
| | | |
| | | this.fetchRightTableData(); |
| | | this.isProcessingSelection = false; |
| | | }, |
| | | |
| | | |
| | | // 第二个表格只允许单选 |
| | | handleSelectionChangeSecond(selected) { |
| | | this.selectedSecondTable = selected.slice(0, 1); |
| | | }, |
| | |
| | | tongbu() { |
| | | this.$modal.loading("正在同步,请稍候..."); |
| | | const requestData = { |
| | | lis: this.selectedFirstTable ? this.selectedFirstTable.map((item) => ({ |
| | | ...item, |
| | | tjNum: this.queryParams.tjNum, |
| | | })) : [], |
| | | jcxmid: this.selectedFirstTable && this.selectedFirstTable.length > 0 ? this.selectedFirstTable[0].jcxmid : null, |
| | | shys: this.selectedFirstTable && this.selectedFirstTable.length > 0 ? this.selectedFirstTable[0].shys : null, |
| | | lis: this.selectedFirstTable |
| | | ? this.selectedFirstTable.map(item => ({ |
| | | ...item, |
| | | tjNum: this.queryParams.tjNum, |
| | | })) |
| | | : [], |
| | | jcxmid: |
| | | this.selectedFirstTable && this.selectedFirstTable.length > 0 |
| | | ? this.selectedFirstTable[0].jcxmid |
| | | : null, |
| | | shys: |
| | | this.selectedFirstTable && this.selectedFirstTable.length > 0 |
| | | ? this.selectedFirstTable[0].shys |
| | | : null, |
| | | tj: this.selectedSecondTable[0], |
| | | }; |
| | | asyncPacs(requestData) |
| | | .then((res) => { |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | this.fetchRightTableData(); |
| | | clearInterval(this.clearTimeSet); |
| | |
| | | this.$message.error(res.message || "同步失败,请稍后重试"); |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | .catch(() => { |
| | | clearInterval(this.clearTimeSet); |
| | | this.clearTimeSet = null; |
| | | this.$modal.closeLoading(); |
| | |
| | | }; |
| | | </script> |
| | | |
| | | |
| | | <style lang="scss" scoped> |
| | | .app-container { |
| | | padding: 20px; |