<template>
  <div class="due-diligence">
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
    >
      <el-form-item label="公司名称">
        <el-input
          v-model="ruleForm.corporateName"
          placeholder="请输入公司名称"
          disabled
        />
      </el-form-item>
      <el-form-item label="统一社会信用代码">
        <el-input
          v-model="ruleForm.socialCreditCode"
          placeholder="请输入统一社会信用代码"
          disabled
        />
      </el-form-item>
      <el-form-item label="尽调预约：">
        <el-radio-group v-model="ruleForm.dueDiligence" disabled>
          <el-radio :label="1">确认</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="联系姓名">
        <el-input
          v-model="ruleForm.contactName"
          placeholder="请输入联系姓名"
          disabled
        />
      </el-form-item>
      <el-form-item label="联系电话" prop="mobile">
        <el-input
          v-model="ruleForm.mobile"
          placeholder="请输入联系电话"
          disabled
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {

  },
  props: {
    dueInfo: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      ruleForm: {
        corporateName: '',
        socialCreditCode: '',
        dueDiligence: 1,
        contactName: '',
        mobile: '',
        code: ''
      },
      rules: {
        mobile: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
        code: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
      }
    }
  },
  watch: {
    dueInfo: {
      handler(newV) {
        if (Object.keys(newV).length) {
          const { corporateName, socialCreditCode, contactName, mobile } = newV
          this.ruleForm = {
            ...this.ruleForm,
            corporateName,
            socialCreditCode,
            contactName,
            mobile
          }
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    validate() {
      return new Promise((resolve, reject) => {
        this.$refs.ruleFormRef.validate(valid => {
          if (valid) {
            resolve(this.ruleForm)
          } else {
            reject()
            return false
          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.due-diligence {
}
</style>
