 <template>
  <div class="examination">
    <div class="common-head-search">
        <el-form :inline='true'>
          <el-form-item label='物料名称'>
            <el-input v-model="search.matName" @keyup.enter.native="searchData()" size="small" placeholder="请输入查询内容" style="width: 200px;margin-right: 10px;"></el-input>
          </el-form-item>
          <el-form-item prop='ruleTypeCode' label="规则类型">
            <el-select v-model="search.ruleTypeCode" clearable @clear='clearType' filterable @change="filterData" collapse-tags size="small">
              <el-option v-for="item in ruleTypeNameType" :key="item.baseCode" :label="item.baseName" :value="item.baseCode">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop='ruleNo' label="规则名称" size="normal">
            <el-select v-model="search.ruleNo" filterable clearable collapse-tags size="small">
              <el-option v-for="item in ruleTypeName" :key="item.ruleNo" :label="item.ruleName" :value="item.ruleNo">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label='抽签日期'>
            <el-date-picker
             v-model="search.entrTime"
             type="daterange"
             range-separator="至"
             start-placeholder="开始日期"
             end-placeholder="结束日期"
             size="small"
             format="yyyy-MM-dd"
             value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="goon" size="mini" @click="searchData">查询</el-button>
            <el-button icon="el-icon-refresh" type="info" plain size="mini" @click="reset">重置</el-button>
          </el-form-item>
        </el-form>
    </div>
    <el-row>
      <el-col :span="9">
        <div class="common-title-div" style="height:auto">
          <div class="common-title-name" style="margin-right:10px">
            <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />
            抽签参数
          </div>
          <div>
            <el-button icon="el-icon-check" type="goon" :loading='drawDataLoading' size="mini" @click="drawData">抽签</el-button> 
          </div>
        </div>
        <div>
          <el-form label-width='60px' :inline="true">
          
            <el-form-item prop='ruleTypeCode' label="规则类型" >
              <el-select v-model="draw.ruleTypeCode" style="width:150px" clearable @clear='clearType' filterable @change="filterLeftData" collapse-tags size="small" >
                <el-option v-for="item in ruleTypeNameType" :key="item.baseCode" :label="item.baseName" :value="item.baseCode">
                </el-option>
              </el-select>
            </el-form-item>

            <el-form-item prop='ruleNo' label="规则名称" size="normal">
              <el-select v-model="draw.ruleNo" filterable clearable collapse-tags size="small" @change="searchLeftMainData" style="width:150px">
                <el-option v-for="item in draw.ruleTypeName" :key="item.ruleNo" :label="item.ruleName" :value="item.ruleNo">
                </el-option>
              </el-select>
            </el-form-item>

            <el-form-item prop="matClassNo" label="物料类型">
              <el-select v-model="draw.matClassNo" @change="selctMatName" clearable style="width: 150px" filterable collapse-tags size="small">
                <el-option
                  v-for="item in draw.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="draw.matNo" clearable style="width: 150px" filterable collapse-tags size="small">
                <el-option
                  v-for="(item, index) in draw.matNameType"
                  :key="index"
                  :label="item.matName"
                  :value="item.matNo"
                >
                </el-option>
              </el-select>
            </el-form-item>
            

            <el-form-item label='单位' prop="company">
              <el-select v-model="draw.company" clearable style="width: 150px" filterable collapse-tags size="small">
                <el-option
                  v-for="item in companyType"
                  :key="item.merchNo"
                  :label="item.merchName"
                  :value="item.merchNo"
                >
                </el-option>
              </el-select>
            </el-form-item>


            <!--<el-form-item label='物料' prop="matNameNo">
              <el-select v-model="draw.matNameNo" clearable style="width: 150px" filterable collapse-tags size="small">
                <el-option
                  v-for="(item, index) in matNameType"
                  :key="index"
                  :label="item.matName"
                  :value="item.matNo"
                >
                </el-option>
              </el-select>
            </el-form-item>-->

            <el-form-item label='抽签日期' prop="createTime">
              <el-date-picker v-model="draw.createTime"  type="date" style="width:150px" size="small" placeholder="请选择排班日期" value-format="yyyy-MM-dd"></el-date-picker>
            </el-form-item>
          </el-form>
        </div>
        <div class="common-table-div" style="margin-top:0">
           <el-table v-loading="allDataLoading" @selection-change='clickRowData' border :height="theight1" highlight-current-row :data="table.data" :icore-filter-flag="icoreFilterFlag"
           :header-cell-style="tableHeaderCellStyle" :summary-method="getSummaries" show-summary>
            <el-table-column type="index" label="NO" align="center"></el-table-column>
            <el-table-column :show-overflow-tooltip="true" sortable min-width="140px" prop="ruleItemName" label="参数项目" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true"  min-width="160px" prop="ruleItemValue" label="参数值" align="center">
              <template slot-scope="{row}">
                <el-input v-model="row.ruleItemValue" oninput ="value=value.replace(/[^0-9.]/g,'')" style="width:100%" size="mini"></el-input>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-col>
      <el-col :span="15">
        <div class="common-title-div" style="height:auto">
          <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 v-loading="dataLoading" ref="dataTable" border :height="theight2" highlight-current-row @selection-change="handleSelectionChange" :data="table.list" :icore-filter-flag="icoreFilterFlag"
           :header-cell-style="tableHeaderCellStyle" :row-class-name="tableRowClassName" :summary-method="getSummaries" show-summary :row-key="getRowKeys"
            @expand-change="expandChange">
            <el-table-column type="expand">
              <template slot-scope="{row}">
                <el-table  ref="dataTable3" border  highlight-current-row :data="row.data"
                 :header-cell-style="tableHeaderCellStyle" :cell-class-name="tableRowClassName2">
                 <el-table-column type="index" label="NO" align="center">
                 </el-table-column>
                 <el-table-column :show-overflow-tooltip="true" min-width="140px" prop="ruleItemName" label="项目名称" align="center"></el-table-column>
                 <el-table-column :show-overflow-tooltip="true" min-width="150px" prop="ruleItemValue" label="输入值" align="center"></el-table-column>
                 </el-table>
              </template>
            </el-table-column>
            <el-table-column type="index" label="NO" align="center">
            </el-table-column>
            <el-table-column type="selection" width="55" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="ruleDate" label="抽签日期" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="ruleName" label="抽签名称" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="ruleTypeName" label="规则类型" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="suppName" label="供货单位" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="matName" label="物料" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="carNo" label="车号" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="ruleResult" label="抽签结果" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="createMan" label="创建人" align="center"></el-table-column>
             <el-table-column sortable :show-overflow-tooltip="true" min-width="140px" prop="unloadPlace" label="卸货地点" align="center"></el-table-column>
          </el-table>
        </div>
      </el-col>
    </el-row>
  </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);
import { ajaxCtx } from '@/config/config.js';
import JsBarcode from 'jsbarcode'
export default {
  data () {
    return {
      table: {
        list: [],
        list2: [],
        data:[],
        subList:[]
      },
      list: [],
      companyType:[],
      draw:{
        ruleTypeCode: '',
        ruleNo: '',
        createTime:'',
        matClassNameType: '',  // 物料类型
        matClassName: '',// 物料类型
        matClassNo: '', // 物料类型
        matNameType: '',  //物料名称
        matName:'',  // 物料名称
        matNo: '',  //物料名称
        company:'',
        ruleTypeName: []
      },
      getRowKeys (row) {
        return row.id
      },
      // matNameType:[],
      sample:{
        tableData1:[],
        tableData2:[]
      },
      printLoading:false,
      printTest:false,
      subTableData:[],
      saveAccount:{},
      ruleDatas:[],
      ruleTypeName:[],
      rules:{
        createTime: [{ required: true, message: '不能为空', trigger: 'blur' }],
        matNameNo: [{ required: true, message: '不能为空', trigger: 'change' }],
        company: [{ required: true, message: '不能为空', trigger: 'change' }],
      },
      tabClickIndex: null,
      showButton:true,
      allDataLoading:false,
      accountLoading:false,
      saveLoading:false,
      saveDataLoading:false,
      subLoading:false,
      backLoading:false,
      dataLoading: false,
      dataLoading2: false,
      icoreFilterFlag: true,
      dialogTableVisible:false,
      imgPreViews:'',
      imgVisible:false,
      leftPage: {
        pageSize: 200,
        pageNum: 1,
        totalPage: 0
      },
      subPage: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      page: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      ruleDatas:[],
      drawDataLoading:false,
      addLoading:false,
      ruleTableData:[],
      classifyLoading:false,
      chooseRow:{},
      saveRow:{},
      allData:[],
      scId: '',
      ruleTypeNameType:[],
      multipleSelection3: [],
      theight1:0,
      theight2:0,
      theight3:0,
      search: {
        entrTime: '',
        matName: '',
        ruleTypeCode:'',
        ruleNo:''
      },
      uploadFile:{},
      savePlanData:{},
      saveSubRow:{},
      action_prod:window.location.protocol + '//' + window.location.host,
      activeName: 'first',
      activeMenu:'',
      allRuleData:[]
    }
  },
  created(){
    this.theight2 = window.innerHeight - 140
    this.theight1 = window.innerHeight - 170
    this.draw.createTime = this.getYNM(new Date())
    this.search.entrTime = [this.getYNM(new Date()), this.getYNM(new Date())]
    this.activeMenu = window.top.localStorage.getItem('activeMenu')
  },
  mounted () {
    this.axios.post("pass/baseManagement/v1/limsbaseinfos/queryBaseInfoByBaseCode",{validFlag:1,baseCode:4838}, {individualType: 'json'}).then(res => {
      this.ruleTypeNameType = res.data;
    }) 
    this.axios.get("pass/baseManagement/v1/limsmerchantsinfos/like/?pageNum=1&pageSize=9999&validFlag=1", {individualType: 'json'}).then(res => {
      this.companyType = res.data.list;
    })
    // this.axios.post("pass/baseManagement/v1/limsbasematerialss/queryLimsBaseMaterialsPage",{object:{validFlag:1,matClassNo: "S008"},pageIndex: 1,pageSize: 99999}, {individualType: 'json'}).then(res => {
    //   this.matNameType = res.data.list;
    // })
    this.axios.post('pass/baseManagement/v1/limsbaserules/queryLimsBaseRuleInfoPage',{"object":{id:"R0020",validFlag:1},pageIndex:1,pageSize:9999}, {individualType: 'json'}).then(res => {
        if (res.code == 0 ||res.code == 200) {
          this.ruleDatas = res.data.list
        } else {
         this.$message.error(res.message)
        }
        this.saveLoading = false
      })
    this.ruleData()
    this.searchData()
    // this.addScreen();
    // this.addScreen2()

    //获取物料类型
    this.axios.get("pass/baseManagement/v1/limsbasematerialsclasss/" + "?validFlag=1").then((res) => {
        this.draw.matClassNameType = res.data.list;
    });
  },
  methods: {
    //获取物料名称
    selctMatName(val) {
      this.draw.matNameType = [];
      this.draw.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.draw.matNameType = res.data.list;
      });
    },
    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;   
    },
    clearType(){
      this.search.ruleNo = ''
      this.ruleTypeName = this.allRuleData
    },
    filterData(val){
      this.ruleTypeName = []
      this.search.ruleNo = ''
      if(!val){
        this.ruleTypeName = this.allRuleData
        return
      }
      this.allRuleData.map(item=>{
        if (item.ruleTypeCode == val) {
          this.ruleTypeName.push(item)
        }
      })
    },
    filterLeftData(val){
      this.draw.ruleTypeName = []
      this.draw.ruleNo = ''
      if(!val){
        this.draw.ruleTypeName = this.allRuleData
        return
      }
      this.allRuleData.map(item=>{
        if (item.ruleTypeCode == val) {
          this.draw.ruleTypeName.push(item)
          this.ruleDatas.push(item)
        }
      })
    },
    ruleData () {
      this.allRuleData = []
      this.ruleTypeName = []
      let obj = {
        object:{
          ruleTypeCode:'',
          validFlag:1
        },
        pageIndex:1,
        pageSize:9999,
      }
      this.axios.post('pass/baseManagement/v1/limsbaserules/queryLimsBaseRuleInfoPage',obj, {individualType: 'json'}).then(res => {
        if (res.code == 0 ||res.code == 200) {
          let data  = res.data.list
          data.forEach(item =>{
            item.validFlag1 = item.validFlag == 0 ? '无效' : item.validFlag == 1 ? '有效' : ''
          })
          this.ruleTypeName = this.allRuleData = data
        } else {
         this.$message.error(res.message)
        }
        this.saveLoading = false
      }).catch(e => {
        this.saveLoading = false
        this.$message.error(e.message)
      })
    },
    searchLeftMainData(){
      this.allDataLoading = true;
      let obj = {
        ruleNo: this.draw.ruleNo,
        validFlag:1
      }
      this.axios.post('pass/baseManagement/v1/limsbaseruleds/queryLimsBaseRuleDList/', obj,{individualType: 'json'}).then(res => {
        this.allDataLoading = false;
        if (res.code == 0 || res.code == 200) {
          let data = res.data;
          let tempArr = []
          data.forEach(item =>{
            if (item.isPara == 1) {
              tempArr.push(item)
            }
          })
          this.table.data = tempArr
        }else{
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.allDataLoading = false;
        this.$message.error(e.message)
      })
      
    },
    expandChange(row, expandedRows) {
      this.dataLoading2 = true
      this.Params2 = row
      this.axios.post('pass/testManagement/v1/limsdataruleds/queryLimsDataRuleDByRuleId?ruleId='+row.ruleId,{individualType: "json"}).then(res => {
        this.dataLoading2 = false
        let data = res.data;
        data.forEach((item,index) =>{
          item.validFlag1 = item.validFlag === '0' ? '无效' : item.validFlag === '1' ? '有效' : ''
        })
        this.$set(row, 'data', data)
      }).catch(e => {
        this.dataLoading2 = false
      });
    },
    getCode (code, arr, codeKey, nameKey) {
        if (!code) {
          return '';
        }
        let targetRow = arr.find(item => {
          return item[codeKey] === code;
        });
        return targetRow ? targetRow[nameKey] : '';
    },
    drawData(){
      if (!this.draw.ruleTypeCode) {
        this.$message.warning('抽签规则类型不能为空')
        return
      }
      if (!this.draw.ruleNo) {
        this.$message.warning('抽签规则名称不能为空')
        return
      }
      // if (!this.draw.company) {
      //   this.$message.warning('抽签单位不能为空')
      //   return
      // }
      if (!this.draw.createTime) {
        this.$message.warning('抽签日期不能为空')
        return
      }
      if (!this.draw.matClassNo) {
        this.$message.warning('抽签物料类型不能为空')
        return
      }
      if (!this.draw.matNo) {
        this.$message.warning('抽签物料名称不能为空')
        return
      }
      
      this.drawDataLoading = true
      let obj = {
        limsDataRuleDs:this.table.data,
        ruleDate:this.draw.createTime,
        suppNo:this.draw.company,
        suppName:this.getCode(this.draw.company,this.companyType,'merchNo','merchName'),
        matNo:this.draw.matNo,
        matName:this.getCode(this.draw.matNo,this.draw.matNameType,'matNo','matName'),
        callApi: this.getCode(this.draw.ruleNo,this.ruleDatas,'ruleNo','callApi'),
        memo: this.getCode(this.draw.ruleNo,this.ruleDatas,'ruleNo','memo'),
        ruleDesc: this.getCode(this.draw.ruleNo,this.ruleDatas,'ruleNo','ruleDesc'),
        ruleTypeCode: this.draw.ruleTypeCode,
        ruleTypeName: this.getCode(this.draw.ruleTypeCode,this.ruleTypeNameType,'baseCode','baseName'),
        ruleNo: this.draw.ruleNo,
        ruleName: this.getCode(this.draw.ruleNo,this.ruleTypeName,'ruleNo','ruleName')
        // matNo:this.draw.matNameNo,
        // matName:this.getCode(this.draw.matNameNo,this.matNameType,'matNo','matName'),
        // callApi: this.ruleDatas[0].callApi,
        // memo: this.ruleDatas[0].memo,
        // ruleDesc: this.ruleDatas[0].ruleDesc,
        // ruleName: this.ruleDatas[0].ruleName,
        // ruleNo: this.draw.ruleNo,
        // ruleTypeCode: this.draw.ruleTypeCode,
        // ruleNo: this.ruleDatas[0].ruleNo,
        // ruleTypeCode: this.ruleDatas[0].ruleTypeCode,
        // ruleTypeName: this.ruleDatas[0].ruleTypeName,
      }
      this.axios.post('pass/testManagement/v1/limsdatarules/saveLimsDataRuleAndRuleD',obj,{individualType: 'json'}).then(res => {
        this.drawDataLoading = false;
        if (res.code == 0 || res.code == 200) {
          this.$message.success(res.message)
          this.searchData()
        }else{
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.drawDataLoading = false;
        this.$message.error(e.message)
      })
    },
    showCell(row){
      this.tabClickIndex = row.index
    },
    saveCell(row){
      this.tabClickIndex = null
    },
    tableRowName({row, rowIndex}){
      row.index = rowIndex
    },
    //查询
    searchData(){
      this.page.pageNum = 1;
      this.page.pageSize = 50
      this.subPage.pageNum = 1
      this.subPage.pageSize = 50
      this.leftPage.pageNum = 1
      this.leftPage.pageSize = 200
      this.mainData()
      //this.leftMainData()
    },
    //点击选中数据
    clickRowData(val){
      this.allData = val
    },
    // leftMainData () {
    //   this.allDataLoading = true;
    //   let obj = {
    //     ruleNo: this.search.ruleNo,
    //     validFlag:1
    //   }
    //   this.axios.post('pass/baseManagement/v1/limsbaseruleds/queryLimsBaseRuleDList/', obj,{individualType: 'json'}).then(res => {
    //     this.allDataLoading = false;
    //     if (res.code == 0 || res.code == 200) {
    //       let data = res.data;
    //       let tempArr = []
    //       data.forEach(item =>{
    //         if (item.isPara == 1) {
    //           tempArr.push(item)
    //         }
    //       })
    //       this.table.data = tempArr
    //     }else{
    //       this.$message.error(res.message)
    //     }
    //   }).catch(e => {
    //     this.allDataLoading = false;
    //     this.$message.error(e.message)
    //   })
    // },
    mainData () {
      this.saveRow = {}
      this.table.list2 = []
      this.dataLoading = true;
      let startTime = ''
      let endTime = ''
      if (!this.search.entrTime) {
         startTime = ''
         endTime = ''
      }else{
        startTime = this.search.entrTime[0] + ' 00:00:00'
        endTime = this.search.entrTime[1] + ' 23:59:59'
      }
      let obj = {
        "object":{
          "matName":this.search.matName,
          'ruleNo':this.search.ruleNo,
          'ruleTypeCode':this.search.ruleTypeCode,
        },
        'startTime': startTime,
        'endTime': endTime,
        'pageIndex': 1,
        'pageSize': 9999,
      }
      this.axios.post('pass/testManagement/v1/limsdatarules/queryLimsDataRulePage/',obj,{individualType: 'json'}).then(res => {
        this.dataLoading = false;
        if (res.code == 0 || res.code == 200) {
          this.table.list = res.data.list;
          this.table.list.forEach(item =>{
            item.stateFlag1 = item.stateFlag === '-1' ? '未处理' : item.stateFlag === '0' ? '已处理' : item.stateFlag === '1' ? '提交' : ''
            item.validFlagName = item.validFlag === '0' ? '无效' : item.validFlag === '1' ? '有效' : ''
            item.entrTime1 = formatDate(item.entrTime, 'yyyy-MM-dd')
          })
          this.page.totalPage = res.data.total;
        }else{
          this.$message.error(res.message)
        }
      }).catch(e => {
        this.dataLoading = false;
        this.$message.error(e.message)
      });
    },
    reset () {
      this.search.matName = '';
      this.search.entrTime = [this.getYNM(new Date()), this.getYNM(new Date())]
      this.searchData();
    },
    handleSelectionChange (val) {
      this.multipleSelection3 = val;
    },
    leftPageSize(size){
      this.leftPage.pageNum = 1
      this.leftPage.pageSize = size;
      // this.leftMainData()
    },
    leftPageCurrent (index) {
      this.leftPage.pageNum = index;
      // this.leftMainData()
    },
    pageSizeChange (size) {
      this.page.pageNum = 1
      this.page.pageSize = size;
      this.mainData();
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.mainData();
    },
    subPageSizeChange (size) {
      this.subPage.pageNum = 1
      this.subPage.pageSize = size;
      this.subData();
    },
    subPageCurrentChange (index) {
      this.subPage.pageNum = index;
      this.subData();
    },
    pageSizeChange2 (size) {
      this.page2.pageNum = 1
      this.page2.pageSize = size;
      this.depData(this.scId);
    },
    pageCurrentChange2 (index) {
      this.page2.pageNum = index;
      this.depData(this.scId);
    },
    addScreen () {
      this.$nextTick(() => {
          let ss = document.createElement('div');
          ss.innerHTML = '筛选';
          ss.style = 'text-align: center;'
          this.$refs.dataTable.$el.getElementsByClassName('el-table__fixed')[0].getElementsByTagName('td')[0].appendChild(ss);
       });
    },
    addScreen2 () {
     this.$nextTick(() => {
          let ss = document.createElement('div');
          ss.innerHTML = '筛选';
          ss.style = 'text-align: center;'
          this.$refs.dataTable2.$el.getElementsByClassName('el-table__fixed')[0].getElementsByTagName('td')[0].appendChild(ss);
       });
    },
    downloadFile (index, objId, objFileName, oldFileName, objType) {
      let obj = {
        objId: objId,
        objName: objType,
        fileName: objFileName//文件新名字
      }
      let fileRow = {}
      this.axios.post('pass/testManagement/v1/limslrcfilesaves/queryListLrcFileSave', obj, {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          fileRow = res.data[res.data.length -1]
          this.axios.get('pass/testManagement/v1/file/download/'+ fileRow.fileName ,{responseType: 'blob'},{headers: {'content-type': 'application/x-www-form-urlencoded'}}).then(res => {
            let blob = new Blob([res]);
            let fileName = oldFileName;
            let elink = document.createElement('a');
            elink.download = fileName;
            elink.style.display = 'none';
            elink.target = "_blank";
            elink.href = URL.createObjectURL(blob);
            document.body.appendChild(elink);
            elink.click();
            URL.revokeObjectURL(elink.href); // 释放URL对象
            document.body.removeChild(elink);
        })  
          // this.download(this.action_prod + fileRow.fileUrl, 'download.txt', 'text/plain', fileRow.oldFileName);
        } else {
          this.$message.error(res.message)
        }
      }).catch(err =>{
        this.$message.error(err.message)
      })
    },
    imgPreView (index,objId, objFileName, objType) {
       let obj = {
        objId: objId,
        objName: objType,
        fileName: objFileName
      }
      let fileRow = {}
      this.axios.post('pass/testManagement/v1/limslrcfilesaves/queryListLrcFileSave', obj, {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          console.log(this.action_prod,'this.action_prod');
          fileRow = res.data[res.data.length -1]
          this.imgPreViews = ''
          this.imgPreViews = this.action_prod +'/icore.icp.web/pass/testManagement/v1/file/download/' + fileRow.fileName
          this.imgVisible = true
          // var form = $('<form>'); // 定义一个form表单
          // form.attr('id', 'downloadform');
          // form.attr('style', 'display:none');
          // form.attr('target', '_blank');
          // form.attr('method', 'get');
          // form.attr('action', this.action_prod +'/icore.icp.web/pass/testManagement/v1/file/download/' + fileRow.fileName);
          // var input1 = $('<input>');
          // input1.attr('type', 'hidden');
          // form.append(input1);
          // $('body').append(form); // 将表单放置在web中
          // form.submit(); // 表单提交
          // $('#downloadform').remove();
        }else{
          this.$message.error(res.message)
        }
      }).catch(err =>{
        this.$message.error(err.message)
      })
      },
   tableRowClassName ({
        row, column, rowIndex, columnIndex
      }) {
        if (columnIndex === 8) {
        if (row.validFlag !== '1') {
          return 'error-row';
        }
        }
        if (columnIndex === 1) {
        if (row.stateFlag === '1') {
          return 'error-green';
        }
        return '';
        }
      },
    tableRowClassName2 ({
        row, column, rowIndex, columnIndex
      }) {
        if (columnIndex === 5) {
        if (row.validFlag !== '1') {
          return 'error-row';
        }
        return '';
        }
      },
    tableHeaderCellStyle () {
      return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
    }
  }
}
</script>
<style  scoped>
  .el-dialog__wrapper .el-dialog .el-dialog__header{
    height: 56px;
    background: rgb(64,158,255);
    border-radius: 4px 4px 0 0;
    color: #fff;
    padding: 14px 24px!important;
  }
</style>
