@utogether/udp-core 1.0.1-beta.3 → 1.0.1-beta.31

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 (165) hide show
  1. package/build/plugins.ts +3 -3
  2. package/dist/{403-BuP9jvH9.js → 403-DdjDWbkf.js} +1 -1
  3. package/dist/{404-DfQk8kKl.js → 404-D9vF2gFz.js} +1 -1
  4. package/dist/{500-OgROWdiZ.js → 500-mVaDmUjL.js} +1 -1
  5. package/dist/{AuthorityInfo-q2ksfkWH.js → AuthorityInfo-DOUJ_Zrj.js} +1 -1
  6. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-B12sAzqt.js +100 -0
  7. package/dist/{Company-DgqowAxc.js → Company-DY__kM9F.js} +3 -3
  8. package/dist/{CompanyPanel-BNb1rUhD.js → CompanyPanel-C5N8QcMA.js} +17 -17
  9. package/dist/{Department-Cl8CROSU.js → Department-DsuDZdy5.js} +3 -3
  10. package/dist/{DepartmentPanel-D5VkqKeP.js → DepartmentPanel-CdwI7Rzu.js} +25 -25
  11. package/dist/{DesignPanel-BGvEusHC.js → DesignPanel-B50-g0TL.js} +1 -1
  12. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-BQF1uQ7w.js → DesignPanel.vue_vue_type_style_index_0_lang-KV8JOZ6v.js} +28 -30
  13. package/dist/DictView-Be2Z5Obk.js +110 -0
  14. package/dist/InvOrganization-Lui1q3Ou.js +74 -0
  15. package/dist/Org-qO5ExsPN.js +39 -0
  16. package/dist/{Preview-BaGmXH7r.js → Preview-Dq4dfV2D.js} +2 -2
  17. package/dist/{ReportDefine-DkQdBErt.js → ReportDefine-DH3FvbS1.js} +1 -1
  18. package/dist/{ReportDesign-DzB_A_G6.js → ReportDesign-Bou01Jbr.js} +43 -43
  19. package/dist/{ReportQuery-DRcMb6ya.js → ReportQuery-BBkmPPSw.js} +1 -1
  20. package/dist/{ReportQueryFrom-CeA9xhR4.js → ReportQueryFrom-BCY8lTJ7.js} +1 -1
  21. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-CgGtcs5V.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-CpktcM8J.js} +1 -1
  22. package/dist/{ReportTemplate-qaiTMQuT.js → ReportTemplate-C_yJXxQ-.js} +28 -28
  23. package/dist/{Role-DsFulAjq.js → Role-CTatYsrC.js} +6 -6
  24. package/dist/{RoleAssign-DMRdocpa.js → RoleAssign-Cqt3CelK.js} +9 -9
  25. package/dist/{RolePanel-wXVysDHM.js → RolePanel-C3JMpNu8.js} +1 -1
  26. package/dist/{RolePanel-B9POS_pg.js → RolePanel-brKRJIhD.js} +1 -1
  27. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-DD8u9pq8.js +132 -0
  28. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CleVvkcY.js → RolePanel.vue_vue_type_script_setup_true_lang-i6Gq4r5B.js} +44 -38
  29. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-DlXUs0j9.js → ScrollPanel.vue_vue_type_style_index_0_lang-CiWKyjm3.js} +23 -23
  30. package/dist/{Staff-Cq4V7ruC.js → Staff-Cd3twQ6Y.js} +3 -3
  31. package/dist/{StaffInfo-CJDKMbud.js → StaffInfo-DJp0a0qd.js} +1 -1
  32. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DQ4DL1KY.js → StaffInfo.vue_vue_type_script_setup_true_lang-Dp2AhJ4I.js} +16 -16
  33. package/dist/{StaffPanel-CG-uggdr.js → StaffPanel-B93hClzs.js} +1 -1
  34. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-DAgN7zN2.js → StaffPanel.vue_vue_type_script_setup_true_lang-CXjUzq7n.js} +2 -2
  35. package/dist/{SysUser-kwnzRNdD.js → SysUser-BvI6vaqI.js} +2 -2
  36. package/dist/{SysUserPanel-DTlZf3vk.js → SysUserPanel-C9V8X-Ek.js} +1 -1
  37. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-bMqTui07.js +343 -0
  38. package/dist/{SystemMenu-BVT0n-L2.js → SystemMenu-D4WME5d0.js} +27 -27
  39. package/dist/{UserInfo-BbTQ9Zat.js → UserInfo-D-AfdfJs.js} +1 -1
  40. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-D_bpYDmI.js → UserInfo.vue_vue_type_style_index_0_lang-C-JQYIxe.js} +41 -39
  41. package/dist/{childView-BJbIhjmf.js → childView--WMSo-wH.js} +1 -1
  42. package/dist/{childView-DCsGFrG-.js → childView-1MTl6Kaj.js} +1 -1
  43. package/dist/childView.vue_vue_type_style_index_0_lang-B8Losc4Y.js +170 -0
  44. package/dist/{childView.vue_vue_type_style_index_0_lang-BCDxpVoD.js → childView.vue_vue_type_style_index_0_lang-BAVKNIXs.js} +1 -1
  45. package/dist/{code-rule-DePU6cdp.js → code-rule-D-RqrQB6.js} +42 -41
  46. package/dist/core.es.js +19 -10
  47. package/dist/{cron-task-DUM1SIGL.js → cron-task-D-X-KFZm.js} +11 -11
  48. package/dist/flow-task-B07st2aD.js +10 -0
  49. package/dist/{frameView-CEUTDtSm.js → frameView-MAW_-GHJ.js} +1 -1
  50. package/dist/index-Bc9vCX7z.js +2904 -0
  51. package/dist/{layoutView-PCjwVwkX.js → layoutView-De2QIEr2.js} +1639 -1629
  52. package/dist/{log-in-e7D5Ss1P.js → log-in-CpGqc33f.js} +5 -4
  53. package/dist/{log-out--RRncZhN.js → log-out-D1b4VRMZ.js} +30 -24
  54. package/dist/{login-log-CvVnyGi3.js → login-log-BNRXLeMi.js} +4 -3
  55. package/dist/login-rdZ0GPYc.js +249 -0
  56. package/dist/{lov-view-D8wwkxFJ.js → lov-view-Ao7LMspL.js} +5 -5
  57. package/dist/{menuInfo-B5JKVwrB.js → menuInfo-DmOcK6An.js} +1 -1
  58. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-CcM9WX4n.js → menuInfo.vue_vue_type_style_index_0_lang-Ln-zFWV7.js} +121 -99
  59. package/dist/{pda-app-DIa1p1Ww.js → pda-app-DY63mQ2T.js} +202 -188
  60. package/dist/{resource-CCQ7Dd-5.js → resource-B21uV58T.js} +18 -18
  61. package/dist/{su-welcome-CLp9YaJa.js → su-welcome-DgjzJeDF.js} +122 -121
  62. package/dist/sys-config-DOtK2I32.js +370 -0
  63. package/dist/udp-core.css +1 -9
  64. package/dist/utogether-MlnyYtNS.js +4 -0
  65. package/index.ts +19 -6
  66. package/package.json +1 -1
  67. package/src/App.vue +65 -70
  68. package/src/api/http.ts +1 -4
  69. package/src/api/index.ts +5 -3
  70. package/src/api/user.ts +2 -2
  71. package/src/components/SuCharts/src/UserInfo.vue +3 -3
  72. package/src/components/SuScrollTree/ScrollPanel.vue +4 -9
  73. package/src/components/udp/content/index.vue +88 -0
  74. package/src/components/udp/form/form.vue +109 -0
  75. package/src/components/udp/{grid.vue → grid/index.vue} +524 -500
  76. package/src/components/udp/index.ts +4 -6
  77. package/src/components/udp/ut-stamp-badge/index.vue +272 -0
  78. package/src/components/udp/utils.ts +408 -379
  79. package/src/directives/permission/index.ts +1 -1
  80. package/src/layout/components/lay-navbar/index.vue +8 -6
  81. package/src/layout/components/lay-panel/index.vue +150 -150
  82. package/src/layout/components/lay-search/index.vue +1 -1
  83. package/src/layout/components/lay-select-org/index.vue +4 -9
  84. package/src/layout/components/lay-sidebar/horizontal.vue +8 -6
  85. package/src/layout/components/lay-sidebar/mixNav.vue +260 -258
  86. package/src/layout/components/lay-sidebar/sidebar-logo.vue +8 -12
  87. package/src/layout/components/lay-tag/index.vue +596 -625
  88. package/src/layout/hooks/useTag.ts +12 -18
  89. package/src/layout/types.ts +3 -2
  90. package/src/main.ts +115 -110
  91. package/src/plugins/i18n/en.ts +302 -291
  92. package/src/plugins/i18n/module/u-workflow.ts +1 -1
  93. package/src/plugins/i18n/zh.ts +362 -338
  94. package/src/plugins/vxe-table/index.ts +116 -53
  95. package/src/plugins/vxe-table/render.tsx +183 -57
  96. package/src/router/index.ts +101 -97
  97. package/src/router/modules/flow.ts +35 -0
  98. package/src/router/modules/remaining.ts +1 -26
  99. package/src/router/utils.ts +50 -7
  100. package/src/store/modules/app.ts +1 -3
  101. package/src/store/modules/multiTags.ts +15 -14
  102. package/src/store/modules/permission.ts +25 -15
  103. package/src/store/modules/system.ts +1 -3
  104. package/src/style/button.scss +85 -85
  105. package/src/style/login.css +1 -1
  106. package/src/style/vxetable.scss +348 -258
  107. package/src/utils/authority/index.ts +1 -1
  108. package/src/utils/index.ts +3 -1
  109. package/src/utils/propTypes.ts +1 -6
  110. package/src/utils/{http → udp/http}/index.ts +27 -30
  111. package/src/utils/{http → udp/http}/types.d.ts +2 -6
  112. package/src/views/login/login-view.vue +6 -20
  113. package/src/views/organization/company/CompanyPanel.vue +259 -259
  114. package/src/views/organization/department/DepartmentPanel.vue +6 -20
  115. package/src/views/organization/inv-org/InvOrganization.vue +22 -7
  116. package/src/views/organization/org/Org.vue +9 -5
  117. package/src/views/system/cron/cron-task.vue +2 -12
  118. package/src/views/system/menu/SystemMenu.vue +185 -197
  119. package/src/views/system/menu/menuInfo.vue +384 -372
  120. package/src/views/system/role/AuthorityInfo.vue +19 -15
  121. package/src/views/system/role/Role.vue +1 -5
  122. package/src/views/system/role/RolePanel.vue +11 -2
  123. package/src/views/system/role/UserInfo.vue +11 -9
  124. package/src/views/system/role-assign/RoleAssign.vue +2 -2
  125. package/src/views/system/role-assign/RolePanel.vue +12 -9
  126. package/src/views/system/sys/sys-config.vue +70 -21
  127. package/src/views/system/sysUser/SysUserPanel.vue +132 -62
  128. package/src/views/uapp/pda/pda-app.vue +48 -16
  129. package/src/views/udev/coderule/code-rule.vue +132 -121
  130. package/src/views/udev/dict/DictView.vue +118 -106
  131. package/src/views/udev/dict/childView.vue +71 -111
  132. package/src/views/udev/lov/childView.vue +1 -7
  133. package/src/views/udev/lov/lov-view.vue +91 -91
  134. package/src/views/ufile/aggregation/File.vue +5 -5
  135. package/src/views/ufile/file/water-mark.vue +14 -14
  136. package/src/views/uhome/components/menu-favorite.vue +314 -331
  137. package/src/views/uhome/su-welcome.vue +3 -3
  138. package/src/views/ulogin/login.vue +19 -12
  139. package/src/views/upms/interface/log-in.vue +2 -8
  140. package/src/views/upms/interface/log-out.vue +2 -8
  141. package/src/views/upms/user/login-log.vue +2 -8
  142. package/src/views/urpt/design/DesignPanel.vue +16 -35
  143. package/src/views/urpt/design/Preview.vue +1 -0
  144. package/src/views/urpt/design/ReportDesign.vue +17 -23
  145. package/src/views/urpt/static-resource/resource.vue +3 -3
  146. package/src/views/urpt/template/ReportTemplate.vue +7 -7
  147. package/src/views/utask/flow-task.vue +18 -0
  148. package/types/global.d.ts +4 -9
  149. package/vite.config.ts +2 -1
  150. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-Bwsf6lMH.js +0 -102
  151. package/dist/DictView-BnxfaOBv.js +0 -96
  152. package/dist/InvOrganization-5y79ZLdY.js +0 -66
  153. package/dist/Org-2oBAXN2r.js +0 -35
  154. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-t6S_0zmJ.js +0 -126
  155. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-BW6PlGjM.js +0 -288
  156. package/dist/childView.vue_vue_type_style_index_0_lang-CDtsalCm.js +0 -187
  157. package/dist/index-ZdgOD7cF.js +0 -3399
  158. package/dist/login-B1CjWVKu.js +0 -252
  159. package/dist/sys-config-BBmf_SqF.js +0 -277
  160. package/dist/utogether-Bkptx2lB.js +0 -182
  161. package/src/components/udp/form-upload.vue +0 -183
  162. package/src/components/udp/lov.vue +0 -410
  163. package/src/components/udp/modal-form.vue +0 -180
  164. package/src/components/udp/modal-grid.vue +0 -297
  165. package/src/utils/udp/useRender.ts +0 -420
@@ -1,379 +1,408 @@
1
- /*
2
- * @Author: levi7754 levi7754@163.com
3
- * @Date: 2025-07-14 17:38:38
4
- * @LastEditors: levi7754 levi7754@163.com
5
- * @LastEditTime: 2025-07-23 10:31:52
6
- * @FilePath: \udp-front\packages\udp-core\src\components\udp\utils.ts
7
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8
- */
9
- import { clone, isString, isEmpty, toDateString, isObject, isFunction } from 'xe-utils';
10
- import { cookies, storageLocal } from '@utogether/utils';
11
- /** 系统配置的key */
12
- const kSYSCONFIG = 'kSysConfig';
13
- const kCOOKIES = 'kCookies_param';
14
-
15
- const sysConfig = storageLocal.getItem(kSYSCONFIG);
16
-
17
- /** 工具栏按钮标准化 */
18
- export const formatButton = (buttons, auth?) => {
19
- buttons.forEach(btn => {
20
- btn.auth = auth ? auth[btn.code] || btn.auth : btn.auth;
21
- if (!btn.name) {
22
- btn.name = `message.btn.${btn.code}`;
23
- } else if (sysConfig?.i18nEnabled === 'Y' && !btn.name.startsWith('message.')) {
24
- btn.name = `message.btn.${btn.name}`;
25
- }
26
- if (btn.dropdowns?.length) {
27
- formatButton(btn.dropdowns, auth);
28
- }
29
- });
30
- return buttons;
31
- };
32
-
33
- /**
34
- * @description 查询10W数据,常用于Excel导出
35
- * @param props 查询接口的路径
36
- * @param http http实例
37
- * @param form 查询条件
38
- * @returns 查询返回的数据
39
- */
40
- export const queryAll = (props, http, form) => {
41
- const params = { pageNum: 1, pageSize: 100000 };
42
- const commonParam = getCookieParam();
43
- Object.assign(params, form, commonParam, props.defaultParams || {});
44
- const query = formatDateRange(params, props.items);
45
-
46
- const { url } = props;
47
- if (!url) return null;
48
- const requestURL = isString(url) ? url : url.fetch || url.restful;
49
- if (!requestURL) return null;
50
- const method = url.fetch ? 'post' : 'get';
51
- return new Promise((resolve, reject) => {
52
- http[method](requestURL, query)
53
- .then((response: IResponseData) => {
54
- resolve(response.list);
55
- })
56
- .catch((e: any) => {
57
- reject(e);
58
- });
59
- });
60
- };
61
-
62
- /**
63
- * @description 查询服务
64
- * @param props 查询接口的路径
65
- * @param form 查询条件
66
- * @param page 分页参数
67
- * @param http http实例
68
- * @param isDoc doc文档
69
- * @returns Promise
70
- */
71
- export const query = (props, form, page, http, isDoc) => {
72
- if (isDoc) return getDocData();
73
- for (const key in form) {
74
- if (form[key] && isString(form[key])) {
75
- form[key] = form[key].trim();
76
- }
77
- }
78
- const params = { pageNum: page.currentPage, pageSize: page.pageSize };
79
- const commonParam = getCookieParam();
80
- Object.assign(params, commonParam, props.defaultParams || {}, form);
81
- const query = formatDateRange(params, props.items);
82
- const { url } = props;
83
- console.log(query);
84
- if (!url) return null;
85
- const requestURL = isString(url) ? url : url.fetch || url.restful;
86
- const method = url.fetch ? 'post' : 'get';
87
- if (!requestURL) return null;
88
- return http[method](requestURL, query);
89
- };
90
-
91
- /**
92
- * @description 表格删除方法
93
- * @param http http实例
94
- * @param records 记录行
95
- * @param props 删除接口的路径
96
- * @returns Promise
97
- */
98
- export const del = (http, records, props) => {
99
- const { url } = props;
100
- if (!url) return null;
101
- const requestURL = isString(url) ? url : url.del || url.restful;
102
- if (!requestURL) return null;
103
- const method = url.del ? 'post' : 'delete';
104
- return http[method](requestURL, records);
105
- };
106
-
107
- /** 更新服务 */
108
- export const save = (http, body, props) => {
109
- const allService = [];
110
- const { url } = props;
111
- if (!url) return null;
112
-
113
- const { insertRecords, updateRecords } = body;
114
- if (!isEmpty(insertRecords)) {
115
- const commonParam = getCookieParam();
116
- insertRecords.forEach(m => {
117
- !isEmpty(props?.defaultValue) && Object.assign(m, props.defaultValue);
118
- Object.keys(commonParam)?.forEach(key => {
119
- m[key] = m[key] || commonParam[key];
120
- });
121
- });
122
- const requestURL = isString(url) ? url : url.add || url.restful;
123
- requestURL && allService.push(http.post(requestURL, insertRecords));
124
- }
125
- if (!isEmpty(updateRecords)) {
126
- const requestURL = isString(url) ? url : url.save || url.restful;
127
- const method = url.save ? 'post' : 'put';
128
- requestURL && allService.push(http[method](requestURL, updateRecords));
129
- }
130
- return allService;
131
- };
132
-
133
- const startFormatter = 'yyyy-MM-dd 00:00:00';
134
- const endFormatter = 'yyyy-MM-dd 23:59:59';
135
- const formatDateRange = (listQuery: any, items) => {
136
- const dateRanges = items.filter(
137
- f => f.itemRender?.name === '#SuDateRange' || f.itemRender?.props?.multiple || f.multiple
138
- );
139
- if (isEmpty(dateRanges)) return listQuery;
140
- const query = clone(listQuery, true);
141
- dateRanges.forEach((element: any) => {
142
- if (element.multiple || element.itemRender?.props?.multiple) {
143
- query[element.field] = query[element.field]?.join(',');
144
- } else {
145
- const val = query[element.field];
146
- if (val && element.toField) {
147
- query[element.fromField] = toDateString(val[0], startFormatter);
148
- query[element.toField] = toDateString(val[1], endFormatter);
149
- } else if (val) {
150
- query[`${element.field}From`] = toDateString(val[0], startFormatter);
151
- query[`${element.field}To`] = toDateString(val[1], endFormatter);
152
- }
153
- delete query[element.field];
154
- }
155
- });
156
- return query;
157
- };
158
-
159
- const getCookieParam = () => {
160
- return cookies.get(kCOOKIES) ? JSON.parse(cookies.get(kCOOKIES)) : {};
161
- };
162
-
163
- /** 工具栏默认按钮组 */
164
- export const inlineButtons = [
165
- {
166
- code: 'insert_actived',
167
- name: 'add',
168
- status: 'u-cyan',
169
- icon: 'vxe-icon-add',
170
- auth: 'add'
171
- },
172
- {
173
- code: 'delete',
174
- status: 'danger',
175
- icon: 'vxe-icon-delete',
176
- auth: 'del'
177
- },
178
- {
179
- code: 'save',
180
- status: 'primary',
181
- icon: 'vxe-icon-save',
182
- auth: 'edit'
183
- }
184
- ];
185
- // form 模式按钮
186
- export const dialogButtons = [
187
- {
188
- code: 'add',
189
- status: 'u-cyan',
190
- icon: 'vxe-icon-add',
191
- auth: 'add'
192
- },
193
- {
194
- code: 'delete',
195
- status: 'danger',
196
- icon: 'vxe-icon-delete',
197
- auth: 'del'
198
- }
199
- ];
200
-
201
- export const defaultColums = [
202
- { field: 'createdByName', width: 90, visible: false },
203
- { field: 'creationDate', width: 140, visible: false },
204
- { field: 'lastUpdatedByName', width: 90, visible: false },
205
- { field: 'lastUpdateDate', width: 140, visible: false }
206
- ];
207
-
208
- /** 导出配置 */
209
- export const getExportConfig = attrs => {
210
- if (isObject(attrs.exportConfig)) return attrs.exportConfig;
211
- return {
212
- filename: attrs.fileName || '导出明细',
213
- type: 'xlsx',
214
- types: ['xlsx', 'csv'],
215
- modes: ['current', 'selected', 'all'],
216
- useStyle: true,
217
- sheetMethod: ({ worksheet }) =>
218
- attrs.onSheetMethod ? attrs.onSheetMethod(worksheet) : onSheetMethod(worksheet),
219
- columnFilterMethod: ({ column }) =>
220
- attrs.columnFilter
221
- ? !!attrs.columnFilter(column)
222
- : !['operate'].includes(column.field) && column.type !== 'checkbox'
223
- };
224
- };
225
-
226
- export const getToolBarConfig = (data, props, attrs, hasAuthority) => {
227
- const refresh = {
228
- icon: 'ri-refresh-line',
229
- iconLoading: 'vxe-icon-spinner roll vxe-loading--default-icon'
230
- };
231
- // 不可编辑时
232
- if (!props.editable) {
233
- data.editConfig.editable = props.editable;
234
- const hasExport = props.needExport && hasAuthority('export');
235
- if (hasExport) {
236
- data.exportConfig = getExportConfig(attrs);
237
- }
238
- data.toolbarConfig = {
239
- buttons: [],
240
- enabled: hasExport,
241
- refresh,
242
- export: { icon: 'ri-download-2-line', code: 'export' },
243
- custom: !!attrs.gridId,
244
- perfect: true
245
- };
246
- return data;
247
- }
248
-
249
- // 先设置传入的按钮
250
- let buttons = clone(attrs.buttons || [], true);
251
-
252
- // 获取默认的按钮
253
- const toolButtons = attrs.mode !== 'form' ? clone(inlineButtons, true) : clone(dialogButtons, true);
254
- // 判断传入的按钮是否有默认按钮的auth,有就不加入按钮组中,相当于重写了默认的按钮
255
- // reverse的原因是: 保持现有按钮顺序, 新增,保存,删除
256
- toolButtons.reverse().forEach(btn => {
257
- !buttons.some(s => s.code === btn.code) && buttons.unshift(btn);
258
- if (attrs.authPrefix && !['print', 'export'].includes(btn.auth)) {
259
- btn.auth =
260
- attrs.authPrefix +
261
- btn.auth.slice(0, 1).toLocaleUpperCase() +
262
- btn.auth.slice(1).toLocaleLowerCase();
263
- }
264
- });
265
-
266
- buttons = formatButton(buttons, props.auth).filter(button => {
267
- const flag = button.auth ? hasAuthority(button.auth) : true;
268
- if (button.dropdowns?.length) {
269
- button.dropdowns = button.dropdowns.filter(
270
- btn => !btn.auth || (btn.auth && hasAuthority(btn.auth))
271
- );
272
- }
273
- return flag;
274
- });
275
- // inline 行内模式,单击行模式
276
- const editConfig = { trigger: 'dblclick', mode: 'row', showStatus: true };
277
- data.editConfig = attrs.mode !== 'form' ? editConfig : { enabled: false };
278
- // 导出权限
279
- const hasExport = props.needExport && hasAuthority('export');
280
- let exportBtn = null;
281
- if (hasExport) {
282
- data.exportConfig = getExportConfig(attrs);
283
- exportBtn = { icon: 'ri-download-2-line', code: 'export' };
284
- }
285
- data.toolbarConfig = {
286
- buttons,
287
- enabled: true,
288
- refresh,
289
- custom: !!attrs.gridId,
290
- export: exportBtn,
291
- perfect: true
292
- };
293
- return data;
294
- };
295
-
296
- /**
297
- * @description: 表格脚合并方法
298
- * @param {*} columns 列数据
299
- * @param {*} data 数据源
300
- * @param {*} sum 合并属性
301
- * @return {*} 合并脚方法
302
- */
303
- export const footerSumMethod = ({ columns, data }, sum) => {
304
- return [
305
- columns.map((column, columnIdx) => {
306
- if (columnIdx === (sum.index || 0)) {
307
- return sum.label || '合计';
308
- }
309
- if (sum.fields?.includes(column.property)) {
310
- const total = data.reduce((prev, cur) => {
311
- return prev + Number(cur[column.property] || 0);
312
- }, 0);
313
- return total ? Number(total.toFixed(sum.decimal || 2)) : total;
314
- }
315
- return '';
316
- })
317
- ];
318
- };
319
-
320
- /**
321
- * @description: checkbox是否可选
322
- */
323
- export const onCheckMethod = (row, props) => {
324
- if (isFunction(props.checkMethod)) {
325
- return props.checkMethod(row);
326
- }
327
- return true;
328
- };
329
-
330
- /*** excel样式重置 */
331
- const onSheetMethod = ws => {
332
- ws.eachRow((row, rowNumber) => {
333
- row.font = { name: '微软雅黑', size: 9 };
334
- row.border = {
335
- top: { style: 'thin' },
336
- left: { style: 'thin' },
337
- bottom: { style: 'thin' },
338
- right: { style: 'thin' }
339
- };
340
-
341
- if (rowNumber === 1) {
342
- row.fill = {
343
- type: 'pattern',
344
- pattern: 'solid',
345
- fgColor: { argb: '4F81BD' }
346
- };
347
- row.font = {
348
- name: '微软雅黑',
349
- size: 10,
350
- bold: true,
351
- color: { argb: 'FFFFFFFF' }
352
- };
353
- }
354
- });
355
- };
356
-
357
- const getDocData = () => {
358
- return new Promise(resolve => {
359
- setTimeout(() => {
360
- const list = [
361
- { id: 1, name: 'Test1', sex: 'Man', age: 28, address: 'Shenzhen' },
362
- { id: 2, name: 'Test2', sex: 'Women', age: 22, address: 'Guangzhou' },
363
- { id: 3, name: 'Test3', sex: 'Man', age: 32, address: 'Shanghai' },
364
- { id: 4, name: 'Test4', sex: 'Women', age: 23, address: 'test abc' },
365
- { id: 5, name: 'Test5', sex: 'Women', age: 30, address: 'Shanghai' }
366
- ];
367
- resolve({ list, total: 5 });
368
- }, 100);
369
- });
370
- };
371
-
372
- export const getAttrs = attrs => {
373
- const data = {};
374
- Object.keys(attrs).forEach(key => {
375
- const nKey = key.replace(/-(\w)/g, str => str.slice(1).toUpperCase());
376
- data[nKey] = attrs[key];
377
- });
378
- return data;
379
- };
1
+ /*
2
+ * @Author: wei.li
3
+ * @Date: 2022-06-23 17:29:11
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2025-11-18 16:35:57
6
+ * @Description: file content
7
+ */
8
+ // @ts-nocheck
9
+
10
+ import { clone, isString, orderBy, isEmpty, toDateString, isObject, isFunction } 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
+ /** 工具栏按钮标准化 */
19
+ export const formatButton = (buttons, auth?) => {
20
+ buttons.forEach(btn => {
21
+ btn.auth = auth ? auth[btn.code] || btn.auth : btn.auth;
22
+ if (!btn.name) {
23
+ btn.name = `message.btn.${btn.code}`;
24
+ } else if (sysConfig?.i18nEnabled === 'Y' && !btn.name.startsWith('message.')) {
25
+ btn.name = `message.btn.${btn.name}`;
26
+ }
27
+ if (btn.dropdowns?.length) {
28
+ formatButton(btn.dropdowns, auth);
29
+ }
30
+ });
31
+ return buttons;
32
+ };
33
+
34
+ /**
35
+ * @description 查询10W数据,常用于Excel导出
36
+ * @param props 查询接口的路径
37
+ * @param http http实例
38
+ * @param form 查询条件
39
+ * @returns 查询返回的数据
40
+ */
41
+ export const queryAll = (props, http, form) => {
42
+ const params = { pageNum: 1, pageSize: 100000 };
43
+ const commonParam = getCookieParam();
44
+ Object.assign(params, form, commonParam, props.defaultParams || {});
45
+ let query = formatMultipleParams(params, props.items);
46
+ query = formatDateRange(query, props.items);
47
+
48
+ const { url } = props;
49
+ if (!url) return null;
50
+ const requestURL = isString(url) ? url : url.fetch || url.restful;
51
+ if (!requestURL) return null;
52
+ const method = url.fetch ? 'post' : 'get';
53
+ return new Promise((resolve, reject) => {
54
+ http[method](requestURL, query)
55
+ .then((response: IResponseData) => {
56
+ resolve(response.list);
57
+ })
58
+ .catch((e: any) => {
59
+ reject(e);
60
+ });
61
+ });
62
+ };
63
+
64
+ /**
65
+ * @description 查询服务
66
+ * @param props 查询接口的路径
67
+ * @param form 查询条件
68
+ * @param page 分页参数
69
+ * @param http http实例
70
+ * @param isDoc doc文档
71
+ * @returns Promise
72
+ */
73
+ export const query = (props, form, page, http, code, isDoc) => {
74
+ if (isDoc) return getDocData();
75
+ for (const key in form) {
76
+ if (form[key] && isString(form[key])) {
77
+ form[key] = form[key].trim();
78
+ }
79
+ }
80
+ const params = { pageNum: page.currentPage, pageSize: page.pageSize };
81
+ const commonParam = getCookieParam();
82
+ Object.assign(params, commonParam, props.defaultParams || {}, form);
83
+
84
+ let query = formatMultipleParams(params, props.items);
85
+ query = formatDateRange(query, props.items);
86
+ const { url } = props;
87
+ if (!url) return null;
88
+ const requestURL = isString(url) ? url : url.fetch || url.restful;
89
+ const method = url.fetch ? 'post' : 'get';
90
+ if (!requestURL) return null;
91
+ return http[method](requestURL, query);
92
+ };
93
+
94
+ /**
95
+ * @description 表格删除方法
96
+ * @param http http实例
97
+ * @param records 记录行
98
+ * @param props 删除接口的路径
99
+ * @returns Promise
100
+ */
101
+ export const del = (http, records, props) => {
102
+ const { url } = props;
103
+ if (!url) return null;
104
+ const requestURL = isString(url) ? url : url.del || url.restful;
105
+ if (!requestURL) return null;
106
+ const method = url.del ? 'post' : 'delete';
107
+ return http[method](requestURL, records);
108
+ };
109
+
110
+ /** 更新服务 */
111
+ export const save = (http, body, props) => {
112
+ const allService = [];
113
+ const { url } = props;
114
+ if (!url) return null;
115
+
116
+ const { insertRecords, updateRecords } = body;
117
+ if (!isEmpty(insertRecords)) {
118
+ const commonParam = getCookieParam();
119
+ insertRecords.forEach(m => {
120
+ !isEmpty(props?.defaultValue) && Object.assign(m, props.defaultValue);
121
+ Object.keys(commonParam)?.forEach(key => {
122
+ m[key] = m[key] || commonParam[key];
123
+ });
124
+ });
125
+ const requestURL = isString(url) ? url : url.add || url.restful;
126
+ requestURL && allService.push(http.post(requestURL, insertRecords));
127
+ }
128
+ if (!isEmpty(updateRecords)) {
129
+ const requestURL = isString(url) ? url : url.save || url.restful;
130
+ const method = url.save ? 'post' : 'put';
131
+ requestURL && allService.push(http[method](requestURL, updateRecords));
132
+ }
133
+ return allService;
134
+ };
135
+
136
+ /**
137
+ * 多选数据优化
138
+ * @param listQuery
139
+ * @param items
140
+ * @returns
141
+ */
142
+ const formatMultipleParams = (listQuery: any, items) => {
143
+ const multipleItems = items.filter(f => f.itemRender?.props?.multiple || f.multiple);
144
+ if (isEmpty(multipleItems)) return listQuery;
145
+ const query = clone(listQuery, true);
146
+ multipleItems.forEach((element: any) => {
147
+ if (element.itemRender.name === '#select' && element.itemRender.props.multiple) {
148
+ if (query[`_${element.field}`]?.length === 0) {
149
+ // 重置后
150
+ query[`${element.field}`] = null;
151
+ }
152
+ delete listQuery[`_${element.field}`];
153
+ delete query[`_${element.field}`];
154
+ }
155
+ });
156
+ return query;
157
+ };
158
+
159
+ const startFormatter = 'yyyy-MM-dd 00:00:00';
160
+ const endFormatter = 'yyyy-MM-dd 23:59:59';
161
+ // 时间范围优化
162
+ const formatDateRange = (listQuery: any, items) => {
163
+ const dateRanges = items.filter(f => ['#SuDateRange', 'VxeDateRangePicker'].includes(f.itemRender?.name));
164
+ if (isEmpty(dateRanges)) return listQuery;
165
+ const query = clone(listQuery, true);
166
+ dateRanges.forEach((element: any) => {
167
+ const val = query[element.field];
168
+ if (val && element.itemRender.startField) {
169
+ query[element.itemRender.startField] = toDateString(query[element.itemRender.startField], startFormatter);
170
+ query[element.itemRender.endField] = toDateString(query[element.itemRender.endField], endFormatter);
171
+ } else if (val) {
172
+ query[`${element.field}From`] = toDateString(val[0], startFormatter);
173
+ query[`${element.field}To`] = toDateString(val[1], endFormatter);
174
+ }
175
+ delete query[element.field];
176
+ });
177
+ return query;
178
+ };
179
+
180
+ const getCookieParam = () => {
181
+ return cookies.get(kCOOKIES) ? JSON.parse(cookies.get(kCOOKIES)) : {};
182
+ };
183
+
184
+ /** 工具栏默认按钮组 */
185
+ export const inlineButtons = [
186
+ {
187
+ code: 'insert_actived',
188
+ name: 'add',
189
+ status: 'u-cyan',
190
+ icon: 'vxe-icon-add',
191
+ auth: 'add',
192
+ sort: 1
193
+ },
194
+ {
195
+ code: 'delete',
196
+ status: 'danger',
197
+ icon: 'vxe-icon-delete',
198
+ auth: 'del',
199
+ sort: 2
200
+ },
201
+ {
202
+ code: 'save',
203
+ status: 'primary',
204
+ icon: 'vxe-icon-save',
205
+ auth: 'edit',
206
+ sort: 3
207
+ }
208
+ ];
209
+ // form 模式按钮
210
+ export const dialogButtons = [
211
+ {
212
+ code: 'add',
213
+ status: 'u-cyan',
214
+ icon: 'vxe-icon-add',
215
+ auth: 'add',
216
+ sort: 1
217
+ },
218
+ {
219
+ code: 'del',
220
+ status: 'danger',
221
+ icon: 'vxe-icon-delete',
222
+ auth: 'del',
223
+ sort: 2
224
+ }
225
+ ];
226
+
227
+ export const defaultColums = [
228
+ { field: 'createdByName', width: 90, visible: false },
229
+ { field: 'creationDate', width: 140, visible: false },
230
+ { field: 'lastUpdatedByName', width: 90, visible: false },
231
+ { field: 'lastUpdateDate', width: 140, visible: false }
232
+ ];
233
+
234
+ /** 导出配置 */
235
+ export const getExportConfig = attrs => {
236
+ if (isObject(attrs.exportConfig)) return attrs.exportConfig;
237
+ return {
238
+ filename: attrs.fileName || '导出明细',
239
+ type: 'xlsx',
240
+ types: ['xlsx', 'csv'],
241
+ modes: ['current', 'selected', 'all'],
242
+ useStyle: true,
243
+ sheetMethod: ({ worksheet }) => (attrs.onSheetMethod ? attrs.onSheetMethod(worksheet) : onSheetMethod(worksheet)),
244
+ columnFilterMethod: ({ column }) =>
245
+ attrs.columnFilter
246
+ ? !!attrs.columnFilter(column)
247
+ : !['operate'].includes(column.field) && column.type !== 'checkbox'
248
+ };
249
+ };
250
+
251
+ export const getToolBarConfig = (data, props, attrs, hasAuthority) => {
252
+ const refreshOptions = {
253
+ icon: 'ri-refresh-line',
254
+ iconLoading: 'vxe-icon-spinner roll vxe-loading--default-icon'
255
+ };
256
+ // 不可编辑时
257
+ if (!props.editable) {
258
+ data.editConfig.editable = props.editable;
259
+ const hasExport = props.needExport && hasAuthority('export');
260
+ if (hasExport) {
261
+ data.exportConfig = getExportConfig(attrs);
262
+ }
263
+ data.toolbarConfig = {
264
+ buttons: [],
265
+ enabled: hasExport,
266
+ refreshOptions,
267
+ exportOptions: { icon: 'ri-download-2-line', code: 'export' },
268
+ export: hasExport,
269
+ custom: !!attrs.gridId,
270
+ refresh: true,
271
+ perfect: true
272
+ };
273
+ return data;
274
+ }
275
+
276
+ // 先设置传入的按钮
277
+ let buttons = clone(attrs.buttons || [], true);
278
+
279
+ buttons.forEach((button, idx) => {
280
+ button.sort = button.sort || idx + 10;
281
+ });
282
+
283
+ // 获取默认的按钮
284
+ const toolButtons = attrs.mode !== 'form' ? clone(inlineButtons, true) : clone(dialogButtons, true);
285
+ // 判断传入的按钮是否有默认按钮的auth,有就不加入按钮组中,相当于重写了默认的按钮
286
+ // reverse的原因是: 保持现有按钮顺序, 新增,保存,删除
287
+ toolButtons.reverse().forEach(btn => {
288
+ !buttons.some(s => s.code === btn.code) && buttons.unshift(btn);
289
+ if (attrs.authPrefix && !['printer', 'export'].includes(btn.auth)) {
290
+ btn.auth = attrs.authPrefix + btn.auth.slice(0, 1).toLocaleUpperCase() + btn.auth.slice(1).toLocaleLowerCase();
291
+ }
292
+ });
293
+
294
+ buttons = formatButton(buttons, props.auth).filter(button => {
295
+ const flag = button.auth ? hasAuthority(button.auth) : true;
296
+ if (button.dropdowns?.length) {
297
+ button.dropdowns = button.dropdowns.filter(btn => !btn.auth || (btn.auth && hasAuthority(btn.auth)));
298
+ }
299
+ return flag;
300
+ });
301
+ // inline 行内模式,单击行模式
302
+ const editConfig = { trigger: 'dblclick', mode: 'row', showStatus: true };
303
+ data.editConfig = attrs.mode !== 'form' ? editConfig : { enabled: false };
304
+ // 导出权限
305
+ const hasExport = props.needExport && hasAuthority('export');
306
+ let exportBtn = null;
307
+ if (hasExport) {
308
+ data.exportConfig = getExportConfig(attrs);
309
+ exportBtn = { icon: 'ri-download-2-line', code: 'export' };
310
+ }
311
+ data.toolbarConfig = {
312
+ buttons: orderBy(buttons, 'sort'),
313
+ enabled: true,
314
+ refreshOptions,
315
+ customOptions: attrs.gridId ? {} : null,
316
+ exportOptions: exportBtn,
317
+ custom: !!attrs.gridId,
318
+ export: hasExport,
319
+ refresh: true,
320
+ perfect: true
321
+ };
322
+ return data;
323
+ };
324
+
325
+ /**
326
+ * @description: 表格脚合并方法
327
+ * @param {*} columns 列数据
328
+ * @param {*} data 数据源
329
+ * @param {*} sum 合并属性
330
+ * @return {*} 合并脚方法
331
+ */
332
+ export const footerSumMethod = ({ columns, data }, sum) => {
333
+ return [
334
+ columns.map((column, columnIdx) => {
335
+ if (columnIdx === (sum.index || 0)) {
336
+ return sum.label || '合计';
337
+ }
338
+ if (sum.fields?.includes(column.property)) {
339
+ const total = data.reduce((prev, cur) => {
340
+ return prev + Number(cur[column.property] || 0);
341
+ }, 0);
342
+ return total ? Number(total.toFixed(sum.decimal || 2)) : total;
343
+ }
344
+ return '';
345
+ })
346
+ ];
347
+ };
348
+
349
+ /**
350
+ * @description: checkbox是否可选
351
+ */
352
+ export const onCheckMethod = (row, props) => {
353
+ if (isFunction(props.checkMethod)) {
354
+ return props.checkMethod(row);
355
+ }
356
+ return true;
357
+ };
358
+
359
+ /*** excel样式重置 */
360
+ const onSheetMethod = ws => {
361
+ ws.eachRow((row, rowNumber) => {
362
+ row.font = { name: '微软雅黑', size: 9 };
363
+ row.border = {
364
+ top: { style: 'thin' },
365
+ left: { style: 'thin' },
366
+ bottom: { style: 'thin' },
367
+ right: { style: 'thin' }
368
+ };
369
+
370
+ if (rowNumber === 1) {
371
+ row.fill = {
372
+ type: 'pattern',
373
+ pattern: 'solid',
374
+ fgColor: { argb: '4F81BD' }
375
+ };
376
+ row.font = {
377
+ name: '微软雅黑',
378
+ size: 10,
379
+ bold: true,
380
+ color: { argb: 'FFFFFFFF' }
381
+ };
382
+ }
383
+ });
384
+ };
385
+
386
+ const getDocData = () => {
387
+ return new Promise(resolve => {
388
+ setTimeout(() => {
389
+ const list = [
390
+ { id: 1, name: 'Test1', sex: 'Man', age: 28, address: 'Shenzhen' },
391
+ { id: 2, name: 'Test2', sex: 'Women', age: 22, address: 'Guangzhou' },
392
+ { id: 3, name: 'Test3', sex: 'Man', age: 32, address: 'Shanghai' },
393
+ { id: 4, name: 'Test4', sex: 'Women', age: 23, address: 'test abc' },
394
+ { id: 5, name: 'Test5', sex: 'Women', age: 30, address: 'Shanghai' }
395
+ ];
396
+ resolve({ list, total: 5 });
397
+ }, 100);
398
+ });
399
+ };
400
+
401
+ export const getAttrs = attrs => {
402
+ const data = {};
403
+ Object.keys(attrs).forEach(key => {
404
+ const nKey = key.replace(/-(\w)/g, str => str.slice(1).toUpperCase());
405
+ data[nKey] = attrs[key];
406
+ });
407
+ return data;
408
+ };