<!--
 * @description: 弹窗
 * @author: tangQing
 * @date: 2022-12-28
!-->
<template>
  <div>
    <el-dialog
      v-dialogDrag
      :visible.sync="dialogData.visible"
      :close-on-click-modal="false"
      title="上传文件或修改"
      width="550px"
      custom-class="el-dialog_table"
    >
      <div class="candialg">
        <el-button v-if="dialogData.type !=='00'" @click="make">
          1、使用工具制作候选人公示
        </el-button>
      </div>
      <div>
        <upload
          ref="upload"
          :limit="1"
          :data="upLoadData"
          :auto-delete="true"
          :auto-upload="true"
          file-ref="fileRef"
          accept=".pdf"
          title=""
          tip-text="2、请上传已盖章公告pdf文件,不要超过500M。"
          @onSuccess="onSuccess"
        />
      </div>
      <div class="but_footer">
        <div class="but_footer-h">
          <div class="but_footer-but">
            <el-button @click="dialogData.visible= false">
              关 闭
            </el-button>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { webConfirmResultBulletinComplete } from '@api/bidding/bidCalibration'
import upload from '@comp/common/updownload/upload'
export default {
  components: {
    upload
  },
  props: {
    // 弹框展示状态
    dialogData: {
      type: Object,
      default: function() {

      }
    }
  },
  data() {
    return {
      // 文件上传
      upLoadData: {
        bizId: '', // 业务主键Id
        fileType: 'win_bid_result_bulletin_content '// 文件类型
      }
    }
  },
  created() {
    if (this.dialogData.type === '00') {
      this.upLoadData.bizId = this.dialogData.row
    } else {
      this.upLoadData.bizId = this.dialogData.row.id
    }
  },
  methods: {
    onSuccess(val) {
      const data = {
        winBidResultBulletinId: this.upLoadData.bizId, // 公告Id
        fileId: val[0].fileData.fileId// 公告Id
      }
      webConfirmResultBulletinComplete(data).then((res) => {
      })
    },
    // 工具制作
    make() {
      this.$emit('toolRevamped', this.dialogData.row)
    }

  }
}
</script>
<style scoped>
.candialg{
  margin-bottom:20px
}
</style>
