<script>
export default {
  name: "ZooBreedingFormDialog",
  data() {
    return {
      form: {
        id: '',//int 饲养计划id
        name: '',//字符 饲养计划名称
        species: '',//字符 种类
        sex: '雄性',//字符 饲养动物性别
        phase: '',//字符 饲养动物阶段：幼年期、成长期、成年期、老年期
        state: 0,//int 状态（0正常 1异常）
        roleId: null,//负责执行计划的饲养员id
        describe: ''//字符 饲养计划的描述
      },
      formAction: {
        idDisable: false,
      }
    }
  },
  props: {
    breedingPlan: {
      type: Object,
    }
  },
  mounted() {
    // 如果传入了对象，说明是编辑
    if (this.breedingPlan) {
      this.form = this.breedingPlan
      this.formAction.idDisable = true
    }
  },
  beforeUnmount() {
    console.log('ZooBreedingFormDialog-beforeUnmount', this);
  }
}
</script>

<template>
  <el-form label-width="auto">
    <el-form-item label="饲养计划ID">
      <el-input v-model="form.id" type="number" placeholder="饲养计划ID" :disabled="formAction.idDisable"/>
    </el-form-item>
    <el-form-item label="计划名称">
      <el-input v-model="form.name" placeholder="计划名称"/>
    </el-form-item>
    <el-form-item label="动物种类">
      <el-input v-model="form.species" placeholder="动物种类"/>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="form.sex">
        <el-radio value="雄性">雄性</el-radio>
        <el-radio value="雌性">雌性</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="生命阶段">
      <el-select v-model="form.phase" placeholder="生命阶段">
        <el-option label="幼年期" :value="0"/>
        <el-option label="成长期" :value="1"/>
        <el-option label="成年期" :value="2"/>
        <el-option label="老年期" :value="3"/>
      </el-select>
    </el-form-item>
    <el-form-item label="动物状态">
      <el-radio-group v-model="form.state">
        <el-radio :value="0">正常</el-radio>
        <el-radio :value="1">异常</el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="执行饲养员">
      <el-input v-model="form.roleId" type="number" placeholder="执行饲养员"/>
    </el-form-item>
    <el-form-item label="计划描述">
      <el-input
          v-model="form.describe"
          :rows="4"
          type="textarea"
          placeholder="计划描述"
          resize="none"
      />
    </el-form-item>
    <div class="right">
      <slot :form="form"></slot>
    </div>
  </el-form>
</template>

<style scoped>

</style>