<template>
  <div class="enterprise-inspection">
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
    >
      <el-form-item :label="formlabel.company" prop="corporateName" class="two-form-item">
        <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-input
          v-model="ruleForm.legalRepresentative"
          placeholder="请输入法人代表"
          disabled
        />
      </el-form-item>
      <el-form-item label="成立日期">
        <el-input
          v-model="ruleForm.startSate"
          placeholder="请输入成立日期"
          disabled
        />
      </el-form-item>
      <el-form-item label="注册资本">
        <el-input
          v-model="ruleForm.registeredCapital"
          placeholder="请输入注册资本"
          disabled
        />
      </el-form-item>
      <el-form-item label="注册地址" style="width: 100%; border-bottom: 0px">
        <el-input
          v-model="ruleForm.address"
          placeholder="请输入注册地址"
          disabled
        />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {
    // CustomSelect: () => import('@/components/CustomSelect/index.vue')
  },
  props: {
    enterpriseInspection: {
      type: Object,
      default: () => {}
    }
    // 'formStyle': {
    //   type: Object,
    //   default: () => {}
    // },
    // inspectionData: {
    //   type: [Object],
    //   default: () => {}
    // },
    // source: {
    //   type: String,
    //   default: ''
    // }
  },
  data() {
    return {
      formlabel: {
        company: '公司名称',
        key: 'corporateName'
      },
      listData: [],
      ruleForm: {
        corporateName: '',
        socialCreditCode: '',
        legalRepresentative: '',
        startSate: '',
        registeredCapital: '',
        address: ''
      },
      rules: {
        // corporateName: [
        //   { required: true, message: `请输入${this.inspectionData?.company?.name || '公司名称'}`, trigger: 'change' }
        // ]
      }
    }
  },
  watch: {
    // inspectionData: {
    //   handler(newV) {
    //     if (newV && Object.keys(newV).length) {
    //       const { company } = newV
    //       if (company) {
    //         this.formlabel.company = company.name
    //         this.formlabel.key = company.key
    //       }
    //     }
    //   },
    //   immediate: true,
    //   deep: true
    // }
    enterpriseInspection: {
      handler(newV) {
        if (newV && Object.keys(newV).length) {
          const { corporateName, socialCreditCode, legalRepresentative, startSate, registeredCapital, address } = newV
          this.ruleForm = {
            corporateName,
            socialCreditCode,
            legalRepresentative,
            startSate,
            registeredCapital,
            address
          }
        }
      },
      immediate: true,
      deep: true
    }
  },
  methods: {
    // searchClick(val) {
    //   getEnterpriseInspectionInfo({ keyword: val }).then(({ data }) => {
    //     this.listData = data
    //   })
    // },
    // searchChange(val) {
    //   const { socialCreditCode, legalRepresentative, startSate, registeredCapital, address } = this.listData.find(item => item.corporateName === val)
    //   this.ruleForm = {
    //     ...this.ruleForm,
    //     socialCreditCode,
    //     legalRepresentative,
    //     startSate,
    //     registeredCapital,
    //     address
    //   }

    //   if (this.source !== '' && this.source === 'projectAdd') {
    //     console.log('send')
    //     window.$bus.$emit('sendCoreName', this.ruleForm.corporateName)
    //   }
    // },
    validate() {
      return new Promise((resolve, reject) => {
        this.$refs.ruleFormRef.validate(valid => {
          if (valid) {
            return resolve(this.ruleForm)
          } else {
            reject()
            return false
          }
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.enterprise-inspection {
}
</style>
