@utogether/udp-core 1.0.1-beta.27 → 1.0.1-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/plugins.ts +37 -37
- package/dist/{403-A9aD_bZN.js → 403-DdjDWbkf.js} +1 -1
- package/dist/{404-DREd70aQ.js → 404-D9vF2gFz.js} +1 -1
- package/dist/{500-C5qVXkGt.js → 500-mVaDmUjL.js} +1 -1
- package/dist/{AuthorityInfo-CYO2IVau.js → AuthorityInfo-DOUJ_Zrj.js} +1 -1
- package/dist/{AuthorityInfo.vue_vue_type_style_index_0_lang-V7e_KwWp.js → AuthorityInfo.vue_vue_type_style_index_0_lang-B12sAzqt.js} +1 -1
- package/dist/{Company-CaottHQO.js → Company-DY__kM9F.js} +3 -3
- package/dist/{CompanyPanel-B3hOiXqj.js → CompanyPanel-C5N8QcMA.js} +1 -1
- package/dist/{Department-CHkuRvJN.js → Department-DsuDZdy5.js} +3 -3
- package/dist/{DepartmentPanel-DieWfIxW.js → DepartmentPanel-CdwI7Rzu.js} +2 -2
- package/dist/{DesignPanel-REWXp3x4.js → DesignPanel-B50-g0TL.js} +1 -1
- package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-Df0xc5XP.js → DesignPanel.vue_vue_type_style_index_0_lang-KV8JOZ6v.js} +2 -2
- package/dist/{DictView-DnpDHskG.js → DictView-Be2Z5Obk.js} +1 -1
- package/dist/{InvOrganization-DoIsDrAx.js → InvOrganization-Lui1q3Ou.js} +1 -1
- package/dist/{Org-C4P5Cwia.js → Org-qO5ExsPN.js} +1 -1
- package/dist/{Preview-d90pQdFJ.js → Preview-Dq4dfV2D.js} +1 -1
- package/dist/{ReportDefine-DNrp4lFP.js → ReportDefine-DH3FvbS1.js} +1 -1
- package/dist/{ReportDesign-Ch8x6_mW.js → ReportDesign-Bou01Jbr.js} +2 -2
- package/dist/{ReportQuery-C1yR0ULS.js → ReportQuery-BBkmPPSw.js} +1 -1
- package/dist/{ReportQueryFrom-BKwf61CL.js → ReportQueryFrom-BCY8lTJ7.js} +1 -1
- package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-D2ddteNz.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-CpktcM8J.js} +1 -1
- package/dist/{ReportTemplate-HLHli4Cc.js → ReportTemplate-C_yJXxQ-.js} +1 -1
- package/dist/{Role-4GbuIhk6.js → Role-CTatYsrC.js} +3 -3
- package/dist/{RoleAssign-FGrSCg5R.js → RoleAssign-Cqt3CelK.js} +3 -3
- package/dist/{RolePanel-Ce1eKsM8.js → RolePanel-C3JMpNu8.js} +1 -1
- package/dist/{RolePanel-BcCozGfv.js → RolePanel-brKRJIhD.js} +1 -1
- package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-BiOcU5GE.js → RolePanel.vue_vue_type_script_setup_true_lang-DD8u9pq8.js} +1 -1
- package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-CqER1M9Y.js → RolePanel.vue_vue_type_script_setup_true_lang-i6Gq4r5B.js} +3 -3
- package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-BbgS5f79.js → ScrollPanel.vue_vue_type_style_index_0_lang-CiWKyjm3.js} +1 -1
- package/dist/{Staff-CBt_0rqg.js → Staff-Cd3twQ6Y.js} +3 -3
- package/dist/{StaffInfo-RCdWZr1r.js → StaffInfo-DJp0a0qd.js} +1 -1
- package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-Dm8Yin3r.js → StaffInfo.vue_vue_type_script_setup_true_lang-Dp2AhJ4I.js} +1 -1
- package/dist/{StaffPanel-2ka-H3IV.js → StaffPanel-B93hClzs.js} +1 -1
- package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-B0u-PqTe.js → StaffPanel.vue_vue_type_script_setup_true_lang-CXjUzq7n.js} +2 -2
- package/dist/{SysUser-Cs7uN3HU.js → SysUser-BvI6vaqI.js} +2 -2
- package/dist/{SysUserPanel-Df3qGMep.js → SysUserPanel-C9V8X-Ek.js} +1 -1
- package/dist/{SysUserPanel.vue_vue_type_script_setup_true_lang-ClwozbZE.js → SysUserPanel.vue_vue_type_script_setup_true_lang-bMqTui07.js} +1 -1
- package/dist/{SystemMenu-BMYVQd-E.js → SystemMenu-D4WME5d0.js} +2 -2
- package/dist/{UserInfo-DDk2iOqY.js → UserInfo-D-AfdfJs.js} +1 -1
- package/dist/{UserInfo.vue_vue_type_style_index_0_lang-CEccCnDi.js → UserInfo.vue_vue_type_style_index_0_lang-C-JQYIxe.js} +1 -1
- package/dist/{childView-C7u4Budn.js → childView--WMSo-wH.js} +1 -1
- package/dist/{childView-DFPGu0W-.js → childView-1MTl6Kaj.js} +1 -1
- package/dist/childView.vue_vue_type_style_index_0_lang-B8Losc4Y.js +170 -0
- package/dist/{childView.vue_vue_type_style_index_0_lang-B3fNaibG.js → childView.vue_vue_type_style_index_0_lang-BAVKNIXs.js} +1 -1
- package/dist/{code-rule-BcaRQ1zV.js → code-rule-D-RqrQB6.js} +40 -37
- package/dist/core.es.js +1 -1
- package/dist/{cron-task-DJQLZCsO.js → cron-task-D-X-KFZm.js} +1 -1
- package/dist/{frameView-uPEaJRC7.js → frameView-MAW_-GHJ.js} +1 -1
- package/dist/{index-D7BXpJPu.js → index-Bc9vCX7z.js} +45 -45
- package/dist/{layoutView-zw1-fplL.js → layoutView-De2QIEr2.js} +3 -3
- package/dist/{login-M-rLGYIn.js → login-rdZ0GPYc.js} +1 -1
- package/dist/{lov-view-BVfIna0M.js → lov-view-Ao7LMspL.js} +2 -2
- package/dist/{menuInfo-BTqoNOuZ.js → menuInfo-DmOcK6An.js} +1 -1
- package/dist/{menuInfo.vue_vue_type_style_index_0_lang-CHco0XcS.js → menuInfo.vue_vue_type_style_index_0_lang-Ln-zFWV7.js} +1 -1
- package/dist/{pda-app-BzzynCVk.js → pda-app-DY63mQ2T.js} +1 -1
- package/dist/{resource-CJQV7_75.js → resource-B21uV58T.js} +1 -1
- package/dist/{su-welcome-BxQYF4Ou.js → su-welcome-DgjzJeDF.js} +22 -19
- package/dist/{sys-config-DNFqTmvL.js → sys-config-DOtK2I32.js} +1 -1
- package/dist/udp-core.css +1 -1
- package/index.ts +49 -49
- package/package.json +3 -3
- package/src/components/SuScrollTree/ScrollPanel.vue +170 -170
- package/src/components/udp/content/index.vue +89 -0
- package/src/components/udp/form/form.vue +109 -109
- package/src/components/udp/grid/index.vue +524 -524
- package/src/components/udp/index.ts +2 -1
- package/src/components/udp/ut-stamp-badge/index.vue +272 -0
- package/src/components/udp/utils.ts +408 -408
- package/src/layout/components/lay-sidebar/sidebar-logo.vue +94 -94
- package/src/layout/components/lay-tag/index.vue +596 -596
- package/src/layout/hooks/useTag.ts +227 -227
- package/src/main.ts +1 -1
- package/src/plugins/i18n/module/u-workflow.ts +71 -71
- package/src/plugins/vxe-table/index.ts +116 -116
- package/src/plugins/vxe-table/render.tsx +945 -945
- package/src/router/index.ts +187 -187
- package/src/router/modules/flow.ts +35 -35
- package/src/router/utils.ts +420 -420
- package/src/store/modules/multiTags.ts +110 -110
- package/src/store/modules/permission.ts +113 -113
- package/src/style/button.scss +85 -85
- package/src/style/vxetable.scss +348 -348
- package/src/views/organization/department/DepartmentPanel.vue +269 -269
- package/src/views/system/menu/SystemMenu.vue +185 -185
- package/src/views/system/menu/menuInfo.vue +384 -384
- package/src/views/system/sysUser/SysUserPanel.vue +348 -348
- package/src/views/udev/coderule/code-rule.vue +17 -5
- package/src/views/udev/dict/DictView.vue +118 -118
- package/src/views/udev/dict/childView.vue +69 -109
- package/src/views/udev/lov/childView.vue +174 -174
- package/src/views/uhome/components/menu-favorite.vue +1 -1
- package/src/views/upms/interface/log-in.vue +100 -100
- package/src/views/upms/user/login-log.vue +54 -54
- package/src/views/utask/flow-task.vue +18 -18
- package/dist/childView.vue_vue_type_style_index_0_lang-BUMcbqzM.js +0 -187
|
@@ -1,408 +1,408 @@
|
|
|
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
|
-
};
|
|
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
|
+
};
|