<template>
    <div>
      <el-table
        :border="true"
        stripe
        fit
        height="100%"
        ref="multipleSelection"
        :data="tableData"
      >
        <el-table-column type="index" width="55" align="center" label="序号">
        </el-table-column>
        <el-table-column
          prop="supplierCode"
          min-width="100px"
          label="供应商编码"
          align="center"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="supplierName"
          show-overflow-tooltip
          min-width="130px"
          align="center"
          label="供应商名称"
          resizable
        >
        </el-table-column>
        <el-table-column
          prop="categoryName"
          show-overflow-tooltip
          min-width="130px"
          align="center"
          label="申请供应分类"
          resizable
        >
        </el-table-column>
      </el-table>
      <div style="margin-top: 20px;font-weight: 500;font-size: 14px;">
        资质附件
      </div>
      <div>
        <el-form
          ref="form"
          v-for="(item, index) in parameter.suppliersQualificationList"
          :key="index"
          label-width="80px"
        >
        <el-form-item style="margin-bottom: 0px !important;font-size: 14px;" :label="item.qualificationCategoryName"></el-form-item>
        <el-table
            class="down"
            :data="item.dataList"
            border
            stripe
            style="width: 100%"
          >
          <el-table-column prop="qualificationCode" label="资质编码">
            </el-table-column>
            <el-table-column prop="qualificationName" label="资质名称">
            </el-table-column>
            <el-table-column
              prop="qualificationAcquisitionDate"
              label="取得日期"
            >
            </el-table-column>
            <el-table-column prop="expiryDate" label="到期日期">
            </el-table-column>
            <el-table-column
              prop="name"
              show-overflow-tooltip
              label="文件名称"
            ></el-table-column>
            <el-table-column
              prop="createTime"
              show-overflow-tooltip
              label="上传时间"
            >
            </el-table-column>
            <el-table-column width="100px" label="附件">
              <template slot-scope="scope">
                <el-button
                  size="small"
                  type="text"
                  v-if="scope.row.accessoryList.length != 0"
                >
                  <a
                    target="_blank"
                    @click="downloadFile(scope.row.name, scope.row.url)"
                    >下载</a
                  >
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </div>
    </div>
  </template>
      
      <script>
  import {helper} from '../../../public/hotent.helper.js'
  import req from '@/request.js'
  import basicData from '@/api/basicData'
  import utils from '@/hotent-ui-util.js'
  import utilData from '@/utils.js'
  import materialEvaluationDialog from './components/materialEvaluationDialog.vue'
  import materialProcurementBid from './components/materialProcurementBid.vue'
  export default {
    components: {
      materialEvaluationDialog, //最低评标法
      materialProcurementBid  //综合评标法
    },
    data() {
      return {
        parameter: {},
        loading: false,
        tableData: [],
        saveFlag: true,
        currentNode: 1,
        activeName: 1,
        scoreData: [],
      }
    },
    mounted() {
      this.currentNode = this.$route.query.node
      window.saveData = this.saveData
      window.relationData = this.relationData
      this.id = utils.getUrlKey('id')
      this.node = utils.getUrlKey('node')
      if (this.id) {
        let params = {
          querys: [],
        }
        params.querys.push({
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'id',
          relation: 'AND',
          value: this.id,
        })
        req
          .post(window.context.portal + '/matApproval/v1/page', params)
          .then((res) => {
            if (res.data.state) {
              this.tableData = res.data.value.rows
            }
          })
      }
    },
    methods: {
        //下载按钮回调
    downloadFile(name, url) {
      var a = document.createElement('a')
      var event = new MouseEvent('click')
      a.download = name
      a.target = '_blank'
      a.href = url
      a.dispatchEvent(event)
    },
      getDictName(code, value) {
        return utilData.getDictName(code, value)
      },
      /* 保存 */
      saveData() {
        if (this.saveFlag) {
          //如果是第一个节点他可以保存数据，否则不需要进行数据操作
          if (this.node == 1) {
            this.parameter.reviewStatus = '1'
            this.$http
              .post(
                '${portal}/supplier/bizSupplierEnterprise/v1/uploadAccessory',this.parameter
              )
              .then((res) => {
                console.log(res, '调用结果')
                if (res.data.state) {
                  this.id = res.data.value
                  let params = {
                    type: 'saveData',
                    state: true,
                    businessKey: this.id, // todo 确认id字段是否正确 用接口返回值做businessKey
                    sysCode: '',
                  }
                  params.vars = {
                    // comPanyUUser: this.form.noticeReleaseUserAccount,
                  }
                  hotent.sendMessage(params)
                  this.saveFlag = false
                }
              })
          } else {
            let params = {
              type: 'saveData',
              state: true,
              businessKey: this.id, // 流程地址参数id
              sysCode: '',
            }
            hotent.sendMessage(params)
            this.isFirst = false
          }
        } else {
          let params = {
            type: 'saveData',
            state: true,
            businessKey: this.id, // 流程地址参数id
            sysCode: '',
          }
          params.vars = {
              	// comPanyUUser: this.form.noticeReleaseUserAccount,
          }
          hotent.sendMessage(params)
          this.isFirst = false
        }
        // }
      },
      relationData(data) {
        this.parameter = data
        this.tableData.push(data)
      },
    },
  }
  </script>
      
      <style lang="scss" scoped>
  .form-content {
    overflow-x: hidden;
  }
  .rows:first-of-type {
    cursor: pointer;
  }
  .auto {
    display: none;
  }
  .classNone {
    display: block;
  }
  .form-flex {
    /deep/.el-form-item__content {
      display: flex;
      align-items: center;
    }
  }
  .append {
    width: 10%;
    background-color: #f5f7fa;
    color: #909399;
    vertical-align: middle;
    display: table-cell;
    position: relative;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    padding: 0 10px;
    white-space: nowrap;
    text-align: center;
  }
  </style>