@gct-paas/core 0.1.6-dev.13 → 0.1.6-dev.15

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.
@@ -0,0 +1,129 @@
1
+ import { FIELD_TYPE } from "../enums/appEnum.mjs";
2
+ import "../enums/index.mjs";
3
+ import { cloneDeep } from "lodash-es";
4
+ //#region src/utils/select-user-utils.ts
5
+ /** 动态类型 */
6
+ var DYN_FORMAT_TYPE_ENUM = /* @__PURE__ */ function(DYN_FORMAT_TYPE_ENUM) {
7
+ /** 申请人直属上级 */
8
+ DYN_FORMAT_TYPE_ENUM["DYN_SUBMITTER_MANAGER"] = "DYN_SUBMITTER_MANAGER";
9
+ /** 申请人部门负责人 */
10
+ DYN_FORMAT_TYPE_ENUM["DYN_SUBMITTER_DEPT_PRINCIPAL"] = "DYN_SUBMITTER_DEPT_PRINCIPAL";
11
+ /** 指定人员字段 */
12
+ DYN_FORMAT_TYPE_ENUM["DYN_MODEL_USERS"] = "DYN_MODEL_USERS";
13
+ /** 指定人员字段直属上级 */
14
+ DYN_FORMAT_TYPE_ENUM["DYN_MODEL_USER_MANAGER"] = "DYN_MODEL_USER_MANAGER";
15
+ /** 指定部门负责人 */
16
+ DYN_FORMAT_TYPE_ENUM["DYN_DEPT_PRINCIPAL"] = "DYN_DEPT_PRINCIPAL";
17
+ /** 指定部门字段 */
18
+ DYN_FORMAT_TYPE_ENUM["DYN_MODEL_ORG"] = "DYN_MODEL_ORG";
19
+ /** 指定部门字段负责人 */
20
+ DYN_FORMAT_TYPE_ENUM["DYN_MODEL_DEPT_PRINCIPAL"] = "DYN_MODEL_DEPT_PRINCIPAL";
21
+ return DYN_FORMAT_TYPE_ENUM;
22
+ }({});
23
+ var DynFormatTypes = Object.values(DYN_FORMAT_TYPE_ENUM);
24
+ var filterDynFormatTypes = Object.values(DYN_FORMAT_TYPE_ENUM).filter((item) => ![DYN_FORMAT_TYPE_ENUM.DYN_SUBMITTER_MANAGER, DYN_FORMAT_TYPE_ENUM.DYN_SUBMITTER_DEPT_PRINCIPAL].includes(item)).map((type) => `${type}:current`);
25
+ var dynamicData = [
26
+ {
27
+ id: "currentDs",
28
+ formatId: DYN_FORMAT_TYPE_ENUM.DYN_SUBMITTER_MANAGER,
29
+ name: "申请人直属上级",
30
+ desc: "可将申请人直属上级设为节点处理人"
31
+ },
32
+ {
33
+ id: "currentDeptDs",
34
+ formatId: DYN_FORMAT_TYPE_ENUM.DYN_SUBMITTER_DEPT_PRINCIPAL,
35
+ name: "申请人部门负责人",
36
+ desc: "可将申请人所在部门负责人设为节点处理人"
37
+ },
38
+ {
39
+ id: "userField",
40
+ formatId: DYN_FORMAT_TYPE_ENUM.DYN_MODEL_USERS,
41
+ name: "指定人员字段",
42
+ desc: "字段所选用户作为节点处理人",
43
+ showPanel: true,
44
+ panelType: "area",
45
+ panelKey: [FIELD_TYPE.USER, FIELD_TYPE.USER_MULTI]
46
+ },
47
+ {
48
+ id: "userFieldDs",
49
+ formatId: DYN_FORMAT_TYPE_ENUM.DYN_MODEL_USER_MANAGER,
50
+ name: "指定人员字段直属上级",
51
+ desc: "字段所选用户的直属上级为节点处理人",
52
+ showPanel: true,
53
+ panelType: "area",
54
+ panelKey: [FIELD_TYPE.USER, FIELD_TYPE.USER_MULTI]
55
+ },
56
+ {
57
+ id: "orgDs",
58
+ formatId: DYN_FORMAT_TYPE_ENUM.DYN_DEPT_PRINCIPAL,
59
+ name: "指定部门负责人",
60
+ desc: "所选部门负责人作为节点处理人",
61
+ showPanel: true,
62
+ panelType: "select"
63
+ },
64
+ {
65
+ id: "orgFieldDs",
66
+ formatId: DYN_FORMAT_TYPE_ENUM.DYN_MODEL_DEPT_PRINCIPAL,
67
+ name: "指定部门字段负责人",
68
+ desc: "字段所选部门负责人作为节点处理人",
69
+ showPanel: true,
70
+ panelType: "area",
71
+ panelKey: [FIELD_TYPE.ORG, FIELD_TYPE.ORG_MULTI]
72
+ }
73
+ ];
74
+ function list2Tree(list) {
75
+ const treeOptions = [];
76
+ const arrClone = cloneDeep(list);
77
+ const mapInfo = arrClone.reduce((obj, item) => {
78
+ item.children = [];
79
+ obj[item.id] = item;
80
+ return obj;
81
+ }, {});
82
+ arrClone.forEach((i) => {
83
+ const parent = mapInfo[i.parentId];
84
+ if (parent) parent.children.push(i);
85
+ else treeOptions.push(i);
86
+ });
87
+ return treeOptions;
88
+ }
89
+ function highlightName(str, searchValue = "") {
90
+ const displayName = str;
91
+ const rDisplayName = displayName?.replace(new RegExp(searchValue?.replace(/* @__PURE__ */ new RegExp(/(?=[$.?+[\]*^|\\(){}/])/g), "\\"), "g"), (s) => `<span class="is-highlight">${s}</span>`);
92
+ if (rDisplayName === displayName) return null;
93
+ return rDisplayName;
94
+ }
95
+ var filterTree = (tree, searchValue) => {
96
+ return tree.map((node) => {
97
+ if (node.children) {
98
+ const filteredChildren = filterTree(node.children, searchValue);
99
+ if (filteredChildren.length > 0) return {
100
+ ...node,
101
+ children: filteredChildren
102
+ };
103
+ }
104
+ const hlName = highlightName(node.name, searchValue);
105
+ if (hlName) return {
106
+ ...node,
107
+ highlightName: hlName
108
+ };
109
+ return null;
110
+ }).filter((node) => node !== null);
111
+ };
112
+ var findUniqueNode = (tree, tid) => {
113
+ for (const node of tree) {
114
+ if (node.id === tid) return node;
115
+ if (node.children) {
116
+ const foundNode = findUniqueNode(node.children, tid);
117
+ if (foundNode) return foundNode;
118
+ }
119
+ }
120
+ return null;
121
+ };
122
+ function showDynamicTitle(id, name) {
123
+ if (id.includes(DYN_FORMAT_TYPE_ENUM.DYN_MODEL_USER_MANAGER)) return `${name}:直属上级`;
124
+ if (id.includes(DYN_FORMAT_TYPE_ENUM.DYN_DEPT_PRINCIPAL)) return `${name}:负责人`;
125
+ if (id.includes(DYN_FORMAT_TYPE_ENUM.DYN_MODEL_DEPT_PRINCIPAL)) return `${name}:负责人`;
126
+ return name;
127
+ }
128
+ //#endregion
129
+ export { DYN_FORMAT_TYPE_ENUM, DynFormatTypes, dynamicData, filterDynFormatTypes, filterTree, findUniqueNode, highlightName, list2Tree, showDynamicTitle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/core",
3
- "version": "0.1.6-dev.13",
3
+ "version": "0.1.6-dev.15",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "loader": "dist/index.esm.min.js",