<template>
  <div class="core-enterprise">
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
    >
      <cy-info-title>核心企业</cy-info-title>
      <el-form-item label="公司名称">
        <el-input v-model="ruleForm.corporateName" placeholder="请输入公司名称" disabled />
      </el-form-item>
      <el-form-item label="集采平台" prop="centralizedProcurementPlatform">
        <el-radio-group v-model="ruleForm.centralizedProcurementPlatform" disabled>
          <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="与供应商存在历史合作" prop="historicalCooperation">
        <el-radio-group v-model="ruleForm.historicalCooperation" disabled>
          <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
      </el-form-item>

      <template v-if="ruleForm.historicalCooperation">
        <cy-info-title>历史合作情况</cy-info-title>
        <el-form-item label="历史合作时间" prop="historicalCooperationDuration">
          <el-input v-model="ruleForm.historicalCooperationDuration" placeholder="历史合作时间" disabled />
        </el-form-item>
        <el-form-item label="历史合作规模" prop="historicalCooperationScale">
          <el-input v-model="ruleForm.historicalCooperationScale" placeholder="历史合作规模" disabled />
        </el-form-item>
        <el-form-item label="累计历史开票金额" prop="historicalCooperationInvoicingAmount">
          <el-input v-model="ruleForm.historicalCooperationInvoicingAmount" placeholder="累计历史开票金额" disabled />
        </el-form-item>
        <el-form-item label="历史回款最长账期" prop="historicalCooperationMaximumAccountingPeriod">
          <el-input v-model="ruleForm.historicalCooperationMaximumAccountingPeriod" placeholder="历史回款最长账期" disabled />
        </el-form-item>
        <el-form-item label="历史合作项目数量" prop="historicalCooperationTimes">
          <el-input v-model="ruleForm.historicalCooperationMaximumAccountingPeriod" placeholder="历史合作项目数量" disabled />
        </el-form-item>
        <el-form-item label="历史合作资料上传" style="width: 100%;">
          <template slot="label">
            <span>*历史合作资料上传</span>
            <span style="color: #A3A8AC; margin-left: 10px; font-weight: 500;">提供近一年与核心企业合作的相关项目，招投标文件、购销合同、订单、验收单、结算单、发票、回单，格式为：pdf</span>
          </template>
          <cy-comm-table
            ref="commTable"
            :columns="columns"
            :data="tableData"
            :count="0"
          />
        </el-form-item>
      </template>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    detailsInfo: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      ruleForm: {
        id: '',
        corporateName: '',
        cProjectInformationId: '',
        centralizedProcurementPlatform: '',
        historicalCooperation: '',

        historicalCooperationDuration: '',
        historicalCooperationScale: '',
        historicalCooperationInvoicingAmount: '',
        historicalCooperationMaximumAccountingPeriod: '',
        historicalCooperationTimes: ''
      },
      tableData: [
        { fileStorageDOS: [] }
      ],
      columns: [
        {
          label: '序号',
          index: true
        },
        {
          label: '历史合同及相应单据',
          ruleRequired: true,
          render: (h, row, index) => {
            return <cy-upload
              ref={`fileStorage${index}`}
              limit={1}
              uploadParams={{
                fileType: 'projectCoreEnterpriseFile'
              }}
              fileData={row.fileStorageDOS}
              defaultDesc='提供1份与核心企业合作过的历史合同及相应单据：招投标文件、购销合同、订单、验收单、结算单、发票、回单（格式为：pdf）'
              disabled />
          }
        }]
    }
  },
  watch: {
    detailsInfo: {
      handler: function(newV) {
        if (newV && Object.keys(newV)) {
          const details = JSON.parse(JSON.stringify(newV))
          for (const k in this.ruleForm) {
            if (details[k] !== '' && details[k] !== null && details[k] !== undefined) {
              this.ruleForm[k] = details[k]
            }
          }
          const { enterprise } = details
          this.ruleForm.corporateName = enterprise.corporateName
          this.tableData = details.projectCoreEnterpriseFileHistoryList
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {

  }

}
</script>

  <style lang="scss" scoped>
  .core-enterprise {
  .el-form {
    padding: 10px 20px;
  }
  }
  </style>
