qx
2025-06-11 eef7c19891e437ef18e79ced890d6aaf0db6113d
src/views/doctor/inspectCheck/index.vue
@@ -87,6 +87,8 @@
  dicts: ["dict_tj_status"],
  data() {
    return {
        isProcessing: false, // 防止死循环
    isDeselection: false, // 标记是否为取消选中
      infoList: {},
      dis: false,
      code: null,
@@ -170,76 +172,49 @@
      return !row.brid ? "row-disabled" : "";
    },
    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); */
handleSelectionChange(val) {
  this.selectedFirstTable = val;
      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('检测到取消选中,清空所有选择');
          this.exaLists.forEach(row => {
            if (!row.brid) {
              console.warn(`名称为 ${row.name} 的行没有申请单号,跳过选择`);
              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
            .filter(row => row[filterKey] === filterValue)
            .map(item => item.tempId));
          console.log(`选中的 ${filterKey} 集合 (tempId):`, selectedSet);
          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, false);
          });
          if (!this.isFetchingRightTableData) {
            this.isFetchingRightTableData = true;
            this.fetchRightTableData().finally(() => {
              this.isFetchingRightTableData = false;
            });
          }
        } else {
          console.log('无选中行,清空 checkList');
          this.checkList = [];
        }
  this.$nextTick(() => {
    if (val.length === 0) {
      console.log('无选中行,清空选择和 checkList');
      this.checkList = [];
      this.exaLists.forEach(row => {
        this.$refs.firstTable && this.$refs.firstTable.toggleRowSelection(row, false);
      });
    },
      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);
    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);
    });
    if (!this.isFetchingRightTableData) {
      this.isFetchingRightTableData = true;
      this.fetchRightTableData().finally(() => {
        this.isFetchingRightTableData = false;
      });
    }
  });
},
    fetchRightTableData() {
      const code = this.queryParams.tjNum;