sohelp-eleplus 1.1.13
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/README.md +7 -0
- package/cache/DictCache.js +58 -0
- package/cache/ModuleCache.js +352 -0
- package/components.js +45 -0
- package/core-export.js +4 -0
- package/http/CrudHttp.js +115 -0
- package/http/DictHttp.js +12 -0
- package/http/ModuleHttp.js +68 -0
- package/http/SohelpHttp.js +125 -0
- package/index.js +6 -0
- package/installer.js +8 -0
- package/lang/en_US.js +4 -0
- package/lang/zh_CN.js +4 -0
- package/lang/zh_TW.js +4 -0
- package/package.json +9 -0
- package/sohelp-ace-editor/index.vue +198 -0
- package/sohelp-application-select/index.vue +15 -0
- package/sohelp-autocode/index.vue +53 -0
- package/sohelp-calendar-view/index.vue +11 -0
- package/sohelp-card-view/index.vue +11 -0
- package/sohelp-condition/index.vue +210 -0
- package/sohelp-cry-input/index.vue +64 -0
- package/sohelp-date/index.vue +27 -0
- package/sohelp-datetime/index.vue +44 -0
- package/sohelp-datetime-picker/index.vue +86 -0
- package/sohelp-datetime-range/index.vue +59 -0
- package/sohelp-dict/index.vue +207 -0
- package/sohelp-dict/props.js +68 -0
- package/sohelp-drawer/index.vue +31 -0
- package/sohelp-drop-card/index.vue +94 -0
- package/sohelp-drop-card/props.js +68 -0
- package/sohelp-dyn-select/index.vue +99 -0
- package/sohelp-dyn-select/props.js +67 -0
- package/sohelp-dyn-tree/index.vue +82 -0
- package/sohelp-dyn-tree-select/index.vue +114 -0
- package/sohelp-entity-form/index.vue +524 -0
- package/sohelp-entity-grid/index.vue +30 -0
- package/sohelp-file-upload/index.vue +218 -0
- package/sohelp-filter-scheme/components/condition.vue +102 -0
- package/sohelp-filter-scheme/components/filter.vue +45 -0
- package/sohelp-filter-scheme/components/keywords.vue +15 -0
- package/sohelp-filter-scheme/components/scheme.vue +49 -0
- package/sohelp-filter-scheme/index.vue +113 -0
- package/sohelp-grid/SohelpGridConfig.js~ +408 -0
- package/sohelp-grid/components/filter-condition-item.vue +298 -0
- package/sohelp-grid/index.vue +1886 -0
- package/sohelp-grid/js/ConditionType.js +101 -0
- package/sohelp-grid/js/DefaultGridOptions.js +141 -0
- package/sohelp-grid/js/DefaultProps.js +27 -0
- package/sohelp-grid/js/SohelpConfigFunction.js +0 -0
- package/sohelp-grid/js/SohelpGridConfig.js +101 -0
- package/sohelp-grid/js/useSohelpGridConfig.js +519 -0
- package/sohelp-grid-select/index.vue +245 -0
- package/sohelp-grid-view/filter/config/grid-filter-condition.vue +221 -0
- package/sohelp-grid-view/filter/config/grid-filter-config.vue +27 -0
- package/sohelp-grid-view/filter/config/grid-filter-field.vue +378 -0
- package/sohelp-grid-view/filter/config/grid-filter-keywords.vue +310 -0
- package/sohelp-grid-view/filter/config/grid-filter-list.vue +313 -0
- package/sohelp-grid-view/filter/config/grid-filter-scheme.vue +264 -0
- package/sohelp-grid-view/filter/config/grid-filter-sort.vue +310 -0
- package/sohelp-grid-view/filter/config/index.vue +206 -0
- package/sohelp-grid-view/filter/filter-form.vue +427 -0
- package/sohelp-grid-view/filter/filter-toolbar.vue +110 -0
- package/sohelp-grid-view/filter/index.vue +160 -0
- package/sohelp-grid-view/index.vue +379 -0
- package/sohelp-grid-view-select/index.vue +141 -0
- package/sohelp-group-view/index.vue +11 -0
- package/sohelp-icon-select/index.vue +96 -0
- package/sohelp-icon-select/vxeui-icon.js +90 -0
- package/sohelp-image-upload/index.vue +286 -0
- package/sohelp-input/index.vue +39 -0
- package/sohelp-modal/index.vue +49 -0
- package/sohelp-module/index.vue +54 -0
- package/sohelp-module/useModalManager.js +89 -0
- package/sohelp-module/useSohelpModule.js +66 -0
- package/sohelp-number-input/index.vue +32 -0
- package/sohelp-number-range/index.vue +135 -0
- package/sohelp-org-select/index.vue +30 -0
- package/sohelp-org-tree/index.vue +18 -0
- package/sohelp-org-tree-select/index.vue +93 -0
- package/sohelp-org-user-tree/index.vue +26 -0
- package/sohelp-org-user-tree-select/index.vue +11 -0
- package/sohelp-pagination/index.vue +11 -0
- package/sohelp-power/index.vue +105 -0
- package/sohelp-pro-form/components/pro-form-footer.vue +44 -0
- package/sohelp-pro-form/components/pro-form-item.vue +1133 -0
- package/sohelp-pro-form/index.vue +257 -0
- package/sohelp-pro-form/util.js +140 -0
- package/sohelp-pro-layout/index.vue +11 -0
- package/sohelp-pro-table/index.vue +14 -0
- package/sohelp-process/index.vue +216 -0
- package/sohelp-rate/index.vue +56 -0
- package/sohelp-rate/props.js +71 -0
- package/sohelp-relation/index.vue +11 -0
- package/sohelp-rich-text/index.vue +242 -0
- package/sohelp-rich-text/util.js +231 -0
- package/sohelp-richtext/index.vue +10 -0
- package/sohelp-role-select/index.vue +33 -0
- package/sohelp-search/components/search-config.vue +0 -0
- package/sohelp-search/index.vue +49 -0
- package/sohelp-search-pro-form/index.vue +11 -0
- package/sohelp-select/index.vue +120 -0
- package/sohelp-split-panel/index.vue +15 -0
- package/sohelp-switch/index.vue +56 -0
- package/sohelp-table/index.vue +151 -0
- package/sohelp-tenant-select/index.vue +128 -0
- package/sohelp-text/index.vue +14 -0
- package/sohelp-textarea-input/index.vue +36 -0
- package/sohelp-time/index.vue +10 -0
- package/sohelp-tree/index.vue +37 -0
- package/sohelp-tree-select/index.vue +18 -0
- package/sohelp-user-select/index.vue +44 -0
- package/sohelp-user-select/index.vue~ +53 -0
- package/sohelp-user-select/props.js +71 -0
- package/sohelp-user-tag/index.vue +12 -0
- package/sohelp-user-tree/index.vue +11 -0
- package/sohelp-vform-drawer/index.vue +40 -0
- package/sohelp-vform-eleplus/favicon.ico +0 -0
- package/sohelp-vform-eleplus/index.vue +297 -0
- package/sohelp-vform-eleplus/preview.html +91 -0
- package/sohelp-vform-eleplus/render.es.js +72433 -0
- package/sohelp-vform-eleplus/render.style.css +16 -0
- package/sohelp-vform-eleplus/render.umd.js +57 -0
- package/sohelp-vform-eleplus/tinymce/langs/zh_CN.js +462 -0
- package/sohelp-vform-eleplus/tinymce/langs/zh_TW.js +419 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/dark/content.css +72 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/dark/content.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/default/content.css +67 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/default/content.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/document/content.css +72 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/document/content.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/writer/content.css +68 -0
- package/sohelp-vform-eleplus/tinymce/skins/content/writer/content.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.css +732 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.inline.css +726 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.inline.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.mobile.css +29 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/content.mobile.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.css +3047 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.mobile.css +673 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.mobile.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.shadowdom.css +37 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide/skin.shadowdom.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.css +714 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.inline.css +726 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.inline.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.mobile.css +29 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/content.mobile.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.css +3047 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.mobile.css +673 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.mobile.min.css +7 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +37 -0
- package/sohelp-vform-eleplus/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +7 -0
- package/sohelp-vform-modal/index.vue +41 -0
- package/sohelp-vform-select/index.vue +11 -0
- package/sohelp-vform-vant/favicon.ico +0 -0
- package/sohelp-vform-vant/render.es.js +14608 -0
- package/sohelp-vform-vant/render.style.css +1 -0
- package/sohelp-vform-vant/render.umd.js +22 -0
- package/sohelp-vxe-grid/DefaultGridOptions.js +102 -0
- package/sohelp-vxe-grid/DefaultProps.js +37 -0
- package/sohelp-vxe-grid/SohelpGridConfig.js +142 -0
- package/sohelp-vxe-grid/index.vue +518 -0
- package/sohelp-vxe-grid-select/index.vue +148 -0
- package/sohelp-vxe-table/index.vue +184 -0
- package/sohelp-workflow/index.vue +495 -0
- package/sohelp-workflow/nodeWrap.vue +53 -0
- package/sohelp-workflow/nodes/addNode.vue +27 -0
- package/sohelp-workflow/nodes/approver.vue +125 -0
- package/sohelp-workflow/nodes/branch.vue +434 -0
- package/sohelp-workflow/nodes/promoter.vue +80 -0
- package/sohelp-workflow/nodes/send.vue +95 -0
- package/sohelp-workflow-drawer/components/approval-modal.vue +182 -0
- package/sohelp-workflow-drawer/components/draw-box.vue +141 -0
- package/sohelp-workflow-drawer/components/form.vue +79 -0
- package/sohelp-workflow-drawer/components/table.vue +153 -0
- package/sohelp-workflow-drawer/components/timeline.vue +189 -0
- package/sohelp-workflow-drawer/components/workflow.vue +68 -0
- package/sohelp-workflow-drawer/index.vue +311 -0
- package/sohelp-workflow-drawer/js/index.js +119 -0
- package/style/index.scss +0 -0
- package/utils/ProFormConvertUtil.js +76 -0
- package/utils/core.js +310 -0
- package/utils/use-form-data.js +48 -0
- package/utils/use-mobile.js +43 -0
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import { reactive, ref } from "vue";
|
|
2
|
+
import _DefaultGridOptions from "@/components/sohelp-eleplus/sohelp-grid/js/DefaultGridOptions";
|
|
3
|
+
import { moduleCache } from "@/components/sohelp-eleplus/cache/ModuleCache";
|
|
4
|
+
import { usePermission } from "@/utils/use-permission";
|
|
5
|
+
import { useMobile } from "@/utils/use-mobile";
|
|
6
|
+
import { useI18n } from "vue-i18n";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 深拷贝
|
|
10
|
+
* @param obj
|
|
11
|
+
* @returns {any}
|
|
12
|
+
*/
|
|
13
|
+
function deepClone(obj) {
|
|
14
|
+
return JSON.parse(JSON.stringify(obj));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 动态生成cellStyle函数
|
|
18
|
+
function createDynamicStyle(styleConfigs = [], isCell = true) {
|
|
19
|
+
// 预编译条件表达式为函数
|
|
20
|
+
const compiledConfigs = styleConfigs.map((config) => ({
|
|
21
|
+
...config,
|
|
22
|
+
conditionFn: new Function("row", `return ${config.condition}`)
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
return function({ row, column }) {
|
|
26
|
+
const _config = isCell ? compiledConfigs.filter((c) => c.name === column.field) : compiledConfigs;
|
|
27
|
+
if (!_config || !_config.length) return null;
|
|
28
|
+
try {
|
|
29
|
+
for (const config of _config) {
|
|
30
|
+
const conditionFn = new Function("row", `return ${config.condition}`);
|
|
31
|
+
if (conditionFn(row)) {
|
|
32
|
+
return {
|
|
33
|
+
color: config.fontColor,
|
|
34
|
+
backgroundColor: config.bgColor,
|
|
35
|
+
fontWeight: config?.bold ? "bold" : "",
|
|
36
|
+
fontStyle: config.italic ? "italic" : "",
|
|
37
|
+
textDecoration: config.strikethrough ? "line-through" : config.underline ? "underline" : ""
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error("条件解析错误:", e);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const createDynamicCellStyle = (styleConfigs = []) => createDynamicStyle(styleConfigs, true);
|
|
49
|
+
const createDynamicRowStyle = (styleConfigs = []) => createDynamicStyle(styleConfigs, false);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 商邦网格列配置列转化成VxeGrid列配置
|
|
53
|
+
* @param property
|
|
54
|
+
* @param sortList
|
|
55
|
+
* @param f
|
|
56
|
+
* @param formulaMap
|
|
57
|
+
* @returns
|
|
58
|
+
**/
|
|
59
|
+
const switchVxeProperty = (property, sortList, f, formulaMap) => {
|
|
60
|
+
let editor = {
|
|
61
|
+
field: property.name,
|
|
62
|
+
title: property.label,
|
|
63
|
+
i18n: property.i18n,
|
|
64
|
+
query: property.query,
|
|
65
|
+
width: property.width || 120,
|
|
66
|
+
type: property.editor || property.type,
|
|
67
|
+
align: property.align || "left",
|
|
68
|
+
titleSuffix: property.tooltip ? { content: property.tooltip, placement: "top" } : "",
|
|
69
|
+
|
|
70
|
+
showOverflow: true,
|
|
71
|
+
editRender: {
|
|
72
|
+
enabled: property.edit,
|
|
73
|
+
edit: property.edit,
|
|
74
|
+
...property.editorParam
|
|
75
|
+
},
|
|
76
|
+
fixed: !property.lock ? false : property.lockAlign,
|
|
77
|
+
slots: {
|
|
78
|
+
default: "default_" + property.name,
|
|
79
|
+
header: "header_" + property.name
|
|
80
|
+
},
|
|
81
|
+
contentRender: {
|
|
82
|
+
name: property.render,
|
|
83
|
+
props: property.renderParam || {},
|
|
84
|
+
event: "event"
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
if (property.length > 0) {
|
|
89
|
+
editor.editRender.maxlength = property.length;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (property.dict) {
|
|
93
|
+
editor.editRender["code"] = property.dict;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 编辑
|
|
97
|
+
if (property.edit) {
|
|
98
|
+
editor.slots.edit = "edit_" + property.name;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
["SohelpImageUpload", "SohelpFileUpload", "SohelpRate", "SohelpSwitch", "SohelpProcess"].includes(property.editor)
|
|
103
|
+
) {
|
|
104
|
+
delete editor.slots.edit; //不渲染编辑
|
|
105
|
+
editor.editRender.enabled = false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//筛选项配置
|
|
109
|
+
if (editor.query) {
|
|
110
|
+
switchFilterConfig(editor);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//是否统计
|
|
114
|
+
const isSummary = f.find((item) => item.field === property.name);
|
|
115
|
+
|
|
116
|
+
if (isSummary) {
|
|
117
|
+
editor.slots["footer"] = "footer_" + property.name;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 排序
|
|
121
|
+
if (sortList?.includes(property.name)) {
|
|
122
|
+
editor["sortable"] = true;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (property.name === "id") {
|
|
126
|
+
editor["width"] = 150;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return editor;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 筛选配置
|
|
134
|
+
*/
|
|
135
|
+
const switchFilterConfig = (editor) => {
|
|
136
|
+
editor.filters = [{ data: "", checked: false }];
|
|
137
|
+
editor.filterRender = {};
|
|
138
|
+
editor.slots = {
|
|
139
|
+
...editor.slots,
|
|
140
|
+
filter: "filter_" + editor.field
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* properties中过滤掉删除的属性
|
|
146
|
+
* @param {*} _filter
|
|
147
|
+
* @returns
|
|
148
|
+
*/
|
|
149
|
+
const filterFieldsByProperties = (_data) => {
|
|
150
|
+
const data = { ..._data };
|
|
151
|
+
const properties = new Set(data.properties?.map((item) => item.name).filter(Boolean) || []);
|
|
152
|
+
const filterArray = (list, key) => {
|
|
153
|
+
return Array.isArray(list) ? list.filter((item) => properties.has(key ? item?.[key] : item)) : [];
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
let validProperties = Object.fromEntries(
|
|
157
|
+
data.properties.filter((item) => item.name && !item.hidden)?.map((item) => [item.name, item.label])
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
data.list = filterArray(data.list).filter((item) => {
|
|
161
|
+
return item in validProperties;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
data.filter.keywords = filterArray(data.filter.keywords);
|
|
165
|
+
data.filter.field = filterArray(data.filter.field, "name");
|
|
166
|
+
|
|
167
|
+
//过滤掉不在列表中的sort属性
|
|
168
|
+
data.filter.sort = filterArray(data.filter.sort.filter((item) => data.filter.field.some((f) => f.name === item)));
|
|
169
|
+
data.properties = data.properties.filter((item) => item.name && !item.hidden);
|
|
170
|
+
return data;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 工具栏默认图标
|
|
175
|
+
*/
|
|
176
|
+
const defaultIcons = {
|
|
177
|
+
"crud.edit": "vxe-icon-edit",
|
|
178
|
+
"crud.delete": "vxe-icon-delete",
|
|
179
|
+
"crud.create": "vxe-icon-add",
|
|
180
|
+
"crud.save": "vxe-icon-save",
|
|
181
|
+
"crud.view": "vxe-icon-eye-fill",
|
|
182
|
+
"workflow.submit": "vxe-icon-success-circle",
|
|
183
|
+
"workflow.view": "vxe-icon-file-txt",
|
|
184
|
+
"report.print": "vxe-icon-print"
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 格式化工具栏
|
|
189
|
+
*/
|
|
190
|
+
const getToolbarsButtons = (data) => {
|
|
191
|
+
if (data?.length) {
|
|
192
|
+
const groupedButtons = data.reduce((acc, button) => {
|
|
193
|
+
const { buttonType } = button;
|
|
194
|
+
if (!acc[buttonType]) {
|
|
195
|
+
acc[buttonType] = [];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
acc[buttonType].push(button);
|
|
199
|
+
return acc;
|
|
200
|
+
}, {});
|
|
201
|
+
|
|
202
|
+
// 按钮格式化
|
|
203
|
+
const formatterButton = (arr, type) => {
|
|
204
|
+
return arr.map((item) => {
|
|
205
|
+
let params = {};
|
|
206
|
+
if (item.params && typeof item.params === "string") {
|
|
207
|
+
try {
|
|
208
|
+
params = JSON.parse(item.params);
|
|
209
|
+
} catch (e) {
|
|
210
|
+
console.error("FormatterButton Error:", e);
|
|
211
|
+
params = {};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
let obj = {
|
|
215
|
+
code: item.type,
|
|
216
|
+
name: item.title || item,
|
|
217
|
+
id: item.id,
|
|
218
|
+
pno: item.pno,
|
|
219
|
+
handler: item.handler,
|
|
220
|
+
buttonType: item.buttonType,
|
|
221
|
+
icon: item.iconCls || defaultIcons[item.type],
|
|
222
|
+
refid: item.refid,
|
|
223
|
+
openType: item.openType,
|
|
224
|
+
params: params
|
|
225
|
+
};
|
|
226
|
+
return obj;
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const { common = [], more = [], batch = [] } = groupedButtons;
|
|
231
|
+
let arr = [...formatterButton(common)];
|
|
232
|
+
if (more.length > 0) {
|
|
233
|
+
arr.push({
|
|
234
|
+
code: "more",
|
|
235
|
+
name: "更多操作",
|
|
236
|
+
dropdowns: formatterButton(more)
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (batch.length > 0) {
|
|
240
|
+
arr.push({
|
|
241
|
+
code: "batchMore",
|
|
242
|
+
name: "批量操作",
|
|
243
|
+
dropdowns: formatterButton(batch, "batch"),
|
|
244
|
+
disabled: true
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return arr;
|
|
248
|
+
}
|
|
249
|
+
return [];
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 网格列表配置
|
|
254
|
+
* @returns
|
|
255
|
+
*/
|
|
256
|
+
export function useSohelpGridConfig() {
|
|
257
|
+
/**
|
|
258
|
+
* 商邦网格列表配置参数
|
|
259
|
+
* @type {UnwrapNestedRefs<{}>}
|
|
260
|
+
*/
|
|
261
|
+
const SohelpConfig = reactive({});
|
|
262
|
+
/**
|
|
263
|
+
*
|
|
264
|
+
* @type {UnwrapNestedRefs<{}>}
|
|
265
|
+
*/
|
|
266
|
+
const propertiesMap = reactive({});
|
|
267
|
+
/**
|
|
268
|
+
* 网格列表统计
|
|
269
|
+
*/
|
|
270
|
+
const footerData = reactive([]);
|
|
271
|
+
/**
|
|
272
|
+
*
|
|
273
|
+
* @type {UnwrapNestedRefs<{}>}
|
|
274
|
+
*/
|
|
275
|
+
const formulaMap = reactive({});
|
|
276
|
+
/**
|
|
277
|
+
* 配置是否加载完成
|
|
278
|
+
*/
|
|
279
|
+
const isConfigInitialized = ref(false);
|
|
280
|
+
const { t } = useI18n();
|
|
281
|
+
/**
|
|
282
|
+
* 初始化商邦网格列表配置
|
|
283
|
+
*/
|
|
284
|
+
const initial = async (isGridConfig, refid) => {
|
|
285
|
+
if (!refid) throw new Error("配置列表请配置地址!");
|
|
286
|
+
let _refid = refid;
|
|
287
|
+
if (_refid.indexOf("!") === -1) _refid = refid + "!default";
|
|
288
|
+
|
|
289
|
+
isConfigInitialized.value = false;
|
|
290
|
+
const permission = usePermission();
|
|
291
|
+
const { mobile } = useMobile();
|
|
292
|
+
|
|
293
|
+
var batchButtonsIndex = -1;
|
|
294
|
+
const DefaultGridOptions = reactive(deepClone(_DefaultGridOptions));
|
|
295
|
+
/**获取列表配置*/
|
|
296
|
+
const config = isGridConfig ? await moduleCache.getGrid(_refid) : await moduleCache.getEntityGrid(_refid);
|
|
297
|
+
|
|
298
|
+
if (!config) {
|
|
299
|
+
throw new Error(_refid + " : 没有发现网格列表配置!");
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
Object.assign(SohelpConfig, filterFieldsByProperties(config));
|
|
304
|
+
Object.assign(
|
|
305
|
+
propertiesMap,
|
|
306
|
+
(SohelpConfig?.properties || []).reduce((acc, cur) => {
|
|
307
|
+
let param = {};
|
|
308
|
+
if (cur?.editorParam && typeof cur.editorParam === "string") {
|
|
309
|
+
try {
|
|
310
|
+
param = JSON.parse(cur.editorParam);
|
|
311
|
+
} catch (e) {
|
|
312
|
+
console.error("解析editorParam失败:", e);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
acc[cur.name] = { ...cur, editorParam: param };
|
|
316
|
+
return acc;
|
|
317
|
+
}, {})
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
// 计算公式
|
|
321
|
+
if (config.formula && config.formula.length > 0) {
|
|
322
|
+
Object.assign(
|
|
323
|
+
formulaMap,
|
|
324
|
+
config.formula.reduce((a, c) => (a[c.formulaField] || (a[c.formulaField] = c), a), {})
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// 按钮权限过滤
|
|
329
|
+
const permissionButtons = config.toolbars.filter((f) => {
|
|
330
|
+
if (!f.authority) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
return permission.hasPermission(f.authority);
|
|
334
|
+
});
|
|
335
|
+
const buttons = getToolbarsButtons(permissionButtons);
|
|
336
|
+
if (buttons && buttons.length > 0) {
|
|
337
|
+
DefaultGridOptions.toolbarConfig.buttons = buttons;
|
|
338
|
+
// 更多下拉菜单索引
|
|
339
|
+
batchButtonsIndex = buttons.reduce((acc, curr, index) => {
|
|
340
|
+
if (curr.code === "batchMore") acc.push(index);
|
|
341
|
+
return acc;
|
|
342
|
+
}, []);
|
|
343
|
+
|
|
344
|
+
//把标题转成国际化
|
|
345
|
+
buttons.forEach((item) => {
|
|
346
|
+
const code = item.code.replace(".", "-");
|
|
347
|
+
const i18nKey = item.i18n === "" || code !== "custom" ? "grid.toolbar." + code : item.i18n;
|
|
348
|
+
if (i18nKey) {
|
|
349
|
+
const i18n = t(i18nKey);
|
|
350
|
+
item.name = i18n ? i18n : item.name;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
//初始化属性列表配置
|
|
356
|
+
let columns = [
|
|
357
|
+
{
|
|
358
|
+
field: "_checkbox",
|
|
359
|
+
title: "",
|
|
360
|
+
fixed: mobile.value ? false : "left",
|
|
361
|
+
type: "checkbox",
|
|
362
|
+
align: "center",
|
|
363
|
+
width: 40
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
field: "_seq",
|
|
367
|
+
type: "seq",
|
|
368
|
+
title: "#",
|
|
369
|
+
fixed: mobile.value ? false : "left",
|
|
370
|
+
align: "center",
|
|
371
|
+
width: 40
|
|
372
|
+
}
|
|
373
|
+
];
|
|
374
|
+
|
|
375
|
+
const isRowDrag = config.rowDrag;
|
|
376
|
+
//是否支持拖动
|
|
377
|
+
if (isRowDrag) {
|
|
378
|
+
columns.unshift({
|
|
379
|
+
title: "",
|
|
380
|
+
fixed: mobile.value ? false : "left",
|
|
381
|
+
width: 40,
|
|
382
|
+
align: "center",
|
|
383
|
+
dragSort: true,
|
|
384
|
+
field: "_drag"
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const requireData = {};
|
|
389
|
+
//商邦列转换成Vxe列
|
|
390
|
+
if (SohelpConfig.properties?.length > 0) {
|
|
391
|
+
SohelpConfig.properties.forEach((column, index) => {
|
|
392
|
+
let item = propertiesMap[column.name];
|
|
393
|
+
const row = switchVxeProperty(item, SohelpConfig.filter?.sort, footerData, formulaMap);
|
|
394
|
+
|
|
395
|
+
// 列表是否显示
|
|
396
|
+
row.visible = SohelpConfig.list.includes(item.name);
|
|
397
|
+
row.fixed = mobile.value ? false : row.fixed;
|
|
398
|
+
// 添加操作栏插槽
|
|
399
|
+
if (item.name === "_operation") {
|
|
400
|
+
row.visible = true;
|
|
401
|
+
row.slots = {
|
|
402
|
+
default: "_operation"
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
columns.push(row);
|
|
407
|
+
|
|
408
|
+
// 校验规则,非空字段必填
|
|
409
|
+
if (item.edit && item.notNull) {
|
|
410
|
+
requireData[item.name] = [
|
|
411
|
+
{
|
|
412
|
+
required: true,
|
|
413
|
+
message: row.title + "不能为空"
|
|
414
|
+
}
|
|
415
|
+
];
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
//没有工具栏则不显示操作拦
|
|
420
|
+
if (config?.operationToolbars?.length == 0) {
|
|
421
|
+
columns = columns.filter((item) => item.field != "_operation");
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
//将columns按照fields排序
|
|
425
|
+
const sortColumns = columns
|
|
426
|
+
.sort((a, b) => {
|
|
427
|
+
if (a.field === "_operation") return 1;
|
|
428
|
+
if (b.field === "_operation") return -1;
|
|
429
|
+
return config.list.indexOf(a.field) - config.list.indexOf(b.field);
|
|
430
|
+
})
|
|
431
|
+
.sort((a, b) => {
|
|
432
|
+
return b.visible - a.visible;
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
//_operation列安排最后一列
|
|
436
|
+
DefaultGridOptions.columns = [
|
|
437
|
+
...sortColumns.filter((col) => col.field !== "_operation"),
|
|
438
|
+
...sortColumns.filter((col) => col.field === "_operation")
|
|
439
|
+
];
|
|
440
|
+
DefaultGridOptions.editRules = { ...requireData };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
//是否开启表尾
|
|
444
|
+
Object.assign(
|
|
445
|
+
footerData,
|
|
446
|
+
(config.properties || [])
|
|
447
|
+
.filter((item) => item.summaryType)
|
|
448
|
+
?.map((item) => {
|
|
449
|
+
return {
|
|
450
|
+
[item.name]: 0,
|
|
451
|
+
summaryRender: item.summaryRender ? JSON.parse(item.summaryRender) : null,
|
|
452
|
+
field: item.name,
|
|
453
|
+
type: item.summaryType
|
|
454
|
+
};
|
|
455
|
+
})
|
|
456
|
+
);
|
|
457
|
+
DefaultGridOptions.showFooter = footerData?.length > 0;
|
|
458
|
+
|
|
459
|
+
// 拦截编辑
|
|
460
|
+
DefaultGridOptions.editConfig.beforeEditMethod = ({ row, column }) => {
|
|
461
|
+
if (column.type === "SohelpTextarea") {
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
return true;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// 设置分页数据
|
|
468
|
+
DefaultGridOptions.pagerConfig.enabled = config.paging;
|
|
469
|
+
DefaultGridOptions.pagerConfig.pageSize = config.limit || 50;
|
|
470
|
+
|
|
471
|
+
// 行列样式
|
|
472
|
+
if (config.colors && config.colors.length > 0) {
|
|
473
|
+
const rowData = config.colors.filter((item) => item.type !== "c");
|
|
474
|
+
const cellData = config.colors.filter((item) => item.type === "c");
|
|
475
|
+
if (rowData.length > 0) {
|
|
476
|
+
DefaultGridOptions.rowStyle = createDynamicRowStyle(rowData);
|
|
477
|
+
} else {
|
|
478
|
+
DefaultGridOptions.stripe = true;
|
|
479
|
+
}
|
|
480
|
+
if (cellData.length > 0) {
|
|
481
|
+
DefaultGridOptions.cellStyle = createDynamicCellStyle(cellData);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
isConfigInitialized.value = true;
|
|
485
|
+
//转化初始化其他参数...
|
|
486
|
+
} catch (error) {
|
|
487
|
+
throw error; //重新抛出错误,以便调用者可以处理它
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
return {
|
|
491
|
+
gridOptions: DefaultGridOptions,
|
|
492
|
+
sohelpConfig: SohelpConfig,
|
|
493
|
+
propertiesMap: propertiesMap,
|
|
494
|
+
batchButtonsIndex: batchButtonsIndex,
|
|
495
|
+
footerData: footerData,
|
|
496
|
+
formulaMap: formulaMap
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* 配置是否加载完成
|
|
502
|
+
*/
|
|
503
|
+
const isConfigDone = async () => {
|
|
504
|
+
return new Promise((resolve) => {
|
|
505
|
+
if (isConfigInitialized.value) {
|
|
506
|
+
resolve();
|
|
507
|
+
} else {
|
|
508
|
+
let timer = setInterval(() => {
|
|
509
|
+
if (isConfigInitialized.value) {
|
|
510
|
+
clearInterval(timer);
|
|
511
|
+
resolve();
|
|
512
|
+
}
|
|
513
|
+
}, 10);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
return { SohelpConfig, initial, isConfigDone, isConfigInitialized, moduleCache };
|
|
519
|
+
}
|