<!--
  @description: 项目规则-招标编辑
  @author: gmy
  @date: 2020-8-3 10:19:58
-->
<template>
  <div class="mb16">
    <table class="from_table">
      <!--     紧急采购-报价截止时间     -->
      <tr>
        <td>
          <el-form-item ref="isEmergencyProcurement" :rules="rules.isEmergencyProcurement" label="紧急采购" prop="isEmergencyProcurement" />
        </td>
        <td>
          <el-radio-group v-model="dataRule.isEmergencyProcurement">
            <el-radio
              v-for="(item) in emergencyProcurementList"
              :key="item.id"
              :label="item.typecode"
            >
              {{ item.typename }}
            </el-radio>
          </el-radio-group>
        </td>
        <!-- 评审办法 -->
        <td>
          <el-form-item ref="reviewMethod" :rules="rules.reviewMethod" label="评审办法" prop="reviewMethod" />
        </td>
        <td v-if="sourceType01A">
          {{ filterDictText(reviewMethod, dataRule.reviewMethod) }}
        </td>
        <td v-else>
          <el-radio-group v-model="dataRule.reviewMethod">
            <el-radio
              v-for="(item) in reviewMethod"
              :key="item.typecode"
              :label="item.typecode"
            >
              {{ item.typename }}
            </el-radio>
          </el-radio-group>
        </td>
      </tr>
      <!--    币种- 付款方式-是否含运费       -->
      <tr>
        <td>
          <el-form-item ref=" currency" label="币种" />
        </td>
        <td>
          <el-select v-model="dataRule.currency" filterable>
            <el-option
              v-for="(item) in currencyList"
              :key="item.id"
              :label="item.typename"
              :value="item.typecode"
            />
          </el-select>
        </td>
        <td>
          <el-form-item ref="isContainsFreight" label="是否含运费" prop="isContainsFreight" />
        </td>
        <td>
          <el-radio-group v-model="dataRule.isContainsFreight">
            <el-radio
              v-for="(item) in containsFreightList"
              :key="item.id"
              :label="item.typecode"
            >
              {{ item.typename }}
            </el-radio>
          </el-radio-group>
        </td>
      </tr>
      <!--    报价要求       -->
      <tr>
        <td>
          <el-form-item ref="quoteType" :rules="rules.quoteType" label="报价要求" prop="quoteType" />
        </td>
        <td colspan="3">
          <el-radio-group v-model="dataRule.quoteType">
            <el-radio
              v-for="(item) in quoteType"
              :key="item.typecode"
              :label="item.typecode"
            >
              {{ item.typename }}
            </el-radio>
          </el-radio-group>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item ref="supplierCategory" :rules="rules.supplierCategory" label="供应商分类" prop="supplierCategory" />
        </td>
        <td v-if="sourceType01A" colspan="3">
          {{ filterDictText(supplierCategoryList, dataRule.supplierCategory?dataRule.supplierCategory.join(','):dataRule.supplierCategory) }}
        </td>
        <td v-else colspan="3">
          <el-checkbox-group v-model="dataRule.supplierCategory">
            <el-checkbox
              v-for="(item, index) in supplierCategoryList"
              :key="index"
              :label="item.typecode"
            >
              {{ item.typename }}
            </el-checkbox>
          </el-checkbox-group>
        </td>
      </tr>
      <tr>
        <td>
          <el-form-item ref="supplierAttribute" :rules="rules.supplierAttribute" label="供应商属性" prop="supplierAttribute" />
        </td>
        <td v-if="sourceType01A" colspan="3">
          {{ filterDictText(supplierAttributeList, dataRule.supplierAttribute?dataRule.supplierAttribute.join(','):dataRule.supplierAttribute) }}
        </td>
        <td v-else colspan="3">
          <el-checkbox-group v-model="dataRule.supplierAttribute">
            <el-checkbox
              v-for="(item, index) in supplierAttributeList"
              :key="index"
              :label="item.typecode"
            >
              {{ item.typename }}
            </el-checkbox>
          </el-checkbox-group>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
/* 公用方法*/
import { filterDictText } from '@/assets/js/utils'
import { characters1_auto } from '@/assets/js/validate'// 校验输入内容
import { procurementProjectGroupMixin } from '../../mixins/procurementProjectGroupMixin'// 立项采购-字典
/* 公共组件*/
import money from '@comp/common/money/money' // 金币组件
export default {
  name: 'ProjectBidsRuleAdd',
  components: {
    money
  },
  mixins: [procurementProjectGroupMixin],
  props: {
    dataRule: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      sourceType01A: false,
      // 校验输入内容
      rules: {
        isEmergencyProcurement: [{ required: true, message: '请选择', trigger: 'blur' }], // 紧急采购
        payType: [{ required: true, validator: characters1_auto, trigger: 'change' }], // 付款方式
        isReceiveTenderBailPrice: [{ required: true, message: '请选择', trigger: 'blur' }], // 收取保证金
        isReceiveTenderDocumentPrice: [{ required: true, message: '请选择', trigger: 'blur' }], // 收取标书费
        quoteType: [{ required: true, message: '请选择', trigger: 'blur' }], // 报价要求
        quoteMethod: [{ required: true, message: '请选择', trigger: 'blur' }], // 询价方式
        isContainsFreight: [{ required: true, message: '请选择', trigger: 'blur' }],
        reviewMethod: [{ required: true, message: '请选择', trigger: 'blur' }], // 评审办法
        supplierCategory: [{ type: 'array', required: true, message: '请选择', trigger: 'change' }], // 供应商分类
        supplierAttribute: [{ type: 'array', required: true, message: '请选择', trigger: 'change' }] // 供应商属性
      }
    }
  },
  created() {
    // 页面初始化
    this.pageInit()
    // 调用项目规则字典方法
    this.initqueryProcurementProjectRuleInitInfo()
  },
  methods: {
    filterDictText, // 引入字典值替换文本通用方法
    // 页面初始化
    pageInit() {
      if (this.$route.query.sourceType.indexOf('01A') !== -1) {
        this.sourceType01A = true
      }
    },
    // 保存或提交时 组装数据然后返回
    assemblyData() {
      const data = {
        id: this.dataRule.id,
        tenderId: this.$route.query.tenderId,
        quoteEndTime: '', // 报价截止时间
        quoteValidity: '', // 报价有效期
        isReceiveTenderBailPrice: this.dataRule.isReceiveTenderBailPrice, // 是否收取保证金
        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, // 报价要求
        quoteMethod: this.dataRule.quoteMethod, // 询价方式
        isReceiveTenderDocumentPrice: this.dataRule.isReceiveTenderDocumentPrice, // 是否收取标书费
        protProjectDocumentPriceList: this.dataRule.protProjectDocumentPriceList, // 标书费金额
        reviewMethod: this.dataRule.reviewMethod, // 评审办法
        supplierCategory: this.dataRule.supplierCategory instanceof Array ? this.dataRule.supplierCategory.join(',') : this.dataRule.supplierCategory, // 供应商分类
        supplierAttribute: this.dataRule.supplierAttribute instanceof Array ? this.dataRule.supplierAttribute.join(',') : this.dataRule.supplierAttribute // 供应商属性
      }
      // 返回
      return data
    }
  }
}
</script>

<style lang="less" scoped>
</style>
