<template>
  <div class="basic-info">
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
    >
      <el-form-item label="公司名称" prop="supplierEnterpriseName">
        <el-input v-model="ruleForm.supplierEnterpriseName" placeholder="请输入公司名称" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    baseInfo: {
      type: Object,
      default: () => {}
    }

  },
  data() {
    return {
      ruleForm: {
        supplierEnterpriseName: ''
      },
      rules: {
        supplierEnterpriseName: [
          { required: true, message: '公司名称不能为空', trigger: 'change' }
        ]
      }
    }
  },
  watch: {
    baseInfo: {
      handler(newV) {
        if (newV && Object.keys(newV)) {
          this.ruleForm.supplierEnterpriseName = newV.supplierEnterpriseName
        }
      },
      immediate: true,
      deep: true
    }
  },
  created() {
    this.ruleForm.supplierEnterpriseName = this.$route.query.enterpriseName
  },
  methods: {
    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>
.basic-info {
padding: 10px 20px;
}

</style>
