sohelp-eleplus 1.1.27 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.js +1 -0
- package/package.json +2 -2
- package/sohelp-ace-editor/README.md +32 -42
- package/sohelp-ace-editor/index.vue +166 -156
- package/sohelp-api-doc/README.md +36 -0
- package/sohelp-api-doc/index.vue +160 -0
- package/sohelp-application-select/README.md +9 -7
- package/sohelp-application-select/index.vue +10 -13
- package/sohelp-autocode/README.md +14 -26
- package/sohelp-calendar-view/README.md +9 -7
- package/sohelp-calendar-view/index.vue +10 -9
- package/sohelp-card/README.md +15 -17
- package/sohelp-card/index.vue +1 -1
- package/sohelp-card-view/README.md +9 -7
- package/sohelp-card-view/index.vue +10 -9
- package/sohelp-condition/README.md +29 -49
- package/sohelp-condition/index.vue +2 -1
- package/sohelp-country-select/README.md +15 -123
- package/sohelp-cry-input/README.md +19 -195
- package/sohelp-cry-input/index.vue +5 -1
- package/sohelp-date/README.md +12 -15
- package/sohelp-datetime/README.md +15 -17
- package/sohelp-datetime-picker/README.md +18 -18
- package/sohelp-datetime-picker/index.vue +11 -4
- package/sohelp-datetime-range/README.md +20 -23
- package/sohelp-demo-block/README.md +43 -0
- package/sohelp-demo-block/index.vue +229 -0
- package/sohelp-dict/README.md +28 -23
- package/sohelp-dict/index.vue +17 -17
- package/sohelp-drawer/README.md +28 -26
- package/sohelp-drop-card/README.md +29 -28
- package/sohelp-drop-card/index.vue +0 -1
- package/sohelp-dyn-select/README.md +31 -16
- package/sohelp-dyn-select/index.vue +65 -67
- package/sohelp-dyn-tree/README.md +26 -20
- package/sohelp-dyn-tree/index.vue +2 -2
- package/sohelp-dyn-tree-select/README.md +28 -19
- package/sohelp-dyn-tree-select/index.vue +23 -7
- package/sohelp-entity-form/README.md +65 -30
- package/sohelp-entity-form/index.vue +3 -2
- package/sohelp-entity-grid/README.md +13 -11
- package/sohelp-entity-grid/index.vue +1 -1
- package/sohelp-file-upload/README.md +25 -27
- package/sohelp-file-upload/index.vue +1 -1
- package/sohelp-filter-scheme/README.md +34 -30
- package/sohelp-filter-scheme/index.vue +2 -2
- package/sohelp-grid/README.md +52 -33
- package/sohelp-grid/index.vue +2217 -2210
- package/sohelp-grid/js/SohelpGridConfig.js +3 -3
- package/sohelp-grid/js/useSohelpGridConfig.js +641 -642
- package/sohelp-grid-select/README.md +32 -27
- package/sohelp-grid-select/index.vue +6 -5
- package/sohelp-grid-view/README.md +51 -22
- package/sohelp-grid-view-select/README.md +33 -25
- package/sohelp-grid-view-select/index.vue +2 -1
- package/sohelp-group-view/README.md +14 -4
- package/sohelp-group-view/index.vue +10 -9
- package/sohelp-icon-select/README.md +14 -12
- package/sohelp-image-upload/README.md +27 -27
- package/sohelp-image-upload/index.vue +2 -2
- package/sohelp-import/README.md +25 -24
- package/sohelp-input/README.md +27 -11
- package/sohelp-input/index.vue +15 -2
- package/sohelp-input-tag/README.md +53 -0
- package/sohelp-input-tag/index.vue +337 -0
- package/sohelp-modal/README.md +42 -16
- package/sohelp-modal/index.vue +21 -4
- package/sohelp-modal-select/README.md +745 -0
- package/sohelp-modal-select/index.vue +705 -0
- package/sohelp-module/README.md +24 -13
- package/sohelp-number-input/README.md +15 -8
- package/sohelp-number-input/index.vue +3 -0
- package/sohelp-number-range/README.md +22 -12
- package/sohelp-number-range/index.vue +3 -11
- package/sohelp-org-modal-select/README.md +47 -0
- package/sohelp-org-modal-select/index.vue +411 -0
- package/sohelp-org-select/README.md +23 -10
- package/sohelp-org-select/index.vue +41 -24
- package/sohelp-org-tree/README.md +19 -7
- package/sohelp-org-tree/index.vue +1 -2
- package/sohelp-org-tree-select/README.md +22 -11
- package/sohelp-org-tree-select/index.vue +1 -2
- package/sohelp-org-user-tree/README.md +19 -7
- package/sohelp-org-user-tree/index.vue +1 -2
- package/sohelp-org-user-tree-select/README.md +8 -3
- package/sohelp-org-user-tree-select/index.vue +8 -7
- package/sohelp-page/README.md +20 -11
- package/sohelp-page/index.vue +1 -1
- package/sohelp-pagination/README.md +14 -6
- package/sohelp-pagination/index.vue +1 -1
- package/sohelp-power/README.md +34 -19
- package/sohelp-power/index.vue +2 -2
- package/sohelp-pro-form/README.md +64 -21
- package/sohelp-pro-layout/README.md +10 -4
- package/sohelp-pro-layout/index.vue +8 -7
- package/sohelp-pro-table/README.md +30 -6
- package/sohelp-process/README.md +26 -13
- package/sohelp-process/index.vue +6 -6
- package/sohelp-rate/README.md +24 -12
- package/sohelp-rate/index.vue +5 -1
- package/sohelp-relation/README.md +10 -4
- package/sohelp-relation/index.vue +8 -7
- package/sohelp-relation-modal-select/README.md +41 -0
- package/sohelp-relation-modal-select/index.vue +70 -0
- package/sohelp-rich-text/README.md +29 -11
- package/sohelp-rich-text/index.vue +21 -20
- package/sohelp-richtext/README.md +12 -2
- package/sohelp-richtext/index.vue +8 -6
- package/sohelp-role-modal-select/README.md +45 -0
- package/sohelp-role-modal-select/index.vue +111 -0
- package/sohelp-role-select/README.md +18 -10
- package/sohelp-role-select/index.vue +36 -27
- package/sohelp-search/README.md +12 -4
- package/sohelp-search/index.vue +2 -2
- package/sohelp-search-pro-form/README.md +15 -1
- package/sohelp-search-pro-form/index.vue +2 -1
- package/sohelp-select/README.md +31 -30
- package/sohelp-select/index.vue +79 -84
- package/sohelp-split-panel/README.md +17 -18
- package/sohelp-switch/README.md +21 -19
- package/sohelp-switch/index.vue +34 -33
- package/sohelp-table/README.md +35 -27
- package/sohelp-table/index.vue +110 -109
- package/sohelp-table-select/README.md +55 -0
- package/sohelp-tenant-select/README.md +19 -18
- package/sohelp-tenant-select/index.vue +105 -109
- package/sohelp-text/README.md +16 -10
- package/sohelp-text/index.vue +5 -5
- package/sohelp-textarea-input/README.md +19 -12
- package/sohelp-time/README.md +11 -10
- package/sohelp-tree/README.md +24 -19
- package/sohelp-tree/index.vue +21 -23
- package/sohelp-tree-select/README.md +23 -10
- package/sohelp-user-modal-select/README.md +739 -0
- package/sohelp-user-modal-select/index.vue +87 -0
- package/sohelp-user-select/README.md +26 -15
- package/sohelp-user-select/index.vue +6 -2
- package/sohelp-user-tag/README.md +5 -7
- package/sohelp-user-tag/index.vue +8 -8
- package/sohelp-user-tree/README.md +5 -8
- package/sohelp-user-tree/index.vue +8 -7
- package/sohelp-vform-drawer/README.md +36 -18
- package/sohelp-vform-drawer/index.vue +2 -2
- package/sohelp-vform-eleplus/README.md +33 -31
- package/sohelp-vform-eleplus/index.vue +2 -2
- package/sohelp-vform-eleplus/tinymce/langs/zh_CN.js +461 -461
- package/sohelp-vform-eleplus/tinymce/langs/zh_TW.js +418 -418
- package/sohelp-vform-eleplus/tinymce/skins/content/dark/content.css +72 -72
- package/sohelp-vform-eleplus/tinymce/skins/content/dark/content.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/content/default/content.css +67 -67
- package/sohelp-vform-eleplus/tinymce/skins/content/default/content.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/content/document/content.css +72 -72
- package/sohelp-vform-eleplus/tinymce/skins/content/document/content.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/content/writer/content.css +68 -68
- package/sohelp-vform-eleplus/tinymce/skins/content/writer/content.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.css +732 -732
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.inline.css +726 -726
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.inline.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.mobile.css +29 -29
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.mobile.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.css +3047 -3047
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.mobile.css +673 -673
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.mobile.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.shadowdom.css +37 -37
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.shadowdom.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.css +714 -714
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.inline.css +726 -726
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.inline.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.mobile.css +29 -29
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.mobile.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.css +3047 -3047
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.mobile.css +673 -673
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.mobile.min.css +7 -7
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +37 -37
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +7 -7
- package/sohelp-vform-modal/README.md +36 -18
- package/sohelp-vform-modal/index.vue +2 -2
- package/sohelp-vform-select/README.md +9 -7
- package/sohelp-vform-select/index.vue +8 -7
- package/sohelp-vxe-grid/DefaultGridOptions.js +5 -3
- package/sohelp-vxe-grid/DefaultProps.js +0 -1
- package/sohelp-vxe-grid/README.md +540 -35
- package/sohelp-vxe-grid/SohelpGridConfig.js +8 -6
- package/sohelp-vxe-grid/index.vue +141 -94
- package/sohelp-vxe-grid-select/README.md +41 -26
- package/sohelp-vxe-table/README.md +23 -20
- package/sohelp-vxe-table/index.vue +5 -4
- package/sohelp-workflow/README.md +21 -17
- package/sohelp-workflow/index.vue +25 -22
- package/sohelp-workflow-drawer/README.md +41 -28
- package/sohelp-workflow-drawer/components/table.vue +158 -158
- package/sohelp-workflow-drawer/index.vue +86 -71
- package/sohelp-workflow-drawer/js/index.js +15 -13
- package/style/index.scss +0 -0
- package/utils/safe-eval.js +89 -0
- package/sohelp-dyn-select/props.js +0 -67
- package/sohelp-user-select/index.vue~ +0 -53
- package/sohelp-user-select/props.js +0 -71
|
@@ -1,642 +1,641 @@
|
|
|
1
|
-
import { reactive, ref } from 'vue';
|
|
2
|
-
import _DefaultGridOptions from '../js/DefaultGridOptions';
|
|
3
|
-
import { moduleCache } from '../../cache/ModuleCache';
|
|
4
|
-
import { usePermission } from '@/utils/use-permission';
|
|
5
|
-
import { useMobile } from '@/utils/use-mobile';
|
|
6
|
-
import { useI18n } from 'vue-i18n';
|
|
7
|
-
import { EleMessage } from '@/components/ele-admin-plus/components';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (conditionFn(row)) {
|
|
32
|
-
return {
|
|
33
|
-
color: config.fontColor,
|
|
34
|
-
backgroundColor: config.bgColor,
|
|
35
|
-
fontWeight: config?.bold ? 'bold' : '',
|
|
36
|
-
fontStyle: config.italic ? 'italic' : '',
|
|
37
|
-
textDecoration: config.strikethrough ? 'line-through' : config.underline ? 'underline' : ''
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} catch (e) {
|
|
42
|
-
console.error('条件解析错误:', e);
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const createDynamicCellStyle = (styleConfigs = []) => createDynamicStyle(styleConfigs, true);
|
|
49
|
-
const createDynamicRowStyle = (styleConfigs = []) => createDynamicStyle(styleConfigs, false);
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 商邦网格列配置列转化成VxeGrid列配置
|
|
53
|
-
* @param property
|
|
54
|
-
* @param sortList
|
|
55
|
-
* @param f
|
|
56
|
-
* @param formulaMap
|
|
57
|
-
* @returns
|
|
58
|
-
**/
|
|
59
|
-
const switchVxeProperty = (property, sortList, f, formulaMap) => {
|
|
60
|
-
let editor = {
|
|
61
|
-
field: property.name,
|
|
62
|
-
title: property.label,
|
|
63
|
-
i18n: property.i18n,
|
|
64
|
-
query: property.query,
|
|
65
|
-
width: property.width || 120,
|
|
66
|
-
type: property.editor || property.type,
|
|
67
|
-
align: property.align || 'left',
|
|
68
|
-
titleSuffix: property.tooltip ? { content: property.tooltip, placement: 'top' } : '',
|
|
69
|
-
|
|
70
|
-
showOverflow: true,
|
|
71
|
-
editRender: {
|
|
72
|
-
enabled: property.edit,
|
|
73
|
-
edit: property.edit,
|
|
74
|
-
...property.editorParam
|
|
75
|
-
},
|
|
76
|
-
fixed: !property.lock ? false : property.lockAlign,
|
|
77
|
-
slots: {
|
|
78
|
-
default: 'default_' + property.name,
|
|
79
|
-
header: 'header_' + property.name
|
|
80
|
-
},
|
|
81
|
-
contentRender: {
|
|
82
|
-
name: property.render,
|
|
83
|
-
props: property.renderParam || {},
|
|
84
|
-
event: 'event'
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 自定义格式化渲然
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
if (property.render && property.render === 'customFormatter') {
|
|
93
|
-
delete editor.slots.default;
|
|
94
|
-
editor.type = 'html';
|
|
95
|
-
editor.formatter = function ({ row, column, cellValue }) {
|
|
96
|
-
if (property.renderParam) {
|
|
97
|
-
try {
|
|
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
|
-
editor.
|
|
166
|
-
editor.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
data.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
'crud.
|
|
212
|
-
'crud.
|
|
213
|
-
'crud.
|
|
214
|
-
'crud.
|
|
215
|
-
'
|
|
216
|
-
'workflow.
|
|
217
|
-
'
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
acc
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
*
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
*
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
*
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
*
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
Object.assign(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
acc
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
row.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
row.
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
...sortColumns.filter((col) => col.field
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
DefaultGridOptions.pagerConfig.
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
params
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
}
|
|
1
|
+
import { reactive, ref } from 'vue';
|
|
2
|
+
import _DefaultGridOptions from '../js/DefaultGridOptions';
|
|
3
|
+
import { moduleCache } from '../../cache/ModuleCache';
|
|
4
|
+
import { usePermission } from '@/utils/use-permission';
|
|
5
|
+
import { useMobile } from '@/utils/use-mobile';
|
|
6
|
+
import { useI18n } from 'vue-i18n';
|
|
7
|
+
import { EleMessage } from '@/components/ele-admin-plus/components';
|
|
8
|
+
import { safeEval, safeFunctionExecSync } from '../../utils/safe-eval.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 深拷贝
|
|
12
|
+
* @param obj
|
|
13
|
+
* @returns {any}
|
|
14
|
+
*/
|
|
15
|
+
function deepClone(obj) {
|
|
16
|
+
return JSON.parse(JSON.stringify(obj));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 动态生成cellStyle函数
|
|
20
|
+
function createDynamicStyle(styleConfigs = [], isCell = true) {
|
|
21
|
+
// 预编译条件表达式为函数
|
|
22
|
+
const compiledConfigs = styleConfigs.map((config) => ({
|
|
23
|
+
...config,
|
|
24
|
+
conditionFn: ($row) => safeEval(config.condition, { $row })
|
|
25
|
+
}));
|
|
26
|
+
return function ({ row, column }) {
|
|
27
|
+
const _config = isCell ? compiledConfigs.filter((c) => c.name === column.field) : compiledConfigs;
|
|
28
|
+
if (!_config || !_config.length) return null;
|
|
29
|
+
try {
|
|
30
|
+
for (const config of _config) {
|
|
31
|
+
if (config.conditionFn(row)) {
|
|
32
|
+
return {
|
|
33
|
+
color: config.fontColor,
|
|
34
|
+
backgroundColor: config.bgColor,
|
|
35
|
+
fontWeight: config?.bold ? 'bold' : '',
|
|
36
|
+
fontStyle: config.italic ? 'italic' : '',
|
|
37
|
+
textDecoration: config.strikethrough ? 'line-through' : config.underline ? 'underline' : ''
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error('条件解析错误:', e);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const createDynamicCellStyle = (styleConfigs = []) => createDynamicStyle(styleConfigs, true);
|
|
49
|
+
const createDynamicRowStyle = (styleConfigs = []) => createDynamicStyle(styleConfigs, false);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 商邦网格列配置列转化成VxeGrid列配置
|
|
53
|
+
* @param property
|
|
54
|
+
* @param sortList
|
|
55
|
+
* @param f
|
|
56
|
+
* @param formulaMap
|
|
57
|
+
* @returns
|
|
58
|
+
**/
|
|
59
|
+
const switchVxeProperty = (property, sortList, f, formulaMap) => {
|
|
60
|
+
let editor = {
|
|
61
|
+
field: property.name,
|
|
62
|
+
title: property.label,
|
|
63
|
+
i18n: property.i18n,
|
|
64
|
+
query: property.query,
|
|
65
|
+
width: property.width || 120,
|
|
66
|
+
type: property.editor || property.type,
|
|
67
|
+
align: property.align || 'left',
|
|
68
|
+
titleSuffix: property.tooltip ? { content: property.tooltip, placement: 'top' } : '',
|
|
69
|
+
|
|
70
|
+
showOverflow: true,
|
|
71
|
+
editRender: {
|
|
72
|
+
enabled: property.edit,
|
|
73
|
+
edit: property.edit,
|
|
74
|
+
...property.editorParam
|
|
75
|
+
},
|
|
76
|
+
fixed: !property.lock ? false : property.lockAlign,
|
|
77
|
+
slots: {
|
|
78
|
+
default: 'default_' + property.name,
|
|
79
|
+
header: 'header_' + property.name
|
|
80
|
+
},
|
|
81
|
+
contentRender: {
|
|
82
|
+
name: property.render,
|
|
83
|
+
props: property.renderParam || {},
|
|
84
|
+
event: 'event'
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 自定义格式化渲然
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
if (property.render && property.render === 'customFormatter') {
|
|
93
|
+
delete editor.slots.default;
|
|
94
|
+
editor.type = 'html';
|
|
95
|
+
editor.formatter = function ({ row, column, cellValue }) {
|
|
96
|
+
if (property.renderParam) {
|
|
97
|
+
try {
|
|
98
|
+
return safeFunctionExecSync(property.renderParam, ['$row', '$column', '$value'], [row, column, cellValue]);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.error('customFormatter 执行错误:', e);
|
|
101
|
+
return cellValue; // 异常时返回原始值
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
return cellValue;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (property.length > 0) {
|
|
110
|
+
editor.editRender.maxlength = property.length;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 字典
|
|
114
|
+
if (property.type === 'SohelpDict') {
|
|
115
|
+
editor.editRender['code'] = property.editRender?.code || property.dict;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 取默认显示值
|
|
119
|
+
if (property.type === 'RELATION' && editor.labelField === '') {
|
|
120
|
+
const fields = property.relationList?.split(',');
|
|
121
|
+
editor.labelField = fields.includes('id') && fields.length > 1 ? fields[1] : fields[0];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// 自定义编辑插槽
|
|
125
|
+
if (property.edit) {
|
|
126
|
+
editor.slots.edit = 'edit_' + property.name;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (
|
|
130
|
+
['SohelpImageUpload', 'SohelpFileUpload', 'SohelpRate', 'SohelpSwitch', 'SohelpProcess'].includes(property.editor)
|
|
131
|
+
) {
|
|
132
|
+
delete editor.slots.edit; //不渲染编辑
|
|
133
|
+
editor.editRender.enabled = false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//筛选项配置
|
|
137
|
+
if (editor.query) {
|
|
138
|
+
switchFilterConfig(editor);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//是否统计
|
|
142
|
+
const isSummary = f.find((item) => item.field === property.name);
|
|
143
|
+
|
|
144
|
+
if (isSummary) {
|
|
145
|
+
editor.slots['footer'] = 'footer_' + property.name;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 排序
|
|
149
|
+
if (sortList?.includes(property.name)) {
|
|
150
|
+
editor['sortable'] = true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (property.name === 'id') {
|
|
154
|
+
editor['width'] = 150;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return editor;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 筛选配置
|
|
162
|
+
*/
|
|
163
|
+
const switchFilterConfig = (editor) => {
|
|
164
|
+
editor.filters = [{ data: '', checked: false }];
|
|
165
|
+
editor.filterRender = {};
|
|
166
|
+
editor.slots = {
|
|
167
|
+
...editor.slots,
|
|
168
|
+
filter: 'filter_' + editor.field
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* properties中过滤掉删除的属性
|
|
174
|
+
* @param {*} _filter
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
const filterFieldsByProperties = (_data) => {
|
|
178
|
+
const data = { ..._data };
|
|
179
|
+
const properties = new Set(data.properties?.map((item) => item.name));
|
|
180
|
+
|
|
181
|
+
const filterArray = (list, key) => {
|
|
182
|
+
return Array.isArray(list) ? list.filter((item) => properties.has(key ? item?.[key] : item)) : [];
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
let validProperties = Object.fromEntries(
|
|
186
|
+
data.properties?.filter((item) => item.name && !item.hidden)?.map((item) => [item.name, item.label])
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
data.list = filterArray(data.list).filter((item) => {
|
|
190
|
+
return item in validProperties;
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
data.filter.keywords = filterArray(data.filter.keywords);
|
|
194
|
+
|
|
195
|
+
//过滤掉不在列表中的sort属性
|
|
196
|
+
data.filter.sort = filterArray(data.filter.sort.filter((item) => data.list.some((f) => f === item)));
|
|
197
|
+
data.properties = data.properties?.filter((item) => item.name && !item.hidden);
|
|
198
|
+
|
|
199
|
+
data.filter.field = data.filter.field.filter((item) => {
|
|
200
|
+
return item.name in validProperties;
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
return data;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 工具栏默认图标
|
|
208
|
+
*/
|
|
209
|
+
const defaultIcons = {
|
|
210
|
+
'crud.edit': 'vxe-icon-edit',
|
|
211
|
+
'crud.delete': 'vxe-icon-delete',
|
|
212
|
+
'crud.create': 'vxe-icon-add',
|
|
213
|
+
'crud.save': 'vxe-icon-save',
|
|
214
|
+
'crud.view': 'vxe-icon-eye-fill',
|
|
215
|
+
'workflow.submit': 'vxe-icon-success-circle',
|
|
216
|
+
'workflow.view': 'vxe-icon-file-txt',
|
|
217
|
+
'report.print': 'vxe-icon-print'
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 格式化工具栏
|
|
222
|
+
*/
|
|
223
|
+
const getToolbarsButtons = (data) => {
|
|
224
|
+
if (data?.length) {
|
|
225
|
+
const groupedButtons = data.reduce((acc, button) => {
|
|
226
|
+
const { buttonType } = button;
|
|
227
|
+
if (!acc[buttonType]) {
|
|
228
|
+
acc[buttonType] = [];
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
acc[buttonType].push(button);
|
|
232
|
+
return acc;
|
|
233
|
+
}, {});
|
|
234
|
+
|
|
235
|
+
// 按钮格式化
|
|
236
|
+
const formatterButton = (arr, type) => {
|
|
237
|
+
return arr.map((item) => {
|
|
238
|
+
let params = {};
|
|
239
|
+
if (item.params && typeof item.params === 'string') {
|
|
240
|
+
try {
|
|
241
|
+
params = JSON.parse(item.params);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
console.error('FormatterButton Error:', e);
|
|
244
|
+
params = {};
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
let obj = {
|
|
248
|
+
code: item.id?.replace('-', '.') || item.type,
|
|
249
|
+
name: item.title || item.name || '',
|
|
250
|
+
id: item.id?.replace('-', '.'),
|
|
251
|
+
pno: item.pno,
|
|
252
|
+
handler: item.handler,
|
|
253
|
+
buttonType: item.buttonType,
|
|
254
|
+
icon: item.iconCls || defaultIcons[item.type],
|
|
255
|
+
refid: item.refid,
|
|
256
|
+
openType: item.openType,
|
|
257
|
+
params: params,
|
|
258
|
+
align: 'left'
|
|
259
|
+
};
|
|
260
|
+
return obj;
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const { common = [], more = [], batch = [] } = groupedButtons;
|
|
265
|
+
let arr = [...formatterButton(common)];
|
|
266
|
+
if (more.length > 0) {
|
|
267
|
+
arr.push({
|
|
268
|
+
code: 'more',
|
|
269
|
+
name: '更多操作',
|
|
270
|
+
dropdowns: formatterButton(more)
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (batch.length > 0) {
|
|
274
|
+
arr.push({
|
|
275
|
+
code: 'batchMore',
|
|
276
|
+
name: '批量操作',
|
|
277
|
+
dropdowns: formatterButton(batch, 'batch'),
|
|
278
|
+
disabled: true
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return arr;
|
|
282
|
+
}
|
|
283
|
+
return [];
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* 网格列表配置
|
|
288
|
+
* @returns
|
|
289
|
+
*/
|
|
290
|
+
export function useSohelpGridConfig() {
|
|
291
|
+
/**
|
|
292
|
+
* 商邦网格列表配置参数
|
|
293
|
+
* @type {UnwrapNestedRefs<{}>}
|
|
294
|
+
*/
|
|
295
|
+
const SohelpConfig = reactive({});
|
|
296
|
+
/**
|
|
297
|
+
*
|
|
298
|
+
* @type {UnwrapNestedRefs<{}>}
|
|
299
|
+
*/
|
|
300
|
+
const propertiesMap = reactive({});
|
|
301
|
+
/**
|
|
302
|
+
* 网格列表统计
|
|
303
|
+
*/
|
|
304
|
+
const footerData = reactive([]);
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
* @type {UnwrapNestedRefs<{}>}
|
|
308
|
+
*/
|
|
309
|
+
const formulaMap = reactive({});
|
|
310
|
+
/**
|
|
311
|
+
* 配置是否加载完成
|
|
312
|
+
*/
|
|
313
|
+
const isConfigInitialized = ref(false);
|
|
314
|
+
const { t } = useI18n();
|
|
315
|
+
/**
|
|
316
|
+
* placeholder占位符映射
|
|
317
|
+
*/
|
|
318
|
+
const placeholderMap = {
|
|
319
|
+
SohelpSelect: '请选择ss',
|
|
320
|
+
SohelpTreeSelect: '请选择',
|
|
321
|
+
SohelpDict: '请选择',
|
|
322
|
+
SohelpUserSelect: '请选择用户',
|
|
323
|
+
SohelpDeptSelect: '请选择部门',
|
|
324
|
+
SohelpRoleSelect: '请选择角色',
|
|
325
|
+
SohelpDatePicker: '请选择日期',
|
|
326
|
+
SohelpTimePicker: '请选择时间',
|
|
327
|
+
SohelpDateTimePicker: '请选择日期时间',
|
|
328
|
+
SohelpInput: '请输入',
|
|
329
|
+
SohelpNumberInput: '请输入'
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* 初始化商邦网格列表配置
|
|
334
|
+
*/
|
|
335
|
+
const initial = async (isGridConfig, refid) => {
|
|
336
|
+
if (!refid) throw new Error('配置列表请配置地址!');
|
|
337
|
+
let _refid = refid;
|
|
338
|
+
if (_refid.indexOf('!') === -1) _refid = refid + '!default';
|
|
339
|
+
|
|
340
|
+
isConfigInitialized.value = false;
|
|
341
|
+
const permission = usePermission();
|
|
342
|
+
const { mobile } = useMobile();
|
|
343
|
+
|
|
344
|
+
var batchButtonsIndex = -1;
|
|
345
|
+
const DefaultGridOptions = reactive(deepClone(_DefaultGridOptions));
|
|
346
|
+
/**获取列表配置*/
|
|
347
|
+
const config = await moduleCache.getGrid(_refid);
|
|
348
|
+
|
|
349
|
+
if (!config) {
|
|
350
|
+
throw new Error(_refid + ' : 没有发现网格列表配置!');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
try {
|
|
354
|
+
Object.assign(SohelpConfig, filterFieldsByProperties(config));
|
|
355
|
+
Object.assign(
|
|
356
|
+
propertiesMap,
|
|
357
|
+
(SohelpConfig?.properties || []).reduce((acc, cur) => {
|
|
358
|
+
let param = {};
|
|
359
|
+
if (cur?.editorParam && typeof cur.editorParam === 'string') {
|
|
360
|
+
try {
|
|
361
|
+
param = JSON.parse(cur.editorParam);
|
|
362
|
+
} catch (e) {
|
|
363
|
+
console.error('解析editorParam失败:', e);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
param.placeholder = param?.placeholder || placeholderMap[cur?.editor] || '';
|
|
367
|
+
acc[cur.name] = { ...cur, editorParam: param };
|
|
368
|
+
return acc;
|
|
369
|
+
}, {})
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
// 计算公式
|
|
373
|
+
if (config.formula && config.formula.length > 0) {
|
|
374
|
+
Object.assign(
|
|
375
|
+
formulaMap,
|
|
376
|
+
config.formula.reduce((a, c) => (a[c.formulaField] || (a[c.formulaField] = c), a), {})
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// 按钮权限过滤
|
|
381
|
+
const permissionButtons = config.toolbars.filter((f) => {
|
|
382
|
+
if (!f.authority) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
return permission.hasPermission(f.authority);
|
|
386
|
+
});
|
|
387
|
+
const buttons = getToolbarsButtons(permissionButtons);
|
|
388
|
+
if (buttons && buttons.length > 0) {
|
|
389
|
+
DefaultGridOptions.toolbarConfig.buttons = buttons;
|
|
390
|
+
// 更多下拉菜单索引
|
|
391
|
+
batchButtonsIndex = buttons.reduce((acc, curr, index) => {
|
|
392
|
+
if (curr.code === 'batchMore') acc.push(index);
|
|
393
|
+
return acc;
|
|
394
|
+
}, []);
|
|
395
|
+
|
|
396
|
+
//把标题转成国际化
|
|
397
|
+
buttons.forEach((item) => {
|
|
398
|
+
const code = item.code.replace('.', '-');
|
|
399
|
+
const i18nKey = item.i18n === '' || code !== 'custom' ? 'grid.toolbar.' + code : item.i18n;
|
|
400
|
+
if (i18nKey) {
|
|
401
|
+
const i18n = t(i18nKey);
|
|
402
|
+
item.name = i18n ? i18n : item.name;
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
//初始化属性列表配置
|
|
408
|
+
let columns = [];
|
|
409
|
+
|
|
410
|
+
//是否支持选择
|
|
411
|
+
if (config?.selectionType === 'checkbox') {
|
|
412
|
+
columns.push({
|
|
413
|
+
field: '_checkbox',
|
|
414
|
+
title: '',
|
|
415
|
+
fixed: mobile.value ? false : 'left',
|
|
416
|
+
type: 'checkbox',
|
|
417
|
+
align: 'center',
|
|
418
|
+
width: 40
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (config?.selectionType === 'radio') {
|
|
423
|
+
columns.push({
|
|
424
|
+
field: '_radio',
|
|
425
|
+
title: '',
|
|
426
|
+
fixed: mobile.value ? false : 'left',
|
|
427
|
+
type: 'radio',
|
|
428
|
+
align: 'center',
|
|
429
|
+
width: 40
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
//是否显示行号
|
|
434
|
+
if (config?.rowNumber) {
|
|
435
|
+
columns.push({
|
|
436
|
+
field: '_seq',
|
|
437
|
+
type: 'seq',
|
|
438
|
+
title: '#',
|
|
439
|
+
fixed: mobile.value ? false : 'left',
|
|
440
|
+
align: 'center',
|
|
441
|
+
width: 40
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
//是否支持拖动
|
|
446
|
+
if (config?.rowDrag) {
|
|
447
|
+
columns.unshift({
|
|
448
|
+
title: '',
|
|
449
|
+
fixed: mobile.value ? false : 'left',
|
|
450
|
+
width: 40,
|
|
451
|
+
align: 'center',
|
|
452
|
+
dragSort: true,
|
|
453
|
+
field: '_drag'
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
//列拖动
|
|
458
|
+
if (config?.columnDrag) {
|
|
459
|
+
DefaultGridOptions.columnConfig.drag = true;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const requireData = {};
|
|
463
|
+
//商邦列转换成Vxe列
|
|
464
|
+
if (SohelpConfig.properties?.length > 0) {
|
|
465
|
+
SohelpConfig.properties.forEach((column, index) => {
|
|
466
|
+
let item = propertiesMap[column.name];
|
|
467
|
+
const row = switchVxeProperty(item, SohelpConfig.filter?.sort, footerData, formulaMap);
|
|
468
|
+
|
|
469
|
+
// 列表是否显示
|
|
470
|
+
row.visible = SohelpConfig.list.includes(item.name);
|
|
471
|
+
row.fixed = mobile.value ? false : row.fixed;
|
|
472
|
+
// 添加操作栏插槽
|
|
473
|
+
if (item.name === '_operation') {
|
|
474
|
+
row.visible = true;
|
|
475
|
+
row.slots = {
|
|
476
|
+
default: '_operation'
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
columns.push(row);
|
|
481
|
+
|
|
482
|
+
// 校验规则,非空字段必填
|
|
483
|
+
if (item.edit && item.notNull) {
|
|
484
|
+
requireData[item.name] = [
|
|
485
|
+
{
|
|
486
|
+
required: true,
|
|
487
|
+
message: row.title + '不能为空'
|
|
488
|
+
}
|
|
489
|
+
];
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
//没有工具栏则不显示操作拦
|
|
494
|
+
if (config?.operations?.length == 0) {
|
|
495
|
+
columns = columns.filter((item) => item.field != '_operation');
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
//将columns按照fields排序
|
|
499
|
+
const sortColumns = columns
|
|
500
|
+
.sort((a, b) => {
|
|
501
|
+
if (a.field === '_operation') return 1;
|
|
502
|
+
if (b.field === '_operation') return -1;
|
|
503
|
+
return config.list.indexOf(a.field) - config.list.indexOf(b.field);
|
|
504
|
+
})
|
|
505
|
+
.sort((a, b) => {
|
|
506
|
+
return b.visible - a.visible;
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
//_operation列安排最后一列
|
|
510
|
+
DefaultGridOptions.columns = [
|
|
511
|
+
...sortColumns.filter((col) => col.field !== '_operation'),
|
|
512
|
+
...sortColumns.filter((col) => col.field === '_operation')
|
|
513
|
+
];
|
|
514
|
+
DefaultGridOptions.editRules = { ...requireData };
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
//是否开启表尾
|
|
518
|
+
Object.assign(
|
|
519
|
+
footerData,
|
|
520
|
+
(config.properties || [])
|
|
521
|
+
.filter((item) => item.summaryType)
|
|
522
|
+
?.map((item) => {
|
|
523
|
+
return {
|
|
524
|
+
[item.name]: 0,
|
|
525
|
+
summaryRender: item.summaryRender ? JSON.parse(item.summaryRender) : null,
|
|
526
|
+
field: item.name,
|
|
527
|
+
type: item.summaryType
|
|
528
|
+
};
|
|
529
|
+
})
|
|
530
|
+
);
|
|
531
|
+
DefaultGridOptions.showFooter = footerData?.length > 0;
|
|
532
|
+
|
|
533
|
+
// 拦截编辑
|
|
534
|
+
DefaultGridOptions.editConfig.beforeEditMethod = ({ row, column }) => {
|
|
535
|
+
if (column.type === 'SohelpTextarea') {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
return true;
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
// 设置分页数据
|
|
542
|
+
DefaultGridOptions.pagerConfig.enabled = config.paging;
|
|
543
|
+
DefaultGridOptions.pagerConfig.pageSize = config.limit || 50;
|
|
544
|
+
|
|
545
|
+
// 行列样式
|
|
546
|
+
if (config.colors && config.colors.length > 0) {
|
|
547
|
+
const rowData = config.colors.filter((item) => item.type !== 'c');
|
|
548
|
+
const cellData = config.colors.filter((item) => item.type === 'c');
|
|
549
|
+
if (rowData.length > 0) {
|
|
550
|
+
DefaultGridOptions.rowStyle = createDynamicRowStyle(rowData);
|
|
551
|
+
} else {
|
|
552
|
+
DefaultGridOptions.stripe = true;
|
|
553
|
+
}
|
|
554
|
+
if (cellData.length > 0) {
|
|
555
|
+
DefaultGridOptions.cellStyle = createDynamicCellStyle(cellData);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
isConfigInitialized.value = true;
|
|
559
|
+
|
|
560
|
+
//序号列配置
|
|
561
|
+
DefaultGridOptions.seqConfig = {
|
|
562
|
+
seqMethod: ({ rowIndex }) => {
|
|
563
|
+
const { pageSize, currentPage } = DefaultGridOptions.pagerConfig;
|
|
564
|
+
return (currentPage - 1) * pageSize + rowIndex + 1;
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
//转化初始化其他参数...
|
|
569
|
+
} catch (error) {
|
|
570
|
+
throw error; //重新抛出错误,以便调用者可以处理它
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const operationsButtons = getOperationToolbars();
|
|
574
|
+
return {
|
|
575
|
+
gridOptions: DefaultGridOptions,
|
|
576
|
+
sohelpConfig: SohelpConfig,
|
|
577
|
+
propertiesMap: propertiesMap,
|
|
578
|
+
batchButtonsIndex: batchButtonsIndex,
|
|
579
|
+
footerData: footerData,
|
|
580
|
+
formulaMap: formulaMap,
|
|
581
|
+
operationsButtons: operationsButtons
|
|
582
|
+
};
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// 操作栏按钮分类
|
|
586
|
+
const getOperationToolbars = () => {
|
|
587
|
+
const buttonsMap = {};
|
|
588
|
+
const permission = usePermission();
|
|
589
|
+
SohelpConfig.operations
|
|
590
|
+
?.filter((f) => !f.authority || permission.hasPermission(f.authority))
|
|
591
|
+
.map((button) => {
|
|
592
|
+
const type = button.buttonType || 'common';
|
|
593
|
+
const code = button.type === 'custom' ? button.id : button.type;
|
|
594
|
+
if (!buttonsMap[type]) {
|
|
595
|
+
buttonsMap[type] = [];
|
|
596
|
+
}
|
|
597
|
+
const title = button.type === 'custom' ? button.title : t('grid.toolbar.' + button.type?.replaceAll('.', '-'));
|
|
598
|
+
let params = button.params || {};
|
|
599
|
+
if (button.params && typeof button.params === 'string') {
|
|
600
|
+
try {
|
|
601
|
+
params = JSON.parse(button.params);
|
|
602
|
+
} catch (e) {
|
|
603
|
+
params = {};
|
|
604
|
+
EleMessage.error('button.params配置JSON参数格式错误');
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
buttonsMap[type].push({
|
|
608
|
+
title: title || button.title,
|
|
609
|
+
id: button.id,
|
|
610
|
+
code: code,
|
|
611
|
+
handler: button.handler,
|
|
612
|
+
icon: button.iconCls,
|
|
613
|
+
params: params,
|
|
614
|
+
refid: button.refid,
|
|
615
|
+
openType: button.openType,
|
|
616
|
+
render: button.render
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
return buttonsMap;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* 配置是否加载完成
|
|
624
|
+
*/
|
|
625
|
+
const isConfigDone = async () => {
|
|
626
|
+
return new Promise((resolve) => {
|
|
627
|
+
if (isConfigInitialized.value) {
|
|
628
|
+
resolve();
|
|
629
|
+
} else {
|
|
630
|
+
let timer = setInterval(() => {
|
|
631
|
+
if (isConfigInitialized.value) {
|
|
632
|
+
clearInterval(timer);
|
|
633
|
+
resolve();
|
|
634
|
+
}
|
|
635
|
+
}, 10);
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
|
|
640
|
+
return { SohelpConfig, initial, isConfigDone, isConfigInitialized, moduleCache };
|
|
641
|
+
}
|