| | |
| | | <span class="highlight">姓名:{{ infoList.tjCustomerName || "暂无" }}</span> |
| | | <span class="highlight">性别:{{ infoList.tjCustomerSex == 0 ? "男" : infoList.tjCustomerSex == 1 ? "女" : "暂无" }}</span> |
| | | <span class="highlight">年龄:{{ infoList.tjCustomerAge || "暂无" }}</span> |
| | | <span class="highlight">门诊号:{{ infoList.cardId || "暂无" }}</span> |
| | | </h3> |
| | | </div> |
| | | <el-table border height="350" ref="tab1" :data="checkList" v-loading="loading" style="width: 100%" |
| | |
| | | }, |
| | | |
| | | handleSelectionChange(val) { |
| | | this.selectedFirstTable = val; |
| | | // 防止重复触发 |
| | | if (this.isProcessingSelection) { |
| | | console.log('正在处理选择,跳过重复触发'); |
| | | return; |
| | | } |
| | | this.isProcessingSelection = true; |
| | | |
| | | this.$nextTick(() => { |
| | | // 如果没有选中行,清空所有选择并跳过接口调用 |
| | | if (val.length === 0) { |
| | | console.log('无选中行,清空选择和 checkList'); |
| | | console.log('检测到取消选中,清空所有选择'); |
| | | this.$refs.firstTable.clearSelection(); |
| | | this.selectedFirstTable = null; |
| | | this.checkList = []; |
| | | this.exaLists.forEach(row => { |
| | | this.$refs.firstTable && this.$refs.firstTable.toggleRowSelection(row, false); |
| | | this.isDeselection = true; |
| | | this.$nextTick(() => { |
| | | this.isProcessingSelection = false; |
| | | this.$refs.firstTable.$forceUpdate(); // 强制刷新表格 |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | const firstSelectedRow = val[0]; |
| | | let filterKey = firstSelectedRow.checkParts ? 'checkParts' : 'brid'; |
| | | let filterValue = firstSelectedRow.checkParts || firstSelectedRow.brid; |
| | | |
| | | console.log(`按 ${filterKey} 筛选: ${filterValue}`); |
| | | const selectedSet = new Set( |
| | | this.exaLists |
| | | .filter(row => row[filterKey] === filterValue) |
| | | .map(item => item.tempId) |
| | | ); |
| | | console.log(`选中的 ${filterKey} 集合 (tempId):`, selectedSet); |
| | | |
| | | // 检查是否点击了全选按钮(val 长度等于表格总行数) |
| | | if (val.length === this.exaLists.length) { |
| | | console.log('检测到全选,选中所有行'); |
| | | this.selectedFirstTable = [...this.exaLists]; // 选中所有行 |
| | | this.$refs.firstTable.clearSelection(); |
| | | this.exaLists.forEach(row => { |
| | | if (!row.brid) { |
| | | console.warn(`名称为 ${row.name} 的行没有申请单号,跳过选择`); |
| | | return; |
| | | } |
| | | const shouldSelect = selectedSet.has(row.tempId); |
| | | console.log(`行 tempId: ${row.tempId}, ${filterKey}: ${row[filterKey]}, 是否选中: ${shouldSelect}`); |
| | | this.$refs.firstTable.toggleRowSelection(row, shouldSelect); |
| | | this.$refs.firstTable.toggleRowSelection(row, true, false); |
| | | }); |
| | | } else { |
| | | // 获取最新选中的行 |
| | | const latestSelectedRow = val[val.length - 1]; |
| | | |
| | | // 检查是否点击了已选中的行(取消所有选中) |
| | | const isTogglingSelectedRow = this.selectedFirstTable && this.selectedFirstTable.some(row => row.tempId === latestSelectedRow.tempId); |
| | | if (isTogglingSelectedRow) { |
| | | console.log('点击已选中行,取消所有选中'); |
| | | this.$refs.firstTable.clearSelection(); |
| | | this.selectedFirstTable = null; |
| | | this.checkList = []; |
| | | this.isDeselection = true; |
| | | this.$nextTick(() => { |
| | | this.isProcessingSelection = false; |
| | | this.$refs.firstTable.$forceUpdate(); // 强制刷新表格 |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 正常选中逻辑:根据 brid 筛选 |
| | | const filterKey = 'brid'; |
| | | const filterValue = latestSelectedRow.brid; |
| | | console.log(`按 ${filterKey} 筛选: ${filterValue}`); |
| | | |
| | | // 清空所有选中状态 |
| | | this.$refs.firstTable.clearSelection(); |
| | | |
| | | // 选中与 brid 匹配的行 |
| | | const rowsToSelect = this.exaLists.filter(row => row.brid === filterValue); |
| | | rowsToSelect.forEach(row => { |
| | | if (!row.brid) { |
| | | console.warn(`名称为 ${row.name} 的行没有申请单号,跳过选择`); |
| | | return; |
| | | } |
| | | this.$refs.firstTable.toggleRowSelection(row, true, false); |
| | | }); |
| | | |
| | | if (!this.isFetchingRightTableData) { |
| | | // 更新 selectedFirstTable 为 brid 匹配的行 |
| | | this.selectedFirstTable = rowsToSelect; |
| | | } |
| | | |
| | | // 调用右侧表格数据 |
| | | if (!this.isFetchingRightTableData && this.selectedFirstTable.length > 0) { |
| | | this.isFetchingRightTableData = true; |
| | | this.fetchRightTableData().finally(() => { |
| | | this.isFetchingRightTableData = false; |
| | | this.$nextTick(() => { |
| | | // 仅更新样式,不触发新事件 |
| | | this.$refs.firstTable.$forceUpdate(); |
| | | this.isProcessingSelection = false; |
| | | }); |
| | | }); |
| | | } else { |
| | | this.isProcessingSelection = false; |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | // 重置 isDeselection 状态 |
| | | this.isDeselection = false; |
| | | }, |
| | | fetchRightTableData() { |
| | | const code = this.queryParams.tjNum; |
| | | if (!code) { |