Commit 66b49abd8f827cb40efc7f56bcf21d144b590dfc
1 parent
382ad6f3
fix:修改日志管理下的登录、异常、操作日志表格格式化中文和查询请求字典
Showing
3 changed files
with
91 additions
and
37 deletions
1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
2 | 2 | import moment from 'moment'; |
3 | +import { findDictItemByCode } from '/@/api/system/dict'; | |
3 | 4 | |
5 | +//格式化资源类型和操作类型 | |
6 | +let formatText; | |
7 | +let actionTypeText; | |
8 | +async function formatTextFunc() { | |
9 | + formatText = await findDictItemByCode({ dictCode: 'operate_log' }); | |
10 | + actionTypeText = await findDictItemByCode({ dictCode: 'exception_log' }); | |
11 | +} | |
12 | +formatTextFunc(); | |
4 | 13 | // 表格数据 |
5 | 14 | export const columns: BasicColumn[] = [ |
6 | 15 | { |
... | ... | @@ -17,6 +26,14 @@ export const columns: BasicColumn[] = [ |
17 | 26 | title: '资源类型', |
18 | 27 | dataIndex: 'entityType', |
19 | 28 | width: 180, |
29 | + format: (_, record) => { | |
30 | + const text = formatText.find((f) => { | |
31 | + if (f.itemValue == record.entityType) { | |
32 | + return f.itemText; | |
33 | + } | |
34 | + }); | |
35 | + return text?.itemText; | |
36 | + }, | |
20 | 37 | }, |
21 | 38 | { |
22 | 39 | title: '资源名称', |
... | ... | @@ -32,18 +49,29 @@ export const columns: BasicColumn[] = [ |
32 | 49 | title: '操作类型', |
33 | 50 | dataIndex: 'actionType', |
34 | 51 | width: 180, |
52 | + format: (_, record) => { | |
53 | + const text = actionTypeText.find((f) => { | |
54 | + if (f.itemValue == record.actionType) { | |
55 | + return f.itemText; | |
56 | + } | |
57 | + }); | |
58 | + return text?.itemText; | |
59 | + }, | |
35 | 60 | }, |
36 | 61 | { |
37 | 62 | title: '操作状态', |
38 | 63 | dataIndex: 'actionStatus', |
39 | 64 | width: 180, |
65 | + format: (_, record) => { | |
66 | + return record.actionStatus == 'SUCCESS' ? '成功' : '失败'; | |
67 | + }, | |
40 | 68 | }, |
41 | 69 | { |
42 | 70 | title: '操作时间', |
43 | 71 | dataIndex: 'createdTime', |
44 | - width: 80, | |
72 | + width: 180, | |
45 | 73 | format: (_, record) => { |
46 | - return moment(record.createdTime).format('YYYY-MM-DD'); | |
74 | + return moment(record.createdTime).format('YYYY-MM-DD-HH-MM-ss'); | |
47 | 75 | }, |
48 | 76 | }, |
49 | 77 | ]; | ... | ... |
1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
2 | 2 | import moment from 'moment'; |
3 | +import { findDictItemByCode } from '/@/api/system/dict'; | |
3 | 4 | |
5 | +//格式化资源类型和操作类型 | |
6 | +let formatText; | |
7 | +let actionTypeText; | |
8 | + | |
9 | +async function formatTextFunc() { | |
10 | + formatText = await findDictItemByCode({ dictCode: 'operate_log' }); | |
11 | + actionTypeText = await findDictItemByCode({ dictCode: 'exception_log' }); | |
12 | +} | |
13 | +formatTextFunc(); | |
4 | 14 | // 表格数据 |
5 | 15 | export const columns: BasicColumn[] = [ |
6 | 16 | { |
... | ... | @@ -17,6 +27,14 @@ export const columns: BasicColumn[] = [ |
17 | 27 | title: '资源类型', |
18 | 28 | dataIndex: 'entityType', |
19 | 29 | width: 180, |
30 | + format: (_, record) => { | |
31 | + const text = formatText.find((f) => { | |
32 | + if (f.itemValue == record.entityType) { | |
33 | + return f.itemText; | |
34 | + } | |
35 | + }); | |
36 | + return text?.itemText; | |
37 | + }, | |
20 | 38 | }, |
21 | 39 | { |
22 | 40 | title: '资源名称', |
... | ... | @@ -32,18 +50,29 @@ export const columns: BasicColumn[] = [ |
32 | 50 | title: '操作类型', |
33 | 51 | dataIndex: 'actionType', |
34 | 52 | width: 180, |
53 | + format: (_, record) => { | |
54 | + const text = actionTypeText.find((f) => { | |
55 | + if (f.itemValue == record.actionType) { | |
56 | + return f.itemText; | |
57 | + } | |
58 | + }); | |
59 | + return text?.itemText; | |
60 | + }, | |
35 | 61 | }, |
36 | 62 | { |
37 | 63 | title: '操作状态', |
38 | 64 | dataIndex: 'actionStatus', |
39 | 65 | width: 180, |
66 | + format: (_, record) => { | |
67 | + return record.actionStatus == 'SUCCESS' ? '成功' : '失败'; | |
68 | + }, | |
40 | 69 | }, |
41 | 70 | { |
42 | 71 | title: '操作时间', |
43 | 72 | dataIndex: 'createdTime', |
44 | - width: 80, | |
73 | + width: 180, | |
45 | 74 | format: (_, record) => { |
46 | - return moment(record.createdTime).format('YYYY-MM-DD'); | |
75 | + return moment(record.createdTime).format('YYYY-MM-DD-HH-MM-ss'); | |
47 | 76 | }, |
48 | 77 | }, |
49 | 78 | ]; |
... | ... | @@ -53,30 +82,28 @@ export const searchFormSchema: FormSchema[] = [ |
53 | 82 | { |
54 | 83 | field: 'entityType', |
55 | 84 | label: '资源类型', |
56 | - component: 'Select', | |
85 | + component: 'ApiSelect', | |
57 | 86 | componentProps: { |
58 | - options: [ | |
59 | - { label: 'DEVICE', value: 'DEVICE' }, | |
60 | - { label: 'DEVICE_PROFILE', value: 'DEVICE_PROFILE' }, | |
61 | - { label: 'RPC', value: 'RPC' }, | |
62 | - { label: 'TENANT', value: 'TENANT' }, | |
63 | - { label: 'TENANT_PROFILE', value: 'TENANT_PROFILE' }, | |
64 | - ], | |
87 | + api: findDictItemByCode, | |
88 | + params: { | |
89 | + dictCode: 'operate_log', | |
90 | + }, | |
91 | + labelField: 'itemText', | |
92 | + valueField: 'itemValue', | |
65 | 93 | }, |
66 | 94 | colProps: { span: 6 }, |
67 | 95 | }, |
68 | 96 | { |
69 | 97 | field: 'actionType', |
70 | 98 | label: '操作类型', |
71 | - component: 'Select', | |
99 | + component: 'ApiSelect', | |
72 | 100 | componentProps: { |
73 | - options: [ | |
74 | - { label: 'ALL', value: '' }, | |
75 | - { label: 'ADDED', value: 'ADDED' }, | |
76 | - { label: 'DELETED', value: 'DELETED' }, | |
77 | - { label: 'RPC_CALL', value: 'RPC_CALL' }, | |
78 | - { label: 'UPDATED', value: 'UPDATED' }, | |
79 | - ], | |
101 | + api: findDictItemByCode, | |
102 | + params: { | |
103 | + dictCode: 'exception_log', | |
104 | + }, | |
105 | + labelField: 'itemText', | |
106 | + valueField: 'itemValue', | |
80 | 107 | }, |
81 | 108 | colProps: { span: 6 }, |
82 | 109 | }, | ... | ... |
1 | 1 | import { BasicColumn, FormSchema } from '/@/components/Table'; |
2 | 2 | import moment from 'moment'; |
3 | +import { findDictItemByCode } from '/@/api/system/dict'; | |
3 | 4 | |
4 | 5 | // 表格数据 |
5 | 6 | export const columns: BasicColumn[] = [ |
... | ... | @@ -14,16 +15,6 @@ export const columns: BasicColumn[] = [ |
14 | 15 | width: 120, |
15 | 16 | }, |
16 | 17 | { |
17 | - title: '资源类型', | |
18 | - dataIndex: 'entityType', | |
19 | - width: 180, | |
20 | - }, | |
21 | - { | |
22 | - title: '资源名称', | |
23 | - dataIndex: 'entityName', | |
24 | - width: 180, | |
25 | - }, | |
26 | - { | |
27 | 18 | title: '操作人员', |
28 | 19 | dataIndex: 'userName', |
29 | 20 | width: 180, |
... | ... | @@ -32,18 +23,24 @@ export const columns: BasicColumn[] = [ |
32 | 23 | title: '操作类型', |
33 | 24 | dataIndex: 'actionType', |
34 | 25 | width: 180, |
26 | + format: (_, record) => { | |
27 | + return record.actionType == 'LOGIN' ? '登录' : '登出'; | |
28 | + }, | |
35 | 29 | }, |
36 | 30 | { |
37 | 31 | title: '操作状态', |
38 | 32 | dataIndex: 'actionStatus', |
39 | 33 | width: 180, |
34 | + format: (_, record) => { | |
35 | + return record.actionStatus == 'SUCCESS' ? '成功' : '失败'; | |
36 | + }, | |
40 | 37 | }, |
41 | 38 | { |
42 | 39 | title: '操作时间', |
43 | 40 | dataIndex: 'createdTime', |
44 | - width: 80, | |
41 | + width: 180, | |
45 | 42 | format: (_, record) => { |
46 | - return moment(record.createdTime).format('YYYY-MM-DD'); | |
43 | + return moment(record.createdTime).format('YYYY-MM-DD-HH-MM-ss'); | |
47 | 44 | }, |
48 | 45 | }, |
49 | 46 | ]; |
... | ... | @@ -53,12 +50,14 @@ export const searchFormSchema: FormSchema[] = [ |
53 | 50 | { |
54 | 51 | field: 'actionType', |
55 | 52 | label: '操作类型', |
56 | - component: 'Select', | |
53 | + component: 'ApiSelect', | |
57 | 54 | componentProps: { |
58 | - options: [ | |
59 | - { label: 'LOGIN', value: 'LOGIN' }, | |
60 | - { label: 'LOGOUT', value: 'LOGOUT' }, | |
61 | - ], | |
55 | + api: findDictItemByCode, | |
56 | + params: { | |
57 | + dictCode: 'user_log', | |
58 | + }, | |
59 | + labelField: 'itemText', | |
60 | + valueField: 'itemValue', | |
62 | 61 | }, |
63 | 62 | colProps: { span: 6 }, |
64 | 63 | }, | ... | ... |