zhuo
2025-05-20 7eb190f13437b2e67788e9f4bdea725fdb165f01
src/views/business/inspectionTask/inspection.vue
@@ -1,5 +1,5 @@
<template>
  <div v-loading="loading" class="inspection">
  <div v-loading="loading" class="inspection" style="background-color: rgb(245, 247, 251);">
    <el-row class="title">
      <el-col :span="8" style="text-align: left">
        <el-form :inline="true" :model="otherForm" class="form-inline" label-width="50px"
@@ -17,21 +17,18 @@
        </el-form>
      </el-col>
      <el-col :span="16" style="text-align: right">
        <!-- <el-button size="small" type="primary" @click="refreshView">刷新</el-button> -->
        <el-button v-if="typeSource === 1" size="small" type="primary" @click="openPurchase">进货验证</el-button>
        <el-button v-if="state === 1 && typeSource === 1" size="small" type="primary"
        <el-button size="small" type="primary" @click="refreshView">刷新</el-button>
        <el-button v-if="typeSource == 1" size="small" type="primary" @click="openPurchase">进货验证</el-button>
        <el-button v-if="state == 1 && typeSource == 1" size="small" type="primary"
          @click="openUnPassDialog('add')">不合格处理</el-button>
        <el-button size="small" type="primary" @click="
          sampleVisible = true;
        uploadSample();
        ">样品切换</el-button>
        <el-button v-if="state == 1" size="small" type="primary" @click="taskVisible = true">任务切换</el-button>
        <el-button size="small" type="primary" @click="sampleVisible = true; uploadSample();">样品切换</el-button>
        <!--        <el-button v-if="state == 1" size="small" type="primary" @click="taskVisible = true">任务切换</el-button>-->
        <el-button v-if="state == 1" size="small" type="primary" @click="addVerifyDia = true">提交</el-button>
        <!-- 复核 -->
        <el-button v-if="state == 2" size="medium" type="primary" @click="openAddCheck">通过</el-button>
        <el-button v-if="state == 2" size="medium" @click="upInsReview(0)">不通过</el-button>
        <el-button type="primary" size="small" @click="exportTable('myTable')">下载原始记录</el-button>
        <el-button size="small" @click="$emit('goback')">返回</el-button>
        <el-button size="small" @click="goback">返回</el-button>
      </el-col>
    </el-row>
    <div class="search">
@@ -73,12 +70,11 @@
        </el-form-item>
        <el-form-item label="备注:">
          <!--          <span style="color:red">{{ insOrder.remark?insOrder.remark:'-' }}</span>-->
          <el-input v-model="insOrder.remark" :disabled="state !== 1" clearable placeholder="请输入" size="small"
          <el-input v-model="insOrder.remark" :disabled="state != 1" clearable placeholder="请输入" size="small"
            @blur="subOtherForm(insOrder.remark, 'remark')"></el-input>
          <!-- <el-tag v-if="currentKey">{{ insOrder.remark }}</el-tag> -->
        </el-form-item>
      </el-form>
      <el-divider></el-divider>
    </div>
    <div class="center">
      <div class="search" style="
@@ -95,8 +91,8 @@
          </el-radio-group>
        </div>
        <div style="display: flex; align-items: center">
          <el-button v-if="state === 1" size="small" type="primary" @click="openAddUnpass">新增不合格复测</el-button>
          <el-button v-if="state === 1" size="small" type="primary" @click="unpassCheck">不合格复测</el-button>
          <el-button v-if="state == 1" size="small" type="primary" @click="openAddUnpass">新增不合格复测</el-button>
          <el-button v-if="state == 1" size="small" type="primary" @click="unpassCheck">不合格复测</el-button>
          <el-button v-if="state > 1" size="small" type="primary" @click="viewUnpassCheck">查看不合格复测</el-button>
          <span v-if="cableTagList.length > 0">&nbsp;&nbsp;电缆配置:</span>
          <el-select v-if="cableTagList.length > 0" v-model="currentTab" clearable placeholder="请选择" size="small"
@@ -292,7 +288,7 @@
                      state == 1
                    "><span :style="`font-family:${n.v.ff} !important;`">{{
                      toFixed(n.v.v, n.v.ct)
                        }}</span></template>
                    }}</span></template>
                    <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '最终值' &&
@@ -339,7 +335,7 @@
      </div>
      <el-upload v-if="state == 1" ref="upload" :action="action" :before-upload="beforeUpload" :data="{
        orderId: id,
      }" :headers="headers" :on-error="onError" :on-success="handleSuccessUp" :show-file-list="false"
      }" :headers="uploadHeader" :on-error="onError" :on-success="handleSuccessUp" :show-file-list="false"
        accept=".jpg,.jpeg,.png,.gif,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.pdf,.zip,.rar"
        style="width: 80px !important;margin-top: 10px;">
        <el-button v-if="state == 1" size="small" type="primary">附件上传</el-button></el-upload>
@@ -348,6 +344,7 @@
    </div>
    <el-drawer :size="550" :visible.sync="sampleVisible" title="样品切换">
      <el-table v-if="sampleVisible" ref="productTable" :current-row-key="currentKey" :data="sampleProduct"
                :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
        :row-class-name="tableRowClassName" :row-key="(record) => record.index" border class="el-table" height="100%"
        highlight-current-row tooltip-effect="dark" @row-click="handleChangeSample">
        <el-table-column :key="Math.random()" align="center" label="序号" type="index" width="70px">
@@ -360,7 +357,6 @@
              size="medium" style="margin-right: 5px">{{ item.label }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="检验人" min-width="80px" prop="checkName" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="是否留样" prop="isLeave" show-overflow-tooltip width="95px">
          <template slot-scope="scope">
            <span>{{ scope.row.isLeave == 0 ? "否" : "是" }}</span>
@@ -505,44 +501,32 @@
        <el-button :loading="reviewLoading" type="primary" @click="upInsReview(1)">确 定</el-button>
      </span>
    </el-dialog>
    <!-- <add-un-pass v-if="addUnPassDialog" ref="addUnPassDialog" :addUnPassDialog="addUnPassDialog"
      @resetAddUnPass="resetAddUnPass"></add-un-pass> -->
    <!-- <UnPassDialog
      v-if="unPassDialog"
      ref="unPassDialog"
      :orderId="orderId"
      :unPassDialog="unPassDialog"
      @resetForm="resetForm"
    ></UnPassDialog> -->
    <!-- <InspectionWord
      v-if="unPassCheck"
      :inspectorList="inspectorList"
      :orderId="orderId"
      :rawMaterialTag="rawMaterialTag"
      :sonLaboratory="sonLaboratory"
      :state="state"
      :typeSource="typeSource"
      :unPassCheck="unPassCheck"
      @closeUnPassCheckDialog="closeUnPassCheckDialog"
      @refreshView="refreshView"
    /> -->
    <!-- <purchase-verification
      v-if="purchaseDialog"
      ref="purchaseDialog"
      :orderId="orderId"
      :purchaseDialog="purchaseDialog"
      @resetPurchaseDialog="resetPurchaseDialog"
    ></purchase-verification> -->
    <!-- 添加不合格复测弹框-->
    <add-un-pass v-if="addUnPassDialog" ref="addUnPassDialog" :addUnPassDialog="addUnPassDialog"
      @resetAddUnPass="resetAddUnPass"></add-un-pass>
    <!-- 不合格处理弹框-->
    <UnPassDialog v-if="unPassDialog" ref="unPassDialog" :orderId="orderId" :unPassDialog="unPassDialog"
      @resetForm="resetForm"></UnPassDialog>
    <!-- 不合格复测弹框-->
    <InspectionWord v-if="unPassCheck" :inspectorList="inspectorList" :orderId="orderId"
                    :cableTag="temCableTag" :repetitionTag="repetitionTag"
      :rawMaterialTag="rawMaterialTag" :sonLaboratory="sonLaboratory" :state="state" :typeSource="typeSource"
      :unPassCheck="unPassCheck" @closeUnPassCheckDialog="closeUnPassCheckDialog" @refreshView="refreshView" />
    <!-- 进货验证弹框-->
    <purchase-verification v-if="purchaseDialog" ref="purchaseDialog" :orderId="orderId"
      :purchaseDialog="purchaseDialog" @resetPurchaseDialog="resetPurchaseDialog"></purchase-verification>
    <!--查看工时弹框-->
    <viewManHourDia ref="viewManHourDia" @submit="openAddVerifyDia"></viewManHourDia>
  </div>
</template>
<script>
import excelFunction from "@/utils/excelFountion";
import limsTable from "@/components/Table/lims-table.vue";
// import UnPassDialog from "../b1-unpass-manage/unPassDialog.vue";
// import AddUnPass from "../b1-unpass-manage/addUnPass.vue";
// import InspectionWord from "./InspectionWord.vue";
// import PurchaseVerification from "../b1-unpass-manage/PurchaseVerification.vue";
import UnPassDialog from "../unpass/components/unPassDialog.vue";
import AddUnPass from "../unpass/components/addUnPass.vue";
import InspectionWord from "./components/InspectionWord.vue";
import PurchaseVerification from "../unpass/components/PurchaseVerification.vue";
import {
  doInsOrder,
  getCableTag,
@@ -562,18 +546,20 @@
  delfile,
  inspectionOrderDetailsTaskSwitching
} from "@/api/business/inspectionTask.js";
import InspectionWorker from '../../../InspectionWorker.worker';
import DataWorker from '../../../DataWorker.worker';
import InspectionWorker from '@/workers/InspectionWorker.worker';
import DataWorker from '../../../workers/DataWorker.worker';
import html2canvas from "html2canvas";
import { mapGetters } from "vuex";
import viewManHourDia from "@/views/business/inspectionTask/components/viewManHourDia.vue";
export default {
  // props: ["sonLaboratory", "orderId", "state", "inspectorList", "typeSource"],
  name: 'Inspection',
  components: {
    // PurchaseVerification,
    // AddUnPass,
    viewManHourDia,
    PurchaseVerification,
    AddUnPass,
    limsTable,
    // UnPassDialog,
    // InspectionWord,
    UnPassDialog,
    InspectionWord,
  },
  data() {
    return {
@@ -789,11 +775,6 @@
  // 用于上传文件的信息
  computed: {
    ...mapGetters(["userId"]),
    headers() {
      return {
        token: sessionStorage.getItem("token"),
      };
    },
    action() {
      return this.javaApi + "/insOrderPlan/uploadFile";
    },
@@ -813,73 +794,23 @@
    this.getInsStateDicts();
    this.getComparisonList();
    this.getAuthorizedPerson();
    // this.getPower();
    this.startWorker();
    this.getList0()
    // this.getList0() // 任务切换
    this.scrollInit();
  },
  activated() {
    this.getTypeDicts(); // 获取紧急程度下拉框选项
    this.getInsStateDicts();
    this.getComparisonList();
    this.getAuthorizedPerson();
    this.startWorker();
    // this.getList0() // 任务切换
    this.scrollInit();
  },
  watch: {
    // 监听任务id,获取任务信息
    id(val) {
      this.loading = true;
      doInsOrder({
        id: val,
        laboratory: this.sonLaboratory,
      }).then(async (res) => {
        this.insOrder = res.data.insOrder;
        this.supplierDensity = res.data.supplierDensity;
        this.getList()
        this.urgentList.forEach((m) => {
          if (m.value == this.insOrder.type) {
            this.insOrder.typeName = m.label;
          }
        });
        this.loading = false;
        if (!res.data.sampleProduct || res.data.sampleProduct.length == 0) {
          this.$emit("goback");
          return this.$message.error("该任务没有样品信息");
        }
        // 赋值当前样品列表
        this.sampleProduct = res.data.sampleProduct;
        this.currentSample = this.HaveJson(this.sampleProduct[0]);
        let insProduct = this.HaveJson(this.currentSample.insProduct);
        // 温度、湿度赋值
        this.otherForm = {
          temperature: this.insOrder.temperature
            ? this.insOrder.temperature
            : null,
          humidity: this.insOrder.humidity ? this.insOrder.humidity : null,
        };
        if (this.typeSource == "1") {
          this.getRawMaterialTag(this.currentSample.id); // 原材料的检验任务查询批数
          this.rawMaterialTag = "1";
        }
        this.getEquipOptions(1);
        // 获取当前样品的检验项
        let list = await this.getCurrentProduct(this.currentSample.id, 0);
        this.currentSample.insProduct = this.HaveJson(list);
        // 初始化传递到后端的参数
        this.param = {};
        this.changeType = 0;
        this.currentSample.insProduct.forEach((a) => {
          this.param[a.id] = {
            insValue: [],
            comValue: [],
            resValue: null,
            equipValue: [],
            equipName: [],
            insResult: null,
          };
        });
        if (this.currentSample.index == undefined)
          this.currentSample["index"] = 1;
        let bushing = this.currentSample.bushing;
        this.getTableLists(); //处理模板列表信息
        this.currentKey = 1;
        this.getCableTag(this.currentSample.id); // 查询是否有要多次检验的电缆配置
        this.getRepetitionTag(this.currentSample.id); // 查询是否有要重复检验项
      });
      this.refreshView()
    },
    // 监听当前模板变化
    currentTable(val1, val0) {
@@ -974,15 +905,12 @@
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          delfile({ id: row.id }).then((res) => {
            if (res.code == 201) return;
            this.$message.success("删除成功");
            this.refresh();
          });
        })
        .catch(() => { });
      }).then(() => {
        delfile({ id: row.id }).then((res) => {
          this.$message.success("删除成功");
          this.getList();
        });
      }).catch(() => { });
    },
    // 文件管理--结束
@@ -1009,9 +937,67 @@
      this.checkUser = "";
    },
    // 刷新页面
    // refreshView() {
    //   this.$emit("refreshView");
    // },
    refreshView() {
      this.loading = true;
      doInsOrder({
        id: this.id,
        laboratory: this.sonLaboratory,
      }).then(async (res) => {
        this.insOrder = res.data.insOrder;
        this.supplierDensity = res.data.supplierDensity;
        this.getList()
        this.urgentList.forEach((m) => {
          if (m.value == this.insOrder.type) {
            this.insOrder.typeName = m.label;
          }
        });
        this.loading = false;
        if (!res.data.sampleProduct || res.data.sampleProduct.length == 0) {
          this.goback();
          return this.$message.error("该任务没有样品信息");
        }
        // 赋值当前样品列表
        this.sampleProduct = res.data.sampleProduct;
        this.currentSample = this.HaveJson(this.sampleProduct[0]);
        let insProduct = this.HaveJson(this.currentSample.insProduct);
        // 温度、湿度赋值
        this.otherForm = {
          temperature: this.insOrder.temperature
            ? this.insOrder.temperature
            : null,
          humidity: this.insOrder.humidity ? this.insOrder.humidity : null,
        };
        if (this.typeSource == "1") {
          this.getRawMaterialTag(this.currentSample.id); // 原材料的检验任务查询批数
          this.rawMaterialTag = "1";
        }
        this.getEquipOptions(1);
        // 获取当前样品的检验项
        let list = await this.getCurrentProduct(this.currentSample.id, 0);
        this.currentSample.insProduct = this.HaveJson(list);
        // 初始化传递到后端的参数
        this.param = {};
        this.changeType = 0;
        this.currentSample.insProduct.forEach((a) => {
          this.param[a.id] = {
            insValue: [],
            comValue: [],
            resValue: null,
            equipValue: [],
            equipName: [],
            insResult: null,
          };
        });
        if (this.currentSample.index == undefined)
          this.currentSample["index"] = 1;
        let bushing = this.currentSample.bushing;
        this.getTableLists(); //处理模板列表信息
        this.currentKey = 1;
        this.getCableTag(this.currentSample.id); // 查询是否有要多次检验的电缆配置
        this.getRepetitionTag(this.currentSample.id); // 查询是否有要重复检验项
      });
    },
    closeUnPassCheckDialog() {
      this.unPassCheck = false;
    },
@@ -1057,8 +1043,9 @@
        id: this.currentSample.id,
        type: this.type,
        laboratory: this.sonLaboratory,
        cableTag: "",
        cableTag: this.temCableTag,
        rawMaterialTag: this.rawMaterialTag,
        repetitionTag: this.repetitionTag,
      };
      this.$nextTick(() => {
        this.$refs.addUnPassDialog.getInsOrder(info);
@@ -1090,7 +1077,7 @@
    },
    // 打开进货验证弹框
    openPurchase() {
      const operationType = this.state === 1 ? "add" : "view";
      const operationType = this.state == 1 ? "add" : "view";
      this.purchaseDialog = true;
      const item = {
        id: this.currentSample.id,
@@ -1130,6 +1117,8 @@
        this.dataAcquisitionInfoNew = this.HaveJson(res.data);
        // 对数采回来的值进行处理
        this.handleDataAcquisition(res.data);
      }).catch(err => {
        this.dataAcquisitionLoading = false;
      });
    },
    objectOrder(obj) {
@@ -1150,7 +1139,6 @@
      this.dataAcquisitionInfo = {};
      this.getData = [];
      for (let i in this.objectOrder(data)) {
        console.log("i---", i);
        let obj = {};
        if (i.includes("@")) {
          obj = {
@@ -1493,12 +1481,10 @@
    },
    // 保存湿度、温度数据
    subOtherForm(m, type) {
      console.log("m---", m);
      write({
        [type]: type === "remark" ? m : Number(m),
        id: this.insOrder.id,
      }).then((res) => {
        if (res.code == 201) return;
        this.$message.success("保存成功");
      });
    },
@@ -1517,34 +1503,6 @@
        a.download = "table.png";
        a.click();
      });
    },
    // 权限获取
    getPower() {
      let power = JSON.parse(sessionStorage.getItem("power"));
      let fileDel = false;
      let fileAdd = false;
      let collected = false;
      let temDataAcquisition = false;
      for (var i = 0; i < power.length; i++) {
        if (power[i].menuMethod == "uploadFile") {
          fileAdd = true;
        }
        if (power[i].menuMethod == "delfile") {
          fileDel = true;
        }
        if (power[i].menuMethod == "isItAllowedToModifyTheCollectedValues") {
          collected = true;
        }
        if (power[i].menuMethod == "temDataAcquisition") {
          temDataAcquisition = true;
        }
      }
      if (!fileDel) {
        // this.componentData0.do.splice(1, 1);
      }
      this.fileAdd = fileAdd;
      this.collected = collected;
      this.temDataAcquisition = temDataAcquisition;
    },
    uploadSample() {
      doInsOrder({
@@ -1683,20 +1641,6 @@
        this.comparisonList = this.dictToValue(response.data);
      });
    },
    // 获取检验值为下拉时的下拉列表
    // selectEnumByCategoryOfSelect(val) {
    //   this.enumList = [];
    //   if (val === undefined || val === null) {
    //     return;
    //   }
    //   this.$axios
    //     .post(this.$api.enums.selectEnumByCategory, {
    //       category: val,
    //     })
    //     .then((res) => {
    //       this.enumList = res.data;
    //     });
    // },
    tableRowClassName({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
@@ -2565,7 +2509,7 @@
        }).then((res) => {
          if (res.code === 200) {
            this.$message.success("操作成功");
            this.$emit("goback");
            this.goback();
            this.addCheck = false;
          }
          this.reviewLoading = false;
@@ -2590,7 +2534,7 @@
        }).then((res) => {
          if (res.code === 200) {
            this.$message.success("操作成功");
            this.$emit("goback");
            this.goback();
          }
          this.reviewLoading = false;
        })
@@ -2601,6 +2545,13 @@
      } else {
        this.$message.error("未输入不通过原因");
      }
    },
    // 查看工时
    viewManHour() {
      this.$refs.viewManHourDia.showDialog(this.id, 99);
    },
    openAddVerifyDia() {
      this.addVerifyDia = true;
    },
    submit() {
      if (this.verifyUser === null || this.verifyUser === "") {
@@ -2631,7 +2582,7 @@
            }).then((res) => {
              if (res.code === 200) {
                this.$message.success("操作成功");
                this.$emit("goback");
                this.goback();
                this.submitLoading = false;
                this.addVerifyDia = false;
              }
@@ -2683,7 +2634,7 @@
                  if (res.code === 200) {
                    this.$message.success("操作成功");
                    this.addVerifyDia = false;
                    this.$emit("goback");
                    this.goback();
                  }
                  this.submitLoading = false;
                })
@@ -2712,17 +2663,24 @@
          } else {
            param = this.param;
          }
          let isNoTestValue = ''
          for (let key in param) {
            if (param[key]) {
              if (param[key].insValue?.length === 0) {
                isNoTestValue = 1
              } else {
                isNoTestValue = ''
              }
            }
          }
          saveInsContext({
            param: JSON.stringify(param),
            currentTable: this.currentTable,
            sampleId: this.currentSample.id,
            orderId: this.orderId,
            sonLaboratory: this.sonLaboratory
            sonLaboratory: this.sonLaboratory,
            isNoTestValue: isNoTestValue
          }).then((res) => {
            if (res.code == 201) {
              this.$message.error("保存失败");
              return;
            }
            this.$message.success("已保存");
          });
          // 向 Worker 发送消息,开始处理逻辑
@@ -2790,7 +2748,7 @@
      }
    },
    getAuthorizedPerson() {
      selectUserCondition({ type: 0 }).then((res) => {
      selectUserCondition({ type: 1 }).then((res) => {
        let data = [];
        res.data.forEach((a) => {
          data.push({
@@ -2874,7 +2832,7 @@
      this.upLoading = false;
      if (response.code == 200) {
        this.$message.success("上传成功");
        this.$refs.fileList.selectList();
        this.getList();
      }
    },
    beforeUpload(file) {
@@ -2893,16 +2851,7 @@
    },
    handleDown(row) {
      downFile({ id: row.id }).then((res) => {
        if (res.code === 200) {
          let url = "";
          if (res.data.type == 1) {
            url = this.javaApi + "/img/" + res.data.fileUrl;
            this.$download.saveAs(url, row.fileName)
          } else {
            url = this.javaApi + "/word/" + res.data.fileUrl;
            this.$download.saveAs(url, row.fileName)
          }
        }
        this.$download.saveAs(res.data.fileUrl, row.fileName)
      })
        .catch((error) => { });
    },
@@ -2926,14 +2875,13 @@
        return v;
      }
    },
    goback() {
      this.$router.go(-1)
    }
  },
};
</script>
<style scoped>
>>>.el-divider {
  margin: 0 !important;
}
.custom-table .el-table__header-wrapper th {
  background-color: #87ceeb;
  /* 只对带有my-custom-table类的表格生效 */
@@ -2969,6 +2917,7 @@
  width: 100%;
  background-color: #fff;
  border-radius: 3px;
  margin-bottom: 10px;
}
.search .form-inline {
@@ -3064,7 +3013,7 @@
}
.content-h-2 {
  justify-content: end;
  justify-content: flex-end;
}
.content-v-0 {
@@ -3135,10 +3084,10 @@
  align-items: center;
}
</style>
<style>
.inspection .el-form-item__label {
<style scoped>
/* .inspection .el-form-item__label {
  color: #000;
}
} */
.inspection .el-drawer__header::before {
  content: "";