<!--
  @description: 评标大厅-重新上传文件-弹框
  @Modifier：yf
  @routerPath:
  @date：  2020-09-3 10:00:28
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.dialog"
    :close-on-click-modal="false"
    :lock-scroll="false"
    :before-close="close"
    title="提示"
    width="500px"
    height="300px"
    custom-class="el-dialog__body-p8 el-dialog_table"
  >
    <p>重新上传评标报告，已经签章的评委将重新进行签章。是否确认重新上传？</p>
    <span slot="footer" class="dialog-footer">
      <upload
        ref="upload"
        :on-change="principalFile"
        :data="reviewReportFilsData"
        :auto-delete="true"
        :auto-upload="true"
        :show-file-list="false"
        :but-text="'确定'"
        :but-type="'primary'"
        :success="successFileList"
        :before-upload="beforeUploadFile"
        accept=".doc,.docx"
        title=""
        file-ref="fileRef"
      />
      <el-button @click="close">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/** 公共组件 */
import upload from '@comp/common/updownload/upload' // 附件上传组件
// api
import { getEvalReportUUid, delReportFileByID } from '@api/procurement/procurementEvaluation'
export default {
  name: 'ReuploadReportDialog',
  components: {
    upload // 文件上传
  },
  mixins: [],
  props: {
    dialogData: {
      type: Object,
      default: function() {
        return {
          avoidanceLoading: false,
          dialog: false // false 关闭弹框  true 打开弹框
        }
      }
    },
    getTenderBase: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },
  data() {
    return {
      // 上传评审报告
      reviewReportFilsData: {
        bizId: '', // 业务主键Id
        fileType: 'reviewReports'// 文件类型
      }
    }
  },
  watch: {
    'dialogData.dialog'(val) {
      if (val) {
        // 初始化调用获取文件主键id方法
        this.getEvalReportUUidData()
      }
    }
  },
  created() {
  },
  methods: {
    // 附件上传
    principalFile(file, fileList) {
      this.principalList = fileList
    },
    // 附件上传成功的回调
    successFileList(file) {
      // 关闭弹框
      this.dialogData.dialog = false
      const data = {
        id: this.reviewReportFilsData.bizId, // UUid
        packId: this.getTenderBase.packId, // 标段id
        stageId: '' // 阶段id
      }
      this.$emit('uploadEvalInformData', data)
      this.$emit('changeUploadstatus')
    },
    //  获取文件上传的主键id请求
    getEvalReportUUidData() {
      const packId = this.getTenderBase.packId
      getEvalReportUUid(packId).then(res => {
        this.reviewReportFilsData.bizId = res.data
      }).catch(() => {

      })
    },
    // 重新上传之前
    beforeUploadFile() {
      delReportFileByID(this.reviewReportFilsData.bizId).then(res => {})
    },
    // 关闭弹框
    close() {
      this.dialogData.dialog = false
      this.dialogData.avoidanceLoading = false
    }
  }
}
</script>

<style scoped lang="less">
/deep/.but_footer .but_footer-but{
  display: -moz-inline-box;
}
/deep/.el-dialog__body-p8 .el-dialog__body {
    height: 20vh;
    overflow: auto;
    padding: 8px;
}
/deep/.fileBtn{
  margin-bottom: -10px !important;
}
.file{
  display: inline-block !important;
}
.file-list{
  display: inline-block !important;
}
</style>
