@utogether/udp-core 1.0.1-beta.1 → 1.0.1-beta.11

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 (147) hide show
  1. package/build/plugins.ts +39 -32
  2. package/dist/{403-Dp617CWX.js → 403-Dsgsr2M-.js} +1 -1
  3. package/dist/{404-Cz_Axb6Y.js → 404-DmPHEfqM.js} +1 -1
  4. package/dist/{500-BGCtRNse.js → 500-OYEgHR2a.js} +1 -1
  5. package/dist/{AuthorityInfo-DGGfm7IS.js → AuthorityInfo-B1H1txG-.js} +1 -1
  6. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-BUlmQtjQ.js +100 -0
  7. package/dist/{Company-IV3GTnzY.js → Company-C8ojgx93.js} +3 -3
  8. package/dist/{CompanyPanel-qV-_VtoL.js → CompanyPanel-Dageer1t.js} +16 -16
  9. package/dist/{Department-B3W-OxW8.js → Department-Dr94_85I.js} +3 -3
  10. package/dist/{DepartmentPanel-Cw3OWxE7.js → DepartmentPanel-Bc5r1HpT.js} +1 -1
  11. package/dist/{DesignPanel-BFxR2fHJ.js → DesignPanel-CcWt1Myp.js} +1 -1
  12. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-DljbeFba.js → DesignPanel.vue_vue_type_style_index_0_lang-CKA6nx1l.js} +24 -26
  13. package/dist/DictView-BHj6wexC.js +110 -0
  14. package/dist/InvOrganization-DP3Le9g-.js +72 -0
  15. package/dist/Org-BRGHTwsw.js +39 -0
  16. package/dist/{Preview-BlDMmpdR.js → Preview-CqMaUD_3.js} +1 -1
  17. package/dist/{ReportDefine-Cub_85LA.js → ReportDefine-PEQdTCOY.js} +1 -1
  18. package/dist/{ReportDesign-hFhq5UVE.js → ReportDesign-CB4bv8ba.js} +43 -43
  19. package/dist/{ReportQuery-ChkWEyxT.js → ReportQuery-B7t4lMK0.js} +1 -1
  20. package/dist/{ReportQueryFrom-KVyD_8Dj.js → ReportQueryFrom-VBxUIMRJ.js} +1 -1
  21. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-CLNODquq.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-HeLA4Qs5.js} +1 -1
  22. package/dist/{ReportTemplate-ag9NDvh2.js → ReportTemplate-DNkv7F5p.js} +28 -28
  23. package/dist/{Role-_q3lQ8CZ.js → Role-BGfTpZK4.js} +6 -6
  24. package/dist/{RoleAssign-DZb9IRsm.js → RoleAssign-DrKFWZzA.js} +8 -8
  25. package/dist/{RolePanel-CsLsz-Ds.js → RolePanel-3lvRh7aS.js} +1 -1
  26. package/dist/{RolePanel-BQb1LlhD.js → RolePanel-BRI5QYe4.js} +1 -1
  27. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-BXKZb7yt.js +132 -0
  28. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-BrnRgHEk.js → RolePanel.vue_vue_type_script_setup_true_lang-Cci_Ysty.js} +44 -38
  29. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-CaFKRwXu.js → ScrollPanel.vue_vue_type_style_index_0_lang-BmId6zzA.js} +21 -21
  30. package/dist/{Staff-BSf9Ypbk.js → Staff-Dr0dq3fW.js} +3 -3
  31. package/dist/{StaffInfo-BNKasyMF.js → StaffInfo-_N9g2hPa.js} +1 -1
  32. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DDZ7ukd0.js → StaffInfo.vue_vue_type_script_setup_true_lang-DiTJY2ug.js} +11 -11
  33. package/dist/{StaffPanel-Bpq0WVlH.js → StaffPanel-mxJQiW3G.js} +1 -1
  34. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-BhiJ0Q-Q.js → StaffPanel.vue_vue_type_script_setup_true_lang-GRGn-5t6.js} +2 -2
  35. package/dist/{SysUser-FAABuNti.js → SysUser-DgA19hZE.js} +2 -2
  36. package/dist/{SysUserPanel-PxJeOgHm.js → SysUserPanel-Bc85z5_K.js} +1 -1
  37. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-BHDrP1Pk.js +294 -0
  38. package/dist/{SystemMenu-C-7NAGon.js → SystemMenu-Be-gFIie.js} +26 -26
  39. package/dist/{UserInfo-ClXKtyGo.js → UserInfo-BCYuwFmr.js} +1 -1
  40. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-8N7P4Hl7.js → UserInfo.vue_vue_type_style_index_0_lang-B1lgokO6.js} +39 -37
  41. package/dist/{childView-C_HmDQNd.js → childView-DhcBr1UA.js} +1 -1
  42. package/dist/{childView-uUlBcTza.js → childView-Dk4zZoXd.js} +1 -1
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-Ckjmw6wJ.js → childView.vue_vue_type_style_index_0_lang-CVnLnl03.js} +40 -40
  44. package/dist/{childView.vue_vue_type_style_index_0_lang-y0sDvYx5.js → childView.vue_vue_type_style_index_0_lang-D4GYVhOc.js} +1 -1
  45. package/dist/{code-rule-AgCVDKFy.js → code-rule-BSwPwuAL.js} +9 -10
  46. package/dist/core.es.js +14 -11
  47. package/dist/{cron-task-C6FgQxTi.js → cron-task-T1ztyra7.js} +1 -1
  48. package/dist/{frameView-BDgISK7N.js → frameView-BDgngiBq.js} +1 -1
  49. package/dist/img/l_img.svg +1 -1
  50. package/dist/img/minicolors.png +0 -0
  51. package/dist/img/v_img.svg +1 -1
  52. package/dist/index-BSj2AtVL.js +4468 -0
  53. package/dist/{layoutView-yb3DV2DQ.js → layoutView-i7dLLBzJ.js} +1181 -1176
  54. package/dist/{login-RRpljbkm.js → login-K5Ludp8x.js} +105 -113
  55. package/dist/{login-log-CvVnyGi3.js → login-log-kqKzKTto.js} +1 -1
  56. package/dist/{lov-view-C9-rjzZR.js → lov-view-lAexiucu.js} +2 -2
  57. package/dist/{menuInfo-CzPQyFhp.js → menuInfo-BaN5YZPp.js} +1 -1
  58. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-BumXunCg.js → menuInfo.vue_vue_type_style_index_0_lang-yI4QOYxG.js} +100 -97
  59. package/dist/{pda-app-Dvy3U-b6.js → pda-app-DEtDXFvM.js} +211 -197
  60. package/dist/{resource-Fy0lFkSV.js → resource-Bztmz7pn.js} +15 -15
  61. package/dist/{su-welcome-DYvSCUST.js → su-welcome-Bx8nBPi9.js} +109 -110
  62. package/dist/sys-config-nvrtYGgi.js +290 -0
  63. package/dist/udp-core.css +2 -2
  64. package/dist/{utogether-CjmJiHoE.js → utogether-yPnwDAIH.js} +1 -1
  65. package/index.ts +40 -36
  66. package/package.json +18 -18
  67. package/src/App.vue +65 -70
  68. package/src/api/index.ts +31 -31
  69. package/src/components/SuCharts/src/UserInfo.vue +78 -78
  70. package/src/components/SuScrollTree/ScrollPanel.vue +3 -3
  71. package/src/components/udp/count-down.vue +536 -0
  72. package/src/components/udp/flip-down/FlipCard/flip-card.vue +251 -0
  73. package/src/components/udp/flip-down/FlipCard/interfaces.ts +4 -0
  74. package/src/components/udp/flip-down/FlipClock/flip-clock.vue +113 -0
  75. package/src/components/udp/form-upload.vue +414 -64
  76. package/src/components/udp/form.vue +112 -0
  77. package/src/components/udp/grid.vue +495 -0
  78. package/src/components/udp/index.ts +10 -4
  79. package/src/components/udp/lov.vue +388 -0
  80. package/src/components/udp/modal-form.vue +13 -3
  81. package/src/components/udp/modal-grid.vue +298 -0
  82. package/src/components/udp/upload.vue +423 -0
  83. package/src/components/udp/utils.ts +447 -40
  84. package/src/directives/permission/index.ts +1 -1
  85. package/src/layout/components/lay-navbar/index.vue +239 -237
  86. package/src/layout/components/lay-panel/index.vue +150 -150
  87. package/src/layout/components/lay-search/index.vue +25 -25
  88. package/src/layout/components/lay-select-org/index.vue +64 -69
  89. package/src/layout/components/lay-sidebar/breadCrumb.vue +1 -1
  90. package/src/layout/components/lay-sidebar/horizontal.vue +190 -191
  91. package/src/layout/components/lay-sidebar/mixNav.vue +260 -258
  92. package/src/layout/components/lay-sidebar/sidebar-logo.vue +92 -98
  93. package/src/layout/components/lay-tag/index.vue +625 -625
  94. package/src/layout/hooks/useNav.ts +173 -173
  95. package/src/layout/layoutView.vue +215 -215
  96. package/src/main.ts +119 -109
  97. package/src/plugins/i18n/en.ts +302 -289
  98. package/src/plugins/i18n/zh.ts +349 -337
  99. package/src/plugins/vxe-table/index.ts +53 -46
  100. package/src/plugins/vxe-table/render.tsx +956 -817
  101. package/src/router/index.ts +177 -183
  102. package/src/router/modules/remaining.ts +58 -83
  103. package/src/store/modules/permission.ts +1 -4
  104. package/src/style/button.scss +85 -78
  105. package/src/style/tailwind.css +1 -68
  106. package/src/style/vxetable.scss +44 -11
  107. package/src/utils/authority/index.ts +1 -1
  108. package/src/utils/{http → udp/http}/index.ts +283 -297
  109. package/src/utils/{http → udp/http}/types.d.ts +8 -5
  110. package/src/utils/udp/useRender.ts +17 -6
  111. package/src/views/login/login-view.vue +300 -314
  112. package/src/views/organization/company/CompanyPanel.vue +259 -259
  113. package/src/views/organization/inv-org/InvOrganization.vue +68 -54
  114. package/src/views/organization/org/Org.vue +9 -5
  115. package/src/views/system/menu/SystemMenu.vue +183 -197
  116. package/src/views/system/menu/menuInfo.vue +363 -371
  117. package/src/views/system/role/AuthorityInfo.vue +19 -15
  118. package/src/views/system/role/Role.vue +1 -5
  119. package/src/views/system/role/RolePanel.vue +11 -2
  120. package/src/views/system/role/UserInfo.vue +195 -193
  121. package/src/views/system/role-assign/RoleAssign.vue +57 -57
  122. package/src/views/system/role-assign/RolePanel.vue +139 -136
  123. package/src/views/system/sys/sys-config.vue +287 -291
  124. package/src/views/system/sysUser/SysUserPanel.vue +278 -278
  125. package/src/views/uapp/pda/pda-app.vue +208 -176
  126. package/src/views/udev/dict/DictView.vue +118 -106
  127. package/src/views/udev/dict/childView.vue +7 -7
  128. package/src/views/udev/lov/lov-view.vue +91 -91
  129. package/src/views/ufile/aggregation/File.vue +5 -5
  130. package/src/views/ufile/file/water-mark.vue +14 -14
  131. package/src/views/uhome/su-welcome.vue +3 -3
  132. package/src/views/ulogin/login.vue +12 -8
  133. package/src/views/upms/user/login-log.vue +1 -1
  134. package/src/views/urpt/design/DesignPanel.vue +507 -526
  135. package/src/views/urpt/design/ReportDesign.vue +15 -19
  136. package/src/views/urpt/static-resource/resource.vue +3 -3
  137. package/src/views/urpt/template/ReportTemplate.vue +7 -7
  138. package/types/global.d.ts +2 -1
  139. package/vite.config.ts +6 -2
  140. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-BqccGW7v.js +0 -102
  141. package/dist/DictView-C-i7e4hZ.js +0 -95
  142. package/dist/InvOrganization-cfT6riGU.js +0 -260
  143. package/dist/Org-CA7vTDIF.js +0 -35
  144. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-cmW7zBLu.js +0 -126
  145. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-njefUln5.js +0 -288
  146. package/dist/index-DzOzUkf6.js +0 -3388
  147. package/dist/sys-config-DJ1vNQTy.js +0 -277
@@ -1,40 +1,447 @@
1
- import { useRender } from '@utogether/utils';
2
-
3
- export const getAttrs = attrs => {
4
- const data = {};
5
- Object.keys(attrs).forEach(key => {
6
- const nKey = key.replace(/-(\w)/g, str => str.slice(1).toUpperCase());
7
- data[nKey] = attrs[key];
8
- });
9
- return data;
10
- };
11
-
12
- export const formatItems = (items, status, span = 24) => {
13
- const renderHook = useRender();
14
-
15
- if (!items.length) return items;
16
- return items.map(item => {
17
- item.title = item.title || `message.${item.field}`;
18
- item.span = item.span || span;
19
- let disabled = false;
20
- if (status === 'detail') {
21
- disabled = true;
22
- item.placeholder = null;
23
- } else {
24
- disabled =
25
- item.disabled === false ? item.disabled : item.disabled || item.itemRender?.props?.disabled;
26
- }
27
- let itemRender = {
28
- name: 'VxeInput',
29
- props: { disabled, placeholder: disabled ? '' : item.placeholder }
30
- };
31
- if (item.code && !item.itemRender) {
32
- itemRender = renderHook.renderDict(item.code);
33
- }
34
- item.itemRender = item.itemRender || itemRender;
35
- item.itemRender['props'] = Object.assign(item.itemRender.props || {}, {
36
- disabled
37
- });
38
- return item;
39
- });
40
- };
1
+ /*
2
+ * @Author: levi7754 levi7754@163.com
3
+ * @Date: 2025-07-14 17:38:38
4
+ * @LastEditors: levi7754 levi7754@163.com
5
+ * @LastEditTime: 2025-08-21 10:57:00
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, merge } from 'xe-utils';
10
+ import { cookies, storageLocal, useRender } from '@utogether/utils';
11
+ /** 系统配置的key */
12
+ const kSYSCONFIG = 'kSysConfig';
13
+ const kCOOKIES = 'kCookies_param';
14
+
15
+ const sysConfig = storageLocal.getItem(kSYSCONFIG);
16
+
17
+ const renderHook = useRender();
18
+
19
+ /** 工具栏按钮标准化 */
20
+ export const formatButton = (buttons, auth?) => {
21
+ buttons.forEach(btn => {
22
+ btn.auth = auth ? auth[btn.code] || btn.auth : btn.auth;
23
+ debugger;
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
+ const params = { pageNum: 1, pageSize: 100000 };
45
+ const commonParam = getCookieParam();
46
+ Object.assign(params, form, commonParam, props.defaultParams || {});
47
+ const query = formatDateRange(params, props.items);
48
+
49
+ const { url } = props;
50
+ if (!url) return null;
51
+ const requestURL = isString(url) ? url : url.fetch || url.restful;
52
+ if (!requestURL) return null;
53
+ const method = url.fetch ? 'post' : 'get';
54
+ return new Promise((resolve, reject) => {
55
+ http[method](requestURL, query)
56
+ .then((response: IResponseData) => {
57
+ resolve(response.list);
58
+ })
59
+ .catch((e: any) => {
60
+ reject(e);
61
+ });
62
+ });
63
+ };
64
+
65
+ /**
66
+ * @description 查询服务
67
+ * @param props 查询接口的路径
68
+ * @param form 查询条件
69
+ * @param page 分页参数
70
+ * @param http http实例
71
+ * @param isDoc doc文档
72
+ * @returns Promise
73
+ */
74
+ export const query = (props, form, page, http, isDoc) => {
75
+ if (isDoc) return getDocData();
76
+ for (const key in form) {
77
+ if (form[key] && isString(form[key])) {
78
+ form[key] = form[key].trim();
79
+ }
80
+ }
81
+ const params = { pageNum: page.currentPage, pageSize: page.pageSize };
82
+ const commonParam = getCookieParam();
83
+ Object.assign(params, commonParam, props.defaultParams || {}, form);
84
+ const query = formatDateRange(params, props.items);
85
+ const { url } = props;
86
+ console.log(query);
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
+ const startFormatter = 'yyyy-MM-dd 00:00:00';
137
+ const endFormatter = 'yyyy-MM-dd 23:59:59';
138
+ const formatDateRange = (listQuery: any, items) => {
139
+ const dateRanges = items.filter(
140
+ f => f.itemRender?.name === '#SuDateRange' || f.itemRender?.props?.multiple || f.multiple
141
+ );
142
+ if (isEmpty(dateRanges)) return listQuery;
143
+ const query = clone(listQuery, true);
144
+ dateRanges.forEach((element: any) => {
145
+ if (element.multiple || element.itemRender?.props?.multiple) {
146
+ query[element.field] = query[element.field]?.join(',');
147
+ } else {
148
+ const val = query[element.field];
149
+ if (val && element.toField) {
150
+ query[element.fromField] = toDateString(val[0], startFormatter);
151
+ query[element.toField] = toDateString(val[1], endFormatter);
152
+ } else if (val) {
153
+ query[`${element.field}From`] = toDateString(val[0], startFormatter);
154
+ query[`${element.field}To`] = toDateString(val[1], endFormatter);
155
+ }
156
+ delete query[element.field];
157
+ }
158
+ });
159
+ return query;
160
+ };
161
+
162
+ const getCookieParam = () => {
163
+ return cookies.get(kCOOKIES) ? JSON.parse(cookies.get(kCOOKIES)) : {};
164
+ };
165
+
166
+ /** 工具栏默认按钮组 */
167
+ export const inlineButtons = [
168
+ {
169
+ code: 'insert_actived',
170
+ name: 'add',
171
+ status: 'u-cyan',
172
+ icon: 'vxe-icon-add',
173
+ auth: 'add'
174
+ },
175
+ {
176
+ code: 'delete',
177
+ status: 'danger',
178
+ icon: 'vxe-icon-delete',
179
+ auth: 'del'
180
+ },
181
+ {
182
+ code: 'save',
183
+ status: 'primary',
184
+ icon: 'vxe-icon-save',
185
+ auth: 'edit'
186
+ }
187
+ ];
188
+ // form 模式按钮
189
+ export const dialogButtons = [
190
+ {
191
+ code: 'add',
192
+ status: 'u-cyan',
193
+ icon: 'vxe-icon-add',
194
+ auth: 'add'
195
+ },
196
+ {
197
+ code: 'delete',
198
+ status: 'danger',
199
+ icon: 'vxe-icon-delete',
200
+ auth: 'del'
201
+ }
202
+ ];
203
+
204
+ export const defaultColums = [
205
+ { field: 'createdByName', width: 90, visible: false },
206
+ { field: 'creationDate', width: 140, visible: false },
207
+ { field: 'lastUpdatedByName', width: 90, visible: false },
208
+ { field: 'lastUpdateDate', width: 140, visible: false }
209
+ ];
210
+
211
+ /** 导出配置 */
212
+ export const getExportConfig = attrs => {
213
+ if (isObject(attrs.exportConfig)) return attrs.exportConfig;
214
+ return {
215
+ filename: attrs.fileName || '导出明细',
216
+ type: 'xlsx',
217
+ types: ['xlsx', 'csv'],
218
+ modes: ['current', 'selected', 'all'],
219
+ useStyle: true,
220
+ sheetMethod: ({ worksheet }) => (attrs.onSheetMethod ? attrs.onSheetMethod(worksheet) : onSheetMethod(worksheet)),
221
+ columnFilterMethod: ({ column }) =>
222
+ attrs.columnFilter
223
+ ? !!attrs.columnFilter(column)
224
+ : !['operate'].includes(column.field) && column.type !== 'checkbox'
225
+ };
226
+ };
227
+
228
+ export const getToolBarConfig = (data, props, attrs, hasAuthority) => {
229
+ const refreshOptions = {
230
+ icon: 'ri-refresh-line',
231
+ code: 'query',
232
+ iconLoading: 'vxe-icon-spinner roll vxe-loading--default-icon'
233
+ };
234
+ debugger;
235
+ // 不可编辑时
236
+ if (!props.editable) {
237
+ data.editConfig.editable = props.editable;
238
+ const hasExport = props.needExport && hasAuthority('export');
239
+ if (hasExport) {
240
+ data.exportConfig = getExportConfig(attrs);
241
+ }
242
+ data.toolbarConfig = {
243
+ buttons: [],
244
+ enabled: hasExport,
245
+ refreshOptions,
246
+ exportOptions: { icon: 'ri-download-2-line', code: 'export' },
247
+ export: hasExport,
248
+ custom: !!attrs.gridId,
249
+ refresh: true,
250
+ perfect: true
251
+ };
252
+ return data;
253
+ }
254
+
255
+ // 先设置传入的按钮
256
+ let buttons = clone(attrs.buttons || [], true);
257
+
258
+ // 获取默认的按钮
259
+ const toolButtons = attrs.mode !== 'form' ? clone(inlineButtons, true) : clone(dialogButtons, true);
260
+ // 判断传入的按钮是否有默认按钮的auth,有就不加入按钮组中,相当于重写了默认的按钮
261
+ // reverse的原因是: 保持现有按钮顺序, 新增,保存,删除
262
+ toolButtons.reverse().forEach(btn => {
263
+ !buttons.some(s => s.code === btn.code) && buttons.unshift(btn);
264
+ if (attrs.authPrefix && !['print', 'export'].includes(btn.auth)) {
265
+ btn.auth = attrs.authPrefix + btn.auth.slice(0, 1).toLocaleUpperCase() + btn.auth.slice(1).toLocaleLowerCase();
266
+ }
267
+ });
268
+
269
+ buttons = formatButton(buttons, props.auth).filter(button => {
270
+ const flag = button.auth ? hasAuthority(button.auth) : true;
271
+ if (button.dropdowns?.length) {
272
+ button.dropdowns = button.dropdowns.filter(btn => !btn.auth || (btn.auth && hasAuthority(btn.auth)));
273
+ }
274
+ return flag;
275
+ });
276
+ // inline 行内模式,单击行模式
277
+ const editConfig = { trigger: 'dblclick', mode: 'row', showStatus: true };
278
+ data.editConfig = attrs.mode !== 'form' ? editConfig : { enabled: false };
279
+ // 导出权限
280
+ const hasExport = props.needExport && hasAuthority('export');
281
+ let exportBtn = null;
282
+ if (hasExport) {
283
+ data.exportConfig = getExportConfig(attrs);
284
+ exportBtn = { icon: 'ri-download-2-line', code: 'export' };
285
+ }
286
+ data.toolbarConfig = {
287
+ buttons,
288
+ enabled: true,
289
+ refreshOptions,
290
+ custom: !!attrs.gridId,
291
+ exportOptions: exportBtn,
292
+ export: hasExport,
293
+ refresh: true,
294
+ perfect: true
295
+ };
296
+ return data;
297
+ };
298
+
299
+ /**
300
+ * @description: 表格脚合并方法
301
+ * @param {*} columns 列数据
302
+ * @param {*} data 数据源
303
+ * @param {*} sum 合并属性
304
+ * @return {*} 合并脚方法
305
+ */
306
+ export const footerSumMethod = ({ columns, data }, sum) => {
307
+ return [
308
+ columns.map((column, columnIdx) => {
309
+ if (columnIdx === (sum.index || 0)) {
310
+ return sum.label || '合计';
311
+ }
312
+ if (sum.fields?.includes(column.property)) {
313
+ const total = data.reduce((prev, cur) => {
314
+ return prev + Number(cur[column.property] || 0);
315
+ }, 0);
316
+ return total ? Number(total.toFixed(sum.decimal || 2)) : total;
317
+ }
318
+ return '';
319
+ })
320
+ ];
321
+ };
322
+
323
+ /**
324
+ * @description: checkbox是否可选
325
+ */
326
+ export const onCheckMethod = (row, props) => {
327
+ if (isFunction(props.checkMethod)) {
328
+ return props.checkMethod(row);
329
+ }
330
+ return true;
331
+ };
332
+
333
+ /*** excel样式重置 */
334
+ const onSheetMethod = ws => {
335
+ ws.eachRow((row, rowNumber) => {
336
+ row.font = { name: '微软雅黑', size: 9 };
337
+ row.border = {
338
+ top: { style: 'thin' },
339
+ left: { style: 'thin' },
340
+ bottom: { style: 'thin' },
341
+ right: { style: 'thin' }
342
+ };
343
+
344
+ if (rowNumber === 1) {
345
+ row.fill = {
346
+ type: 'pattern',
347
+ pattern: 'solid',
348
+ fgColor: { argb: '4F81BD' }
349
+ };
350
+ row.font = {
351
+ name: '微软雅黑',
352
+ size: 10,
353
+ bold: true,
354
+ color: { argb: 'FFFFFFFF' }
355
+ };
356
+ }
357
+ });
358
+ };
359
+
360
+ const getDocData = () => {
361
+ return new Promise(resolve => {
362
+ setTimeout(() => {
363
+ const list = [
364
+ { id: 1, name: 'Test1', sex: 'Man', age: 28, address: 'Shenzhen' },
365
+ { id: 2, name: 'Test2', sex: 'Women', age: 22, address: 'Guangzhou' },
366
+ { id: 3, name: 'Test3', sex: 'Man', age: 32, address: 'Shanghai' },
367
+ { id: 4, name: 'Test4', sex: 'Women', age: 23, address: 'test abc' },
368
+ { id: 5, name: 'Test5', sex: 'Women', age: 30, address: 'Shanghai' }
369
+ ];
370
+ resolve({ list, total: 5 });
371
+ }, 100);
372
+ });
373
+ };
374
+
375
+ export const getAttrs = attrs => {
376
+ const data = {};
377
+ Object.keys(attrs).forEach(key => {
378
+ const nKey = key.replace(/-(\w)/g, str => str.slice(1).toUpperCase());
379
+ data[nKey] = attrs[key];
380
+ });
381
+ return data;
382
+ };
383
+
384
+ export const formatItems = (items, status, span = 24) => {
385
+ if (!items.length) return items;
386
+ return items.map(item => {
387
+ if (item.children?.length) {
388
+ item.children = formatItems(item.children, status, span);
389
+ return item;
390
+ } else {
391
+ item.title = item.title || `message.${item.field}`;
392
+ item.span = item.span || span;
393
+ if (item.type === 'collapseNode') {
394
+ // 折叠项目,title和宽度不需要
395
+ item.title = '';
396
+ item.titleWidth = 0;
397
+ }
398
+ let disabled = false;
399
+ if (status === 'detail') {
400
+ disabled = true;
401
+ item.placeholder = null;
402
+ } else {
403
+ disabled = item.disabled === false ? item.disabled : item.disabled || item.itemRender?.props?.disabled;
404
+ }
405
+ let itemRender = {
406
+ name: 'VxeInput',
407
+ props: { disabled, placeholder: disabled ? '' : item.placeholder }
408
+ };
409
+ if (item.code && !item.itemRender) {
410
+ itemRender = renderHook.renderDict(item.code);
411
+ }
412
+ item.itemRender = item.itemRender || itemRender;
413
+ item.itemRender['props'] = Object.assign(item.itemRender.props || {}, {
414
+ disabled
415
+ });
416
+ return item;
417
+ }
418
+ });
419
+ };
420
+
421
+ /**
422
+ * @description: 标准化必填数据
423
+ * @param {*} records 数据列表
424
+ * @param {*} t i18n对象
425
+ * @return {*} rule数据
426
+ */
427
+ export const formatRules = (records, t) => {
428
+ const rule = {};
429
+ records.forEach(item => {
430
+ if (item.children?.length) {
431
+ const subRuls = formatRules(item.children, t);
432
+ merge(rule, subRuls);
433
+ } else {
434
+ if (item.required) {
435
+ const { field, title } = item;
436
+ const i18n = title?.startsWith('message.');
437
+ rule[field] = [
438
+ {
439
+ required: true,
440
+ message: `${t('message.required')}${title && i18n ? t(title) : title || t(`message.${field}`)}`
441
+ }
442
+ ];
443
+ }
444
+ }
445
+ });
446
+ return rule;
447
+ };
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { usePermissionStoreHook } from '../../store/modules/permission';
10
10
  import type { Directive } from 'vue';
11
- import router from '../../router';
11
+ import { router } from '../../router';
12
12
  import type { DirectiveBinding } from 'vue';
13
13
 
14
14
  export const auth: Directive = {