<!--
  @description:采购立项-项目管理-采购文件-综合评估法
  @Modifier:gmy
  @routerPath:/procurement/procurementDrive/procurementDocumentsPurchase/procurementDocuments
  @date:2020/7/13-13:27
-->
<template>
  <div class="p0-16 main">
    <table v-if="upLoadData.fileType!==''" class="tableData">
      <tr class="singleRow">
        <td><span class="red-star">*</span>采购文件</td>
        <td>
          <upload
            v-if="auditStatus===''"
            ref="upload"
            :title="``"
            :data="upLoadData"
            :auto-upload="true"
            :auto-delete="true"
            :limit="1"
            :tip-text="tipText"
            accept="doc,.docx,.pdf,.zip"
            file-ref="fileRef2"
          />
          <downloadFile v-if="auditStatus==='01'|| auditStatus==='00'" :data="upLoadData" />
        </td>
      </tr>
    </table>
    <!--操作按钮 提交字段 00 01 暂定表示已提交则不显示-->
    <div v-if="auditStatus===''" class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button type="primary" @click="submit">
            提交
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* api*/
import { procurementProcfileTakeEffect, getProcurementProcfileByPackId } from '@/api/procurement/procurementProtdoc'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 组件*/
import upload from '@comp/common/updownload/upload'
import downloadFile from '@comp/common/updownload/downloadFile'
export default {
  components: {
    upload,
    downloadFile
  },
  mixins: [ListMixin],
  props: {

  },
  data() {
    return {
      // 采购文件附件
      upLoadData: {
        bizId: '',
        fileType: ''
      },
      tipText: '上传附件格式（*.doc;*.docx;*.pdf;*.zip），不超过200M',
      formData: {
        id: '',
        packIds: this.$route.query.packId,
        state: '01',
        tenderId: this.$route.query.id
      },
      toggle: true,
      auditStatus: ''
    }
  },
  watch: {

  },
  created() {
    const packId = this.$route.query.packId
    if (packId) {
      this.getFileData(packId)
    }
  },
  methods: {
    // 提交
    submit() {
      procurementProcfileTakeEffect(this.formData).then(res => {
        if (res.header.ret === '0') {
          this.$message({
            type: 'success',
            message: res.header.msg,
            onClose: () => {
              this.getFileData(this.$route.query.packId)
            }
          })
          this.$forceUpdate()
        }
      })
    },
    // 获取采购文件数据方法
    getFileData(packId) {
      getProcurementProcfileByPackId(packId).then(res => {
        // 采购文件
        this.upLoadData.bizId = res.data.procfileId
        this.upLoadData.fileType = res.data.fileTypeContent
        // 采购文件状态 暂定 00 01 ''
        this.auditStatus = res.data.auditStatus ? res.data.auditStatus : ''
      })
    }
  }
}
</script>

<style lang="less" scoped>

</style>

