<template>
  <div class="resource">
    <div class="zy-head-search">
      <span>物品类别</span>
      <el-select v-model="search.stuffTypeCode" :disabled="true" clearable filterable collapse-tags size="small"
        style="width:200px;margin-right: 10px;" placeholder="请选择物品类别">
        <el-option v-for="(item, index) in stuffTypeNameList" :key="index" :label="item.baseName" :value="item.baseCode">
        </el-option>
      </el-select>
      <span>物品名称</span>
      <el-input v-model="search.stuffName" size="small" placeholder="请输入物品名称" style="width: 200px"></el-input>
      <span>配制日期</span>
      <el-date-picker v-model="search.times" type="datetimerange" range-separator="至" start-placeholder="开始日期"
        end-placeholder="结束日期" size="small" style="width: 350px" value-format="yyyy-MM-dd HH:mm:ss">
      </el-date-picker>
      <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>
    </div>
    <el-row>
      <el-col :span="12">
        <div class="zy-title-div" style="margin-top: 30px;">
          <div class="zy-title-name">
            <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />
            标准溶液表
          </div>
          <div>
            <!-- <el-button icon="el-icon-circle-plus-outline" type="goon" size="mini" @click="addData">新增</el-button>
            <el-button icon="el-icon-edit" type="goon" size="mini" @click="modifyData">修改</el-button>
            <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="deleteData">停用</el-button>
            <el-button icon="el-icon-check" type="goon" size="mini" @click="recoverData">启用</el-button> -->
          </div>
        </div>
        <!-- 物品信息表表格 -->
        <div class="common-table-div" style="margin-bottom:0;margin-top:0">
          <el-table v-loading="dataLoading" ref="dataTable" border :height="height_top" highlight-current-row
            :data="table.list" :icore-filter-flag="icoreFilterFlag" :header-cell-style="tableHeaderCellStyle"
            @row-click="getAllListByEmpNo" :cell-class-name="tableRowClassName"
            :exchangeFilterMap="{ 'validFlag': { '0': '已停用', '1': '已启用' }, }">
            <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" label="数据状态" align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.validFlag == 0">已停用</span>
                <span v-else-if="scope.row.stateFlag === '2'">已提交</span>
                <span v-else-if="scope.row.validFlag == 1">已启用</span>
              </template>
            </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="stuffNoUser" label="溶液编号 "
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="stuffName" label="溶液名称 "
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="stuffSpec" label="溶液溶度/单位"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="stkAlarm" label="库存数量"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="160px" prop="memo1" label="配制日期"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="160px" prop="memo2" 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="120px" prop="createMan" label="创建人"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="createTime" label="创建时间"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="updateMan" label="更新人"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="updateTime" label="更新时间"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="auditMan" label="提交人"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="auditTime" label="提交时间"
              align="center"></el-table-column>
          </el-table>
        </div>
        <div class="zy-foot-page">
          <el-pagination v-loading="dataLoading" @size-change="pageSizeChange" @current-change="pageCurrentChange"
            :current-page="page.pageNum" :page-sizes="[10, 20, 50, 100, 200]" :page-size="page.pageSize"
            layout="total, sizes, prev, pager, next, jumper" :total="page.totalPage" background>
          </el-pagination>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="zy-title-div" style="width: 100%;">
          <div class="zy-title-name">
            <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />
            标准液配置表
          </div>
          <span>
            <!-- <el-button icon="el-icon-circle-plus-outline" type="goon" size="mini" @click="addData2">新增</el-button>
                    <el-button icon="el-icon-edit" type="goon" size="mini" @click="modifyData2">修改</el-button>
                    <el-button icon="el-icon-edit" type="goon" size="mini" @click="calculate(1)" :loading="calculateLoading">计算</el-button>
                    <el-button icon="el-icon-circle-close" type="danger" size="mini" :loading=deleteLoading @click="deleteMake(1)">删除</el-button>
                    <el-button icon="el-icon-circle-plus-outline" type="goon" size="mini" :loading="auditLoading" @click="audit(1)">提交</el-button>
                    <el-button icon="el-icon-circle-plus-outline" type="danger" size="mini" :loading="cancelAuditLoading" @click="cencelAudit(1)">撤销提交</el-button> -->
          </span>
        </div>
        <div class="common-table-div" style="margin-bottom:0;margin-top:0">
          <el-table v-loading="dataLoading2" ref="dataTable2" border :height="height_bot" :data="table.list2"
            @row-click="click2" @selection-change="selectRow2" :icore-filter-flag="icoreFilterFlag"
            :header-cell-style="tableHeaderCellStyle" :exchangeFilterMap="{ 'validFlag': { '0': '已停用', '1': '已启用' }, }">
            <el-table-column type="selection" width="50" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="stateFlag" label="状态"
              align="center">
              <template slot-scope="scope">
                <span v-if="scope.row.stateFlag === '1'">
                  已提交
                </span>
                <span v-else-if="scope.row.stateFlag === '2'">
                  已审核
                </span>
                <span v-else>
                  待提交
                </span>
              </template>
            </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="150px" prop="anlyItemName" label="分析项目名称"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="anlyValue" label="报出值"
              align="center">
              <template slot-scope="{ row }">
                <el-input v-model="row.anlyValue" size="small" style="width: 100%">
                </el-input>
              </template>
            </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="110px" prop="formulaName" label="计算公式"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="dspOrder" label="显示序号"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="unitName" label="计量单位"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="stuffNo" label="物品编号"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="stuffName" label="物品名称"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="testItemName" label="测试任务"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="createMan" label="创建人"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="200px" prop="createTime" label="创建时间"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="updateMan" label="修改人"
              align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="200px" prop="updateTime" label="修改时间"
              align="center"></el-table-column>
          </el-table>
        </div>
        <div class="zy-foot-page"></div>
      </el-col>
    </el-row>
    <el-dialog :close-on-click-modal="false" @close="closebatch" width="70%" :visible.sync="recallShow" top="8%">
      <div class="zy-title-div">
        <div class="zy-title-name">
          <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />
          标定液标定表
        </div>
      </div>
      <div class="common-table-div" style="margin-bottom:0;margin-top:0">
        <el-table v-loading="dataLoadingLog" ref="dataTableLog" border :data="table.listLog"
          @selection-change="handleSelectionChange" :header-cell-style="tableHeaderCellStyle"
          :exchangeFilterMap="{ 'validFlag': { '0': '已停用', '1': '已启用' }, }">
          <el-table-column type="selection" width="30" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="testItemName" label="测试项目名称"
            align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="itemTypeName" label="项目类型"
            align="center"></el-table-column>
        </el-table>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button icon="el-icon-circle-plus-outline" type="goon" size="mini" @click="determine">确定</el-button>
      </div>
    </el-dialog>
    <div is="alertComponents" :showFlag="showFlag" :Params="Params" @refresh='refresh(1)'></div>
  </div>
</template>
<script>
import {
  getCookie,
  formatDate
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js';
import alertComponents from './alertComponents';
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  components: { alertComponents },
  data() {
    return {
      headerHeight: 0, // 搜索栏高度
      titleHeight: 0, // 标题栏高度
      footerHeight: 0, // 分页栏高度
      minTableHeight: 250, // 表格最小高度阈值
      resizeObserver: null, // 窗口监听对象
      table: {
        list: [],
        list2: [],
        listLog: [],
      },
      calculateLoading: false,
      deleteLoading: false,
      auditLoading: false,
      cancelAuditLoading: false,
      icoreFilterFlag: true,
      dataLoading: false,
      dataLoading2: false,
      dataLoading3: false,
      dataLoading4: false,
      dataLoadingLog: false,
      stuffTypeNameList: [],
      multipleSelection: [],
      selectRow2s: [],
      selectRow3s: [],
      selectRow4s: [],
      tableList: {},
      page: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      showFlag: false,
      Params: {},
      stuffNo: '',
      search: {
        stuffName: '',
        stuffTypeCode: '',
        times: []
      },
      height_top: 0,
      height_bot: 0,
      recallShow: false,
      optVal: 1,
      activeName: 'first',
    }
  },
  beforeDestroy() {
    window.removeEventListener('resize', this.calcTableHeight);
    if (this.resizeObserver) {
      this.resizeObserver.disconnect();
      this.resizeObserver = null;
    }
  },
  mounted() {
    this.axios.post('pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode', { validFlag: 1, baseCode: 4813 }, { individualType: 'json' })
      .then(res => {
        this.stuffTypeNameList = res.data;
      })
    this.search.stuffTypeCode = '481311'
    this.searchData();
    this.calcTableHeight();
    window.addEventListener('resize', this.calcTableHeight);
    this.resizeObserver = new ResizeObserver(() => {
      this.calcTableHeight();
    });
    const headerEl = document.querySelector('.zy-head-search');
    const titleEl = document.querySelector('.zy-title-div');
    const footerEl = document.querySelector('.zy-foot-page');
    if (headerEl) this.resizeObserver.observe(headerEl);
    if (titleEl) this.resizeObserver.observe(titleEl);
    if (footerEl) this.resizeObserver.observe(footerEl);
  },
  created() {
    // this.height_top = window.innerHeight - 150;
    // this.height_bot = window.innerHeight - 150;
    let timestamp = new Date().getTime() - (7 * 24 * 60 * 60 * 1000) // 默认前一周
    this.search.times = [this.getYNM(new Date(timestamp)) + ' 00:00:00', this.getYNM(new Date()) + ' 23:59:59']
  },
  // mounted () {
  //   this.axios.post('pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode',{validFlag:1,baseCode:4813}, {individualType: 'json'})
  //       .then(res => {
  //       this.stuffTypeNameList= res.data;
  //   })
  //   this.search.stuffTypeCode = '481311'
  //   this.searchData();
  // },
  methods: {
    calcTableHeight() {
      this.$nextTick(() => {
        const headerEl = document.querySelector('.zy-head-search');
        const titleEl = document.querySelector('.zy-title-div');
        const footerEl = document.querySelector('.zy-foot-page');

        this.headerHeight = headerEl ? headerEl.offsetHeight : 0;
        this.titleHeight = titleEl ? titleEl.offsetHeight : 0;
        this.footerHeight = footerEl ? footerEl.offsetHeight : 0;

        const totalReserveHeight = this.headerHeight + this.titleHeight + this.footerHeight + 20; // 20为额外边距（可调整）

        const calcHeight = window.innerHeight / 2 - totalReserveHeight;
        this.height_top = calcHeight < this.minTableHeight ? this.minTableHeight : calcHeight;
        this.height_bot = this.height_top;

        this.$refs.dataTable.doLayout();
        this.$refs.dataTable2.doLayout();
        this.$refs.dataTable3.doLayout();
        this.$refs.dataTable4.doLayout();
        this.$refs.dataTable5.doLayout();
        this.$refs.dataTable6.doLayout();
        this.$refs.dataTable7.doLayout();
      });
    },
    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}`;
    },
    click2(val) {
      this.$refs.dataTable2.toggleRowSelection(val);
    },
    selectRow2(val) {
      this.selectRow2s = val;
    },
    selectRow3(val) {
      this.selectRow3s = val;
    },
    selectRow4(val) {
      this.selectRow4s = val;
    },
    determine() {
      if (this.multipleSelection.length < 1) {
        this.$message.warning('请选中一条测试项目数据！')
        return
      }
      if (this.optVal === 1) {
        if (!this.table.list2 || this.table.list2.length > 0) {
          return this.$message.warning('当前物料已有标准液配置数据，无法重复添加!')
        }
      }
      let lists = [];
      this.multipleSelection.forEach(res => {
        lists.push(res.testItemNo);
      })
      let mn = 'PZ'
      if (this.optVal === 2) {
        mn = 'BD'
      } else if (this.optVal === 3) {
        mn = 'FD'
      }
      let obj = {
        stuffNo: this.tableList.stuffNo,
        stuffName: this.tableList.stuffName,
        itemTypeCode: this.multipleSelection[0].itemTypeCode,
        mnemonicCode: mn,
        list: lists,
      }
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/addListByStuffNo', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.recallShow = false;
          if (this.optVal === 1) {
            this.mainData1(this.tableList)
          } else if (this.optVal === 2) {
            this.mainData2(this.tableList)
          } else if (this.optVal === 3) {
            this.mainData3(this.tableList)
          }
          this.$message.success('新增成功！')
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
      });
    },
    modifyData3() {
      if (this.selectRow3s.length == 0) {
        this.$message.warning('请选中一条标准液标定数据！')
        return
      }
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/modifyData', this.selectRow3s, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.mainData2(this.tableList)
          this.$message.success('修改成功！')
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      });
    },
    modifyData4() {
      if (this.selectRow4s.length == 0) {
        this.$message.warning('请选中一条标准液复定数据！')
        return
      }
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/modifyData', this.selectRow4s, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.mainData3(this.tableList)
          this.$message.success('修改成功！')
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      });
    },
    addData3() {
      if (this.tableList.stuffNo == null || this.tableList.stuffNo == '') {
        this.$message.warning('请选中一条物品信息一条数据！')
        return
      }
      if (this.tableList.validFlag === '0') {
        this.$message.warning('当前选中的物品信息数据无效，无法新增!')
        return
      }
      if (this.tableList.stateFlag === '2') {
        this.$message.warning('当前选中的物品信息数据已提交，无法新增!')
        return
      }
      let obj = {
        object: {
          validFlag: '1',
          itemTypeCode: '480408',
        },
        pageIndex: 1,
        pageSize: 999,
      }
      this.axios.post('pass/baseManagement/v1/limsstdtestitems/queryLimsStdTestItemPage', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.listLog = res.data.list;
          this.recallShow = true;
          this.optVal = 2;
        } else {
          return this.$message.warning(res.message)
        }
      }).catch(e => {
        return this.$message.error(e.message)
      });

    },
    addData4() {
      if (this.tableList.stuffNo == null || this.tableList.stuffNo == '') {
        this.$message.warning('请选中一条物品信息一条数据！')
        return
      }
      if (this.tableList.validFlag === '0') {
        this.$message.warning('当前选中的物品信息数据无效，无法新增!')
        return
      }
      if (this.tableList.stateFlag === '2') {
        this.$message.warning('当前选中的物品信息数据已提交，无法新增!')
        return
      }
      let obj = {
        object: {
          validFlag: '1',
          itemTypeCode: '480408',
        },
        pageIndex: 1,
        pageSize: 999,
      }
      this.axios.post('pass/baseManagement/v1/limsstdtestitems/queryLimsStdTestItemPage', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.listLog = res.data.list;
          this.recallShow = true;
          this.optVal = 3;
        } else {
          return this.$message.warning(res.message)
        }
      }).catch(e => {
        return this.$message.error(e.message)
      });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    refresh(number) {
      switch (number) {
        case 1:
          this.searchData();
          break
      }
    },
    cencelAudit(val) {
      let arr = []
      let state = false;
      if (val === 1) {
        this.table.list2.forEach(s => {
          if (s.stateFlag != "1") {
            state = true;
          }
        })
        if (!this.table.list2 || this.table.list2.length < 1) {
          return this.$message.warning('表格中没有数据，提交失败!')
        }
        for (let i = 0; i < this.table.list2.length; i++) {
          arr.push(this.table.list2[i].id)
        }
      } else if (val === 2) {
        this.table.list3.forEach(s => {
          if (s.stateFlag != "1") {
            state = true;
          }
        })
        if (!this.table.list3 || this.table.list3.length < 1) {
          return this.$message.warning('表格中没有数据，提交失败!')
        }
        for (let i = 0; i < this.table.list3.length; i++) {
          arr.push(this.table.list3[i].id)
        }
      } else if (val === 3) {
        this.table.list4.forEach(s => {
          if (s.stateFlag != "1") {
            state = true;
          }
        })
        if (!this.table.list4 || this.table.list4.length < 1) {
          return this.$message.warning('表格中没有数据，提交失败!')
        }
        for (let i = 0; i < this.table.list4.length; i++) {
          arr.push(this.table.list4[i].id)
        }
      }
      if (state) {
        return this.$message.warning('不符合撤回提交条件!')
      }
      this.cancelAuditLoading = true
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/cancelAudit', arr, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.cancelAuditLoading = false
          this.$message.success(res.message)
          if (val === 1) {
            this.mainData1(this.tableList)
          } else if (val === 2) {
            this.mainData2(this.tableList)
          } else if (val === 3) {
            this.mainData3(this.tableList)
          }
          this.searchData()
        } else {
          this.cancelAuditLoading = false
          this.$message.warning(res.message)
        }
      }).catch(e => {
        this.cancelAuditLoading = false
        this.$message.error(e.message)
      })
    },
    audit(val) {
      let arr = []
      let state = false;
      if (val === 1) {
        this.table.list2.forEach(s => {
          if (s.stateFlag != "0") {
            state = true;
          }
        })
        if (!this.table.list2 || this.table.list2.length < 1) {
          return this.$message.warning('表格中没有数据，提交失败!')
        }
        for (let i = 0; i < this.table.list2.length; i++) {
          arr.push(this.table.list2[i])
        }
      } else if (val === 2) {
        this.table.list3.forEach(s => {
          if (s.stateFlag != "0") {
            state = true;
          }
        })
        if (!this.table.list3 || this.table.list3.length < 1) {
          return this.$message.warning('表格中没有数据，提交失败!')
        }
        for (let i = 0; i < this.table.list3.length; i++) {
          arr.push(this.table.list3[i])
        }
      } else if (val === 3) {
        this.table.list4.forEach(s => {
          if (s.stateFlag != "0") {
            state = true;
          }
        })
        if (!this.table.list4 || this.table.list4.length < 1) {
          return this.$message.warning('表格中没有数据，提交失败!')
        }
        for (let i = 0; i < this.table.list4.length; i++) {
          arr.push(this.table.list4[i])
        }
      }
      if (state) {
        return this.$message.warning('不符合提交条件!')
      }
      this.auditLoading = true
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/audit', arr, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.auditLoading = false
          this.$message.success(res.message)
          if (val === 1) {
            this.mainData1(this.tableList)
          } else if (val === 2) {
            this.mainData2(this.tableList)
          } else if (val === 3) {
            this.mainData3(this.tableList)
          }
          this.searchData()
        } else {
          this.auditLoading = false
          this.$message.warning(res.message)
        }
      }).catch(e => {
        this.auditLoading = false
        this.$message.error(e.message)
      })
    },
    // 物品信息表新增
    addData() {
      this.showFlag = !this.showFlag;
      this.Params = null;
    },
    // 修改物品信息表
    modifyData() {
      if (!this.tableList || JSON.stringify(this.tableList) === '{}') {
        this.$message.warning('请选中您需要修改的一条数据！')
      }
      this.showFlag = !this.showFlag;
      this.Params = this.tableList
    },
    // 物品信息表删除
    deleteData() {
      if (!this.tableList || JSON.stringify(this.tableList) === '{}') {
        this.$message.warning('请选中您需要停用的一条数据！')
      }
      this.tableList.updateMan = userName;
      this.tableList.updateNo = userId
      let arr = []
      arr.push(this.tableList)
      this.axios.post('pass/baseManagement/v1/limslrcstuffs/abolish', arr, { 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)
      })
    },
    // 信息表恢复
    recoverData() {
      if (!this.tableList || JSON.stringify(this.tableList) === '{}') {
        this.$message.warning('请选中您需要启用的一条数据！')
      }
      this.tableList.updateMan = userName;
      this.tableList.updateNo = userId
      let arr = []
      arr.push(this.tableList)
      this.axios.post('pass/baseManagement/v1/limslrcstuffs/recover', arr, { 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)
      })

    },
    deleteMake(val) {
      this.$confirm('确认执行【删除】操作吗？', '是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let arr = []
        if (val === 1) {
          if (!this.selectRow2s || this.selectRow2s.length < 1) {
            return this.$message.warning('请在【标准液配置表】中勾选需要删除的数据！')
          }
          arr = this.selectRow2s
        } else if (val === 2) {
          if (!this.selectRow3s || this.selectRow3s.length < 1) {
            return this.$message.warning('请在【标定液标定表1】中勾选需要删除的数据！')
          }
          arr = this.selectRow3s
        } else if (val === 3) {
          if (!this.selectRow4s || this.selectRow4s.length < 1) {
            return this.$message.warning('请在【标定液标定表2】中勾选需要删除的数据！')
          }
          arr = this.selectRow4s
        }
        this.deleteLoading = true
        this.axios.post('pass/testManagement/v1/limslrcstuffmakes/deleteData', arr, { individualType: 'json' }).then(res => {
          if (res.code == 0 || res.code == 200) {
            this.deleteLoading = false
            if (val === 1) {
              this.mainData1(this.tableList)
            } else if (val === 2) {
              this.mainData2(this.tableList)
            } else if (val === 3) {
              this.mainData3(this.tableList)
            }
            return this.$message.success(res.message)
          } else {
            this.deleteLoading = false
            return this.$message.warning(res.message)
          }
        }).catch(e => {
          this.deleteLoading = false
          return this.$message.error(e.message)
        })
      }).catch(() => {
        this.deleteLoading = false
        this.$message({
          type: 'info',
          message: '已取消停用'
        });

      });
    },
    // 计算
    calculate(val) {
      let arr = []
      if (val === 1) {
        if (!this.table.list2 || this.table.list2.length < 1) {
          return this.$message.warning('表格中没有数据，计算失败!')
        }
        arr = this.table.list2;
      } else if (val === 2) {
        if (!this.table.list3 || this.table.list3.length < 1) {
          return this.$message.warning('表格中没有数据，计算失败!')
        }
        arr = this.table.list3;
      } else if (val === 3) {
        if (!this.table.list4 || this.table.list4.length < 1) {
          return this.$message.warning('表格中没有数据，计算失败!')
        }
        arr = this.table.list4;
      }

      this.calculateLoading = true
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/calculateData', arr, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.calculateLoading = false
          if (val === 1) {
            this.mainData1(this.tableList);
          } else if (val === 2) {
            this.mainData2(this.tableList);
          } else if (val === 3) {
            this.mainData3(this.tableList)
          }
          return this.$message.success(res.message)
        } else {
          this.calculateLoading = false
          return this.$message.warning(res.message)
        }
      }).catch(e => {
        this.calculateLoading = false
        return this.$message.error(e.message)
      })
    },
    modifyData2() {
      if (this.selectRow2s.length == 0) {
        this.$message.warning('请选中一条标准液配置信息！')
        return
      }
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/modifyData', this.selectRow2s, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.mainData1(this.tableList)
          this.$message.success('修改成功！')
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      });
    },
    addData2() {
      if (this.tableList.stuffNo == null || this.tableList.stuffNo == '') {
        this.$message.warning('请选中一条物品信息一条数据！')
        return
      }
      if (this.tableList.stateFlag === '2') {
        this.$message.warning('当前选中的物品信息已经被提交，无法新增！')
        return
      }
      if (this.tableList.validFlag === '0') {
        this.$message.warning('当前选中的物品信息无效，无法新增！')
        return
      }
      let obj = {
        object: {
          validFlag: '1',
          itemTypeCode: '480408',
        },
        pageIndex: 1,
        pageSize: 9999,
      }
      this.axios.post('pass/baseManagement/v1/limsstdtestitems/queryLimsStdTestItemPage', obj, { individualType: 'json' }).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.listLog = res.data.list;
          this.recallShow = true;
          this.optVal = 1
        } else {
          return this.$message.warning(res.message)
        }
      }).catch(e => {
        return this.$message.error(e.message)
      });

    },
    closebatch() { },
    // tabcilck(row) {
    //     if(row.name == "first"){
    //         this.tabTop = '480408'
    //     }else{
    //         this.tabTop = '480409'
    //     }
    // },
    searchData() {
      this.dataLoading = true;
      this.page.pageNum = 1;
      let params = ''
      if (!this.search.times) {
        params = '?pageNum=' + this.page.pageNum + '' +
          '&pageSize=' + this.page.pageSize + '&stuffTypeCode=' + this.search.stuffTypeCode + '&stuffName=' + this.search.stuffName +
          '&optEvent=' + '2'
      } else {
        params = '?pageNum=' + this.page.pageNum + '' +
          '&pageSize=' + this.page.pageSize + '&stuffTypeCode=' + this.search.stuffTypeCode + '&stuffName=' + this.search.stuffName +
          '&makeStartTime=' + this.search.times[0] + '&makeEndTime=' + this.search.times[1] + '&optEvent=' + '2'
      }
      this.axios.get('pass/baseManagement/v1/limslrcstuffs/queryLimsLrcStuffPage' + params)
        .then(res => {
          this.dataLoading = false;
          this.table.list = res.data.list;
          this.page.totalPage = res.data.total;
        }).catch(e => {
          this.dataLoading = false;
        });
    },
    reset() { },
    getAllListByEmpNo(val) {
      this.tableList = val
      this.mainData1(val);
      this.mainData2(val);
      this.mainData3(val)
    },
    mainData1(val) {
      if (val == null) {
        this.$message.warning('请选中一条物品信息一条数据！')
        return
      }
      this.dataLoading2 = true;
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/queryByStuffNo', { stuffNo: val.stuffNo, mnemonicCode: 'PZ' }, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.table.list2 = res.data;
        } else {
          this.$message.error(res.message)
        }
        this.dataLoading2 = false;
      }).catch(e => {
        this.$message.error(e.message)
        this.dataLoading2 = false;
      })
    },
    mainData2(val) {
      if (val == null) {
        this.$message.warning('请选中一条物品信息一条数据！')
        return
      }
      this.dataLoading3 = true;
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/queryByStuffNo', { stuffNo: val.stuffNo, mnemonicCode: 'BD' }, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.table.list3 = res.data;
        } else {
          this.$message.error(res.message)
        }
        this.dataLoading3 = false;
      }).catch(e => {
        this.$message.error(e.message)
        this.dataLoading3 = false;
      })
    },
    mainData3(val) {
      if (val == null) {
        this.$message.warning('请选中一条物品信息一条数据！')
        return
      }
      this.dataLoading4 = true;
      this.axios.post('pass/testManagement/v1/limslrcstuffmakes/queryByStuffNo', { stuffNo: val.stuffNo, mnemonicCode: 'FD' }, { individualType: 'json' }).then(res => {
        if (res.succeed) {
          this.table.list4 = res.data;
        } else {
          this.$message.error(res.message)
        }
        this.dataLoading4 = false;
      }).catch(e => {
        this.$message.error(e.message)
        this.dataLoading4 = false;
      })
    },
    pageSizeChange(size) {
      this.page.pageSize = size;
      this.getDataList();
    },
    pageCurrentChange(index) {
      this.page.pageNum = index;
      this.getDataList();
    },
    tableRowClassName({
      row, column, rowIndex, columnIndex
    }) {
      if (columnIndex === 1) {
        if (row.stateFlag === '2') {
          return 'success-cell'
        }
        if (row.validFlag === '0') {
          return 'error-row';
        }
      }
    },
    tableHeaderCellStyle() {
      return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
    }
  },
}
</script>
<style lang="less">
.success-cell {
  background-color: #1a9f17;
}
</style>
