<template>
  <a-form ref="formRef" :model="form" :rules="rules" layout="vertical">
    <a-row :gutter="20">
      <a-col :span="24">
        <a-form-item label="分类名称:" name="categoryName">
          <a-input v-model:value="form.categoryName" allow-clear placeholder="请输入分类名称" />
        </a-form-item>
      </a-col>
      <a-col :span="18">
        <a-form-item label="分类编码:" name="categoryCode">
          <a-input v-model:value="form.categoryCode" allow-clear placeholder="请输入分类编码" :disabled="props.isUpdate" />
        </a-form-item>
      </a-col>
      <a-col :span="6">
        <a-form-item label="排序:" name="fldSort">
          <a-input-number
            v-model:value="form.fldSort"
            :min="0"
            style="width: 100%"
            placeholder="请输入排序"
            allow-clear
            autocomplete="off"
          />
        </a-form-item>
      </a-col>
    </a-row>
  </a-form>
</template>

<script setup name="ListTypeForm">
import { reactive } from 'vue';

const props = defineProps({
  // 表单数据
  form: Object,
  isUpdate: Boolean
});

// 验证规则
const rules = reactive({
  categoryName: [{ required: true, message: '请输入分类名称', type: 'string', trigger: 'blur' }],
  categoryCode: [{ required: true, message: '请输入分类编码', type: 'string', trigger: 'blur' }],
  fldSort: [{ required: true, message: '请输入排序', type: 'number', trigger: 'blur' }]
});
</script>

<style></style>
