wwl
2025-04-23 2ba7ab0ee950b3be4607f280889c0daf4ec6c99f
src/views/sampling/sampling/index.vue
@@ -105,8 +105,9 @@
      </div>
      <div style="width: 50%">
        <!-- v-if="this.rightTabShow" -->
        <el-table v-if="tableList.length > 0" v-loading="loading" :data="tableList" @selection-change="handleChange"
          :span-method="objectSpanMethod" ref="tab1" :row-class-name="tableRowClassName" border height="520px">
        <el-table :key="tableKey" :row-key="getRowKey" v-if="tableList.length > 0" v-loading="loading" :data="tableList"
          @selection-change="handleChange" :span-method="objectSpanMethod" ref="tab1"
          :row-class-name="tableRowClassName" border height="520px">
          <el-table-column type="selection" width="40" align="center" />
          <!--  :selectable="selectEnable" -->
          <!-- <el-table-column label="是否签收" align="center" prop="isSignFor" /> -->
@@ -298,6 +299,7 @@
        proName: null,
      },
      startTime: "",
      tableKey: "",
      pickerOptions: {
        shortcuts: [
          {
@@ -532,6 +534,7 @@
      return ""; // 如果 applicationTime 无效,返回空字符串
    },
    /** 查询体检采样管理列表 */
    /** 查询体检采样管理列表 */
    getList() {
      this.queryParams.compId = this.CheckBox.drugManufacturerId;
      this.loading1 = true;
@@ -550,10 +553,11 @@
        if (response.data && response.data.list && response.data.list.length > 0) {
          this.samplingList = response.data.list;
          this.total = response.data.total;
          this.$nextTick(() => {
            this.$refs.tb.toggleRowSelection(this.samplingList[0], true); // 默认选中第一行
            this.fetchData(this.samplingList[0].tjNumber); // 刷新右侧表格
          });
          // 移除默认选中第一行的逻辑
          // this.$nextTick(() => {
          //   this.$refs.tb.toggleRowSelection(this.samplingList[0], true); // 默认选中第一行
          //   this.fetchData(this.samplingList[0].tjNumber); // 刷新右侧表格
          // });
        } else {
          this.samplingList = [];
          this.tableList = [];
@@ -602,8 +606,19 @@
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.createTimeList = [];
      this.handleQuery();
      this.createTimeList = []; // 清空日期范围
      this.queryParams.tjNumber = null; // 清空体检号
      this.queryParams.name = null; // 清空姓名
      this.queryParams.tjCompName = null; // 清空单位名称
      this.selectList = []; // 清空右侧选中项
      this.selectedRows = []; // 清空左侧选中项
      this.tableList = []; // 清空右侧表格数据
      this.ids = []; // 清空选中的 ID
      this.$refs.tb.clearSelection(); // 清空左侧表格选中状态
      if (this.$refs.tab1) {
        this.$refs.tab1.clearSelection(); // 清空右侧表格选中状态
      }
      this.handleQuery(); // 重新查询
    },
    handleSelectionChange(selection) {
@@ -647,6 +662,11 @@
      // 调试日志
      console.log(`当前选中数量: ${selectedCount}`);
      console.log(`是否禁用选择: ${this.disableSelections}`);
    },
    getRowKey(row) {
      return row.id; // 必须唯一且稳定
    },
    fetchData(tjNumber) {
@@ -656,13 +676,18 @@
          .then((response) => {
            if (response.data) {
              this.tableList = response.data;
              this.tableKey = Date.now()
              this.$nextTick(() => {
                this.$refs.elTable.doLayout(); // 通过 ref 调用表格方法
                if (this.$refs.tab1) {
                  this.$refs.tab1.clearSelection(); // 清空之前的选中状态
                  this.$refs.tab1.doLayout(); // 修改为正确的 ref 名称
                  this.$refs.tab1.clearSelection(); // 清空选中状态
                  const headerCheckbox = this.$refs.tab1.$el.querySelector('.el-table__header .el-checkbox');
                  if (headerCheckbox) headerCheckbox.style.display = 'inline';
                }
              });
              resolve(this.tableList);
              this.loading = false;
            } else {
              this.tableList = [];
              this.selectList = [];
@@ -910,6 +935,7 @@
      };
      websocket.onopen = () => {
        this.websocket = websocket;
        console.log(this.selectList, "this.selectList")
        this.dayinData = this.selectList.map((item) => ({
          jyxh: item.jyxh,
          proName: item.proName,
@@ -919,6 +945,8 @@
          cardId: item.cardId,
          tjTime: item.createTime,
        }));
        // 连接设备
        this.jsonObj = {
          type: "3",
@@ -927,7 +955,12 @@
          },
        };
        var jStr = JSON.stringify(this.jsonObj);
        console.log(jStr, "jStr");
        this.websocket.send(jStr);
        this.$refs.tab1.clearSelection(); // 清除右侧表格的选中状态
        this.selectList = []; // 清空 selectList
        this.ids = []; // 清空 ids
        this.jsonObj = {};
        // this.dialogVisible = false;
      };
@@ -945,9 +978,7 @@
        .then((res) => {
          if (res.code === 200) {
            this.buda(); // 打印条码
            this.$refs.tab1.clearSelection(); // 清除右侧表格的选中状态
            this.selectList = []; // 清空 selectList
            this.ids = []; // 清空 ids
            this.getList(); // 刷新左侧表格
            console.log("采样后 - selectList:", this.selectList, "qiehuan:", this.qiehuan);
          } else {
@@ -978,6 +1009,7 @@
        });
    },
    // 单选按钮
    // 单选按钮
    radioChange(value) {
      this.loading = true;
      this.queryParams.isSignFor = value;
@@ -990,13 +1022,14 @@
          } else {
            this.samplingList = response.data.list;
            this.loading = false;
            if (this.samplingList.length != 0) {
              this.$nextTick(() => {
                this.$refs.tb.toggleRowSelection(this.samplingList[0], true);
              });
            } else {
              this.$refs.tb.clearSelection();
            }
            // 移除默认选中第一行的逻辑
            // if (this.samplingList.length != 0) {
            //   this.$nextTick(() => {
            //     this.$refs.tb.toggleRowSelection(this.samplingList[0], true);
            //   });
            // } else {
            //   this.$refs.tb.clearSelection();
            // }
          }
          this.total = response.data.total;
          this.loading = false;
@@ -1058,7 +1091,7 @@
<style>
#ta .el-table__header-wrapper .el-checkbox {
  /* display: none; */
  display: none;
}
.el-table .warning-row {