From ebbd788fbb2c0b45d4473798efc57eec8ba74a25 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期二, 18 六月 2024 14:51:16 +0800 Subject: [PATCH] 版本更新至2.11.5 --- src/views/demo/system/account/account.data.ts | 112 +++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 71 insertions(+), 41 deletions(-) diff --git a/src/views/demo/system/account/account.data.ts b/src/views/demo/system/account/account.data.ts index 8d475eb..9a24fad 100644 --- a/src/views/demo/system/account/account.data.ts +++ b/src/views/demo/system/account/account.data.ts @@ -1,5 +1,27 @@ -import { getAllRoleList, isAccountExist } from '/@/api/demo/system'; -import { BasicColumn, FormSchema } from '/@/components/Table'; +import { getAllRoleList, isAccountExist } from '@/api/demo/system'; +import { BasicColumn, FormSchema } from '@/components/Table'; + +/** + * transform mock data + * { + * 0: '鍗庝笢鍒嗛儴', + * '0-0': '鍗庝笢鍒嗛儴-鐮斿彂閮�' + * '0-1': '鍗庝笢鍒嗛儴-甯傚満閮�', + * ... + * } + */ +export const deptMap = (() => { + const pDept = ['鍗庝笢鍒嗛儴', '鍗庡崡鍒嗛儴', '瑗垮寳鍒嗛儴']; + const cDept = ['鐮斿彂閮�', '甯傚満閮�', '鍟嗗姟閮�', '璐㈠姟閮�']; + + return pDept.reduce((map, p, pIdx) => { + map[pIdx] = p; + + cDept.forEach((c, cIndex) => (map[`${pIdx}-${cIndex}`] = `${p}-${c}`)); + + return map; + }, {}); +})(); export const columns: BasicColumn[] = [ { @@ -26,6 +48,13 @@ title: '瑙掕壊', dataIndex: 'role', width: 200, + }, + { + title: '鎵�灞為儴闂�', + dataIndex: 'dept', + customRender: ({ value }) => { + return deptMap[value]; + }, }, { title: '澶囨敞', @@ -60,10 +89,12 @@ message: '璇疯緭鍏ョ敤鎴峰悕', }, { + trigger: 'blur', validator(_, value) { return new Promise((resolve, reject) => { + if (!value) return resolve(); isAccountExist(value) - .then(() => resolve()) + .then(resolve) .catch((err) => { reject(err.message || '楠岃瘉澶辫触'); }); @@ -72,44 +103,43 @@ }, ], }, - // { - // field: 'pwd', - // label: '瀵嗙爜', - // component: 'InputPassword', - // required: true, - // ifShow: false, - // }, - // { - // label: '瑙掕壊', - // field: 'role', - // component: 'ApiSelect', - // componentProps: { - // api: getAllRoleList, - // labelField: 'roleName', - // valueField: 'roleValue', - // }, - // required: true, - // }, - // { - // field: 'dept', - // label: '鎵�灞為儴闂�', - // component: 'TreeSelect', - // componentProps: { - // fieldNames: { - // label: 'deptName', - // key: 'id', - // value: 'id', - // }, - // getPopupContainer: () => document.body, - // }, - // required: true, - // }, - // { - // field: 'nickname', - // label: '鏄电О', - // component: 'Input', - // required: true, - // }, + { + field: 'pwd', + label: '瀵嗙爜', + component: 'InputPassword', + required: true, + ifShow: false, + }, + { + label: '瑙掕壊', + field: 'role', + component: 'ApiSelect', + componentProps: { + api: getAllRoleList, + labelField: 'roleName', + valueField: 'roleValue', + }, + required: true, + }, + { + field: 'dept', + label: '鎵�灞為儴闂�', + component: 'TreeSelect', + componentProps: { + fieldNames: { + label: 'deptName', + value: 'id', + }, + getPopupContainer: () => document.body, + }, + required: true, + }, + { + field: 'nickname', + label: '鏄电О', + component: 'Input', + required: true, + }, { label: '閭', -- Gitblit v1.9.3