<!--
  @description: 项目规则之询价组件
  @author: gmy
  @date: 2020-8-04 10:28:58
-->
<template>
  <div>
    <table class="tableData">
      <!-- 紧急采购-报价截止时间 -->
      <tr>
        <td>
          紧急采购
        </td>
        <td>
          {{ filterDictText(emergencyProcurementList, dataRule.isEmergencyProcurement) }}
        </td>
        <td>
          <!-- isEdit 是否点击变更字段 布尔值 true已点击 false未点击 点击展示编辑 否则就是查看 -->
          <template v-if="!otherData.isEdit">报价截止时间</template>
          <el-form-item v-if="otherData.isEdit" :rules="rules.quoteEndTime" label="报价截止时间" prop="quoteEndTime" />
        </td>
        <td>
          <!-- isEdit 是否点击变更字段 布尔值 true已点击 false未点击 点击展示编辑 否则就是查看 -->
          <!-- <span v-if="!otherData.isEdit">{{ dataRule.quoteEndTime }}</span> -->
          <template v-if="!otherData.isEdit">{{ dataRule.quoteEndTime && $Moment(dataRule.quoteEndTime).format(momentDateTime) }}</template>
          <el-date-picker
            v-if="otherData.isEdit"
            v-model="dataRule.quoteEndTime"
            :picker-options="disabledPickerOptions"
            :format="elValueFormat"
            :value-format="elValueFormat"
            :default-time="defaultTimeDateTime"
            type="datetime"
            placeholder="选择日期时间"
            @change="changeQuoteEndTime"
          />
        </td>
      </tr>
      <!--    报价有效期  强制上传应答文件     -->
      <tr>
        <td>
          <!-- isEdit 是否点击变更字段 布尔值 true已点击 false未点击 点击展示编辑 否则就是查看 -->
          <template v-if="!otherData.isEdit">报价有效期</template>
          <el-form-item v-if="otherData.isEdit" :rules="rules.quoteValidity" label="报价有效期" prop="quoteValidity" />
        </td>
        <td>
          <template v-if="!otherData.isEdit">{{ $Moment(dataRule.quoteValidity).format(momentDate) }}</template>
          <el-date-picker
            v-if="otherData.isEdit"
            v-model="dataRule.quoteValidity"
            :picker-options="quoteValidityOpions"
            :value-format="elValueFormatDate"
            type="date"
            placeholder="选择日期时间"
          />
        </td>
        <td>
          强制上传应答文件
        </td>
        <td>
          {{ filterDictText(uploadReplyFileList, dataRule.isUploadReplyFile) }}
        </td>
      </tr>
      <!--    付款方式  币种       -->
      <tr>
        <td>
          币种
        </td>
        <td>
          {{ filterDictText(currencyList, dataRule.currency) }}
        </td>
        <td>
          付款方式
        </td>
        <td>
          {{ filterDictText(payTypelist, dataRule.payType) }}
        </td>
      </tr>
      <!--  是否含运费-- 报价要求       -->
      <tr>
        <td>
          是否含运费
        </td>
        <td>
          {{ filterDictText(containsFreightList, dataRule.isContainsFreight) }}
        </td>
        <td>
          报价要求
        </td>
        <td>
          {{ filterDictText(quoteType, dataRule.quoteType) }}
        </td>
      </tr>
      <tr>
        <td>
          询价方式
        </td>
        <td>
          {{ filterDictText(protproject_quoteMethodList, dataRule.quoteMethod) }}
        </td>
        <td>
          评审办法
        </td>
        <td>
          {{ filterDictText(reviewMethod, dataRule.reviewMethod) }}
        </td>
      </tr>
      <tr>
        <td>
          是否收取标书费
        </td>
        <td :colspan="dataRule.isReceiveTenderDocumentPrice === '01' ? '' : '3'">
          {{ filterDictText(documentPrice, dataRule.isReceiveTenderDocumentPrice) }}
        </td>
        <td v-if="dataRule.isReceiveTenderDocumentPrice === '01'">
          <el-form-item ref="documentPrice" :rules="rules.documentPrice" label="标书费金额" prop="documentPrice" />
        </td>
        <td v-if="dataRule.isReceiveTenderDocumentPrice === '01'">
          {{ dataRule.protProjectDocumentPriceList[0].documentPrice }}
        </td>
      </tr>
      <tr>
        <td>
          供应商分类
        </td>
        <td>
          {{ dataRule.supplierCategory && filterDictText(supplierCategoryList, dataRule.supplierCategory) }}
        </td>
        <td>
          供应商属性
        </td>
        <td>
          {{ dataRule.supplierAttribute && filterDictText(supplierAttributeList, dataRule.supplierAttribute) }}
        </td>
      </tr>
      <!--tenderType 01邀请-->
<!--      <template v-if="tenderType==='01'">
        <tr>
          <td>
            <el-form-item label="是否联合体" prop="ifCombo" />
          </td>
          <td colspan="3">
            {{ filterDictText(ifComboTypeList,dataRule.ifCombo) }}
          </td>
        </tr>
        <tr v-if="dataRule.ifCombo==='01'">
          <td>
            <el-form-item label="联合体协议" prop="ifCombo" />
          </td>
          <td colspan="3">
            <downloadFile v-if="invitationComboFileType.bizId" :data="invitationComboFileType" />
          </td>
        </tr>
      </template>-->
    </table>
  </div>
</template>

<script>
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'
import downloadFile from '@comp/common/updownload/downloadFile' // 附件下载
/* 混合开发-参数字段*/
import { procurementProjectGroupMixin } from '../../mixins/procurementProjectGroupMixin'// 立项采购-字典
import { procurementProjectMixins } from '../../mixins/procurementProjectMixins'// 立项采购-公用方法参数
export default {
  name: 'ProcurementProjectAdd',
  components: {
    downloadFile
  },
  mixins: [procurementProjectGroupMixin, procurementProjectMixins],
  props: {
    // 项目规则数据
    dataRule: {
      type: Object,
      default: () => {
        return {}
      }
    },
    // 其他数据
    otherData: {
      type: Object,
      default: () => {
        return {}
      }
    },
    tenderType: {
      type: String,
      default: ''
    },
    tenderId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // 限制不可以选择现在之前的时间报价截止时间存在时应大不可选择报价截止之前的时间
      quoteValidityOpions: {
        disabledDate: time => {
          // 报价截止时间存在
          const endTime = this.dataRule.quoteEndTime
          if (endTime) {
            return time.getTime() < new Date(endTime).getTime()
          } else {
            return time.getTime() < Date.now() - 8.64e7
          }
        }
      },
      // 校验输入内容
      rules: {
        quoteEndTime: [{ required: true, message: '请选择', trigger: 'blur' }], // 报价截止时间
        quoteValidity: [{ required: true, message: '请选择', trigger: 'blur' }] // 报价有效期
      }
    }
  },
  created() {
    this.invitationComboFileType.bizId = this.tenderId
    // 调用项目规则字典方法
    this.initqueryProcurementProjectRuleInitInfo()
  },
  methods: {
    filterDictText, // 引入字典值替换文本通用方法
    // 项目规则，报价有效期，默认为报价截止时间，90天
    changeQuoteEndTime(val) {
      // 校验时间有值时可以设置报价有效期
      if (val) {
        this.dataRule.quoteValidity = this.$Moment(val).add(90, 'days').format(this.momentDate)
      }
    },
    // 保存或提交时 组装数据然后返回
    assemblyData() {
      const data = {
        id: this.dataRule.id,
        quoteEndTime: this.dataRule.quoteEndTime ? this.$Moment(this.dataRule.quoteEndTime).format(this.momentSaveFormat) : '', // 报价截止时间
        quoteValidity: this.dataRule.quoteValidity ? this.$Moment(this.dataRule.quoteValidity).format(this.momentSaveFormat) : '', // 报价有效期
        isReceiveTenderBailPrice: this.dataRule.isReceiveTenderBailPrice, // 是否收取保证金
        isReceiveTenderDocumentPrice: this.dataRule.isReceiveTenderDocumentPrice, // 是否收取标书费
        protProjectDocumentPriceList: this.dataRule.protProjectDocumentPriceList, // 标书费金额
        protProjectBailPriceList: this.dataRule.protProjectBailPriceList, // 保证金金额
        isUploadReplyFile: this.dataRule.isUploadReplyFile, // 强制上传应答文件
        isContainsFreight: this.dataRule.isContainsFreight, // 是否含运费
        currency: this.dataRule.currency, // 币种
        payType: this.dataRule.payType, // 付费方式
        isEmergencyProcurement: this.dataRule.isEmergencyProcurement, // 是否紧急采购
        quoteType: this.dataRule.quoteType // 报价要求
      }
      // 返回
      return data
    }
  }
}
</script>

<style lang="less" scoped>
  /deep/.el-form-item--small.el-form-item{
    margin-bottom: 0;
  }
</style>

