<!-- 三级审核： -->
<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-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-input v-model="searchForm.carNo" @keyup.enter.native="searchData()" size="small" placeholder="请输入查询编号"
            style="width: 150px" clearable></el-input>
        </el-form-item>
        <el-form-item label="中心编号">
          <el-input v-model="searchForm.sampleNo" @keyup.enter.native="searchData()" size="small" placeholder="请输入查询编号"
            style="width: 150px" clearable></el-input>
        </el-form-item>
        <el-form-item label="创建时间">
          <el-date-picker v-model="searchForm.times[0]" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"
            placeholder="开始日期" size="mini" style="width: 140px" :default-time="'00:00:00'">
          </el-date-picker>
          <span>至</span>
          <el-date-picker v-model="searchForm.times[1]" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"
            placeholder="结束日期" size="mini" style="width: 140px" :default-time="'23:59:59'">
          </el-date-picker>
          <!-- <el-date-picker
            v-model="searchForm.times"
            type="daterange"
            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="audit"
                      v-privilege="activeMenu + 'audit'" size="mini">审批通过</el-button>
                    <el-button icon="el-icon-check" type="goon" :loading="batchDataLoading" @click="showBatch"
                      v-privilege="activeMenu + 'batch'" size="mini">批量审核</el-button>
                    <el-button icon="el-icon-check" type="danger" :loading="backAuditLoading" @click="showBackData"
                      v-privilege="activeMenu + 'back'" size="mini">审批不通过</el-button>
                    <el-button icon="el-icon-check" type="goon" :loading="sampleLoading" @click="retest('480403')"
                      v-privilege="activeMenu + 'audit'" size="mini">增加任务</el-button>
                  </el-form-item>
                </el-form>
              </div>
            </div>
            <div class="common-table-div">
              <el-table ref="table1" :height="theight1" v-loading="tableLoading4" :data="tableData4"
                :cell-class-name="tableRowClassName" :summary-method="getSummaries2" show-summary
                @row-click="searchAnalyze" 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="80" align="center" prop="state"
                  label="状态"></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="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="75" align="center" prop="entrTypeName"
                  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="100" align="center" prop="memo"
                  label="检测标准"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="150" align="center" prop="nantNo"
                  label="使用设备"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="entrMemo"
                  label="委托备注"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="100px" prop="auditMan"
                  label="二审审核人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="140px" prop="auditTime"
                  label="二审审核时间"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="checkMan"
                  label="提交人"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="checkTime"
                  label="提交时间"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="createMan"
                  label="创建人"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="createTime"
                  label="创建时间"></el-table-column>
              </el-table>
            </div>
            <div class="common-foot-style">
              <el-pagination @size-change="handleSizeChangeMain" @current-change="Data4()"
                :current-page.sync="pageIndex4" :page-sizes="[10, 20, 50, 100, 200, 500, 800]" :page-size="pageSize4"
                layout="total, sizes, prev, pager, next, jumper" :total="total4" 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 + 'withdraw'" @click="showBackAuditData">撤回已审核</el-button>
              </div>
            </div>
            <div class="common-table-div">
              <el-table v-loading="tableLoading42" ref="table2" :row-class-name="tableRowClassName0"
                :cell-class-name="cellClassName" @selection-change="SelectionValues"
                @current-change="handleCurrentChange" border @row-click="searchAnalyze" :height="theight2"
                highlight-current-row :data="tableData42" :icore-filter-flag="icoreFilterFlag"
                :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 min-width="80" align="center" prop="state"
                  label="状态"></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="75" align="center" prop="entrTypeName"
                  label="委托类型"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="80" align="center" prop="sampleTypeCode"
                  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 show-overflow-tooltip sortable min-width="150" align="center" prop="nantNo"
                  label="使用设备"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="entrMemo"
                  label="委托备注"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="80px" prop="checkMan" label="提交人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="checkTime" label="提交时间"
                  align="center"></el-table-column>
                  <el-table-column sortable show-overflow-tooltip align="center" min-width="100px" prop="auditMan"
                  label="二审审核人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="140px" prop="auditTime"
                  label="二审审核时间"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="100px" prop="apprMan" label="三审审核人"
                  align="center"></el-table-column>
                <el-table-column sortable show-overflow-tooltip min-width="140px" prop="apprTime" label="三审审核时间"
                  align="center"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="createMan"
                  label="创建人"></el-table-column>
                <el-table-column show-overflow-tooltip sortable min-width="75" align="center" prop="createTime"
                  label="创建时间"></el-table-column>
              </el-table>
              <div class="common-foot-style">
                <el-pagination @size-change="handleSizeChangeDep" @current-change="Data5()"
                  :current-page.sync="pageIndex42" :page-sizes="[10, 20, 100, 200, 500, 800]" :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">
            <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-close" :loading="deleteLoading" type="danger" size="mini"
                  @click="deleteData">停用</el-button>
                <el-button icon="el-icon-check" :loading="deleteLoading" type="goon" size="mini"
                  @click="recall">启用</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"
                :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="180" fixed="left" 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="reviseValue"
                  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="memo" 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 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="outputTypeName"
                  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="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: 18px">批量审核</span>
        </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 v-else-if="col.prop == 'sampleNo'">{{
                tableData[scope.$index].sampleNo
                }}</span>
              <span v-else-if="col.prop == 'carNo'">{{
                tableData[scope.$index].carNo
                }}</span>
              <span v-else-if="scope.$index > 0">{{
                scope.row[col.prop]
                }}</span>
            </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="batchAudit()">审批通过</el-button>
        <el-button size="mini" type="danger" 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="closeBack">
      <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" 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 show-overflow-tooltip sortable min-width="120px" align="center" prop="receivedDate"
                  label="收样日期"></el-table-column>
                <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="testItemName"
                  label="退回原因" align="center">
                  <template slot-scope="{ row }">
                    <el-input v-model="row.logMemo" @blur="saveCell" @keyup.enter.native="saveCell" size="small"
                      style="width: 100%"></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="danger" size="mini" :loading="backAuditLoading"
          @click="tableType === 1 ? back() : backAudit()">审批不通过</el-button>
        <el-button type="goon" size="mini" @click="closeBack">取 消</el-button>
      </span>
    </el-dialog>
    <div is="historyAlert" :showFlag="historyShowFlag" :Params="Params" @refresh="refresh"></div>
    <div is="resurveyAlert" :showFlag="resetShowFlag" :Params="Params2" :itemTypeCode="itemTypeCode"
      @refresh="refresh2">
    </div>
  </div>
</template>
<script>
import { getCookie, formatDate } from "@/utils/util.js";
import { cookieUserId, cookieUserName } from "@/config/config.js";
import historyAlert from "../../testAnalysis/components/testManagement/historyAlert";
import resurveyAlert from "../../testAnalysis/components/testManagement/resurveyAlert";
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  components: { historyAlert, resurveyAlert },
  data() {
    return {
      fromDaiban: null,
      searchForm: {
        times: "",
        matName: "",
        sampleTypeCode: "",
        eqpNo: "",
        carNo: "",
        sampleNo: ""
      },
      autoCollData: {
        eqpTypeCode: "",
        eqpNo: "",
      },
      historyShowFlag: false,
      gangwei: "",
      showFlag: false,
      resetShowFlag: false,
      deleteFlag: false,
      dataCollectionFlag: false,
      Params: {},
      Params2: {},
      itemTypeCode: "",
      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,
      tableType: 0,
      withdrawLoading: false,
      batchDataLoading: false,
      buttonLoading1: false,
      buttonLoading2: false,
      batchLoading: false,
      addByLoading: false,
      addKbLoading: false,
      addGlyLoading: false,
      testTable: [],
      cols: [],
      tableData: [],
      resultData: [],
      collectionLoading: false,
      autoColletLoading: false,
      clickColl: false,
      batchShow: false,
      eqpType: [],
      autoEqpType: [],
      facilityType: [],
      selectVal: [], // 已审 多选
      selectVal4: [],
      selectVal42: [], //
      selectMul: [],
      companyNameType: [],
      userdeptNo: "",
      usersectionNo: "",
      userjobs: "",
      selectRecall: [],
      selectTable: [], //分析项目勾选值
      testShow: false,
      checked: true,
      interval: null,
      saveValue: "",
      saveMainData: [],
      cllotData: [],
      addRetestLoading: false,
      dataLoading: false,
      glDialogLoading: false,
      sampleLoading: false,
      backAuditLoading: 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,
      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" },
            ],
          },
        },
      },
    };
  },
  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;
    let timestamp = new Date().getTime() - 7 * 24 * 60 * 60 * 1000; // 默认前一周

    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 == 1 ? "second" : "first";
    } else {
      this.searchForm.times = [
        this.getYNM(new Date(timestamp)),
        this.getYNM(new Date()),
        // this.getYNM(new Date(timestamp)) + " 00:00:00",
        // this.getYNM(new Date()) + " 23:59:59",
      ];
    }
    this.activeMenu = window.top.localStorage.getItem("activeMenu");
    this.axios
      .post(
        "pass/baseManagement/v1/sysorgs/querySysOrgCompanyAll",
        {},
        { individualType: "json" }
      )
      .then((response) => {
        this.companyNameType = response.data;
        this.getCompany();
      });
  },
  watch: {
    "$route.query.type"(newType) {
      this.searchForm.type = newType || '';
    }
  },
  mounted() {
    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=" +
        ""
        // "&sectionName="+this.searchForm.type
      )
      .then((res) => {
        this.allFacility = res.data.list;
      });
    // 设备信息
    this.axios
      .post("pass/baseManagement/v1/limslrceqpinfos/queryAll", {
        individualType: "json",
      })
      .then((res) => {
        this.matNameType = res.data;
      });
    this.searchData();
  },
  methods: {
    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;
    },
    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 = "";
      let timestamp = new Date().getTime() - 7 * 24 * 60 * 60 * 1000; // 默认前一周

      this.searchForm.times = [
        this.getYNM(new Date(timestamp)),
        this.getYNM(new Date()),
        // this.getYNM(new Date(timestamp)) + " 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;
    },
    //撤回已提交数据
    backWithdraw() {
      if (this.selectVal4.length < 1) {
        this.$message.warning("请先勾选您要撤回的数据");
        return;
      }
      for (let item of this.selectVal4) {
        if (item.validFlag == "0") {
          this.$message.warning("请选择有效数据");
          return;
        }
      }
      this.withdrawLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/withdraw",
          this.selectVal4,
          { 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);
        });
    },
    //打开批量审核窗口
    showBatch() {
      if (this.saveMainData.length < 1) {
        this.$message.warning("请勾选测试项目的数据");
        return;
      }
      let temp = [];
      this.saveMainData.map((item) => {
        temp.push(item.stId);
      });
      this.batchDataLoading = true;
      this.axios
        .post("pass/testManagement/v1/limssampletestds/transferData", 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.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);
        });
    },
    refresh2() {
      this.searchData();
    },
    // 增加任务
    retest(itemTypeCode) {
      if (itemTypeCode === "480403") {
        // 增加检验任务
        if (this.saveMainData.length === 0) {
          this.$message.warning("请至少勾选1条需要增加任务的数据!");
          return;
        }
        let count = 14;
        if (this.saveMainData.length > count) {
          return this.$message.warning(
            "单次添加的任务数量不能超过" + (count + 1) + "条"
          );
        }
        for (let i = 0; i < this.saveMainData.length; i++) {
          if (this.saveMainData[i].validFlag === 0) {
            return this.$message.warning(
              "已停用的数据无法增加任务，请重新查询之后重新操作!"
            );
          }
        }
      }
      this.resetShowFlag = !this.resetShowFlag;
      this.Params2 = Object.assign([], this.saveMainData);
      this.itemTypeCode = itemTypeCode;
    },
    // 批量审核删除数据（前端删除）
    delData(row, index) {
      let that = this;
      // console.log(row, index)
      that.tableData.splice(index, 1);
      that.testTable.splice(index - 1, 1);
      let srow = that.saveMainData[index - 1];
      that.saveMainData.splice(index - 1, 1);
      that.$refs.table2.toggleRowSelection(srow, false);
    },
    // 批量审核
    batchAudit() {
      let tempData = [];
      this.saveMainData.map((item) => {
        tempData.push(item.stId);
      });
      this.batchLoading = true;
      this.axios
        .post("pass/testManagement/v1/limssampletests/audit", tempData, {
          individualType: "json",
        })
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success("批量审核成功!");
            this.batchShow = false;
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.batchLoading = false;
        })
        .catch((err) => {
          this.batchLoading = false;
          this.$message.error(err.message);
        });
    },
    //审核
    audit() {
      if (this.saveMainData.length < 1) {
        this.$message.warning("请先勾选您要审核的数据!");
        return;
      }
      this.sampleLoading = true;
      let ids = [];
      this.saveMainData.forEach((item) => {
        ids.push(item.id);
      });
      this.axios
        .post("pass/testManagement/v1/limssampletests/audit", ids, {
          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);
        });
    },
    // 显示撤回已审核操作的数据
    showBackAuditData() {
      if (this.selectVal.length < 1) {
        this.$message.warning("请先勾选您要退回的数据!");
        return;
      }
      this.backLoading = true;

      this.selectVal.forEach((item) => {
        item.logMemo = "";
        this.dialog.form.tableData.push(item);
      });
      this.dialog.show = true;
      this.backLoading = false;
      this.tableType = 1;
    },
    // 显示审批不通过的数据
    showBackData() {
      if (this.saveMainData.length < 1) {
        this.$message.warning("请先勾选您要退回的数据!");
        return;
      }
      this.backAuditLoading = true;

      this.saveMainData.forEach((item) => {
        item.logMemo = "";
        this.dialog.form.tableData.push(item);
      });
      this.dialog.show = true;
      this.backAuditLoading = false;
      this.tableType = 0;
    },
    backAudit() {
      let bool = false;
      this.dialog.form.tableData.forEach((ss) => {
        if (ss.logMemo == "" || ss.logMemo == null) {
          bool = true;
        }
      });
      if (bool) {
        this.$message.warning("请输入退回原因!");
        return;
      }
      this.backAuditLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/backAudit",
          this.dialog.form.tableData,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.closeBack();
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.backAuditLoading = false;
        })
        .catch((err) => {
          this.backAuditLoading = false;
          this.$message.error(err.message);
        });
    },
    // 撤回已审核
    back() {
      if (this.dialog.form.tableData.length < 1) {
        this.$message.warning("请先勾选您要退回的数据!");
        return;
      }
      let bool = false;
      this.dialog.form.tableData.forEach((ss) => {
        if (ss.logMemo == "" || ss.logMemo == null) {
          bool = true;
        }
      });
      if (bool) {
        this.$message.warning("请输入退回原因!");
        return;
      }
      this.backLoading = true;
      this.backAuditLoading = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletests/back",
          this.dialog.form.tableData,
          { individualType: "json" }
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.closeBack();
            this.searchData();
          } else {
            this.$message.error(res.message);
          }
          this.backLoading = false;
          this.backAuditLoading = false;
        })
        .catch((err) => {
          this.backLoading = false;
          this.backAuditLoading = false;
          this.$message.error(err.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.autoColletLoading = false;
    },
    changeIsOneHint(val) {
      this.isOneHint = val;
    },
    realTimeCollect(val) {
      if (val && this.tableData3.length <= 0) {
        this.$message.warning("测试分析项目不能为空");
        this.stopall();
        return;
      }
      if (val && this.autoCollData.eqpNo && this.autoCollData.eqpTypeCode) {
      } else {
        this.$message.warning("请选择【设备类型】【设备名称】，不能为空");
        this.stopall();
        // this.checked  = false
        return;
      }
    },
    startTime(tableLength, openOff, times) {
      let that = this;
      var timesRun = 0;
      that.interval = setInterval(function () {
        timesRun += 1;
        if (!openOff) {
          clearInterval(that.interval);
        }
        if (!tableLength) {
          clearInterval(that.interval);
        }
        if (timesRun > tableLength) {
          clearInterval(that.interval);
        }
        that.autoCollet();
      }, times);
    },
    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 = [];
    },
    closeBack() {
      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;
        }
      }
    },
    //保存
    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.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.pageIndex4 = 1;
      this.pageSize4 = 200;
      this.pageIndex42 = 1;
      this.pageSize42 = 200;
      this.tableData3 = [];
      this.Data4(); // 未审核数据
      this.Data5(); // 已审核数据
    },
    // 未审核
    Data4() {
      let startTime = null;
      let endTime = null;
      startTime = this.searchForm.times[0] === null ? null : (this.searchForm.times[0] + ' 00:00:00')
      endTime = this.searchForm.times[1] === null ? null : (this.searchForm.times[1] + ' 23:59:59')
      // let startTime = "";
      // let endTime = "";
      // if (!this.searchForm.times) {
      //   startTime = "";
      //   endTime = "";
      // } else {
      //   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,
          carNo: this.searchForm.carNo
        },
        list: [4],
        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.state =
                item.validFlag == 0
                  ? "无效"
                  : item.validFlag == 1
                    ? item.stateFlag === "4"
                      ? "待审核"
                      : "未知"
                    : "无效";
            });
          } 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 = null;
      let endTime = null;
      startTime = this.searchForm.times[0] === null ? null : (this.searchForm.times[0] + ' 00:00:00')
      endTime = this.searchForm.times[1] === null ? null : (this.searchForm.times[1] + ' 23:59:59')
      // let startTime = "";
      // let endTime = "";
      // if (!this.searchForm.times) {
      //   startTime = "";
      //   endTime = "";
      // } else {
      //   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,
          carNo: this.searchForm.carNo
        },
        list: [5], // 查询已审
        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",
          obj,
          { 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.state =
                item.validFlag == 0
                  ? "无效"
                  : item.validFlag == 1
                    ? item.stateFlag === "5"
                      ? "已审核"
                      : "未知"
                    : "无效";
            });
            this.tableLoading42 = false;
          } else {
            this.$message.error(res.message);
            this.tableLoading42 = false;
          }
        })
        .catch((err) => {
          this.tableLoading42 = false;
          this.$message.error(err.message);
        });
    },
    searchResultD(row) {
      //保存点击的样品信息数据，保存、提交操作时刷新
      this.tableLoading3 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampleresultds/queryLimsSampleResultDList?srId=" +
          row.SR_ID
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData3 = res.data;
            this.tableData3.forEach((item) => {
              item.isReportName =
                item.isReport == 0 ? "否" : item.isReport == 1 ? "是" : "";
              item.isAlarmName =
                item.isAlarm == 0 ? "否" : item.isAlarm == 1 ? "是" : "";
            });
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading3 = false;
        })
        .catch((err) => {
          this.tableLoading3 = false;
          this.$message.error(err.message);
        });
    },
    //点击测试项目，查询分析项目
    searchAnalyze(row, notColl) {
      //保存点击的样品信息数据，保存、提交操作时刷新
      this.saveAnaly = {};
      this.analyzeVal = row;
      this.tableLoading3 = true;
      this.axios
        .post(
          "pass/testManagement/v1/limssampletestds/queryLimsSampleTestDListNoValid?stId=" +
          this.analyzeVal.id
        )
        .then((res) => {
          if (res.code == 0 || res.code == 200) {
            this.tableData3 = res.data;
            this.tableData3.forEach((item) => {
              item.isReportName =
                item.isReport == 0 ? "否" : item.isReport == 1 ? "是" : "";
              item.isAlarmName =
                item.isAlarm == 0 ? "否" : item.isAlarm == 1 ? "是" : "";
            });
          } else {
            this.$message.error(res.message);
          }
          this.tableLoading3 = false;
        })
        .catch((err) => {
          this.tableLoading3 = 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);
        });
    },
    //表格数据右移
    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.state === "无效") {
        return "error-row";
      } else {
        return "error-green";
      }
    },
    handleSizeChangeMain(pageSize) {
      this.pageIndex4 = 1;
      this.pageSize4 = pageSize;
      this.Data4();
    },
    handleSizeChangeDep(pageSize) {
      this.pageIndex42 = 1;
      this.pageSize42 = pageSize;
      this.Data5();
    },
    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();
    },
    tableRowClassName0({ row, rowIndex }) {
      if (row.state === "无效") {
        return "error-row";
      } else if (row.state === "未知") {
        return "error-green";
      }
      return "";
    },
    cellClassName({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 2) {
        if (row.state === "已审核") {
          return "error-green";
        }
        return "";
      }
    },
    tableRowClassName({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 2) {
        if (row.yearMonth === "1") {
          return "error-row";
        }
      }
      if (row.STATE === "无效") {
        return "error-row";
      } else if (row.STATE === "未知") {
        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";
      }
      if (columnIndex === 2) {
        if (row.validFlag === "0") {
          return "error-row";
        }
      }
    },
    tableHeaderCellStyle() {
      return "background-color: rgb(249,249,249) !important;color: rgb(73, 72, 72);border-bottom: 1px solid #DCDFE7;border-top:3px solid #3ac1ea;";
    },
    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;
    }
  }
}
</style>
