<template>
  <div class="create-bidding">
    <!-- <create-bidding-Content /> -->
    <cy-info-title>基础信息</cy-info-title>
    <basic-information ref="basicInformation" :basic-information="basicInformation" :disabled="disabled" />
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
      style="margin-top: 20px"
    >
      <cy-info-title>招投标信息</cy-info-title>
      <el-form-item label="是否资格预审：" prop="prequalification">
        <el-radio-group v-model="ruleForm.prequalification" :disabled="disabled">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item
        label="招标文件："
        class="form-required"
      >
        <cy-upload
          ref="tendersFile"
          :upload-params="{
            fileType: 'tendersFile'
          }"
          :file-data="ruleForm.tendersFile"
          :upload-from-orange-status="true"
          placeholder="请上传招标文件"
          :disabled="disabled"
        />
      </el-form-item>
      <el-form-item
        label="投标文件："
        class="form-required"
      >
        <cy-upload
          ref="biddingFile"
          :upload-params="{
            fileType: 'biddingFile'
          }"
          :file-data="ruleForm.biddingFile"
          :upload-from-orange-status="true"
          placeholder="请上传投标文件"
          :disabled="disabled"
        />
      </el-form-item>
    </el-form>
    <div v-if="!disabled" class="submit-btn">
      <el-button @click="() => { $router.go(-1) }">关闭</el-button>
      <el-button type="primary" @click="onSubmit">提交</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MyTradeBiddingManagement',
  components: {
    BasicInformation: () => import('../components/BasicInformation.vue')
  },
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    deatailsInfo: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      ruleForm: {
        prequalification: '',
        tendersFile: [],
        biddingFile: []
      },
      uploadParams: {},
      rules: {
        prequalification: [{ required: true, message: '请选择是否资格预审', trigger: 'blur' }]
      },
      basicInformation: {}
    }
  },
  watch: {
    deatailsInfo: {
      handler(newV) {
        if (Object.keys(newV).length) {
          const { prequalification, biddingFileList, tendersFileList, basicInfoResultVo } = JSON.parse(JSON.stringify(newV))
          this.ruleForm = {
            prequalification,
            tendersFile: tendersFileList || [],
            biddingFile: biddingFileList || []
          }
          this.basicInformation = {
            projectName: basicInfoResultVo.projectName,
            enterprise: basicInfoResultVo.enterprise,
            mainEnterprise: basicInfoResultVo.mainEnterprise,
            platform: basicInfoResultVo.platform,
            businessNumber: basicInfoResultVo.businessNumber
          }
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    onSubmit() {}
  }
}
</script>

<style lang="scss" scoped>
.create-bidding {

}
</style>
