1
wwl
2025-03-05 cb1f69717eed3b6a61b6c61a8934bac752782b2d
src/views/sampling/sampling/index.vue
@@ -14,17 +14,17 @@
          format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-"
          start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions"></el-date-picker>
      </el-form-item>
      <el-form-item label="单位名称" prop="tjCompName" style="margin-left: 20px; margin-right: 500px">
      <el-form-item label="单位名称" prop="compName" style="margin-left: 20px; margin-right: 500px">
        <el-select :remote-method="getRemoteData" v-model="queryParams.tjCompName" value-key="drugManufacturerId"
          style="width: 200px" remote filterable placeholder="请选择单位名称" clearable @change="searchSelect">
          <el-option v-for="dict in CompanyList" :key="dict.drugManufacturerId" :label="dict.cnName" :value="dict" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="是否采样" prop="isSignFor">
                    <el-select style="width:100px" v-model="queryParams.isSignFor" placeholder="是否采样">
                    <el-select1 style="width:100px" v-model="queryParams.isSignFor" placeholder="是否采样">
                            <el-option v-for="dict in dict.type.sampling_type" :key="dict.value" :label="dict.label"
                                :value="dict.value"></el-option>
                        </el-select>
                        </el-select1>
            </el-form-item> -->
      <!-- <el-form-item label="体检时间" prop="tjTime">
                <el-date-picker clearable v-model="queryParams.tjTime" type="date" value-format="yyyy-MM-dd"
@@ -95,7 +95,7 @@
            </template>
          </el-table-column>
          <el-table-column label="手机号" align="center" prop="cusPhone" width="120px" />
          <el-table-column label="单位名称" align="center" prop="firmName" width="120px" />
          <el-table-column label="单位名称" align="center" prop="compName" width="120px" />
          <el-table-column label="申请时间" align="center" prop="applicationTime" width="210">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.applicationTime) }}</span>
@@ -249,7 +249,7 @@
      piliangList: [],
      msg: "",
      getNumbr: null,
      valueUrl: "ws://192.168.1.138:6789/websocket",
      valueUrl: "ws://127.0.0.1:6789/websocket",
      webSocket: null,
      list: [],
      selectList: [],
@@ -378,7 +378,7 @@
    // 选框数据
    searchSelect(val) {
      this.CheckBox = val;
      this.queryParams.dw = this.CheckBox.cnName;
      this.queryParams.dw = this.CheckBox.drugManufacturerId;
      console.log(this.CheckBox, 9999);
    },
    getRemoteData(query) {
@@ -393,27 +393,60 @@
      }
    },
    async piliangPrint() {
      for (const item of this.piliangList) {
        try {
          // 获取数据,并等待数据更新完成
          const tableList = await this.fetchData(item.tjNumber);
      // 检查是否有选中的数据
      if (this.piliangList.length === 0) {
        this.$message.warning('请先选择要打印的数据');
        return;
      }
          // 只保留最新两个元素
          if (tableList.length > 0) {
            this.selectList = tableList.slice(0, 2);
          } else {
            this.selectList = []; // 如果没有数据,清空selectList
      const loadingInstance = this.$loading({
        lock: true,
        text: '打印中...',
        spinner: 'el-icon-loading',
        background: 'rgba(255, 255, 255, 0.7)'
      });
      try {
        for (const item of this.piliangList) {
          try {
            // 获取数据,并等待数据更新完成
            const tableList = await this.fetchData(item.tjNumber);
            // 检查 tableList 是否有数据
            if (!tableList || tableList.length === 0) {
              console.error(`体检号 ${item.tjNumber} 无相关数据`);
              continue;
            }
            // 直接使用所有数据
            this.selectList = tableList;
            // 检查 selectList 是否有数据
            if (this.selectList.length === 0) {
              console.error(`体检号 ${item.tjNumber} 的 selectList 为空,跳过 WebSocket 操作`);
              continue;
            }
            // 使用更新后的 tableList 获取 ids
            let ids = this.selectList.map(row => row.id);
            if (ids.length === 0) {
              console.error(`体检号 ${item.tjNumber} 无有效 ID`);
              continue;
            }
            // 确认采样
            await this.Confirmreceipt1(ids);
            // 等待一段时间
            await new Promise(resolve => setTimeout(resolve, 5000));
          } catch (error) {
            console.error(`处理体检号 ${item.tjNumber} 时出错:`, error);
          }
          // 使用更新后的tableList获取ids
          let ids = this.selectList.map(row => row.id);
          await this.Confirmreceipt1(ids);
          // 等待一段时间
          await new Promise(resolve => setTimeout(resolve, 5000));
        } catch (error) {
          console.error(`处理体检号 ${item.tjNumber} 时出错:`, error);
        }
      } finally {
        this.ids = []; // 清空 ids
        this.selectList = []; // 清空 selectList
        loadingInstance.close();
      }
    },
    getTruncatedName(proName) {
@@ -615,11 +648,14 @@
      const selectedCount = selection.length;
      const totalCount = this.samplingList.length;
      // 如果只有一条数据,不要禁用选择
      if (selectedCount === 1 && totalCount === 1) {
      // 如果只有一条数据,不要禁用选择,并展示右侧列表
      if (selectedCount === 1) {
        this.disableSelections = false;
      } else if (selectedCount === totalCount && selectedCount > 0) {
        const selectedPerson = selection[0];
        const tjNumber = selectedPerson.tjNumber;
        console.log(`选中的体检号: ${tjNumber}`);
        this.fetchData(tjNumber);
      } else if (selectedCount === totalCount && selectedCount > 1) {
        // 全选时禁用选择新行
        this.disableSelections = true;
        this.tableList = [];
@@ -627,13 +663,7 @@
      } else {
        // 非全选时启用选择
        this.disableSelections = false;
        if (selectedCount === 1) {
          const selectedPerson = selection[0];
          const tjNumber = selectedPerson.tjNumber;
          console.log(`选中的体检号: ${tjNumber}`);
          this.fetchData(tjNumber);
        } else if (selectedCount > 1) {
        if (selectedCount > 1) {
          // 保留单选功能,取消多选
          let del_row = selection.shift();
          this.$refs.tb.toggleRowSelection(del_row, false);