<template>
  <div class="time-confirm-content">
    <cy-info-title>基础信息</cy-info-title>
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-position="top" label-width="120px" class="rule-form-orange">
      <el-form-item label="公司名称" prop="enterpriseName">
        <el-input v-model="detailsInfo.enterpriseName" disabled placeholder="请输入公司名称" />
      </el-form-item>
      <el-form-item label="统一社会信用代码" prop="socialCreditCode">
        <el-input v-model="detailsInfo.socialCreditCode" disabled placeholder="请输入统一社会信用代码" />
      </el-form-item>
      <el-form-item label="尽调时间" prop="dueDiligenceTime">
        <el-date-picker
          v-model="ruleForm.dueDiligenceTime"
          type="date"
          placeholder="选择尽调时间"
          :disabled="disabled"
          value-format="yyyy-MM-dd"
        />
      </el-form-item>
      <el-form-item label="联系人姓名" prop="contactName" class="one-form-item">
        <el-input v-model="ruleForm.contactName" placeholder="请输入联系人姓名" :disabled="disabled" />
      </el-form-item>
      <el-form-item label="联系电话" prop="mobile" class="one-form-item">
        <el-input v-model="ruleForm.mobile" placeholder="请输入联系电话" :disabled="disabled" />
      </el-form-item>
      <el-form-item label="备注" prop="remark" style="width: 100%">
        <el-input
          v-model="ruleForm.remark"
          type="textarea"
          placeholder="请输入备注"
          :rows="3"
          :disabled="disabled"
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    detailsInfo: {
      type: Object,
      default: () => {

      }
    }
  },
  data() {
    return {
      ruleForm: {
        dueDiligenceTime: '',
        contactName: '',
        mobile: '',
        remark: ''
      },
      rules: {
        dueDiligenceTime: [
          { required: true, message: '请选择尽调时间', trigger: 'change' }
        ],
        contactName: [
          { required: true, message: '请输入联系人姓名', trigger: 'blur' }
        ],
        mobile: [
          { required: true, message: '请输入联系电话', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    detailsInfo: {
      handler(newV) {
        const { dueDiligenceTime, contactName, mobile, remark } = newV
        this.ruleForm = {
          dueDiligenceTime: dueDiligenceTime || '',
          contactName,
          mobile,
          remark
        }
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    getParams() {
      return new Promise((resolve, reject) => {
        this.$refs.ruleForm.validate(valid => {
          if (valid) {
            resolve(this.ruleForm)
          } else {
            reject()
            return false
          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
