<!-- 五级审核页面 -->
<template>
  <div class="examination thre_approve_wrap">
    <div class="common-head-search">
      <el-form :inline="true">
        <el-form-item label="检验车间">
          <el-select v-model="search.deptNo" filterable clearable style="width:140px;" @clear="clearSelect"
            @change="selectClass" size="small">
            <el-option v-for="item in sectionNameType" :key="item.orgCode" :label="item.orgName" :value="item.orgCode">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="检验班组">
          <el-select v-model="search.sectionNo" filterable clearable style="width:140px;" size="small">
            <el-option v-for="item in sectionClassType" :key="item.orgCode" :label="item.orgName" :value="item.orgCode">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="matClassNo" label="物料类型">
          <el-select v-model="search.matClassNo" @change="selctMatName" clearable style="width: 100%" filterable
            size="small">
            <el-option v-for="item of matClassNameType" :key="item.matClassNo" :label="item.matClassName"
              :value="item.matClassNo">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item prop="matNo" label="物料名称">
          <el-select
            v-model="search.matNo"
            clearable
            style="width: 100%"
            filterable
            size="small"
          >
            <el-option
              v-for="item of matNameType"
              :key="item.matNo"
              :label="item.matName"
              :value="item.matNo"
            >
            </el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label='中心编号'>
          <el-input v-model="search.sampleNo" @keyup.enter.native="searchData()" size="small" placeholder="请输入中心编号查询"
            style="width: 150px;"></el-input>
        </el-form-item>
        <el-form-item label="创建日期">
          <el-date-picker v-model="search.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="search.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="search.times"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="small"
            style="width:300px"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd">
          </el-date-picker> -->
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" type="goon" size="mini" :disable='disSearch' @click="searchData">查询
          </el-button>
          <el-button icon="el-icon-refresh" type="info" plain size="mini" :disable='disSearch' @click="resetData">重置
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-tabs type="border-card" v-model="activeName">
      <el-tab-pane label="待审核" name="first">
        <span slot="label">待审核<el-badge :max="10" :hidden='tableData11.length == 0' style="margin-top:-18px"
            :value="tableData11.length"></el-badge></span>
        <el-row>
          <el-col :span='4'>
            <div class="common-title-div">
              <div class="common-title-name">
                <img style="width: 25px; height: 25px" src='../../../assets/img/imgScreen/logo.png' />
                待审物料
              </div>
              <div>
              </div>
            </div>
            <div class="common-table-div">
              <el-table ref="tableMain11" :height="theight1" v-loading="tableLoading11" :data="tableData11"
                highlight-current-row @row-click="handleCurrentChange11" :header-cell-style="tableHeaderCellStyle"
                :summary-method="getSummaries11" show-summary border style="width: 100%" :icorePanelShown="100"
                :icore-filter-flag="icoreFilterFlag">
                <el-table-column sortable show-overflow-tooltip align="center" min-width="100" prop="MAT_NAME"
                  label="物料名称"></el-table-column>
              </el-table>
            </div>
          </el-col>
          <el-col :span='20'>
            <div class="common-title-div">
              <div class="common-title-name">
                <img style="width: 25px; height: 25px" src='../../../assets/img/imgScreen/logo.png' />
                待审核内容
              </div>
              <div>
                <el-form :inline='true' @submit.native.prevent>
                  <el-form-item>
                    <el-button icon="el-icon-check" type="goon" size="mini" :loading='buttonLoading1' @click="audit"
                      v-privilege="activeMenu + 'check'">
                      审批通过
                    </el-button>
                    <el-button icon="el-icon-back" type="danger" size="mini" :loading='backLoading' @click="checkErr"
                      v-privilege="activeMenu + 'nocheck'">
                      审批不通过
                    </el-button>
                  </el-form-item>
                </el-form>
              </div>
            </div>
            <div class="common-table-div">
              <el-table ref="tableMain12" :height="theight1" v-loading="tableLoading1" :data="tableData1"
                @selection-change="searchFollow1" highlight-current-row :summary-method="getSummaries"
                :header-cell-style="tableHeaderCellStyle" show-summary :span-method="arraySpanMethod" border
                style="width: 100%" :icorePanelShown="100" :icore-filter-flag="icoreFilterFlag"
                :row-class-name="selectStyle" :cell-class-name="selectCellStyle">
                <el-table-column type="index" label="NO" fixed="left" align="center" width="45"></el-table-column>
                <el-table-column type="selection" width="45" fixed="left" align="center"></el-table-column>
                <!--                <el-table-column sortable show-overflow-tooltip align="center" width="135" prop="CONTRACT_NO"-->
                <!--                                 label="合同号" v-if="false"></el-table-column>-->
                <el-table-column sortable show-overflow-tooltip align="center" width="80" prop="ENTR_TYPE_NAME"
                  label="委托类型"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="80" prop="DEPT_NAME"
                  label="检验车间"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="80" prop="SECTION_NAME"
                  label="检验班组"></el-table-column>
                <el-table-column sortable show-overflow-tooltip fixed="left" min-width="100" prop="SAMPLE_NO"
                  label="中心编号">
                  <template slot-scope="scope">
                    <span @click.stop="showHistory(scope.row)" style="color:rgb(15,69,105);cursor: pointer;"
                      class="color-yellow">
                      {{ scope.row.SAMPLE_NO }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column sortable show-overflow-tooltip fixed="left" min-width="100" prop="CAR_NO" label="委托编号">
                  <template slot-scope="scope">
                    <span @click.stop="showSourceResult(scope.row)" style="color:rgb(15,69,105);cursor: pointer;"
                      class="color-yellow">
                      {{ scope.row.CAR_NO }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column sortable show-overflow-tooltip fixed="left" min-width="100" prop="MAT_NAME"
                  label="物料名称"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="80" prop="SAMPLE_TYPE_NAME"
                  label="样品类型"></el-table-column>
                <el-table-column prop="tyu" label="分析项目" show-overflow-tooltip>
                  <template v-for="col in cols">
                    <el-table-column :prop="col" show-overflow-tooltip min-width="72" align='center' :key="col"
                      :label="col">
                      <template slot-scope="scope">
                        <el-tooltip class="item" effect="dark" :content="content" placement="top">
                          <span @click.stop="showMaxAndMinVal(scope.row, col)" style="cursor: pointer;"
                            :class="{ 'color-danger': (scope.row[col] && scope.row[col].split('_')[1] == '2') || scope.row[col + 'Flag'] , 'color-warning': scope.row[col] && scope.row[col].split('_')[1] == '1' }">
                            {{ scope.row[col] || scope.row[col] == '0' ? scope.row[col].split('_')[0] : '' }}
                          </span>
                        </el-tooltip>
                      </template>
                    </el-table-column>
                  </template>
                </el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="75px" prop="ENTR_MEMO"
                  label="委托备注"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="75px" prop="CREATE_MAN"
                  label="创建人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="125px" prop="CREATE_TIME"
                  label="创建时间"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="75px" prop="UPDATE_MAN"
                  label="修改人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="125px" prop="UPDATE_TIME"
                  label="修改时间"></el-table-column>
              </el-table>
              <div class="common-foot-style">
                <el-pagination @size-change="handleSizeChangeMain" @current-change="handleCurrentChangeMain"
                  :current-page.sync="pageIndex" :page-sizes="[100, 200, 500, 800, 1000, 1500]" :page-size="pageSize"
                  size="mini" layout="total, sizes, prev, pager, next, jumper" :total="total_main"
                  background></el-pagination>
              </div>
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
      <el-tab-pane label="已审核" name="second">
        <el-row>
          <el-col :span='4'>
            <div class="common-title-div">
              <div class="common-title-name">
                <img style="width: 25px; height: 25px" src='../../../assets/img/imgScreen/logo.png' />
                已审物料
              </div>
            </div>
            <div class="common-table-div">
              <el-table ref="tableMain21" :height="theight1" v-loading="tableLoading21" :data="tableData21"
                highlight-current-row @row-click="handleCurrentChange21" :header-cell-style="tableHeaderCellStyle"
                :summary-method="getSummaries11" show-summary border style="width: 100%" :icorePanelShown="100"
                :icore-filter-flag="icoreFilterFlag">
                <el-table-column sortable show-overflow-tooltip align="center" min-width="100" prop="MAT_NAME"
                  label="物料名称"></el-table-column>
              </el-table>
            </div>
          </el-col>
          <el-col :span='20'>
            <div class="common-title-div">
              <div class="common-title-name">
                <img style="width: 25px; height: 25px" src='../../../assets/img/imgScreen/logo.png' />
                已审核内容
              </div>
              <div>
                <el-form :inline='true' @submit.native.prevent>
                  <el-form-item>
                    <el-button icon="el-icon-check" type="danger" size="mini" :loading='buttonLoadingBack'
                      @click="rollback">撤回审核</el-button>
                    <el-button icon="el-icon-check" type="goon" size="mini" :loading='buttonLoading1' @click="audit1"
                      v-privilege="activeMenu + 'check'">
                      再次发送电文
                    </el-button>
                  </el-form-item>
                </el-form>
              </div>
            </div>
            <div class="common-table-div">
              <el-table ref="tableMain22" :height="theight2" v-loading="tableLoading2" :data="tableData2"
                @selection-change="searchFollow2" highlight-current-row :summary-method="getSummaries"
                :header-cell-style="tableHeaderCellStyle" show-summary :span-method="arraySpanMethod2" border
                style="width: 100%" :icorePanelShown="100" :icore-filter-flag="icoreFilterFlag">
                <el-table-column label="NO" fixed="left" align="center" width="45">
                  <template slot-scope="scope">
                    <span :style="{ color: scope.row && scope.row.MSG_RES_FLAG === '失败' ? 'red' : '' }">
                      {{ scope.$index + 1 }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column type="selection" width="45" fixed="left" align="center"></el-table-column>
                <!--                <el-table-column sortable show-overflow-tooltip align="center" width="135" prop="CONTRACT_NO"-->
                <!--                                 label="合同号"></el-table-column>-->
                <el-table-column sortable show-overflow-tooltip align="center" min-width="80px" prop="DEPT_NAME"
                  label="检验车间"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="80px" prop="SECTION_NAME"
                  label="检验班组"></el-table-column>
                <el-table-column sortable show-overflow-tooltip fixed="left" min-width="100px" prop="SAMPLE_NO"
                  label="中心编号">
                  <template slot-scope="scope">
                    <span @click.stop="showHistory(scope.row)" style="color:rgb(15,69,105);cursor: pointer;"
                      class="color-yellow">
                      {{ scope.row.SAMPLE_NO }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column sortable show-overflow-tooltip fixed="left" min-width="100" prop="CAR_NO" label="委托编号">
                  <template slot-scope="scope">
                    <span @click.stop="showSourceResult(scope.row)" style="color:rgb(15,69,105);cursor: pointer;"
                      class="color-yellow">
                      {{ scope.row.CAR_NO }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column sortable show-overflow-tooltip fixed="left" min-width="100" prop="MAT_NAME"
                  label="物料名称"></el-table-column>
                <!-- <el-table-column sortable show-overflow-tooltip align="center" min-width="100" prop="BATCH_NO"
                                 label="批次号">
                  <template slot-scope="scope">
                    <span @click.stop="showSourceResult(scope.row)" style="color: rgb(15,69,105);cursor: pointer;">
                      {{ scope.row.BATCH_NO }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="100" prop="MAT_NAME"
                                 label="物料名称"></el-table-column> -->
                <el-table-column sortable show-overflow-tooltip align="center" width="80" prop="ENTR_TYPE_NAME"
                  label="委托类型"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="80" prop="SAMPLE_TYPE_NAME"
                  label="样品类型"></el-table-column>
                <!-- <el-table-column sortable show-overflow-tooltip align="center" min-width="80" prop="STD_NAME" label="方法"></el-table-column> -->
                <el-table-column label="分析项目" show-overflow-tooltip>
                  <template v-for="col in cols2">
                    <el-table-column :prop="col" show-overflow-tooltip min-width="72" align='center' :key="col"
                      :label="col">
                      <template slot-scope="scope">
                        <span @click.stop="showMaxAndMinVal(scope.row, col)" style="cursor: pointer;">
                          {{ scope.row[col] || scope.row[col] == '0' ? scope.row[col].split('_')[0] : '' }}
                        </span>
                      </template>
                    </el-table-column>
                  </template>
                </el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="75px" prop="ENTR_MEMO"
                  label="委托备注"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="100px" prop="AUDIT_MAN"
                  label="二审审核人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="140px" prop="AUDIT_TIME"
                  label="二审审核时间"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="75px" prop="CREATE_MAN"
                  label="创建人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="125px" prop="CREATE_TIME"
                  label="创建时间"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="75px" prop="UPDATE_MAN"
                  label="修改人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="125px" prop="UPDATE_TIME"
                  label="修改时间"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="125px" prop="MSG_RES_FLAG"
                  label="电文发送状态">
                  <template slot-scope="scope">
                    <el-tooltip class="item" effect="dark" :content="scope.row.MSG_RES_DETAIL" placement="top">
                      <span>{{ scope.row.MSG_RES_FLAG }}</span>
                    </el-tooltip>
                  </template>
                </el-table-column>
              </el-table>
              <div class="common-foot-style">
                <el-pagination @size-change="handleSizeChangeMain2" @current-change="handleCurrentChangeMain2"
                  :current-page.sync="pageIndex2" :page-sizes="[100, 200, 500, 800, 1000, 1500]" :page-size="pageSize2"
                  size="mini" layout="total, sizes, prev, pager, next, jumper" :total="total_main2"
                  background></el-pagination>
              </div>
            </div>
          </el-col>
        </el-row>
      </el-tab-pane>
    </el-tabs>
    <el-dialog :close-on-click-modal='false' @close="closeexewindow" width='100%' :visible.sync="showExeManWin" 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>
      <el-table ref="exetable" border highlight-current-row :data="exeTableData" :span-method="arraySpanMethod13"
        :header-cell-style="tableHeaderCellStyle" :summary-method="getSummaries" show-summary>
        <el-table-column type="index" label="NO" width="45" fixed align="center"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="50" fixed align='center' prop="SAMPLE_NO"
          label="样品号"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="30" fixed align='center' prop="STATE_FLAG"
          label="状态">
          <template slot-scope="scope">
            <span v-if="scope.row.VALID_FLAG == 0">已作废</span>
            <span v-else-if="scope.row.STATE_FLAG == 0">未执行</span>
            <span v-else-if="scope.row.STATE_FLAG == 1">已执行</span>
            <span v-else-if="scope.row.STATE_FLAG == 2">已领用</span>
            <span v-else-if="scope.row.STATE_FLAG == 3">已提交</span>
            <span v-else-if="scope.row.STATE_FLAG == 4">未审核</span>
            <span v-else-if="scope.row.STATE_FLAG == 5">已审核</span>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="70" fixed align="center" prop="MAT_NAME"
          label="物料名称"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="110" fixed align='center' prop="TEST_ITEM_NAME"
          label="测试任务"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="70" fixed align='center' prop="SECTION_NAME"
          label="任务所属班组"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="40" fixed align="center" prop="CREATE_MAN"
          label="接收任务人"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="40" fixed align="center" prop="CHECK_MAN"
          label="任务提交人"></el-table-column>
        <el-table-column show-overflow-tooltip sortable width="140" fixed align="center" prop="CREATE_TIME"
          label="接任务时间"></el-table-column>
        <el-table-column show-overflow-tooltip sortable width="140" fixed align="center" prop="CHECK_TIME"
          label="提交时间"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" type="danger" icon="el-icon-remove-outline" @click="closeexewindow">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :close-on-click-modal='false' @close="closeSourceResultWin" width='100%'
      :visible.sync="showSourceResultWin" 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>
      <el-row>
        <el-col :span="24">
          <el-table :data="sourceResult">
            <el-table-column show-overflow-tooltip sortable min-width="120" fixed align="center" prop="sampleNo"
              label="中心编号"></el-table-column>
            <!-- <el-table-column show-overflow-tooltip sortable min-width="70" fixed align="center" prop="batchNo"
                             label="批次号"></el-table-column> -->
            <el-table-column show-overflow-tooltip sortable min-width="70" fixed align="center" prop="batchNo"
              label="加权值">
              <template v-for="info in addInfoList">
                <el-table-column sortable :prop="info" show-overflow-tooltip min-width="72" align='center' :key="info"
                  :label="info">
                  <template slot-scope="scope">
                    <span>{{ scope.row[info] }}</span>
                  </template>
                </el-table-column>
              </template>
            </el-table-column>
            <el-table-column show-overflow-tooltip sortable min-width="70" fixed align="center" prop="matName"
              label="物料名称"></el-table-column>
            <el-table-column label="分析项目" show-overflow-tooltip>
              <template v-for="head in headList">
                <el-table-column sortable :prop="col" show-overflow-tooltip min-width="72" align='center' :key="head"
                  :label="head">
                  <template slot-scope="scope">
                    <span>{{ scope.row[head] }}</span>
                  </template>
                </el-table-column>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" type="danger" icon="el-icon-remove-outline" @click="closeSourceResultWin">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :close-on-click-modal='false' @close="closeexewindow" width='100%' :visible.sync="showBackWin" 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>
      <el-table ref="backtable" border highlight-current-row :data="backTableData" :span-method="arraySpanMethod14"
        :header-cell-style="tableHeaderCellStyle" :summary-method="getSummaries" show-summary
        @selection-change="selectBackItem">
        <el-table-column type="index" label="NO" width="45" fixed 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 min-width="70" fixed align="center" prop="ANLY_ITEM_NAME" label="退回原因">
          <template slot-scope="scope">
            <el-input :autosize="{ minRows: 1, maxRows: 2 }" size="mini" placeholder="在此输入退回原因"
              v-model="scope.row.SEND_BACK_REASON"></el-input>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="70" fixed align="center" prop="ANLY_ITEM_NAME"
          label="分析项(报出值)"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="70" fixed align="center" prop="SECTION_NAME"
          label="班组"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="50" fixed align='center' prop="SAMPLE_NO"
          label="样品号"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="110" fixed align='center' prop="MAT_NAME"
          label="物料名称"></el-table-column>
        <el-table-column show-overflow-tooltip sortable min-width="110" fixed align='center' prop="TEST_ITEM_NAME"
          label="测试任务"></el-table-column>
        <el-table-column v-if="showc" show-overflow-tooltip sortable min-width="50" fixed align='center'
          prop="ANLY_ITEM_NO" label="分析项目编号"></el-table-column>
        <el-table-column v-if="showc" show-overflow-tooltip sortable min-width="110" fixed align='center' prop="SR_ID"
          label="二审ID号"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" type="danger" icon="el-icon-remove-outline" @click="backAnlyItem"
          :loading='backLoading'>审批不通过</el-button>
        <el-button size="mini" type="danger" icon="el-icon-remove-outline" @click="closebackwindow">关闭</el-button>
      </span>
    </el-dialog>
    <div is="historyAlert" :showFlag="historyShowFlag" :Params="Params" @refresh="refresh"></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';
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  components: { historyAlert },
  data() {
    return {
      search: {
        deptNo: '',
        sectionNo: '',
        matClassNo: '',
        matNo: '',
        sampleTypeCode: '',
        matName: '',
        times: '',
        sampleNo: '',
        type:''
      },
      historyShowFlag: false,
      Params: {},
      disableDept: false,
      showExeManWin: false,        //任务执行人窗口
      exeTableData: [],            //任务执行人窗口表格数据
      showBackWin: false,          //退回信息窗口
      backTableData: [],           //退回信息窗口表格数据
      backItemSelect: [],          //选择的需要返工的分析项
      globalSaId: null,            //记录点击的三审数据ID
      showSourceResultWin: false,  //加权信息窗口
      canClose: false,
      showc: false,
      dialogTableVisible: false,
      sampleTypeNameType: [],
      saveAnalyAudit: [],
      deptNo: '', // 登录人的部门(车间)
      sectionNo: '', // 登录人的班组
      classNo: '', // 登录人的岗位
      disSearch: false,
      saveAnlyData: [],
      click_main: {}, // 选中物料行（未审核）
      click_main2: {}, // 选中物料行（已审核）
      theight1: 0,
      theight2: 0,
      isFixed: 'left',
      oldTableData: [],
      oldTableLoading: false,
      calculateLoading: false,
      analyAuditLoading: false,
      tableLoading11: false,
      tableLoading21: false,
      tableLoading1: false,
      tableLoading2: false,
      tableLoading3: false,
      buttonLoading1: false,
      buttonLoading2: false,
      buttonLoading3: false,
      buttonLoadingBack: false,
      cols: [], // 未审核动态列
      cols2: [], // 已审核动态列
      tableData11: [],// 待审核物料
      tableData21: [],// 已审核物料
      tableData1: [],
      tableData2: [],
      tableData3: [],
      max: '',
      min: '',
      content: '',
      pageIndex: 1,
      pageSize: 500,
      total_main: 0,
      pageIndex2: 1,
      pageSize2: 500,
      total_main2: 0,
      multipleSelection1: [], // 1表多选
      multipleSelection2: [], // 2表多选
      activeName: 'first',
      backManLoading: false,
      backPlanLoading: false,
      icoreFilterFlag: true,
      sectionNameType: [], // 检验车间
      sectionClassType: [], // 检验班组
      companyNameType: [], // 公司
      matNameType: [], // 物料名称-查询
      matClassNameType: [], // 物料类型-查询
      activeMenu: '',
      backLoading: false, // 审核不通过
      sourceResult: [],   // 加权原始记录
      headList: [],
      addInfoList: [],
      maxAndMin: {}
    }
  },
  created() {
    this.theight1 = window.innerHeight - 240;
    this.theight2 = window.innerHeight - 240;
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
    let timestamp = new Date().getTime() - (7 * 24 * 60 * 60 * 1000) // 默认前一周
    this.search.times = [this.getYNM(new Date(timestamp)), this.getYNM(new Date())]
    // 获取所有机构
    this.axios.post('pass/baseManagement/v1/sysorgs/querySysOrgCompanyAll', {}, { individualType: 'json' }).then((response) => {
      this.companyNameType = response.data;
      // 获取检测中心下的机构
      this.selectDepartment('JCZX')
      // this.getCompany()
    });
    this.activeMenu = window.top.localStorage.getItem('activeMenu');
  },
  watch: {
  "$route.query.type"(newType) {
    this.search.type = newType || '';
  }
},
  mounted() {
    this.search.type = this.$route.query.type  || '';
    this.axios.post('pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode', {
      validFlag: 1,
      baseCode: 4801,
      // sectionName:this.search.type
    }, { individualType: 'json' }).then(res => {
      this.sampleTypeNameType = res.data
    })
    //物料类型
    this.axios.get('pass/baseManagement/v1/limsbasematerialsclasss/?validFlag=1').then((res) => {
      this.matClassNameType = res.data.list;
    });
  },
  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}`;
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计';
        }
        if (index === 1) {
          sums[index] = data.length;
        }
      });
      return sums;
    },
    getSummaries11(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计：' + data.length;
        }
      });
      return sums;
    },
    //获取个人所属哪个公司
    getCompany() {
      this.axios.get('pass/baseManagement/v1/limslrcemps/' + userId).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.search.deptNo = res.data ? res.data.deptNo : ''
          this.disableDept = res.data
          this.selectClass(this.search.deptNo)
          this.searchData()
        } else {
          this.disSearch = true
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.disSearch = true
        this.$message.error(e.message)
      })
    },
    resetData() {
      this.search.deptNo = ''
      this.search.sectionNo = ''
      this.search.matClassNo = ''
      this.search.matNo = ''
      this.search.sampleNo = ''
      this.search.times = [this.getYNM(new Date()), this.getYNM(new Date())]
      this.searchData()
    },
    async audit1() {
      if (this.multipleSelection2.length < 1) {
        this.$message.warning('请先勾选要发送的数据')
        return
      }
      this.buttonLoading1 = true
      let aa = 0;//成功
      let bb = 0;//失败
      let cc = 0;//取消
      for (let i = 0; i < this.multipleSelection2.length; i++) {
        let arr = [];
        arr.push(this.multipleSelection2[i]);
        const cfs = await this.axios.post('pass/testManagement/v1/limssamplereleases/checkLimsSampleReleases', arr, { individualType: 'json' });
        if (cfs.code == 0 || cfs.code == 200) {
          if (cfs.data.info) {
            this.$message.warning(cfs.data)
          } else {
            let info = ''
            let map = {
              "msgTopic": "lims/xcom/LS/CX/99",
              "msgSource": cfs.data.byteData,
              "msgFrom": "LS"
            }
            const cfs1 = await this.axios.post('pass/mqtt/v1/sends/sendMessage', map, { individualType: 'json' });
            if (cfs1 == 0) {
              aa++;
            } else {
              bb++;
              this.$message.error("样号是：" + this.multipleSelection2[i].sampleNo + '发送电文错误!')
            }
          }
        } else {
          bb++;
          this.$message.error(cfs.message)
        }
      }
      this.buttonLoading1 = false
      this.searchData()
      if (bb == 0 && cc == 0) {
        this.$message.success('执行完毕，成功提交 ' + aa + ' 条数据');
      } else {
        this.$message.warning('执行完毕，成功提交 ' + aa + ' 条数据，失败 ' + bb + ' 条, 取消' + cc + ' 条');
      }
    },
    //撤回审批
    rollback() {
      if (this.multipleSelection2.length == 0) {
        this.$message.warning('请勾选需要撤回审核的数据')
        return
      }
      let saIds = [];
      this.multipleSelection2.forEach(s => {
        saIds.push(s.SA_ID)
      })
      this.buttonLoadingBack = true;
      this.axios.post('pass/testManagement/v1/limssamplereleases/withdrawTheAudit', saIds, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.$message.success("操作成功！");
        } else {
          this.$message.error(res.message)
        }
        this.buttonLoadingBack = false;
      }).catch(e => {
        this.buttonLoadingBack = false;
        this.$message.error(e.message)
      })
    },
    // 审批
    async audit() {
      if (this.multipleSelection1.length < 1) {
        this.$message.warning('请先勾选要审批的数据')
        return
      }
      this.buttonLoading1 = true
      let sampleNoStr = '';
      this.multipleSelection1.forEach(item => {
        if (item.CHANGE_COLOR) {
          sampleNoStr = sampleNoStr + ',' + item.SAMPLE_NO
        }
      })
      if (sampleNoStr) {
        sampleNoStr = sampleNoStr.slice(1);
        this.$confirm('样号[' + sampleNoStr + ']四审未完毕，是否继续审核？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.axios.post('pass/testManagement/v1/limssamplereleases/checkLimsSampleReleases', this.multipleSelection1, { individualType: 'json' }).then(res => {
            if (res.code == 1 || res.code == 200) {
              if (res.data.info) {
                this.$message.success(res.data)
                this.buttonLoading1 = false
              } else {
                let info = ''
                let map = {
                  "msgTopic": "lims/xcom/LS/CX/99",
                  "msgSource": res.data.byteData,
                  "msgFrom": "LS"
                }
                this.axios.post('pass/mqtt/v1/sends/sendMessage', map, { individualType: 'json' }).then(res => {
                  debugger
                  console.log(res.message)
                }).catch(e => {
                  info = '发送电文错误!'
                })
                this.$message.success(res.message + ',' + info)
                this.buttonLoading1 = false
              }
              this.searchData()
            } else {
              this.$message.error(res.message)
              this.buttonLoading1 = false
            }
          }).catch(err => {
            this.buttonLoading1 = false
            this.$message.error(err.message)
          })
        }).catch(ex => {
          this.buttonLoading1 = false
          this.$message.error(err.message)
        })
      } else {
        let aa = 0;//成功
        let bb = 0;//失败
        let cc = 0;//取消
        for (let i = 0; i < this.multipleSelection1.length; i++) {
          let arr = [];
          arr.push(this.multipleSelection1[i]);
          const cfs = await this.axios.post('pass/testManagement/v1/limssamplereleases/checkLimsSampleReleases', arr, { individualType: 'json' });
          if (cfs.code == 0 || cfs.code == 200) {
            if (cfs.data.info) {
              this.$message.warning(cfs.data)
            } else {
              let info = ''
              let map = {
                "msgTopic": "lims/xcom/LS/CX/99",
                "msgSource": cfs.data.byteData,
                "msgFrom": "LS"
              }
              const cfs1 = await this.axios.post('pass/mqtt/v1/sends/sendMessage', map, { individualType: 'json' });
              if (cfs1 == 0) {
                aa++;
              } else {
                bb++;
                this.$message.error("样号是：" + this.multipleSelection1[i].sampleNo + '发送电文错误!')
              }
            }
          } else {
            bb++;
            this.$message.error(cfs.message)
          }
        }
        this.buttonLoading1 = false
        this.searchData()
        if (bb == 0 && cc == 0) {
          this.$message.success('执行完毕，成功提交 ' + aa + ' 条数据');
        } else {
          this.$message.warning('执行完毕，成功提交 ' + aa + ' 条数据，失败 ' + bb + ' 条, 取消' + cc + ' 条');
        }
        //   this.axios.post('pass/testManagement/v1/limssamplereleases/checkLimsSampleReleases', this.multipleSelection1, {individualType: 'json'}).then(res => {
        //     if (res.code == 0 || res.code == 200) {
        //       if (res.data.info) {
        //         this.$message.warning(res.data)
        //         this.buttonLoading1 = false
        //       } else {

        //         let info = ''

        //         let map = {
        //             "msgTopic":"lims/xcom/LS/CX/99",
        //             "msgSource":res.data.byteData,
        //             "msgFrom":"LS"
        //           }
        //          this.axios.post('pass/mqtt/v1/sends/sendMessage',map,{individualType: 'json'}).then(res => {

        //             console.log(res.message)
        //           }).catch(e => {
        //             info = '发送电文错误!'
        //           })
        //         this.$message.success(res.message+',' + info)
        //         this.buttonLoading1 = false
        //       }
        //       this.searchData()
        //     } else {
        //       this.$message.error(res.message)
        //       this.buttonLoading1 = false
        //     }
        //   }).catch(err => {
        //     this.buttonLoading1 = false
        //     this.$message.error(err.message)
        //   })
      }
    },
    // 取消
    cancel() {
      if (JSON.stringify(this.click_main) === '{}') {
        this.$message.warning('请先点击选中一条审核内容数据');
        return;
      }
      if (this.click_main.stateFlag == 5) {
        this.$message.warning('数据已审核,不可进行取消操作');
        return;
      }
      this.buttonLoading2 = true
      this.axios.post('pass/testManagement/v1/limssampleresults/cancelLimsSampleResult?id=' + this.click_main.srId, { 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)
      })
    },
    // 退回到任务池
    backPlan() {
      if (this.saveAnlyData.length < 1) {
        this.$message.warning('请选勾选需要退回的数据')
        return
      }
      for (let i = 0; i < this.saveAnlyData.length; i++) {
        if (this.saveAnlyData[i].stateFlag == '2') {
          this.$message.warning('已审核的数据不能进行计算')
          return
        }
      }
      let tempArr = []
      this.saveAnlyData.map(item => {
        tempArr.push(item.id)
      })
      this.backPlanLoading = true
      this.axios.post('pass/testManagement/v1/limssampleresultds/sendBackTaskTest', tempArr, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
        this.backPlanLoading = false
      }).catch(err => {
        this.backPlanLoading = false
        this.$message.error(err.message)
      })
    },
    //异常
    abnormal() {
    },
    //查询
    searchData() {
      if (!this.search.times) {
        this.$message.error('请先选择时间');
        return true;
      }
      this.pageIndex = 1
      this.pageSize = 500
      this.pageIndex2 = 1
      this.pageSize2 = 500
      this.dataMainWl11()
      this.dataMainWl21()
      // this.dataMain()
      // this.dataMain2()
    },
    // 车间列表（检测中心下）
    selectDepartment(val) {
      this.sectionNameType = [];
      this.companyNameType.find((item) => {
        if (val === item.orgCode) {
          this.sectionNameType = item.sysOrgList;
        }
      });
    },
    // 根据选中的车间名称，查询班组名称
    selectClass(val) {
      this.sectionClassType = [];
      this.sectionNameType.find((item) => {
        if (val === item.orgCode) {
          this.sectionClassType = item.sysOrgList;
          this.search.sectionNo = '';
        }
      });
    },
    // 未审核物料
    dataMainWl11() {
      this.click_main = {}
      this.tableData1 = []
      this.total_main = 0
      let startTime = null;
      let endTime = null;
      startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
      endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
      // let startTime = ''
      // let endTime = ''
      // if (!this.search.times) {
      //   startTime = ''
      //   endTime = ''
      // } else {
      //   startTime = this.search.times[0] + ' 00:00:00'
      //   endTime = this.search.times[1] + ' 23:59:59'
      // }
      let obj = {
        object: {
          validFlag: '1',
          deptNo: this.search.deptNo,
          sectionNo: this.search.sectionNo,
          sampleNo: this.search.sampleNo
        },
        list: [5],
        mode: this.search.matClassNo,
        startTime: startTime,
        endTime: endTime,
        deptName:this.search.type
      }
      this.tableLoading11 = true;
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryReleaseWl', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.tableData11 = res.data
          if (this.search.sampleNo && this.tableData11.length > 0) {
            this.$refs.tableMain11.setCurrentRow(this.tableData11[0])
            this.click_main.MAT_NO = this.tableData11[0].MAT_NO ? this.tableData11[0].MAT_NO : ''
            this.pageIndex = 1
            this.pageSize = 200
            this.dataMain();
          }
        } else {
          this.$message.error(res.message)
        }
        this.tableLoading11 = false;
      }).catch(err => {
        this.tableLoading11 = false;
        this.$message.error(err.message)
      })
    },
    // 已审核物料
    dataMainWl21() {
      this.click_main2 = {}
      this.tableData2 = []
      this.total_main2 = 0
      let startTime = null;
      let endTime = null;
      startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
      endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
      // let startTime = ''
      // let endTime = ''
      // if (!this.search.times) {
      //   startTime = ''
      //   endTime = ''
      // } else {
      //   startTime = this.search.times[0] + ' 00:00:00'
      //   endTime = this.search.times[1] + ' 23:59:59'
      // }
      let obj = {
        object: {
          validFlag: '1',
          deptNo: this.search.deptNo,
          sectionNo: this.search.sectionNo,
          sampleNo: this.search.sampleNo
        },
        list: [6, 7],
        mode: this.search.matClassNo,
        startTime: startTime,
        endTime: endTime,
        deptName:this.search.type
      }
      this.tableLoading21 = true;
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryReleaseWl2', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.tableData21 = res.data
          if (this.search.sampleNo && this.tableData21.length > 0) {
            this.$refs.tableMain21.setCurrentRow(this.tableData21[0])
            this.click_main2.MAT_NO = this.tableData21[0].MAT_NO ? this.tableData21[0].MAT_NO : ''
            this.pageIndex2 = 1
            this.pageSize2 = 200
            this.dataMain2();
          }
        } else {
          this.$message.error(res.message)
        }
        this.tableLoading21 = false;
      }).catch(err => {
        this.tableLoading21 = false;
        this.$message.error(err.message)
      })
    },
    // 未审核数据
    dataMain() {
      if (!this.click_main || !this.click_main.MAT_NO) {
        return false;
      }
      let startTime = null;
      let endTime = null;
      startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
      endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
      // let startTime = ''
      // let endTime = ''
      // if (!this.search.times) {
      //   startTime = ''
      //   endTime = ''
      // } else {
      //   startTime = this.search.times[0] + ' 00:00:00'
      //   endTime = this.search.times[1] + ' 23:59:59'
      // }
      let obj = {
        object: {
          matNo: this.click_main.MAT_NO,
          validFlag: '1',
          deptNo: this.search.deptNo,
          sectionNo: this.search.sectionNo,
          sampleNo: this.search.sampleNo
        },
        'list': [5],
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.pageIndex,
        'pageSize': this.pageSize
      }
      this.tableLoading1 = true;
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryLimsSampleReleasePage2', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.tableData1 = res.data.data.list
          if (this.tableData1 != null && this.tableData1.length > 0) {
            this.tableData1.sort((a, b) => {
              a.CHANGE_COLOR = a.CHANGE_COLOR ? 1 : 0
              b.CHANGE_COLOR = b.CHANGE_COLOR ? 1 : 0
              return a.CHANGE_COLOR - b.CHANGE_COLOR
            })
          }
          this.cols = res.data.head
          this.total_main = res.data.data.total
        } else {
          this.$message.error(res.message)
        }
        this.tableLoading1 = false;
      }).catch(err => {
        this.tableLoading1 = false;
        this.$message.error(err.message)
      })
    },
    showMaxAndMinVal(row, col) {
      let params = {
        batchNo: row.BATCH_NO,
        anlyItemName: col,
        contractNo: row.CONTRACT_NO,
        matNo: row.MAT_NO
      }
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryMaxAndMinVal', params, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.maxAndMin = res.data;
          if (this.maxAndMin != null && this.maxAndMin.MAXI !== '') {
            this.max = this.maxAndMin.MAXI;
          }
          if (this.maxAndMin != null && this.maxAndMin.MINI !== '') {
            this.min = this.maxAndMin.MINI;
          }
          if (this.max != null && this.min != null && this.max !== '' && this.min !== '') {
            this.content = '最大值:' + this.max + ',最小值:' + this.min;
          } else {
            this.content = '';
          }
        } else {
          this.$message.warning(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message);
      })
    },
    // 已审核数据
    dataMain2() {
      if (!this.click_main2 || !this.click_main2.MAT_NO) {
        return;
      }
      let startTime = null;
      let endTime = null;
      startTime = this.search.times[0] === null ? null : (this.search.times[0] + ' 00:00:00')
      endTime = this.search.times[1] === null ? null : (this.search.times[1] + ' 23:59:59')
      // let startTime = ''
      // let endTime = ''
      // if (!this.search.times) {
      //   startTime = ''
      //   endTime = ''
      // } else {
      //   startTime = this.search.times[0] + ' 00:00:00'
      //   endTime = this.search.times[1] + ' 23:59:59'
      // }
      let obj = {
        object: {
          matNo: this.click_main2.MAT_NO,
          validFlag: '1',
          deptNo: this.search.deptNo,
          sectionNo: this.search.sectionNo,
          sampleNo: this.search.sampleNo
        },
        'list': [6, 7],
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': this.pageIndex2,
        'pageSize': this.pageSize2
      }
      this.tableLoading2 = true;
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryLimsSampleReleasePage4', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.tableData2 = res.data.data.list
          this.cols2 = res.data.head
          this.total_main2 = res.data.data.total
        } else {
          this.$message.error(res.message)
        }
        this.tableLoading2 = false;
      }).catch(err => {
        this.tableLoading2 = false;
        this.$message.error(err.message)
      })
    },
    handleSizeChangeMain(pageSize) {
      this.pageIndex = 1;
      this.pageSize = pageSize;
      this.dataMain();
    },
    handleCurrentChangeMain(pageIndex) {
      this.pageIndex = pageIndex;
      this.dataMain();
    },
    handleSizeChangeMain2(pageSize) {
      this.pageIndex2 = 1;
      this.pageSize2 = pageSize;
      this.dataMain2();
    },
    handleCurrentChangeMain2(pageIndex) {
      this.pageIndex2 = pageIndex;
      this.dataMain2();
    },
    tableHeaderCellStyle() {
      return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
    },
    // 根据物料类型查询物料 - 查询
    selctMatName(val) {
      this.matNameType = [];
      this.search.matNo = '';
      if (!val) {
        return;
      }
      //物料名称
      this.axios.post('pass/baseManagement/v1/limsbasematerialss/queryLimsBaseMaterialsPage/',
        {
          object: { validFlag: 1, matClassNo: val },
          pageIndex: 1,
          pageSize: 99999,
        },
        { individualType: 'json' }
      ).then((res) => {
        this.matNameType = res.data.list;
      });
    },
    clearSelect() {
      this.search.sectionNo = '';
    },
    //选中数据1
    searchFollow1(val) {
      this.multipleSelection1 = val
    },
    //选中数据2
    searchFollow2(val) {
      this.multipleSelection2 = val
    },
    // 选中需要退回的分析项
    selectBackItem(val) {
      this.backItemSelect = val
      console.log('val', val)
    },
    // 选中未审核物料
    handleCurrentChange11(val) {
      this.click_main = val
      // console.log('this.click_main', this.click_main)
      this.dataMain();
    },
    // 选中已审核物料
    handleCurrentChange21(val) {
      this.click_main2 = val
      this.dataMain2();
    },
    // 审批不通过
    checkErr() {
      if (this.multipleSelection1.length == 0) {
        this.$message.warning('请勾选需要退回的数据')
        return
      }
      if (this.multipleSelection1.length > 1) {
        this.$message.warning('请只勾选需要退回的单条数据')
        return
      }
      this.showResult(this.multipleSelection1[0]);
    },
    // 显示指定元素所属的班组的整条二审数据
    showResult(row) {
      this.showBackWin = true
      let saId = row.RID
      this.globalSaId = row.RID
      this.backTableData = []
      this.axios.get('pass/testManagement/v1/limssamplereleases/showResult?saId=' + saId).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.backTableData = res.data
          this.backLoading = true
        } else {
          this.$message.error(res.message)
        }
        this.backLoading = false
      }).catch(e => {
        this.backLoading = false
        this.$message.error(e.message)
      })
    },
    //按班组退回数据
    backAnlyItem() {
      if (this.backItemSelect.length == 0) {
        this.$message.warning('请勾选需要退回的数据~！');
        return
      }
      let anlyArr = []
      this.backItemSelect.forEach(item => {
        let obj = {
          sendBackReason: item.SEND_BACK_REASON,
          anlyItemNo: item.ANLY_ITEM_NO,
          srId: item.SR_ID,
          saId: this.globalSaId
        }
        anlyArr.push(obj)
      })
      this.backLoading = true
      this.axios.post('pass/testManagement/v1/limssamplereleases/backAnlyItemBySection', anlyArr, { individualType: 'json' }).then(res => {
        if (res.code == 200 || res.code == 0) {
          this.$message.success(res.data);
          this.closebackwindow();
          this.pageIndex = 1
          this.pageSize = 500
          this.pageIndex2 = 1
          this.pageSize2 = 500
          // this.dataMainWl11()
          this.dataMain();
        } else {
          this.$message.warning(res.message);
        }
        this.backLoading = false;

      }).catch(e => {
        this.$message.warning(e.message);
        this.backLoading = false;
      });
    },
    // 表格1合并单元格
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
      let tableData = this.$refs.tableMain12.tableData
      let rowsPan = 1;
      let thisColomnData = row[column['property']];
      // 相同合同列的行合并
      if (column['property'] === 'CONTRACT_NO' && thisColomnData) {
        if (rowIndex > 0 && thisColomnData === tableData[rowIndex - 1][column['property']]) {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
        while (tableData[rowIndex + rowsPan] && thisColomnData === tableData[rowIndex + rowsPan][column['property']]) {
          rowsPan += 1
        }
        return {
          rowspan: rowsPan,
          colspan: 1
        };
      }
    },
    showExeManAndTime(val) {
      this.showExeManWin = true;
      // 查询任务执行信息
      var srId = val.SR_ID;
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryTaskExeInfo', { srId: srId }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.exeTableData = res.data;
          this.canClose = true;
        } else {
          this.$message.error(res.data);
          this.canClose = true;
        }
      }).catch(e => {
        this.$message.error(e.message);
        this.canClose = true;
      })
    },
    showHistory(row) {
      if (!row) {
        return this.$message.warning('查询历史记录失败，参数错误!')
      }
      let sampleNo = row.SAMPLE_NO;
      this.axios.post('pass/testManagement/v1/limssamplehistorys/queryHistoryTestAll?sampleNo=' + sampleNo).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);
      })
    },
    showSourceResult(val) {
      let obj = val
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryAddWeightInfo', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.showSourceResultWin = true;
          this.headList = res.data.headList;
          this.sourceResult = res.data.data;
          this.addInfoList = res.data.addInfoList;
        } else {
          this.$message.warning(res.message);
        }
      }).catch(e => {
        this.$message.error(e.message);
      })
    },
    closeSourceResultWin() {
      this.showSourceResultWin = false
    },
    // 执行人窗口表格合并单元格
    arraySpanMethod13({ row, column, rowIndex, columnIndex }) {
      let tableData = this.$refs.exetable.tableData
      let rowsPan = 1;
      let thisColomnData = row[column['property']];
      // 相同合同列的行合并
      if (column['property'] === 'SAMPLE_NO' && thisColomnData) {
        if (rowIndex > 0 && thisColomnData === tableData[rowIndex - 1][column['property']]) {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
        while (tableData[rowIndex + rowsPan] && thisColomnData === tableData[rowIndex + rowsPan][column['property']]) {
          rowsPan += 1
        }
        return {
          rowspan: rowsPan,
          colspan: 1
        };
      }
    },
    // 分析项目退回窗口合并
    arraySpanMethod14({ row, column, rowIndex, columnIndex }) {
      let tableData = this.$refs.backtable.tableData
      let rowsPan = 1;
      let thisColomnData = row['SECTION_NAME'];
      // 相同合同列的行合并
      if ((column['property'] === 'SECTION_NAME' && thisColomnData)) {
        if (rowIndex > 0 && thisColomnData === tableData[rowIndex - 1]['SECTION_NAME']) {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
        while (tableData[rowIndex + rowsPan] && thisColomnData === tableData[rowIndex + rowsPan]['SECTION_NAME']) {
          rowsPan += 1
        }
        return {
          rowspan: rowsPan,
          colspan: 1
        };
      }
    },
    // 关闭任务执行信息窗口
    closeexewindow() {
      if (!this.canClose) {
        return;
      }
      this.showExeManWin = false;
      this.exeTableData = []; // 清空表格数据
    },
    // 关闭分析项退回窗口
    closebackwindow() {
      this.showBackWin = false;
      this.backItemSelect = [];
      this.backTableData = [];
    },
    selectStyle({ row, rowIndex }) {
      if (row.CHANGE_COLOR) {
        return 'row-bule';
      }
    },
    selectCellStyle({ row, column, rowIndex, columnIndex }) {
      if (row.CHANGE_COLOR) {
        return 'error-blue';
      }
    },
    // 表格2合并单元格
    arraySpanMethod2({ row, column, rowIndex, columnIndex }) {
      let tableData = this.$refs.tableMain22.tableData
      let rowsPan = 1;
      let thisColomnData = row[column['property']];
      // 相同合同列的行合并
      if (column['property'] === 'CONTRACT_NO' && thisColomnData) {
        if (rowIndex > 0 && thisColomnData === tableData[rowIndex - 1][column['property']]) {
          return {
            rowspan: 0,
            colspan: 0
          };
        }
        while (tableData[rowIndex + rowsPan] && thisColomnData === tableData[rowIndex + rowsPan][column['property']]) {
          rowsPan += 1
        }
        return {
          rowspan: rowsPan,
          colspan: 1
        };
      }
    }
  }
}
</script>
<style scoped></style>
<style>
.row-bule {
  background-color: rgb(89, 179, 253) !important;
}

.el-table__body tr.current-row.row-bule>td {
  background-color: rgb(89, 179, 253) !important;
}
</style>
