1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
| import { BasicColumn, FormSchema } from '/@/components/Table';
| import { h } from 'vue';
| import { Switch } from 'ant-design-vue';
| import { setRoleStatus } from '/@/api/tigerapi/system';
| import { useMessage } from '/@/hooks/web/useMessage';
|
| export const columns: BasicColumn[] = [
| {
| title: '角色名称',
| dataIndex: 'ROLE_DESC',
| width: 200,
| },
| {
| title: '角色值',
| dataIndex: 'ROLE_CODE',
| width: 180,
| },
| //{
| // title: '排序',
| // dataIndex: 'orderNo',
| // width: 50,
| //},
| {
| title: '状态',
| dataIndex: 'IS_ACTIVE',
| width: 120,
| customRender: ({ record }) => {
| if (!Reflect.has(record, 'pendingStatus')) {
| record.pendingStatus = false;
| }
| return h(Switch, {
| checked: record.IS_ACTIVE === 'Y',
| checkedChildren: '已启用',
| unCheckedChildren: '已禁用',
| loading: record.pendingStatus,
| onChange(checked: boolean) {
| const oldStatus = record.IS_ACTIVE;
| record.pendingStatus = true;
| const newStatus = checked ? 'Y' : 'N';
| console.log(10, newStatus);
| const { createMessage } = useMessage();
| record.IS_ACTIVE = newStatus;
| setRoleStatus(record)
| .then(() => {
| createMessage.success(`已成功修改角色状态`);
| })
| .catch(() => {
| createMessage.error('修改角色状态失败');
| record.IS_ACTIVE = oldStatus;
| })
| .finally(() => {
| record.pendingStatus = false;
| });
| },
| });
| },
| editDynamicDisabled: true,
| },
| {
| title: '创建时间',
| dataIndex: 'CREATE_TIME',
| width: 180,
| },
| //{
| // title: '备注',
| // dataIndex: 'remark',
| //},
| ];
|
| export const searchFormSchema: FormSchema[] = [
| {
| field: 'ROLE_DESC',
| label: '角色名称',
| component: 'Input',
| colProps: { span: 8 },
| },
| {
| field: 'IS_ACTIVE',
| label: '状态',
| component: 'Select',
| componentProps: {
| options: [
| { label: '启用', value: 'Y' },
| { label: '停用', value: 'N' },
| ],
| },
| colProps: { span: 8 },
| },
| ];
|
| const isMenu = (type: number) => type === 0;
| const isOrg = (type: number) => type === 1;
| const isFty = (type: number) => type === 2;
| const isWh = (type: number) => type === 3;
| export const formSchema: FormSchema[] = [
| {
| field: 'ROLE_DESC',
| label: '角色名称',
| required: true,
| component: 'Input',
| colProps: {
| span: 24,
| },
| },
| {
| field: 'ROLE_CODE',
| label: '角色值',
| required: true,
| component: 'Input',
| colProps: {
| span: 24,
| },
| },
| {
| field: 'ID',
| label: '角色ID',
| component: 'Input',
| show: false,
| colProps: {
| span: 24,
| },
| },
| {
| field: 'IS_ACTIVE',
| label: '状态',
| component: 'RadioButtonGroup',
| defaultValue: 'N',
| colProps: {
| span: 24,
| },
| componentProps: {
| options: [
| { label: '启用', value: 'Y' },
| { label: '停用', value: 'N' },
| ],
| },
| },
| {
| field: 'DATA_TYPE',
| label: '权限分配',
| component: 'RadioButtonGroup',
| defaultValue: 0,
| componentProps: ({ schema, tableAction, formActionType, formModel }) => {
| return {
| options: [
| { label: '菜单分配', value: 0 },
| { label: '组织分配', value: 1 },
| { label: '工厂分配', value: 2 },
| { label: '仓库分配', value: 3 },
| ],
| onChange: (e) => {},
| };
| },
| colProps: { lg: 24, md: 24 },
| },
| {
| label: ' ',
| field: 'menu',
| slot: 'menu',
| component: 'Input',
| colProps: {
| span: 24,
| },
| ifShow: ({ values }) => isMenu(values.DATA_TYPE),
| },
| {
| label: ' ',
| field: 'org',
| slot: 'org',
| component: 'Input',
| colProps: {
| span: 24,
| },
| ifShow: ({ values }) => isOrg(values.DATA_TYPE),
| },
| {
| label: ' ',
| field: 'fty',
| slot: 'fty',
| component: 'Input',
| colProps: {
| span: 24,
| },
| ifShow: ({ values }) => isFty(values.DATA_TYPE),
| },
| {
| label: ' ',
| field: 'wh',
| slot: 'wh',
| component: 'Input',
| colProps: {
| span: 24,
| },
| ifShow: ({ values }) => isWh(values.DATA_TYPE),
| },
| ];
|
|