<template>
  <div class="examination">
    <div class="common-head-search">
      <el-form :inline="true">
        <el-form-item label='委托单位'>
          <el-select v-model="search.planCompanyNo" clearable filterable collapse-tags size="small"
            style="width:200px;margin-right: 10px;" placeholder="请选择查询内容">
            <el-option v-for="item in entrOrgNameType" :key="item.baseName" :label="item.orgName" :value="item.orgCode">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label='物料名称'>
          <el-input v-model="search.matName" size="small" @keyup.enter.native="searchData()" placeholder="请输入查询内容"
            style="width: 200px;margin-right: 10px;"></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">
          </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">
          </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" @click="searchData">查询</el-button>
          <el-button icon="el-icon-refresh" type="info" plain size="mini" @click="reset">重置</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='page.totalPage == 0' style="margin-top:-18px" :value="page.totalPage"></el-badge></span>

          </el-tab-pane>
          <el-tab-pane label="检验原料" name="second">

          </el-tab-pane>
      </el-tabs> -->
    <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-button icon="el-icon-check" type="goon" size="mini" v-privilege="activeMenu + 'sampling'"
          @click="ylCheckData">抽检</el-button>
        <el-button icon="el-icon-check" type="goon" size="mini" v-privilege="activeMenu + 'recheck'"
          @click="ylUncheckData">复检</el-button>
      </div>
    </div>
    <div class="common-table-div" style="margin-bottom:0;margin-top:0">
      <el-table id="excelTable" v-loading="dataLoading" ref="dataTable" border :height="height_top"
        highlight-current-row @selection-change="ylHandleSelectionChange" :data="table.ylList"
        :icore-filter-flag="icoreFilterFlag" :header-cell-style="tableHeaderCellStyle"
        :cell-class-name="tableRowClassName" :summary-method="getSummaries" show-summary>
        <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
        <el-table-column type="selection" width="55" fixed="left" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="stateFlag1" label="状态"
          align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="100px" prop="entrId" label="委托编号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="contractNo" label="合同号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="suppName" label="供应商"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="matName" label="物料"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="carNo" label="委托样号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="matOrigin" label="产地"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="transportTypeName" label="运输类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="acceptName" label="收货单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sendPlace" label="发站"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="packTypeName" label="包装方式"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="isCiq1" label="是否商检"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="isBatch1" label="是否配批"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="smpDeliName" label="取样频次"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="unloadPlace" label="卸货地点"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="lotsNo" label="送货批次"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="planCompanyName" label="计划单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="companyName" label="检验单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="deptName" label="检验车间"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sectionName" label="检验班组"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="entrTime1" label="委托日期"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="pointName" label="取样地点"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="smpCompanyName" label="采样单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="smpDeptName" label="采样车间"
          align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="140px" prop="smpSectionName" label="采样班组"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sampleTypeName" label="样品类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="entrTypeName" label="委托类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="testTypeName" label="检验类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="matClassName" label="物料分类"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="matShapeName" label="试样形状"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="spec" label="规格"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="netWgt" label="重量(t)"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sampleNum" label="样品数量"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sampleWgt" label="样品重量"
          align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="100px" prop="planNo" label="计量预报号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="entTime" label="进厂时间"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="testCost" label="检测费用"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isSmp1" label="是否取样"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isPrep1" label="是否组合"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isCheck1" label="是否外检"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isMater1" label="是否计量"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="memo" label="备注"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="95px" prop="createMan" label="创建人"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="160px" prop="createTime" label="创建时间"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="95px" prop="updateMan" label="修改人"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="160px" prop="updateTime" label="修改时间"
          align="center"></el-table-column>
      </el-table>
    </div>
    <div class="common-foot-style">
      <el-pagination @size-change="ylPageSizeChange" @current-change="ylPageCurrentChange" :current-page="page3.pageNum"
        :page-sizes="[100, 200, 500, 800, 1000]" :page-size="page3.pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="page3.totalPage" background>
      </el-pagination>
    </div>
    <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-button icon="el-icon-check" type="goon" size="mini" v-privilege="activeMenu + 'sampling'" @click="checkData">抽检</el-button>
              <el-button icon="el-icon-check" type="goon" size="mini" v-privilege="activeMenu + 'recheck'" @click="uncheckData">复检</el-button> -->
        <el-button icon="el-icon-remove-outline" type="danger" size="mini" v-privilege="activeMenu + 'delete'"
          @click="deleteData2">停用</el-button>
        <el-button icon="el-icon-check" type="goon" size="mini" v-privilege="activeMenu + 'submit'"
          @click="submitData2">提交</el-button>
      </div>
    </div>
    <div class="common-table-div" style="margin-bottom:0;margin-top:0">
      <el-table id="excelTable" v-loading="dataLoading" ref="dataTable" border :height="height_top"
        highlight-current-row @selection-change="handleSelectionChange" :data="table.list"
        :icore-filter-flag="icoreFilterFlag" :header-cell-style="tableHeaderCellStyle" @cell-click='searchFollow'
        :cell-class-name="tableRowClassName" :summary-method="getSummaries" show-summary>
        <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
        <el-table-column type="selection" width="55" fixed="left" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="stateFlag1" label="状态"
          align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="100px" prop="entrId" label="委托编号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="contractNo" label="合同号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="suppName" label="供应商"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="matName" label="物料"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="carNo" label="委托样号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="matOrigin" label="产地"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="transportTypeName" label="运输类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="acceptName" label="收货单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sendPlace" label="发站"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="packTypeName" label="包装方式"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="isCiq1" label="是否商检"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="isBatch1" label="是否配批"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="smpDeliName" label="取样频次"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="unloadPlace" label="卸货地点"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="lotsNo" label="送货批次"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="planCompanyName" label="计划单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="companyName" label="检验单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="deptName" label="检验车间"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sectionName" label="检验班组"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="entrTime1" label="委托日期"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="pointName" label="取样地点"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="smpCompanyName" label="采样单位"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="smpDeptName" label="采样车间"
          align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="140px" prop="smpSectionName" label="采样班组"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sampleTypeName" label="样品类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="entrTypeName" label="委托类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="testTypeName" label="检验类型"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="matClassName" label="物料分类"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="matShapeName" label="试样形状"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="spec" label="规格"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="netWgt" label="重量(t)"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sampleNum" label="样品数量"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="sampleWgt" label="样品重量"
          align="center"></el-table-column>
        <el-table-column :show-overflow-tooltip="true" sortable min-width="100px" prop="planNo" label="计量预报号"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="entTime" label="进厂时间"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="testCost" label="检测费用"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isSmp1" label="是否取样"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isPrep1" label="是否组合"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isCheck1" label="是否外检"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isMater1" label="是否计量"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="memo" label="备注"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="95px" prop="createMan" label="创建人"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="160px" prop="createTime" label="创建时间"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="95px" prop="updateMan" label="修改人"
          align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="160px" prop="updateTime" label="修改时间"
          align="center"></el-table-column>
      </el-table>
    </div>
    <div class="common-foot-style">
      <el-pagination @size-change="pageSizeChange" @current-change="pageCurrentChange" :current-page="page.pageNum"
        :page-sizes="[100, 200, 500, 800, 1000]" :page-size="page.pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="page.totalPage" background>
      </el-pagination>
    </div>
    <!-- <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-button icon="el-icon-remove-outline" type="danger" size="mini" v-privilege="activeMenu + 'delete'" @click="deleteData2">删除</el-button>
      <el-button icon="el-icon-check" type="goon" size="mini" v-privilege="activeMenu + 'submit'" @click="submitData2">提交</el-button>
      </div>
    </div>
    <div class="common-table-div" style="margin-bottom:0;margin-top:0">
       <el-table v-loading="dataLoading2" ref="dataTable2" border :height="height_bot" highlight-current-row @selection-change="handleSelectionChange2" :data="table.list2" :icore-filter-flag="icoreFilterFlag"
       :header-cell-style="tableHeaderCellStyle" :cell-class-name="tableRowClassName2" :summary-method="getSummaries" show-summary>
        <el-table-column type="index" label="NO" fixed="left" align="center">
        </el-table-column>
        <el-table-column type="selection" width="55" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="entrTime1" label="抽复检日期" align="center"></el-table-column>

        <el-table-column sortable :show-overflow-tooltip="true" min-width="200px" prop="testTypeName" label="检验类型"  align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="sampleTypeName" label="样品类型" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="matName" label="物料名称" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="entrTypeName" label="委托类型" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="planCompanyName" label="委托单位"  align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="stateFlag1" label="状态" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="validFlag1" label="数据状态" align="center"></el-table-column>

      </el-table>
    </div> -->
  </div>
</template>
<script>
import {
  getCookie,
  formatDate
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js'
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  data() {
    return {
      table: {
        list: [],
        list2: [],
        ylList: []
      },
      activeName: 'first',
      dataLoading: false,
      dataLoading2: false,
      icoreFilterFlag: true,
      page: {
        pageSize: 200,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 200,
        pageNum: 1,
        totalPage: 0
      },
      page3: {
        pageSize: 200,
        pageNum: 1,
        totalPage: 0
      },
      list: [],
      planId: '',
      showFlag: false,
      Params: {},
      showFlag2: false,
      Params2: {},
      entrOrgNameType: [],
      entrOrgNameType1: [],
      sampleTypeNameType: [],
      ylMultipleSelection3: [],
      multipleSelection3: [],
      multipleSelection4: [],
      search: {
        entrTime: '',
        times: [],
        planCompanyName: '',
        matName: ''
      },
      height_top: 0,
      height_bot: 0,
      activeMenu: ''
    }
  },
  created() {
    this.height_top = window.innerHeight / 2 - 130 < 249 ? 249 : window.innerHeight / 2 - 120;
    this.height_bot = window.innerHeight / 2 - 130 < 249 ? 249 : window.innerHeight / 2 - 120;
    this.search.times = [this.getYNM(new Date()), this.getYNM(new Date())]
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
  },
  mounted() {
    this.axios.post("pass/baseManagement/v1/sysorgs/querySysOrgCompanyAll", {}, { individualType: 'json' }).then(response => {
      this.entrOrgNameType = response.data
    });
    // this.getentrOrgNameTypeList();
    this.searchData();
    // this.getDataList2();
    this.addScreen();
    this.addScreen2()
  },
  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;
    },
    refresh() {
      this.mainData();
    },
    refresh2() {
      this.depData(this.planId);
    },
    checkData() {
      let _this = this;
      if (_this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选您要抽检的数据！')
        return
      }
      _this.axios.post('pass/testManagement/v1/limstestentrusts/check', _this.multipleSelection3, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('抽检成功');
          _this.refresh()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    uncheckData() {
      let _this = this;
      if (_this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选您要复检的数据！')
        return
      }
      _this.axios.post('pass/testManagement/v1/limstestentrusts/uncheck', _this.multipleSelection3, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('复检成功');
          _this.refresh()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    ylCheckData() {
      let _this = this;
      if (_this.ylMultipleSelection3.length < 1) {
        this.$message.warning('请勾选您要抽检的数据！')
        return
      }
      _this.axios.post('pass/testManagement/v1/limstestentrusts/check', _this.ylMultipleSelection3, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('抽检成功');
          _this.searchData()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    ylUncheckData() {
      let _this = this;
      if (_this.ylMultipleSelection3.length < 1) {
        this.$message.warning('请勾选您要复检的数据！')
        return
      }
      _this.axios.post('pass/testManagement/v1/limstestentrusts/uncheck', _this.ylMultipleSelection3, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.$message.success('复检成功');
          _this.searchData()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    deleteData2() {
      let _this = this;
      if (_this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选您要停用的数据！')
      } else {
        for (var j = 0; j < _this.multipleSelection3.length; j++) {
          if (_this.multipleSelection3[j].validFlag === '0') {
            this.$message.warning('请勾选状态为已启用的数据！')
            return
          }
        }
        _this.dialogTableVisible = false;
        for (var i = 0; i < _this.multipleSelection3.length; i++) {
          _this.multipleSelection3[i].updateMan = userName;
          _this.multipleSelection3[i].updateNo = userId
        }
        _this.axios.post('pass/testManagement/v1/limstestentrusts/abolish', _this.multipleSelection3, { individualType: 'json' }).then(res => {
          if (res.succeed) {
            this.$message.success('停用操作成功');
            _this.mainData()
          } else {
            this.$message.error(res.message)
          }
        }).catch(e => {
          this.$message.error(e.message)
        })
      }
    },
    submitData2() {
      let _this = this;
      if (_this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选您要提交的数据！')
      } else {
        for (var j = 0; j < _this.multipleSelection3.length; j++) {
          if (_this.multipleSelection3[j].stateFlag === '1') {
            this.$message.warning('请勾选状态为编辑的数据！')
            return
          }
        }
        let ids = this.multipleSelection3.map(item => item.id)
        _this.dialogTableVisible2 = false;
        // for (var i = 0; i < _this.multipleSelection4.length; i++) {
        // _this.multipleSelection4[i].updateMan = userName;
        // _this.multipleSelection4[i].updateNo = userId
        // }
        _this.axios.post('pass/testManagement/v1/limstestentrusts/submit', ids, { individualType: 'json' }).then(res => {
          if (res.succeed) {
            this.$message.success('提交成功');
            _this.mainData()
          } else {
            this.$message.error(res.message)
          }
        }).catch(e => {
          this.$message.error(e.message)
        })
      }
    },
    searchData() {
      this.page.pageNum = 1
      this.page.pageSize = 200
      this.page3.pageNum = 1
      this.page3.pageSize = 200
      this.ylMainData()
      this.mainData()
    },
    mainData() {
      let startTime = ''
      let endTime = ''
      if (!this.search.times) {
        startTime = ''
        endTime = ''
      } else {
        startTime = formatDate(this.search.times[0], "yyyy-MM-dd") + ' 00:00:00'
        endTime = formatDate(this.search.times[1], "yyyy-MM-dd") + ' 23:59:59'
      }
      let tempobj = {
        'object': {
          "sampleTypeCode": "",
          'isBatch': '',
          'planCompanyNo': this.search.planCompanyNo,
          'matName': this.search.matName,
          validFlag: 1
        },
        'list': [480302, 480305],
        'pageIndex': this.page.pageNum,
        'pageSize': this.page.pageSize,
        'startTime': startTime,
        'endTime': endTime
      }
      this.axios.post('pass/testManagement/v1/limstestentrusts/queryLimsTestEntrustPage/', tempobj, { individualType: 'json' }).then(res => {
        this.dataLoading = false;
        this.table.list = res.data.list;
        this.table.list.forEach(item => {
          item.stateFlag1 = item.stateFlag === '0' ? '编辑' : item.stateFlag === '1' ? '提交' : ''
          item.isCiq1 = item.isCiq === '0' ? '否' : item.isCiq === '1' ? '是' : ''
          item.isBatch1 = item.isBatch === '0' ? '否' : item.isBatch === '1' ? '是' : ''
          item.isSmp1 = item.isSmp === '0' ? '否' : item.isSmp === '1' ? '是' : ''
          item.isPrep1 = item.isPrep === '0' ? '否' : item.isPrep === '1' ? '是' : ''
          item.isCheck1 = item.isCheck === '0' ? '否' : item.isCheck === '1' ? '是' : ''
          item.isMater1 = item.isMater === '0' ? '否' : item.isMater === '1' ? '是' : ''
          item.entrTime1 = formatDate(item.entrTime, 'yyyy-MM-dd')
        })
        // if (this.table.list.length > 0) {
        //   this.$refs.dataTable.setCurrentRow(this.table.list[0])
        //   this.searchFollow(this.table.list[0])
        // }
        this.page.totalPage = res.data.total;
      }).catch(e => {
        this.dataLoading = false;
      });
    },
    ylMainData() {
      this.saveRow = {}
      this.dataLoading = true;
      if (!this.search.times) {
        this.startTime = ''
        this.endTime = ''
      } else {
        this.startTime = this.getYNM(new Date) + ' 00:00:00'
        this.endTime = this.getYNM(new Date) + ' 23:59:59'
      }
      let obj = {
        object: {
          entrOrgNo: this.search.planCompanyNo, // 委托单位
          sampleTypeCode: 480101,
          matName: this.search.matName,
          stateFlag: 1
        },
        list: [480301],
        'startTime': this.startTime,
        'endTime': this.endTime,
        pageIndex: this.page3.pageNum,
        pageSize: this.page3.pageSize
      }
      this.axios.post('pass/testManagement/v1/limstestentrusts/queryLimsTestEntrustPage', obj, { individualType: 'json' }).then(res => {
        this.dataLoading = false;
        this.table.ylList = res.data.list;
        this.table.ylList.forEach(item => {
          item.stateFlag1 = item.stateFlag === '0' ? '编辑' : item.stateFlag === '1' ? '提交' : ''
          item.isCiq1 = item.isCiq === '0' ? '否' : item.isCiq === '1' ? '是' : ''
          item.isBatch1 = item.isBatch === '0' ? '否' : item.isBatch === '1' ? '是' : ''
          item.isSmp1 = item.isSmp === '0' ? '否' : item.isSmp === '1' ? '是' : ''
          item.isPrep1 = item.isPrep === '0' ? '否' : item.isPrep === '1' ? '是' : ''
          item.isCheck1 = item.isCheck === '0' ? '否' : item.isCheck === '1' ? '是' : ''
          item.isMater1 = item.isMater === '0' ? '否' : item.isMater === '1' ? '是' : ''
          item.entrTime1 = formatDate(item.entrTime, 'yyyy-MM-dd')
        })
        this.page3.totalPage = res.data.total;
      }).catch(e => {
        this.dataLoading = false;
      });
    },
    searchFollow(row) {
      this.planId = row.entrId ? row.entrId : ''
      this.page2.pageNum = 1
      this.page2.pageSize = 50
      this.depData(this.planId)
    },
    depData(planId) {
      this.dataLoading2 = true;
      this.axios.post('pass/testManagement/v1/limstestentrustds/queryLimsTestEntrustDPage', { object: { entrId: planId }, pageIndex: this.page2.pageNum, pageSize: this.page2.pageSize }, { individualType: 'json' }).then(res => {
        this.dataLoading2 = false;
        this.table.list2 = res.data.list;
        this.table.list2.forEach(item => {
          item.validFlag1 = item.validFlag === '0' ? '无效' : item.validFlag === '1' ? '有效' : ''
        })
        this.page2.totalPage = res.data.total;
      }).catch(e => {
        this.dataLoading2 = false;
      });
    },
    reset() {
      let _this = this;
      _this.search.times = [this.getYNM(new Date()), this.getYNM(new Date())]
      _this.search.planCompanyNo = '';
      _this.search.matName = '';
      _this.searchData();
    },
    handleSelectionChange(val) {
      this.multipleSelection3 = val;
    },
    ylHandleSelectionChange(val) {
      this.ylMultipleSelection3 = val;
    },
    pageSizeChange(size) {
      this.page.pageSize = size;
      this.mainData();
    },
    pageCurrentChange(index) {
      this.page.pageNum = index;
      this.mainData();
    },
    ylPageSizeChange(size) {
      this.page3.pageSize = size;
      this.ylMainData();
    },
    ylPageCurrentChange(index) {
      this.page3.pageNum = index;
      this.ylMainData();
    },
    handleSelectionChange2(val) {
      this.multipleSelection4 = val;
    },
    pageSizeChange2(size) {
      this.page2.pageSize = size;
      this.depData(this.planId);
    },
    pageCurrentChange2(index) {
      this.page2.pageNum = index;
      this.depData(this.planId);
    },
    addScreen() {
      this.$nextTick(() => {
        let ss = document.createElement('div');
        ss.innerHTML = '筛选';
        ss.style = 'text-align: center;'
        this.$refs.dataTable.$el.getElementsByClassName('el-table__fixed')[0].getElementsByTagName('td')[0].appendChild(ss);
      });
    },
    addScreen2() {
      this.$nextTick(() => {
        let ss = document.createElement('div');
        ss.innerHTML = '筛选';
        ss.style = 'text-align: center;'
        this.$refs.dataTable2.$el.getElementsByClassName('el-table__fixed')[0].getElementsByTagName('td')[0].appendChild(ss);
      });
    },
    tableRowClassName({
      row, column, rowIndex, columnIndex
    }) {
      if (columnIndex === 13) {
        if (row.validFlag !== '1') {
          return 'error-row';
        }
      }
      if (columnIndex === 2) {
        if (row.stateFlag === '1') {
          return 'error-green';
        }
        return '';
      }
    },
    tableRowClassName2({
      row, column, rowIndex, columnIndex
    }) {
      if (columnIndex === 5) {
        if (row.validFlag !== '1') {
          return 'error-row';
        }
        return '';
      }
    },
    tableHeaderCellStyle() {
      return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
    }
  }
}
</script>
<style scoped></style>
