<template>
  <div class="project-owner-info">

    <enterprise-inspection ref="enterpriseInspection" :inspection-data="inspectionData" />
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
    >
      <el-form-item
        label="是否为项目成立的公司"
        prop="companyForProject"
        class="industry"
      >
        <el-radio-group v-model="ruleForm.companyForProject">
          <el-radio :label="1">是</el-radio>
          <el-radio :label="0">否</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {
    EnterpriseInspection: () => import('../../components/EnterpriseInspection')
  },
  data() {
    return {
      inspectionData: {
        company: {
          key: 'corporateName',
          name: '项目业主方公司名称'
        }
      },
      ruleForm: {
        companyForProject: ''
      },
      rules: {
        companyForProject: [
          { required: true, message: '请选择是否为项目成立的公司', trigger: 'change' }
        ]
      }
    }
  },
  methods: {
    async validate() {
      const enterprise = await this.$refs.enterpriseInspection.validate()
      return new Promise((resolve, reject) => {
        this.$refs.ruleFormRef.validate(valid => {
          if (valid) {
            const projectOwnerInfo = {
              ...this.ruleForm,
              enterprise
            }
            return resolve(projectOwnerInfo)
          } else {
            reject()
            return false
          }
        })
      })
    }

  }
}
</script>

<style lang="scss" scoped>
.project-owner-info {
  padding: 10px 20px;
}
</style>
