gaoluyang
9 天以前 fcadf16afa65a8a5ca53a33c4b8f4bf2efe2ea03
src/views/business/inspectionTask/inspection.vue
@@ -1,7 +1,7 @@
<template>
  <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-col v-if="insOrder.ifsOrderType!=='02wg'" :span="8" style="text-align: left">
        <el-form :inline="true" :model="otherForm" class="form-inline" label-width="50px"
          style="text-align: right; padding-top: 0; display: inline">
          <el-form-item label="温度:" style="margin-bottom: 0">
@@ -16,12 +16,14 @@
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="16" style="text-align: right">
      <el-col :span="insOrder.ifsOrderType!=='02wg'?16:24" style="text-align: right">
        <el-button v-if="insOrder.ifsOrderType && insOrder.ifsOrderType==='02wg'" size="small" type="primary" @click="showMaterialPropsDialog">IFS物料属性更新</el-button>
        <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 v-if="state == 1 && [0,1].includes(Number(typeSource))" 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 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>
@@ -31,49 +33,104 @@
      </el-col>
    </el-row>
    <div class="search">
      <el-form :inline="true" :model="searchForm" class="form-inline" label-position="right" label-width="100px">
        <el-form-item label="委托编号:">
          <el-input v-model="insOrder.entrustCode" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item label="样品编号:">
          <el-tooltip :content="currentSample.sampleCode" :disabled="!currentSample.sampleCode">
            <el-input v-model="currentSample.sampleCode" clearable disabled placeholder="请输入" size="small"></el-input>
          </el-tooltip>
        </el-form-item>
        <el-form-item label="样品名称:">
          <el-input v-model="currentSample.sample" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item label="样品数量:">
          <el-input v-model="sampleProduct.length" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item label="样品型号:">
          <el-input v-model="currentSample.model" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item label="下发时间:">
          <el-input v-model="insOrder.sendTime" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item label="紧急程度:">
          <el-input v-model="insOrder.typeName" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item label="约定时间:">
          <el-input v-model="insOrder.appointed" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item v-if="typeSource === 1" label="抽检数量:">
          <el-input v-model="insOrder.testQuantity" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item v-if="typeSource === 1" label="厂家密度:">
          <el-input v-model="supplierDensity" clearable disabled placeholder="请输入" size="small"></el-input>
        </el-form-item>
        <el-form-item label="当前样品位数:" label-width="120px">
          <el-tag v-if="currentKey">{{ `NO.${currentKey}` }}</el-tag>
        </el-form-item>
        <el-form-item label="备注:">
          <!--          <span style="color:red">{{ insOrder.remark?insOrder.remark:'-' }}</span>-->
<!--      <el-form :inline="true" :model="searchForm" class="form-inline" label-position="right" label-width="100px">-->
<!--        <el-form-item label="委托编号:">-->
<!--          <el-input v-model="insOrder.entrustCode" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="样品编号:">-->
<!--          <el-tooltip :content="currentSample.sampleCode" :disabled="!currentSample.sampleCode">-->
<!--            <el-input v-model="currentSample.sampleCode" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--          </el-tooltip>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="样品名称:">-->
<!--          <el-input v-model="currentSample.sample" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="样品数量:">-->
<!--          <el-input v-model="sampleProduct.length" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="样品型号:">-->
<!--          <el-input v-model="currentSample.model" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="下发时间:">-->
<!--          <el-input v-model="insOrder.sendTime" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="紧急程度:">-->
<!--          <el-input v-model="insOrder.typeName" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="约定时间:">-->
<!--          <el-input v-model="insOrder.appointed" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item v-if="typeSource === 1" label="抽检数量:">-->
<!--          <el-input v-model="insOrder.testQuantity" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item v-if="typeSource === 1" label="厂家密度:">-->
<!--          <el-input v-model="supplierDensity" clearable disabled placeholder="请输入" size="small"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="当前样品位数:" label-width="120px">-->
<!--          <el-tag v-if="currentKey">{{ `NO.${currentKey}` }}</el-tag>-->
<!--        </el-form-item>-->
<!--        <el-form-item label="备注:">-->
<!--          &lt;!&ndash;          <span style="color:red">{{ insOrder.remark?insOrder.remark:'-' }}</span>&ndash;&gt;-->
<!--          <el-input v-model="insOrder.remark" :disabled="state != 1" clearable placeholder="请输入" size="small"-->
<!--            @blur="subOtherForm(insOrder.remark, 'remark')"></el-input>-->
<!--          &lt;!&ndash; <el-tag v-if="currentKey">{{ insOrder.remark }}</el-tag> &ndash;&gt;-->
<!--        </el-form-item>-->
<!--        <template v-if="insOrder.isSplitOrder && insOrder.isSplitOrder===1">-->
<!--          <el-form-item label="外护颜色:">-->
<!--            <el-input v-model="insOrder.outerColor" clearable disabled placeholder="" size="small"></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="绝缘颜色:">-->
<!--            <el-input v-model="insOrder.insulationColor" clearable disabled placeholder="" size="small"></el-input>-->
<!--          </el-form-item>-->
<!--          <el-form-item label="盘号:">-->
<!--            <el-input v-model="insOrder.drumNo" clearable disabled placeholder="" size="small"></el-input>-->
<!--          </el-form-item>-->
<!--        </template>-->
<!--      </el-form>-->
      <el-descriptions title="检验单概况" :column="4" border>
        <template v-if="insOrder.ifsOrderType">
          <el-descriptions-item label="零件号">{{insOrder.partNo}}</el-descriptions-item>
          <el-descriptions-item label="零件名称">{{insOrder.partDetail}}</el-descriptions-item>
          <el-descriptions-item label="批次号">{{ insOrder.lotBatchNo }}</el-descriptions-item>
          <el-descriptions-item label="抽检数量">{{insOrder.testQuantity}}</el-descriptions-item>
          <el-descriptions-item label="厂家密度">{{supplierDensity}}</el-descriptions-item>
          <template v-if="insOrder.ifsOrderType && insOrder.ifsOrderType==='02wg'">
            <el-descriptions-item label="载具编号">{{insOrder.drumNo}}</el-descriptions-item>
            <el-descriptions-item label="起始米标(km)">{{insOrder.startMeterMark}}</el-descriptions-item>
            <el-descriptions-item label="截止米标(km)">{{insOrder.endMeterMark}}</el-descriptions-item>
            <el-descriptions-item label="入库长度(km)">{{calcInbondLength(insOrder.startMeterMark,insOrder.endMeterMark)}}</el-descriptions-item>
            <el-descriptions-item label="绝缘颜色">{{insOrder.insulationColor}}</el-descriptions-item>
            <el-descriptions-item label="外护颜色">{{insOrder.outerColor}}</el-descriptions-item>
            <el-descriptions-item label="印字信息">{{insOrder.letteringInfo}}</el-descriptions-item>
          </template>
        </template>
        <template v-else>
          <el-descriptions-item label="委托编号">{{ insOrder.entrustCode }}</el-descriptions-item>
          <el-descriptions-item label="样品编号">{{ currentSample.sampleCode }}</el-descriptions-item>
          <el-descriptions-item label="样品名称">{{ currentSample.sample }}</el-descriptions-item>
          <el-descriptions-item label="样品数量">{{ insOrder.testQuantity }}</el-descriptions-item>
          <el-descriptions-item label="下发时间">{{ insOrder.sendTime }}</el-descriptions-item>
          <el-descriptions-item label="紧急程度">{{ insOrder.typeName }}</el-descriptions-item>
          <el-descriptions-item label="约定时间">{{ insOrder.appointed }}</el-descriptions-item>
        </template>
        <el-descriptions-item label="当前样品位数"><el-tag v-if="currentKey">{{ `NO.${currentKey}` }}</el-tag></el-descriptions-item>
        <el-descriptions-item label="备注">
          <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>
                    @blur="subOtherForm(insOrder.remark, 'remark')"></el-input>
        </el-descriptions-item>
        <el-descriptions-item v-if="isDirectTemplateOrder()" label="设备" :span="2">
          <el-select v-model="selectedDeviceIds" multiple filterable clearable size="small" placeholder="请选择设备"
            :disabled="state != 1" @change="saveOverviewDevices">
            <el-option v-for="device in orderDeviceOptions" :key="device.id" :label="device.label" :value="device.id" />
          </el-select>
        </el-descriptions-item>
        <el-descriptions-item label="检验结论">
          <el-radio-group v-model="reviewInsResult" :disabled="state != 2">
            <el-radio :label="1">合格</el-radio>
            <el-radio :label="0">不合格</el-radio>
          </el-radio-group>
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <div class="center">
      <div class="search" style="
@@ -97,7 +154,7 @@
          <el-select v-if="cableTagList.length > 0" v-model="currentTab" clearable placeholder="请选择" size="small"
            @change="(m) => handleChangeCableTag(currentSample.id, 0, 'cableTag', m)
              " @focus="getCableTag(currentSample.id)">
            <el-option v-for="item in cableTagList" :key="item.cableTag" :label="item.cableTag" :value="item.cableTag">
            <el-option v-for="(item, index) in cableTagList" :key="index" :label="item.cableTag" :value="item.cableTag">
              <span style="float: left">{{ item.cableTag }}</span>
              <el-tag v-if="item.status == 0" size="small" style="float: right; margin-top: 5px"
                type="danger">未检</el-tag>
@@ -112,7 +169,7 @@
            size="small" @change="(m) =>
              handleChangeCableTag(currentSample.id, 0, 'repetitionTag', m)
              " @focus="getRepetitionTag(currentSample.id)">
            <el-option v-for="item in repetitionTagList" :key="item.repetitionTag" :label="item.radius"
            <el-option v-for="(item, index) in repetitionTagList" :key="index" :label="item.radius"
              :value="item.repetitionTag">
              <span style="float: left">{{ item.radius }}</span>
              <el-tag v-if="item.status == 0" size="small" style="float: right; margin-top: 5px"
@@ -126,7 +183,7 @@
          <span v-if="typeSource == '1'">&nbsp;&nbsp;待检验数量:</span>
          <el-select v-if="typeSource == '1'" v-model="rawMaterialTag" placeholder="请选择" size="small" @change="(m) => handleChangeCableTag(currentSample.id, 4, 'cableTag', m)
            " @focus="getRawMaterialTag(currentSample.id)">
            <el-option v-for="item in rawMaterialTagList" :key="item.rawMaterialTag" :label="item.rawMaterialTag"
            <el-option v-for="(item, index) in rawMaterialTagList" :key="index" :label="item.rawMaterialTag"
              :value="item.rawMaterialTag">
              <span style="float: left">{{ item.rawMaterialTag }}</span>
              <el-tag v-if="item.status == 0" size="small" style="float: right; margin-top: 5px"
@@ -172,7 +229,9 @@
                      n.v.ps.value.includes('检验值') &&
                      state == 1
                    ">
                      <el-input v-if="getInspectionValueType(n.i) == 1"
                      <el-input v-if="getInspectionValueType(n.i) == 1 ||
                        (getInspectionValueType(n.i) != 2 && getInspectionValueType(n.i) != 4)
                        "
                        :key="'abc-' + '000' + index + '000' + i + '000' + j" v-model="n.v.v" :disabled="(getInspectionItemType(n.i) == 1 &&
                          !dataAcquisitionEidtAble) ||
                          (n.u != userId && n.u != undefined && n.u != '')
@@ -202,68 +261,13 @@
                            'getDataType'
                          )
                          " />
                      <!-- <el-select v-else-if="getInspectionValueType(n.i) == 5" v-model="n.v.v" :disabled="state > 1 ||
                      getInspectionItemType(n.i) == 1 ||
                      (n.u != userId && n.u != undefined && n.u != '')
                      " class="table_input" @change="(m) =>
                        changeInput(
                          m,
                          `${item.templateId}-${n.r}-${n.c}-${n.i}`,
                          n,
                          'getDataType'
                        )
                        " @visible-change="(e) => getDic(e, n.i)">
                      <el-option v-for="(e, i) in enumList" :key="i" :label="e.label" :value="e.value"></el-option>
                    </el-select> -->
                      <span v-else-if="getInspectionValueType(n.i) == 4"
                        :style="`font-family:${n.v.ff} !important;`">/</span>
                    </template>
                    <template v-else-if="n.v.ps != undefined && n.v.ps.value === '结论'">
                      <el-select v-if="
                        (getInspectionValueType(n.i) == 2 ||
                          getInspectionValueType(n.i) == 5) &&
                        state == 1
                      " v-model="n.v.v" class="table_input" @change="(m) =>
                        changeInput(
                          m,
                          `${item.templateId}-${n.r}-${n.c}-${n.i}`,
                          n,
                          'getDataType',
                          'changeSelect'
                        )
                        ">
                        <el-option :value="1" label="合格"></el-option>
                        <el-option :value="0" label="不合格"></el-option>
                        <el-option :value="3" label="不判定"></el-option>
                        <el-option :value="2" label="待定"></el-option>
                      </el-select>
                      <template v-if="state > 1">
                        <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">合格</span>
                        <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">不合格</span>
                        <span v-else-if="n.v.v === 3"
                          :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">不判定</span>
                        <span v-else :style="`font-family:${n.v.ff} !important;`">待定</span>
                      </template>
                      <template v-if="getInspectionValueType(n.i) != 2 &&
                        state == 1">
                        <span v-if="n.v.v === 1" :style="`font-family:${n.v.ff} !important;color: green;`">合格</span>
                        <span v-else-if="n.v.v === 0" :style="`font-family:${n.v.ff} !important;color: red;`">不合格</span>
                        <span v-else-if="n.v.v === 3"
                          :style="`font-family:${n.v.ff} !important;color: #3A7BFA;`">不判定</span>
                        <span v-else :style="`font-family:${n.v.ff} !important;`">待定</span>
                      </template>
                    </template>
                    <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '设备编码' &&
                      state == 1
                    ">
                      <span>{{ n.v.v }}</span>
                    </template>
                    <template v-else-if="
                      n.v.ps != undefined && n.v.ps.value === '设备名称'
                    ">
                      <el-select v-model="n.v.v" :disabled="state > 1" class="table_input" filterable multiple
                      <el-select v-model="n.v.v" :disabled="state > 1" class="table_input" filterable multiple clearable
                        placeholder="设备" remote @change="(val) => changeEquip(val, n)"
                        @visible-change="(e) => getEquipOptions(e, n.i)">
                        <el-option v-for="item in equipOptions" :key="item.value" :label="item.label"
@@ -274,20 +278,11 @@
                    </template>
                    <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '要求值' &&
                      state == 1
                    ">
                      <span :style="`font-family:${n.v.ff} !important;`">{{
                        getTell(n.i)
                      }}</span>
                    </template>
                    <template v-else-if="
                      n.v.ps != undefined &&
                      n.v.ps.value === '计算值' &&
                      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 === '最终值' &&
@@ -343,6 +338,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">
@@ -499,25 +495,76 @@
        <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"
                    :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>
    <!--    IFS物料属性编辑弹框-->
    <el-dialog
      title="更新IFS库存物料批次属性"
      :visible.sync="ifsMaterialPropsVisible"
      width="20%">
      <el-form style="width:100%" :model="ifsMaterialPropsForm">
        <el-form-item label="载具编号(Attr1):">
          <el-input placeholder="载具编号" size="small" v-model="ifsMaterialPropsForm.drumNo"></el-input>
        </el-form-item>
        <el-form-item label="起始米标(Attr2):">
          <el-input @blur="validateQuality()" placeholder="起始米标" size="small" v-model="ifsMaterialPropsForm.startMeterMark">
            <span slot="suffix">km</span>
          </el-input>
        </el-form-item>
        <el-form-item label="截止米标(Attr3):">
          <el-input @blur="validateQuality()" placeholder="截止米标" size="small" v-model="ifsMaterialPropsForm.endMeterMark">
            <span slot="suffix">km</span>
          </el-input>
        </el-form-item>
        <!--        <el-form-item label="入库长度">-->
        <!--          <el-input v-model="ifsMaterialPropsForm.inboundLength"></el-input>-->
        <!--        </el-form-item>-->
        <el-form-item label="外护颜色(Attr4):">
          <el-select size="small" v-model="ifsMaterialPropsForm.outerColor">
            <el-option v-for="(item,index) in outerColorList" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="绝缘颜色(Attr5):">
          <el-select size="small" v-model="ifsMaterialPropsForm.insulationColor">
            <el-option v-for="(item,index) in insulationColorList" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="印字信息(Attr8):">
          <el-select size="small" v-model="ifsMaterialPropsForm.letteringInfo" placeholder="请选择">
            <el-option v-for="(item,index) in letteringInfoList" :label="item.dictLabel" :value="item.dictValue" :key="index"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="closePartPropDialog()">取 消</el-button>
    <el-button type="primary" @click="saveOrUpdatePartProp()">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
import excelFunction from "@/utils/excelFountion";
import limsTable from "@/components/Table/lims-table.vue";
import UnPassDialog from "../unpass/components/addUnPass.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 {getOneByIfsId,saveOrUpdateProps} from "@/api/business/ifsPartProps.js";
import {
  doInsOrder,
  getCableTag,
@@ -531,19 +578,25 @@
  checkSubmitPlan,
  submitPlan,
  saveInsContext,
  saveTemplateContext,
  getOrderDevices,
  saveOrderDevices,
  selectUserCondition,
  downFile,
  getFileList,
  delfile,
  inspectionOrderDetailsTaskSwitching
} from "@/api/business/inspectionTask.js";
import InspectionWorker from '../../../InspectionWorker.worker';
import DataWorker from '../../../DataWorker.worker';
import InspectionWorker from '@/workers/InspectionWorker.worker.js';
import DataWorker from '@/workers/DataWorker.worker.js';
import html2canvas from "html2canvas";
import { mapGetters } from "vuex";
import viewManHourDia from "@/views/business/inspectionTask/components/viewManHourDia.vue";
import {getDicts} from "@/api/system/dict/data";
export default {
  name: 'inspection',
  name: 'Inspection',
  components: {
    viewManHourDia,
    PurchaseVerification,
    AddUnPass,
    limsTable,
@@ -552,6 +605,21 @@
  },
  data() {
    return {
      outerColorList:[],
      insulationColorList:[],
      letteringInfoList: [],
      ifsMaterialPropsForm:{
        id:null,
        ifsInventoryId: null,
        drumNo: '', // 载具编号
        startMeterMark: '', // 起始米标
        endMeterMark: '', // 截止米标
        insulationColor: '', // 绝缘颜色
        outerColor: '', // 外护颜色
        inboundLength: '', // 入库长度
        letteringInfo: '', // 印字信息
      },
      ifsMaterialPropsVisible:false,
      sonLaboratory: null,
      orderId: null,
      state: null,
@@ -595,9 +663,12 @@
      comparisonList: [],
      excelMethodList: [],
      equipOptions: [],
      orderDeviceOptions: [],
      selectedDeviceIds: [],
      reviewLoading: false,
      reviewDia: false,
      noReason: "",
      reviewInsResult: null,
      tableWidth: 1000,
      currentTable: null,
      tableLists: [],
@@ -627,6 +698,10 @@
      result: null,
      worker: null,
      worker0: null,
      // 检验值按触发顺序串行保存,避免同一检验项的旧请求覆盖新请求。
      saveQueue: null,
      calculationRevision: 0,
      completedCalculationRevision: 0,
      wareLength: [],
      dataAcquisitionInfo: {},
      dataAcquisitionInfoNew: {},
@@ -724,7 +799,6 @@
        size: 10,
        current: 0,
      },
      tableLoading: false,
      // 文件列表相关--结束
      // 任务切换列表--开始
      tableData0: [],
@@ -769,6 +843,7 @@
    },
  },
  created() {
    this.saveQueue = Promise.resolve();
    let { sonLaboratory, orderId, state, inspectorList, typeSource } =
      this.$route.query;
    this.sonLaboratory = sonLaboratory;
@@ -783,7 +858,15 @@
    this.getInsStateDicts();
    this.getComparisonList();
    this.getAuthorizedPerson();
    // this.getPower();
    this.startWorker();
    // this.getList0() // 任务切换
    this.scrollInit();
  },
  activated() {
    this.getTypeDicts(); // 获取紧急程度下拉框选项
    this.getInsStateDicts();
    this.getComparisonList();
    this.getAuthorizedPerson();
    this.startWorker();
    // this.getList0() // 任务切换
    this.scrollInit();
@@ -794,8 +877,9 @@
      this.refreshView()
    },
    // 监听当前模板变化
    currentTable(val1, val0) {
    async currentTable(val1, val0) {
      if (val0 != null && val1 != val0) {
        await this.waitForPendingSaves();
        if (this.changeType && this.changeType > 0) {
          // 如果是光纤、光纤带,则不执行下面操作
          return;
@@ -804,17 +888,7 @@
          if (m.templateId == val1) {
            let list = await this.getCurrentProduct(this.currentSample.id, 0);
            this.currentSample.insProduct = this.HaveJson(list); //赋值当前样品的检验项
            this.param = {}; //初始化传到后端的参数
            this.currentSample.insProduct.forEach((a, j) => {
              this.param[a.id] = {
                insValue: [],
                comValue: [],
                resValue: null,
                equipValue: [],
                equipName: [],
                insResult: null,
              };
            });
            this.param = {}; //初始化传到后端的参数,按“模板id + 单元格坐标”存
            // 去重模板,返回有几个模板
            const mySet1 = new Set();
            this.tableLists = this.currentSample.insProduct.filter((m) => {
@@ -859,6 +933,87 @@
    this.stopWorker();
  },
  methods: {
    validateQuality(){
      let inboundLength = Number(this.calcInbondLength(this.ifsMaterialPropsForm.startMeterMark,this.ifsMaterialPropsForm.endMeterMark));
      let testQuantity = Number(this.insOrder.testQuantity);
      if(inboundLength!=null && testQuantity!==inboundLength){
        this.$message.warning(`入库长度(${inboundLength}km)与检验数量(${testQuantity}km)不符,请确认!`);
      }
    },
    calcInbondLength(startMeterMark,endMeterMark){
      let inboundLength = null;
      if((startMeterMark!=null && startMeterMark!=='') && (endMeterMark!=null&&endMeterMark!=='')){
        let minus = this.$Big(endMeterMark).minus(this.$Big(startMeterMark));
        inboundLength = Math.abs(minus)
      }
      return inboundLength;
    },
    getLetteringInfoDicts(){
      getDicts("lettering_info_type").then(res=>{
        if(res.code==200){
          this.letteringInfoList = res.data
        }
      })
    },
    getInsulationColorDicts(){
      getDicts("insulation_color_type").then(res=>{
        if(res.code==200){
          this.insulationColorList = res.data
        }
      })
    },
    getOuterColorDicts(){
      getDicts("outer_color_type").then(res=>{
        if(res.code==200){
          this.outerColorList = res.data
        }
      })
    },
    closePartPropDialog(){
      this.ifsMaterialPropsForm = {
        id:null,
        ifsInventoryId: null,
        drumNo: '', // 载具编号
        startMeterMark: '', // 起始米标
        endMeterMark: '', // 截止米标
        insulationColor: '', // 绝缘颜色
        outerColor: '', // 外护颜色
        inboundLength: '', // 入库长度
        letteringInfo: '', // 印字信息
      }
      this.ifsMaterialPropsVisible = false;
    },
    getPartProps(ifsId){
      getOneByIfsId(ifsId).then((res)=>{
        if(res.code==200 && res.data){
          this.ifsMaterialPropsForm = res.data;
        }
      })
    },
    saveOrUpdatePartProp(){
      this.ifsMaterialPropsForm.ifsInventoryId = this.insOrder.ifsInventoryId
      saveOrUpdateProps({
        ...this.ifsMaterialPropsForm,
        partNo: this.insOrder.partNo,
        lotBatchNo: this.insOrder.lotBatchNo,
      }).then((res)=>{
        if(res.code==200){
          this.$message.success("保存成功");
          this.ifsMaterialPropsVisible = false;
          this.refreshView()
        }
      })
    },
    //打开IFS物料属性弹框
    showMaterialPropsDialog(){
      this.getPartProps(this.insOrder.ifsInventoryId)
      this.getOuterColorDicts()
      this.getInsulationColorDicts()
      this.getLetteringInfoDicts()
      this.$nextTick(()=>{
        this.ifsMaterialPropsVisible = true;
      })
    },
    // 文件管理--开始
    getList() {
      this.tableLoading = true;
@@ -886,15 +1041,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(() => { });
    },
    // 文件管理--结束
@@ -921,13 +1073,19 @@
      this.checkUser = "";
    },
    // 刷新页面
    refreshView() {
    async refreshView() {
      await this.waitForPendingSaves();
      this.loading = true;
      doInsOrder({
        id: this.id,
        laboratory: this.sonLaboratory,
      }).then(async (res) => {
        this.insOrder = res.data.insOrder;
        this.reviewInsResult = this.insOrder.insResult;
        if(res.data.insOrder.ifsOrderType==='02wg'){
          //查询零件属性
          this.getPartProps(res.data.insOrder.ifsInventoryId)
        }
        this.supplierDensity = res.data.supplierDensity;
        this.getList()
        this.urgentList.forEach((m) => {
@@ -956,22 +1114,15 @@
          this.rawMaterialTag = "1";
        }
        this.getEquipOptions(1);
        if (this.sonLaboratory === "新聚") {
          this.loadOverviewDevices();
        }
        // 获取当前样品的检验项
        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;
@@ -1027,8 +1178,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);
@@ -1122,7 +1274,6 @@
      this.dataAcquisitionInfo = {};
      this.getData = [];
      for (let i in this.objectOrder(data)) {
        console.log("i---", i);
        let obj = {};
        if (i.includes("@")) {
          obj = {
@@ -1465,12 +1616,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("保存成功");
      });
    },
@@ -1489,34 +1638,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({
@@ -1549,6 +1670,7 @@
    },
    // 切换样品
    async handleChangeSample(row, column, event) {
      await this.waitForPendingSaves();
      // 初始化数据
      this.param = {};
      this.sampleVisible = false;
@@ -1560,16 +1682,6 @@
      // 初始化后端传参
      this.param = {};
      this.changeType = 0;
      this.currentSample.insProduct.forEach((a, j) => {
        this.param[a.id] = {
          insValue: [],
          comValue: [],
          resValue: null,
          equipValue: [],
          equipName: [],
          insResult: null,
        };
      });
      // 处理页面列表数据
      this.getTableLists();
      this.currentKey = row.index;
@@ -1605,16 +1717,6 @@
        let list = await this.getCurrentProduct(m, type, cableTag);
        if (list && list.length > 0) {
          this.param = {};
          list.forEach((a) => {
            this.param[a.id] = {
              insValue: [],
              comValue: [],
              resValue: null,
              equipValue: [],
              equipName: [],
              insResult: null,
            };
          });
          this.getTableLists0(list);
          this.worker.postMessage(
            JSON.stringify({
@@ -1655,20 +1757,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;
    },
@@ -1772,209 +1860,18 @@
          count++;
        });
      });
      // 本次循环主要是控制合并,以及控制检验项信息是否展示出来,以便后续检验
      // 按后端下发的“模板ID + 模板行号”直接绑定检验项,不做名称比对,不隐藏任何行
      this.tableList.forEach((a) => {
        let dels = new Set(); //需要删除的行
        let ids = []; //所有检验项的id
        let set3 = new Set();
        a.template.forEach((b) => {
          let size1 = set3.size;
          let size2 = set3.add(b.r).size;
          if (size1 < size2) {
            let str = "";
            let str2 = "";
            let unit2 = "";
            let count4 = 0;
            let isThree = 0;
            a.template.forEach((c) => {
              // 获取到 检验项分类+检验项+检验子项的拼接,如果模板里的信息跟接口返回的检验项信息能够匹配则展示出来
              if (b.r === c.r) {
                if (
                  c.v.ps != undefined &&
                  c.v.ps.value === "检验项分类" &&
                  count4 === 0
                ) {
                  // 三级分类
                  isThree = 1;
                } else if (
                  c.v.ps != undefined &&
                  c.v.ps.value === "检验项" &&
                  count4 === 0
                ) {
                  // 二级分类
                  isThree = 0;
                }
                if (isThree == 0) {
                  if (c.v.ps != undefined && c.v.ps.value === "检验项") {
                    if (count4 === 0) {
                      if (c.v.v) {
                        c.v.v = c.v.v.replace(/\s*/g, "");
                      }
                      str += c.v.v;
                      count4 += 1;
                    }
                  } else if (
                    c.v.ps != undefined &&
                    c.v.ps.value === "检验子项"
                  ) {
                    if (count4 === 1) {
                      if (c.v.v) {
                        c.v.v = c.v.v.replace(/\s*/g, "");
                      }
                      str += c.v.v;
                      count4 += 1;
                    }
                  }
                } else if (isThree == 1) {
                  if (c.v.ps != undefined && c.v.ps.value === "检验项分类") {
                    if (count4 === 0) {
                      if (c.v.v) {
                        c.v.v = c.v.v.replace(/\s*/g, "");
                      }
                      str += c.v.v;
                      count4 += 1;
                    }
                  } else if (c.v.ps != undefined && c.v.ps.value === "检验项") {
                    if (count4 === 1) {
                      if (c.v.v) {
                        c.v.v = c.v.v.replace(/\s*/g, "");
                      }
                      str += c.v.v;
                      count4 += 1;
                    }
                  } else if (
                    c.v.ps != undefined &&
                    c.v.ps.value === "检验子项"
                  ) {
                    if (count4 === 2) {
                      if (c.v.v) {
                        c.v.v = c.v.v.replace(/\s*/g, "");
                      }
                      str += c.v.v;
                      count4 += 1;
                    }
                  }
                }
                if (str === "机械性能干态拉伸强度(纵向)") {
                  if (c.v.ps != undefined && c.v.ps.value === "单位") {
                    if (c.v.v) {
                      c.v.v = c.v.v.replace(/\s*/g, "");
                    }
                    str2 = str + c.v.v;
                    unit2 = c.v.v;
                  }
                }
              }
            });
            if (str != "") {
              let count2 = 0;
              for (let i in this.currentSample.insProduct) {
                let inspectionItemClass =
                  this.currentSample.insProduct[i].inspectionItemClass ==
                    null ||
                    this.currentSample.insProduct[i].inspectionItemClass ==
                    undefined
                    ? ""
                    : this.currentSample.insProduct[i].inspectionItemClass;
                inspectionItemClass = inspectionItemClass.replace(/\s*/g, "");
                let inspectionItem =
                  this.currentSample.insProduct[i].inspectionItem == null ||
                    this.currentSample.insProduct[i].inspectionItem == undefined
                    ? ""
                    : this.currentSample.insProduct[i].inspectionItem;
                inspectionItem = inspectionItem.replace(/\s*/g, "");
                let inspectionItemSubclass =
                  this.currentSample.insProduct[i].inspectionItemSubclass ==
                    null ||
                    this.currentSample.insProduct[i].inspectionItemSubclass ==
                    undefined
                    ? ""
                    : this.currentSample.insProduct[i].inspectionItemSubclass;
                inspectionItemSubclass = inspectionItemSubclass.replace(
                  /\s*/g,
                  ""
                );
                if (inspectionItemSubclass === "干态拉伸强度(纵向)") {
                  // 检验子项为'干态拉伸强度(纵向)'时,模版里是两个计算值对应相同的检验值并且计算方式不同,要根据相同的'单位'做特殊的渲染
                  const unit = this.currentSample.insProduct[i].unit;
                  if (
                    (this.currentSample.insProduct[i].templateId ===
                      a.templateId &&
                      inspectionItemClass +
                      inspectionItem +
                      inspectionItemSubclass +
                      unit ===
                      str2) ||
                    (this.currentSample.insProduct[i].templateId ===
                      a.templateId &&
                      !unit2.includes("/") &&
                      inspectionItemClass +
                      inspectionItem +
                      inspectionItemSubclass ===
                      str)
                  ) {
                    ids.push({
                      r: b.r,
                      id: this.currentSample.insProduct[i].id,
                      product: this.currentSample.insProduct[i],
                    });
                    break;
                  }
                } else {
                  // 如果相等,那么说明找到了,并且把id存起来,后续检验项也会在页面中显示出来
                  if (
                    this.currentSample.insProduct[i].templateId ===
                    a.templateId &&
                    inspectionItemClass +
                    inspectionItem +
                    inspectionItemSubclass ===
                    str
                  ) {
                    ids.push({
                      r: b.r,
                      id: this.currentSample.insProduct[i].id,
                      product: this.currentSample.insProduct[i],
                    });
                    break;
                  }
                }
                count2++;
              }
              if (count2 == this.currentSample.insProduct.length) {
                dels.add(b.r);
              }
        const directProducts = this.currentSample.insProduct.filter(
          (product) => product.templateId === a.templateId &&
            product.templateRowIndex !== null && product.templateRowIndex !== undefined
        );
        directProducts.forEach((product) => {
          a.template.forEach((cell) => {
            if (cell.r === product.templateRowIndex) {
              cell.i = product.id;
            }
          }
        });
        // 操作删除
        dels.forEach((del) => {
          for (let b = 0; b < a.template.length; b++) {
            if (a.template[b].r === del) {
              a.template.splice(b, 1);
              b -= 1;
            }
          }
        });
        // 操作赋值--主要赋值单位,试验方法等信息
        ids.forEach((id) => {
          for (let b = 0; b < a.template.length; b++) {
            if (a.template[b].r === id.r) {
              a.template[b].i = id.id;
              if (
                a.template[b].v.ps != undefined &&
                a.template[b].v.ps.value === "单位"
              ) {
                a.template[b].v.v = id.product.unit;
              }
              if (
                a.template[b].v.ps != undefined &&
                (a.template[b].v.ps.value === "试验方法" ||
                  a.template[b].v.ps.value === "检测方法")
              ) {
                a.template[b].v.v = id.product.methodS;
              }
            }
          }
          });
        });
        let set2 = new Set();
        // 合并的数据处理,cs  rs  代表合并的数量
@@ -1997,20 +1894,11 @@
          }
        });
      });
      // 本次循环主要是对后端传参进行初始化,样式逻辑修改
      // 本次循环主要做样式逻辑处理,可编辑单元格初始化
      this.tableList.forEach((a) => {
        let arrs = [];
        let set = new Set();
        let count1 = 0;
        let conclusionList = []; //结论列表
        let finalList = []; //最终值列表
        // 结论与最终值在这里一一对应,以下两个列表长度肯定是一样的,如果有不一样,那么多半是模板配置得问题
        conclusionList = a.template.filter(
          (n) => n.v.ps != undefined && n.v.ps.value === "结论"
        ); //结论列表
        finalList = a.template.filter(
          (n) => n.v.ps != undefined && n.v.ps.value === "最终值"
        ); //最终值列表
        a.template.forEach((b) => {
          if (
            b.v.ps != undefined &&
@@ -2021,61 +1909,18 @@
            count1++;
            b.v.v = count1;
          }
          if (b.v.ps != undefined && b.v.ps.value === "要求值") {
            // 对要求值进行赋值
            b.v.v = this.getAsk(b.i);
          }
          // 对页面的和给后端传参的检验值,计算值,设备编码,设备名称,最终值,结论进行初始化
          // 初始化可填写/可计算单元格,后续按坐标回显
          if (
            b.v.ps != undefined &&
            typeof b.v.ps.value === "string" &&
            b.v.ps.value.includes("检验值")
            (b.v.ps.value.includes("检验值") ||
              b.v.ps.value === "计算值" ||
              b.v.ps.value === "最终值" ||
              b.v.ps.value === "设备名称")
          ) {
            this.$set(b.v, "v", "");
            // b.v.v = ''
            b.u = "";
            b.i && this.param[b.i] && this.param[b.i].insValue.push(b);
          }
          if (b.v.ps != undefined && b.v.ps.value === "计算值") {
            this.$set(b.v, "v", "");
            // b.v.v = ''
            b.i && this.param[b.i] && this.param[b.i].comValue.push(b);
          }
          if (b.v.ps != undefined && b.v.ps.value === "设备编码") {
            // b.v.v = ''
            this.$set(b.v, "v", "");
            b.i && this.param[b.i] && this.param[b.i].equipValue.push(b);
          }
          if (b.v.ps != undefined && b.v.ps.value === "设备名称") {
            this.$set(b.v, "v", "");
            // b.v.v = ''
            b.i && this.param[b.i] && this.param[b.i].equipName.push(b);
          }
          if (b.v.ps != undefined && b.v.ps.value === "最终值") {
            // b.v.v = ''
            this.$set(b.v, "v", "");
            if (
              b.i !== undefined &&
              this.param[b.i] &&
              !this.param[b.i].resValue
            ) {
              this.param[b.i].resValue = b;
            }
          }
          if (b.v.ps != undefined && b.v.ps.value === "结论") {
            if (
              b.i !== undefined &&
              this.param[b.i] &&
              !this.param[b.i].insResult
            ) {
              this.param[b.i].insResult = b;
              conclusionList.forEach((n, i) => {
                if (n.r == b.r && n.c == b.c) {
                  b.v.f = `(${this.comparisonList.find((j) => j.value == finalList[i].c)
                    .label
                    }${finalList[i].r + 1})`;
                }
              });
            if (b.v.ps.value.includes("检验值")) {
              b.u = "";
            }
          }
          set.add(b.r);
@@ -2103,110 +1948,56 @@
            a.style.columnlen[i] === undefined ? 100 : a.style.columnlen[i];
        }
      });
      // 本次循环主要是对页面及后端传参进行初始化赋值
      this.currentSample.insProduct.forEach(async (a) => {
        try {
          // 计算值赋值
          let comValue = JSON.parse(a.insProductResult.comValue);
          for (var i = 0; i < comValue.length; i++) {
            if (
              this.param[a.id].comValue.find(
                (m) => m.c == comValue[i].c && m.r == comValue[i].r
              )
            ) {
              this.param[a.id].comValue.find(
                (m) => m.c == comValue[i].c && m.r == comValue[i].r
              ).v.v = this.toFixed(
                comValue[i].v,
                this.param[a.id].comValue.find(
                  (m) => m.c == comValue[i].c && m.r == comValue[i].r
                ).v.ct
              );
            } else if (!comValue[i].c || !comValue[i].r) {
              this.param[a.id].comValue[i].v.v = this.toFixed(
                comValue[i].v,
                this.param[a.id].comValue[i].v.ct
              );
            }
          }
        } catch (e) { }
        try {
          // 检验值赋值
          let insValue = JSON.parse(a.insProductResult.insValue);
          for (let i = 0; i < insValue.length; i++) {
            if (
              this.param[a.id].insValue.find(
                (m) => m.c == insValue[i].c && m.r == insValue[i].r
              )
            ) {
              this.param[a.id].insValue.find(
                (m) => m.c == insValue[i].c && m.r == insValue[i].r
              ).v.v = this.toFixed(
                insValue[i].v,
                this.param[a.id].insValue.find(
                  (m) => m.c == insValue[i].c && m.r == insValue[i].r
                ).v.ct
              );
              this.param[a.id].insValue.find(
                (m) => m.c == insValue[i].c && m.r == insValue[i].r
              ).u = insValue[i].u;
              // this.param[a.id].insValue[i].v.v = insValue[i].v
              // this.param[a.id].insValue[i].u = insValue[i].u
            }
          }
        } catch (e) { }
        try {
          // 设备编号赋值
          let equipValue = JSON.parse(a.insProductResult.equipValue);
          for (let i = 0; i < equipValue.length; i++) {
            // 普通设备赋值
            this.param[a.id].equipValue[i].v.v = equipValue[i].v;
          }
        } catch (e) { }
        try {
          // 设备名称赋值
          let equipName = JSON.parse(a.insProductResult.equipName);
          for (let i = 0; i < equipName.length; i++) {
            equipName[i].v !== "" &&
              equipName[i].v.map((val) => {
                const index = this.equipOptions.findIndex(
                  (item) => item.value === val
                );
                if (index > -1) {
                  // 根据设备编码转换为相应的设备名称
                  val = this.equipOptions[index].deviceName;
                }
              });
          }
          for (let i = 0; i < equipName.length; i++) {
            // 普通设备名称赋值
            this.param[a.id].equipName[i].v.v = equipName[i].v;
          }
        } catch (e) {
          console.log("设备名称赋值----", e);
        }
        try {
          // 最终值赋值
          this.param[a.id].resValue.v.v = this.toFixed(
            a.lastValue,
            this.param[a.id].resValue.v.ct
          );
          // 结论赋值
          this.param[a.id].insResult.v.v = a.insResult;
        } catch (e) { }
      });
      // 按“模板id + 单元格坐标(r-c)”回显已保存的值
      this.initParamByCoordinate();
      // 对excel函数进行处理
      this.handleExcelMethod();
    },
    // 按“模板id + 单元格坐标(r-c)”回显已保存的值
    initParamByCoordinate() {
      this.param = {};
      this.tableList.forEach((a) => {
        this.param[a.templateId] = {};
        const product = this.currentSample.insProduct.find(
          (m) => m.templateId === a.templateId
        );
        let saved =
          (product && (product.recordValues || product.insProductResult)) || {};
        if (typeof saved === "string") {
          try {
            saved = JSON.parse(saved);
          } catch (e) {
            saved = {};
          }
        }
        a.template.forEach((cell) => {
          const key = `${cell.r}-${cell.c}`;
          const item = saved[key];
          if (item === undefined || item === null) {
            return;
          }
          const value = typeof item === "object" ? item.v : item;
          if (value === undefined || value === null) {
            return;
          }
          cell.v.v = value;
          if (typeof item === "object" && item.u) {
            cell.u = item.u;
          }
          this.param[a.templateId][key] = {
            v: value,
            u: typeof item === "object" ? item.u : cell.u,
          };
        });
      });
    },
    // 检验值输入后触发的函数
    changeInput(m, code, n, getDataType, changeSelect) {
    changeInput(m, code, n, getDataType) {
      // 为数采定义一个逻辑参数
      if (getDataType == "getDataType") {
        this.getDataType = 2;
      }
      let currentInsItemId = null; //当前检验项id
      if (n) {
        currentInsItemId = JSON.parse(JSON.stringify(n.i));
        // 定义一个函数来验证分数是否有效
        if (typeof n.v.v == "string") {
          function isValidFraction(fraction) {
@@ -2220,6 +2011,7 @@
        }
      }
      try {
        const revision = ++this.calculationRevision;
        // 向 Worker 发送消息,开始处理逻辑
        this.worker.postMessage(
          JSON.stringify({
@@ -2234,164 +2026,51 @@
            getDataTypeId: this.getDataTypeId,
            modelType: this.sampleProduct[0].model,
            currentInsItem: n,
            revision: revision,
          })
        );
        // 先保存主线程中已经输入的原始值。Worker 完成计算后会再次入队保存计算结果。
        // 这样即使用户输入后立即刷新、切换或返回,最后编辑的单元格也不会丢失。
        if (n) {
          this.saveInsContext();
        }
      } catch (error) {
        console.log(444, error);
      }
      // 监听 Worker 返回的结果
      this.worker.onmessage = (event) => {
        this.result = JSON.parse(event.data);
        switch (this.result.method) {
        const workerResult = JSON.parse(event.data);
        if (workerResult.revision != null && workerResult.revision < this.calculationRevision) {
          return;
        }
        this.result = workerResult;
        switch (workerResult.method) {
          case "saveInsContext":
            this.$nextTick(() => {
              // this.$delete(this.tableList[0],'arr')
              const resultValue = workerResult.value;
              this.$set(
                this.tableList[0],
                "arr",
                this.result.value.tableList[0].arr
                resultValue.tableList[0].arr
              );
              this.param = this.result.value.param;
              if (this.result.value.currentInsItemId) {
                currentInsItemId = this.result.value.currentInsItemId;
              }
              // 特殊处理一下结论,会有这种特殊情况
              for (var i in this.param) {
                if (
                  this.param[i].insResult &&
                  this.param[i].insResult.v &&
                  this.param[i].insResult.v.v
                ) {
                  if (this.param[i].insResult.v.v == "合格") {
                    this.$set(this.param[i].insResult.v, "v", 1);
                  } else if (this.param[i].insResult.v.v == "不合格") {
                    this.$set(this.param[i].insResult.v, "v", 0);
                  }
                }
              }
              this.saveInsContext(currentInsItemId);
              this.param = resultValue.param;
              this.saveInsContext();
              this.completedCalculationRevision = Math.max(
                this.completedCalculationRevision,
                workerResult.revision || 0
              );
            });
            break;
          case "tableList":
            this.$nextTick(() => {
              // 更新数据
              this.$delete(this.tableList[0], "arr");
              this.$set(this.tableList[0], "arr", this.result.value[0].arr);
              // this.param = this.result.value.param
              if (this.result.value.currentInsItem) {
                currentInsItemId = this.result.value.currentInsItem.i;
              }
              this.$set(this.tableList[0], "arr", workerResult.value[0].arr);
            });
            break;
          case "getCurrentInsProduct":
            // 更新页面数据
            this.getCurrentInsProduct(this.result.value);
            break;
        }
      };
      // 保存数据
      setTimeout(() => {
        if (changeSelect) {
          this.saveInsContext(currentInsItemId);
        }
      }, 200);
    },
    // 根据后端传参更新页面数据   param => this.tableList[0].insProductResult
    getCurrentInsProduct(pId) {
      if (!this.tableList[0].insProductResult) {
        this.tableList[0].insProductResult = {};
      }
      for (let m in this.param[pId]) {
        let value = this.param[pId][m];
        switch (m) {
          case "comValue":
            // 赋值计算值
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                };
                this.tableList[0].insProductResult[m].push(obj);
              });
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(
                  this.tableList[0].insProductResult[m]
                );
              } catch (error) {
                console.log(555, error);
              }
            }
            break;
          // 赋值检验值
          case "insValue":
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                  u: a.u,
                };
                this.tableList[0].insProductResult[m].push(obj);
              });
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(
                  this.tableList[0].insProductResult[m]
                );
              } catch (error) {
                console.log(666, error);
              }
            }
            break;
          // 赋值设备编号
          case "equipValue":
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                };
                this.tableList[0].insProductResult[m].push(obj);
              });
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(
                  this.tableList[0].insProductResult[m]
                );
              } catch (error) {
                console.log(777, error);
              }
            }
            break;
          // 赋值设备名称
          case "equipName":
            if (value && value.length > 0) {
              this.tableList[0].insProductResult[m] = [];
              value.forEach((a, i) => {
                let obj = {
                  v: a.v.v,
                };
                this.tableList[0].insProductResult[m].push(obj);
              });
              try {
                this.tableList[0].insProductResult[m] = JSON.stringify(
                  this.tableList[0].insProductResult[m]
                );
              } catch (error) {
                console.log(888, error);
              }
            }
            break;
          // 赋值最终值
          case "resValue":
            this.tableList[0].lastValue = value ? value.v.v : "";
            break;
          // 赋值结论
          case "insResult":
            this.tableList[0].insResult = value ? value.v.v : "";
            break;
        }
      }
    },
    // 对EXCEL函数进行处理
    handleExcelMethod() {
@@ -2435,14 +2114,6 @@
        }
      }
    },
    // 获取要求描述
    getTell(id) {
      for (var a in this.currentSample.insProduct) {
        if (this.currentSample.insProduct[a].id == id) {
          return this.currentSample.insProduct[a].tell;
        }
      }
    },
    // 动态获取单元格宽度
    handleWidth(n) {
      let sum = 0;
@@ -2483,14 +2154,6 @@
        }
      }
    },
    // 获取要求值
    getAsk(id) {
      for (var a in this.currentSample.insProduct) {
        if (this.currentSample.insProduct[a].id == id) {
          return this.currentSample.insProduct[a].ask;
        }
      }
    },
    // 获取所有设备
    getEquipOptions(e, id) {
      if (e) {
@@ -2509,17 +2172,6 @@
          });
      }
    },
    // getDic(e, id) {
    //   if (e) {
    //     for (var a in this.currentSample.insProduct) {
    //       if (this.currentSample.insProduct[a].id == id) {
    //         let str = this.currentSample.insProduct[a].dic;
    //         this.selectEnumByCategoryOfSelect(str);
    //         return str;
    //       }
    //     }
    //   }
    // },
    openAddCheck() {
      this.addCheck = true;
    },
@@ -2527,6 +2179,10 @@
    upInsReview(e) {
      if (e == 1) {
        // 通过
        if (this.reviewInsResult !== 0 && this.reviewInsResult !== 1) {
          this.$message.error("请选择检验结论");
          return;
        }
        this.reviewLoading = true;
        verifyPlan({
          orderId: this.orderId,
@@ -2534,6 +2190,7 @@
          laboratory: this.sonLaboratory,
          tell: null,
          userId: this.checkUser,
          insResult: this.reviewInsResult,
        }).then((res) => {
          if (res.code === 200) {
            this.$message.success("操作成功");
@@ -2574,57 +2231,77 @@
        this.$message.error("未输入不通过原因");
      }
    },
    submit() {
    // 查看工时
    viewManHour() {
      this.$refs.viewManHourDia.showDialog(this.id, 99);
    },
    openAddVerifyDia() {
      this.addVerifyDia = true;
    },
    confirmSubmit(){
      submitPlan({
        orderId: this.orderId,
        laboratory: this.sonLaboratory,
        verifyUser: this.verifyUser,
        entrustCode: this.insOrder.entrustCode,
        registerInsResults: false,
      }).then((res) => {
        if (res.code === 200) {
          this.$message.success("操作成功");
          this.goback();
          this.submitLoading = false;
          this.addVerifyDia = false;
        }
      })
        .catch((error) => {
          console.error(error);
          this.submitLoading = false;
        });
    },
    async submit() {
      if (this.verifyUser === null || this.verifyUser === "") {
        this.$message.error("请指定复核人员");
        return;
      }
      if (!this.otherForm.humidity) {
      if (this.isDirectTemplateOrder() && (!this.selectedDeviceIds || this.selectedDeviceIds.length === 0)) {
        this.$message.error("请选择设备");
        return;
      }
      if (!this.otherForm.humidity && this.insOrder.ifsOrderType!=='02wg') {
        this.$message.error("请输入湿度");
        return;
      }
      if (!this.otherForm.temperature) {
      if (!this.otherForm.temperature && this.insOrder.ifsOrderType!=='02wg') {
        this.$message.error("请输入温度");
        return;
      }
      if (!this.insOrder.lotPartId && this.insOrder.ifsOrderType==='02wg') {
        this.$message.error("请填写IFS库存物料批次属性");
        return;
      }
      await this.waitForPendingSaves();
      this.submitLoading = true;
      checkSubmitPlan({
        orderId: this.orderId,
        laboratory: this.sonLaboratory,
      }).then((res) => {
        if (res.code === 200) {
          if (!res.data || res.data.length == 0) {
          if (!res.data || res.data.errorMsg.length == 0) {
            this.submitLoading = true;
            submitPlan({
              orderId: this.orderId,
              laboratory: this.sonLaboratory,
              verifyUser: this.verifyUser,
              entrustCode: this.insOrder.entrustCode,
            }).then((res) => {
              if (res.code === 200) {
                this.$message.success("操作成功");
                this.goback();
                this.submitLoading = false;
                this.addVerifyDia = false;
              }
            })
              .catch((error) => {
                console.error(error);
                this.submitLoading = false;
              });
            this.confirmSubmit();
          } else {
            let newData = [];
            const h = this.$createElement;
            for (let i in res.data) {
              const lastChar = res.data[i].slice(-1);
            for (let i in res.data.errorMsg) {
              const lastChar = res.data.errorMsg[i].slice(-1);
              if (lastChar == "-") {
                res.data[i] = res.data[i].slice(0, -1);
                res.data.errorMsg[i] = res.data.errorMsg[i].slice(0, -1);
              }
              newData.push(
                h(
                  "p",
                  { style: "font-size: 14px;color: red;" },
                  Number(i) + 1 + "、" + res.data[i]
                  Number(i) + 1 + "、" + res.data.errorMsg[i]
                )
              );
            }
@@ -2647,22 +2324,23 @@
            })
              .then(() => {
                this.submitLoading = true;
                submitPlan({
                  orderId: this.orderId,
                  laboratory: this.sonLaboratory,
                  verifyUser: this.verifyUser,
                }).then((res) => {
                  if (res.code === 200) {
                    this.$message.success("操作成功");
                    this.addVerifyDia = false;
                    this.goback();
                  }
                  this.submitLoading = false;
                })
                  .catch((error) => {
                    console.error(error);
                    this.submitLoading = false;
                  });
                this.confirmSubmit()
                // submitPlan({
                //   orderId: this.orderId,
                //   laboratory: this.sonLaboratory,
                //   verifyUser: this.verifyUser,
                // }).then((res) => {
                //   if (res.code === 200) {
                //     this.$message.success("操作成功");
                //     this.addVerifyDia = false;
                //     this.goback();
                //   }
                //   this.submitLoading = false;
                // })
                //   .catch((error) => {
                //     console.error(error);
                //     this.submitLoading = false;
                //   });
              })
              .catch(() => { });
          }
@@ -2674,95 +2352,168 @@
        });
      return;
    },
    // 统一在这里保存数据
    saveInsContext(currentInsItemId) {
      try {
        if (this.param) {
          let param = null;
          if (currentInsItemId) {
            param = { [currentInsItemId]: this.param[currentInsItemId] };
          } else {
            param = this.param;
    // 按“模板id + 单元格坐标(r-c)”从当前模板快照出待保存参数
    buildParam() {
      const param = {};
      this.tableList.forEach((a) => {
        param[a.templateId] = {};
        // Worker 回传后 arr 是页面上的最新对象,template 仍可能保留计算前的旧值。
        const cells = a.arr && a.arr.length
          ? a.arr.reduce((all, row) => all.concat(row), [])
          : a.template;
        const resultHeader = cells.find((cell) =>
          cell.v && String(cell.v.v || "").trim() === "检验结果"
        );
        const exportRows = new Set(cells.filter((cell) =>
          cell.v && cell.v.ps && cell.v.ps.value === "导出值"
        ).map((cell) => cell.r));
        cells.forEach((cell) => {
          const isEditable =
            cell.v.ps != undefined &&
            typeof cell.v.ps.value === "string" &&
            (cell.v.ps.value.includes("检验值") ||
              cell.v.ps.value === "计算值" ||
              cell.v.ps.value === "最终值" ||
              cell.v.ps.value === "设备名称");
          const isExportResult = resultHeader && exportRows.has(cell.r) && cell.c === resultHeader.c;
          if (!isEditable && !isExportResult) {
            return;
          }
          saveInsContext({
            param: JSON.stringify(param),
            currentTable: this.currentTable,
            sampleId: this.currentSample.id,
            orderId: this.orderId,
            sonLaboratory: this.sonLaboratory
          }).then((res) => {
            if (res.code == 201) {
              this.$message.error("保存失败");
              return;
            }
            this.$message.success("已保存");
          });
          // 向 Worker 发送消息,开始处理逻辑
          this.worker.postMessage(
            JSON.stringify({
              modelType: this.sampleProduct[0].model,
              type: "saveData",
              tableList: this.tableList,
              param: this.param,
              currentTable: this.currentTable,
            })
          );
          if (
            isEditable &&
            cell.v.ps.value.includes("检验值") &&
            (cell.v.v === "" || cell.v.v === null || cell.v.v === undefined)
          ) {
            return;
          }
          param[a.templateId][`${cell.r}-${cell.c}`] = {
            v: cell.v.v,
            u: cell.u,
          };
        });
      });
      return param;
    },
    // 统一在这里保存数据
    saveInsContext() {
      try {
        if (!this.param) {
          return;
        }
        const param = this.buildParam();
        this.param = param;
        let isNoTestValue = "";
        this.tableList.forEach((a) => {
          a.template.forEach((cell) => {
            if (
              cell.v.ps != undefined &&
              typeof cell.v.ps.value === "string" &&
              cell.v.ps.value.includes("检验值") &&
              (cell.v.v === "" || cell.v.v === null || cell.v.v === undefined)
            ) {
              isNoTestValue = 1;
            }
          });
        });
        const payload = {
          param: JSON.stringify(param),
          currentTable: this.currentTable,
          sampleId: this.currentSample.id,
          orderId: this.orderId,
          sonLaboratory: this.sonLaboratory,
          isNoTestValue: isNoTestValue
        };
        const previousSave = this.saveQueue || Promise.resolve();
        this.saveQueue = previousSave
          .catch(() => undefined)
          .then(() => this.isDirectTemplateOrder()
            ? saveTemplateContext({
                orderId: this.orderId,
                sampleId: this.currentSample.id,
                templateId: this.currentTable,
                values: param[this.currentTable] || {},
              })
            : saveInsContext(payload))
          .then(() => {
            this.$message.success("已保存");
          })
          .catch((error) => {
            console.error("检验数据保存失败", error);
            this.$message.error("检验数据保存失败,请重试");
          });
        // 向 Worker 发送消息,开始处理逻辑
        this.worker.postMessage(
          JSON.stringify({
            modelType: this.sampleProduct[0].model,
            type: "saveData",
            tableList: this.tableList,
            param: this.param,
            currentTable: this.currentTable,
          })
        );
      } catch (error) {
        console.log(999, error);
      }
    },
    // 设备改变
    changeEquip(val, n, v) {
      try {
        // this.$set(n.v,'v',val)
        this.tableList[0].arr.forEach((item, index) => {
          item.forEach((m, i) => {
            if (this.param[m.i]) {
              this.param[m.i].state = 1;
    async waitForPendingSaves() {
      const targetRevision = this.calculationRevision;
      if (this.completedCalculationRevision < targetRevision) {
        await new Promise((resolve) => {
          const startedAt = Date.now();
          const waitWorker = () => {
            if (this.completedCalculationRevision >= targetRevision || Date.now() - startedAt > 5000) {
              resolve();
              return;
            }
            // if(m.i==n.i&&m.v.ps&&m.v.ps.value=='设备名称'&&v){
            //   this.$set(m.v,'v',v)
            // }
          });
            setTimeout(waitWorker, 20);
          };
          waitWorker();
        });
        for (let i in this.param) {
          if (this.param[i].state != 1) {
            delete this.param[i];
          }
        }
        // this.equipOptions为设备名称下拉框选项数据
        for (let i1 in this.param[n.i].equipName) {
          if (
            this.param[n.i].equipName[i1].i === n.i &&
            this.param[n.i].equipName[i1].r === n.r
          ) {
            this.$delete(this.param[n.i].equipValue[i1].v, "v");
            // 将数组赋值给设备编码
            this.$set(this.param[n.i].equipValue[i1].v, "v", val.join(","));
            this.$delete(this.param[n.i].equipName[i1].v, "v");
            // 将数组赋值给设备编码
            this.$set(this.param[n.i].equipName[i1].v, "v", val);
            this.tableList[0].arr.forEach((item, index) => {
              item.forEach((m) => {
                if (m.i == n.i && m.v.ps && m.v.ps.value == "设备编码") {
                  this.$set(m.v, "v", val.join(","));
                }
                if (m.i == n.i && m.v.ps && m.v.ps.value == "设备名称") {
                  this.$set(m.v, "v", val);
                }
              });
            });
          }
        }
        // 保存数据
        this.saveInsContext(n.i);
      } catch (e) {
        console.log("changeEquip----", e);
      }
      if (this.saveQueue) {
        await this.saveQueue;
      }
    },
    // 设备改变
    changeEquip(val, n) {
      const selectedDevices = Array.isArray(val) ? [...val] : [];
      const deviceCodes = selectedDevices.join(",");
      this.$set(n.v, "v", selectedDevices);
      this.tableList.forEach((table) => {
        (table.arr || []).forEach((row) => {
          row.forEach((cell) => {
            if (cell.i == n.i && cell.v.ps) {
              if (cell.v.ps.value === "设备名称") {
                this.$set(cell.v, "v", [...selectedDevices]);
              } else if (cell.v.ps.value === "设备编码") {
                this.$set(cell.v, "v", deviceCodes);
              }
            }
          });
        });
      });
      // 选择、移除、清空均由 change 事件触发,立即保存。
      this.saveInsContext();
    },
    isDirectTemplateOrder() {
      return this.sonLaboratory === "新聚" && this.currentSample &&
        (this.currentSample.insProduct || []).some((product) => product.templateRowIndex != null);
    },
    loadOverviewDevices() {
      Promise.all([search({ status: 0 }), getOrderDevices({ orderId: this.orderId })]).then(([devices, selected]) => {
        this.orderDeviceOptions = (devices.data || []).map((device) => ({
          id: device.id,
          label: `${device.deviceName}--${device.managementNumber}`,
        }));
        this.selectedDeviceIds = selected.data || [];
      });
    },
    saveOverviewDevices() {
      return saveOrderDevices({ orderId: this.orderId, deviceIds: this.selectedDeviceIds })
        .then(() => this.$message.success("设备已保存"));
    },
    getAuthorizedPerson() {
      selectUserCondition({ type: 0 }).then((res) => {
      selectUserCondition({ type: 1 }).then((res) => {
        let data = [];
        res.data.forEach((a) => {
          data.push({
@@ -2819,16 +2570,6 @@
      // 初始化后端传参
      this.param = {};
      this.changeType = 0;
      this.currentSample.insProduct.forEach((a, j) => {
        this.param[a.id] = {
          insValue: [],
          comValue: [],
          resValue: null,
          equipValue: [],
          equipName: [],
          insResult: null,
        };
      });
      // 页面数据处理
      this.getTableLists();
      // 更新到多线程
@@ -2846,7 +2587,7 @@
      this.upLoading = false;
      if (response.code == 200) {
        this.$message.success("上传成功");
        this.$refs.fileList.selectList();
        this.getList();
      }
    },
    beforeUpload(file) {
@@ -2865,16 +2606,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) => { });
    },
@@ -2898,8 +2630,9 @@
        return v;
      }
    },
    goback() {
      this.$tab.closeOpenPage({ path: "/business/inspectionTask" });
    async goback() {
      await this.waitForPendingSaves();
      this.$router.go(-1)
    }
  },
};
@@ -2941,6 +2674,7 @@
  background-color: #fff;
  border-radius: 3px;
  margin-bottom: 10px;
  padding: 10px;
}
.search .form-inline {
@@ -3036,7 +2770,7 @@
}
.content-h-2 {
  justify-content: end;
  justify-content: flex-end;
}
.content-v-0 {