dict.item.data.ts 2.6 KB
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '文本值',
    dataIndex: 'itemText',
    width: 160,
  },
  {
    title: '字典值',
    dataIndex: 'itemValue',
    width: 180,
  },
  {
    title: '描述',
    dataIndex: 'description',
    width: 180,
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 100,
    slots: { customRender: 'status' },
  },
  {
    title: '排序',
    dataIndex: 'sort',
    width: 80,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'itemText',
    label: '文本值',
    component: 'Input',
    colProps: { span: 6 },
    componentProps: {
      maxLength: 32,
      placeholder: '请输入文本值',
    },
    dynamicRules: () => {
      return [
        {
          required: false,
          validator: (_, value) => {
            if (String(value).length > 32) {
              return Promise.reject('字数不超过32个字');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'dictId',
    label: '文本值',
    component: 'Input',
    show: false,
    componentProps: {
      maxLength: 36,
      placeholder: '请输入文本值',
    },
    dynamicRules: () => {
      return [
        {
          required: false,
          validator: (_, value) => {
            if (String(value).length > 36) {
              return Promise.reject('字数不超过36个字');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'itemText',
    label: '文本值',
    required: true,
    component: 'Input',
    componentProps: {
      maxLength: 32,
      placeholder: '请输入文本值',
    },
  },
  {
    field: 'itemValue',
    label: '字典值',
    required: true,
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入字典值',
    },
  },
  {
    field: 'sort',
    label: '排序',
    component: 'InputNumber',
    defaultValue: 1,
    componentProps: {
      maxLength: 32,
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'RadioButtonGroup',
    defaultValue: 1,
    componentProps: {
      options: [
        { label: '禁用', value: 0 },
        { label: '启用', value: 1 },
      ],
    },
  },
  {
    label: '备注',
    field: 'description',
    component: 'InputTextArea',
    componentProps: {
      maxLength: 255,
    },
  },
];