@utogether/udp-core 2.0.0-beta.27 → 2.0.0-beta.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.
Files changed (100) hide show
  1. package/dist/{403-gdcH0-Bo.js → 403-CyoOD-Ik.js} +1 -1
  2. package/dist/{404-Se2SF97M.js → 404-Ch_OHTw0.js} +1 -1
  3. package/dist/{500-B6j9AqLo.js → 500-Cf9am7HK.js} +1 -1
  4. package/dist/{AuthorityInfo-CQ8ydZvr.js → AuthorityInfo-BJ427cqG.js} +1 -1
  5. package/dist/{AuthorityInfo.vue_vue_type_style_index_0_lang-C4NRvS8p.js → AuthorityInfo.vue_vue_type_style_index_0_lang-D9y7AwbB.js} +11 -12
  6. package/dist/{Company-BzSVBSC4.js → Company-qo-lKPkv.js} +3 -3
  7. package/dist/{CompanyPanel-DBjZB4aJ.js → CompanyPanel-DkKWAKvY.js} +7 -7
  8. package/dist/{Department-BkgseHo8.js → Department-CHUQByKX.js} +3 -3
  9. package/dist/{DepartmentPanel-Sen93_2M.js → DepartmentPanel-C742dfOO.js} +27 -28
  10. package/dist/{DesignPanel-pqDcwaFC.js → DesignPanel-D9oE5R7m.js} +1 -1
  11. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-BjtYyEw7.js → DesignPanel.vue_vue_type_style_index_0_lang-hYldVEbo.js} +192 -108
  12. package/dist/{DictView-CJLG4LlE.js → DictView-CrFXprP9.js} +1 -1
  13. package/dist/{InvOrganization-D0Jq1IAa.js → InvOrganization-Cz8SzIgs.js} +6 -7
  14. package/dist/{Org-CO_1WT39.js → Org-Bzt6yKox.js} +9 -10
  15. package/dist/{Preview-DLI4Bwel.js → Preview-jonigfMQ.js} +1 -1
  16. package/dist/{ReportDefine-Cw46OnJ_.js → ReportDefine-BpiM5Ovq.js} +1 -1
  17. package/dist/{ReportDesign-D4sHTXT7.js → ReportDesign-fp09cXJ7.js} +24 -25
  18. package/dist/{ReportQuery-DtOCvQSN.js → ReportQuery-52ZP1PYP.js} +1 -1
  19. package/dist/{ReportQueryFrom-QjL-ETPq.js → ReportQueryFrom-DSYavJb1.js} +1 -1
  20. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-Dj9ne87n.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-DBGYEp0u.js} +4 -4
  21. package/dist/{ReportTemplate-BxAgc_Aj.js → ReportTemplate-CA_UW0eD.js} +3 -3
  22. package/dist/{Role-Df77BBD-.js → Role-DqOt8Bk0.js} +3 -3
  23. package/dist/{RoleAssign-BrunouML.js → RoleAssign-BdxhefhQ.js} +3 -3
  24. package/dist/{RolePanel-HLA7XBlN.js → RolePanel-2gZ3H0ET.js} +1 -1
  25. package/dist/{RolePanel-DSVwqhiD.js → RolePanel-BsNd0svJ.js} +1 -1
  26. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CN0rUxKz.js → RolePanel.vue_vue_type_script_setup_true_lang-DLOwgF99.js} +9 -9
  27. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CKlbqRa5.js → RolePanel.vue_vue_type_script_setup_true_lang-DmzD9kab.js} +26 -27
  28. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-D_FeSXKv.js → ScrollPanel.vue_vue_type_style_index_0_lang-B9ptUMeI.js} +7 -7
  29. package/dist/{Staff-BeL1xcRf.js → Staff-D3L8fEoY.js} +3 -3
  30. package/dist/{StaffInfo-CIfnltyX.js → StaffInfo-DYRw6ZYJ.js} +1 -1
  31. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DbLFwWfG.js → StaffInfo.vue_vue_type_script_setup_true_lang-xqEOQnMs.js} +1 -1
  32. package/dist/{StaffPanel-BV2CHWac.js → StaffPanel-DkrNH6Px.js} +1 -1
  33. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-CvT-Vp2G.js → StaffPanel.vue_vue_type_script_setup_true_lang-BPBMnliy.js} +8 -9
  34. package/dist/{SysUser-DPfNvthk.js → SysUser-Bl1-cIpJ.js} +2 -2
  35. package/dist/{SysUserPanel-CoLKYlQE.js → SysUserPanel-yxNLaBwt.js} +1 -1
  36. package/dist/{SysUserPanel.vue_vue_type_script_setup_true_lang-lcO3Cjbq.js → SysUserPanel.vue_vue_type_script_setup_true_lang-BDcsgSl5.js} +11 -12
  37. package/dist/{SystemMenu-sdj1dRDA.js → SystemMenu-C4_Arn12.js} +9 -10
  38. package/dist/{UserInfo-CTX4hhFl.js → UserInfo-QcNwJCUR.js} +1 -1
  39. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-ClhCd_8z.js → UserInfo.vue_vue_type_style_index_0_lang-DLIeUphX.js} +5 -6
  40. package/dist/{childView-BDmWwJO5.js → childView-B23DEO2u.js} +1 -1
  41. package/dist/{childView-Dx3ACtHa.js → childView-saDZQv9x.js} +1 -1
  42. package/dist/{childView.vue_vue_type_style_index_0_lang-CfKq_0FN.js → childView.vue_vue_type_style_index_0_lang-RsKR6CAC.js} +14 -15
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-DxZNtkhd.js → childView.vue_vue_type_style_index_0_lang-ZFEfavUY.js} +11 -12
  44. package/dist/{code-rule-cvN4gYC_.js → code-rule-2_Ihx_by.js} +12 -13
  45. package/dist/core.es.js +21 -19
  46. package/dist/{cron-task-B0TkxFdp.js → cron-task-BFOPJQIk.js} +3 -4
  47. package/dist/{frameView-5cy5BSgS.js → frameView-f7Ya0Knj.js} +1 -1
  48. package/dist/img/minicolors.png +0 -0
  49. package/dist/{index-C5WRTwvI.js → index-BpdTDaTk.js} +811 -604
  50. package/dist/{layout-home-DrARg-3o.js → layout-home-v3DPJ7rB.js} +12 -13
  51. package/dist/{layoutView-25v_ngk5.js → layoutView-DZHoQDH1.js} +186 -187
  52. package/dist/{log-in-Bmz5Uhbt.js → log-in-BPAMJTwH.js} +4 -5
  53. package/dist/{log-out-B-8m3oNj.js → log-out-DZACF0jg.js} +8 -9
  54. package/dist/{login-Cmp2RvvW.js → login-B8cwozax.js} +22 -23
  55. package/dist/{lov-view-BATtzw2X.js → lov-view-Ba7Y7xy0.js} +4 -5
  56. package/dist/{menuInfo-BIvrE7nm.js → menuInfo-BpRKFYK8.js} +1 -1
  57. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-B6USomit.js → menuInfo.vue_vue_type_style_index_0_lang-DJ5sUC6m.js} +17 -18
  58. package/dist/{pda-app-CzHVyeEa.js → pda-app-C0jJecrL.js} +7 -8
  59. package/dist/{resource-Y5lGB38n.js → resource-BG22Cw4P.js} +4 -4
  60. package/dist/su-welcome-DaxhbrC6.js +879 -0
  61. package/dist/{sys-config-CqO03LeC.js → sys-config-CG2fMtak.js} +22 -23
  62. package/dist/udp-core.css +1 -1
  63. package/dist/{useNav-C-rCgubt.js → useNav-_u2UAQWk.js} +24 -24
  64. package/index.ts +54 -51
  65. package/package.json +21 -21
  66. package/src/api/http.ts +10 -4
  67. package/src/api/index.ts +51 -51
  68. package/src/api/user.ts +64 -64
  69. package/src/components/udp/content/index.vue +93 -93
  70. package/src/components/udp/form-upload/form-upload.vue +496 -496
  71. package/src/components/udp/grid/index.vue +643 -544
  72. package/src/components/udp/index.ts +2 -1
  73. package/src/components/udp/modal-form/index.vue +326 -0
  74. package/src/components/udp/utils.ts +420 -420
  75. package/src/layout/components/lay-navbar/index.vue +240 -240
  76. package/src/layout/components/lay-search/components/SearchModal.vue +185 -185
  77. package/src/layout/components/lay-sidebar/mixNav.vue +261 -261
  78. package/src/layout/components/lay-sidebar/sidebarItem.vue +199 -195
  79. package/src/layout/components/lay-sidebar/vertical.vue +92 -92
  80. package/src/layout/layoutView.vue +1 -0
  81. package/src/main.ts +111 -111
  82. package/src/plugins/i18n/zh.ts +5 -1
  83. package/src/plugins/vxe-table/index.ts +116 -116
  84. package/src/router/index.ts +158 -156
  85. package/src/router/utils.ts +434 -430
  86. package/src/store/modules/permission.ts +1 -1
  87. package/src/store/modules/system.ts +193 -193
  88. package/src/style/print-lock.css +380 -375
  89. package/src/style/suprint.css +990 -985
  90. package/src/utils/authority/index.ts +46 -46
  91. package/src/utils/dataFormat/index.ts +309 -222
  92. package/src/utils/udp/http/index.ts +19 -11
  93. package/src/views/uhome/components/home-todo.vue +15 -3
  94. package/src/views/uhome/dynamic-card.vue +31 -31
  95. package/src/views/uhome/su-welcome.vue +310 -310
  96. package/src/views/ulogin/login.vue +292 -292
  97. package/src/views/urpt/design/DesignPanel.vue +538 -507
  98. package/src/views/urpt/design/print-data.ts +39 -59
  99. package/dist/await-to-js.es5-Bv3Eu4mi.js +0 -10
  100. package/dist/su-welcome-CXA6OzBw.js +0 -878
@@ -1,420 +1,420 @@
1
- /*
2
- * @Author: wei.li
3
- * @Date: 2022-06-23 17:29:11
4
- * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2026-04-16 09:37:11
6
- * @Description: file content
7
- */
8
- // @ts-nocheck
9
-
10
- import { clone, isString, orderBy, isEmpty, toDateString, isObject, isFunction, isArray } from 'xe-utils';
11
- import { cookies, storageLocal } from '@utogether/utils';
12
- /** 系统配置的key */
13
- const kSYSCONFIG = 'kSysConfig';
14
- const kCOOKIES = 'kCookies_param';
15
-
16
- const sysConfig = storageLocal.getItem(kSYSCONFIG);
17
-
18
- let exportOptions = null;
19
-
20
- /** 工具栏按钮标准化 */
21
- export const formatButton = (buttons, auth?) => {
22
- buttons.forEach(btn => {
23
- btn.auth = auth ? auth[btn.code] || btn.auth : btn.auth;
24
- if (!btn.name) {
25
- btn.name = `message.btn.${btn.code}`;
26
- } else if (sysConfig?.i18nEnabled === 'Y' && !btn.name.startsWith('message.')) {
27
- btn.name = `message.btn.${btn.name}`;
28
- }
29
- if (btn.dropdowns?.length) {
30
- formatButton(btn.dropdowns, auth);
31
- }
32
- });
33
- return buttons;
34
- };
35
-
36
- /**
37
- * @description 查询10W数据,常用于Excel导出
38
- * @param props 查询接口的路径
39
- * @param http http实例
40
- * @param form 查询条件
41
- * @returns 查询返回的数据
42
- */
43
- export const queryAll = (props, http, form) => {
44
- console.log('exportMethod', exportOptions);
45
- const params = { pageNum: 1, pageSize: 100000 };
46
- const commonParam = getCookieParam();
47
- Object.assign(params, form, commonParam, props.defaultParams || {}, exportOptions.params);
48
- let query = formatMultipleParams(params, props.items);
49
- query = formatDateRange(query, props.items);
50
-
51
- const { url } = props;
52
- if (!url) return null;
53
- const requestURL = isString(url) ? url : url.fetch || url.restful;
54
- if (!requestURL) return null;
55
- const method = url.fetch ? 'post' : 'get';
56
- return new Promise((resolve, reject) => {
57
- http[method](requestURL, query)
58
- .then((response: IResponseData) => {
59
- resolve(response.list);
60
- })
61
- .catch((e: any) => {
62
- reject(e);
63
- });
64
- });
65
- };
66
-
67
- /**
68
- * @description 查询服务
69
- * @param props 查询接口的路径
70
- * @param form 查询条件
71
- * @param page 分页参数
72
- * @param http http实例
73
- * @param isDoc doc文档
74
- * @returns Promise
75
- */
76
- export const query = (props, form, page, http, code, isDoc) => {
77
- if (isDoc) return getDocData();
78
-
79
- console.log('query', form);
80
-
81
- for (const key in form) {
82
- if (form[key] && isString(form[key])) {
83
- form[key] = form[key].trim();
84
- }
85
- }
86
- const params = { pageNum: page.currentPage, pageSize: page.pageSize };
87
- const commonParam = getCookieParam();
88
- Object.assign(params, commonParam, props.defaultParams || {}, form);
89
-
90
- let query = formatMultipleParams(params, props.items);
91
- query = formatDateRange(query, props.items);
92
- const { url } = props;
93
- if (!url) return null;
94
- const requestURL = isString(url) ? url : url.fetch || url.restful;
95
- const method = url.fetch ? 'post' : 'get';
96
- if (!requestURL) return null;
97
- return http[method](requestURL, query);
98
- };
99
-
100
- /**
101
- * @description 表格删除方法
102
- * @param http http实例
103
- * @param records 记录行
104
- * @param props 删除接口的路径
105
- * @returns Promise
106
- */
107
- export const del = (http, records, props) => {
108
- const { url } = props;
109
- if (!url) return null;
110
- const requestURL = isString(url) ? url : url.del || url.restful;
111
- if (!requestURL) return null;
112
- const method = url.del ? 'post' : 'delete';
113
- return http[method](requestURL, records);
114
- };
115
-
116
- /** 更新服务 */
117
- export const save = (http, body, props) => {
118
- const allService = [];
119
- const { url } = props;
120
- if (!url) return null;
121
-
122
- const { insertRecords, updateRecords } = body;
123
- if (!isEmpty(insertRecords)) {
124
- const commonParam = getCookieParam();
125
- insertRecords.forEach(m => {
126
- !isEmpty(props?.defaultValue) && Object.assign(m, props.defaultValue);
127
- Object.keys(commonParam)?.forEach(key => {
128
- m[key] = m[key] || commonParam[key];
129
- });
130
- });
131
- const requestURL = isString(url) ? url : url.add || url.restful;
132
- requestURL && allService.push(http.post(requestURL, insertRecords));
133
- }
134
- if (!isEmpty(updateRecords)) {
135
- const requestURL = isString(url) ? url : url.save || url.restful;
136
- const method = url.save ? 'post' : 'put';
137
- requestURL && allService.push(http[method](requestURL, updateRecords));
138
- }
139
- return allService;
140
- };
141
-
142
- /**
143
- * 多选数据优化
144
- * @param listQuery
145
- * @param items
146
- * @returns
147
- */
148
- const formatMultipleParams = (listQuery: any, items) => {
149
- const multipleItems = items.filter(f => f.itemRender?.props?.multiple || f.multiple);
150
- if (isEmpty(multipleItems)) return listQuery;
151
- const query = clone(listQuery, true);
152
- multipleItems.forEach((element: any) => {
153
- if (element.itemRender.name === '#select' && element.itemRender.props.multiple) {
154
- if (query[`_${element.field}`]?.length === 0) {
155
- // 重置后
156
- query[`${element.field}`] = null;
157
- }
158
- delete listQuery[`_${element.field}`];
159
- delete query[`_${element.field}`];
160
- }
161
- });
162
- return query;
163
- };
164
-
165
- const startFormatter = 'yyyy-MM-dd 00:00:00';
166
- const endFormatter = 'yyyy-MM-dd 23:59:59';
167
- // 时间范围优化
168
- const formatDateRange = (listQuery: any, items) => {
169
- const dateRanges = items.filter(f => ['#SuDateRange', 'VxeDateRangePicker'].includes(f.itemRender?.name));
170
- if (isEmpty(dateRanges)) return listQuery;
171
- const query = clone(listQuery, true);
172
- dateRanges.forEach((element: any) => {
173
- let selectedDate = query[element.field];
174
- if (element.itemRender.name === 'VxeDateRangePicker' && selectedDate && !isArray(selectedDate)) {
175
- selectedDate = selectedDate.split(',');
176
- }
177
- const { startField, endField } = element.itemRender;
178
- if (selectedDate && startField) {
179
- query[startField] = toDateString(query[startField] || selectedDate[0], startFormatter);
180
- query[endField] = toDateString(query[endField] || selectedDate[1], endFormatter);
181
- } else if (selectedDate) {
182
- query[`${element.field}From`] = toDateString(selectedDate[0], startFormatter);
183
- query[`${element.field}To`] = toDateString(selectedDate[1], endFormatter);
184
- }
185
- delete query[element.field];
186
- });
187
- return query;
188
- };
189
-
190
- const getCookieParam = () => {
191
- return cookies.get(kCOOKIES) ? JSON.parse(cookies.get(kCOOKIES)) : {};
192
- };
193
-
194
- /** 工具栏默认按钮组 */
195
- export const inlineButtons = [
196
- {
197
- code: 'insert_actived',
198
- name: 'add',
199
- status: 'u-cyan',
200
- icon: 'vxe-icon-add',
201
- auth: 'add',
202
- sort: 1
203
- },
204
- {
205
- code: 'delete',
206
- status: 'danger',
207
- icon: 'vxe-icon-delete',
208
- auth: 'del',
209
- sort: 2
210
- },
211
- {
212
- code: 'save',
213
- status: 'primary',
214
- icon: 'vxe-icon-save',
215
- auth: 'edit',
216
- sort: 3
217
- }
218
- ];
219
- // form 模式按钮
220
- export const dialogButtons = [
221
- {
222
- code: 'add',
223
- status: 'u-cyan',
224
- icon: 'vxe-icon-add',
225
- auth: 'add',
226
- sort: 1
227
- },
228
- {
229
- code: 'del',
230
- status: 'danger',
231
- icon: 'vxe-icon-delete',
232
- auth: 'del',
233
- sort: 2
234
- }
235
- ];
236
-
237
- export const defaultColums = [
238
- { field: 'createdByName', width: 90, visible: false },
239
- { field: 'creationDate', width: 140, visible: false },
240
- { field: 'lastUpdatedByName', width: 90, visible: false },
241
- { field: 'lastUpdateDate', width: 140, visible: false }
242
- ];
243
-
244
- /** 导出配置 */
245
- export const getExportConfig = attrs => {
246
- if (isObject(attrs.exportConfig)) return attrs.exportConfig;
247
- return {
248
- filename: attrs.fileName || '导出明细',
249
- type: 'xlsx',
250
- types: ['xlsx', 'csv'],
251
- modes: ['current', 'selected', 'all'],
252
- useStyle: true,
253
- sheetMethod: ({ worksheet }) => (attrs.onSheetMethod ? attrs.onSheetMethod(worksheet) : onSheetMethod(worksheet)),
254
- beforeExportMethod: options =>
255
- attrs.beforeExportMethod ? (exportOptions = attrs.beforeExportMethod(options)) : null,
256
- columnFilterMethod: ({ column }) =>
257
- attrs.columnFilter
258
- ? !!attrs.columnFilter(column)
259
- : !['operate'].includes(column.field) && column.type !== 'checkbox'
260
- };
261
- };
262
-
263
- export const getToolBarConfig = (data, props, attrs, hasAuthority) => {
264
- const refreshOptions = {
265
- icon: 'ri-refresh-line',
266
- iconLoading: 'vxe-icon-spinner roll vxe-loading--default-icon'
267
- };
268
- // 不可编辑时
269
- if (!props.editable) {
270
- data.editConfig.editable = props.editable;
271
- const hasExport = props.needExport && hasAuthority('export');
272
- if (hasExport) {
273
- data.exportConfig = getExportConfig(attrs);
274
- }
275
- data.toolbarConfig = {
276
- buttons: [],
277
- enabled: hasExport,
278
- refreshOptions,
279
- exportOptions: { icon: 'ri-download-2-line', code: 'export' },
280
- export: hasExport,
281
- custom: !!attrs.gridId,
282
- refresh: true,
283
- perfect: true
284
- };
285
- return data;
286
- }
287
-
288
- // 先设置传入的按钮
289
- let buttons = clone(attrs.buttons || [], true);
290
-
291
- buttons.forEach((button, idx) => {
292
- button.sort = button.sort || idx + 10;
293
- });
294
-
295
- // 获取默认的按钮
296
- const toolButtons = attrs.mode !== 'form' ? clone(inlineButtons, true) : clone(dialogButtons, true);
297
- // 判断传入的按钮是否有默认按钮的auth,有就不加入按钮组中,相当于重写了默认的按钮
298
- // reverse的原因是: 保持现有按钮顺序, 新增,保存,删除
299
- toolButtons.reverse().forEach(btn => {
300
- !buttons.some(s => s.code === btn.code) && buttons.unshift(btn);
301
- if (attrs.authPrefix && !['printer', 'export'].includes(btn.auth)) {
302
- btn.auth = attrs.authPrefix + btn.auth.slice(0, 1).toLocaleUpperCase() + btn.auth.slice(1).toLocaleLowerCase();
303
- }
304
- });
305
-
306
- buttons = formatButton(buttons, props.auth).filter(button => {
307
- const flag = button.auth ? hasAuthority(button.auth) : true;
308
- if (button.dropdowns?.length) {
309
- button.dropdowns = button.dropdowns.filter(btn => !btn.auth || (btn.auth && hasAuthority(btn.auth)));
310
- }
311
- return flag;
312
- });
313
- // inline 行内模式,单击行模式
314
- const editConfig = { trigger: 'dblclick', mode: 'row', showStatus: true };
315
- data.editConfig = attrs.mode !== 'form' ? editConfig : { enabled: false };
316
- // 导出权限
317
- const hasExport = props.needExport && hasAuthority('export');
318
- let exportBtn = null;
319
- if (hasExport) {
320
- data.exportConfig = getExportConfig(attrs);
321
- exportBtn = { icon: 'ri-download-2-line', code: 'export' };
322
- }
323
- data.toolbarConfig = {
324
- buttons: orderBy(buttons, 'sort'),
325
- enabled: true,
326
- refreshOptions,
327
- customOptions: attrs.gridId ? {} : null,
328
- exportOptions: exportBtn,
329
- custom: !!attrs.gridId,
330
- export: hasExport,
331
- refresh: true,
332
- perfect: true
333
- };
334
- return data;
335
- };
336
-
337
- /**
338
- * @description: 表格脚合并方法
339
- * @param {*} columns 列数据
340
- * @param {*} data 数据源
341
- * @param {*} sum 合并属性
342
- * @return {*} 合并脚方法
343
- */
344
- export const footerSumMethod = ({ columns, data }, sum) => {
345
- return [
346
- columns.map((column, columnIdx) => {
347
- if (columnIdx === (sum.index || 0)) {
348
- return sum.label || '合计';
349
- }
350
- if (sum.fields?.includes(column.property)) {
351
- const total = data.reduce((prev, cur) => {
352
- return prev + Number(cur[column.property] || 0);
353
- }, 0);
354
- return total ? Number(total.toFixed(sum.decimal || 2)) : total;
355
- }
356
- return '';
357
- })
358
- ];
359
- };
360
-
361
- /**
362
- * @description: checkbox是否可选
363
- */
364
- export const onCheckMethod = (row, props) => {
365
- if (isFunction(props.checkMethod)) {
366
- return props.checkMethod(row);
367
- }
368
- return true;
369
- };
370
-
371
- /*** excel样式重置 */
372
- const onSheetMethod = ws => {
373
- ws.eachRow((row, rowNumber) => {
374
- row.font = { name: '微软雅黑', size: 9 };
375
- row.border = {
376
- top: { style: 'thin' },
377
- left: { style: 'thin' },
378
- bottom: { style: 'thin' },
379
- right: { style: 'thin' }
380
- };
381
-
382
- if (rowNumber === 1) {
383
- row.fill = {
384
- type: 'pattern',
385
- pattern: 'solid',
386
- fgColor: { argb: '4F81BD' }
387
- };
388
- row.font = {
389
- name: '微软雅黑',
390
- size: 10,
391
- bold: true,
392
- color: { argb: 'FFFFFFFF' }
393
- };
394
- }
395
- });
396
- };
397
-
398
- const getDocData = () => {
399
- return new Promise(resolve => {
400
- setTimeout(() => {
401
- const list = [
402
- { id: 1, name: 'Test1', sex: 'Man', age: 28, address: 'Shenzhen' },
403
- { id: 2, name: 'Test2', sex: 'Women', age: 22, address: 'Guangzhou' },
404
- { id: 3, name: 'Test3', sex: 'Man', age: 32, address: 'Shanghai' },
405
- { id: 4, name: 'Test4', sex: 'Women', age: 23, address: 'test abc' },
406
- { id: 5, name: 'Test5', sex: 'Women', age: 30, address: 'Shanghai' }
407
- ];
408
- resolve({ list, total: 5 });
409
- }, 100);
410
- });
411
- };
412
-
413
- export const getAttrs = attrs => {
414
- const data = {};
415
- Object.keys(attrs).forEach(key => {
416
- const nKey = key.replace(/-(\w)/g, str => str.slice(1).toUpperCase());
417
- data[nKey] = attrs[key];
418
- });
419
- return data;
420
- };
1
+ /*
2
+ * @Author: wei.li
3
+ * @Date: 2022-06-23 17:29:11
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2026-04-16 09:37:11
6
+ * @Description: file content
7
+ */
8
+ // @ts-nocheck
9
+
10
+ import { clone, isString, orderBy, isEmpty, toDateString, isObject, isFunction, isArray } from 'xe-utils';
11
+ import { cookies, storageLocal } from '@utogether/utils';
12
+ /** 系统配置的key */
13
+ const kSYSCONFIG = 'kSysConfig';
14
+ const kCOOKIES = 'kCookies_param';
15
+
16
+ const sysConfig = storageLocal.getItem(kSYSCONFIG);
17
+
18
+ let exportOptions = null;
19
+
20
+ /** 工具栏按钮标准化 */
21
+ export const formatButton = (buttons, auth?) => {
22
+ buttons.forEach(btn => {
23
+ btn.auth = auth ? auth[btn.code] || btn.auth : btn.auth;
24
+ if (!btn.name) {
25
+ btn.name = `message.btn.${btn.code}`;
26
+ } else if (sysConfig?.i18nEnabled === 'Y' && !btn.name.startsWith('message.')) {
27
+ btn.name = `message.btn.${btn.name}`;
28
+ }
29
+ if (btn.dropdowns?.length) {
30
+ formatButton(btn.dropdowns, auth);
31
+ }
32
+ });
33
+ return buttons;
34
+ };
35
+
36
+ /**
37
+ * @description 查询10W数据,常用于Excel导出
38
+ * @param props 查询接口的路径
39
+ * @param http http实例
40
+ * @param form 查询条件
41
+ * @returns 查询返回的数据
42
+ */
43
+ export const queryAll = (props, http, form) => {
44
+ console.log('exportMethod', exportOptions);
45
+ const params = { pageNum: 1, pageSize: 100000 };
46
+ const commonParam = getCookieParam();
47
+ Object.assign(params, form, commonParam, props.defaultParams || {}, exportOptions.params);
48
+ let query = formatMultipleParams(params, props.items);
49
+ query = formatDateRange(query, props.items);
50
+
51
+ const { url } = props;
52
+ if (!url) return null;
53
+ const requestURL = isString(url) ? url : url.fetch || url.restful;
54
+ if (!requestURL) return null;
55
+ const method = url.fetch ? 'post' : 'get';
56
+ return new Promise((resolve, reject) => {
57
+ http[method](requestURL, query)
58
+ .then((response: IResponseData) => {
59
+ resolve(response.list);
60
+ })
61
+ .catch((e: any) => {
62
+ reject(e);
63
+ });
64
+ });
65
+ };
66
+
67
+ /**
68
+ * @description 查询服务
69
+ * @param props 查询接口的路径
70
+ * @param form 查询条件
71
+ * @param page 分页参数
72
+ * @param http http实例
73
+ * @param isDoc doc文档
74
+ * @returns Promise
75
+ */
76
+ export const query = (props, form, page, http, code, isDoc) => {
77
+ if (isDoc) return getDocData();
78
+
79
+ console.log('query', form);
80
+
81
+ for (const key in form) {
82
+ if (form[key] && isString(form[key])) {
83
+ form[key] = form[key].trim();
84
+ }
85
+ }
86
+ const params = { pageNum: page.currentPage, pageSize: page.pageSize };
87
+ const commonParam = getCookieParam();
88
+ Object.assign(params, commonParam, props.defaultParams || {}, form);
89
+
90
+ let query = formatMultipleParams(params, props.items);
91
+ query = formatDateRange(query, props.items);
92
+ const { url } = props;
93
+ if (!url) return null;
94
+ const requestURL = isString(url) ? url : url.fetch || url.restful;
95
+ const method = url.fetch ? 'post' : 'get';
96
+ if (!requestURL) return null;
97
+ return http[method](requestURL, query);
98
+ };
99
+
100
+ /**
101
+ * @description 表格删除方法
102
+ * @param http http实例
103
+ * @param records 记录行
104
+ * @param props 删除接口的路径
105
+ * @returns Promise
106
+ */
107
+ export const del = (http, records, props) => {
108
+ const { url } = props;
109
+ if (!url) return null;
110
+ const requestURL = isString(url) ? url : url.del || url.restful;
111
+ if (!requestURL) return null;
112
+ const method = url.del ? 'post' : 'delete';
113
+ return http[method](requestURL, records);
114
+ };
115
+
116
+ /** 更新服务 */
117
+ export const save = (http, body, props) => {
118
+ const allService = [];
119
+ const { url } = props;
120
+ if (!url) return null;
121
+
122
+ const { insertRecords, updateRecords } = body;
123
+ if (!isEmpty(insertRecords)) {
124
+ const commonParam = getCookieParam();
125
+ insertRecords.forEach(m => {
126
+ !isEmpty(props?.defaultValue) && Object.assign(m, props.defaultValue);
127
+ Object.keys(commonParam)?.forEach(key => {
128
+ m[key] = m[key] || commonParam[key];
129
+ });
130
+ });
131
+ const requestURL = isString(url) ? url : url.add || url.restful;
132
+ requestURL && allService.push(http.post(requestURL, insertRecords));
133
+ }
134
+ if (!isEmpty(updateRecords)) {
135
+ const requestURL = isString(url) ? url : url.save || url.restful;
136
+ const method = url.save ? 'post' : 'put';
137
+ requestURL && allService.push(http[method](requestURL, updateRecords));
138
+ }
139
+ return allService;
140
+ };
141
+
142
+ /**
143
+ * 多选数据优化
144
+ * @param listQuery
145
+ * @param items
146
+ * @returns
147
+ */
148
+ const formatMultipleParams = (listQuery: any, items) => {
149
+ const multipleItems = items.filter(f => f.itemRender?.props?.multiple || f.multiple);
150
+ if (isEmpty(multipleItems)) return listQuery;
151
+ const query = clone(listQuery, true);
152
+ multipleItems.forEach((element: any) => {
153
+ if (element.itemRender.name === '#select' && element.itemRender.props.multiple) {
154
+ if (query[`_${element.field}`]?.length === 0) {
155
+ // 重置后
156
+ query[`${element.field}`] = null;
157
+ }
158
+ delete listQuery[`_${element.field}`];
159
+ delete query[`_${element.field}`];
160
+ }
161
+ });
162
+ return query;
163
+ };
164
+
165
+ const startFormatter = 'yyyy-MM-dd 00:00:00';
166
+ const endFormatter = 'yyyy-MM-dd 23:59:59';
167
+ // 时间范围优化
168
+ const formatDateRange = (listQuery: any, items) => {
169
+ const dateRanges = items.filter(f => ['#SuDateRange', 'VxeDateRangePicker'].includes(f.itemRender?.name));
170
+ if (isEmpty(dateRanges)) return listQuery;
171
+ const query = clone(listQuery, true);
172
+ dateRanges.forEach((element: any) => {
173
+ let selectedDate = query[element.field];
174
+ if (element.itemRender.name === 'VxeDateRangePicker' && selectedDate && !isArray(selectedDate)) {
175
+ selectedDate = selectedDate.split(',');
176
+ }
177
+ const { startField, endField } = element.itemRender;
178
+ if (selectedDate && startField) {
179
+ query[startField] = toDateString(query[startField] || selectedDate[0], startFormatter);
180
+ query[endField] = toDateString(query[endField] || selectedDate[1], endFormatter);
181
+ } else if (selectedDate) {
182
+ query[`${element.field}From`] = toDateString(selectedDate[0], startFormatter);
183
+ query[`${element.field}To`] = toDateString(selectedDate[1], endFormatter);
184
+ }
185
+ delete query[element.field];
186
+ });
187
+ return query;
188
+ };
189
+
190
+ const getCookieParam = () => {
191
+ return cookies.get(kCOOKIES) ? JSON.parse(cookies.get(kCOOKIES)) : {};
192
+ };
193
+
194
+ /** 工具栏默认按钮组 */
195
+ export const inlineButtons = [
196
+ {
197
+ code: 'insert_actived',
198
+ name: 'add',
199
+ status: 'u-cyan',
200
+ icon: 'vxe-icon-add',
201
+ auth: 'add',
202
+ sort: 1
203
+ },
204
+ {
205
+ code: 'delete',
206
+ status: 'danger',
207
+ icon: 'vxe-icon-delete',
208
+ auth: 'del',
209
+ sort: 2
210
+ },
211
+ {
212
+ code: 'save',
213
+ status: 'primary',
214
+ icon: 'vxe-icon-save',
215
+ auth: 'edit',
216
+ sort: 3
217
+ }
218
+ ];
219
+ // form 模式按钮
220
+ export const dialogButtons = [
221
+ {
222
+ code: 'add',
223
+ status: 'u-cyan',
224
+ icon: 'vxe-icon-add',
225
+ auth: 'add',
226
+ sort: 1
227
+ },
228
+ {
229
+ code: 'del',
230
+ status: 'danger',
231
+ icon: 'vxe-icon-delete',
232
+ auth: 'del',
233
+ sort: 2
234
+ }
235
+ ];
236
+
237
+ export const defaultColums = [
238
+ { field: 'createdByName', width: 90, visible: false },
239
+ { field: 'creationDate', width: 140, visible: false },
240
+ { field: 'lastUpdatedByName', width: 90, visible: false },
241
+ { field: 'lastUpdateDate', width: 140, visible: false }
242
+ ];
243
+
244
+ /** 导出配置 */
245
+ export const getExportConfig = attrs => {
246
+ if (isObject(attrs.exportConfig)) return attrs.exportConfig;
247
+ return {
248
+ filename: attrs.fileName || '导出明细',
249
+ type: 'xlsx',
250
+ types: ['xlsx', 'csv'],
251
+ modes: ['current', 'selected', 'all'],
252
+ useStyle: true,
253
+ sheetMethod: ({ worksheet }) => (attrs.onSheetMethod ? attrs.onSheetMethod(worksheet) : onSheetMethod(worksheet)),
254
+ beforeExportMethod: options =>
255
+ attrs.beforeExportMethod ? (exportOptions = attrs.beforeExportMethod(options)) : null,
256
+ columnFilterMethod: ({ column }) =>
257
+ attrs.columnFilter
258
+ ? !!attrs.columnFilter(column)
259
+ : !['operate'].includes(column.field) && column.type !== 'checkbox'
260
+ };
261
+ };
262
+
263
+ export const getToolBarConfig = (data, props, attrs, hasAuthority) => {
264
+ const refreshOptions = {
265
+ icon: 'ri-refresh-line',
266
+ iconLoading: 'vxe-icon-spinner roll vxe-loading--default-icon'
267
+ };
268
+ // 不可编辑时
269
+ if (!props.editable) {
270
+ data.editConfig.editable = props.editable;
271
+ const hasExport = props.needExport && hasAuthority('export');
272
+ if (hasExport) {
273
+ data.exportConfig = getExportConfig(attrs);
274
+ }
275
+ data.toolbarConfig = {
276
+ buttons: [],
277
+ enabled: hasExport,
278
+ refreshOptions,
279
+ exportOptions: { icon: 'ri-download-2-line', code: 'export' },
280
+ export: hasExport,
281
+ custom: !!attrs.gridId,
282
+ refresh: true,
283
+ perfect: true
284
+ };
285
+ return data;
286
+ }
287
+
288
+ // 先设置传入的按钮
289
+ let buttons = clone(attrs.buttons || [], true);
290
+
291
+ buttons.forEach((button, idx) => {
292
+ button.sort = button.sort || idx + 10;
293
+ });
294
+
295
+ // 获取默认的按钮
296
+ const toolButtons = attrs.mode !== 'form' ? clone(inlineButtons, true) : clone(dialogButtons, true);
297
+ // 判断传入的按钮是否有默认按钮的auth,有就不加入按钮组中,相当于重写了默认的按钮
298
+ // reverse的原因是: 保持现有按钮顺序, 新增,保存,删除
299
+ toolButtons.reverse().forEach(btn => {
300
+ !buttons.some(s => s.code === btn.code) && buttons.unshift(btn);
301
+ if (attrs.authPrefix && !['printer', 'export'].includes(btn.auth)) {
302
+ btn.auth = attrs.authPrefix + btn.auth.slice(0, 1).toLocaleUpperCase() + btn.auth.slice(1).toLocaleLowerCase();
303
+ }
304
+ });
305
+
306
+ buttons = formatButton(buttons, props.auth).filter(button => {
307
+ const flag = button.auth ? hasAuthority(button.auth) : true;
308
+ if (button.dropdowns?.length) {
309
+ button.dropdowns = button.dropdowns.filter(btn => !btn.auth || (btn.auth && hasAuthority(btn.auth)));
310
+ }
311
+ return flag;
312
+ });
313
+ // inline 行内模式,单击行模式
314
+ const editConfig = { trigger: 'dblclick', mode: 'row', showStatus: true };
315
+ data.editConfig = attrs.mode !== 'form' ? editConfig : { enabled: false };
316
+ // 导出权限
317
+ const hasExport = props.needExport && hasAuthority('export');
318
+ let exportBtn = null;
319
+ if (hasExport) {
320
+ data.exportConfig = getExportConfig(attrs);
321
+ exportBtn = { icon: 'ri-download-2-line', code: 'export' };
322
+ }
323
+ data.toolbarConfig = {
324
+ buttons: orderBy(buttons, 'sort'),
325
+ enabled: true,
326
+ refreshOptions,
327
+ customOptions: attrs.gridId ? {} : null,
328
+ exportOptions: exportBtn,
329
+ custom: !!attrs.gridId,
330
+ export: hasExport,
331
+ refresh: true,
332
+ perfect: true
333
+ };
334
+ return data;
335
+ };
336
+
337
+ /**
338
+ * @description: 表格脚合并方法
339
+ * @param {*} columns 列数据
340
+ * @param {*} data 数据源
341
+ * @param {*} sum 合并属性
342
+ * @return {*} 合并脚方法
343
+ */
344
+ export const footerSumMethod = ({ columns, data }, sum) => {
345
+ return [
346
+ columns.map((column, columnIdx) => {
347
+ if (columnIdx === (sum.index || 0)) {
348
+ return sum.label || '合计';
349
+ }
350
+ if (sum.fields?.includes(column.property)) {
351
+ const total = data.reduce((prev, cur) => {
352
+ return prev + Number(cur[column.property] || 0);
353
+ }, 0);
354
+ return total ? Number(total.toFixed(sum.decimal || 2)) : total;
355
+ }
356
+ return '';
357
+ })
358
+ ];
359
+ };
360
+
361
+ /**
362
+ * @description: checkbox是否可选
363
+ */
364
+ export const onCheckMethod = (row, props) => {
365
+ if (isFunction(props.checkMethod)) {
366
+ return props.checkMethod(row);
367
+ }
368
+ return true;
369
+ };
370
+
371
+ /*** excel样式重置 */
372
+ const onSheetMethod = ws => {
373
+ ws.eachRow((row, rowNumber) => {
374
+ row.font = { name: '微软雅黑', size: 9 };
375
+ row.border = {
376
+ top: { style: 'thin' },
377
+ left: { style: 'thin' },
378
+ bottom: { style: 'thin' },
379
+ right: { style: 'thin' }
380
+ };
381
+
382
+ if (rowNumber === 1) {
383
+ row.fill = {
384
+ type: 'pattern',
385
+ pattern: 'solid',
386
+ fgColor: { argb: '4F81BD' }
387
+ };
388
+ row.font = {
389
+ name: '微软雅黑',
390
+ size: 10,
391
+ bold: true,
392
+ color: { argb: 'FFFFFFFF' }
393
+ };
394
+ }
395
+ });
396
+ };
397
+
398
+ const getDocData = () => {
399
+ return new Promise(resolve => {
400
+ setTimeout(() => {
401
+ const list = [
402
+ { id: 1, name: 'Test1', sex: 'Man', age: 28, address: 'Shenzhen' },
403
+ { id: 2, name: 'Test2', sex: 'Women', age: 22, address: 'Guangzhou' },
404
+ { id: 3, name: 'Test3', sex: 'Man', age: 32, address: 'Shanghai' },
405
+ { id: 4, name: 'Test4', sex: 'Women', age: 23, address: 'test abc' },
406
+ { id: 5, name: 'Test5', sex: 'Women', age: 30, address: 'Shanghai' }
407
+ ];
408
+ resolve({ list, total: 5 });
409
+ }, 100);
410
+ });
411
+ };
412
+
413
+ export const getAttrs = attrs => {
414
+ const data = {};
415
+ Object.keys(attrs).forEach(key => {
416
+ const nKey = key.replace(/-(\w)/g, str => str.slice(1).toUpperCase());
417
+ data[nKey] = attrs[key];
418
+ });
419
+ return data;
420
+ };