From fa3ac93010bea3805438ee3ab0a182bfbf7423da Mon Sep 17 00:00:00 2001 From: baoshiwei <baoshiwei@shlanbao.cn> Date: 星期一, 27 五月 2024 16:19:31 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/views/system/dict/dict.data.ts | 184 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 184 insertions(+), 0 deletions(-) diff --git a/src/views/system/dict/dict.data.ts b/src/views/system/dict/dict.data.ts new file mode 100644 index 0000000..c616581 --- /dev/null +++ b/src/views/system/dict/dict.data.ts @@ -0,0 +1,184 @@ +import { BasicColumn } from '/@/components/Table'; +import { FormSchema } from '/@/components/Table'; +import { dictItemCheck } from './dict.api'; +import { rules } from '/@/utils/helper/validator'; +export const columns: BasicColumn[] = [ + { + title: '瀛楀吀鍚嶇О', + dataIndex: 'dictName', + width: 240, + }, + { + title: '瀛楀吀缂栫爜', + dataIndex: 'dictCode', + width: 240, + }, + { + title: '鎻忚堪', + dataIndex: 'description', + // width: 120 + }, +]; + +export const recycleBincolumns: BasicColumn[] = [ + { + title: '瀛楀吀鍚嶇О', + dataIndex: 'dictName', + width: 120, + }, + { + title: '瀛楀吀缂栫爜', + dataIndex: 'dictCode', + width: 120, + }, + { + title: '鎻忚堪', + dataIndex: 'description', + width: 120, + }, +]; + +export const searchFormSchema: FormSchema[] = [ + { + label: '瀛楀吀鍚嶇О', + field: 'dictName', + component: 'Input', + colProps: { span: 6 }, + }, + { + label: '瀛楀吀缂栫爜', + field: 'dictCode', + component: 'Input', + colProps: { span: 6 }, + }, +]; + +export const formSchema: FormSchema[] = [ + { + label: '', + field: 'id', + component: 'Input', + show: false, + }, + { + label: '瀛楀吀鍚嶇О', + field: 'dictName', + required: true, + component: 'Input', + }, + { + label: '瀛楀吀缂栫爜', + field: 'dictCode', + component: 'Input', + dynamicDisabled: ({ values }) => { + return !!values.id; + }, + dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_dict', 'dict_code', model, schema, true), + }, + { + label: '鎻忚堪', + field: 'description', + component: 'Input', + }, +]; + +export const dictItemColumns: BasicColumn[] = [ + { + title: '鍚嶇О', + dataIndex: 'itemText', + width: 80, + }, + { + title: '鏁版嵁鍊�', + dataIndex: 'itemValue', + width: 80, + }, +]; + +export const dictItemSearchFormSchema: FormSchema[] = [ + { + label: '鍚嶇О', + field: 'itemText', + component: 'Input', + }, + { + label: '鐘舵��', + field: 'status', + component: 'JDictSelectTag', + componentProps: { + dictCode: 'dict_item_status', + stringToNumber: true, + }, + }, +]; + +export const itemFormSchema: FormSchema[] = [ + { + label: '', + field: 'id', + component: 'Input', + show: false, + }, + { + label: '鍚嶇О', + field: 'itemText', + required: true, + component: 'Input', + }, + { + label: '鏁版嵁鍊�', + field: 'itemValue', + component: 'Input', + dynamicRules: ({ values, model }) => { + return [ + { + required: true, + validator: (_, value) => { + if (!value) { + return Promise.reject('璇疯緭鍏ユ暟鎹��'); + } + if (new RegExp("[`~!@#$^&*()=|{}'<>銆娿��/?锛侊骏锛堬級鈥斻�愩�戔�橈紱锛氣�濃�溿�傦紝銆侊紵]").test(value)) { + return Promise.reject('鏁版嵁鍊间笉鑳藉寘鍚壒娈婂瓧绗︼紒'); + } + return new Promise<void>((resolve, reject) => { + let params = { + dictId: values.dictId, + id: model.id, + itemValue: value, + }; + dictItemCheck(params) + .then((res) => { + res.success ? resolve() : reject(res.message || '鏍¢獙澶辫触'); + }) + .catch((err) => { + reject(err.message || '楠岃瘉澶辫触'); + }); + }); + }, + }, + ]; + }, + }, + { + label: '鎻忚堪', + field: 'description', + component: 'Input', + }, + { + field: 'sortOrder', + label: '鎺掑簭', + component: 'InputNumber', + defaultValue: 1, + }, + { + field: 'status', + label: '鏄惁鍚敤', + defaultValue: 1, + component: 'JDictSelectTag', + componentProps: { + type: 'radioButton', + dictCode: 'dict_item_status', + stringToNumber: true, + }, + }, +]; -- Gitblit v1.9.3