<!--
@description: 开启新伦次弹框组件
@Modifier: gaoMy
@date: 2020-8-12 14:26:15
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="dialogData.dialog"
    :close-on-click-modal="false"
    append-to-body
    title="开启新轮次"
    custom-class="el-dialog_table"
  >
    <section class="p8">
      <el-form
        ref="form"
        :model="formData"
        :rules="rules"
        :inline-message="true"
      >
        <!--      点击修改-->
        <table class="from_table">
          <tr>
            <td v-if="dialogData.tenderMethod!=='12'">
              <el-form-item label="报价结束时间" prop="EndTime" />
            </td>
            <td v-if="dialogData.tenderMethod!=='12'">
              <el-date-picker
                v-model="formData.EndTime"
                :value-format="elValueFormat"
                :format="elValueFormat"
                :picker-options="disabledPickerOptions"
                :default-time="defaultTimeDateTime"
                type="datetime"
                placeholder="选择结束时间"
              />
            </td>
          </tr>
          <tr v-if="dialogData.tenderMethod!=='11'">
            <td>
              <el-form-item ref="isLast" label="是否为最终轮次" prop="isLast" />
            </td>
            <td>
              <el-radio-group v-model="formData.isLast">
                <el-radio
                  v-for="(item) in ifAtlastRoundList"
                  :key="item.typecode"
                  :label="item.typecode"
                >
                  {{ item.typename }}
                </el-radio>
              </el-radio-group>
            </td>
          </tr>
          <tr>
            <td>
              <el-form-item ref="isLast" label="入围供应商" prop="isLast" />
            </td>
            <td>
              {{ dialogData.selectedSuppliers }}
            </td>
          </tr>
          <tr>
            <td>
              报价说明文件
            </td>
            <td>
              <upload
                ref="upload"
                :title="''"
                :data="quotationDescriptionFileData"
                :file-list="principalList"
                :auto-delete="true"
                :auto-upload="true"
                tip-text="上传附件格式（*.doc;*.docx;*.pdf;*.png;*.jpg;*.zip;*.jpeg;*.txt;*.xlsx;*.xls;*.ppt;*.pptx;*.rar）单个文件不得超过200M"
                accept=".doc,.docx,.pdf,.png,.jpg,.zip,.jpeg,.txt,.xlsx,.xls,.ppt,.pptx,.rar"
                file-ref="fileRef"
                but-text="点击上传"
              />
            </td>
          </tr>
          <tr>
            <td>
              谈判说明
            </td>
            <td>
              <el-input v-model="formData.negotiationsThat" type="textarea" />
            </td>
          </tr>
        </table>
      </el-form>
    </section>
    <!--底部操作按钮-->
    <span slot="footer" class="dialog-footer">
      <el-button
        :loading="confirmLoading"
        type="primary"
        @click="ensure('form')"
      >{{ language.Determine }}</el-button>
      <el-button @click="dialogData.dialog = false">
        {{ language.cancel }}
      </el-button>
    </span>
  </el-dialog>
</template>

<script>
// api
import { getEvalReportUUid } from '@/api/procurement/procurementEvaluation' // 获取项目类型数据
// vuex
import { mapGetters } from 'vuex'
// 组件
import upload from '@comp/common/updownload/upload' // 附件上传组件
// 公共方法
import { procurementOfferGroupMixin } from '../mixins/procurementOffGroupMixin'
import { procurementOfferMixin } from '../mixins/procurementOfferMixin'
export default {
  name: 'ProcurementCollectionDialogVue',
  components: {
    upload
  },
  mixins: [procurementOfferGroupMixin, procurementOfferMixin],
  props: {
    // 弹框展示状态
    dialogData: {
      type: Object,
      default: function() {}
    }
  },
  data() {
    return {
      value1: '',
      confirmLoading: false,
      uuId: '',
      // 开起结束时间
      formData: {
        EndTime: '', // 开启新伦次截止时间
        isLast: '', // 是否为最终轮次 00 否01 是
        negotiationsThat: '' // 谈判说明
      },
      // 校验规则
      rules: {
        EndTime: [{ required: true, message: '请选择', trigger: 'blur' }], // 结束时间
        isLast: [{ required: true, message: '请选择', trigger: 'blur' }]
      },
      principalList: []
    }
  },
  computed: {
    /* language 国际化*/
    ...mapGetters(['language'])
  },
  watch: {
    // 监听-弹框展示状态
    'dialogData.dialog'(val) {
      if (val) {
        // 弹框已打开
        // 清空元数据
        this.confirmLoading = false
        this.clearData()
      }
    }
  },
  mounted() {
    this.getUuid()
  },
  methods: {
    // 获取UUid
    getUuid() {
      getEvalReportUUid(this.dialogData.packId)
        .then(res => {
          this.quotationDescriptionFileData.bizId = res.data
          this.uuId = res.data
        })
    },
    // 选择信息-确定
    ensure(formName) {
      this.confirmLoading = true
      this.$refs[formName].validate((valid, field) => {
        if (valid) {
          // 获取开启徐黁次选择的数据
          const openNewRoundData = {
            EndTime: this.dialogData.tenderMethod !== '12' ? this.$Moment(this.formData.EndTime).format(this.momentSaveFormat) : '', // 开启新伦次截止时间保留到s
            isLast: this.formData.isLast, // 是否开启新伦次字段
            uuId: this.uuId,
            negotiationsThat: this.formData.negotiationsThat // 谈判说明
          }
          this.$emit('consignContractInfo', openNewRoundData)
          this.dialogData.dialog = false
        } else {
          this.confirmLoading = false
          return false
        }
      })
    },
    // 清楚时间
    clearData() {
      this.formData.EndTime = ''
    }
  }
}
</script>

<style scoped></style>
