<!--
  @description: 标中澄清-澄清
  @Modifier: 杨胜国
  @routerPath:/procurement/procurementDrive/procEvaluateClarify/procEvaluateClarifySupAdd
  @date: 2021-02-09 17:33:00
-->
<template>
  <div>
    <el-form
      ref="fromData"
      :rules="rules"
      :inline-message="true"
      :model="formData"
    >
      <table class="from_table">
        <tr>
          <td style="padding:16px">
            澄清标题
          </td>
          <td colspan="3" style="padding:16px">
            {{ formData.bidClarificationTitle }}
          </td>
        </tr>
        <!-- <tr>
          <td style="padding:16px">
            澄清内容文件
          </td>
          <td colspan="3" style="padding:16px">
            <downloadFile :data="bidClarificationContent" />
          </td>
        </tr> -->
        <tr>
          <td style="padding:16px">
            澄清文件
          </td>
          <td colspan="3" style="padding:16px">
            <downloadFile :data="bidClarificationAttachment" />
          </td>
        </tr>
        <tr>
          <td>
            <el-form-item label="澄清回复文件" prop="bidClarificationSupContent" />
          </td>
          <td colspan="3">
            <upload
              ref="bidClarificationSupContent"
              :on-change="bidClarificationSupContentFile"
              :data="bidClarificationSupContent"
              :auto-delete="true"
              :auto-upload="true"
              :file-size="200"
              title=""
              accept=".doc, .docx, .pdf, .png, .jpg, .zip;.jpeg;.txt;.xlsx;. xls;.ppt;.pptx;.rar"
              tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.jpeg;*.txt;*.xlsx;*.xls;*.ppt;*.pptx;*.rar）单个文件不得超过200M"
              file-ref="fileRef"
            />
          </td>
        </tr>
        <tr>
          <td>
            <el-form-item label="附件" prop="bidClarificationSupAttachment" />
          </td>
          <td colspan="3">
            <upload
              ref="bidClarificationSupAttachment"
              :on-change="bidClarificationSupAttachmentFile"
              :data="bidClarificationSupAttachment"
              :auto-delete="true"
              :auto-upload="true"
              :file-size="200"
              title=""
              accept=".doc, .docx, .pdf, .png, .jpg, .zip;.jpeg;.txt;.xlsx;. xls;.ppt;.pptx;.rar"
              tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.jpeg;*.txt;*.xlsx;*.xls;*.ppt;*.pptx;*.rar）单个文件不得超过200M"
              file-ref="fileRef"
            />
          </td>
        </tr>
      </table>
    </el-form>
    <!--保存按钮-->
    <div class="but_footer">
      <div class="but_footer-h" />
      <div class="but_footer-but">
        <!--工作流进入不显示返回-->
        <el-button :loading="confirmLoading" type="primary" @click="saveBidClarificationInfo()">
          提交澄清
        </el-button>
        <el-button @click="back">
          返 回
        </el-button>
      </div>
    </div>
  </div>
</template>

<script>
/* 接口*/
import { saveBidClarificationReceiptInfo } from '@/api/procurement/procurementProject'// 澄清
/* 混合开发方法-参数字段*/
import { clarificationGroupMixin } from '../../mixins/clarificationGroupMixin'// 澄清质疑-公用参数
import { clarificationMixin } from '../../mixins/clarificationMixin'// 澄清质疑-公用参数

/* 组件*/
import upload from '@comp/common/updownload/upload' // 附件上传组件
import downloadFile from '@comp/common/updownload/downloadFile'
export default {
  name: 'ClarificationAdd',
  components: {
    upload,
    downloadFile
  },
  inject: ['getTenderBase'],
  mixins: [clarificationGroupMixin, clarificationMixin],
  data() {
    return {
      tenderBase: this.getTenderBase(), // 项目信息
      confirmLoading: false,
      supplierList: [],
      formData: {
        bidClarificationTitle: this.$route.params.bidClarificationTitle, // 澄清标题
        packId: '', // 标段id
        packName: '', // 标段名称
        packNo: '', // 标段编号
        tenderId: '', // 项目id
        bidClarificationId: '', // 澄清id
        clarificationEndTime: '', // 澄清截止时间
        bidClarificationSupContent: '', // 澄清内容文件
        bidClarificationSupAttachment: '', // 澄清附件
        bidClarificationSupplierInfoDtoList: [], // 需要澄清的供应商列表
        status: '01' // 00 保存 01 提交
      },
      // 标中澄清内容文件
      bidClarificationSupContent: {
        bizId: '',
        fileType: 'procurement_bid_clarification_receipt_content'
      },
      // 标中澄清附件
      bidClarificationSupAttachment: {
        bizId: '',
        fileType: 'procurement_bid_clarification_receipt_attachment'
      },
      // 校验
      rules: {
        bidClarificationSupContent: [{ required: true, message: '请上传', trigger: 'blur' }], // 澄清内容文件
        bidClarificationSupAttachment: [{ required: true, message: '请上传', trigger: 'blur' }] // 澄清附件
      }
    }
  },
  created() {
    // 初始化
    this.init()
  },
  methods: {
    init() {
      this.bidClarificationSupContent.bizId = this.bidClarificationSupAttachment.bizId = this.$route.params.bidClarificationSupplierId
      this.formData.packId = this.tenderBase.packId // 标段id
      this.formData.packName = this.tenderBase.packName // 标段名称
      this.formData.packNo = this.tenderBase.packNo // 标段编号
      this.formData.tenderId = this.tenderBase.tenderId // 项目id
      // 采购附件id赋值
      this.bidClarificationContent.bizId = this.bidClarificationAttachment.bizId = this.$route.params.bidClarificationId
    },
    // 澄清内容文件
    bidClarificationSupContentFile(file, fileList) {
      if (fileList.length > 0) {
        this.$set(this.formData, 'bidClarificationSupContent', 'true')// 上传了
      } else {
        this.$set(this.formData, 'bidClarificationSupContent', '')// 未上传
      }
    },
    // 澄清附件
    bidClarificationSupAttachmentFile(file, fileList) {
      if (fileList.length > 0) {
        this.$set(this.formData, 'bidClarificationSupAttachment', 'true')// 上传了
      } else {
        this.$set(this.formData, 'bidClarificationSupAttachment', '')// 未上传
      }
    },
    // 返回
    back() {
      this.$router.push({
        name: 'procEvaluateClarifySupList'
      })
    },
    /*
    * 保存接口
    * */
    saveBidClarificationInfo() {
      this.$refs.fromData.validate((valid, field) => {
        if (valid) { // 校验通过
          this.confirmLoading = true // btnLoding
          const params = {
            bidClarificationSupplierId: this.$route.params.bidClarificationSupplierId
          }
          saveBidClarificationReceiptInfo(params).then(response => {
            this.$message.success(response.header.msg)
            this.confirmLoading = false // btnLoding
            this.back()
          }).catch(() => {
            this.confirmLoading = false // btnLoding
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
