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,76 @@
|
|
|
1
|
+
export const filterFields = [
|
|
2
|
+
'id',
|
|
3
|
+
'id_insert_date',
|
|
4
|
+
'id_insert_user',
|
|
5
|
+
'id_insert_org',
|
|
6
|
+
'id_update_date',
|
|
7
|
+
'id_update_user'
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const getColProps = (grid, colSpan) => {
|
|
11
|
+
if (grid === 1 || colSpan === 1) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const span = 24 / grid;
|
|
15
|
+
return { span: span * colSpan };
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// 根据type匹配组件类型
|
|
19
|
+
export const matchingType = (type) => {
|
|
20
|
+
switch (type) {
|
|
21
|
+
case 'BOOLEAN':
|
|
22
|
+
return 'switch';
|
|
23
|
+
case 'DATE':
|
|
24
|
+
return 'date';
|
|
25
|
+
case 'DATETIME':
|
|
26
|
+
return 'datetime';
|
|
27
|
+
case 'JSON':
|
|
28
|
+
return 'textarea';
|
|
29
|
+
case 'INT':
|
|
30
|
+
return 'inputNumber';
|
|
31
|
+
case 'BIGINT':
|
|
32
|
+
return 'inputNumber';
|
|
33
|
+
case 'FLOAT':
|
|
34
|
+
return 'inputNumber';
|
|
35
|
+
case 'SEQUENCE':
|
|
36
|
+
return 'inputNumber';
|
|
37
|
+
case 'TIMESTAMP':
|
|
38
|
+
case 'LONGBLOB':
|
|
39
|
+
case 'TEXT':
|
|
40
|
+
return 'SohelpInput'
|
|
41
|
+
case 'AUTOCODE':
|
|
42
|
+
return 'SohelpAutocode'
|
|
43
|
+
case 'FILE':
|
|
44
|
+
return 'SohelpFileUpload';
|
|
45
|
+
case 'IMAGE':
|
|
46
|
+
return 'SohelpImageUpload';
|
|
47
|
+
case 'RELATION':
|
|
48
|
+
return 'SohelpTableSelect';
|
|
49
|
+
default:
|
|
50
|
+
return 'input';
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const toProFormConfig = (res) => {
|
|
55
|
+
return res.properties
|
|
56
|
+
.filter((item) => !filterFields.includes(item.name))
|
|
57
|
+
.map((item, index) => {
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
key: item?.name || 'tempKey' + index,
|
|
61
|
+
type: item?.editor ? item.editor : matchingType(item?.type || ''),
|
|
62
|
+
i18n:item.i18n,
|
|
63
|
+
label: item.label,
|
|
64
|
+
length: item.length,
|
|
65
|
+
fieldType: item.type,
|
|
66
|
+
isEntity: item?.isEntity ?? true,
|
|
67
|
+
required: item.notNull,
|
|
68
|
+
itemProps: item?.formItemOption ? JSON.parse(item.formItemOption) : '',
|
|
69
|
+
props: item?.editorParam ? JSON.parse(item.editorParam) : '',
|
|
70
|
+
options: item?.editorData ? JSON.parse(item.editorData) : '',
|
|
71
|
+
prop: item?.name,
|
|
72
|
+
hidden: item.hidden || filterFields.includes(item.name),
|
|
73
|
+
colProps: getColProps(res.gridNum, item.gridNum)
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
};
|
package/utils/core.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/** 常用工具方法 */
|
|
2
|
+
/**
|
|
3
|
+
* parentId 形式数据转 children 形式
|
|
4
|
+
* @param option ToTreeOption
|
|
5
|
+
*/
|
|
6
|
+
export function toTree(option) {
|
|
7
|
+
const data = option.data;
|
|
8
|
+
const idField = option.idField || 'id';
|
|
9
|
+
const parentIdField = option.parentIdField || 'parentId';
|
|
10
|
+
const childrenField = option.childrenField || 'children';
|
|
11
|
+
const parentIdIsNull = option.parentId == null;
|
|
12
|
+
const parentId = parentIdIsNull ? [] : option.parentId;
|
|
13
|
+
const addParentIds = option.addParentIds;
|
|
14
|
+
const parentIdsField = option.parentIdsField || 'parentIds';
|
|
15
|
+
const parentIds = option.parentIds ?? [];
|
|
16
|
+
if (data == null) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
if (parentIdIsNull) {
|
|
20
|
+
data.forEach((d) => {
|
|
21
|
+
if (!data.some((t) => d[parentIdField] == t[idField]) &&
|
|
22
|
+
!parentId.includes(d[parentIdField])) {
|
|
23
|
+
parentId.push(d[parentIdField]);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const result = [];
|
|
28
|
+
data.forEach((d) => {
|
|
29
|
+
if (d[idField] == d[parentIdField]) {
|
|
30
|
+
throw new Error([
|
|
31
|
+
'data error: {',
|
|
32
|
+
idField + ': ',
|
|
33
|
+
JSON.stringify(d[idField]),
|
|
34
|
+
', ' + parentIdField + ': ',
|
|
35
|
+
JSON.stringify(d[parentIdField]),
|
|
36
|
+
'}'
|
|
37
|
+
].join(''));
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(parentId)
|
|
40
|
+
? parentId.includes(d[parentIdField])
|
|
41
|
+
: d[parentIdField] == parentId) {
|
|
42
|
+
const t = { ...d };
|
|
43
|
+
const children = toTree({
|
|
44
|
+
data,
|
|
45
|
+
idField,
|
|
46
|
+
parentIdField,
|
|
47
|
+
childrenField,
|
|
48
|
+
parentId: d[idField],
|
|
49
|
+
addParentIds,
|
|
50
|
+
parentIdsField,
|
|
51
|
+
parentIds: [...parentIds, d[idField]]
|
|
52
|
+
});
|
|
53
|
+
if (children.length > 0) {
|
|
54
|
+
t[childrenField] = children;
|
|
55
|
+
}
|
|
56
|
+
if (addParentIds) {
|
|
57
|
+
t[parentIdsField] = parentIds;
|
|
58
|
+
}
|
|
59
|
+
result.push(t);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 遍历树形形式数据
|
|
66
|
+
* @param data 需要遍历的数据
|
|
67
|
+
* @param callback 回调
|
|
68
|
+
* @param childrenField children 字段名
|
|
69
|
+
*/
|
|
70
|
+
export function eachTree(data, callback, childrenField = 'children', parent) {
|
|
71
|
+
if (data) {
|
|
72
|
+
data.forEach((d, i) => {
|
|
73
|
+
if (callback &&
|
|
74
|
+
callback(d, i, parent) !== false &&
|
|
75
|
+
d[childrenField]?.length) {
|
|
76
|
+
eachTree(d[childrenField], callback, childrenField, d);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 格式化树形数据
|
|
83
|
+
* @param data 需要格式化的数据
|
|
84
|
+
* @param formatter 格式器
|
|
85
|
+
* @param childrenField children 字段名
|
|
86
|
+
* @param resultChildrenField 格式化后的 children 字段名
|
|
87
|
+
*/
|
|
88
|
+
export function mapTree(data, formatter, childrenField = 'children', resultChildrenField = 'children', parent) {
|
|
89
|
+
const result = [];
|
|
90
|
+
if (data && data.length) {
|
|
91
|
+
data.forEach((d, i) => {
|
|
92
|
+
const item = formatter(d, i, parent);
|
|
93
|
+
if (item) {
|
|
94
|
+
if (d[childrenField] != null) {
|
|
95
|
+
item[resultChildrenField] = mapTree(d[childrenField], formatter, childrenField, resultChildrenField, item);
|
|
96
|
+
}
|
|
97
|
+
result.push(item);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 查找树形数据
|
|
105
|
+
* @param data 数据
|
|
106
|
+
* @param predicate 查找条件
|
|
107
|
+
* @param childrenField children 字段名
|
|
108
|
+
*/
|
|
109
|
+
export function findTree(data, predicate, childrenField) {
|
|
110
|
+
let temp;
|
|
111
|
+
eachTree(data, (d, i) => {
|
|
112
|
+
if (predicate(d, i)) {
|
|
113
|
+
temp = d;
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}, childrenField);
|
|
117
|
+
return temp;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 生成随机字符串
|
|
121
|
+
* @param length 长度
|
|
122
|
+
* @param radix 基数
|
|
123
|
+
*/
|
|
124
|
+
export function uuid(length = 32, radix) {
|
|
125
|
+
const str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
126
|
+
let result = '';
|
|
127
|
+
for (let i = 0; i < length; i++) {
|
|
128
|
+
result += str.charAt(Math.floor(Math.random() * (radix || str.length)));
|
|
129
|
+
}
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 生成 m 到 n 的随机数
|
|
134
|
+
* @param m 最小值, 包含
|
|
135
|
+
* @param n 最大值, 不包含
|
|
136
|
+
*/
|
|
137
|
+
export function random(m, n) {
|
|
138
|
+
return Math.floor(Math.random() * (m - n) + n);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* 数字千分位
|
|
142
|
+
* @param num 数字
|
|
143
|
+
*/
|
|
144
|
+
export function formatNumber(num) {
|
|
145
|
+
return String(num ?? '').replace(/(\d{1,3})(?=(\d{3})+(?:$|\.))/g, '$1,');
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 赋值不改变原字段
|
|
149
|
+
* @param target 目标对象
|
|
150
|
+
* @param source 源对象
|
|
151
|
+
* @param excludes 排除的字段
|
|
152
|
+
*/
|
|
153
|
+
export function assignObject(target, source, excludes) {
|
|
154
|
+
Object.keys(target).forEach((key) => {
|
|
155
|
+
if (!excludes?.includes(key)) {
|
|
156
|
+
target[key] = source[key];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
return target;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 全屏
|
|
163
|
+
* @param el HTMLElement
|
|
164
|
+
*/
|
|
165
|
+
export function requestFullscreen(el) {
|
|
166
|
+
if (el == null) {
|
|
167
|
+
el = document.documentElement;
|
|
168
|
+
}
|
|
169
|
+
const func = el.requestFullscreen ||
|
|
170
|
+
el.requestFullScreen ||
|
|
171
|
+
el.webkitRequestFullScreen ||
|
|
172
|
+
el.mozRequestFullScreen ||
|
|
173
|
+
el.msRequestFullScreen;
|
|
174
|
+
if (!func) {
|
|
175
|
+
throw new Error('您的浏览器不支持全屏模式');
|
|
176
|
+
}
|
|
177
|
+
func.call(el);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 退出全屏
|
|
181
|
+
*/
|
|
182
|
+
export function exitFullscreen() {
|
|
183
|
+
const func = document.exitFullscreen ||
|
|
184
|
+
document.exitFullScreen ||
|
|
185
|
+
document.webkitCancelFullScreen ||
|
|
186
|
+
document.mozCancelFullScreen ||
|
|
187
|
+
document.msExitFullscreen;
|
|
188
|
+
func && func.call(document);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 检查是否全屏
|
|
192
|
+
*/
|
|
193
|
+
export function checkFullscreen() {
|
|
194
|
+
return !!(document.fullscreenElement ||
|
|
195
|
+
document.webkitFullscreenElement ||
|
|
196
|
+
document.mozFullScreenElement ||
|
|
197
|
+
document.msFullscreenElement);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 百度地图坐标转高德地图坐标
|
|
201
|
+
* @param point 坐标
|
|
202
|
+
*/
|
|
203
|
+
export function bd09ToGcj02(point) {
|
|
204
|
+
const x_pi = (3.141592653589793 * 3000.0) / 180.0;
|
|
205
|
+
const x = point.lng - 0.0065;
|
|
206
|
+
const y = point.lat - 0.006;
|
|
207
|
+
const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
|
|
208
|
+
const theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
|
|
209
|
+
return {
|
|
210
|
+
lng: z * Math.cos(theta),
|
|
211
|
+
lat: z * Math.sin(theta)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* 高德地图坐标转百度地图坐标
|
|
216
|
+
* @param point 坐标
|
|
217
|
+
*/
|
|
218
|
+
export function gcj02ToBd09(point) {
|
|
219
|
+
const x_pi = (3.141592653589793 * 3000.0) / 180.0;
|
|
220
|
+
const x = point.lng;
|
|
221
|
+
const y = point.lat;
|
|
222
|
+
const z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
|
223
|
+
const theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
|
224
|
+
return {
|
|
225
|
+
lng: z * Math.cos(theta) + 0.0065,
|
|
226
|
+
lat: z * Math.sin(theta) + 0.006
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 判断是否是外链
|
|
231
|
+
* @param url 地址
|
|
232
|
+
*/
|
|
233
|
+
export function isExternalLink(url) {
|
|
234
|
+
return !!(url &&
|
|
235
|
+
(url.startsWith('http://') ||
|
|
236
|
+
url.startsWith('https://') ||
|
|
237
|
+
url.startsWith('//')));
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* 获取节点样式
|
|
241
|
+
* @param el 节点
|
|
242
|
+
*/
|
|
243
|
+
export function getCurrentStyle(el) {
|
|
244
|
+
return el['currentStyle'] || window.getComputedStyle(el, null) || {};
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* 防抖函数
|
|
248
|
+
* @param func 函数
|
|
249
|
+
* @param wait 等待时间
|
|
250
|
+
*/
|
|
251
|
+
export function debounce(func, wait) {
|
|
252
|
+
let timer = void 0;
|
|
253
|
+
const debounced = function (...args) {
|
|
254
|
+
if (timer) {
|
|
255
|
+
clearTimeout(timer);
|
|
256
|
+
}
|
|
257
|
+
timer = setTimeout(() => {
|
|
258
|
+
func.apply(this, args);
|
|
259
|
+
timer = void 0;
|
|
260
|
+
}, wait);
|
|
261
|
+
};
|
|
262
|
+
return debounced;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 节流函数
|
|
266
|
+
* @param func 函数
|
|
267
|
+
* @param wait 等待时间
|
|
268
|
+
*/
|
|
269
|
+
export function throttle(func, wait) {
|
|
270
|
+
let timer = void 0;
|
|
271
|
+
const debounced = function (...args) {
|
|
272
|
+
if (!timer) {
|
|
273
|
+
func.apply(this, args);
|
|
274
|
+
timer = setTimeout(() => {
|
|
275
|
+
timer = void 0;
|
|
276
|
+
}, wait);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
return debounced;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* 忽略对象属性
|
|
283
|
+
* @param obj 来源对象
|
|
284
|
+
* @param fields 忽略的属性
|
|
285
|
+
*/
|
|
286
|
+
export function omit(obj, fields) {
|
|
287
|
+
const result = Object.assign({}, obj);
|
|
288
|
+
if (obj) {
|
|
289
|
+
for (let i = 0; i < fields.length; i++) {
|
|
290
|
+
const key = fields[i];
|
|
291
|
+
delete result[key];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* 摘选对象属性
|
|
298
|
+
* @param obj 来源对象
|
|
299
|
+
* @param fields 摘选的属性
|
|
300
|
+
*/
|
|
301
|
+
export function pick(obj, fields) {
|
|
302
|
+
const result = {};
|
|
303
|
+
if (obj) {
|
|
304
|
+
for (let i = 0; i < fields.length; i++) {
|
|
305
|
+
const key = fields[i];
|
|
306
|
+
result[key] = obj[key];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { reactive } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 表单数据hook
|
|
5
|
+
* @param initValue 默认值
|
|
6
|
+
*/
|
|
7
|
+
export function useFormData(initValue) {
|
|
8
|
+
/** 表单数据 */
|
|
9
|
+
const form = reactive({ ...initValue });
|
|
10
|
+
const _initValue = JSON.stringify(initValue)
|
|
11
|
+
|
|
12
|
+
/** 重置为初始值 */
|
|
13
|
+
const resetFields = (field) => {
|
|
14
|
+
const keys = Object.keys(form);
|
|
15
|
+
if (typeof field === 'string' && field) {
|
|
16
|
+
if (keys.includes(field)) {
|
|
17
|
+
form[field] = initValue ? initValue[field] : void 0;
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
keys.forEach((key) => {
|
|
22
|
+
form[key] = initValue[key] || '';
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** 赋值不改变字段 */
|
|
27
|
+
const assignFields = (data, excludes) => {
|
|
28
|
+
Object.keys(form).forEach((key) => {
|
|
29
|
+
if (!excludes?.includes?.(key)) {
|
|
30
|
+
form[key] = data[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** 赋值某字段 */
|
|
36
|
+
const setFieldValue = (field, value) => {
|
|
37
|
+
form[field] = value;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const result = [form, resetFields, assignFields, setFieldValue];
|
|
41
|
+
// 支持对象解构以兼容旧版
|
|
42
|
+
Object.assign(result, {
|
|
43
|
+
form,
|
|
44
|
+
resetFields,
|
|
45
|
+
assignFields
|
|
46
|
+
});
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ref, onBeforeUnmount } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取是否是移动端小屏幕hook
|
|
5
|
+
* @param onChange 值改变回调
|
|
6
|
+
*/
|
|
7
|
+
export function useMobile(onChange) {
|
|
8
|
+
const media = window.matchMedia('(max-width: 768px)');
|
|
9
|
+
const mobile = ref(media.matches);
|
|
10
|
+
|
|
11
|
+
const onMediaChangeListener = () => {
|
|
12
|
+
mobile.value = media.matches;
|
|
13
|
+
onChange && onChange(mobile.value);
|
|
14
|
+
};
|
|
15
|
+
media.addEventListener('change', onMediaChangeListener);
|
|
16
|
+
|
|
17
|
+
onBeforeUnmount(() => {
|
|
18
|
+
media.removeEventListener('change', onMediaChangeListener);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return { mobile };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 获取是否是移动端触摸设备hook
|
|
26
|
+
* @param onChange 值改变回调
|
|
27
|
+
*/
|
|
28
|
+
export function useMobileDevice(onChange) {
|
|
29
|
+
const media = window.matchMedia('(pointer: coarse)');
|
|
30
|
+
const mobileDevice = ref(media.matches);
|
|
31
|
+
|
|
32
|
+
const onMediaChangeListener = () => {
|
|
33
|
+
mobileDevice.value = media.matches;
|
|
34
|
+
onChange && onChange(mobileDevice.value);
|
|
35
|
+
};
|
|
36
|
+
media.addEventListener('change', onMediaChangeListener);
|
|
37
|
+
|
|
38
|
+
onBeforeUnmount(() => {
|
|
39
|
+
media.removeEventListener('change', onMediaChangeListener);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return { mobileDevice };
|
|
43
|
+
}
|