@utogether/udp-core 2.0.0-beta.26 → 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 (183) hide show
  1. package/dist/403-CyoOD-Ik.js +65 -0
  2. package/dist/404-Ch_OHTw0.js +65 -0
  3. package/dist/500-Cf9am7HK.js +67 -0
  4. package/dist/AuthorityInfo-BJ427cqG.js +4 -0
  5. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-D9y7AwbB.js +99 -0
  6. package/dist/AuthorityPanel-lVnZ5bce.js +4 -0
  7. package/dist/AuthorityPanel.vue_vue_type_style_index_0_lang-nsfhDlvV.js +113 -0
  8. package/dist/Company-qo-lKPkv.js +25 -0
  9. package/dist/CompanyPanel-DkKWAKvY.js +204 -0
  10. package/dist/DataSet-iBHzs75s.js +147 -0
  11. package/dist/Department-CHUQByKX.js +25 -0
  12. package/dist/DepartmentPanel-C742dfOO.js +248 -0
  13. package/dist/DesignPanel-D9oE5R7m.js +4 -0
  14. package/dist/DesignPanel.vue_vue_type_style_index_0_lang-hYldVEbo.js +1097 -0
  15. package/dist/DictView-CrFXprP9.js +110 -0
  16. package/dist/InvOrganization-Cz8SzIgs.js +73 -0
  17. package/dist/Org-Bzt6yKox.js +38 -0
  18. package/dist/Preview-jonigfMQ.js +48 -0
  19. package/dist/ReportDefine-BpiM5Ovq.js +10 -0
  20. package/dist/ReportDesign-fp09cXJ7.js +164 -0
  21. package/dist/ReportQuery-52ZP1PYP.js +74 -0
  22. package/dist/ReportQueryFrom-DSYavJb1.js +4 -0
  23. package/dist/ReportQueryFrom.vue_vue_type_style_index_0_lang-DBGYEp0u.js +177 -0
  24. package/dist/ReportTemplate-CA_UW0eD.js +161 -0
  25. package/dist/Role-DqOt8Bk0.js +25 -0
  26. package/dist/RoleAssign-BdxhefhQ.js +26 -0
  27. package/dist/RolePanel-2gZ3H0ET.js +4 -0
  28. package/dist/RolePanel-BsNd0svJ.js +4 -0
  29. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-DLOwgF99.js +152 -0
  30. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-DmzD9kab.js +131 -0
  31. package/dist/ScrollPanel.vue_vue_type_style_index_0_lang-B9ptUMeI.js +99 -0
  32. package/dist/Staff-D3L8fEoY.js +26 -0
  33. package/dist/StaffInfo-DYRw6ZYJ.js +4 -0
  34. package/dist/StaffInfo.vue_vue_type_script_setup_true_lang-xqEOQnMs.js +107 -0
  35. package/dist/StaffPanel-DkrNH6Px.js +4 -0
  36. package/dist/StaffPanel.vue_vue_type_script_setup_true_lang-BPBMnliy.js +152 -0
  37. package/dist/SysUser-Bl1-cIpJ.js +15 -0
  38. package/dist/SysUserPanel-yxNLaBwt.js +4 -0
  39. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-BDcsgSl5.js +352 -0
  40. package/dist/SystemMenu-C4_Arn12.js +155 -0
  41. package/dist/UserInfo-QcNwJCUR.js +4 -0
  42. package/dist/UserInfo.vue_vue_type_style_index_0_lang-DLIeUphX.js +159 -0
  43. package/dist/childView-B23DEO2u.js +4 -0
  44. package/dist/childView-saDZQv9x.js +4 -0
  45. package/dist/childView.vue_vue_type_style_index_0_lang-RsKR6CAC.js +182 -0
  46. package/dist/childView.vue_vue_type_style_index_0_lang-ZFEfavUY.js +142 -0
  47. package/dist/code-rule-2_Ihx_by.js +147 -0
  48. package/dist/core.es.js +26 -6
  49. package/dist/cron-task-BFOPJQIk.js +134 -0
  50. package/dist/flow-task-PoDnE_kE.js +10 -0
  51. package/dist/frameView-f7Ya0Knj.js +43 -0
  52. package/dist/index-BpdTDaTk.js +3213 -0
  53. package/dist/layout-home-v3DPJ7rB.js +231 -0
  54. package/dist/layoutView-DZHoQDH1.js +3190 -0
  55. package/dist/log-in-BPAMJTwH.js +115 -0
  56. package/dist/log-out-DZACF0jg.js +129 -0
  57. package/dist/login-B8cwozax.js +216 -0
  58. package/dist/login-log-CVvRgZSu.js +70 -0
  59. package/dist/lov-view-Ba7Y7xy0.js +98 -0
  60. package/dist/menuInfo-BpRKFYK8.js +4 -0
  61. package/dist/menuInfo.vue_vue_type_style_index_0_lang-DJ5sUC6m.js +359 -0
  62. package/dist/pda-app-C0jJecrL.js +706 -0
  63. package/dist/redirect-DTz8GSnv.js +15 -0
  64. package/dist/resource-BG22Cw4P.js +97 -0
  65. package/dist/su-welcome-DaxhbrC6.js +879 -0
  66. package/dist/sys-config-CG2fMtak.js +384 -0
  67. package/dist/udp-core.css +1 -2
  68. package/dist/useNav-_u2UAQWk.js +84 -0
  69. package/dist/utogether-MlnyYtNS.js +4 -0
  70. package/dist/wecom-push-B75FLee5.js +70 -0
  71. package/index.ts +54 -50
  72. package/package.json +21 -21
  73. package/src/App.vue +79 -78
  74. package/src/api/http.ts +10 -4
  75. package/src/api/index.ts +51 -51
  76. package/src/api/user.ts +64 -64
  77. package/src/components/SuQrcode/src/index.tsx +231 -236
  78. package/src/components/udp/content/index.vue +93 -93
  79. package/src/components/udp/form-upload/form-upload.vue +496 -496
  80. package/src/components/udp/grid/index.vue +643 -544
  81. package/src/components/udp/index.ts +2 -1
  82. package/src/components/udp/modal-form/index.vue +326 -0
  83. package/src/components/udp/utils.ts +420 -420
  84. package/src/layout/components/lay-navbar/index.vue +240 -240
  85. package/src/layout/components/lay-panel/index.vue +2 -6
  86. package/src/layout/components/lay-search/components/SearchModal.vue +185 -181
  87. package/src/layout/components/lay-sidebar/mixNav.vue +261 -261
  88. package/src/layout/components/lay-sidebar/sidebarItem.vue +199 -195
  89. package/src/layout/components/lay-sidebar/vertical.vue +92 -92
  90. package/src/layout/layoutView.vue +1 -0
  91. package/src/main.ts +111 -109
  92. package/src/plugins/i18n/zh.ts +5 -1
  93. package/src/plugins/vxe-table/index.ts +116 -116
  94. package/src/router/index.ts +5 -34
  95. package/src/router/utils.ts +434 -430
  96. package/src/store/modules/permission.ts +1 -1
  97. package/src/store/modules/system.ts +193 -186
  98. package/src/style/print-lock.css +380 -375
  99. package/src/style/suprint.css +990 -985
  100. package/src/style/vxetable.scss +372 -364
  101. package/src/utils/authority/index.ts +19 -2
  102. package/src/utils/dataFormat/index.ts +309 -222
  103. package/src/utils/udp/http/index.ts +126 -67
  104. package/src/utils/udp/http/types.d.ts +15 -14
  105. package/src/views/login/login-view.vue +4 -21
  106. package/src/views/organization/department/DepartmentPanel.vue +3 -4
  107. package/src/views/system/sys/sys-config.vue +344 -344
  108. package/src/views/uhome/components/home-todo.vue +191 -178
  109. package/src/views/uhome/dynamic-card.vue +31 -31
  110. package/src/views/uhome/su-welcome.vue +310 -310
  111. package/src/views/ulogin/login.vue +292 -296
  112. package/src/views/urpt/design/DesignPanel.vue +538 -507
  113. package/src/views/urpt/design/print-data.ts +39 -59
  114. package/tsconfig.json +2 -3
  115. package/types/global.d.ts +234 -234
  116. package/vite.config.ts +2 -1
  117. package/dist/403-D6Wb3JJh.js +0 -72
  118. package/dist/404-B_HNbPNV.js +0 -72
  119. package/dist/500-BMemTTy1.js +0 -77
  120. package/dist/AuthorityInfo-6wHxwiFM.js +0 -91
  121. package/dist/AuthorityPanel-OqF_DvXA.js +0 -98
  122. package/dist/Company-BLXSfow0.js +0 -21
  123. package/dist/CompanyPanel-B4kRZ5Cg.js +0 -199
  124. package/dist/DataSet-CuGZcKC-.js +0 -141
  125. package/dist/Department-oFhsa7cd.js +0 -21
  126. package/dist/DepartmentPanel-B1UGpu-r.js +0 -242
  127. package/dist/DepartmentPanel-BL58AdoT.js +0 -2
  128. package/dist/DesignPanel-DmkFVw1N.js +0 -1196
  129. package/dist/DictView-CC5yMzOq.js +0 -100
  130. package/dist/File-WJXjGYxr.js +0 -89
  131. package/dist/InvOrganization-BwMmD8Ua.js +0 -76
  132. package/dist/Org-HgnOWubi.js +0 -76
  133. package/dist/Preview-CAzWxLmP.js +0 -45
  134. package/dist/ReIcon-DecitXmg.js +0 -413
  135. package/dist/ReportDefine-BgLM-Rjk.js +0 -10
  136. package/dist/ReportDesign-DwchGG2P.js +0 -158
  137. package/dist/ReportQuery-D5jaRJEn.js +0 -101
  138. package/dist/ReportQueryFrom-CNlmtYey.js +0 -198
  139. package/dist/ReportTemplate-CNcTmccs.js +0 -162
  140. package/dist/Role-Be8WfdCA.js +0 -21
  141. package/dist/RoleAssign-CtehGAUf.js +0 -22
  142. package/dist/RolePanel-CAwITg_q.js +0 -131
  143. package/dist/RolePanel-SN0FGFZ7.js +0 -176
  144. package/dist/ScrollPanel-DW30pGz1.js +0 -88
  145. package/dist/Staff-V2YsNKcj.js +0 -22
  146. package/dist/StaffInfo-CKRPW0r4.js +0 -149
  147. package/dist/StaffPanel-BxcgMg7u.js +0 -143
  148. package/dist/SysUser-Dxyj5w5m.js +0 -12
  149. package/dist/SysUserPanel-DI6CWcZo.js +0 -365
  150. package/dist/SystemMenu-BBHREM8T.js +0 -154
  151. package/dist/UserInfo-BMVQ0xwE.js +0 -194
  152. package/dist/_plugin-vue_export-helper-C6QCLu9I.js +0 -8
  153. package/dist/api-BFNxcxSN.js +0 -30
  154. package/dist/authority-BJFEUdrh.js +0 -20
  155. package/dist/await-to-js.es5-DkWYmPXW.js +0 -10
  156. package/dist/childView-BBjPEraB.js +0 -184
  157. package/dist/childView-DNqG2UVm.js +0 -181
  158. package/dist/code-rule-QFrhqFrW.js +0 -151
  159. package/dist/contant-Q77dU_V3.js +0 -4
  160. package/dist/cron-task-BpUDKEAU.js +0 -131
  161. package/dist/flow-task-DAc2NrDU.js +0 -11
  162. package/dist/frameView-Di0zJZUR.js +0 -39
  163. package/dist/layout-home-BVp7vYLR.js +0 -239
  164. package/dist/layoutView-B6Mx2ERA.js +0 -2662
  165. package/dist/log-in-BrNB0mLz.js +0 -117
  166. package/dist/log-out-dYfqvzy6.js +0 -111
  167. package/dist/login-D_Hjy3Jd.js +0 -231
  168. package/dist/login-log-CJak-ANA.js +0 -79
  169. package/dist/lov-view-DM5Nm5tW.js +0 -95
  170. package/dist/menuInfo-BlOY1KZW.js +0 -346
  171. package/dist/mitt-CQgI7DYU.js +0 -27
  172. package/dist/pda-app-CA7YI37u.js +0 -589
  173. package/dist/redirect-N0k4tImU.js +0 -16
  174. package/dist/resource-CfQTHFcs.js +0 -94
  175. package/dist/su-welcome-DVD3S_du.js +0 -799
  176. package/dist/sys-config-Ddb3vBpK.js +0 -316
  177. package/dist/system-Cm3lyBas.js +0 -1528
  178. package/dist/udp-core-DaQd5CF1.js +0 -2028
  179. package/dist/useDataThemeChange-DJ4K3VGp.js +0 -226
  180. package/dist/useNav-BhOJIdrJ.js +0 -106
  181. package/dist/utogether-l7JXs4Lv.js +0 -4
  182. package/dist/water-mark-WDQZ9YqB.js +0 -119
  183. package/dist/wecom-push-kWkAVRCj.js +0 -77
@@ -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
+ };