<template>
  <div>
    <el-form label-position="top" ref="form" :model="data" :rules="rules">
      <el-form-item label="名称" prop="codeTypeName" :error="error.codeTypeName">
        <el-input v-model="data.codeTypeName" maxlength='50'></el-input>
      </el-form-item>
      <el-form-item label="编码" prop="codeTypeValue" :error="error.codeTypeValue">
        <el-input v-model="data.codeTypeValue" maxlength='50'></el-input>
      </el-form-item>
      <el-form-item label="类型" prop="codeKind" :error="error.codeKind">
        <el-radio-group v-model="data.codeKind">
          <el-radio label="1">列表</el-radio>
          <el-radio label="2">树状</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>

    <OptionHistory v-if="data.uuid" :data="data"></OptionHistory>
  </div>
</template>
<script>
  import OptionHistory from "@/common/OptionHistory";

  export default {
    components: {OptionHistory},
    props: {
      data: Object,
      error: Object
    },
    data() {
      return {
        rules: {
          codeTypeName: [{required: true, message: "请输入代码标识!"}],
          codeTypeValue: [{required: true, message: "请输入代码名称!"}]
        }
      };
    },
    methods: {
      // 因为表单里面没有按钮,所以需要暴露方法
      // 提供一个校验方法 ,
      validate() {
        return this.$refs.form.validate().then(() => this.data);
      }
    }
  };
</script>
