qx
qx
2025-04-14 5350514e716d3383fa3923a007fecac5b1ea365a
src/views/sampling/sampling/index.vue
@@ -104,9 +104,10 @@
        </el-table>
      </div>
      <div style="width: 50%">
        <!-- v-if="this.rightTabShow"  v-if="tableList.length > 0"-->
        <el-table  v-loading="loading" :data="tableList" @selection-change="handleChange" :span-method="objectSpanMethod"
          ref="elTable" :row-class-name="tableRowClassName" border height="520px">
        <!-- v-if="this.rightTabShow" -->
        <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" /> -->
@@ -197,7 +198,7 @@
                :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div> -->
    <div style="margin-right: 63%">
    <div style="margin-right: 50%">
      <!-- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :pager-count="5" :current-page.sync="currentPage1" :current-page="page"
                :page-sizes="pageSize" :page-size="size" layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination> -->
@@ -211,7 +212,12 @@
<script>
import {
  listSampling,
  getSampling,
  getList,
  delSampling,
  addSampling,
  updateSampling,
  confirmSampling,
  getCusCyList,
  mergeCaiYang,
@@ -222,8 +228,10 @@
import { getNewDateList } from "@/api/hosp/order";
import moment from "moment";
import {
  SubmitCompany,
  getCompany,
  queryCompany,
  addbatch,
} from "@/api/team/tuanti";
export default {
  dicts: [
@@ -237,6 +245,7 @@
  data() {
    return {
      CheckBox: {},
      CompanyList: [],
      piliangList: [],
      msg: "",
@@ -256,6 +265,7 @@
      tjStatus: "1",
      dayinData: [],
      jsonObj: {},
      // 非单个禁用
      single: true,
      // 非多个禁用
@@ -322,19 +332,23 @@
      },
      // 表单参数
      form: {},
      tableKey: "",
      // 表单校验
      rules: {},
      // rightTabShow: false
      allSelected: false,
      disableSelections: false, // 控制选择禁用状态
    };
  },
  created() {
    // this.getNowTime();
    getTxmmccd().then((res) => {
      this.msg = Number(res.msg);
      console.log(res, 444);
    });
    getCompany(this.queryParams).then((response) => {
      this.CompanyList = response.data;
      this.loading = false;
    });
    this.getdate();
@@ -520,6 +534,7 @@
      return ""; // 如果 applicationTime 无效,返回空字符串
    },
    /** 查询体检采样管理列表 */
    /** 查询体检采样管理列表 */
    getList() {
      this.queryParams.compId = this.CheckBox.drugManufacturerId;
      this.loading1 = true;
@@ -528,68 +543,40 @@
      if (this.createTimeList) {
        this.queryParams.beginTime = this.createTimeList[0];
        this.queryParams.endTime = this.createTimeList[1];
      } else if (this.createTimeList == null) {
      } else {
        this.queryParams.beginTime = null;
        this.queryParams.endTime = null;
      }
      getList(this.queryParams).then((response) => {
        this.loading1 = false;
        if (response.data) {
          if (!response.data.list || response.data.list.length === 0) {
            this.samplingList = [];
            this.tableList = [];
            this.loading1 = false;
            this.loading = false;
            return;
          } else {
            this.samplingList = response.data.list;
            // 判断是否需要刷新右边表格
            this.$nextTick(() => {
              this.$refs.tb.toggleRowSelection(this.samplingList[0], true);
              // 检查是否全选
              if (this.samplingList.length === this.selectedRows.length) {
                this.disableSelections = true;
              } else {
                this.disableSelections = false;
              }
            });
          }
        if (response.data && response.data.list && response.data.list.length > 0) {
          this.samplingList = response.data.list;
          this.total = response.data.total;
          this.loading1 = false;
        } else {
          this.samplingList = [];
          this.tableList = [];
          this.loading1 = false;
        }
      });
          this.$nextTick(() => {
            if (this.$refs.tb) {
      /* getList(this.queryParams).then((response) => {
        if (response.data) {
          if (response.data.list == null) {
            this.samplingList = [];
            this.tableList = [];
            this.loading = false;
          } else {
            this.samplingList = response.data.list;
            console.log(this.samplingList,888);
            this.loading = false;
            if (this.samplingList.length != 0) {
              this.$nextTick(() => {
                this.$refs.tb.toggleRowSelection(this.samplingList[0], true);
              });
            } else {
              this.$refs.tb.clearSelection();
              const headerCheckbox = this.$refs.tb.$el.querySelector('.el-table__header .el-checkbox');
              if (headerCheckbox) headerCheckbox.style.display = 'none';
            }
          }
          this.total = response.data.total;
          this.loading = false;
          });
          // 移除默认选中第一行的逻辑
          // this.$nextTick(() => {
          //   this.$refs.tb.toggleRowSelection(this.samplingList[0], true); // 默认选中第一行
          //   this.fetchData(this.samplingList[0].tjNumber); // 刷新右侧表格
          // });
        } else {
          this.samplingList = [];
          this.tableList = [];
          this.loading = false;
          this.selectList = []; // 清空 selectList
          this.ids = []; // 清空 ids
          if (this.$refs.tab1) {
            this.$refs.tab1.clearSelection(); // 清空右侧表格选中状态
          }
        }
      }); */
        this.loading1 = false;
      });
    },
    // 取消按钮
    cancel() {
@@ -627,8 +614,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) {
@@ -674,6 +672,10 @@
      console.log(`是否禁用选择: ${this.disableSelections}`);
    },
    getRowKey(row) {
      return row.id; // 必须唯一且稳定
    },
    fetchData(tjNumber) {
      return new Promise((resolve, reject) => {
        this.loading = true;
@@ -681,12 +683,24 @@
          .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.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 = [];
              this.ids = [];
              if (this.$refs.tab1) {
                this.$refs.tab1.clearSelection();
              }
              resolve([]);
            }
          })
@@ -907,10 +921,7 @@
    },
    handleChange(selection) {
      // console.log(selection);
      this.selectList = selection;
      console.log(this.selectList, 9977);
      var array = selection;
      this.ids = array.map((item) => item.id);
    },
@@ -930,6 +941,7 @@
      };
      websocket.onopen = () => {
        this.websocket = websocket;
        console.log(this.selectList, "this.selectList")
        this.dayinData = this.selectList.map((item) => ({
          jyxh: item.jyxh,
          proName: item.proName,
@@ -939,6 +951,8 @@
          cardId: item.cardId,
          tjTime: item.createTime,
        }));
        // 连接设备
        this.jsonObj = {
          type: "3",
@@ -947,7 +961,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;
      };
@@ -956,23 +975,24 @@
    // 确认采样
    Confirmreceipt() {
      const loadingInstance = this.$loading({
        lock: true, // 锁定屏幕
        text: "加载中...", // 加载文本
        spinner: "el-icon-loading", // 自定义加载图标
        background: "rgba(255, 255, 255, 0.7)", // 背景颜色
        lock: true,
        text: "加载中...",
        spinner: "el-icon-loading",
        background: "rgba(255, 255, 255, 0.7)",
      });
      confirmSampling(this.ids)
        .then((res) => {
          console.log(this.selectList, 2222);
          if (res.code === 200) {
            this.buda();
            this.getList();
            this.buda(); // 打印条码
            this.getList(); // 刷新左侧表格
            console.log("采样后 - selectList:", this.selectList, "qiehuan:", this.qiehuan);
          } else {
            this.$message.error(res.msg);
          }
        })
        .catch((error) => {
          console.error("采样失败:", error);
        })
        .finally(() => {
          loadingInstance.close();
@@ -995,6 +1015,7 @@
        });
    },
    // 单选按钮
    // 单选按钮
    radioChange(value) {
      this.loading = true;
      this.queryParams.isSignFor = value;
@@ -1006,14 +1027,23 @@
            this.loading = false;
          } 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();
            this.$nextTick(() => {
            if (this.$refs.tb) {
              const headerCheckbox = this.$refs.tb.$el.querySelector('.el-table__header .el-checkbox');
              if (headerCheckbox) headerCheckbox.style.display = 'none';
            }
          });
            this.loading = false;
            // 移除默认选中第一行的逻辑
            // 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;