<template>
  <div class="examination">
    <div class="common-head-search">
      <el-form :inline='true'>
        <el-form-item label="证书名称">
          <el-select v-model="search.cretNo" clearable filterable collapse-tags size="small" @change='selectItem' style="width:200px;margin-right: 10px;" placeholder="请选择查询内容">
            <el-option v-for="(item,index) in cretNameType" :key="index" :label="item.cretName"
              :value="item.cretNo">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="证书项目">
          <el-select v-model="search.cretItemName" clearable filterable collapse-tags size="small" style="width:200px;margin-right: 10px;" placeholder="请选择查询内容">
            <el-option v-for="(item,index) in cretItemNameType" :key="index" :label="item.cretItemName"
              :value="item.cretItemName">
            </el-option>
          </el-select>
        </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>
        <div class="common-title-div">
          <div class="common-title-name">
            <img style="width: 25px; height: 25px" src='../../../../assets/img/imgScreen/logo.png' />
            证书项目配置表
          </div>
          <div>
            <el-button icon="el-icon-remove-outline" type="danger" :loading='stopLoading' size="mini" @click="deleteData">停用</el-button>
            <el-button icon="el-icon-check" type="goon" size="mini" :loading='startLoading' @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="theight1" highlight-current-row @selection-change="handleSelectionChange" 
           @row-click="savaRowBig" :data="table.list" :icore-filter-flag="icoreFilterFlag"
          :header-cell-style="tableHeaderCellStyle" :cell-class-name="tableRowClassName" :summary-method="getSummaries" show-summary>
            <el-table-column type="index" label="NO" fixed="left" align="center"></el-table-column>
            <el-table-column type="selection" width="55" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="90px" prop="validFlag1" label="数据状态" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="cretNoM" label="证书项号" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" prop="cretName" label="证书名称" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="cretItemName" label="证书项目" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="strRowStd" label="标准数据起始行" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="strColStd" label="标准数据起始列" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="strRowD" label="检验数据起始行" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="strColD" label="检验数据起始列" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="rowStep" label="行步长" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="colStep" label="列步长" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="dataTypeName" 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="140px" prop="cretImg1" label="图片" align="center">
            <template slot-scope="scope">
                 <span>{{scope.row.cretImg1}}</span>
               </template>
            </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="100px" label="下载、预览" align="center">
               <template slot-scope="scope">
                 <el-tooltip content="下载文件" placement="bottom" effect="light">
                 <el-button
                 :disabled='!scope.row.cretImg1'
                  type="goon" size="mini" icon="el-icon-download" circle
                  @click="downloadFile(scope.$index, scope.row.cretNoM, scope.row.cretImg.fileName,  scope.row.cretImg.oldFileName, 'LIMS_CRET_TMP_M')">
                </el-button>
                 </el-tooltip>
                <el-tooltip content="预览照片" placement="bottom" effect="light">
                 <el-button
                 :disabled='!scope.row.cretImg1'
                  type="warning" size="mini" icon="el-icon-view" circle
                  @click="imgPreView(scope.$index, scope.row.cretNoM, scope.row.cretImg.fileName, 'LIMS_CRET_TMP_M')">
                </el-button>
                </el-tooltip>
               </template>
             </el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="memo" 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-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="80px" 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>
        </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 :span='24'>
        <div class="common-title-div">
          <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-circle-plus-outline" type="goon" size="mini" @click="addData3">新增</el-button>
            <el-button icon="el-icon-remove-outline" type="danger" :loading='smallStopLoading' size="mini" @click="deleteData3">删除</el-button>
          </div>
        </div>
        <div class="common-table-div" style="margin-bottom:0;margin-top:0">
          <el-table v-loading="dataLoading3" ref="dataTable3" border :height="theight2" highlight-current-row @selection-change="clickRowDep" :data="table.list3" :icore-filter-flag="icoreFilterFlag"
          :header-cell-style="tableHeaderCellStyle" :cell-class-name="tableRowClassName3" :summary-method="getSummaries" show-summary>
            <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="cretNoM" 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="80px" prop="dataTypeName" label="数据类型" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="defaultValue" label="默认值" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="120px" prop="reviseRuleName" label="修约规则" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="dspOrder" label="显示顺序" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="validFlag1" label="数据状态" align="center"></el-table-column>
            <el-table-column sortable :show-overflow-tooltip="true" min-width="80px" prop="memo" 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-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="80px" 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>
        </div>
        <!-- <div class="common-foot-style">
          <el-pagination v-loading="dataLoading3" @size-change="pageSizeChange3" @current-change="pageCurrentChange3"
          :current-page="page3.pageNum" :page-sizes="[10, 20, 50, 100, 200]" :page-size="page3.pageSize" layout="total, sizes, prev, pager, next, jumper"
          :total="page3.totalPage" background>
        </el-pagination>
        </div>  -->
      </el-col>
    </el-row>
    <el-dialog :close-on-click-modal='false' @close="testCancel" width='80%' :visible.sync="testShow" customClass="boxWidth33">
        <div slot="title" class="titleBox">
        <i class='el-icon-document' style="font-size: 20px"></i>
        <span style="margin-left:10px;font-size:18px">证书小项配置表</span>
        </div>
        <el-row>
          <el-col :span='12'>
            <div>
                <div class="common-title-name">
                    <img style="width: 25px; height: 25px; margin-left: 20px" src='../../../../assets/img/imgScreen/logo.png' />
                     分析项目
                    <el-input v-model="testItemName2" size="small" placeholder="请输入查询内容" @keyup.enter.native="getDataLists2()" style="width: 150px"></el-input>
                </div>
                <div class="common-table-div">
                     <el-table v-loading="taskDataLoading" ref="dataTable" border :height="heightTop" highlight-current-row :data="table.listTests"
                     :header-cell-style="tableHeaderCellStyle" :icore-filter-flag="icoreFilterFlag">
                      <el-table-column type="index" label="NO" align="center"></el-table-column>
                      <el-table-column label="操作" width="50">
                          <template slot-scope="{row}">
                              <el-button type="text" style="padding:0"  @click="rightData2(row)">右移</el-button>
                          </template>
                      </el-table-column>
                      <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="anlyItemName" label="分析项目名称" align="center"></el-table-column>
                      <el-table-column min-width="120px" :show-overflow-tooltip="true" sortable prop="reviseRuleName" label="修约规则" align="center"></el-table-column>
                     </el-table>
                </div>
                <div style="margin-top: 20px; margin-left: 10px">
                    <el-pagination  @size-change="SizeTest" @current-change="pageChangeTest"
                      :current-page="pageTests.pageNum" :page-sizes="[10, 20, 50, 100, 200]" :page-size="pageTests.pageSize" layout="total, sizes, prev, pager, next"
                      :total="pageTests.totalPage" background>
                    </el-pagination>
                </div>
            </div>
          </el-col>
          <el-col :span='12'>
            <div>
                <div class="common-title-name">
                  <img style="width: 25px; height: 25px; margin-left: 20px" src='../../../../assets/img/imgScreen/logo.png' />
                    选择任务
                </div>
                <div class="common-table-div">
                     <el-table v-loading="dataLoading2" ref="dataTable2" border :height="heightTop" :data="table.addTest"
                     :header-cell-style="tableHeaderCellStyle">
                      <el-table-column type="index" label="NO" align="center"></el-table-column>
                      <el-table-column label="操作" width="120px">
                        <template slot-scope="scope">
                          <el-button type="text" style="padding:0" :disabled="scope.$index == 0" @click="moveUpward(scope.row, scope.$index)">上移</el-button>
                          <el-button type="text" style="padding:0" :disabled="(scope.$index + 1) == table.addTest.length" @click="moveDown(scope.row, scope.$index)">下移</el-button>
                          <el-button type="text" style="padding:0"  @click="leftData2(scope.$index,scope.row)">删除</el-button>
                        </template>
                      </el-table-column>
                      <el-table-column min-width="120px"  :show-overflow-tooltip="true" prop="anlyItemName" label="分析项目名称" align="center"></el-table-column>
                      <el-table-column min-width="120px"  :show-overflow-tooltip="true" prop="reviseRuleName" label="修约规则" align="center"></el-table-column>
                     </el-table>
                </div>
            </div>
          </el-col>
        </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button type="goon" size="mini" icon="el-icon-check" :loading='addtestLoading' @click="addtestData()">确定</el-button>
        <el-button size="mini" type="goon" icon="el-icon-remove-outline" @click="testCancel">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  getCookie
} from '@/utils/util.js';
import {
  cookieUserId,
  cookieUserName
} from '@/config/config.js';
let userName = getCookie(cookieUserName);
let userId = getCookie(cookieUserId);
export default {
  data () {
    return {
      table: {
        list: [],
        list2: [],
        list3: [],
        listTest:[],
        listTests:[],
        addTest:[],
        analy:[]
      },
      testItemName2:'',
      testShow:false,
      dataLoading: false,
      dataLoading2: false,
      dataLoading3: false,
      stopLoading:false,
      startLoading:false,
      bigStopLoading:false,
      bigStartLoading:false,
      smallStopLoading:false,
      smallStartLoading:false,
      saveRowMain:{},
      saveBigData:{},
      icoreFilterFlag: true,
      page: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      page2: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      page3: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      pageTests: {
        pageSize: 50,
        pageNum: 1,
        totalPage: 0
      },
      cretNoM: '',
      testItemName: '',
      depData:[],
      cretItemNameType1: [],
      showFlag: false,
      Params: {},
      showFlag2: false,
      Params2: {},
      addtestLoading:false,
      cretItemNameType: [],
      multipleSelection3: [],
      multipleSelection4: [],
      multipleSelection5: [],
      taskDataLoading:false,
      search: {
        cretNo: '',
        cretItemName: ''
      },
      cretNameType:[],
      heightTop:0,
      theight1:0,
      theight2:0,
      action_prod: window.location.protocol + '//' + window.location.host,
    }
  },
  created(){
    this.theight1 = window.innerHeight / 2 - 130 < 249 ? 249 : window.innerHeight / 2 - 100;
    this.theight2 = window.innerHeight / 2 - 130 < 249 ? 249 : window.innerHeight / 2 - 100;
    this.heightTop = window.innerHeight/2 - 130 < 249 ? 249 : window.innerHeight/2 - 130
  },
  mounted () {
    this.axios.post('pass/baseManagement/v1/limscrettmps/queryLimsCretTmpList',{validFlag:1},{individualType: 'json'}).then(res => {
      this.cretNameType = res.data
     })
    this.searchData();
    this.getDataLists2()
    this.addScreen();
  },
  methods: {
    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;   
    },
    selectItem(val){
      this.cretItemNameType = []
      this.search.cretItemName = ''
      if (!val) {
        return
      }
      this.axios.post('pass/baseManagement/v1/limscrettmpms/querycretItemName',{cretNo:val,validFlag:1},{individualType: 'json'}).then(res => {
        this.cretItemNameType = res.data
      })
    },
    refresh () {
      this.getDataList();
    },
    refresh2 () {
      this.getDataList2 (this.saveRowMain.cretNoM)
    },
    refresh3 () {
      this.getDataList3 (this.saveBigData.cretNoM)
    },
    deleteData () {
      if (this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选您要停用的数据！')
      } else {
        for (var j= 0; j < this.multipleSelection3.length; j++) {
          if (this.multipleSelection3[j].validFlag === '0') {
          this.$message.warning('请勾选状态为已启用的数据！')  
          return 
          }
        }
        this.stopLoading = true
        this.axios.post('pass/baseManagement/v1/limscrettmpms/abolishrecover', this.multipleSelection3, {individualType: 'json'}).then(res => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.refresh()
          } else {
           this.$message.error(res.message)
          }
          this.stopLoading = false
        }).catch(e => {
          this.stopLoading = false
         this.$message.error(e.message)
       })
      }
    },
    recoverData () {
      if (this.multipleSelection3.length < 1) {
        this.$message.warning('请勾选您要启用的数据！')
      } else {
          for (var j= 0; j < this.multipleSelection3.length; j++) {
          if (this.multipleSelection3[j].validFlag === '1') {
          this.$message.warning('请勾选状态为已停用的数据！')  
          return 
          }
        }
        this.startLoading = true
        this.axios.post('pass/baseManagement/v1/limscrettmpms/abolishrecover', this.multipleSelection3, {individualType: 'json'}).then(res => {
          if (res.code == 0 || res.code == 200) {
            this.$message.success(res.message);
            this.refresh()
          } else {
           this.$message.error(res.message)
          }
          this.startLoading = false
        }).catch(e => {
          this.startLoading = false
         this.$message.error(e.message)
       })
      }
    },
    testCancel(){
      this.table.addTest = []
      this.addList = []
      this.testShow = false
      this.addtestLoading = false
    },
    //证书小项配置表新增数据
    addData3 () {
      if (JSON.stringify(this.saveBigData)==="{}") {
       this.$message.warning('请点击选中一条证书项目配置表数据')
       return
      }
      this.testShow = true
      this.table.addTest = JSON.parse(JSON.stringify(this.table.list3))
      this.Params = this.saveBigData
    },
    //新增确定操作
    addtestData(){
      if (this.table.addTest.length < 1) {
        this.$message.warning('请先移动数据到右边的表格中')
        return
      } 
      this.table.addTest.forEach(item =>{
        item.dspOrder = null
        item.cretNoM = this.saveBigData.cretNoM
      })
      this.addtestLoading = true
      this.axios.post('pass/baseManagement/v1/limscrettmpds/batchinsertlimscret', this.table.addTest, {individualType: 'json'}).then(res => {
        if (res.succeed) {
          this.$message.success("新增成功")
          this.getDataList3 (this.saveBigData.cretNoM)
          this.testCancel()
        } else {
         this.$message.error(res.message)
        }
        this.addtestLoading = false
      }).catch(e => {
        this.addtestLoading = false
        this.$message.error(e.message)
      })
    },
    //点击选中一条证书小项配置表数据
    clickRowDep (val) {
      this.depData = val;
    },
    //证书小项配置表删除
    deleteData3 () {
      if (this.depData.length < 1) {
        this.$message.warning('请勾选您要删除的数据')
        return
      }
      let tempArr = []
      this.depData.map(item=>{
        tempArr.push(item.id)
      })
      this.smallStopLoading = true
      this.axios.post('pass/baseManagement/v1/limscrettmpds/batchdeletelimscret', tempArr, {individualType: 'json'}).then(res => {
        if (res.code ==0 || res.code == 200) {
         this.$message.success(res.message);
         this.getDataList3 (this.saveBigData.cretNoM)
        } else {
         this.$message.error(res.message)
        }
        this.smallStopLoading = false
      }).catch(e => {
        this.smallStopLoading = false
       this.$message.error(e.message)
      })
    },
    searchData () {
      this.page.pageNum = 1;
      this.page.pageSize = 50
      this.getDataList()
    },
    reset () {
      this.search.cretNo = '';
      this.search.cretItemName = '';
      this.searchData();
    },
    //查询证书项目配置表
    getDataList () {
      this.saveBigData = {}
      this.table.list3 = []
      this.dataLoading = true;
      let obj = {
        object:{
          cretNo:this.search.cretNo,
          cretItemName:this.search.cretItemName
        },
        pageIndex:this.page.pageNum, 
        pageSize:this.page.pageSize
      }
      this.axios.post('pass/baseManagement/v1/limscrettmpms/queryLimsCretTmpMPage',obj,{individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.list = res.data.list;
          this.table.list.forEach(item =>{
            item.validFlag1 = item.validFlag == 0 ? '无效' : item.validFlag == 1 ? '有效' : ''
            item.isSon1 = item.isSon == 0 ? '否' : item.isSon == 1 ? '是' : ''
            item.isMerge1 = item.isMerge == 0 ? '否' : item.isMerge == 1 ? '是' : ''
            item.cretImg = JSON.parse(item.cretImg) 
            item.cretImg1 = item.cretImg.oldFileName ? item.cretImg.oldFileName : ''
          })
          if (this.table.list.length > 0) {
            this.$refs.dataTable.setCurrentRow(this.table.list[0])
            this.savaRowBig(this.table.list[0])
          }
          this.page.totalPage = res.data.total;
        }else{
          this.$message.error(res.message)
        }
        this.dataLoading = false;
      }).catch(e => {
        this.dataLoading = false;
        this.$message.error(e.message)
      });
    },
    savaRowBig (val) {
      this.saveBigData = val
      this.page3.pageNum = 1
      this.page3.pageSize = 50
      this.getDataList3 (this.saveBigData.cretNoM)
    },
    getDataList3 (cretNoM) {
      this.dataLoading3 = true;
      let values = cretNoM ? cretNoM : ''
      let obj = {
        'object':{
          cretNoM:values
        },
        pageIndex:this.page3.pageNum,
        pageSize:this.page3.pageSize
      }
      this.axios.post('pass/baseManagement/v1/limscrettmpds/queryLimsCretTmpDPage',obj,{individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          this.table.list3 = res.data.list;
          this.table.list3.forEach(item =>{
            item.validFlag1 = item.validFlag == 0 ? '无效' : item.validFlag == 1 ? '有效' : ''
          })
          this.page3.totalPage = res.data.total;
        }else{
          this.$message.error(res.message)
        }
        this.dataLoading3 = false; 
      }).catch(e => {
        this.dataLoading3 = false;
      });
    },
    getDataLists2() {
      this.pageTests.pageNum = 1
      this.getDataListTest2()
    },
    getDataListTest2 () {
      let obj = {
        object:{
          validFlag:1,
          anlyItemName:this.testItemName2
        },
        pageIndex:this.pageTests.pageNum,
        pageSize:this.pageTests.pageSize
      }
      this.taskDataLoading = true;
      this.axios.post('pass/baseManagement/v1/limsstdanlyitems/queryLimsStdAnlyItemPage',obj,{individualType: 'json'}).then(res => {
        this.taskDataLoading = false;
        this.table.listTests = res.data.list;
        this.pageTests.totalPage = res.data.total;
      }).catch(e => {
        this.taskDataLoading = false;
      });
    },
    handleSelectionChange (val) {
      this.multipleSelection3 = val;
    },
    pageSizeChange (size) {
      this.page.pageSize = size;
      this.getDataList();
    },
    pageCurrentChange (index) {
      this.page.pageNum = index;
      this.getDataList();
    },
    pageSizeChange3 (size) {
      this.page3.pageSize = size;
      this.getDataList3 (this.saveBigData.cretNoM)
    },
    pageCurrentChange3 (index) {
      this.page3.pageNum = index;
      this.getDataList3 (this.saveBigData.cretNoM)
    },
    //表格数据右移
    rightData2 (row) {
      //新增的数据清空id
      row.cretNoD = ''
      row.createMan = ''
      row.createNo = ''
      row.createTime = ''
      row.updateNo = ''
      row.updateMan = ''
      row.updateTime = ''
      this.table.addTest.push(row)
    },
    //删除表格数据
    leftData2 (index,row) { 
      if (row.cretNoD) {
         this.$message.warning('不可删除原有数据！')
         return false
      }
      this.table.addTest.splice(index, 1);
    },
    //上移
    moveUpward(row, index) {
      if (index > 0) {
          let upData = this.table.addTest[index - 1];
          this.table.addTest.splice(index - 1, 1);
          this.table.addTest.splice(index, 0, upData);
      } else {
        this.$message({message: '已经是第一条，上移失败',type: 'warning'});
      }
    },
    //下移
    moveDown(row, index) {
      if ((index + 1) == this.table.addTest.length) {
          this.$message({message: '已经是最后一条，下移失败',type: 'warning' });
      } else {
          let downData = this.table.addTest[index + 1];
          this.table.addTest.splice(index + 1, 1);
          this.table.addTest.splice(index, 0, downData);
      }
    },
    SizeTest (size) {
      this.pageTests.pageSize = size;
      this.getDataListTest2();
    },
    pageChangeTest (index) {
      this.pageTests.pageNum = index;
      this.getDataListTest2();
    },
    downloadFile (index, objId, objFileName, oldFileName, objType) {
      let obj = {
        objId: objId,
        objName: objType,
        fileName: objFileName//文件新名字
      }
      let fileRow = {}
      this.axios.post('pass/baseManagement/v1/limslrcfilesaves/queryListLrcFileSave', obj, {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          fileRow = res.data[0]
          this.axios.get('pass/baseManagement/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/baseManagement/v1/limslrcfilesaves/queryListLrcFileSave', obj, {individualType: 'json'}).then(res => {
        if (res.code == 0 || res.code == 200) {
          fileRow = res.data[0]
          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 + fileRow.fileUrl);
          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 === 2) {
      if (row.validFlag !== '1') {
        return 'error-row';
      }
      return '';
      }
    },
    tableRowClassName2 ({row, column, rowIndex, columnIndex}) {
      if (columnIndex === 6) {
      if (row.validFlag !== '1') {
        return 'error-row';
      }
      return '';
      }
    },
    tableRowClassName3 ({row, column, rowIndex, columnIndex}) {
      if (columnIndex === 9) {
      if (row.validFlag !== '1') {
        return 'error-row';
      }
      return '';
      }
    },
    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);
       });
    },
    tableHeaderCellStyle () {
      return 'color: rgb(255,255,255);border-bottom: 1px solid #DCDFE7;'
    }
  }
}
</script>
<style  scoped>
</style>
