<!-- 测试分析-测试管理 -->
<template>
  <div class="examination testManagement">
    <div class="common-head-search">
      <el-form :inline="true" @submit.native.prevent ref="searchForm" :model="searchForm"
        class="demo-form-inline sui-search-form">
        <el-form-item label="样品名称">
          <el-input v-model="searchForm.matName" @keyup.enter.native="searchData()" size="small" placeholder="请输入查询内容"
            style="width: 150px"></el-input>
        </el-form-item>
        <el-form-item label="样品编号">
          <el-input v-model="searchForm.sampleNo" size="small" placeholder="请输入查询内容" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="样品类型">
          <el-select v-model="searchForm.sampleTypeCode" clearable filterable collapse-tags size="small"
            style="width: 150px" placeholder="请选择查询内容">
            <el-option v-for="item in sampleTypeNameType" :key="item.baseName" :label="item.baseName"
              :value="item.baseCode">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="任务领用日期">
          <el-date-picker v-model="searchForm.times[0]" value-format="yyyy-MM-dd HH:mm:ss" format="" type="datetime"
            placeholder="开始日期" size="mini" style="width: 180px" :default-time="'00:00:00'">
          </el-date-picker>
          <span>至</span>
          <el-date-picker v-model="searchForm.times[1]" value-format="yyyy-MM-dd HH:mm:ss" format="" type="datetime"
            placeholder="结束日期" size="mini" style="width: 180px" :default-time="'23:59:59'">
          </el-date-picker>
          <!-- <el-date-picker
            v-model="searchForm.times"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="small"
            style="width: 350px"
            value-format="yyyy-MM-dd HH:mm:ss"
            :default-time="['00:00:00', '23:59:59']"
          >
          </el-date-picker> -->
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" type="goon" size="mini" @click="searchData">查询</el-button>
          <el-button icon="el-icon-refresh" type="info" plain size="mini" @click="resetData">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-row>
      <el-col :span="10">
        <el-tabs type="border-card" v-model="activeName" class="testManagement_left">
          <el-tab-pane label="待接任务" name="first">
            <span slot="label">待接任务<el-badge :max="10" :hidden="total_main == 0" style="margin-top: -18px"
                :value="total_main"></el-badge></span>
            <div class="common-title-div" style="height: auto">
              <div class="common-title-name" style="margin-right: 10px">
                <img style="width: 25px; height: 25px" src="../../../../assets/img/imgScreen/logo.png" />
                未接收
              </div>
              <div>
                <el-form :inline="true" @submit.native.prevent>
                  <el-form-item style="margin-bottom: 0">
                    <el-button icon="el-icon-check" type="goon" :loading="sampleLoading" @click="recSample"
                      v-privilege="activeMenu + 'receive'" size="mini">接任务</el-button>
                  </el-form-item>
                  <el-form-item style="margin-bottom: 0">
                    <el-input ref="autoInput" v-model="values" placeholder="扫码接任务" size="mini" style="width: 150px"
                      @input="autoSubmit()" clearable :disabled="inputLoading"></el-input>
                  </el-form-item>
                  <!--<el-form-item>
                    <el-button icon="el-icon-check" type="goon" size="mini" :loading='inputLoading' v-privilege="activeMenu + 'codeSampling'" @click="transferTask">任务转移</el-button>
                  </el-form-item>-->
                </el-form>
              </div>
            </div>
            <div class="common-table-div">
              <el-table ref="table1" :height="theight1" v-loading="tableLoading1" :data="tableData1"
                :summary-method="getSummaries2" show-summary border @selection-change="searchFollow"
                :header-cell-style="tableHeaderCellStyle" highlight-current-row :icorePanelShown="100"
                :icore-filter-flag="icoreFilterFlag" :exchangeFilterMap="{
                  lock_flag: { '0': '未锁定', '1': '已锁定' },
                }" style="width: 100%">
                <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
                <el-table-column type="selection" width="45" fixed="left" align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="carNo"
                  label="委托编号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="sampleNo"
                  label="中心编号">
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="150" align="center" prop="matName"
                  label="物料名称"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="testItemName"
                  label="测试项目"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="receivedDate"
                  label="收样日期"></el-table-column>
                <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="entrMemo" label="委托备注"
                  align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="matOrder"
                  label="物料顺序"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="sampleTypeName"
                  label="样品类型"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="functionName"
                  label="任务类型"></el-table-column>
              </el-table>
            </div>
            <div class="common-foot-style">
              <el-pagination @size-change="handleSizeChangeMain" @current-change="DataMain()"
                :current-page.sync="pageIndex" :page-sizes="[10, 20, 30, 40, 100, 200]" :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="total_main" background></el-pagination>
            </div>
          </el-tab-pane>
          <el-tab-pane label="已接任务" name="second">
            <div class="common-title-div" style="height: auto">
              <div class="common-title-name" style="margin-right: 10px">
                <img style="width: 25px; height: 25px" src="../../../../assets/img/imgScreen/logo.png" />
                已接收
              </div>
              <div class="buttons">
                <el-button icon="el-icon-back" type="danger" size="mini" :loading="backLoading"
                  v-privilege="activeMenu + 'back'" @click="back">退回</el-button>
                <el-button icon="el-icon-check" type="goon" :loading="submitLoading" @click="subData"
                  v-privilege="activeMenu + 'submit'" size="mini">提交</el-button>
                <el-button icon="el-icon-check" type="goon" @click="retest('480403')" size="mini"
                  v-privilege="activeMenu + 'retest'">增加任务</el-button>
                <el-button icon="el-icon-check" type="goon" @click="retest('480405')" size="mini"
                  v-privilege="activeMenu + 'retest'">增加标样</el-button>
                <el-button icon="el-icon-check" type="goon" @click="collectData" v-privilege="activeMenu + 'collect'"
                  size="mini">批量采集</el-button>
                <el-button icon="el-icon-back" type="danger" size="mini" :loading="backLoading"
                  v-privilege="activeMenu + 'backCollect'" @click="backCollect">撤回采集</el-button>
                <el-button icon="el-icon-check" type="goon" :loading="batchDataLoading" @click="batchData"
                  v-privilege="activeMenu + 'batch'" size="mini">批量录入</el-button>
                <el-button icon="el-icon-circle-close" :loading="buttonLoading1" type="danger" size="mini"
                  v-privilege="activeMenu + 'disable'" @click="abolish">停用</el-button>
                <el-button icon="el-icon-check" type="goon" :loading="addByLoading" @click="addBy" size="mini"
                  v-privilege="activeMenu + 'addBy'">增加标准点</el-button>
                <el-button icon="el-icon-check" type="goon" @click="addGly" size="mini"
                  v-privilege="activeMenu + 'addGly'">增加管理样</el-button>
                <el-button icon="el-icon-check" type="goon" :loading="addKbLoading" @click="addKb" size="mini"
                  v-privilege="activeMenu + 'addKb'">增加空白样</el-button>
                <el-checkbox v-model="isOneHint" @change="changeIsOneHint">重复提醒一次</el-checkbox>
              </div>
            </div>
            <div class="common-table-div">
              <el-table v-loading="tableLoading2" ref="table2" :cell-class-name="tableRowClassName"
                @selection-change="SelectionValues" @current-change="handleCurrentChange" border
                @row-click="searchAnalyze" :height="theight2" highlight-current-row :data="tableData2"
                :icore-filter-flag="icoreFilterFlag"
                :exchangeFilterMap="{
                  isSendBack: { '0': '普通任务', '1': '普通任务' , '2': '额外任务' },
                }"
                :header-cell-style="tableHeaderCellStyle"
                :summary-method="getSummaries2" show-summary>
                <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
                <el-table-column type="selection" width="45" fixed="left" align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable width="95" align="center" prop="isSendBack" label="类型">
                  <template slot-scope="scope">
                    <span v-if="scope.row.isSendBack === '2'" :class="{ 'color-warning': true }">
                      额外任务
                    </span>
                    <span v-else> 普通任务 </span>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="carNo"
                  label="委托编号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="sampleNo"
                  label="中心编号">
                  <template slot-scope="scope">
                    <span @click.stop="showHistory(scope.row)" style="cursor: pointer"
                      :class="{ 'color-blue': scope.row.sampleNo }">
                      {{ scope.row.sampleNo }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="150" align="center" prop="matName"
                  label="物料名称"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="170" align="center" prop="testItemName"
                  label="测试项目"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="receivedDate"
                  label="收样日期"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="entrMemo"
                  label="委托备注"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="sampleTypeName"
                  label="样品类型"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="stdName"
                  label="方法"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="eqpName"
                  label="仪器类型"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="testDirection"
                  label="测试部门">
                  <template slot-scope="{ row }">
                    <el-input v-model="row.testDirection" size="small" @keyup.enter.native="calAge(row)"
                      style="width: 100%">
                    </el-input>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="memo"
                  label="备注"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="80px" prop="createMan" label="创建人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="createTime" label="创建时间"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="80px" prop="updateMan" label="修改人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="updateTime" label="修改时间"
                  align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="stateFlagName"
                  label="状态"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="validFlagName"
                  label="数据状态"></el-table-column>
              </el-table>
              <div class="common-foot-style">
                <el-pagination @size-change="handleSizeChangeDep" @current-change="DataDep()"
                  :current-page.sync="pageIndex_dep" :page-sizes="[10, 20, 30, 40, 100, 200]" :page-size="pageSize_dep"
                  layout="total, sizes, prev, pager, next, jumper" :total="total_dep" background></el-pagination>
              </div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="已提交" name="third">
            <div class="common-title-div" style="height: auto">
              <div class="common-title-name" style="margin-right: 10px">
                <img style="width: 25px; height: 25px" src="../../../../assets/img/imgScreen/logo.png" />
                已提交
              </div>
              <div class="buttons">
                <el-button icon="el-icon-back" type="danger" size="mini" :loading="withdrawLoading"
                  @click="backWithdraw">撤回</el-button>
              </div>
              <el-button icon="el-icon-check" type="goon" @click="retest2('480403')" size="mini"
                v-privilege="activeMenu + 'retest'">增加任务</el-button>
            </div>
            <div class="common-table-div">
              <el-table v-loading="tableLoading4" ref="table4" :cell-class-name="tableRowClassName"
                @selection-change="SelectionValues4" @current-change="handleCurrentChange" border
                @row-click="searchAnalyze" :height="theight2" highlight-current-row :data="tableData4"
                :icore-filter-flag="icoreFilterFlag" :header-cell-style="tableHeaderCellStyle"
                :exchangeFilterMap="{
                  isSendBack: { '0': '普通任务', '1': '普通任务' , '2': '额外任务' },
                }"
                :summary-method="getSummaries2" show-summary>
                <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
                <el-table-column type="selection" width="45" fixed="left" align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable width="95" align="center" prop="isSendBack" label="类型">
                  <template slot-scope="scope">
                    <span v-if="scope.row.isSendBack === '2'" :class="{ 'color-warning': true }">
                      额外任务
                    </span>
                    <span v-else> 普通任务 </span>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="carNo"
                  label="委托编号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="sampleNo"
                  label="中心编号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="150" align="center" prop="matName"
                  label="物料名称"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="testItemName"
                  label="测试项目"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="receivedDate"
                  label="收样日期"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="entrMemo"
                  label="委托备注"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="sampleTypeName"
                  label="样品类型"></el-table-column>
                <!-- <el-table-column
                  show-overflow-tooltip
                  sortable
                  min-width="100"
                  align="center"
                  prop="id"
                  label="编号"
                ></el-table-column> -->
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="stdName"
                  label="方法"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="eqpName"
                  label="仪器类型"></el-table-column>
                <!-- <el-table-column
                  show-overflow-tooltip
                  sortable
                  min-width="100"
                  align="center"
                  prop="testPostName"
                  label="分析岗位"
                ></el-table-column> -->
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="testDirection"
                  label="测试部门"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="memo"
                  label="备注"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="80px" prop="createMan" label="创建人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="createTime" label="创建时间"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="80px" prop="updateMan" label="修改人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="updateTime" label="修改时间"
                  align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="stateFlagName"
                  label="状态"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="validFlagName"
                  label="数据状态"></el-table-column>
              </el-table>
              <div class="common-foot-style">
                <el-pagination @size-change="handleSizeChange4" @current-change="Data4()"
                  :current-page.sync="pageIndex4" :page-sizes="[10, 20, 30, 40, 100, 200]" :page-size="pageSize4"
                  layout="total, sizes, prev, pager, next, jumper" :total="total4" background></el-pagination>
              </div>
            </div>
          </el-tab-pane>
          <el-tab-pane label="已停用" name="stop">
            <div class="common-title-div" style="height: auto">
              <div class="common-title-name" style="margin-right: 10px">
                <img style="width: 25px; height: 25px" src="../../../../assets/img/imgScreen/logo.png" />
                已停用
              </div>
              <div class="buttons">
                <el-button icon="el-icon-check" :loading="buttonLoading2" type="goon" size="mini"
                  v-privilege="activeMenu + 'effectivity'" @click="recoverData">启用</el-button>
              </div>
            </div>
            <div class="common-table-div">
              <el-table v-loading="tableLoading42" ref="table42" :cell-class-name="tableRowClassName"
                @selection-change="SelectionValues42" @current-change="handleCurrentChange" border
                @row-click="searchAnalyze" :height="theight2" highlight-current-row :data="tableData42"
                :icore-filter-flag="icoreFilterFlag" :header-cell-style="tableHeaderCellStyle"
                :exchangeFilterMap="{
                  isSendBack: { '0': '普通任务', '1': '普通任务' , '2': '额外任务' },
                }"
                :summary-method="getSummaries2" show-summary>
                <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
                <el-table-column type="selection" width="45" fixed="left" align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable width="95" align="center" prop="isSendBack" label="类型">
                  <template slot-scope="scope">
                    <span v-if="scope.row.isSendBack === '2'" :class="{ 'color-warning': true }">
                      额外任务
                    </span>
                    <span v-else> 普通任务 </span>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="carNo"
                  label="委托编号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="115" align="center" prop="sampleNo"
                  label="中心编号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="150" align="center" prop="matName"
                  label="物料名称"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="testItemName"
                  label="测试项目"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="receivedDate"
                  label="收样日期"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="entrMemo"
                  label="委托备注"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="sampleTypeName"
                  label="样品类型"></el-table-column>
                <!-- <el-table-column
                  show-overflow-tooltip
                  sortable
                  min-width="100"
                  align="center"
                  prop="id"
                  label="编号"
                ></el-table-column> -->
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="stdName"
                  label="方法"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="eqpName"
                  label="仪器类型"></el-table-column>
                <!-- <el-table-column
                  show-overflow-tooltip
                  sortable
                  min-width="100"
                  align="center"
                  prop="testPostName"
                  label="分析岗位"
                ></el-table-column> -->
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="testDirection"
                  label="测试部门"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="memo"
                  label="备注"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="80px" prop="createMan" label="创建人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="createTime" label="创建时间"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="80px" prop="updateMan" label="修改人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="updateTime" label="修改时间"
                  align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="stateFlagName"
                  label="状态"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="validFlagName"
                  label="数据状态"></el-table-column>
              </el-table>
              <div class="common-foot-style">
                <el-pagination @size-change="handleSizeChange5" @current-change="Data5()"
                  :current-page.sync="pageIndex42" :page-sizes="[10, 20, 30, 40, 100, 200]" :page-size="pageSize42"
                  layout="total, sizes, prev, pager, next, jumper" :total="total42" background></el-pagination>
              </div>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-col>
      <el-col :span="14">
        <el-tabs type="border-card" v-model="activeName2">
          <el-tab-pane :label="analyzeVal.matName
            ? '【 ' +
            analyzeVal.matName +
            ' 】 - 【 ' +
            analyzeVal.testItemName +
            ' 】'
            : '未选择数据'
            " name="first2">
            <el-form :inline="true" :model="autoCollData" ref="autoCollData" :rules="autoColl">
              <el-form-item prop="eqpTypeCode" label="设备类型">
                <el-select v-model="autoCollData.eqpTypeCode" @change="selectAuto" filterable collapse-tags size="small"
                  style="width: 150px" placeholder="">
                  <el-option v-for="item in facilityType" :key="item.baseCode" :label="item.baseName"
                    :value="item.baseCode">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="eqpNo" label="设备名称">
                <el-select v-model="autoCollData.eqpNo" clearable filterable collapse-tags size="small"
                  style="width: 150px" placeholder="">
                  <el-option v-for="item in autoEqpType" :key="item.eqpNo" :label="item.eqpName + ` (${item.memo})`"
                    :value="item.eqpNo">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-input v-model="scale" ref="autoBalance" size="mini" style="display: inline-block; width: 100px"
                  clearable @input="autoScale()" placeholder="扫码选设备"></el-input>
              </el-form-item>
              <el-form-item>
                <!--<el-button icon="el-icon-check" type="goon" size="mini" v-privilege="activeMenu + 'autoCollets'"  :loading='autoColletLoading' @click="autoCollet">自动采集</el-button>-->
                <el-checkbox v-model="isAutoColl" @change="realTimeCollect">自动采集</el-checkbox>
                <el-button icon="el-icon-check" type="goon" size="mini" :loading="autoColletLoading"
                  @click="autoCollet">手动采集</el-button>
              </el-form-item>
            </el-form>
            <div style="height: auto; padding-top: 1px" class="common-title-div">
              <div class="common-title-name">
                <img style="width: 25px; height: 25px" src="../../../../assets/img/imgScreen/logo.png" />
                分析项目
              </div>
              <div class="buttons">
                <el-button icon="el-icon-circle-plus-outline" @click="addAnaly" v-privilege="activeMenu + 'addData'"
                  type="goon" size="mini">新增</el-button>
                <el-button icon="el-icon-remove-outline" type="danger" :loading="deleteLoading" size="mini"
                  v-privilege="activeMenu + 'delete'" @click="deleteData">删除</el-button>
                <el-button icon="el-icon-back" type="danger" :loading="errorLoading" size="mini"
                  @click="deleteRecall">撤回</el-button>
                <el-button icon="el-icon-check" :loading="formulacomLoading" @click="formulacom" type="goon"
                  v-privilege="activeMenu + 'formulacom'" size="mini">计算</el-button>
                <el-button icon="el-icon-check" :loading="saveLoading" @click="saveData" type="goon"
                  v-privilege="activeMenu + 'save'" size="mini">保存</el-button>
                <el-button icon="el-icon-remove-outline" :loading="errorLoading" type="danger" size="mini"
                  @click="abnormal">异常申报</el-button>
              </div>
              <div></div>
            </div>
            <div class="common-table-div">
              <el-table v-loading="tableLoading3" border :height="theight3" @selection-change="selectMultiples"
                highlight-current-row @row-click="clickRow" :data="tableData3" :icore-filter-flag="icoreFilterFlag"
                :header-cell-style="tableHeaderCellStyle" @row-dblclick="showCell" :row-class-name="tableRowName"
                :cell-class-name="fxTableRowClassName" :summary-method="getSummaries2" show-summary>
                <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
                <el-table-column type="selection" width="45" fixed="left" align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="90" fixed="left" align="center"
                  prop="anlyItemNo" label="分析项目编号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="180" fixed="left" align="center"
                  prop="anlyItemName" label="分析项目"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="130" align="center" prop="anlyValue"
                  label="报出值">
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="150" align="center" prop="reviseValue"
                  label="录入值">
                  <template slot-scope="{ row }">
                    <el-select :disabled="analyzeVal.stateFlag != 0" v-if="
                      row.index === tabClickIndex &&
                      !row.showInput &&
                      row.dataTypeCode !== '482504'
                    " clearable allow-create v-model="row.reviseValue" filterable size="small">
                      <el-option v-for="(item, index) in row.defaultList" :key="index" :label="item" :value="item">
                      </el-option>
                    </el-select>
                    <el-input :disabled="analyzeVal.stateFlag != 0" :controls="false" v-else-if="
                      row.index === tabClickIndex &&
                      row.showInput &&
                      row.dataTypeCode !== '482504'
                    " @blur="saveCell" v-model="row.reviseValue" @keyup.enter.native="saveCell" size="small"
                      style="width: 100%">
                    </el-input>
                    <el-date-picker v-model="row.reviseValue" type="datetime" size="small" placeholder="选择日期时间"
                      v-else-if="row.dataTypeCode === '482504'" align="right" style="width: 100%"
                      :default-value="new Date()">
                    </el-date-picker>
                    <span v-else>{{ row.reviseValue }}</span>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="dasValue"
                  label="采集值"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="cptValue"
                  label="计算值"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="memo" label="备注">
                  <template slot-scope="{ row }">
                    <el-input v-model="row.memo" @blur="saveCell" @keyup.enter.native="saveCell" size="small"
                      style="width: 100%"></el-input>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="memo" label="文件上传">
                  <template slot-scope="scope">
                    <el-upload class="upload" action="" style="width: 40px; display: inline-block" :multiple="false"
                      :show-file-list="false" accept="" :http-request="httpRequest">
                      <el-button type="goon" size="mini" :disabled="analyzeVal.stateFlag != 0"
                        @click="saveUpload(scope.row)" icon="el-icon-upload2"></el-button>
                    </el-upload>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="130" align="center" prop="archiveId"
                  label="文件路径">
                  <template slot-scope="scope">
                    <span v-if="scope.row.archiveId">
                      <template v-for="fileName in scope.row.archiveId.split('#')">
                        <span @click.stop="imgPreView(scope.row, fileName)" style="cursor: pointer"
                          :class="{ 'color-blue': fileName !== '' }">
                          {{ fileName }}
                        </span>
                      </template>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="unitName"
                  label="单位"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="formulaName"
                  label="计算公式"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="reviseRuleName"
                  label="修约规则"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="isReportName"
                  label="是否报出"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="isAlarmName"
                  label="是否报警"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="minSign"
                  label="最小符号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="minValue"
                  label="最小值"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="maxSign"
                  label="最大符号"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="maxValue"
                  label="最大值"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="maxLimit"
                  label="方法上限值"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="minLimit"
                  label="方法下限值"></el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
    <!-- 录入湿温度 -->
    <el-dialog class="testManagement-pllr" :close-on-click-modal="false" @close="closeTemperature" width="70%"
      :visible.sync="temperatureShow">
      <div slot="title" class="titleBox">
        <i class="el-icon-document" style="font-size: 20px"></i>
        <span style="margin-left: 10px; font-size: 18px">温湿度记录</span>
        <span style="margin-left: 10px; font-size: 18px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;选择化验室</span>
        <el-select v-model="form.pointNo" clearable filterable collapse-tags @change="temperatureData" size="small"
          style="width: 150px" placeholder="请选择查询内容">
          <el-option v-for="item in pointType" :key="item.pointName" :label="item.pointName" :value="item.pointNo">
          </el-option>
        </el-select>
        <!-- <el-form-item label="任务领用日期">
          <el-date-picker
            v-model="form.times"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="small"
            style="width: 350px"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item> -->
        <el-button icon="el-icon-check" @click="determine" type="goon" size="mini">确定
        </el-button>
      </div>
      <div style="padding: 10px 0">
        <el-row>
          <el-col :span="24">
            <el-table v-loading="temperatureLoading3" ref="dataTable" border :height="heightTop" highlight-current-row
              :data="dialog3.form.tableData" :header-cell-style="tableHeaderCellStyle" @row-click="temperatureRow"
              :icore-filter-flag="icoreFilterFlag">
              <el-table-column type="index" label="NO" align="center"></el-table-column>
              <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="pointName" label="分析室"
                align="center"></el-table-column>
              <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="envDate" label="记录日期"
                align="center"></el-table-column>
              <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="tempNow" label="温度 ℃"
                align="center"></el-table-column>
              <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="moisNow" label="湿度 %"
                align="center"></el-table-column>
              <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="weather" label="天气情况"
                align="center"></el-table-column>
              <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="createMan" label="创建人"
                align="center"></el-table-column>
              <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="createTime" label="创建时间"
                align="center"></el-table-column>
            </el-table>
            <div style="margin-top: 20px; margin-left: 10px">
              <el-pagination style="float: right" @size-change="temperatureSizeTest"
                @current-change="temperaturePageChangeTest" :current-page="temperaturelog.pageNum"
                :page-sizes="[10, 20, 50, 100, 200]" :page-size="temperaturelog.pageSize"
                layout="total, sizes, prev, pager, next" :total="temperaturelog.totalPage" background>
              </el-pagination>
            </div>
          </el-col>
        </el-row>
      </div>
      <el-form ref="dialog_form" size="mini" label-width="100px">
        <el-row>
          <el-col :span="8">
            <el-form-item prop="pointNo" label="化验室">
              <el-select v-model="dialog3.form.data.pointNo" clearable filterable collapse-tags size="small"
                style="width: 200px" placeholder="请选择查询内容">
                <el-option v-for="item in pointType" :key="item.pointName" :label="item.pointName"
                  :value="item.pointNo">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="记录日期">
              <el-date-picker v-model="dialog3.form.data.envDate" type="date" placeholder="选择日期" size="small"
                style="width: 100%"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="3" style="text-align: center">
            <el-button icon="el-icon-circle-plus-outline" type="goon" size="mini" @click="addData">新增</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="pointNo" label="温度（℃）">
              <el-input v-model="dialog3.form.data.tempNow" clearable style="width: 200px" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="湿度（%）">
              <el-input v-model="dialog3.form.data.moisNow" clearable style="width: 200px" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3" style="text-align: center">
            <el-button icon="el-icon-edit" type="goon" size="mini" @click="modifyData">修改</el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="16">
            <el-form-item label="天气描述">
              <el-input v-model="dialog3.form.data.weather" clearable style="width: 100%" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3" style="text-align: center">
            <el-button icon="el-icon-remove-outline" type="danger" size="mini" @click="deData">删除</el-button>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="goon" size="mini" @click="closeTemperature">取 消</el-button>
        <!-- <el-button
          type="goon"
          size="mini"
          :loading="addGlyLoading"
          @click="addGlySure"
          >保 存</el-button
        > -->
      </span>
    </el-dialog>
    <!-- 批量录入 -->
    <el-dialog class="testManagement-pllr" :close-on-click-modal="false" @close="closebatch" width="100%"
      :visible.sync="batchShow" top="0">
      <div slot="title" class="titleBox">
        <div>
          <i class="el-icon-document" style="font-size: 20px"></i>
          <span style="margin-left: 10px; font-size: 16px">批量录入</span>
          <span style="font-size: 16px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;标样选择&nbsp;&nbsp;
          </span>
          <el-date-picker v-model="itemSize" type="date" size="small" placeholder="根据日期选择标样数据" align="right"
            style="width: 20%" value-format="yyyyMMdd">
          </el-date-picker>
          <span style="font-size: 16px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;设备选择&nbsp;&nbsp;</span>
          <el-select v-model="equipment.nantNo" clearable multiple style="width: 18%; height: 28px" filterable
            collapse-tags size="small">
            <el-option v-for="(item, index) in matNameType" :key="index"
              :label="item.eqpName + '(' + item.eqpUseNo + ')'" :value="item.eqpNo">
            </el-option>
          </el-select>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <el-button type="goon" size="mini" :loading="temperatureLoading"
            @click="temperatureSubmit()">选择湿温度</el-button>
          <!-- <span style="font-size: 16px">&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;湿温度&nbsp;&nbsp;</span>
          <el-input
            v-model="equipment.itemTemp"
            size="small"
            placeholder="请输入湿温度"
            style="height: 32px;width: 150px;"
          ></el-input> -->
        </div>
      </div>
      <el-table ref="tablePllr" border :height="theight4" highlight-current-row :data="tableData"
        :header-cell-style="tableHeaderCellStyle" :cell-class-name="tableRowBatch" :summary-method="getSummaries2"
        show-summary>
        <el-table-column type="index" label="NO" fixed="left" align="center">
          <template slot-scope="scope">
            <span>{{ scope.$index }}</span>
          </template>
        </el-table-column>
        <el-table-column width="50px" fixed="left" label="操作" align="center">
          <template slot-scope="scope">
            <el-button v-if="scope.$index > 0" type="text" style="padding: 0"
              @click="delData(scope.row, scope.$index)">删除</el-button>
          </template>
        </el-table-column>
        <template v-for="col in cols">
          <el-table-column :prop="col.prop" :fixed="col.prop == 'sampleNo' ||
            col.prop == 'matName' ||
            col.prop == 'carNo'
            " show-overflow-tooltip min-width="90" align="center" :key="col.prop" :label="col.label">
            <template slot-scope="scope">
              <span v-if="col.prop == 'matName'">{{
                tableData[scope.$index].matName
                }}</span>
              <!--              <span style=display:none v-else-if="col.prop == 'testOrder'">{{tableData[scope.$index].testOrder}}</span>-->
              <span v-else-if="col.prop == 'sampleNo'">{{
                tableData[scope.$index].sampleNo
                }}</span>
              <span v-else-if="col.prop == 'carNo'">{{
                tableData[scope.$index].carNo
                }}</span>
              <el-select v-else-if="
                col.showInput == '0' &&
                col.showDateTime === '0' &&
                scope.$index > 0
              " clearable allow-create v-model="scope.row[col.prop]" filterable size="small" style="width: 100%"
                :class="{
                  bgRed:
                    resData[col.prop + '_' + scope.row.stId] &&
                    resData[col.prop + '_' + scope.row.stId] === '0',
                  bgOrange:
                    resData[col.prop + '_' + scope.row.stId] &&
                    resData[col.prop + '_' + scope.row.stId] === '1',
                }">
                <el-option v-for="(item, index) in col.defaultList" :key="index" :label="item" :value="item">
                </el-option>
              </el-select>
              <el-input v-else-if="col.zwFlag == '0' && col.showDateTime === '0'"
                @input="inputData($event, scope.$index, col.prop)"
                @keydown.native="keyDown($event, scope.row, scope.$index)" :id="scope.column.id + '--' + scope.$index"
                v-model="scope.row[col.prop]" size="small" style="width: 100%" :class="{
                  bgRed:
                    resData[col.prop + '_' + scope.row.stId] &&
                    resData[col.prop + '_' + scope.row.stId] === '0',
                  bgOrange:
                    resData[col.prop + '_' + scope.row.stId] &&
                    resData[col.prop + '_' + scope.row.stId] === '1',
                }">
              </el-input>
              <el-date-picker v-model="scope.row[col.prop]" type="datetime" size="small" placeholder="选择日期时间"
                @change="sign(scope.row[col.prop], scope.row, col.prop)"
                v-else-if="col.showDateTime === '1' && scope.$index > 0" align="right" style="width: 100%">
              </el-date-picker>
              <el-input v-else @input="inputData($event, scope.$index, col.prop)"
                @keydown.native="keyDown($event, scope.row, scope.$index)" :id="scope.column.id + '--' + scope.$index"
                v-model="scope.row[col.prop]" size="small" style="width: 100%" :class="{
                  bgRed:
                    resData[col.prop + '_' + scope.row.stId] &&
                    resData[col.prop + '_' + scope.row.stId] === '0',
                  bgOrange:
                    resData[col.prop + '_' + scope.row.stId] &&
                    resData[col.prop + '_' + scope.row.stId] === '1',
                }">
              </el-input>
            </template>
          </el-table-column>
        </template>
      </el-table>
      <span slot="footer" class="dialog-footer">
        (红色背景：当前值不符合最小值要求；橙色背景，当前值不符合最大值要求)
        <!-- <el-button type="goon" size="mini" icon="el-icon-check" :loading='batchLoading' @click="submitBatch()">计算并提交</el-button> -->
        <el-button type="goon" size="mini" icon="el-icon-check" :loading="batchLoading"
          @click="submitBatch()">提交</el-button>
        <el-button type="goon" size="mini" icon="el-icon-check" :loading="batchLoading" @click="jisuan()">计算</el-button>
        <!-- <el-button type="goon" size="mini" icon="el-icon-check" :loading='batchLoading' @click="saveBatch()">确定</el-button> -->
        <el-button size="mini" type="goon" icon="el-icon-remove-outline" @click="closebatch">取消</el-button>
      </span>
    </el-dialog>
    <!-- 新增管理样 -->
    <el-dialog :close-on-click-modal="false" width="80%" :visible.sync="dialog.show" @close="closeBly">
      <div slot="title" class="titleBox">
        <i class="el-icon-document" style="font-size: 20px"></i>
        <span style="margin-left: 10px; font-size: 18px">新增管理样</span>
      </div>
      <div style="padding: 10px 0">
        <el-form ref="dialog_form" :model="dialog.form.data" :rules="dialog.form.rules" size="mini" label-width="100px">
          <el-row>
            <el-col :span="24">
              <el-table v-loading="glDialogLoading" ref="dataTable" border :height="heightTop" highlight-current-row
                :data="dialog.form.tableData" :header-cell-style="tableHeaderCellStyle"
                :icore-filter-flag="icoreFilterFlag">
                <el-table-column type="index" label="NO" align="center"></el-table-column>
                <el-table-column width="100px" show-overflow-tooltip label="操作" align="center">
                  <template slot-scope="scope">
                    <el-button type="text" style="padding: 0"
                      @click="dialogDeleteData(scope.row, scope.$index)">删除</el-button>
                  </template>
                </el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="sampleNo" label="中心编号"
                  align="center"></el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="matName" label="物料名称"
                  align="center"></el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="testItemName"
                  label="测试项目" align="center"></el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="receivedDate"
                  label="收样日期" align="center"></el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="testItemName"
                  label="管理样编号" align="center">
                  <template slot-scope="scope">
                    <el-input size="mini" v-model.trim="scope.row.glSampleNo"></el-input>
                  </template>
                </el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="testItemName"
                  label="管理样物料名称" align="center">
                  <template slot-scope="scope">
                    <el-input size="mini" required v-model.trim="scope.row.glMatName"></el-input>
                  </template>
                </el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="testItemName"
                  label="新增管理样个数" align="center">
                  <template slot-scope="scope">
                    <el-input size="mini" v-model.trim="scope.row.glCount"></el-input>
                  </template>
                </el-table-column>
              </el-table>
              <div style="margin-top: 20px; margin-left: 10px">
                <el-pagination style="float: right" @size-change="glDialogSizeTest"
                  @current-change="glDialogPageChangeTest" :current-page="glDialog.pageNum"
                  :page-sizes="[10, 20, 50, 100, 200]" :page-size="glDialog.pageSize"
                  layout="total, sizes, prev, pager, next" :total="glDialog.totalPage" background>
                </el-pagination>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="goon" size="mini" @click="closeBly">取 消</el-button>
        <el-button type="goon" size="mini" :loading="addGlyLoading" @click="addGlySure">保 存</el-button>
      </span>
    </el-dialog>
    <!-- 新增标准点 -->
    <el-dialog :close-on-click-modal="false" width="600px" :visible.sync="addByShow" @close="closeBly">
      <div slot="title" class="titleBox">
        <i class="el-icon-document" style="font-size: 20px"></i>
        <span style="margin-left: 10px; font-size: 18px">新增标准点</span>
      </div>
      <div style="padding: 10px 0">
        <el-form ref="dialog_form2" :model="dialog2.form.data" :rules="dialog2.form.rules" size="mini"
          label-width="100px">
          <el-row>
            <el-col :span="24">
              <el-form-item label="标准点数量" prop="sampleNum">
                <el-input clearable style="width: 90%" :maxlength="3" oninput="value=value.replace(/[^1-9]/g,'')"
                  v-model="dialog2.form.data.sampleNum"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="9" v-if="this.gangwei == 'P000084'">
              <el-form-item label="元素" prop="yuansu">
                <el-input clearable style="width: 90%" :maxlength="3" v-model="dialog2.form.data.yuansu"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="goon" size="mini" @click="closeBly">取 消</el-button>
        <el-button type="goon" size="mini" @click="addBy2">保 存</el-button>
      </span>
    </el-dialog>
    <!-- 分析项目删除撤回 -->
    <el-dialog :close-on-click-modal="false" @close="closebatch" width="100%" :visible.sync="recallShow" top="0">
      <div slot="title" class="titleBox">
        <i class="el-icon-document" style="font-size: 20px"></i>
        <span style="margin-left: 10px; font-size: 18px">分析项目撤回</span>
      </div>
      <div class="common-table-div">
        <el-table v-loading="tableLoading5" border :height="theight3" @selection-change="selectMultiples"
          highlight-current-row @row-click="clickRow" :data="tableData5" :icore-filter-flag="icoreFilterFlag"
          :header-cell-style="tableHeaderCellStyle" @row-dblclick="showCell" :cell-class-name="fxTableRowClassName"
          :row-class-name="tableRowName" :summary-method="getSummaries2" show-summary>
          <el-table-column type="index" label="NO" align="center"></el-table-column>
          <el-table-column type="selection" width="45" align="center"></el-table-column>
          <!-- <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="testItemName" label="测试项目" ></el-table-column> -->
          <el-table-column show-overflow-tooltip sortable min-width="180" align="center" prop="anlyItemName"
            label="分析项目"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="anlyValue" label="报出值">
          </el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="dasValue"
            label="采集值"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="cptValue"
            label="计算值"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="reviseValue"
            label="录入值"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="unitName"
            label="单位"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="formulaName"
            label="计算公式"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="reviseRuleName"
            label="修约规则"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="isReportName"
            label="是否报出"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="100" align="center" prop="isAlarmName"
            label="是否报警"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="minSign"
            label="最小符号"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="minValue"
            label="最小值"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="maxSign"
            label="最大符号"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="maxValue"
            label="最大值"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="maxLimit"
            label="方法上限值"></el-table-column>
          <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="minLimit"
            label="方法下限值"></el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="goon" size="mini" icon="el-icon-check" :loading="batchLoading" @click="recall()">撤回</el-button>
        <el-button size="mini" type="goon" icon="el-icon-remove-outline" @click="closebatch">取消</el-button>
      </span>
    </el-dialog>
    <div is="alertComponents" :showFlag="showFlag" :Params="Params" @refresh="refresh"></div>
    <div is="historyAlert" :showFlag="historyShowFlag" :Params="Params" @refresh="refresh"></div>
    <div is="resurveyAlert" :showFlag="resetShowFlag" :Params="Params" :itemTypeCode="itemTypeCode" @refresh="refresh2">
    </div>
    <div is="dataCollectionAlert" :showFlag="dataCollectionFlag" :Params2="Params2" @refresh="refresh3"></div>
  </div>
</template>
<script>
import { getCookie, formatDate } from "@/utils/util.js";
import { cookieUserId, cookieUserName } from "@/config/config.js";
import alertComponents from "./alertComponents";
import historyAlert from "./historyAlert";
import resurveyAlert from "./resurveyAlert";
import dataCollectionAlert from "./dataCollectionAlert";
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  components: {
    alertComponents,
    historyAlert,
    resurveyAlert,
    dataCollectionAlert,
  },
  data() {
    return {
      fromDaiban: null,
      temperatureShow: false,
      temperatureLoading: false,
      temperatureLoading3: false,
      temperaturelog: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0,
      },
      form: {
        times: [],
        pointNo: "",
      },
      pointType: [],
      temperatureRowData: {},
      wetTemperature: "",

      searchForm: {
        times: "",
        matName: "",
        sampleNo: "",
        sampleTypeCode: "",
        eqpNo: "",
      },
      autoCollData: {
        eqpTypeCode: "",
        eqpNo: "",
      },
      gangwei: "",
      showFlag: false,
      historyShowFlag: false,
      resetShowFlag: false,
      deleteFlag: false,
      dataCollectionFlag: false,
      Params: {},
      itemTypeCode: "",
      Params2: [],
      matNameType: [],
      autoColl: {
        eqpTypeCode: [
          { required: true, message: "不能为空", trigger: "change" },
        ],
        eqpNo: [{ required: true, message: "不能为空", trigger: "change" }],
      },
      table: {
        listTests: [],
        collectionData: [],
        selectCollectionData: [],
        sampleData: [],
      },
      activeName: "first",
      activeName2: "first2",
      backLoading: false,
      withdrawLoading: false,
      batchDataLoading: false,
      buttonLoading1: false,
      buttonLoading2: false,
      batchLoading: false,
      addByLoading: false,
      addKbLoading: false,
      addGlyLoading: false,
      testTable: [],
      resData: {},
      cols: [],
      tableData: [],
      resultData: [],
      collectionLoading: false,
      autoColletLoading: false,
      clickColl: false,
      batchShow: false,
      itemSize: "", //区分标样数据
      eqpType: [],
      autoEqpType: [],
      facilityType: [],
      selectVal: [], // 已接任务 多选
      selectVal4: [], // 已提交
      selectVal42: [], // 无效数据多选
      selectMul: [],
      companyNameType: [],
      userdeptNo: "",
      usersectionNo: "",
      userjobs: "",
      selectRecall: [],
      testShow: false,
      checked: true,
      interval: null,
      saveValue: "",
      saveMainData: [],
      cllotData: [],
      addRetestLoading: false,
      dataLoading: false,
      glDialogLoading: false,
      sampleLoading: false,
      saveLoading: false,
      errorLoading: false,
      submitLoading: false,
      isAutoColl: false,
      sampleTypeNameType: [],
      analyzeVal: {},
      analyzeValues: {},
      formulacomLoading: false,
      isOneHint: false,
      theight1: 0,
      theight2: 0,
      theight3: 0,
      theight4: 0,
      testItemName2: "",
      pageTests: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0,
      },
      glDialog: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0,
      },
      equipment: {
        nantNo: [],
        itemTemp: "",
      },
      addByShow: false,
      deleteLoading: false,
      collectionShow: false,
      recallShow: false,
      addCollectionLoading: false,
      tableLoading1: false,
      tableLoading2: false,
      tableLoading3: false,
      tableLoading4: false,
      tableLoading42: false,
      tableLoading5: false,
      saveFileRow: {},
      fileList: [],
      selectLine: {},
      tabClickIndex: null,
      func: "",
      originalData: [],
      tableData1: [],
      tableData2: [],
      tableData3: [],
      tableData4: [],
      tableData42: [],
      tableData5: [],
      pageIndex: 1,
      pageSize: 100,
      total_main: 0,
      pageIndex_dep: 1,
      pageSize_dep: 100,
      total_dep: 0,
      pageIndex4: 1,
      pageSize4: 100,
      pageIndex42: 1,
      pageSize42: 100,
      total4: 0,
      total42: 0,
      scale: "",
      allFacility: [],
      scaleId: null,
      inputLoading: false,
      values: "",
      saveAnaly: {},
      timeId: null,
      icoreFilterFlag: true,
      heightTop: 0,
      activeMenu: "",
      dialog: {
        show: false,
        form: {
          data: {
            sampleNo: "",
            matName: "",
          },
          tableData: [],
          rules: {
            sampleNo: [
              { required: true, message: "该项不能为空", trigger: "blur" },
            ],
            matName: [
              { require: true, message: "物料名称不能为空!", trigger: "blur" },
            ],
          },
        },
      },
      dialog2: {
        show: false,
        form: {
          data: {
            sampleNum: "6", // 标准点数量
            yuansu: "",
          },
          rules: {
            sampleNum: [
              { required: true, message: "该项不能为空", trigger: "blur" },
            ],
          },
        },
      },
      dialog3: {
        show: false,
        form: {
          data: {
            pointNo: "",
            pointName: "",
            envDate: "",
            tempNow: "",
            moisNow: "",
            tempUnit: "",
            moisUnit: "",
            weather: "",
          },
          tableData: [],
        },
      },
    };
  },
  created() {
    this.theight1 =
      window.innerHeight - 185 < 249 ? 249 : window.innerHeight - 230;
    this.theight2 =
      window.innerHeight - 185 < 249 ? 249 : window.innerHeight - 230;
    this.theight3 =
      window.innerHeight - 230 < 249 ? 249 : window.innerHeight - 230;
    this.theight4 =
      window.innerHeight - 140 < 249 ? 249 : window.innerHeight - 140;
    this.heightTop =
      window.innerHeight / 2 - 130 < 249 ? 249 : window.innerHeight / 2 - 130;
    // this.itemSize = new Date();

    this.activeMenu = window.top.localStorage.getItem("activeMenu");

    this.fromDaiban = JSON.parse(sessionStorage.getItem("fromDaiban"));
    sessionStorage.removeItem("fromDaiban");

    if (this.fromDaiban) {
      this.searchForm.times = [
        this.fromDaiban.startTime,
        this.fromDaiban.endTime,
      ];
      this.activeName = this.fromDaiban.status == 0 ? "first" : "second";
    } else {
      this.searchForm.times = [
        this.getYNM(new Date()) + " 00:00:00",
        this.getYNM(new Date()) + " 23:59:59",
      ];
    }

    this.axios
      .post(
        "pass/baseManagement/v1/sysorgs/querySysOrgCompanyAll",
        {},
        { individualType: "json" }
      )
      .then((response) => {
        this.companyNameType = response.data;
        this.getCompany();
      });
    this.searchForm.sampleNo = this.$route.query.Name;
    this.searchData();
  },
  mounted() {
    console.log('testManagement:',this.$route.query.type)
    this.searchForm.type = this.$route.query.type  || '';
    this.axios
      .post(
        "pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",
        { validFlag: 1, baseCode: 4801 },
        { individualType: "json" }
      )
      .then((res) => {
        this.sampleTypeNameType = res.data;
      });
    this.axios
      .post(
        "pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",
        { validFlag: 1, baseCode: 4808 },
        { individualType: "json" }
      )
      .then((res) => {
        this.facilityType = res.data;
      });
    this.axios
      .get(
        "pass/baseManagement/v1/limslrceqpinfos/like/" +
        "?pageNum=1" +
        "&pageSize=9999" +
        "&eqpTypeName=" +
        "" +
        "&stateFlag=" +
        ""
      )
      .then((res) => {
        this.allFacility = res.data.list;
      });
    // 设备信息
    this.axios
      .post("pass/baseManagement/v1/limslrceqpinfos/queryAll", {
        individualType: "json",
      })
      .then((res) => {
        this.matNameType = res.data;
      });
    // 实验室
    this.axios
      .post(
        "pass/baseManagement/v1/limsbasepoints/queryLimsBasePointPage",
        { pageIndex: 1, pageSize: 9999, object: { validFlag: 1 } },
        { individualType: "json" }
      )
      .then((res) => {
        this.pointType = res.data.list;
      });
    this.searchData();
  },
  methods: {
    addData() {
      this.dialog3.form.data.pointName = this.getCode(
        this.dialog3.form.data.pointNo,
        this.pointType,
        "pointNo",
        "pointName"
      );
      if (this.dialog3.form.data.pointNo == "") {
        this.$message.warning("请先选择化验室！");
        return;
      }
      this.dialog3.form.data.envId = "";
      this.dialog3.form.data.id = "";
      this.axios
        .post(
          "pass/testManagement/v1/limsdataenvironments/insertUpdate",
          this.dialog3.form.data,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.temperatureData();
            this.closeData();
            this.$message.success("添加成功！");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((err) => {
          this.$message.error(err.message);
        });
    },
    temperatureRow(row) {
      this.temperatureRowData = row;
      this.dialog3.form.data = row;
    },
    modifyData() {
      this.axios
        .post(
          "pass/testManagement/v1/limsdataenvironments/insertUpdate",
          this.dialog3.form.data,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.closeData();
            this.$message.success("修改成功！");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((err) => {
          this.$message.error(err.message);
        });
    },
    deData() {
      this.axios
        .delete(
          "pass/testManagement/v1/limsdataenvironments/" +
          this.temperatureRowData.envId
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.temperatureData();
            this.closeData();
            this.$message.success("删除成功！");
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((err) => {
          this.$message.error(err.message);
        });
    },
    closeData() {
      this.dialog3.form.data = {
        pointNo: "",
        pointName: "",
        envDate: "",
        tempNow: "",
        moisNow: "",
        tempUnit: "",
        moisUnit: "",
        weather: "",
      };
    },
    determine() {
      if (this.temperatureRowData == {} || this.temperatureRowData == null) {
        this.$message.warning("请选择湿温度！");
        return;
      }
      this.equipment.itemTemp = this.temperatureRowData.envId;
      this.temperatureShow = false;
    },
    temperatureSubmit() {
      this.temperatureShow = true;
    },
    closeTemperature() {
      this.closeData();
      this.temperatureShow = false;
    },
    temperatureSizeTest(size) {
      this.temperaturelog.pageSize = size;
      this.temperatureData();
    },
    temperaturePageChangeTest(index) {
      this.temperaturelog.pageNum = index;
      this.temperatureData();
    },
    temperatureData() {
      let obj = {
        pageIndex: this.temperaturelog.pageNum,
        pageSize: this.temperaturelog.pageSize,
        // startTime:'',
        // endTime:'',
        mode: this.form.pointNo,
      };
      this.temperatureLoading = true;
      this.temperatureLoading3 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limsdataenvironments/queryPageList",
          obj,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.temperaturelog.totalPage = res.data.total;
            this.dialog3.form.tableData = res.data.list;
          } else {
            this.$message.error(res.message);
          }
          this.temperatureLoading = false;
          this.temperatureLoading3 = false;
        })
        .catch((err) => {
          this.temperatureLoading = false;
          this.temperatureLoading3 = false;
          this.$message.error(err.message);
        });
    },
    getCode(code, arr, codeKey, nameKey) {
      if (!code) {
        return "";
      }
      let targetRow = arr.find((item) => {
        return item[codeKey] === code;
      });
      return targetRow ? targetRow[nameKey] : "";
    },
    getYNM(date) {
      let year = date.getFullYear().toString();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      month = month < 10 ? "0" + month : month;
      day = day < 10 ? "0" + day : day;
      return `${year}-${month}-${day}`;
    },
    refresh() {
      this.searchAnalyze(this.analyzeVal, true);
    },
    refresh2() {
      this.searchData();
    },
    refresh3() {
      // console.log('批量采集执行完毕');
    },
    getSummaries2(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "总计";
        }
        if (index === 1) {
          sums[index] = data.length;
        } else if (column.property === "quantity") {
          let val = 0;
          for (let i in data) {
            val = this.floatComputed(
              data[i].quantity ? data[i].quantity : 0,
              val,
              "+"
            );
          }
          sums[index] = val;
        }
      });
      return sums;
    },
    calAge(e) {
      if (e == null || e == {}) {
        this.$message.warning("无参数传值！");
        return;
      }
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/updateLimsSampleTest",
          e,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((err) => {
          this.$message.error(err.message);
        });
    },
    //分析项目删除撤回
    deleteRecall() {
      if (this.selectLine.length < 1) {
        this.$message.warning("请选择一条需要撤回的主数据！");
        return;
      }
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/queryLimsSampleTestDList2?stId=" +
          this.selectLine.id
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData5 = res.data;
            this.tableData5.forEach((item) => {
              item.anlyValue = item.anlyValue
                ? item.anlyValue
                : item.defaultValue;
              item.isReportName =
                item.isReport == 0 ? "否" : item.isReport == 1 ? "是" : "";
              item.isAlarmName =
                item.isAlarm == 0 ? "否" : item.isAlarm == 1 ? "是" : "";
            });
            // console.log("查询撤回的数据", res.data)
          } else {
            this.$message.error(res.message);
          }
          this.recallShow = !this.recallShow;
          this.tableLoading5 = false;
        })
        .catch((err) => {
          this.tableLoading5 = false;
          this.$message.error(err.message);
        });
    },
    recall() {
      if (this.selectRecall.length < 1) {
        this.$message.warning("请勾选需要撤回的数据！");
        return;
      }
      let tempIds = this.selectRecall.map((item) => item.stIdD);
      this.deleteLoading = true;
      let obj = {
        id: tempIds,
        validFlag: "1",
      };
      this.axios
        .post("pass/testManagement/v1/limssampletestds/delete", obj, {
          individualType: "json",
        })
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchAnalyze(this.analyzeVal, true);
          } else {
            this.$message.error(res.message);
          }
          this.deleteLoading = false;
          this.recallShow = !this.recallShow;
        })
        .catch((e) => {
          this.deleteLoading = false;
          this.$message.error(e.message);
        });
    },
    addAnaly() {
      if (JSON.stringify(this.analyzeVal) == "{}") {
        this.$message.warning("请选择一条需要新增的主数据！");
        return;
      }
      if (this.analyzeVal.stateFlag == 3) {
        this.$message.warning(
          "选中的已接收数据为已提交的数据，不能进行新增！,请选择状态为未处理的数据进行操作"
        );
        return;
      }
      this.showFlag = !this.showFlag;
      this.Params = this.analyzeVal;
    },
    clickRow(val) {
      this.saveAnaly = val;
    },
    //删除分析项目
    deleteData() {
      if (this.selectMul.length < 1) {
        this.$message.warning("请勾选需要删除的数据！");
        return;
      }
      if (this.analyzeVal.stateFlag == 3) {
        this.$message.warning(
          "选中的已接收数据为已提交的数据，不能进行删除！,请选择状态为未处理的数据进行操作"
        );
        return;
      }
      let tempIds = this.selectMul.map((item) => item.stIdD);
      this.deleteLoading = true;
      let obj = {
        id: tempIds,
        validFlag: "0",
      };
      this.axios
        .post("pass/testManagement/v1/limssampletestds/delete", obj, {
          individualType: "json",
        })
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchAnalyze(this.analyzeVal, true);
          } else {
            this.$message.error(res.message);
          }
          this.deleteLoading = false;
        })
        .catch((e) => {
          this.deleteLoading = false;
          this.$message.error(e.message);
        });
    },
    selectAuto(val) {
      this.autoEqpType = [];
      this.scale = "";
      this.autoCollData.eqpNo = "";
      if (!val) {
        return;
      }
      this.axios
        .post(
          "pass/baseManagement/v1/limslrceqpinfos/queryeqpName",
          { eqpTypeCode: val },
          { individualType: "json" }
        )
        .then((res) => {
          this.autoEqpType = res.data;
        });
    },
    resetData() {
      this.searchForm.matName = "";
      this.searchForm.sampleTypeCode = "";
      this.searchForm.eqpNo = "";
      this.searchForm.times = [
        this.getYNM(new Date()) + " 00:00:00",
        this.getYNM(new Date()) + " 23:59:59",
      ];
      this.searchData();
    },
    SelectionValues(val) {
      this.selectVal = val;
    },
    // 已提交、无效数据，多选
    SelectionValues4(val) {
      this.selectVal4 = val;
    },
    SelectionValues42(val) {
      this.selectVal42 = val;
    },
    selectMultiples(val) {
      this.selectMul = val;
      this.selectRecall = val;
    },
    //点击选中样品信息数据
    searchFollow(val) {
      this.saveMainData = val;
    },
    //获取选中已接任务数据
    handleCurrentChange(val) {
      this.selectLine = val;
    },
    //异常申报
    abnormal() {
      if (this.selectMul.length < 1) {
        this.$message.warning("请先勾选您要异常申报的数据");
        return;
      }
      let obj = {
        limsSampleTest: this.selectLine,
        limsSampleTestDList: this.selectMul,
        limsObjHeat: {
          declareNo: userId,
          declareName: userName,
          objTypeName: "检验异常",
          objTypeCode: "482603",
          objFlag: "0",
          validFlag: "1",
          createMan: userName,
          createNo: userId,
        },
      };
      this.errorLoading = true;
      this.$confirm("确认要申报" + this.selectMul.length + "条异常吗", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.axios
            .post("pass/testManagement/v1/limsobjheats/toDeclare/", obj, {
              individualType: "json",
            })
            .then((res) => {
              if (res.code == 500) {
                this.$message.error(res.message);
                this.errorLoading = false;
              } else {
                this.$message.success(res.message);
                this.errorLoading = false;
              }
            })
            .catch((err) => {
              this.errorLoading = false;
              this.$message.error(err.message);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
          this.errorLoading = false;
        });
    },
    //撤回已提交数据
    backWithdraw() {
      if (this.selectVal4.length < 1) {
        this.$message.warning("请先勾选您要撤回的数据");
        return;
      }
      for (let item of this.selectVal4) {
        if (item.validFlag == "0") {
          this.$message.warning("请选择有效数据");
          return;
        }
      }
      let params = [];
      this.selectVal4.forEach((item) => {
        params.push({ stId: item.id });
      });
      this.withdrawLoading = true;
      this.axios
        .post("pass/testManagement/v1/limssampletests/backAuditData", params, {
          individualType: "json",
        })
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.withdrawLoading = false;
        })
        .catch((err) => {
          this.withdrawLoading = false;
          this.$message.error(err.message);
        });
    },
    //接样
    recSample() {
      if (this.saveMainData.length < 1) {
        this.$message.warning("请先勾选您要接样的数据");
        return;
      }
      this.sampleLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/pickUpSample",
          this.saveMainData,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.sampleLoading = false;
        })
        .catch((err) => {
          this.sampleLoading = false;
          this.$message.error(err.message);
        });
    },
    // 显示历史记录
    showHistory(row) {
      if (!row) {
        return this.$message.warning("查询历史记录失败，参数错误!");
      }
      this.axios
        .post(
          "pass/testManagement/v1/limssamplehistorys/queryHistoryTest",
          row,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            //打开窗口
            this.historyShowFlag = !this.historyShowFlag;
            this.Params = Object.assign([{}], res.data);
          } else {
            this.$message.warning("查询历史记录失败!");
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },
    autoSubmit(val) {
      if (!this.values) {
        this.$message.warning("请先用扫码枪扫描标签");
        return;
      }
      if (!this.timeId) {
        this.timeId = setTimeout(() => {
          this.inputLoading = true;
          this.axios
            .post(
              "pass/testManagement/v1/limssampletests/pickUpSampleScan?tkId=" +
              this.values,
              { individualType: "json" }
            )
            .then((res) => {
              if (res.code == 0 || res.code == 200) {
                this.$message.success(res.message);
                this.searchData();
              } else {
                this.$message.error(res.message);
              }
              this.$nextTick(() => {
                this.$refs.autoInput.focus();
              });
              this.values = "";
              this.inputLoading = false;
            })
            .catch((e) => {
              this.$nextTick(() => {
                this.$refs.autoInput.focus();
              });
              this.values = "";
              this.inputLoading = false;
            })
            .catch((e) => {
              this.$nextTick(() => {
                this.$refs.autoInput.focus();
              });
              this.values = "";
              this.inputLoading = false;
              this.$message.error(e.message);
            });
          this.timeId = null;
        }, 1000);
      }
    },
    autoScale(val) {
      if (!this.scale) {
        this.$message.warning("请先用扫码枪扫描二维码");
        return;
      }
      if (!this.scaleId) {
        this.scaleId = setTimeout(() => {
          this.autoCollData.eqpTypeCode = "";
          this.autoEqpType = this.allFacility;
          this.autoCollData.eqpNo = this.scale;
          this.scaleId = null;
        }, 1000);
      }
    },
    //扫码接样
    changeval() {
      if (!this.values) {
        this.$message.warning("请先用扫码枪扫描标签");
        return;
      }
      this.inputLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/pickUpSampleScan?tkId=" +
          this.values,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.values = "";
            this.$message.success(res.message);
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.inputLoading = false;
        })
        .catch((e) => {
          this.inputLoading = false;
          this.$message.error(e.message);
        });
    },
    stopall() {
      if (this.interval != null) {
        clearInterval(this.interval);
      }
      this.isAutoColl = false;
      this.autoColletLoading = false;
    },
    changeIsOneHint(val) {
      this.isOneHint = val;
    },
    realTimeCollect(val) {
      if (val && this.tableData3.length <= 0) {
        this.$message.warning("测试分析项目不能为空");
        this.stopall();
        this.isAutoColl = false;
        return;
      }
      if (val && this.autoCollData.eqpNo && this.autoCollData.eqpTypeCode) {
        this.startTime(this.tableData3.length, 1, 3000);
      } else {
        if (!(this.autoCollData.eqpNo && this.autoCollData.eqpTypeCode)) {
          this.$message.warning("请选择【设备类型】【设备名称】，不能为空");
        }
        this.stopall();
        this.isAutoColl = false;
        return;
      }
    },
    intervalCollectData() {
      if (this.isAutoColl && this.autoCollData.eqpNo) {
        if (this.autoCollData.eqpTypeCode) {
          let params = {
            eqpNo: this.autoCollData.eqpNo,
            eqpTypeCode: this.autoCollData.eqpTypeCode,
            stId: this.analyzeVal.stId,
          };
          this.axios
            .post(
              "pass/testManagement/v1/limssampletests/intervalCollectData",
              params,
              { individualType: "json" }
            )
            .then((res) => {
              if (res.code == 0 || res.code == 200) {
                this.searchAnalyze(this.analyzeVal, true);
              } else {
                this.isAutoColl = false;
                this.$message.warning(res);
                return;
              }
            })
            .catch((e) => {
              this.isAutoColl = false;
              this.$message.error(e.message);
              return;
            });
        } else {
          this.isAutoColl = false;
          return this.$message.warning("设备仪器类型发生更改，自动采集结束!");
        }
      } else {
        this.isAutoColl = false;
        return this.$message.warning("设备仪器发生更改，自动采集结束!");
      }
    },
    startTime(tableLength, openOff, times) {
      let that = this;
      try {
        let timesRun = 0;
        this.interval = setInterval(function () {
          timesRun += 1;
          if (!openOff) {
            this.isAutoColl = false;
            clearInterval(this.interval);
          }
          if (!tableLength) {
            this.isAutoColl = false;
            clearInterval(this.interval);
          }
          if (timesRun > tableLength) {
            this.isAutoColl = false;
            clearInterval(this.interval);
          }
          that.autoCollet();
        }, times);
      } catch (e) {
        clearInterval(this.interval);
        this.isAutoColl = false;
        return this.$message.warning("发生异常，自动采集中断！");
      }
    },
    subData() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选您要提交的数据");
        return;
      }
      for (let item of this.selectVal) {
        if (item.stateFlag != 0) {
          this.$message.warning("请选择状态为未处理的数据");
          return;
        }
        if (item.validFlag == "0") {
          this.$message.warning("请选择有效数据");
          return;
        }
        this.$confirm("确认是否提交?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
          if (this.isOneHint) {
            this.subDataAndHintOne();
          } else {
            this.subData3();
          }
        });
      }
    },
    // 提交, 批量、同步执行
    async subData2() {
      this.saveLoading = true;
      this.submitLoading = true;
      let cg = 0; // 成功
      let sb = 0; // 失败
      let qx = 0; // 取消
      let sbwl = []; // 失败的物料
      let ids = []; //需要提交的数据的id
      for (let i = 0; i < this.selectVal.length; i++) {
        let item = this.selectVal[i];
        ids.push(item.stId);
      }
      try {
        let tishi = [];
        const cfs = await this.axios.post(
          "pass/testManagement/v1/limssampletests/queryBySample_No",
          ids,
          { individualType: "json" }
        );
        if (cfs.code == 0 || cfs.code == 200) {
          let b = true;
          for (let i = 0; i < cfs.data.length; i++) {
            if (cfs.data[i]) {
              b = false;
              tishi.push(this.selectVal[i].matName);
            }
          }
          if (b) {
            let b2 = true;
            const res = await this.axios.post(
              "pass/testManagement/v1/limssampletests/errorWarningRemind",
              ids,
              { individualType: "json" }
            );
            if (res.code == 0 || res.code == 200) {
              for (let i = 0; i < ids.length; i++) {
                if (res.data.get(i)) {
                  b2 = false;
                }
              }
              if (b2) {
              }
              if (res.data) {
              } else {
                const res4 = await this.axios.post(
                  "pass/testManagement/v1/limssampletests/submit" + ids,
                  { individualType: "json" }
                );
                if (res4.code == 0 || res4.code == 200) {
                  cg++;
                } else {
                  sbwl.push(item.matName);
                  sb++;
                }
              }
            }
          } else {
            this.$confirm(
              item.matName + "," + tishi + "，这条数据重复，是否重复提交？",
              "提示",
              {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              }
            )
              .then()
              .catch((err) => {
                // 选择 取消
                qx++;
              });
          }
        }
      } catch (err) {
        sbwl.push(item.matName);
        sb++;
        // console.log('eeeeee');
      }
    },
    async subData3() {
      this.saveLoading = true;
      this.submitLoading = true;
      let cg = 0; // 成功
      let sb = 0; // 失败
      let qx = 0; // 取消
      let sbwl = []; // 失败的物料centerPersonnelScheduling
      for (let i = 0; i < this.selectVal.length; i++) {
        let item = this.selectVal[i];
        try {
          const cfs = await this.axios.post(
            "pass/testManagement/v1/limssampletests/queryBySample_No?stId=" +
            item.stId,
            { individualType: "json" }
          );
          if (cfs.code == 0 || cfs.code == 200) {
            if (cfs.data) {
              await this.$confirm(
                item.matName +
                "," +
                item.testItemName +
                "，这条数据重复，是否重复提交？",
                "提示",
                {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                }
              )
                .then(async () => {
                  const res = await this.axios.post(
                    "pass/testManagement/v1/limssampletests/errorWarningRemind?stId=" +
                    item.stId,
                    { individualType: "json" }
                  );
                  if (res.code == 0 || res.code == 200) {
                    if (res.data) {
                      if (res.data.code == 0) {
                        let temp = res.data.object;
                        const res2 = await this.axios.post(
                          "pass/testManagement/v1/limssampletests/submit?stId=" +
                          item.stId,
                          { individualType: "json" }
                        );
                        if (res2.code == 0 || res2.code == 200) {
                          cg++;
                        } else {
                          sbwl.push(res2.message);
                          sb++;
                        }
                      } else {
                        await this.$confirm(
                          "第" +
                          (i + 1) +
                          "条数据, " +
                          `${res.data.message},是否继续?`,
                          "超差预警提醒",
                          {
                            confirmButtonText: "确定",
                            cancelButtonText: "取消",
                            type: "warning",
                          }
                        )
                          .then(async () => {
                            const res4 = await this.axios.post(
                              "pass/testManagement/v1/limssampletests/submit?stId=" +
                              item.stId,
                              { individualType: "json" }
                            );
                            if (res4.code == 0 || res4.code == 200) {
                              cg++;
                            } else {
                              sbwl.push(res4.message);
                              sb++;
                              this.$message.error(
                                "第" +
                                (i + 1) +
                                "条数据提交失败：" +
                                res4.message
                              );
                            }
                          })
                          .catch((err) => {
                            // 选择 取消
                            qx++;
                          });
                      }
                    } else {
                      const res4 = await this.axios.post(
                        "pass/testManagement/v1/limssampletests/submit?stId=" +
                        item.stId,
                        { individualType: "json" }
                      );
                      if (res4.code == 0 || res4.code == 200) {
                        cg++;
                      } else {
                        sbwl.push(res4.message);
                        sb++;
                        this.$message.error(
                          "第" + (i + 1) + "条数据提交失败：" + res4.message
                        );
                      }
                    }
                  } else {
                    sbwl.push(item.matName);
                    sb++;
                    this.$message.error(
                      "第" + (i + 1) + "条数据提交失败：" + res.message
                    );
                  }
                })
                .catch((err) => {
                  // 选择 取消
                  qx++;
                });
            } else {
              const res = await this.axios.post(
                "pass/testManagement/v1/limssampletests/errorWarningRemind?stId=" +
                item.stId,
                { individualType: "json" }
              );
              // console.log('res.data=' + res.data + ",res.code=" + res.code);
              if (res.code == 0 || res.code == 200) {
                if (res.data) {
                  if (res.data.code == 0) {
                    let temp = res.data.object;
                    const res2 = await this.axios.post(
                      "pass/testManagement/v1/limssampletests/submit?stId=" +
                      item.stId,
                      { individualType: "json" }
                    );
                    if (res2.code == 0 || res2.code == 200) {
                      cg++;
                    } else {
                      sbwl.push(res2.message);
                      sb++;
                    }
                  } else {
                    await this.$confirm(
                      "第" +
                      (i + 1) +
                      "条数据, " +
                      `${res.data.message},是否继续?`,
                      "超差预警提醒",
                      {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                      }
                    )
                      .then(async () => {
                        const res4 = await this.axios.post(
                          "pass/testManagement/v1/limssampletests/submit?stId=" +
                          item.stId,
                          { individualType: "json" }
                        );
                        if (res4.code == 0 || res4.code == 200) {
                          cg++;
                        } else {
                          sbwl.push(res4.message);
                          sb++;
                        }
                      })
                      .catch((err) => {
                        // 选择 取消
                        qx++;
                      });
                  }
                } else {
                  const res4 = await this.axios.post(
                    "pass/testManagement/v1/limssampletests/submit?stId=" +
                    item.stId,
                    { individualType: "json" }
                  );
                  if (res4.code == 0 || res4.code == 200) {
                    cg++;
                  } else {
                    sbwl.push(res4.message);
                    sb++;
                  }
                }
              } else {
                sbwl.push(item.matName);
                sb++;
                //this.$message.error('第' + (i+1) + '条数据提交失败：' + res.message)
              }
            }
          } else {
            sbwl.push(item.matName);
            sb++;
          }
        } catch (err) {
          sbwl.push(item.matName);
          sb++;
        }
      }
      this.saveLoading = false;
      this.submitLoading = false;
      //console.log('cg', cg);
      //console.log('sb', sb);
      if (sb == 0 && qx == 0) {
        this.$message.success("执行完毕，成功提交 " + cg + " 条数据");
      } else {
        this.$message.warning(
          "执行完毕，成功提交 " +
          cg +
          " 条数据，失败 " +
          sb +
          " 条：[" +
          sbwl +
          "], 取消" +
          qx +
          " 条"
        );
      }
      this.searchData();
    },
    // 在检验数据是否重复提交时只提醒一次
    async subDataAndHintOne() {
      this.saveLoading = true;
      this.submitLoading = true;
      let cg = 0; // 成功
      let sb = 0; // 失败
      let qx = 0; // 取消
      let sbwl = []; // 失败的物料centerPersonnelScheduling
      let stIds = [];
      let needcheck = true; //记录是不是第一次提醒
      for (let k = 0; k < this.selectVal.length; k++) {
        stIds.push(this.selectVal[k].stId);
      }
      let param = { needcheck: needcheck, stIds: stIds };
      for (let i = 0; i < this.selectVal.length; i++) {
        let item = this.selectVal[i];
        try {
          // console.log(i + ":" + param.needcheck);
          const cfs = await this.axios.post(
            "pass/testManagement/v1/limssampletests/queryRepetable",
            param,
            { individualType: "json" }
          );
          if (cfs.code == 0 || cfs.code == 200) {
            param.needcheck = false; //false 表示待提交的样全部已经进行了查重，不需要再次查重
            var hintInfo = cfs.message;
            var msgArr = hintInfo.split("&");
            if (cfs.data) {
              let flag = await this.$confirm(msgArr[0], "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
              })
                .then(() => { })
                .catch((err) => {
                  qx++;
                  return "cancel";
                });
              if (flag !== "cancel") {
                const res = await this.axios.post(
                  "pass/testManagement/v1/limssampletests/errorWarningRemind?stId=" +
                  item.stId,
                  { individualType: "json" }
                );
                if (res.code == 0 || res.code == 200) {
                  if (res.data) {
                    if (res.data.code == 0) {
                      let temp = res.data.object;
                      const res2 = await this.axios.post(
                        "pass/testManagement/v1/limssampletests/submit?stId=",
                        item.stId,
                        { individualType: "json" }
                      );
                      if (res2.code == 0 || res2.code == 200) {
                        cg++;
                      } else {
                        sbwl.push(res2.message);
                        sb++;
                      }
                    } else {
                      await this.$confirm(
                        "第" +
                        (i + 1) +
                        "条数据, " +
                        `${res.data.message},是否继续?`,
                        "超差预警提醒",
                        {
                          confirmButtonText: "确定",
                          cancelButtonText: "取消",
                          type: "warning",
                        }
                      )
                        .then(async () => {
                          const res4 = await this.axios.post(
                            "pass/testManagement/v1/limssampletests/submit?stId=" +
                            item.stId,
                            { individualType: "json" }
                          );
                          if (res4.code == 0 || res4.code == 200) {
                            cg++;
                          } else {
                            sbwl.push(res4.message);
                            sb++;
                          }
                        })
                        .catch((err) => {
                          // 选择 取消
                          qx++;
                        });
                    }
                  } else {
                    const res4 = await this.axios.post(
                      "pass/testManagement/v1/limssampletests/submit?stId=" +
                      item.stId,
                      { individualType: "json" }
                    );
                    if (res4.code == 0 || res4.code == 200) {
                      cg++;
                    } else {
                      sbwl.push(res4.message);
                      sb++;
                    }
                  }
                } else {
                  sbwl.push(item.matName);
                  sb++;
                  this.$message.error(
                    "第" + (i + 1) + "条数据提交失败：" + res.message
                  );
                }
              } else {
                break;
              }
            } else {
              const res = await this.axios.post(
                "pass/testManagement/v1/limssampletests/errorWarningRemind?stId=" +
                item.stId,
                { individualType: "json" }
              );
              // console.log('res.data=' + res.data + ",res.code=" + res.code);
              if (res.code == 0 || res.code == 200) {
                if (res.data) {
                  if (res.data.code == 0) {
                    let temp = res.data.object;
                    const res2 = await this.axios.post(
                      "pass/testManagement/v1/limssampletests/submit?stId=" +
                      item.stId,
                      { individualType: "json" }
                    );
                    if (res2.code == 0 || res2.code == 200) {
                      cg++;
                    } else {
                      sbwl.push(res2.message);
                      sb++;
                    }
                  } else {
                    await this.$confirm(
                      "第" +
                      (i + 1) +
                      "条数据, " +
                      `${res.data.message},是否继续?`,
                      "超差预警提醒",
                      {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                      }
                    )
                      .then(async () => {
                        const res4 = await this.axios.post(
                          "pass/testManagement/v1/limssampletests/submit?stId=" +
                          item.stId,
                          { individualType: "json" }
                        );
                        if (res4.code == 0 || res4.code == 200) {
                          cg++;
                        } else {
                          sbwl.push(res4.message);
                          sb++;
                        }
                      })
                      .catch((err) => {
                        // 选择 取消
                        qx++;
                      });
                  }
                } else {
                  const res4 = await this.axios.post(
                    "pass/testManagement/v1/limssampletests/submit?stId=" +
                    item.stId,
                    { individualType: "json" }
                  );
                  if (res4.code == 0 || res4.code == 200) {
                    cg++;
                  } else {
                    sbwl.push(res4.message);
                    sb++;
                  }
                }
              } else {
                sbwl.push(item.matName);
                sb++;
                //this.$message.error('第' + (i+1) + '条数据提交失败：' + res.message)
              }
            }
          } else {
            sbwl.push(item.matName);
            sb++;
          }
        } catch (err) {
          sbwl.push(item.matName);
          sb++;
          // console.log('eeeeee');
        }
      }
      this.saveLoading = false;
      this.submitLoading = false;
      //console.log('cg', cg);
      //console.log('sb', sb);
      if (sb == 0 && qx == 0) {
        this.$message.success("执行完毕，成功提交 " + cg + " 条数据");
      } else {
        // this.$message.warning('执行完毕，成功提交 ' + cg + ' 条数据，失败 ' + sb + ' 条：['+sbwl+'], 取消' + qx + ' 条');
        this.$message.warning(
          "执行完毕，成功提交 " +
          cg +
          " 条数据，失败 " +
          sb +
          " 条：[" +
          sbwl +
          "], 取消" +
          msgArr[1] +
          " 条"
        );
      }
      this.searchData();
    },
    retest2(itemTypeCode) {
      if (this.selectVal4.length === 0) {
        this.$message.warning("请至少勾选1条需要增加任务的数据!");
        return;
      }
      let count = 14;
      if (this.selectVal4.length > count) {
        return this.$message.warning(
          "单次添加的任务数量不能超过" + (count + 1) + "条"
        );
      }
      for (let i = 0; i < this.selectVal4.length; i++) {
        if (this.selectVal4[i].validFlag === 0) {
          return this.$message.warning(
            "已停用的数据无法增加任务，请重新查询之后重新操作!"
          );
        }
      }
      this.resetShowFlag = !this.resetShowFlag;
      this.Params = Object.assign([], this.selectVal4);
      this.itemTypeCode = itemTypeCode;
    },
    // 增加任务
    retest(itemTypeCode) {
      if (itemTypeCode === "480405") {
        // 增加标样任务
        if (this.selectVal.length !== 1) {
          this.$message.warning("只能勾选1条需要增加标样的数据!");
          return;
        }
        if (this.selectVal[0].stateFlag === 3) {
          return this.$message.warning(
            "已提交的数据无法增加任务，请重新查询之后重新操作!"
          );
        }
        if (this.selectVal[0].validFlag === 0) {
          return this.$message.warning(
            "已停用的数据无法增加任务，请重新查询之后重新操作!"
          );
        }
      } else if (itemTypeCode === "480403") {
        // 增加检验任务
        if (this.selectVal.length === 0) {
          this.$message.warning("请至少勾选1条需要增加任务的数据!");
          return;
        }
        let count = 14;
        if (this.selectVal.length > count) {
          return this.$message.warning(
            "单次添加的任务数量不能超过" + (count + 1) + "条"
          );
        }
        for (let i = 0; i < this.selectVal.length; i++) {
          if (this.selectVal[i].validFlag === 0) {
            return this.$message.warning(
              "已停用的数据无法增加任务，请重新查询之后重新操作!"
            );
          }
          // if (this.selectVal[i].stateFlag === 3) {
          //   return this.$message.warning('已提交的数据无法增加任务，请重新查询之后重新操作!')
          // }
        }
      }
      this.resetShowFlag = !this.resetShowFlag;
      this.Params = Object.assign([], this.selectVal);
      this.itemTypeCode = itemTypeCode;
    },
    //自动采集数据
    autoCollet() {
      if (JSON.stringify(this.analyzeVal) === "{}") {
        this.isAutoColl = false;
        clearInterval(this.interval);
        this.$message.warning(
          "请先点击选中一条需要自动采集的已接收表格中的数据！"
        );
        return;
      }
      if (this.analyzeVal.stateFlag == 3) {
        this.isAutoColl = false;
        clearInterval(this.interval);
        this.$message.warning(
          "已提交的数据不能进行自动采集,请选择状态为未处理的数据！"
        );
        return;
      }
      if (this.analyzeVal.stateFlag == 4) {
        this.isAutoColl = false;
        clearInterval(this.interval);
        this.$message.warning(
          "已经二审的数据不能进行自动采集,请选择状态为未处理的数据！"
        );
        return;
      }
      if (this.analyzeVal.stateFlag == 5) {
        this.isAutoColl = false;
        clearInterval(this.interval);
        this.$message.warning(
          "已三审的数据不能进行自动采集,请选择状态为未处理的数据！"
        );
        return;
      }
      this.$refs.autoCollData.validate((valid) => {
        if (valid) {
          let obj = {
            eqpNo: this.autoCollData.eqpNo,
            stId: this.analyzeVal.stId,
          };
          this.autoColletLoading = true;
          this.axios
            .post(
              "pass/testManagement/v1/limssampletests/voluntarilygather",
              obj,
              { individualType: "json" }
            )
            .then((res) => {
              if (res.code == 0 || res.code == 200) {
                this.$message.success(res.message);
                this.searchAnalyze2(this.analyzeVal);
              } else {
                this.$message.error(res.message);
              }
              this.autoColletLoading = false;
            })
            .catch((err) => {
              // console.log("异常")
              this.autoColletLoading = false;
              this.$message.error(err.message);
            });
        } else {
          this.isAutoColl = false;
          clearInterval(this.interval);
          return this.$message.warning("设备选择异常，采集中断!");
        }
      });
    },
    // 批量采集弹窗
    collectData() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选测试项目的数据");
        return;
      }
      for (let item of this.selectVal) {
        if (item.stateFlag != 0) {
          this.$message.warning("请选择状态为未处理的数据");
          return;
        }
        if (item.validFlag == "0") {
          this.$message.warning("请勾选有效数据");
          return;
        }
      }
      this.dataCollectionFlag = !this.dataCollectionFlag;
      this.Params2 = this.selectVal;
    },
    // 撤销采集数据
    backCollect() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选数据");
        return;
      }
      for (let item of this.selectVal) {
        if (item.stateFlag != 0) {
          this.$message.warning("请选择状态为未处理的数据");
          return;
        }
        if (item.validFlag == "0") {
          this.$message.warning("请选择有效数据");
          return;
        }
      }
      this.backLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/backCollect",
          this.selectVal,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.succeed) {
            this.$message.success(res.message);
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.backLoading = false;
        })
        .catch((e) => {
          this.backLoading = false;
          this.$message.error(e.message);
        });
    },
    //计算
    formulacom() {
      if (this.tableData3.length < 1) {
        this.$message.warning("表格中无数据，无法进行计算");
        return;
      }
      if (this.analyzeVal.stateFlag == 3) {
        this.$message.warning(
          "已提交的数据不能进行计算,请选择状态为未处理的数据进行操作"
        );
        return;
      }
      if (this.analyzeVal.validFlag == "0") {
        this.$message.warning("停用的数据不能进行计算");
        return;
      }
      this.formulacomLoading = true;
      this.tableData3.forEach((item) => {
        if (item.dataTypeCode === "482504" && item.reviseValue) {
          item.reviseValue = formatDate(
            item.reviseValue,
            "yyyy-MM-dd HH:mm:ss"
          );
        }
      });
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/formulacom",
          this.tableData3,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchAnalyze(this.analyzeVal, true);
          } else {
            this.$message.error(res.message);
          }
          this.formulacomLoading = false;
        })
        .catch((err) => {
          this.formulacomLoading = false;
          this.$message.error(err.message);
        });
    },
    // 移除文件
    handleRemove(file, fileList) {
      const data = this.axios.delete(`/icore.icp.web${file.url}`);
      if (data.data) {
        if (data.data.size - 0 > 0) {
          return this.$message.success("文件删除成功");
        } else {
          this.$message.error("文件删除失败，请重试");
        }
      }
    },
    // 处理文件个数超出限制
    handleExceed(files, fileList) {
      if (files.length + fileList.length > 5) {
        return this.$message.warning(
          `当前限制选择 5 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length
          } 个文件`
        );
      }
    },
    httpRequest(e) {
      if (!e.file) {
        return false;
      }
      let file = new FormData();
      file.append("file", e.file);
      let config = {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      };
      this.axios
        .post("pass/baseManagement/v1/file/upload", file, config)
        .then((res) => {
          if (res.code === "0" || res.code === "200") {
            if (
              this.saveFileRow.archiveId &&
              this.saveFileRow.archiveId.length > 0 &&
              this.saveFileRow.archiveId.match("oss-volume-")
            ) {
              this.saveFileRow.archiveId =
                this.saveFileRow.archiveId + "#" + res.data[0].fileName;
            } else {
              this.saveFileRow.archiveId = res.data[0].fileName;
            }
            this.saveData();
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },
    //批量录入
    batchData() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选测试项目的数据");
        return;
      }
      let temp = [];
      this.selectVal.map((item) => {
        temp.push(item.stId);
      });
      this.batchDataLoading = true;
      this.axios
        .post("pass/testManagement/v1/limssampletestds/transitionData", temp, {
          individualType: "json",
        })
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            if (res.data.badyData.length > 0) {
              // 增加第一行用于批量修改
              let obj = Object.assign({}, res.data.badyData[0]);
              for (let key in obj) {
                obj[key] = "";
              }
              let arr = res.data.badyData;
              arr.splice(0, 0, obj);
              this.cols = res.data.head;
              this.tableData = arr;
              this.testTable = res.data.headBabyData;
              this.resData = res.data.sampleTestDFlags;
            }
            this.batchShow = true;
            this.$nextTick(() => {
              this.$refs["tablePllr"].bodyWrapper.scrollTop = 0;
            });
          } else {
            this.$message.error(res.message);
          }
          this.batchDataLoading = false;
        })
        .catch((e) => {
          this.batchDataLoading = false;
          this.$message.error(e.message);
        });
    },
    jisuan() {
      let temp = [];
      this.resultData = [];
      // 第一行不提交
      let arr = this.tableData.slice(0);
      arr.splice(0, 1);
      arr.forEach((item, index) => {
        let obj = Object.assign(item);
        delete obj.index;
        //将对象转化成数组、循环获取到index
        let tempArr = Object.keys(obj);
        tempArr.forEach((items, indexs) => {
          this.resultData.push({
            anlyValue: obj[items],
            stIdD: this.testTable[index][items],
          });
        });
      });
      this.keepEquipment();
      let tempData = [];
      this.selectVal.map((item) => {
        tempData.push(item.stId);
      });
      this.batchLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/batchUpdateLimsSampleTestDList",
          this.resultData,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.axios
              .post(
                "pass/testManagement/v1/limssampletests/batchInputFormulacom?itemSize=" +
                this.itemSize,
                tempData,
                { individualType: "json" }
              )
              .then((res) => {
                if (res.code == 0 || res.code == 200) {
                  this.axios
                    .post(
                      "pass/testManagement/v1/limssampletestds/transitionData",
                      tempData,
                      { individualType: "json" }
                    )
                    .then((res) => {
                      if (res.data.badyData.length > 0) {
                        // 增加第一行用于批量修改
                        let obj = Object.assign({}, res.data.badyData[0]);
                        for (let key in obj) {
                          obj[key] = "";
                        }
                        let arr = res.data.badyData;
                        arr.splice(0, 0, obj);
                        this.cols = res.data.head;
                        this.tableData = arr;
                        this.testTable = res.data.headBabyData;
                        this.resData = res.data.sampleTestDFlags;
                        if (this.analyzeVal && this.analyzeVal.id) {
                          this.searchAnalyze(this.analyzeVal, true);
                        }
                      }
                    })
                    .catch((e) => {
                      this.$message.error(e.message);
                    });
                } else {
                  this.$message.error(res.message);
                }
              })
              .catch((err) => {
                this.$message.error(err.message);
              });
          } else {
            this.$message.error(res.message);
          }
          this.batchLoading = false;
        })
        .catch((err) => {
          this.batchLoading = false;
          this.$message.error(err.message);
        });
    }, //保存设备
    keepEquipment() {
      let ids = []; //需要保存的数据的id
      for (let i = 0; i < this.selectVal.length; i++) {
        let item = this.selectVal[i];
        ids.push(item.stId);
      }
      //获取仪器名称集合
      let strr = [];
      this.equipment.nantNo.forEach((a) => {
        this.matNameType.forEach((a1) => {
          if (a == a1.eqpNo) {
            strr.push(a1.eqpName + "(" + a1.eqpUseNo + ")");
          }
        });
      });
      let map = {
        stId: ids,
        itemTemp: this.equipment.itemTemp,
        nantNo: strr,
      };
      this.axios
        .post("pass/testManagement/v1/limssampletests/keepEquipment", map, {
          individualType: "json",
        })
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((err) => {
          this.$message.error(err.message);
        });
    },
    imgPreView(row, fileName) {
      this.axios
        .get(
          "pass/baseManagement/v1/file/download/" + fileName,
          { responseType: "blob" },
          { headers: { "content-type": "application/x-www-form-urlencoded" } }
        )
        .then((res) => {
          let blob = new Blob([res]);
          let elink = document.createElement("a");
          elink.download = fileName;
          elink.style.display = "none";
          elink.target = "_blank";
          elink.href = URL.createObjectURL(blob);
          document.body.appendChild(elink);
          elink.click();
          URL.revokeObjectURL(elink.href); // 释放URL对象
          document.body.removeChild(elink);
        })
        .catch((e) => {
          return this.$message.error(e.message);
        });
    },
    saveUpload(row) {
      this.saveFileRow = row;
    },
    // 计算并提交
    submitBatch() {
      this.batchShow = false;
      let temp = [];
      this.resultData = [];
      // 第一行不提交
      let arr = this.tableData.slice(0);
      arr.splice(0, 1);
      arr.forEach((item, index) => {
        let obj = Object.assign(item);
        delete obj.index;
        //将对象转化成数组、循环获取到index
        let tempArr = Object.keys(obj);
        tempArr.forEach((items, indexs) => {
          // console.log('名字'+items +'数值'+ obj[items]+'数组的id'+this.testTable[index][items]);
          this.resultData.push({
            anlyValue: obj[items],
            stIdD: this.testTable[index][items],
          });
        });
      });
      this.keepEquipment();
      let tempData = [];
      this.selectVal.map((item) => {
        tempData.push(item.stId);
      });
      this.batchLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/batchUpdateLimsSampleTestDList",
          this.resultData,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            if (this.isOneHint) {
              this.subDataAndHintOne();
            } else {
              this.subData3();
            }
          } else {
            this.$message.error(res.message);
          }
          this.batchLoading = false;
        })
        .catch((err) => {
          this.batchLoading = false;
          this.$message.error(err.message);
        });
      // let temp = []
      // this.resultData = []
      // // 第一行不提交
      // let arr = this.tableData.slice(0);
      // arr.splice(0,1);
      // arr.forEach((item,index) =>{
      //   let obj = Object.assign(item)
      //   delete obj.index
      //   //将对象转化成数组、循环获取到index
      //   let tempArr = Object.keys(obj)
      //   tempArr.forEach((items,indexs) =>{
      //     // console.log('名字'+items +'数值'+ obj[items]+'数组的id'+this.testTable[index][items]);
      //     this.resultData.push({anlyValue:obj[items],stIdD:this.testTable[index][items]})

      //   })
      // })
      // let tempData = []
      // this.selectVal.map(item =>{
      //   tempData.push(item.stId)
      // })
      // this.batchLoading = true
      // this.axios.post('pass/testManagement/v1/limssampletestds/batchUpdateLimsSampleTestDList',this.resultData,{individualType: 'json'}).then(res =>{
      //   if (res.code == 0 || res.code == 200) {
      //     this.axios.post('pass/testManagement/v1/limssampletests/formulacomByStIds',tempData,{individualType: 'json'}).then(res =>{
      //       if (res.code == 0 || res.code == 200) {
      //         this.piliangtijiao = tempData;
      //         console.log(this.piliangtijiao)
      //         this.subData30()
      //         // for(let i=0;i<tempData.length;i++){
      //           // this.axios.post('pass/testManagement/v1/limssampletests/submit?stId=' + tempData[i],{individualType: 'json'}).then(res => {
      //           //   if(res.code== 0 || res.code == 200) {
      //           //     this.$message.success(res.message);
      //           //   } else {
      //           //     this.$message.error(res.message)
      //           //   }
      //           //   if(i == tempData.length-1){
      //           //     setTimeout(() => {
      //           //       this.searchData();
      //           //     }, 500);
      //           //   }
      //           // }).catch(e => {
      //           //   this.$message.error(e.message)
      //           // })
      //         // }
      //       }else{
      //         this.$message.error(res.message)
      //       }
      //     }).catch(err =>{
      //       this.$message.error(err.message)
      //     })
      //     this.closebatch()
      //   }else{
      //     this.$message.error(res.message)
      //   }
      //   this.batchLoading = false
      // }).catch(err =>{
      //   this.batchLoading = false
      //   this.$message.error(err.message)
      // })
    },
    //保存批量数据
    saveBatch() {
      let temp = [];
      this.resultData = [];
      // 第一行不提交
      let arr = this.tableData.slice(0);
      arr.splice(0, 1);
      arr.forEach((item, index) => {
        let obj = Object.assign(item);
        delete obj.index;
        //将对象转化成数组、循环获取到index
        let tempArr = Object.keys(obj);
        tempArr.forEach((items, indexs) => {
          // console.log('名字'+items +'数值'+ obj[items]+'数组的id'+this.testTable[index][items]);
          this.resultData.push({
            anlyValue: obj[items],
            stIdD: this.testTable[index][items],
          });
        });
      });
      let tempData = [];
      this.selectVal.map((item) => {
        tempData.push(item.stId);
      });
      this.batchLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/batchUpdateLimsSampleTestDList",
          this.resultData,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.axios
              .post(
                "pass/testManagement/v1/limssampletests/formulacomByStIds",
                tempData,
                { individualType: "json" }
              )
              .then((res) => {
                if (res.code == 0 || res.code == 200) {
                  this.$message.success(res.message);
                } else {
                  this.$message.error(res.message);
                }
              })
              .catch((err) => {
                this.$message.error(err.message);
              });
            this.searchData();
            this.closebatch();
          } else {
            this.$message.error(res.message);
          }
          this.batchLoading = false;
        })
        .catch((err) => {
          this.batchLoading = false;
          this.$message.error(err.message);
        });
    },
    getCompany() {
      this.axios
        .get("pass/baseManagement/v1/limslrcemps/" + userId)
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.userdeptNo = res.data ? res.data.deptNo : "";
            this.usersectionNo = res.data ? res.data.sectionNo : "";
            this.userjobs = res.data ? res.data.postNo : "";
          } else {
            this.$message.error(e.message);
          }
        })
        .catch((e) => {
          this.$message.error(e.message);
        });
    },
    closebatch() {
      this.batchShow = false;
      this.batchLoading = false;
      this.recallShow = false;
      this.cols = [];
      this.tableData = [];
      this.testTable = [];
    },
    closeBly() {
      this.dialog.show = false;
      this.addByShow = false;
      this.dialog.form.data.sampleNo = "";
      this.dialog.form.tableData = [];
    },
    inputData(val, index, prop) {
      let that = this;
      // 修改第一行数据，联动修改同列其他行数据
      if (index == 0 && that.tableData.length > 1) {
        for (let i = 1; i < that.tableData.length; i++) {
          that.tableData[i][prop] = val;
        }
      }
    },
    sign(val, row, prop) {
      if (val) {
        row[prop] = formatDate(val, "yyyy-MM-dd HH:mm:ss");
      }
    },
    //保存
    saveData() {
      if (this.tableData3.length < 1) {
        this.$message.warning("表格中无数据，无法进行保存");
        return;
      }
      if (this.analyzeVal.stateFlag == 3) {
        this.$message.warning(
          "已提交的数据不能进行保存,请选择状态为未处理的数据进行操作"
        );
        return;
      }
      if (this.analyzeVal.validFlag == "0") {
        this.$message.warning("停用的数据不能进行保存");
        return;
      }
      this.saveLoading = true;
      this.tableData3.forEach((item) => {
        if (item.dataTypeCode === "482504" && item.reviseValue) {
          item.reviseValue = formatDate(
            item.reviseValue,
            "yyyy-MM-dd HH:mm:ss"
          );
        }
      });
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/testAnalysisUpdateLimsSampleTestDList",
          this.tableData3,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchAnalyze(this.analyzeVal, true);
            // this.searchData()
          } else {
            this.$message.error(res.message);
          }
          this.saveLoading = false;
        })
        .catch((err) => {
          this.saveLoading = false;
          this.$message.error(err.message);
        });
    },
    //查询操作
    searchData() {
      this.pageIndex = 1;
      this.pageSize = 100;
      this.pageSize_dep = 100;
      this.pageIndex_dep = 1;
      this.DataMain(); // 待接任务
      this.DataDep(); // 已接任务
      this.Data4(); // 已提交、无效数据
      this.Data5(); // 无效数据
    },
    // 测试管理-待接任务
    DataMain() {
      // this.saveMainData = {}
      let startTime = "";
      let endTime = "";
      if (!this.searchForm.times) {
        // startTime = null
        // endTime = null
      } else {
        // startTime = this.searchForm.times[0] + ' 00:00:00'
        // endTime = this.searchForm.times[1] + ' 23:59:59'
        startTime = this.searchForm.times[0];
        endTime = this.searchForm.times[1];
      }
      // 中心分析室查询待接任务不用时间参数
      if (this.userdeptNo != null && this.userdeptNo === "P31301100") {
        startTime = "";
        endTime = "";
      }
      let obj = {
        object: {
          sampleTypeCode: this.searchForm.sampleTypeCode,
          // 'isCtrl':0,
          functionCode: "484003",
          stateFlag: 1,
          optNo: userId,
        },
        mode3: this.searchForm.matName, // 样品名称
        pageSize: this.pageSize,
        pageIndex: this.pageIndex,
        startTime: startTime,
        endTime: endTime,
        deptName:this.searchForm.type,
      };
      this.tableLoading1 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limstasktests/queryLimsTaskTestPage2",
          obj,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData1 = res.data.list;
            this.total_main = res.data.total;
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading1 = false;
        })
        .catch((err) => {
          this.tableLoading1 = false;
          this.$message.error(err.message);
        });
    },
    // 已接任务
    DataDep() {
      this.tableData3 = [];
      let startTime = "";
      let endTime = "";
      this.analyzeVal = {};
      if (!this.searchForm.times) {
        startTime = "";
        endTime = "";
      } else {
        // startTime = this.searchForm.times[0] + ' 00:00:00'
        // endTime = this.searchForm.times[1] + ' 23:59:59'
        startTime = this.searchForm.times[0];
        endTime = this.searchForm.times[1];
      }
      let obj = {
        object: {
          matName: this.searchForm.matName,
          sampleTypeCode: this.searchForm.sampleTypeCode,
          validFlag: "1",
          sampleNo: this.searchForm.sampleNo,
          createNo: userId,
        },
        list: [0], // 已接任务、未处理状态
        list2: [484003], // 测试分析模块
        pageSize: this.pageSize_dep,
        pageIndex: this.pageIndex_dep,
        startTime: startTime,
        endTime: endTime,
        deptName:this.searchForm.type,
      };
      this.tableLoading2 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/queryLimsSampleTestPage1",
          obj,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData2 = res.data.list;
            this.total_dep = res.data.total;
            this.tableData2.forEach((item) => {
              item.stateFlagName =
                item.stateFlag == "0"
                  ? "未处理"
                  : item.stateFlag == "3"
                    ? "已提交"
                    : "";
              item.validFlagName =
                item.validFlag == 0
                  ? "无效"
                  : item.validFlag == 1
                    ? "有效"
                    : "";
              if (item.sampleTypeCode != 480102) {
                item.suppName = "";
                item.acceptName = "";
              }
            });
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading2 = false;
        })
        .catch((err) => {
          this.tableLoading2 = false;
          this.$message.error(err.message);
        });
    },
    // 已提交、或者无效数据
    Data4() {
      let startTime = "";
      let endTime = "";
      if (!this.searchForm.times) {
        startTime = "";
        endTime = "";
      } else {
        /*startTime = this.searchForm.times[0] + ' 00:00:00'
        endTime = this.searchForm.times[1] + ' 23:59:59'*/
        startTime = this.searchForm.times[0];
        endTime = this.searchForm.times[1];
      }
      let obj = {
        object: {
          matName: this.searchForm.matName,
          sampleTypeCode: this.searchForm.sampleTypeCode,
          sampleNo: this.searchForm.sampleNo,
          createNo: userId,
        },
        mode: "1", // mode 1 表示查询已提交、或者无效数据
        list: [3],
        list2: [484003], // 测试分析模块
        pageSize: this.pageSize4,
        pageIndex: this.pageIndex4,
        startTime: startTime,
        endTime: endTime,
        deptName:this.searchForm.type,
      };
      this.tableLoading4 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/queryLimsSampleTestPage",
          obj,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData4 = res.data.list;
            this.total4 = res.data.total;
            this.tableData4.forEach((item) => {
              item.stateFlagName =
                item.stateFlag == "0"
                  ? "未处理"
                  : item.stateFlag == "3"
                    ? "已提交"
                    : "";
              item.validFlagName =
                item.validFlag == 0
                  ? "无效"
                  : item.validFlag == 1
                    ? "有效"
                    : "";
              if (item.sampleTypeCode != 480102) {
                item.suppName = "";
                item.acceptName = "";
              }
            });
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading4 = false;
        })
        .catch((err) => {
          this.tableLoading4 = false;
          this.$message.error(err.message);
        });
    },
    dialogDeleteData(row, index) {
      row.glMatName = "";
      row.glSampleNo = "";
      row.glCount = 1;
      this.dialog.form.tableData.splice(index, 1);
      this.glDialog.totalPage = this.glDialog.totalPage - 1;
    },
    Data5() {
      let startTime = "";
      let endTime = "";
      if (!this.searchForm.times) {
        startTime = "";
        endTime = "";
      } else {
        // startTime = this.searchForm.times[0] + ' 00:00:00'
        // endTime = this.searchForm.times[1] + ' 23:59:59'
        startTime = this.searchForm.times[0];
        endTime = this.searchForm.times[1];
      }
      let obj2 = {
        object: {
          matName: this.searchForm.matName,
          sampleTypeCode: this.searchForm.sampleTypeCode,
          sampleNo: this.searchForm.sampleNo,
          createNo: userId,
        },
        mode: "0", // mode 0 表示查询无效数据
        list2: [484003], // 测试分析模块
        pageSize: this.pageSize42,
        pageIndex: this.pageIndex42,
        startTime: startTime,
        endTime: endTime,
        deptName:this.searchForm.type,
      };
      this.tableLoading42 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/queryLimsSampleTestPage",
          obj2,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData42 = res.data.list;
            this.total42 = res.data.total;
            this.tableData42.forEach((item) => {
              item.stateFlagName =
                item.stateFlag == "0"
                  ? "未处理"
                  : item.stateFlag == "3"
                    ? "已提交"
                    : "";
              item.validFlagName =
                item.validFlag == 0
                  ? "无效"
                  : item.validFlag == 1
                    ? "有效"
                    : "";
              if (item.sampleTypeCode != 480102) {
                item.suppName = "";
                item.acceptName = "";
              }
            });
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading42 = false;
        })
        .catch((err) => {
          this.tableLoading42 = false;
          this.$message.error(err.message);
        });
    },
    searchAnalyze2(row) {
      //保存点击的样品信息数据，保存、提交操作时刷新
      this.saveAnaly = {};
      this.analyzeVal = row;
      this.tableLoading3 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/queryLimsSampleTestDList?stId=" +
          this.analyzeVal.id
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData3 = res.data;
            this.tableData3.forEach((item) => {
              item.showInput =
                item.defaultValue && item.defaultValue.indexOf("#") > -1
                  ? false
                  : true;
              item.defaultList = item.defaultValue
                ? item.defaultValue.split("#")
                : [];
              item.anlyValue = item.anlyValue
                ? item.anlyValue
                : item.defaultList[0];
              item.isReportName =
                item.isReport == 0 ? "否" : item.isReport == 1 ? "是" : "";
              item.isAlarmName =
                item.isAlarm == 0 ? "否" : item.isAlarm == 1 ? "是" : "";
              if (item.anlyValue && item.maxValue && item.maxSign) {
                let anlyVal = item.anlyValue;
                if (
                  item.anlyValue.startsWith("<") ||
                  item.anlyValue.startsWith("≤")
                ) {
                  anlyVal = item.anlyValue.slice(1);
                }
                if (item.maxSign === "<") {
                  let i = anlyVal - 0 >= item.maxValue - 0 ? 1 : -1;
                  item.warning = i;
                } else if (item.maxSign === "<=") {
                  let i = anlyVal - 0 > item.maxValue - 0 ? 1 : -1;
                  item.warning = i;
                }
              }
              if (item.anlyValue && item.minValue && item.minSign) {
                let anlyVal = item.anlyValue;
                if (
                  item.anlyValue.startsWith("<") ||
                  item.anlyValue.startsWith("≤")
                ) {
                  anlyVal = item.anlyValue.slice(1);
                }
                if (item.minSign === ">") {
                  let i = anlyVal - 0 <= item.minValue - 0 ? 0 : -1;
                  item.warning = i;
                } else if (item.minSign === ">=") {
                  let i = anlyVal - 0 < item.minValue - 0 ? 0 : -1;
                  item.warning = i;
                }
              }
            });
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading3 = false;
        })
        .catch((err) => {
          this.tableLoading3 = false;
          this.$message.error(err.message);
        });
    },
    //点击测试项目，查询分析项目
    searchAnalyze(row, clear, event) {
      this.stopall();
      //保存点击的样品信息数据，保存、提交操作时刷新
      this.saveAnaly = {};
      this.analyzeVal = row;
      this.tableLoading3 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/queryLimsSampleTestDList?stId=" +
          this.analyzeVal.id
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData3 = res.data;
            this.tableData3.forEach((item) => {
              item.showInput =
                item.defaultValue && item.defaultValue.indexOf("#") > -1
                  ? false
                  : true;
              item.defaultList = item.defaultValue
                ? item.defaultValue.split("#")
                : [];
              item.anlyValue = item.anlyValue
                ? item.anlyValue
                : item.defaultList[0];
              item.isReportName =
                item.isReport == 0 ? "否" : item.isReport == 1 ? "是" : "";
              item.isAlarmName =
                item.isAlarm == 0 ? "否" : item.isAlarm == 1 ? "是" : "";
              if (item.anlyValue && item.maxValue && item.maxSign) {
                let anlyVal = item.anlyValue;
                if (
                  item.anlyValue.startsWith("<") ||
                  item.anlyValue.startsWith("≤")
                ) {
                  anlyVal = item.anlyValue.slice(1);
                }
                if (item.maxSign === "<") {
                  let i = anlyVal - 0 >= item.maxValue - 0 ? 1 : -1;
                  item.warning = i;
                } else if (item.maxSign === "<=") {
                  let i = anlyVal - 0 > item.maxValue - 0 ? 1 : -1;
                  item.warning = i;
                }
              }
              if (item.anlyValue && item.minValue && item.minSign) {
                let anlyVal = item.anlyValue;
                if (
                  item.anlyValue.startsWith("<") ||
                  item.anlyValue.startsWith("≤")
                ) {
                  anlyVal = item.anlyValue.slice(1);
                }
                if (item.minSign === ">") {
                  let i = anlyVal - 0 <= item.minValue - 0 ? 0 : -1;
                  item.warning = i;
                } else if (item.minSign === ">=") {
                  let i = anlyVal - 0 < item.minValue - 0 ? 0 : -1;
                  item.warning = i;
                }
              }
            });
            // if (this.isAutoColl && notColl instanceof PointerEvent){
            //    this.autoCollet();
            // }
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading3 = false;
        })
        .catch((err) => {
          this.tableLoading3 = false;
          this.$message.error(err.message);
        });
    },
    //表格数据右移
    rightData2(row) {
      //新增的数据清空id
      row.cretNoD = "";
      this.table.addTest.push(row);
    },
    showCell(row) {
      this.tabClickIndex = row.index;
    },
    saveCell(row) {
      this.tabClickIndex = null;
    },
    tableRowName({ row, rowIndex }) {
      row.index = rowIndex;
      if (row.warning - 0 === 1) {
        return "row-orange"; //橙色
      }
      if (row.warning - 0 === 0) {
        return "error-row"; //红色
      }
    },
    handleSizeChangeMain(pageSize) {
      this.pageIndex = 1;
      this.pageSize = pageSize;
      this.DataMain();
    },
    handleSizeChangeDep(pageSize) {
      this.pageIndex_dep = 1;
      this.pageSize_dep = pageSize;
      this.DataDep();
    },
    handleSizeChange4(pageSize) {
      this.pageIndex4 = 1;
      this.pageSize4 = pageSize;
      this.Data4();
    },
    handleSizeChange5(pageSize) {
      this.pageIndex42 = 1;
      this.pageSize42 = pageSize;
      this.Data5();
    },
    glDialogSizeTest(size) {
      this.glDialog.pageSize = size;
    },
    glDialogPageChangeTest(index) {
      this.glDialog.pageNum = index;
    },
    SizeTest(size) {
      this.pageTests.pageSize = size;
      this.getDataListTest2();
    },
    pageChangeTest(index) {
      this.pageTests.pageNum = index;
      this.getDataListTest2();
    },
    tableRowClassName({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 2) {
        if (row.yearMonth === "1") {
          return "error-row";
        }
      }
      if (row.validFlag !== "1") {
        return "error-row";
      } else if (row.stateFlag === "3") {
        return "error-green";
      }
      return "";
      // if (columnIndex === 0) {
      //   if (row.validFlag !== '1') {
      //       return 'error-row';
      //   } else if (row.stateFlag === '3') {
      //     return 'error-green';
      //   }
      // }
      // return ''
    },
    tableRowBatch({ row, column, rowIndex, columnIndex }) { },
    fxTableRowClassName({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 3) {
        //最大符号与最小符号必须同时存在，最大值与最小值必须有一项要有值，否则直接return不进入判断
        if (row.maxSign && row.minSign && (row.maxValue || row.minValue)) {
          if (row.maxSign == "<=" && row.minSign == ">=") {
            if (
              Number(row.anlyValue) <=
              Number(row.maxValue ? row.maxValue : Infinity) &&
              Number(row.anlyValue) >= Number(row.minValue ? row.minValue : 0)
            ) {
              return "error-green";
            } else {
              return "error-row";
            }
          }
          if (row.maxSign == "<=" && row.minSign == ">") {
            if (
              Number(row.anlyValue) <=
              Number(row.maxValue ? row.maxValue : Infinity) &&
              Number(row.anlyValue) > Number(row.minValue ? row.minValue : 0)
            ) {
              return "error-green";
            } else {
              return "error-row";
            }
          }
          if (row.maxSign == "<" && row.minSign == ">=") {
            if (
              Number(row.anlyValue) <
              Number(row.maxValue ? row.maxValue : Infinity) &&
              Number(row.anlyValue) >= Number(row.minValue ? row.minValue : 0)
            ) {
              return "error-green";
            } else {
              return "error-row";
            }
          }
          if (row.maxSign == "<" && row.minSign == ">") {
            if (
              Number(row.anlyValue) <
              Number(row.maxValue ? row.maxValue : Infinity) &&
              Number(row.anlyValue) > Number(row.minValue ? row.minValue : 0)
            ) {
              return "error-green";
            } else {
              return "error-row";
            }
          }
        }
        return "";
      } else if (column.property === "reviseValue") {
        return "error-blue";
      }
    },
    tableHeaderCellStyle() {
      return "background-color: rgb(249,249,249) !important;color: rgb(73, 72, 72);border-bottom: 1px solid #DCDFE7;border-top:3px solid #3ac1ea;";
    },
    // 停用
    abolish() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选您要停用的数据");
        return;
      }
      for (let item of this.selectVal) {
        if (item.stateFlag == "3") {
          this.$message.warning("已提交的数据不能停用");
          return;
        }
      }
      this.buttonLoading1 = true;
      let abolishlength = this.selectVal.length;
      this.$confirm(
        "确认要停用" + abolishlength + "条数据吗",
        "是否继续?",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          let _this = this;
          _this.axios
            .post(
              "pass/testManagement/v1/limssampletests/abolish",
              this.selectVal,
              { individualType: "json" }
            )
            .then((res) => {
              if (res.code == 0 || res.code == 200) {
                this.$message.success(res.message);
                this.searchData();
              } else {
                this.$message.error(res.message);
              }
              this.buttonLoading1 = false;
            })
            .catch((err) => {
              this.buttonLoading1 = false;
              this.$message.error(err.message);
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消停用",
          });
          this.buttonLoading1 = false;
        });
    },
    // 启用
    recoverData() {
      if (this.selectVal42.length < 1) {
        this.$message.warning("请勾选您要启用的数据");
        return;
      }
      this.buttonLoading2 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/recover",
          this.selectVal42,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.buttonLoading2 = false;
        })
        .catch((err) => {
          this.buttonLoading2 = false;
          this.$message.error(err.message);
        });
    },
    // 批量退回
    back() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选您要退回的数据");
        return;
      }
      for (let item of this.selectVal) {
        if (item.stateFlag != 0) {
          this.$message.warning("请选择状态为未处理的数据");
          return;
        }
        if (item.isSendBack == "2") {
          this.$message.warning("额外增加的任务不允许退回");
          return;
        }
      }
      this.backLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/sendBacks",
          this.selectVal,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.succeed) {
            this.$message.success(res.message);
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.backLoading = false;
        })
        .catch((e) => {
          this.backLoading = false;
          this.$message.error(e.message);
        });
    },
    // 新增标样
    addBy() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选您要新增标样的数据");
        return;
      }
      if (this.selectVal.length > 1) {
        this.$message.warning("请勾选一条数据");
        return;
      }
      if (this.selectVal[0].stateFlag == 3) {
        this.$message.warning(
          "已提交的数据不能增加标样,请选择状态为未处理的数据进行操作"
        );
        return;
      }
      // if (JSON.stringify(this.analyzeVal)==="{}") {
      //   this.$message.warning("请先点击选中一条测试项目数据");
      //   return
      // }
      // if (this.analyzeVal.stateFlag == 3) {
      //   this.$message.warning("已提交的数据不能增加标样,请选择状态为未处理的数据进行操作");
      //   return;
      // }
      this.gangwei = this.selectVal[0].testPostCode;
      this.addByShow = !this.addByShow;
    },
    addBy2() {
      let that = this;
      if (that.selectVal.length < 1) {
        that.$message.warning("请勾选您要新增标样的数据");
        return;
      }
      if (that.selectVal.length > 1) {
        that.$message.warning("请勾选一条数据");
        return;
      }
      let addData = {
        testItemNo: "T0424", // 标准曲线
        id: that.selectVal[0].id,
        yuansu: that.dialog2.form.data.yuansu,
        vlaue: that.dialog2.form.data.sampleNum,
      };
      that.$refs["dialog_form2"].validate((valid) => {
        if (valid) {
          that.axios
            .post("pass/testManagement/v1/limssampletests/addTest", addData, {
              individualType: "json",
            })
            .then((res) => {
              if (res.code == 0 || res.code == 200) {
                that.$message.success(res.message);
                that.searchData();
              } else {
                that.$message.error(res.message);
              }
              that.addByLoading = false;
              that.addByShow = false;
            })
            .catch((err) => {
              that.addByLoading = false;
              that.$message.error(err.message);
            });
        }
      });
    },
    // 新增管理样弹窗
    addGly() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请勾选您要新增标样的数据");
        return;
      }
      if (this.selectVal.length > 6) {
        return this.$message.warning(
          "每次批量增加管理样最大数量为6,当前数量" + this.selectVal.length
        );
      }
      for (let i = 0; i < this.selectVal.length; i++) {
        if (this.selectVal[i].matName.indexOf("管理样") != -1) {
          return this.$message.warning("请取消勾选管理样!");
        }
        if (this.selectVal[i].stateFlag === "3") {
          return this.$message.warning(
            "勾选的数据中含有已提交数据，请刷新页面后重试!"
          );
        }
        this.selectVal[i].glSampleNo = "";
        this.selectVal[i].glMatName = "(管理样)" + this.selectVal[i].matName;
        this.selectVal[i].glCount = "1";
        this.dialog.form.tableData.push(this.selectVal[i]);
      }
      this.dialog.show = true;
      if (this.dialog.form.tableData.length > 0) {
        this.$refs.dialog_form.setCurrentRow(this.$refs.dialog_form.data[0]);
      }
    },
    // 新增管理样确认
    addGlySure() {
      let arr = [];
      this.addGlyLoading = true;
      if (this.dialog.form.tableData.length == 0) {
        this.addGlyLoading = false;
        return this.$message.warning("没有数据，无法增加管理样!");
      }
      for (let i = 0; i < this.dialog.form.tableData.length; i++) {
        if (this.dialog.form.tableData[i].glCount > 6) {
          this.addGlyLoading = false;
          return this.$message.warning(
            "每条数据设置的管理样增加个数最大为6，请重新设置!"
          );
        }
        if (this.dialog.form.tableData[i].glCount < 1) {
          this.addGlyLoading = false;
          return this.$message.warning(
            "每条数据设置的管理样增加个数必须大于0,请重新设置!"
          );
        }
        if (
          this.dialog.form.tableData[i].glSampleNo == null ||
          this.dialog.form.tableData[i].glSampleNo === ""
        ) {
          this.addGlyLoading = false;
          return this.$message.warning("必须设置管理样编号!请重新设置");
        }
        if (
          this.dialog.form.tableData[i].glMatName == null ||
          this.dialog.form.tableData[i].glMatName === ""
        ) {
          this.addGlyLoading = false;
          return this.$message.warning("必须为管理样设置物料名称!请重新设置");
        }
        let obj = {
          id: this.dialog.form.tableData[i].stId,
          glSampleNo: this.dialog.form.tableData[i].glSampleNo,
          glMatName: this.dialog.form.tableData[i].glMatName,
          glCount: this.dialog.form.tableData[i].glCount,
          // 设置固定增加的分析项目，针对当前需要固定添加标样含量的需求，后续如需改动或删除，改变下面变量即可
          append: {
            anlyItemNo: "A0555",
            anlyItemName: "标样含量",
          },
        };
        arr.push(obj);
      }
      this.axios
        .post("pass/testManagement/v1/limssampletests/addGly", arr, {
          individualType: "json",
        })
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.searchData();
            this.addGlyLoading = false;
          } else {
            this.$message.error(res.message);
            this.addGlyLoading = false;
          }
          this.addGlyLoading = false;
          this.closeBly();
        })
        .catch((err) => {
          this.addGlyLoading = false;
          this.$message.error(err.message);
        });
    },
    addKb() {
      if (this.selectVal.length == 0) {
        this.$message.warning("请选择需要增加空白样的数据！");
        return;
      }
      if (this.selectVal.length > 1) {
        this.$message.warning("只能勾选一条数据增加空白样，请取消多选");
        return;
      }
      var stId = this.selectVal[0].stId;
      this.addKbLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/addKb",
          { stId: stId },
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.addKbLoading = false;
            this.DataDep();
          } else {
            this.addKbLoading = false;
            this.$message.error(res.data);
          }
        })
        .catch((e) => {
          this.addKbLoading = false;
          this.$message.error(e.data);
        });
    },
    keyDown(event, row, rindex) {
      let tdTarget = event.target;
      let pid = tdTarget.id;
      if (!pid) {
        return true;
      }
      let ids = pid.split("--");
      if (ids.length != 2) {
        return true;
      }
      let columnId = ids[0];
      let index = ids[1];
      let that = this;
      while (tdTarget.tagName !== "TD") {
        tdTarget = tdTarget.parentElement;
      }
      if (event.keyCode === 13) {
        this.jisuanRow(row, rindex);
      }
      // 如果按下键盘下键或者回车键
      if (event.keyCode === 40 || event.keyCode === 13) {
        let ind = Number(index) + 1;
        let id = "#" + columnId + "--" + ind;
        let input = $(id);
        if (input) {
          this.$refs.tablePllr.setCurrentRow(this.tableData[ind]);
          input.focus();
          input.select(); // 选中内容
          event.stopPropagation();
          event.stopImmediatePropagation();
          event.preventDefault();
          return false;
        }
      } else if (event.keyCode === 38) {
        // 键盘上键
        let ind = Number(index) - 1;
        let id = "#" + columnId + "--" + ind;
        let input = $(id);
        if (input) {
          this.$refs.tablePllr.setCurrentRow(this.tableData[ind]);
          input.focus();
          input.select(); // 选中内容
          event.stopPropagation();
          event.stopImmediatePropagation();
          event.preventDefault();
          return false;
        }
      } else if (event.keyCode === 37) {
        // 键盘左键
        let input =
          $(tdTarget).prev().find("input") &&
          $(tdTarget).prev().find("input")[0];
        if (input) {
          input.focus();
          input.select(); // 选中内容
          event.stopPropagation();
          event.stopImmediatePropagation();
          event.preventDefault();
          return false;
        }
      } else if (event.keyCode === 39) {
        // 键盘右键
        let input = $(tdTarget).next().find("input")[0];
        if (input) {
          input.focus();
          input.select(); // 选中内容
          event.stopPropagation();
          event.stopImmediatePropagation();
          event.preventDefault();
          return false;
        }
      }
    },
    // 删除数据（前端删除）
    delData(row, index) {
      let that = this;

      that.tableData.splice(index, 1);
      that.testTable.splice(index - 1, 1);
      let srow = that.selectVal[index - 1];
      that.selectVal.splice(index - 1, 1);
      that.$refs.table2.toggleRowSelection(srow, false);
    },
    // 计算单行
    jisuanRow(row, index) {
      if (index < 1) {
        return true;
      }

      let temp = [];
      let obj = Object.assign(row);
      delete obj.index;
      //将对象转化成数组、循环获取到index
      let tempArr = Object.keys(obj);
      tempArr.forEach((items, indexs) => {
        temp.push({
          anlyValue: obj[items],
          stIdD: this.testTable[index - 1][items],
        });
      });
      let tempData = [row.stId];
      // console.log('temp', temp);
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/batchUpdateLimsSampleTestDList",
          temp,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.axios
              .post(
                "pass/testManagement/v1/limssampletests/formulacomByStIds",
                tempData,
                { individualType: "json" }
              )
              .then((res) => {
                if (res.code == 0 || res.code == 200) {
                  this.axios
                    .post(
                      "pass/testManagement/v1/limssampletestds/transitionData",
                      tempData,
                      { individualType: "json" }
                    )
                    .then((res) => {
                      if (res.data.badyData.length > 0) {
                        let obj = res.data.badyData[0];
                        this.tableData.splice(index, 1, obj);
                      }
                    })
                    .catch((e) => {
                      this.$message.error(e.message);
                    });
                } else {
                  this.$message.error(res.message);
                }
              })
              .catch((err) => {
                this.$message.error(err.message);
              });
          } else {
            this.$message.error(res.message);
          }
        })
        .catch((err) => {
          this.$message.error(err.message);
        });
    },
    selectStyle({ row, column, rowIndex, columnIndex }) {
      if (row.warning) {
        return "row-green";
      }
    },
  },
};
</script>
<style scoped></style>
<style lang="less">
.testManagement {
  .buttons {
    .el-button {
      margin: 2px 3px 0 0;
    }
  }

  .textOverflow {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .testManagement_left {
    .el-table .el-table__body tr.error-row {
      background-color: rgb(253, 89, 89) !important;
    }

    .el-table .el-table__body tr.error-row>td {
      background-color: rgb(253, 89, 89) !important;
    }

    .el-table .el-table__body tr.error-green {
      background-color: rgb(202, 249, 130) !important;
    }

    .el-table .el-table__body tr.error-green>td {
      background-color: rgb(202, 249, 130) !important;
    }
  }

  .testManagement-pllr {
    .el-table .el-table__body tr.current-row>td {
      //background-color: rgba(26, 75, 236, 0.2) !important;
      background-color: rgba(64, 158, 255, 0.3) !important;
    }
  }

  .row-orange {
    background-color: #fa9707 !important;
  }
}
</style>
