<!-- 标准管理-测试指标维护 -->
<template>
  <div class="examination">
    <div class="common-head-search">
      <el-form :inline="true">
        <el-form-item label='测试指标编码'>
          <el-input v-model="search.indexNo" size="small" @keyup.enter.native="searchData" placeholder="请输入查询内容" style="width: 200px;"></el-input>
        </el-form-item>
        <el-form-item label='测试计划编码'>
          <el-input v-model="search.testPlanNo" size="small" @keyup.enter.native="searchData" placeholder="请输入查询内容" style="width: 200px;"></el-input>
        </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-button icon="el-icon-back" type="goon" plain v-show="backButton" size="mini" @click="toBack">返回样品模板</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-row>
      <el-col :span='12'>
        <div>
          <div  style="padding-top: 10px;padding-left: 30px;">
            <div class="common-title-name" style="display:inline-block;margin-right:0">
              <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />测试指标集
            </div>
            <el-button icon="el-icon-circle-plus-outline" type="goon" size="mini" @click="dialogTableVisible4 = true">新增</el-button>
            <el-button icon="el-icon-edit" type="goon" size="mini" @click="modifyData4">修改</el-button>
            <el-button icon="el-icon-circle-plus-outline" type="goon" size="mini" @click="copyData4">复制</el-button>
            <el-button icon="el-icon-remove-outline" type="danger" size="mini" @click="deleteData4">停用</el-button>
            <el-button icon="el-icon-check" type="goon" size="mini" @click="recoverData4">启用</el-button>
          </div>

        </div>
        <div class="common-table-div" style="margin-bottom:0">
          <el-table v-loading="dataLoading4" ref="dataTable2" border :height="heightTop" @row-click="searchTestPlan" highlight-current-row
          :data="table.list4" :icore-filter-flag="icoreFilterFlag"
          :header-cell-style="tableHeaderCellStyle" :row-class-name="tableRowClassName4" :summary-method="getSummaries" show-summary>
          <el-table-column type="index" label="NO" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="indexNo" label="测试指标编码" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="indexName" label="测试指标名称" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="130px" prop="gradeName" label="牌号" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="stdName" label="标准" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="130px" prop="judgeTypeName" label="判定类型" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="testPlanNo" label="测试计划编码" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="testPlanName" label="测试计划名称" align="center"></el-table-column>
           <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="validFlag1" label="数据状态" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="130px" prop="taskNo" label="测试任务编码" align="center"></el-table-column>
          <el-table-column sortable :show-overflow-tooltip="true" min-width="130px" prop="taskName" 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="100px" 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>
        </div>
        <div class="common-foot-style">
          <el-pagination v-loading="dataLoading4" @size-change="pageSizeChange4" @current-change="pageCurrentChange4"
            :current-page="page4.pageNum" :page-sizes="[10, 20, 50, 100, 200]" :page-size="page4.pageSize" layout="total, sizes, prev, pager, next, jumper"
            :total="page4.totalPage" background>
          </el-pagination>
        </div>
      </el-col>
      <el-col :span='12'>
        <div>
          <div  style="padding-top: 10px;padding-left: 30px;">
            <div class="common-title-name" style="display:inline-block;margin-right:0">
              <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />测试任务
            </div>
            <!-- <el-button icon="el-icon-edit" type="goon" size="mini" @click="modifyData">编辑</el-button>
            <el-button icon="el-icon-remove-outline" type="danger" size="mini" @click="deleteData">停用</el-button>
            <el-button icon="el-icon-check" type="goon" size="mini" @click="recoverData" style="margin-right：60px">启用</el-button> -->

          </div>
        </div>
        <div class="common-table-div" style="margin-bottom:0">
            <el-table v-loading="dataLoading" ref="dataTable" border :height="heightTop" highlight-current-row @row-click="searchAnalysis" :data="table.list" :icore-filter-flag="icoreFilterFlag"
            :header-cell-style="tableHeaderCellStyle" :row-class-name="tableRowClassName2" :summary-method="getSummaries" show-summary>
            <el-table-column type="index" label="NO" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="testItemNo" label="测试项目编号" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="testItemName" label="测试项目名称" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="itemTypeName" label="项目类型" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="doOrder" label="执行顺序" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="testCnt" label="测试次数" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="testLocate" label="测试位置" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="validFlag1" label="数据状态" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="pointName" label="作业点" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="testPostName" label="测试岗位" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="110px" prop="eqpTypeName" label="测试设备类型" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="testLimit" label="测试时限" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isTest1" label="是否免检" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="isRefer1" label="是否引用" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="200px" prop="memo" 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="80px" prop="createMan" label="创建人" align="center"></el-table-column>
          </el-table>
        </div>
        <div class="common-foot-style">
          <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-row>
     <el-row>
      <el-col>
        <div>
    <div class="common-title-div" style="margin-bottom:0">
      <div class="common-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="addAnalyze">新增</el-button>
      <el-button icon="el-icon-edit" type="goon" size="mini" @click="modifyData2">修改</el-button>
      <el-button icon="el-icon-remove-outline" type="danger" size="mini" @click="deleteData2">停用</el-button>
      <el-button icon="el-icon-check" type="goon" size="mini" @click="recoverData2">启用</el-button>
      <el-button icon="el-icon-circle-close" type="danger" size="mini" @click="deleteAnalyze">删除</el-button>
      </div>
    </div>
    <div class="common-table-div">
       <el-table v-loading="dataLoading2" ref="dataTable4" border :height="heightTop" highlight-current-row @row-click="clickAnalysis" :data="table.list2" :icore-filter-flag="icoreFilterFlag2"
       :header-cell-style="tableHeaderCellStyle" :row-class-name="tableRowClassName3" :summary-method="getSummaries" show-summary>
        <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="testItemNo" label="测试任务编码" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="testItemName" label="测试任务名称" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="anlyItemNo" label="分析项目编号" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="anlyItemName" label="分析项目名称" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="anlyItemAlias" label="分析项目别名" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="unitName" label="数值单位" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="defaultValue" label="默认值" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="80px"  prop="validFlag1" label="数据状态" align="center">
          <!-- <template slot-scope="scope">
              <span v-if="scope.row.validFlag == 1">有效</span>
              <span v-else-if="scope.row.validFlag == 0">无效</span>
          </template> -->
        </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="90px" prop="dataTypeName" label="数据类型" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="formulaName" label="计算公式" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="reviseRuleName" label="修约规则" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="anlyCnt" label="分析次数" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="outputTypeName" label="输出类型" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="minSign" label="下限符" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="minValue" label="下限值" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="maxSign" label="上限符" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="maxValue" label="上限值" align="center"></el-table-column>
         <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="maxStd" label="标准上限值" align="center"></el-table-column>
         <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="minStd" label="标准下限值" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="maxLimit" label="方法上限值" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="minLimit" label="方法下限值" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="isReport1" label="是否报出" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="isRare1" label="是否贵重" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="isLogin1" label="是否必检" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="isAlarm1" label="是否报警" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="isCompute1" label="是否计算" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="isMid1" label="是否中间项" align="center"></el-table-column>
        <el-table-column sortable :show-overflow-tooltip="true" min-width="200px" prop="memo" label="备注" align="center"></el-table-column>
      </el-table>
    </div>
    <!-- <div class="common-foot-style">
        <el-pagination v-loading="dataLoading2" @size-change="pageSizeChange2" @current-change="pageCurrentChange2"
          :current-page="page2.pageNum" :page-sizes="[10, 20, 50, 100, 200]" :page-size="page2.pageSize" layout="total, sizes, prev, pager, next, jumper"
          :total="page2.totalPage" background>
        </el-pagination>
    </div> -->
    </div>
      </el-col>
    </el-row>
    <el-dialog @close="closeDialog" :close-on-click-modal='false' :visible.sync="dialogTableVisible4" customClass="customWidth_standas">
        <div slot="title" class="titleBox">
        <i :class="tableType4 === 0? 'el-icon-document':'el-icon-edit-outline'" style="font-size: 20px"></i>
        <span style="margin-left:10px;font-size:18px">{{tableTypeDsc4}}</span>
        </div>
        <el-form :model="formData4" label-width="80px" :rules="monitorRules4" ref="monitorForm4">
          <el-row>
            <el-col :span='12'>
              <el-form-item v-if="tableType4 === 1" prop='testPlanName' label="测试计划">
                <el-input v-model="formData4.testPlanName" readOnly disabled size="small" style="width: 100%;"></el-input>
              </el-form-item>
              <el-form-item v-if="tableType4 === 0" prop="testPlanNo" label="测试计划">
                <el-select v-model="formData4.testPlanNo" filterable collapse-tags size="small" style="width: 100%;">
                  <el-option v-for="(item,index) in testPlanNameType" :key="index" :label="item.testPlanName"
                    :value="item.testPlanNo">
                  </el-option>
                </el-select>
               </el-form-item>
            </el-col>
            <el-col :span='12'>
              <el-form-item  v-if="tableType4 === 1"  prop='taskName' label="测试任务">
                <el-input v-model="formData4.taskName" readOnly disabled size="small" style="width: 100%;"></el-input>
              </el-form-item>
              <el-form-item v-if="tableType4 === 0" prop="taskNo" label="测试任务">
               <el-select v-model="formData4.taskNo" filterable collapse-tags size="small" style="width: 100%;">
                  <el-option v-for="(item,index) in taskNameType" :key="index" :label="item.taskName"
                    :value="item.taskNo">
                  </el-option>
                </el-select>
               </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span='12'>
              <el-form-item prop="indexName" label="指标名称">
                <el-input v-model="formData4.indexName" placeholder="请输入" size="small" style="width: 100%;"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span='12'>
              <el-form-item label="产品标准">
                <el-select v-model="formData4.stdNo" filterable collapse-tags size="small" style="width: 100%;">
                  <el-option v-for="(item,index) in stdNameType" :key="index" :label="item.stdName"
                    :value="item.stdNo">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span='12'>
              <el-form-item label="牌号">
                <el-select v-model="formData4.gradeNo" filterable collapse-tags size="small" style="width: 100%;">
                  <el-option v-for="(item,index) in gradeNameType" :key="index" :label="item.gradeName"
                    :value="item.gradeNo">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span='12'>
              <el-form-item label="判定类型">
                <el-select v-model="formData4.judgeTypeCode" filterable collapse-tags size="small" style="width: 100%;">
                  <el-option v-for="(item,index) in judgeTypeNameType" :key="index" :label="item.baseName"
                    :value="item.baseCode">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span='24'>
              <el-form-item prop="memo" label="备注">
               <el-input v-model="formData4.memo" size="small" style="width: 100%;" placeholder="请输入"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
         </el-form>
       <span slot="footer" class="dialog-footer">
        <el-button type="goon" icon="el-icon-check" size="mini" @click="tableType4 == 0 ? addTarget() : modifyTarget()">确定</el-button>
        <el-button size="mini" type="goon" icon="el-icon-remove-outline" @click="cancel">取消</el-button>
      </span>
    </el-dialog>
    <!-- <div is="alertComponets" :showFlag="showFlag" :Params="Params" :Params2="Params2" @refresh='refresh'></div> -->
    <div is="addAnalyzeAlert" :showFlag="showAddFlag" :Params="AnalyzeData" @refresh='refresh2'></div>
    <div is="alertComponets3" :showFlag="showFlag3" :Params="Params3" @refresh='refresh2'></div>
    <!-- <div is="alertComponets5" :showFlag="showFlag5" :Params="Params6" :Params2="Params4" @refresh='refresh'></div> -->
  </div>
</template>
<script>
import {
  getCookie
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js';
import alertComponets from './alertComponents';
import addAnalyzeAlert from './addAnalyzeAlert';
import alertComponets3 from './alertComponents3';
import alertComponets5 from './alertComponents5';
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  components: {alertComponets, alertComponets3, alertComponets5,addAnalyzeAlert},
  data () {
    return {
      table: {
        list: [],
        list2: [],
        list3: []
      },
      AnalyzeData:{},
      showAddFlag:false,
      testPlanNameType:[],
      saveIndex:{},
      saveAnalysis:{},
      taskNameType:[],
      stdNameType:[],
      gradeNameType:[],
      judgeTypeNameType:[],
      dataLoading: false,
      dataLoading2: false,
      dataLoading3: false,
      dataLoading4: false,
      icoreFilterFlag: true,
      icoreFilterFlag2: true,
      icoreFilterFlag3: true,
      icoreFilterFlag4: true,
      activeName: 'first',
      page: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 100,
        pageNum: 1,
        totalPage: 0
      },
      page4: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      dialogTableVisible4:false,
      tableType4:0,
      tableTypeDsc4:'新增测试指标集',
      formData4:{indexName:'默认指标集'},
      monitorRules4:{taskNo: [{ required: true, message: '该项不能为空', trigger:'change'},],
                    testPlanNo: [{ required: true, message: '该项不能为空', trigger:'change'},],
                    taskName: [{ required: true, message: '该项不能为空', trigger:'blur'},],
                    testPlanName: [{ required: true, message: '该项不能为空', trigger:'blur'},],
                    indexName:[{ required: true, message: '该项不能为空', trigger:'blur'},],
      },
      backButton:false,
      taskNoD: '',
      indexNo: '',
      showFlag: false,
      showFlag2: false,
      showFlag3: false,
      showFlag4: false,
      showFlag5: false,
      saveAnalyData:{},
      Params: {},
      Params2: {},
      Params3: {},
      Params4: {},
      Params5: {},
      Params6: {},
      multipleSelection: [],
      multipleSelection2: [],
      multipleSelection3: [],
      multipleSelection5: [],
      testItemNameType: [],
      search: {
        taskNo: '',
        testPlanNo: ''
      },
      heightTop:0,
      search2:{},
      tmpNo: '',
      pageList: {},
    }
  },
  created(){
    this.heightTop = window.innerHeight/2 - 130 < 249 ? 249 : window.innerHeight/2 - 130
    this.backButton = this.$route.query.testPlanNo ? true : false
    this.search.testPlanNo = this.$route.query.testPlanNo ? this.$route.query.testPlanNo : ''
    this.search2 = this.$route.query.searchData ? this.$route.query.searchData : {}
    this.tmpNo = this.$route.query.tmpNo ? this.$route.query.tmpNo : ''
    this.pageList = this.$route.query.pageList ? this.$route.query.pageList : {}
  },
 mounted () {
  this.axios.post('pass/baseManagement/v1/limsstdtestplans/queryLimsStdTestPlanPage',{object:{validFlag:1},pageIndex:1,pageSize:99999}, {individualType: 'json'}).then(res => {
    this.testPlanNameType = res.data.list;
  })
  this.axios.post('pass/baseManagement/v1/limsstdtasks/queryLimsStdTaskPage',{object:{validFlag:1},pageIndex:1,pageSize:99999}, {individualType: 'json'}).then(res => {
    this.taskNameType = res.data.list;
  })
  //产品标准
  this.axios.post('pass/baseManagement/v1/limsstdinfos/queryLimsStdInfoList/',{object:{validFlag:1},pageIndex:1,pageSize:9999},{individualType: 'json'}).then(res => {
    this.stdNameType = res.data.list;
  })
  //牌号
  this.axios.post('pass/baseManagement/v1/limsbasegrades/queryLimsBaseGradePage',{object:{grandTypeCode:'',gradeName:''},pageIndex:1,pageSize:99999}, {individualType: 'json'}).then(res => {
    this.gradeNameType = res.data.list;
  })
    //判定类型
    this.axios.post("pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",{validFlag:1,baseCode:4816}, {individualType: 'json'}).then(res => {
      this.judgeTypeNameType = res.data
    })
    this.searchData();
  },
  methods: {
    getCode (code, arr, codeKey, nameKey) {
      if (!code) {
        return '';
      }
      let targetRow = arr.find(item => {
        return item[codeKey] === code;
      });
      return targetRow ? targetRow[nameKey] : '';
    },
    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;
    },
    closeDialog(){
      this.$refs['monitorForm4'].resetFields()
      this.tableType4 = 0
      this.tableTypeDsc4 = '新增测试指标集'
      this.formData4 = {indexName:'默认指标集'}
      this.dialogTableVisible4 = false
    },
    cancel(){
      this.$refs['monitorForm4'].resetFields()
      this.tableType4 = 0
      this.tableTypeDsc4 = '新增测试指标集'
      this.formData4 = {indexName:'默认指标集'}
      this.dialogTableVisible4 = false
    },
    refresh2 () {
      this.getDataList2(this.taskNoD);
    },
    addTarget(){
      this.$refs['monitorForm4'].validate((valid) => {
        if (valid) {
          this.formData4.createMan = userName
          this.formData4.createNo = userId
          this.formData4.testPlanName = this.getCode(this.formData4.testPlanNo,this.testPlanNameType,'testPlanNo','testPlanName')
          this.formData4.taskName = this.getCode(this.formData4.taskNo,this.taskNameType,'taskNo','taskName')
          this.formData4.stdName = this.getCode(this.formData4.stdNo,this.stdNameType,'stdNo','stdName')
          this.formData4.gradeName = this.getCode(this.formData4.gradeNo,this.gradeNameType,'gradeNo','gradeName')
          this.formData4.judgeTypeName = this.getCode(this.formData4.judgeTypeCode,this.judgeTypeNameType,'baseCode','baseName')
          this.axios.post('pass/baseManagement/v1/limsstdindexs/', [this.formData4], {individualType: 'json'}).then(res => {
            if (res.code == 0 || res.code == 200) {
              this.$message.success('测试指标集添加成功')
              this.cancel()
              this.searchData()
            } else {
              this.$message.error(res.message)
            }
          }).catch(e => {
            this.$message.error(e.message)
          })
        }
      })
    },
    modifyTarget(){
      this.$refs['monitorForm4'].validate((valid) => {
        if (valid) {
          this.formData4.stdName = this.getCode(this.formData4.stdNo,this.stdNameType,'stdNo','stdName')
          this.formData4.gradeName = this.getCode(this.formData4.gradeNo,this.gradeNameType,'gradeNo','gradeName')
          this.formData4.judgeTypeName = this.getCode(this.formData4.judgeTypeCode,this.judgeTypeNameType,'baseCode','baseName')
          this.axios.put('pass/baseManagement/v1/limsstdindexs/', this.formData4, {individualType: 'json'}).then(res => {
            if (res.code == 0 || res.code == 200) {
              this.$message.success('测试指标集添加成功')
              this.cancel()
              this.searchData()
            }else {
              this.$message.error(res.message)
            }
          }).catch(e => {
            this.$message.error(e.message)
          })
        }
      })
    },
    //返回样品模板页面
    toBack(){
      this.$router.push({path:'/sampleTemplateMaintenance', query:{searchData: this.search2, pageList: this.pageList, tmpNo: this.tmpNo}})
    },
    //修改测试指标集
    modifyData4 () {
      if (JSON.stringify(this.saveIndex)==="{}") {
        this.$message.warning('请点击选中一条测试指标集数据')
        return
      }
      this.tableType4 = 1
      this.tableTypeDsc4 = '修改测试指标集'
      this.formData4 = Object.assign({},this.saveIndex) ;
      this.dialogTableVisible4 = true
    },
    //测试指标集复制
    copyData4 () {
      if (JSON.stringify(this.saveIndex)==="{}") {
        this.$message.warning('请点击选中一条测试指标集数据')
        return
      }
      this.axios.post('pass/baseManagement/v1/limsstdindexs/copyLimsStdIndexAll?id='+this.saveIndex.id, {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
         this.$message.success(res.message)
         this.searchData()
        } else {
         this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    //测试指标集停用
    deleteData4 () {
      if (JSON.stringify(this.saveIndex)==="{}") {
        this.$message.warning('请点击选中一条测试指标集数据')
        return
      }
      if(this.saveIndex.validFlag == 0){
        this.$message.warning('请点击选中状态为已启用的数据！')
        return
      }
      let tempObj = Object.assign({},this.saveIndex)
      tempObj.updateMan = userName
      tempObj.updateNo = userId
      this.axios.post('pass/baseManagement/v1/limsstdindexs/abolish', [tempObj], {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.$message.success('停用成功');
          this.searchData()
        } else {
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    //测试指标集启用
    recoverData4 () {
      if (JSON.stringify(this.saveIndex)==="{}") {
        this.$message.warning('请点击选中一条测试指标集数据')
        return
      }
      if(this.saveIndex.validFlag == 1){
        this.$message.warning('请点击选中状态为已停用的数据！')
        return
      }
      let tempObj = Object.assign({},this.saveIndex)
      tempObj.updateMan = userName
      tempObj.updateNo = userId
      this.axios.post('pass/baseManagement/v1/limsstdindexs/recover', [tempObj], {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.$message.success('启用成功');
          this.searchData()
        } else {
         this.$message.error(res.message)
        }
        }).catch(e => {
         this.$message.error(e.message)
       })
    },
    addAnalyze(){
      if (JSON.stringify(this.saveAnalyData)==="{}") {
        this.$message.warning('请点击选中一条测试任务数据')
        return
      }
      this.showAddFlag = !this.showAddFlag;
      this.AnalyzeData = Object.assign({},this.saveAnalyData,{indexNo:this.saveIndex.indexNo,indexName:this.saveIndex.indexName});
    },
    //分析项目修改
    modifyData2 () {
      if (JSON.stringify(this.saveAnalysis)==="{}") {
        this.$message.warning('请点击选中一条分析项目数据')
        return
      }
      this.showFlag3 = !this.showFlag3;
      this.Params3 = this.saveAnalysis;
    },
    deleteAnalyze() {
      if (JSON.stringify(this.saveAnalysis)==="{}") {
        this.$message.warning('请点击选中一条分析项目数据')
        return
      }
      this.axios.delete('pass/baseManagement/v1/limsstdindexds/'+this.saveAnalysis.id, {individualType: 'json'}).then(res => {
        if (res.succeed) {
          this.$message.success(res.message);
          this.getDataList2(this.taskNoD);
        } else {
         this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    //停用分析项目
    deleteData2 () {
      if (JSON.stringify(this.saveAnalysis)==="{}") {
        this.$message.warning('请点击选中一条分析项目数据')
        return
      }
      if(this.saveAnalysis.validFlag == 0){
        this.$message.warning('请点击选中状态为已启用的数据！')
        return
      }
      let tempObj = Object.assign({},this.saveAnalysis)
      tempObj.updateMan = userName
      tempObj.updateNo = userId
      this.axios.post('pass/baseManagement/v1/limsstdindexds/abolish', [tempObj], {individualType: 'json'}).then(res => {
        if (res.succeed) {
          this.$message.success(res.message);
          this.getDataList2(this.taskNoD);
        } else {
         this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    //启用分析项目
    recoverData2 () {
      if (JSON.stringify(this.saveAnalysis)==="{}") {
        this.$message.warning('请点击选中一条分析项目数据')
        return
      }
      if(this.saveAnalysis.validFlag == 1){
        this.$message.warning('请点击选中状态为已停用的数据！')
        return
      }
      let tempObj = Object.assign({},this.saveAnalysis)
      tempObj.updateMan = userName
      tempObj.updateNo = userId
      this.axios.post('pass/baseManagement/v1/limsstdindexds/recover', [tempObj], {individualType: 'json'}).then(res => {
        if (res.code==0 || res.code == 200) {
          this.$message.success('启用成功');
          this.getDataList2(this.taskNoD);
        } else {
         this.$message.error(res.message)
        }
      }).catch(e => {
        this.$message.error(e.message)
      })
    },
    //查询按钮操作
    searchData () {
      this.dataLoading4 = true;
      this.page.pageNum = 1;
      this.page4.pageNum = 1;
      this.page4.pageSize = 100
      this.getDataList4()
    },
    //重置
    reset () {
      this.search.indexNo = '';
      this.search.testPlanNo = '';
      this.searchData();
    },
    //查询测试指标集
    getDataList4 () {
      this.table.list = []
      this.table.list2 = []
      this.saveIndex = {}
      this.saveAnalysis = {}
      this.dataLoading4 = true;
      let obj = {
        object:{
          indexNo:this.search.indexNo,
          testPlanNo:this.search.testPlanNo
        },
        pageIndex:this.page.pageNum,
        pageSize:this.page.pageSize
      }
      this.axios.post('pass/baseManagement/v1/limsstdindexs/queryLimsStdIndexPage',obj, {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code ==200) {
          this.table.list4 = res.data.list;
          this.table.list4.forEach(item =>{
            item.validFlag1 = item.validFlag == 0 ? '无效' : item.validFlag == 1 ? '有效' : ''
          })
          this.page4.totalPage = res.data.total;
          if (this.table.list4.length > 0) {
            this.searchTestPlan(this.table.list4[0])
          }
        }else{
          this.$message.error(res.message)
        }
        this.dataLoading4 = false;
      }).catch(e => {
        this.dataLoading4 = false;
        this.$message.error(e.message)
      });
    },
    //默认选中测试指标集的第一行，并查询测试任务
    searchTestPlan (val) {
      this.saveIndex = Object.assign({},val)
      this.indexNo = val.indexNo;
      if (!this.indexNo) {
        return
      }
      this.getDataList (this.indexNo);
    },
    //查询测试任务数据
    getDataList (indexNo) {
      this.table.list2 = []
      this.saveAnalysis = {}
      this.saveAnalyData = {}
      this.dataLoading = true;
      let obj = {
        // object:{isIndex:1},
        object:{},
        mode:indexNo,
        pageIndex:this.page.pageNum,
        pageSize:this.page.pageSize
      }
      this.axios.post('pass/baseManagement/v1/limsstdtaskds/queryLimsStdTaskDPage',obj,{individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.list = res.data.list;
          this.table.list.sort((a,b)=>{
            return a.doOrder - b.doOrder
          })
          this.table.list.forEach(item =>{
            item.validFlag1 = item.validFlag === '0' ? '无效' : item.validFlag === '1' ? '有效' : ''
            item.isCompute1 = item.isCompute === '0' ? '否' : item.isCompute === '1' ? '是' : ''
            item.isMid1 = item.isMid === '0' ? '否' : item.isMid === '1' ? '是' : ''
            item.isReport1 = item.isReport === '0' ? '否' : item.isReport === '1' ? '是' : ''
            item.isLogin1 = item.isLogin === '0' ? '否' : item.isLogin === '1' ? '是' : ''
            item.isAlarm1 = item.isAlarm === '0' ? '否' : item.isAlarm === '1' ? '是' : ''
            item.isRare1 = item.isRare === '0' ? '否' : item.isRare === '1' ? '是' : ''
            item.isTest1 = item.isTest === '0' ? '否' : item.isTest === '1' ? '是' : ''
            item.isRefer1 = item.isRefer === '0' ? '否' : item.isRefer === '1' ? '是' : ''
          })
          this.page.totalPage = res.data.total;
          if (this.table.list.length > 0) {
            this.$refs.dataTable.setCurrentRow(this.table.list[0])
            this.searchAnalysis(this.table.list[0])
          }
        }else{
          this.$message.error(res.message)
        }
        this.dataLoading = false;
      }).catch(e => {
        this.dataLoading = false;
        this.$message.error(e.message)
      });
    },
    //默认选中测试任务第一条数据，并查询分析项目数据
    searchAnalysis(val) {
      this.saveAnalyData = val
      this.taskNoD = val.taskNoD;
      if (!this.taskNoD) {
        return
      }
      this.getDataList2 (this.taskNoD);
    },
    //查询分析项目数据
    getDataList2 (taskNoD) {
      this.saveAnalysis = {}
      this.dataLoading2 = true
      let obj = {
        object:{taskNoD:taskNoD,indexNo:this.indexNo, isReport:0,isAlarm:0},
        pageIndex:this.page2.pageNum,
        pageSize:this.page2.pageSize
      }
      this.axios.post('pass/baseManagement/v1/limsstdindexds/queryLimsStdIndexDPage',obj,{individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.list2 = res.data.list;
          this.page2.totalPage = res.data.total;
          this.table.list2.forEach(item =>{
            item.validFlag1 = item.validFlag == 0 ? '无效' : item.validFlag == 1 ? '有效' : ''
            item.isCompute1 = item.isCompute == 0 ? '否' : item.isCompute == 1 ? '是' : ''
            item.isMid1 = item.isMid == 0 ? '否' : item.isMid == 1 ? '是' : ''
            item.isReport1 = item.isReport == 0 ? '否' : item.isReport == 1 ? '是' : ''
            item.isLogin1 = item.isLogin == 0 ? '否' : item.isLogin == 1 ? '是' : ''
            item.isAlarm1 = item.isAlarm == 0 ? '否' : item.isAlarm == 1 ? '是' : ''
            item.isRare1 = item.isRare == 0 ? '否' : item.isRare == 1 ? '是' : ''
          })
        }else{
          this.$message.error(res.message)
        }
        this.dataLoading2= false
      }).catch(e => {
        this.dataLoading2 = false;
        this.$message.error(e.message)
      });
    },
    //点击选中分析项目
    clickAnalysis(val){
      this.saveAnalysis = val
    },
    pageSizeChange4 (size) {
      this.page4.pageNum = 1
      this.page4.pageSize = size;
      this.getDataList4();
    },
    pageCurrentChange4 (index) {
      this.page4.pageNum = index;
      this.getDataList4();
    },
    pageSizeChange (size) {
      this.page.pageNum = 1
      this.page.pageSize = size;
      this.getDataList(this.indexNo);
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.getDataList(this.indexNo);
    },
    pageSizeChange2 (size) {
      this.page2.pageNum = 1
      this.page2.pageSize = size;
      this.getDataList2(this.taskNoD);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.getDataList2(this.taskNoD);
    },
    tableRowClassName ({row, column, rowIndex, columnIndex}) {
      if (row.validFlag !== '1') {
        return 'error-row';
      }
      return '';
    },
    tableRowClassName2 ({row, column, rowIndex, columnIndex}) {
      if (row.validFlag !== '1') {
        return 'error-row';
      }
      return '';
    },
    tableRowClassName3 ({row, column, rowIndex, columnIndex}) {
      if (row.validFlag !== '1') {
        return 'error-row';
      }
      return '';
    },
    tableRowClassName4 ({row, column, rowIndex, columnIndex}) {
      if (row.validFlag !== '1') {
        return 'error-row';
      }
      return '';
    },
    tableHeaderCellStyle () {
      return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
    }
  }
}
</script>
<style  scoped>
</style>
