Skip to content

Commit

Permalink
fix(demo): account page table without dept (#3164)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaowoxiaobala authored Oct 17, 2023
1 parent 1a5bedd commit 40aac65
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions mock/demo/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const accountList = (() => {
role: '@first',
createTime: '@datetime',
remark: '@cword(10,20)',
'dept|0-2': 1,
'status|1': ['0', '1'],
});
}
Expand Down
29 changes: 29 additions & 0 deletions src/views/demo/system/account/account.data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
import { getAllRoleList, isAccountExist } from '/@/api/demo/system';
import { BasicColumn, FormSchema } from '/@/components/Table';

/**
* transform mock data
* {
* 0: '华东分部',
* '0-0': '华东分部-研发部'
* '0-1': '华东分部-市场部',
* ...
* }
*/
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[] = [
{
title: '用户名',
Expand All @@ -27,6 +49,13 @@ export const columns: BasicColumn[] = [
dataIndex: 'role',
width: 200,
},
{
title: '所属部门',
dataIndex: 'dept',
customRender: ({ value }) => {
return deptMap[value];
},
},
{
title: '备注',
dataIndex: 'remark',
Expand Down

0 comments on commit 40aac65

Please sign in to comment.