<template>
  <div class="owner-box">
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-position="top" label-width="120px" class="rule-form-orange">
      <el-form-item v-if="type === 'project'" label="项目业主方" prop="corporateName" class="one-form-item">
        <el-input v-model="ruleForm.corporateName" placeholder="请输入项目类型" />
      </el-form-item>
      <el-form-item v-if="type === 'company'" label="核心企业名称" prop="corporateName" class="one-form-item">
        <el-input v-model="ruleForm.corporateName" placeholder="请输入核心企业名称" />
      </el-form-item>
      <el-form-item label="统一社会信用代码" prop="socialCreditCode" class="one-form-item">
        <el-input v-model="ruleForm.socialCreditCode" placeholder="请输入项目名称" />
      </el-form-item>
      <el-form-item v-if="type === 'company'" label="集采平台" prop="centralizedProcurementPlatform" style="width: 100%">
        <el-input v-model="ruleForm.centralizedProcurementPlatform" placeholder="请输入 集采平台" />
      </el-form-item>
      <el-form-item label="成立年限" prop="yearsDiff" :class="{'one-form-item': type === 'company'}">
        <el-input v-model="ruleForm.yearsDiff" placeholder="请输入成立年限" />
      </el-form-item>
      <el-form-item v-if="type === 'project'" label="是否为项目成立的公司" prop="companyForProject" :class="{'one-form-item': type === 'company'}">
        <el-input v-model="ruleForm.companyForProject" placeholder="请输入是否为项目成立的公司" />
      </el-form-item>
      <el-form-item label="评估得分" prop="establishmentPeriodScore" :class="{'one-form-item': type === 'company'}">
        <el-input v-model="ruleForm.establishmentPeriodScore" placeholder="请输入评估得分" />
      </el-form-item>

      <el-form-item label="注册资本" prop="registeredCapital" class="one-form-item">
        <el-input v-model="ruleForm.registeredCapital" placeholder="请输入 注册资本" />
      </el-form-item>
      <el-form-item label="评估得分" prop="registeredCapitalScore" class="one-form-item">
        <el-input v-model="ruleForm.registeredCapitalScore" placeholder="请输入评估得分" />
      </el-form-item>

      <el-form-item v-if="type === 'project'" label="注册地址" prop="address" class="one-form-item">
        <el-input v-model="ruleForm.address" placeholder="请输入注册地址" />
      </el-form-item>
      <el-form-item v-if="type === 'project'" label="评估得分" prop="registeredAddressScore" class="one-form-item">
        <el-input v-model="ruleForm.registeredAddressScore" placeholder="请输入评估得分" />
      </el-form-item>

      <el-form-item label="实际经营地址" prop="businessAddress" class="one-form-item">
        <el-input v-model="ruleForm.businessAddress" placeholder="请输入实际经营地址" />
      </el-form-item>
      <el-form-item label="评估得分" prop="businessAddressScore" class="one-form-item">
        <el-input v-model="ruleForm.businessAddressScore" placeholder="请输入评估得分" />
      </el-form-item>

      <el-form-item label="企业性质" prop="enterpriseNature" class="one-form-item">
        <el-input v-model="ruleForm.enterpriseNature" placeholder="请输入企业性质" />
      </el-form-item>
      <el-form-item label="评估得分" prop="enterpriseNatureScore" class="one-form-item">
        <el-input v-model="ruleForm.enterpriseNatureScore" placeholder="请输入评估得分" />
      </el-form-item>

      <el-form-item label="控股比例" prop="holdingRatio" class="one-form-item">
        <el-input v-model="ruleForm.holdingRatio" placeholder="请输入控股比例" />
      </el-form-item>
      <el-form-item label="评估得分" prop="holdingRatioScore" class="one-form-item">
        <el-input v-model="ruleForm.holdingRatioScore" placeholder="请输入评估得分" />
      </el-form-item>

      <el-form-item label="股权层级" prop="equityHierarchy" class="one-form-item">
        <el-input v-model="ruleForm.equityHierarchy" placeholder="请输入股权层级" />
      </el-form-item>
      <el-form-item label="评估得分" prop="equityHierarchyScore" class="one-form-item">
        <el-input v-model="ruleForm.equityHierarchyScore" placeholder="请输入评估得分" />
      </el-form-item>
      <el-form-item label="信用评级" prop="creditRating" class="one-form-item">
        <el-input v-model="ruleForm.creditRating" placeholder="请输入信用评级" />
      </el-form-item>
      <el-form-item label="评估得分" prop="creditRatingScore" class="one-form-item">
        <el-input v-model="ruleForm.creditRatingScore" placeholder="请输入评估得分" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    type: {
      type: String,
      default: ''
    },
    details: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      ruleForm: {
        corporateName: '',
        socialCreditCode: '',
        yearsDiff: '',
        companyForProject: '',
        centralizedProcurementPlatform: '',
        establishmentPeriodScore: '',
        registeredCapital: '',
        registeredCapitalScore: '',
        address: '',
        registeredAddressScore: '',
        businessAddress: '',
        businessAddressScore: '',
        enterpriseNature: '',
        enterpriseNatureScore: '',
        holdingRatio: '',
        holdingRatioScore: '',
        equityHierarchy: '',
        equityHierarchyScore: '',
        creditRating: '',
        creditRatingScore: ''
      },
      rules: {}
    }
  },
  watch: {
    details: {
      handler(newV) {
        if (newV && Object.keys(newV)) {
          const details = JSON.parse(JSON.stringify(newV))
          console.log(details)
          for (const k in this.ruleForm) {
            if (details[k] !== '' && details[k] !== null && details[k] !== undefined) {
              this.ruleForm[k] = details[k]
            }
          }
          console.log(this.ruleForm)
        }
      },
      immediate: true,
      deep: true
    }
  }
}
</script>

<style lang="scss" scoped>
.owner-box {
padding: 10px 15px;
}
</style>
