Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(demo): account page table without dept #3164

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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