| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import type { VbenFormSchema } from '#/adapter/form' |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table' |
| | | |
| | | import { CommonStatusEnum, DICT_TYPE } from '#/packages/constants/src' |
| | | import { getDictOptions } from '#/packages/effects/hooks/src' |
| | | |
| | | import { z } from '#/adapter/form' |
| | | |
| | | /** æ°å¢/ä¿®æ¹ç表å */ |
| | | export function useFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'id', |
| | | component: 'Input', |
| | | dependencies: { |
| | | triggerFields: [''], |
| | | show: () => false |
| | | } |
| | | }, |
| | | { |
| | | fieldName: 'code', |
| | | label: 'é¢éç¼ç ', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: 'å¦ system_notice' |
| | | }, |
| | | rules: z |
| | | .string({ message: 'é¢éç¼ç ä¸è½ä¸ºç©º' }) |
| | | .regex(/^[a-z][a-z0-9_]*$/, 'åªè½ç±å°å忝 / æ°å / ä¸åçº¿ç»æï¼ä¸ä»¥åæ¯å¼å¤´') |
| | | }, |
| | | { |
| | | fieldName: 'name', |
| | | label: 'é¢éåç§°', |
| | | component: 'Input', |
| | | componentProps: { |
| | | placeholder: 'å¦ ç³»ç»å
Œ' |
| | | }, |
| | | rules: 'required' |
| | | }, |
| | | { |
| | | fieldName: 'avatar', |
| | | label: 'é¢é头å', |
| | | component: 'ImageUpload', |
| | | componentProps: { |
| | | maxNumber: 1 |
| | | }, |
| | | rules: 'required' |
| | | }, |
| | | { |
| | | fieldName: 'sort', |
| | | label: 'æåº', |
| | | component: 'InputNumber', |
| | | componentProps: { |
| | | min: 0 |
| | | }, |
| | | rules: z.number().default(0) |
| | | }, |
| | | { |
| | | fieldName: 'status', |
| | | label: 'ç¶æ', |
| | | component: 'RadioGroup', |
| | | componentProps: { |
| | | options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), |
| | | buttonStyle: 'solid', |
| | | optionType: 'button' |
| | | }, |
| | | rules: z.number().default(CommonStatusEnum.ENABLE) |
| | | } |
| | | ] |
| | | } |
| | | |
| | | /** å表çæç´¢è¡¨å */ |
| | | export function useGridFormSchema(): VbenFormSchema[] { |
| | | return [ |
| | | { |
| | | fieldName: 'code', |
| | | label: 'ç¼ç ', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: 'é¢éä¸å¡ç ' |
| | | } |
| | | }, |
| | | { |
| | | fieldName: 'name', |
| | | label: 'åç§°', |
| | | component: 'Input', |
| | | componentProps: { |
| | | allowClear: true, |
| | | placeholder: 'é¢éåç§°' |
| | | } |
| | | }, |
| | | { |
| | | fieldName: 'status', |
| | | label: 'ç¶æ', |
| | | component: 'Select', |
| | | componentProps: { |
| | | allowClear: true, |
| | | options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), |
| | | placeholder: 'è¯·éæ©ç¶æ' |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | |
| | | /** å表çåæ®µ */ |
| | | export function useGridColumns(): VxeTableGridOptions['columns'] { |
| | | return [ |
| | | { |
| | | field: 'id', |
| | | title: 'ç¼å·', |
| | | width: 80 |
| | | }, |
| | | { |
| | | field: 'avatar', |
| | | title: '头å', |
| | | width: 80, |
| | | slots: { default: 'avatar' } |
| | | }, |
| | | { |
| | | field: 'code', |
| | | title: 'ç¼ç ', |
| | | minWidth: 160 |
| | | }, |
| | | { |
| | | field: 'name', |
| | | title: 'åç§°', |
| | | minWidth: 140 |
| | | }, |
| | | { |
| | | field: 'sort', |
| | | title: 'æåº', |
| | | width: 80 |
| | | }, |
| | | { |
| | | field: 'status', |
| | | title: 'ç¶æ', |
| | | width: 100, |
| | | cellRender: { |
| | | name: 'CellDict', |
| | | props: { type: DICT_TYPE.COMMON_STATUS } |
| | | } |
| | | }, |
| | | { |
| | | field: 'createTime', |
| | | title: 'å建æ¶é´', |
| | | minWidth: 180, |
| | | formatter: 'formatDateTime' |
| | | }, |
| | | { |
| | | title: 'æä½', |
| | | width: 160, |
| | | fixed: 'right', |
| | | slots: { default: 'actions' } |
| | | } |
| | | ] |
| | | } |