| | |
| | | dicts: ["dict_tj_status"], |
| | | data() { |
| | | return { |
| | | isProcessing: false, // 防止死循环 |
| | | isDeselection: false, // 标记是否为取消选中 |
| | | infoList: {}, |
| | | dis: false, |
| | | code: null, |
| | |
| | | }, |
| | | |
| | | handleSelectionChange(val) { |
| | | // console.log(val); |
| | | /* if (val.length > 1) { |
| | | let del_row = val.shift(); |
| | | this.$refs.tb.toggleRowSelection(del_row, false); //设置这一行取消选中 |
| | | } |
| | | console.log(val, 999); */ |
| | | |
| | | if (val.length > 0) { |
| | | // const selectedRow = val[0]; |
| | | // console.log(val[0], 555); |
| | | |
| | | this.selectedFirstTable = val; |
| | | console.log("当前选中的行数据:", this.selectedFirstTable); |
| | | this.fetchRightTableData(val); |
| | | } else { |
| | | this.selectedFirstTable = null; |
| | | this.checkList = []; |
| | | } |
| | | |
| | | this.$nextTick(() => { |
| | | if (isDeselection) { |
| | | console.log('检测到取消选中,清空所有选择'); |
| | | if (val.length === 0) { |
| | | console.log('无选中行,清空选择和 checkList'); |
| | | this.checkList = []; |
| | | this.exaLists.forEach(row => { |
| | | if (!row.brid) { |
| | | console.warn(`名称为 ${row.name} 的行没有申请单号,跳过选择`); |
| | | this.$refs.firstTable && this.$refs.firstTable.toggleRowSelection(row, false); |
| | | }); |
| | | return; |
| | | } |
| | | this.$refs.firstTable.toggleRowSelection(row, false, false); |
| | | }); |
| | | this.checkList = []; |
| | | } else if (val.length > 0) { |
| | | |
| | | const firstSelectedRow = val[0]; |
| | | let filterKey = firstSelectedRow.checkParts ? 'checkParts' : 'brid'; |
| | | let filterValue = firstSelectedRow.checkParts || firstSelectedRow.brid; |
| | | |
| | | const checkPartsMatches = this.exaLists.filter(row => row.checkParts === firstSelectedRow.checkParts); |
| | | if (firstSelectedRow.checkParts && checkPartsMatches.length <= 1) { |
| | | filterKey = 'brid'; |
| | | filterValue = firstSelectedRow.brid; |
| | | } |
| | | |
| | | console.log(`按 ${filterKey} 筛选: ${filterValue}`); |
| | | const selectedSet = new Set(this.exaLists |
| | | const selectedSet = new Set( |
| | | this.exaLists |
| | | .filter(row => row[filterKey] === filterValue) |
| | | .map(item => item.tempId)); |
| | | .map(item => item.tempId) |
| | | ); |
| | | console.log(`选中的 ${filterKey} 集合 (tempId):`, selectedSet); |
| | | |
| | | this.exaLists.forEach(row => { |
| | |
| | | return; |
| | | } |
| | | const shouldSelect = selectedSet.has(row.tempId); |
| | | console.log(`行 tempId: ${row.tempId}, ${filterKey}: ${row[filterKey]},是否选中: ${shouldSelect}`); |
| | | this.$refs.firstTable.toggleRowSelection(row, shouldSelect, false); |
| | | console.log(`行 tempId: ${row.tempId}, ${filterKey}: ${row[filterKey]}, 是否选中: ${shouldSelect}`); |
| | | this.$refs.firstTable.toggleRowSelection(row, shouldSelect); |
| | | }); |
| | | |
| | | if (!this.isFetchingRightTableData) { |
| | |
| | | this.fetchRightTableData().finally(() => { |
| | | this.isFetchingRightTableData = false; |
| | | }); |
| | | } |
| | | } else { |
| | | console.log('无选中行,清空 checkList'); |
| | | this.checkList = []; |
| | | } |
| | | }); |
| | | }, |