<template>
  <div class="cooperation-box">
    <el-form
      :model="ruleForm"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
    >
      <el-form-item label="本次拟合作金额（万元）">
        <cy-amount-input
          :value="ruleForm.cooperationAmount"
          placeholder="请输入本次拟合作金额（万元）"
          unit-name="CNY"
          is-unit
        />
      </el-form-item>
      <el-form-item label="月供货峰值（万元）">
        <cy-amount-input
          :value="ruleForm.peakValue"
          placeholder="请输入月供货峰值（万元）"
          unit-name="CNY"
          is-unit
        />
      </el-form-item>
      <el-form-item label="本次用款高峰值（万元）">
        <cy-amount-input
          :value="ruleForm.highPeakUsage"
          placeholder="请输入本次用款高峰值（万元）"
          unit-name="CNY"
          is-unit
        />
      </el-form-item>
      <el-form-item label="预估账期（月）">
        <el-input
          :value="ruleForm.estimatedAccountingPeriod"
          placeholder="请输入预估账期"
        />
      </el-form-item>
      <el-form-item label="评估得分">
        <el-input
          :value="ruleForm.estimatedAccountingPeriodScore"
          placeholder="请输入评估得分"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    details: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      ruleForm: {
        cooperationAmount: '',
        peakValue: '',
        estimatedAccountingPeriod: '',
        highPeakUsage: '',
        estimatedAccountingPeriodScore: ''
      }
    }
  },
  watch: {
    details: {
      handler(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]
            }
          }
        }
      },
      immediate: true,
      deep: true
    }
  }
}
</script>

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