<!-- 六级审核页面 -->
<template>
  <div class="examination">
    <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-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">审批通过</el-button>
                    <el-button icon="el-icon-back" type="danger" size="mini" :loading='backLoading' @click="checkErr">审批不通过</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"
              >
                <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="合同号"></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="样号"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="100" prop="BATCH_NO" label="批次号"></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 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 cols">
                    <el-table-column :prop="col" show-overflow-tooltip min-width="80" align='center' :key="col" :label="col"></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="[10, 20, 30, 40, 100 , 200]"
                  :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-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 type="index" label="NO" fixed="left" align="center" width="45"></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="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 align="center" min-width="100" prop="SAMPLE_NO" label="样号"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="100" prop="BATCH_NO" label="批次号"></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" 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"></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="80" prop="AUDIT_MAN" label="审核人"></el-table-column>
                <el-table-column sortable show-overflow-tooltip align="center" min-width="140" 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>
              <div class="common-foot-style">
                <el-pagination
                  @size-change="handleSizeChangeMain2"
                  @current-change="handleCurrentChangeMain2"
                  :current-page.sync="pageIndex2"
                  :page-sizes="[10, 20, 30, 40, 100 , 200]"
                  :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>
  </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 {
      search: {
        deptNo: '',
        sectionNo: '',
        matClassNo: '',
        matNo: '',
        sampleTypeCode: '',
        matName: '',
        times:''
      },
      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,
      cols:[], // 未审核动态列
      cols2:[], // 已审核动态列
      tableData11:[],// 待审核物料
      tableData21:[],// 已审核物料
      tableData1:[],
      tableData2:[],
      tableData3:[],
      pageIndex: 1,
      pageSize:100,
      total_main:0,
      pageIndex2: 1,
      pageSize2:100,
      total_main2:0,
      multipleSelection1: [], // 1表多选
      multipleSelection2: [], // 2表多选
      activeName:'first',
      backManLoading:false,
      backPlanLoading:false,
      icoreFilterFlag: true,
      sectionNameType:[], // 检验车间
      sectionClassType:[], // 检验班组
      companyNameType:[], // 公司
      matNameType: [], // 物料名称-查询
      matClassNameType: [], // 物料类型-查询
      activeMenu:'',
      backLoading: false // 审核不通过
    }
  },
  created() {
    this.theight1 = window.innerHeight -240;
    this.theight2 = window.innerHeight -240;
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
    console.log('66')
    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')
    });
  },
  mounted () {
    this.axios.post("pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",{validFlag:1,baseCode:4801}, {individualType: 'json'}).then(res => {
      this.sampleTypeNameType = res.data
    })
    //物料类型
    this.axios.get("pass/baseManagement/v1/limsbasematerialsclasss/?validFlag=1").then((res) => {
      this.matClassNameType = res.data.list;
    });
    this.getCompany()
  },
  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.classNo = res.data ? res.data.postNo : ''
          this.deptNo = res.data ? res.data.deptNo : ''
          this.sectionNo = res.data ? res.data.sectionNo : ''
          // this.searchData()
        }else{
          this.disSearch = true
          this.$message.error(e.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.times =  [this.getYNM(new Date()), this.getYNM(new Date())]
      // this.searchData()
    },
    // 审批
    audit(){
      if (this.multipleSelection1.length < 1) {
        this.$message.warning('请先勾选要审批的数据')
        return
      }
      this.buttonLoading1 = true
      this.axios.post('pass/testManagement/v1/limsfourapprove/checkFourApprove', this.multipleSelection1, {individualType: 'json'}).then(res =>{
        if (res.code == 0 || res.code == 200) {
          if(res.data && res.data != 'true'){
            this.$message.warning(res.data)
          }else{
            this.$message.success(res.message)
          }
          this.searchData()
        }else{
          this.$message.error(res.message)
        }
        this.buttonLoading1 = false
      }).catch(err =>{
        this.buttonLoading1 = false
        this.$message.error(err.message)
      })
    },
    // 取消
    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 = 100
      this.pageIndex2 = 1
      this.pageSize2 = 100
      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 = ''
      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
        },
        list:[6],
        mode: this.search.matClassNo,
        startTime: startTime,
        endTime: endTime
      }
      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
        }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 = ''
      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
        },
        list:[7],
        mode: this.search.matClassNo,
        startTime: startTime,
        endTime: endTime
      }
      this.tableLoading21 = true;
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryReleaseWl',obj, {individualType: 'json'}).then(res =>{
        if (res.code == 0 || res.code == 200) {
          this.tableData21 = res.data
        }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 = ''
      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
        },
        'list':[6],
        '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
          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)
      })
    },
    // 已审核数据
    dataMain2 () {
      if(!this.click_main2 || !this.click_main2.MAT_NO){
        return;
      }
      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
        },
        'list':[7],
        'startTime': startTime,
        'endTime':  endTime,
        'pageIndex':this.pageIndex2,
        'pageSize':this.pageSize2
      }
      this.tableLoading2 = true;
      this.axios.post('pass/testManagement/v1/limssamplereleases/queryLimsSampleReleasePage2', 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
    },
    // 选中未审核物料
    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 < 1) {
        this.$message.warning('请先勾选要审批的原始数据')
        return
      }
      this.backLoading = true
      this.$confirm('确定审核不通过？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
      }).then(()=>{
          // 审核不通过
          this.axios.post('pass/testManagement/v1/limsfourapprove/checkErrFourApprove', this.multipleSelection1, {individualType: 'json'}).then(res =>{
            if (res.code == 0 || res.code == 200) {
              if(res.data.info && res.data.info != 'true'){
                this.$message.warning(res.data)
              }else{
                this.$message.success(res.message)
              }
              this.dataMain();
              this.batchShow = false;
            } else {
              this.$message.error(res.message)
            }
            this.backLoading = false
          }).catch(e =>{
            this.backLoading = false
            this.$message.error(e.message)
          })
        }
      ).catch(e => {
        this.backLoading = false
        console.log('取消了')
      });
    },
    // 表格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
        };
      }
    },
    // 表格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>
