@ibiz-template/runtime 0.5.0 → 0.5.1-dev.0
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/dist/index.esm.js +165 -144
- package/dist/index.system.min.js +1 -1
- package/out/constant/view-type.d.ts +5 -1
- package/out/constant/view-type.d.ts.map +1 -1
- package/out/constant/view-type.js +4 -0
- package/out/controller/control/exp-bar/tree-exp-bar.controller.d.ts +1 -2
- package/out/controller/control/exp-bar/tree-exp-bar.controller.d.ts.map +1 -1
- package/out/controller/control/exp-bar/tree-exp-bar.controller.js +6 -7
- package/out/controller/control/gantt/gantt.controller.js +2 -2
- package/out/controller/control/gantt/gantt.service.js +2 -2
- package/out/controller/control/tree/tree.controller.d.ts +8 -3
- package/out/controller/control/tree/tree.controller.d.ts.map +1 -1
- package/out/controller/control/tree/tree.controller.js +63 -63
- package/out/controller/control/tree/tree.service.js +8 -8
- package/out/controller/control/tree-grid-ex/tree-grid-ex.controller.d.ts.map +1 -1
- package/out/controller/control/tree-grid-ex/tree-grid-ex.controller.js +2 -2
- package/out/interface/controller/event/view/i-sub-app-ref-view.event.d.ts +12 -0
- package/out/interface/controller/event/view/i-sub-app-ref-view.event.d.ts.map +1 -0
- package/out/interface/controller/event/view/i-sub-app-ref-view.event.js +1 -0
- package/out/interface/controller/event/view/index.d.ts +1 -0
- package/out/interface/controller/event/view/index.d.ts.map +1 -1
- package/out/interface/controller/event/view/index.js +1 -0
- package/out/interface/controller/state/control/i-gantt.state.d.ts +2 -2
- package/out/interface/controller/state/control/i-gantt.state.d.ts.map +1 -1
- package/out/interface/controller/state/control/i-tree.state.d.ts +26 -25
- package/out/interface/controller/state/control/i-tree.state.d.ts.map +1 -1
- package/out/interface/controller/state/view/i-sub-app-ref-view.state.d.ts +11 -0
- package/out/interface/controller/state/view/i-sub-app-ref-view.state.d.ts.map +1 -0
- package/out/interface/controller/state/view/i-sub-app-ref-view.state.js +1 -0
- package/out/interface/controller/state/view/index.d.ts +1 -0
- package/out/interface/controller/state/view/index.d.ts.map +1 -1
- package/out/interface/controller/state/view/index.js +1 -0
- package/out/service/dto/method.dto.d.ts +12 -1
- package/out/service/dto/method.dto.d.ts.map +1 -1
- package/out/service/dto/method.dto.js +15 -3
- package/out/service/vo/gantt-node-data/gantt-code-list-node-data.d.ts +2 -2
- package/out/service/vo/gantt-node-data/gantt-code-list-node-data.d.ts.map +1 -1
- package/out/service/vo/gantt-node-data/gantt-data-set-node-data.d.ts +2 -2
- package/out/service/vo/gantt-node-data/gantt-data-set-node-data.d.ts.map +1 -1
- package/out/service/vo/gantt-node-data/gantt-static-node-data.d.ts +2 -2
- package/out/service/vo/gantt-node-data/gantt-static-node-data.d.ts.map +1 -1
- package/out/service/vo/tree-node-data/tree-code-list-node-data.d.ts +3 -3
- package/out/service/vo/tree-node-data/tree-code-list-node-data.d.ts.map +1 -1
- package/out/service/vo/tree-node-data/tree-code-list-node-data.js +10 -10
- package/out/service/vo/tree-node-data/tree-data-set-node-data.d.ts +4 -4
- package/out/service/vo/tree-node-data/tree-data-set-node-data.d.ts.map +1 -1
- package/out/service/vo/tree-node-data/tree-data-set-node-data.js +27 -27
- package/out/service/vo/tree-node-data/tree-node-data.d.ts +12 -13
- package/out/service/vo/tree-node-data/tree-node-data.d.ts.map +1 -1
- package/out/service/vo/tree-node-data/tree-node-data.js +8 -8
- package/out/service/vo/tree-node-data/tree-static-node-data.d.ts +4 -4
- package/out/service/vo/tree-node-data/tree-static-node-data.d.ts.map +1 -1
- package/out/service/vo/tree-node-data/tree-static-node-data.js +11 -11
- package/package.json +5 -5
- package/src/constant/view-type.ts +5 -0
- package/src/controller/control/exp-bar/tree-exp-bar.controller.ts +6 -7
- package/src/controller/control/gantt/gantt.controller.ts +2 -2
- package/src/controller/control/gantt/gantt.service.ts +2 -2
- package/src/controller/control/tree/tree.controller.ts +70 -65
- package/src/controller/control/tree/tree.service.ts +8 -8
- package/src/controller/control/tree-grid-ex/tree-grid-ex.controller.ts +7 -3
- package/src/interface/controller/event/view/i-sub-app-ref-view.event.ts +12 -0
- package/src/interface/controller/event/view/index.ts +1 -0
- package/src/interface/controller/state/control/i-gantt.state.ts +2 -2
- package/src/interface/controller/state/control/i-tree.state.ts +27 -25
- package/src/interface/controller/state/view/i-sub-app-ref-view.state.ts +10 -0
- package/src/interface/controller/state/view/index.ts +1 -0
- package/src/service/dto/method.dto.ts +14 -2
- package/src/service/vo/gantt-node-data/gantt-code-list-node-data.ts +2 -2
- package/src/service/vo/gantt-node-data/gantt-data-set-node-data.ts +2 -2
- package/src/service/vo/gantt-node-data/gantt-static-node-data.ts +2 -2
- package/src/service/vo/tree-node-data/tree-code-list-node-data.ts +13 -13
- package/src/service/vo/tree-node-data/tree-data-set-node-data.ts +35 -35
- package/src/service/vo/tree-node-data/tree-node-data.ts +19 -22
- package/src/service/vo/tree-node-data/tree-static-node-data.ts +16 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-node-data.d.ts","sourceRoot":"","sources":["../../../../src/service/vo/tree-node-data/tree-node-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;GAMG;AACH,8BAAsB,YAAa,YAAW,aAAa;IACzD,KAAK,EAAE,MAAM,CAAgB;IAE7B,SAAS,EAAE,MAAM,CAAC;IAElB,
|
|
1
|
+
{"version":3,"file":"tree-node-data.d.ts","sourceRoot":"","sources":["../../../../src/service/vo/tree-node-data/tree-node-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;GAMG;AACH,8BAAsB,YAAa,YAAW,aAAa;IACzD,KAAK,EAAE,MAAM,CAAgB;IAE7B,SAAS,EAAE,MAAM,CAAC;IAElB,GAAG,EAAG,MAAM,CAAC;IAEb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B,KAAK,EAAG,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAExC,OAAO,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;IAE5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAElC,OAAO,EAAE,MAAM,CAAC;IAEhB,KAAK,EAAE,OAAO,CAAS;IAEvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd,SAAS,CAAC,EAAE,MAAM,CAAC;gBAGjB,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,aAAa,GAAG,SAAS,EACzC,IAAI,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAuBpE;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,KAAK,GAAG,SAAS;CAa1D"}
|
|
@@ -9,22 +9,22 @@ import { createUUID } from 'qx-util';
|
|
|
9
9
|
export class TreeNodeData {
|
|
10
10
|
constructor(model, parentNodeData, opts) {
|
|
11
11
|
this._uuid = createUUID();
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
12
|
+
this._leaf = false;
|
|
13
|
+
this._leaf = opts.leaf === true;
|
|
14
|
+
this._parent = parentNodeData;
|
|
15
15
|
this._nodeType = model.treeNodeType;
|
|
16
16
|
// 所有节点都要继承父的上下文,如果父存在则复制父的资源上下文,否则返回空对象。
|
|
17
|
-
if (this.
|
|
18
|
-
this.
|
|
17
|
+
if (this._parent) {
|
|
18
|
+
this._context = Object.assign({}, this._parent._context);
|
|
19
19
|
}
|
|
20
20
|
// 附加导航上下文和视图参数
|
|
21
21
|
if (opts.navContext) {
|
|
22
|
-
this.
|
|
22
|
+
this._context = Object.assign(this._context || {}, opts.navContext);
|
|
23
23
|
}
|
|
24
24
|
if (opts.navParams) {
|
|
25
|
-
this.
|
|
25
|
+
this._params = Object.assign({}, opts.navParams);
|
|
26
26
|
}
|
|
27
|
-
this.
|
|
27
|
+
this._nodeId = model.id;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* 计算节点图标
|
|
@@ -10,10 +10,10 @@ import { TreeNodeData } from './tree-node-data';
|
|
|
10
10
|
* @implements {ITreeNodeData}
|
|
11
11
|
*/
|
|
12
12
|
export declare class TreeStaticNodeData extends TreeNodeData implements ITreeNodeData {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
_text: string;
|
|
14
|
+
_id: string;
|
|
15
|
+
_value?: string;
|
|
16
|
+
_deData?: IData;
|
|
17
17
|
constructor(model: IDETreeStaticNode, parentNodeData: ITreeNodeData | undefined, opts: {
|
|
18
18
|
parentValueLevel?: number;
|
|
19
19
|
leaf: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-static-node-data.d.ts","sourceRoot":"","sources":["../../../../src/service/vo/tree-node-data/tree-static-node-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,YAAa,YAAW,aAAa;IAC3E,
|
|
1
|
+
{"version":3,"file":"tree-static-node-data.d.ts","sourceRoot":"","sources":["../../../../src/service/vo/tree-node-data/tree-static-node-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,YAAa,YAAW,aAAa;IAC3E,KAAK,EAAE,MAAM,CAAC;IAEd,GAAG,EAAG,MAAM,CAAC;IAEb,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,OAAO,CAAC,EAAE,KAAK,CAAC;gBAGd,KAAK,EAAE,iBAAiB,EACxB,cAAc,EAAE,aAAa,GAAG,SAAS,EACzC,IAAI,EAAE;QAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE;CAuCrD"}
|
|
@@ -15,30 +15,30 @@ export class TreeStaticNodeData extends TreeNodeData {
|
|
|
15
15
|
const nodeValue = model.nodeValue === 'root' ? undefined : model.nodeValue;
|
|
16
16
|
// id小写
|
|
17
17
|
const selfId = `${model.id}`.toLowerCase();
|
|
18
|
-
Object.defineProperty(this, '
|
|
18
|
+
Object.defineProperty(this, '_id', {
|
|
19
19
|
get() {
|
|
20
|
-
return this.
|
|
20
|
+
return this._parent ? `${this._parent._id}:${selfId}` : selfId;
|
|
21
21
|
},
|
|
22
22
|
enumerable: true,
|
|
23
23
|
configurable: true,
|
|
24
24
|
});
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
25
|
+
this._text = model.text;
|
|
26
|
+
this._value = nodeValue;
|
|
27
27
|
// 静态节点数据去对应级别的父节点数据
|
|
28
28
|
if (parentNodeData && opts.parentValueLevel) {
|
|
29
29
|
// 根据父值级别查找父数据
|
|
30
30
|
let parent = parentNodeData;
|
|
31
31
|
for (let index = 1; index < opts.parentValueLevel; index++) {
|
|
32
|
-
parent = parent === null || parent === void 0 ? void 0 : parent.
|
|
32
|
+
parent = parent === null || parent === void 0 ? void 0 : parent._parent;
|
|
33
33
|
}
|
|
34
|
-
if (parent === null || parent === void 0 ? void 0 : parent.
|
|
35
|
-
this.
|
|
34
|
+
if (parent === null || parent === void 0 ? void 0 : parent._deData) {
|
|
35
|
+
this._deData = parent._deData;
|
|
36
36
|
}
|
|
37
37
|
// 静态节点值不存在时,取父数据的值
|
|
38
|
-
this.
|
|
38
|
+
this._value = nodeValue || (parent === null || parent === void 0 ? void 0 : parent._value);
|
|
39
39
|
}
|
|
40
|
-
this.srfkey = ((_a = this.
|
|
41
|
-
this.srfmajortext = ((_b = this.
|
|
42
|
-
this.
|
|
40
|
+
this.srfkey = ((_a = this._deData) === null || _a === void 0 ? void 0 : _a.srfkey) || this._value;
|
|
41
|
+
this.srfmajortext = ((_b = this._deData) === null || _b === void 0 ? void 0 : _b.srfmajortext) || this._text;
|
|
42
|
+
this._icon = this.calcIcon(model);
|
|
43
43
|
}
|
|
44
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibiz-template/runtime",
|
|
3
|
-
"version": "0.5.0",
|
|
3
|
+
"version": "0.5.1-dev.0",
|
|
4
4
|
"description": "控制器包",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "out/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"author": "chitanda",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@ibiz-template/core": "^0.5.0",
|
|
33
|
-
"@ibiz/model-core": "^0.1.
|
|
32
|
+
"@ibiz-template/core": "^0.5.1-dev.0",
|
|
33
|
+
"@ibiz/model-core": "^0.1.1",
|
|
34
34
|
"@types/path-browserify": "^1.0.2",
|
|
35
35
|
"@types/qs": "^6.9.11",
|
|
36
36
|
"@types/systemjs": "^6.13.5",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@ibiz-template/core": "^0.5.0-beta.0",
|
|
50
|
-
"@ibiz/model-core": "^0.1.
|
|
50
|
+
"@ibiz/model-core": "^0.1.1",
|
|
51
51
|
"async-validator": "^4.2.5",
|
|
52
52
|
"dayjs": "^1.11.7",
|
|
53
53
|
"echarts": "^5.4.3",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"qx-util": "^0.4.8",
|
|
60
60
|
"ramda": "^0.29.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "c54e4d6aef0c43875f83272fed9126b0265236e0"
|
|
63
63
|
}
|
|
@@ -53,7 +53,7 @@ export class TreeExpBarController
|
|
|
53
53
|
* @date 2023-07-10 03:07:11
|
|
54
54
|
* @memberof TreeExpBarController
|
|
55
55
|
*/
|
|
56
|
-
navKeyName = '
|
|
56
|
+
navKeyName = '_id' as const;
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* 有导航视图的节点模型标识集合
|
|
@@ -88,7 +88,6 @@ export class TreeExpBarController
|
|
|
88
88
|
*
|
|
89
89
|
* @author zk
|
|
90
90
|
* @date 2023-05-29 03:05:36
|
|
91
|
-
* @param {IData} data
|
|
92
91
|
* @memberof ExpBarControlController
|
|
93
92
|
*/
|
|
94
93
|
xDataActive(event: ITreeEvent['onActive']['event']): void {
|
|
@@ -111,11 +110,11 @@ export class TreeExpBarController
|
|
|
111
110
|
context: IContext,
|
|
112
111
|
params: IParams,
|
|
113
112
|
): INavViewMsg {
|
|
114
|
-
const nodeId = node.
|
|
115
|
-
const deData = node.
|
|
116
|
-
const nodeModel = this.getNodeModel(node.
|
|
113
|
+
const nodeId = node._id;
|
|
114
|
+
const deData = node._deData || node;
|
|
115
|
+
const nodeModel = this.getNodeModel(node._nodeId);
|
|
117
116
|
if (!nodeModel) {
|
|
118
|
-
throw new RuntimeError(`找不到${node.
|
|
117
|
+
throw new RuntimeError(`找不到${node._nodeId}的节点模型`);
|
|
119
118
|
}
|
|
120
119
|
const result = this.prepareParams(nodeModel, deData, context, params);
|
|
121
120
|
result.context.currentSrfNav = nodeId;
|
|
@@ -142,7 +141,7 @@ export class TreeExpBarController
|
|
|
142
141
|
return true;
|
|
143
142
|
}
|
|
144
143
|
// 需要导航视图的时候,返回第一个配置了导航视图的节点数据
|
|
145
|
-
return this.navNodeModelIds.includes(node.
|
|
144
|
+
return this.navNodeModelIds.includes(node._nodeId);
|
|
146
145
|
});
|
|
147
146
|
if (!data) {
|
|
148
147
|
return;
|
|
@@ -109,7 +109,7 @@ export class GanttController
|
|
|
109
109
|
data: IData,
|
|
110
110
|
isTransformData: boolean = false,
|
|
111
111
|
): Promise<void> {
|
|
112
|
-
const key = nodeData.srfkey ? 'srfkey' : '
|
|
112
|
+
const key = nodeData.srfkey ? 'srfkey' : '_id';
|
|
113
113
|
const currentNode = this.state.items.find(
|
|
114
114
|
item => item[key] === nodeData[key],
|
|
115
115
|
);
|
|
@@ -117,7 +117,7 @@ export class GanttController
|
|
|
117
117
|
ibiz.log.error('找不到对应的动态实体树节点数据', nodeData);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
|
-
const nodeModel = this.getNodeModel(currentNode.
|
|
120
|
+
const nodeModel = this.getNodeModel(currentNode._nodeId);
|
|
121
121
|
if (nodeModel) {
|
|
122
122
|
const newData = isTransformData
|
|
123
123
|
? this.transformNodeDataItem(nodeModel, data)
|
|
@@ -78,7 +78,7 @@ export class GanttService extends TreeService {
|
|
|
78
78
|
} else {
|
|
79
79
|
// 有父节点的计算节点关系查询对应节点数据并合并
|
|
80
80
|
const childNodeRSs = getChildNodeRSs(this.model, {
|
|
81
|
-
parentId: parentNodeData.
|
|
81
|
+
parentId: parentNodeData._nodeId,
|
|
82
82
|
hasQuery,
|
|
83
83
|
});
|
|
84
84
|
|
|
@@ -185,7 +185,7 @@ export class GanttService extends TreeService {
|
|
|
185
185
|
childNode,
|
|
186
186
|
opts,
|
|
187
187
|
);
|
|
188
|
-
childNode.
|
|
188
|
+
childNode._children = subChildrenNodes;
|
|
189
189
|
}
|
|
190
190
|
}),
|
|
191
191
|
);
|
|
@@ -305,7 +305,7 @@ export class TreeController<
|
|
|
305
305
|
|
|
306
306
|
// 有父节点绑定到父节点数据上,无父节点替换rootNodes
|
|
307
307
|
if (parentNode) {
|
|
308
|
-
parentNode.
|
|
308
|
+
parentNode._children = nodes;
|
|
309
309
|
} else {
|
|
310
310
|
this.state.rootNodes = nodes;
|
|
311
311
|
}
|
|
@@ -326,10 +326,11 @@ export class TreeController<
|
|
|
326
326
|
// 更新items
|
|
327
327
|
this.state.items = [];
|
|
328
328
|
recursiveIterate(
|
|
329
|
-
{
|
|
329
|
+
{ _children: this.state.rootNodes },
|
|
330
330
|
(node: ITreeNodeData) => {
|
|
331
331
|
this.state.items.push(node);
|
|
332
332
|
},
|
|
333
|
+
{ childrenFields: ['_children'] },
|
|
333
334
|
);
|
|
334
335
|
|
|
335
336
|
// 重新计算展开节点标识
|
|
@@ -349,7 +350,7 @@ export class TreeController<
|
|
|
349
350
|
): Promise<void> {
|
|
350
351
|
// 节点有配置常用操作的上下文菜单时,触发界面行为,后续逻辑都不走
|
|
351
352
|
const clickActionItem =
|
|
352
|
-
this.contextMenuInfos[nodeData.
|
|
353
|
+
this.contextMenuInfos[nodeData._nodeId]?.clickTBUIActionItem;
|
|
353
354
|
if (clickActionItem) {
|
|
354
355
|
return this.doUIAction(
|
|
355
356
|
clickActionItem.uiactionId!,
|
|
@@ -361,7 +362,7 @@ export class TreeController<
|
|
|
361
362
|
|
|
362
363
|
// 导航的时候,没有导航视图的时候,节点后续点击逻辑都不走,也不选中
|
|
363
364
|
if (this.state.navigational) {
|
|
364
|
-
const nodeModel = this.getNodeModel(nodeData.
|
|
365
|
+
const nodeModel = this.getNodeModel(nodeData._nodeId);
|
|
365
366
|
if (!nodeModel?.navAppViewId) {
|
|
366
367
|
return;
|
|
367
368
|
}
|
|
@@ -372,7 +373,7 @@ export class TreeController<
|
|
|
372
373
|
// 选中相关处理
|
|
373
374
|
const { selectedData } = this.state;
|
|
374
375
|
// 选中里没有则添加,有则删除
|
|
375
|
-
const filterArr = selectedData.filter(item => item.
|
|
376
|
+
const filterArr = selectedData.filter(item => item._id !== nodeData._id);
|
|
376
377
|
if (filterArr.length === selectedData.length) {
|
|
377
378
|
this.setSelection(
|
|
378
379
|
this.state.singleSelect
|
|
@@ -398,11 +399,11 @@ export class TreeController<
|
|
|
398
399
|
* @param {boolean} isExpand true为展开,false为折叠
|
|
399
400
|
*/
|
|
400
401
|
onExpandChange(nodeData: ITreeNodeData, isExpand: boolean): void {
|
|
401
|
-
const hasKey = this.state.expandedKeys.includes(nodeData.
|
|
402
|
+
const hasKey = this.state.expandedKeys.includes(nodeData._id);
|
|
402
403
|
if (isExpand && !hasKey) {
|
|
403
|
-
this.state.expandedKeys.push(nodeData.
|
|
404
|
+
this.state.expandedKeys.push(nodeData._id);
|
|
404
405
|
} else if (!isExpand && hasKey) {
|
|
405
|
-
const index = this.state.expandedKeys.indexOf(nodeData.
|
|
406
|
+
const index = this.state.expandedKeys.indexOf(nodeData._id);
|
|
406
407
|
if (index !== -1) {
|
|
407
408
|
this.state.expandedKeys.splice(index, 1);
|
|
408
409
|
}
|
|
@@ -427,13 +428,13 @@ export class TreeController<
|
|
|
427
428
|
return this._evt.emit('onActive', { ...nodeParams, nodeData: item });
|
|
428
429
|
}
|
|
429
430
|
|
|
430
|
-
setSelection(selection:
|
|
431
|
+
setSelection(selection: { _id: string }[]): void {
|
|
431
432
|
// todo 当自己点选中时,父节点选不选中,如果选中需要在这边优化
|
|
432
433
|
|
|
433
434
|
// 通过id过滤出原始的树节点数据,避免外部使用的时候传入的选中数据有问题。
|
|
434
|
-
const selectionIds = selection.map(item => item.
|
|
435
|
+
const selectionIds = selection.map(item => item._id);
|
|
435
436
|
const filterArr = this.state.items.filter(item =>
|
|
436
|
-
selectionIds.includes(item.
|
|
437
|
+
selectionIds.includes(item._id),
|
|
437
438
|
);
|
|
438
439
|
super.setSelection(filterArr);
|
|
439
440
|
}
|
|
@@ -453,11 +454,11 @@ export class TreeController<
|
|
|
453
454
|
* 通过标识获取节点数据
|
|
454
455
|
* @author lxm
|
|
455
456
|
* @date 2023-12-22 02:21:38
|
|
456
|
-
* @param {string}
|
|
457
|
+
* @param {string} key 可以是节点_id也可以是_uuid
|
|
457
458
|
* @return {*} {(ITreeNodeData | undefined)}
|
|
458
459
|
*/
|
|
459
460
|
getNodeData(key: string): ITreeNodeData | undefined {
|
|
460
|
-
const find = this.state.items.find(item => item.
|
|
461
|
+
const find = this.state.items.find(item => item._id === key);
|
|
461
462
|
if (find) {
|
|
462
463
|
return find;
|
|
463
464
|
}
|
|
@@ -526,9 +527,9 @@ export class TreeController<
|
|
|
526
527
|
params: IParams;
|
|
527
528
|
} {
|
|
528
529
|
return {
|
|
529
|
-
data: [{ ...nodeData, ...(nodeData.
|
|
530
|
-
context: Object.assign(this.context.clone(), nodeData.
|
|
531
|
-
params: { ...this.params, ...(nodeData.
|
|
530
|
+
data: [{ ...nodeData, ...(nodeData._deData || {}) }],
|
|
531
|
+
context: Object.assign(this.context.clone(), nodeData._context || {}),
|
|
532
|
+
params: { ...this.params, ...(nodeData._params || {}) },
|
|
532
533
|
};
|
|
533
534
|
}
|
|
534
535
|
|
|
@@ -545,11 +546,15 @@ export class TreeController<
|
|
|
545
546
|
let expandedKeys: string[] = [...this.state.expandedKeys];
|
|
546
547
|
|
|
547
548
|
// 计算加载回来的里面带的默认展开
|
|
548
|
-
recursiveIterate(
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
549
|
+
recursiveIterate(
|
|
550
|
+
{ _children: nodes },
|
|
551
|
+
(node: ITreeNodeData) => {
|
|
552
|
+
if (node._children?.length) {
|
|
553
|
+
expandedKeys.push(node._id);
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
{ childrenFields: ['_children'] },
|
|
557
|
+
);
|
|
553
558
|
|
|
554
559
|
// 去重
|
|
555
560
|
expandedKeys = Array.from(new Set(expandedKeys));
|
|
@@ -565,10 +570,10 @@ export class TreeController<
|
|
|
565
570
|
* @return {*} {Promise<void>}
|
|
566
571
|
*/
|
|
567
572
|
async refreshNodeChildren(
|
|
568
|
-
nodeData:
|
|
573
|
+
nodeData: { _id?: string; srfkey?: string },
|
|
569
574
|
refreshParent = false,
|
|
570
575
|
): Promise<void> {
|
|
571
|
-
const key = nodeData.srfkey ? 'srfkey' : '
|
|
576
|
+
const key = nodeData.srfkey ? 'srfkey' : '_id';
|
|
572
577
|
const currentNode = this.state.items.find(
|
|
573
578
|
item => item[key] === nodeData[key],
|
|
574
579
|
);
|
|
@@ -579,18 +584,18 @@ export class TreeController<
|
|
|
579
584
|
|
|
580
585
|
// 刷新父,但是没父,刷新根
|
|
581
586
|
if (refreshParent) {
|
|
582
|
-
const {
|
|
587
|
+
const { _parent } = currentNode;
|
|
583
588
|
// 没有父,或者父是不显示的根节点,那么刷新所有
|
|
584
589
|
if (
|
|
585
|
-
!
|
|
586
|
-
(!this.model.rootVisible && this.state.rootNodes.includes(
|
|
590
|
+
!_parent ||
|
|
591
|
+
(!this.model.rootVisible && this.state.rootNodes.includes(_parent))
|
|
587
592
|
) {
|
|
588
593
|
await this.refresh();
|
|
589
594
|
return;
|
|
590
595
|
}
|
|
591
596
|
}
|
|
592
597
|
|
|
593
|
-
const targetNode = refreshParent ? currentNode.
|
|
598
|
+
const targetNode = refreshParent ? currentNode._parent! : currentNode;
|
|
594
599
|
|
|
595
600
|
const nodes = await this.loadNodes(targetNode);
|
|
596
601
|
this._evt.emit('onAfterRefreshParent', {
|
|
@@ -609,7 +614,7 @@ export class TreeController<
|
|
|
609
614
|
|
|
610
615
|
// 找到已存在的要展开的节点
|
|
611
616
|
const existNodes = this.state.items.filter(item =>
|
|
612
|
-
noExpandKeys.includes(item.
|
|
617
|
+
noExpandKeys.includes(item._id),
|
|
613
618
|
);
|
|
614
619
|
|
|
615
620
|
// 补充所有未展开的节点标识,查询过程中会自动加载后续展开
|
|
@@ -634,7 +639,7 @@ export class TreeController<
|
|
|
634
639
|
* @return {*} {boolean}
|
|
635
640
|
*/
|
|
636
641
|
calcAllowDrag(draggingNode: ITreeNodeData): boolean {
|
|
637
|
-
const nodeModel = this.getNodeModel(draggingNode.
|
|
642
|
+
const nodeModel = this.getNodeModel(draggingNode._nodeId);
|
|
638
643
|
return nodeModel?.allowDrag === true;
|
|
639
644
|
}
|
|
640
645
|
|
|
@@ -652,30 +657,30 @@ export class TreeController<
|
|
|
652
657
|
dropNode: ITreeNodeData,
|
|
653
658
|
type: 'inner' | 'prev' | 'next',
|
|
654
659
|
): boolean {
|
|
655
|
-
const draggingNodeModel = this.getNodeModel(draggingNode.
|
|
660
|
+
const draggingNodeModel = this.getNodeModel(draggingNode._nodeId)!;
|
|
656
661
|
// * 移入的情况
|
|
657
662
|
if (type === 'inner') {
|
|
658
663
|
return !!this.findDropNodeRS(
|
|
659
|
-
dropNode.
|
|
664
|
+
dropNode._nodeId!,
|
|
660
665
|
draggingNodeModel.appDataEntityId!,
|
|
661
666
|
);
|
|
662
667
|
}
|
|
663
668
|
// * 前后的情况
|
|
664
669
|
|
|
665
670
|
// 父相同的情况下,就是排序,看当前节点是否能排序
|
|
666
|
-
if (draggingNode.
|
|
667
|
-
const currentNodeModel = this.getNodeModel(dropNode.
|
|
671
|
+
if (draggingNode._parent?._id === dropNode._parent?._id) {
|
|
672
|
+
const currentNodeModel = this.getNodeModel(dropNode._nodeId)!;
|
|
668
673
|
return currentNodeModel?.allowOrder === true;
|
|
669
674
|
}
|
|
670
675
|
|
|
671
676
|
// 没有父就是根节点,根节点没有上层关系,无法换父
|
|
672
|
-
if (!dropNode.
|
|
677
|
+
if (!dropNode._parent) {
|
|
673
678
|
return false;
|
|
674
679
|
}
|
|
675
680
|
|
|
676
681
|
// 父不一样的时候需要判断能否移入到对方的父节点内
|
|
677
682
|
return !!this.findDropNodeRS(
|
|
678
|
-
dropNode.
|
|
683
|
+
dropNode._parent!._nodeId!,
|
|
679
684
|
draggingNodeModel.appDataEntityId!,
|
|
680
685
|
);
|
|
681
686
|
}
|
|
@@ -714,31 +719,31 @@ export class TreeController<
|
|
|
714
719
|
): Promise<void> {
|
|
715
720
|
if (
|
|
716
721
|
dropType === 'inner' &&
|
|
717
|
-
!dropNode.
|
|
718
|
-
dropNode.
|
|
722
|
+
!dropNode._leaf &&
|
|
723
|
+
dropNode._children === undefined
|
|
719
724
|
) {
|
|
720
|
-
await this.expandNodeByKey([dropNode.
|
|
725
|
+
await this.expandNodeByKey([dropNode._id]);
|
|
721
726
|
}
|
|
722
727
|
|
|
723
728
|
/** 修改的树节点数据 */
|
|
724
729
|
const modifiedNodeDatas: ITreeNodeData[] = [];
|
|
725
|
-
const draggingNodeModel = this.getNodeModel(draggingNode.
|
|
726
|
-
const dropInNode = dropType === 'inner' ? dropNode : dropNode.
|
|
727
|
-
const isChangedParent = dropNode?.
|
|
728
|
-
let orderNodeModel = this.getNodeModel(dropNode.
|
|
730
|
+
const draggingNodeModel = this.getNodeModel(draggingNode._nodeId)!;
|
|
731
|
+
const dropInNode = dropType === 'inner' ? dropNode : dropNode._parent!;
|
|
732
|
+
const isChangedParent = dropNode?._id !== draggingNode._parent?._id;
|
|
733
|
+
let orderNodeModel = this.getNodeModel(dropNode._nodeId)!;
|
|
729
734
|
|
|
730
735
|
// * 处理切换父节点
|
|
731
736
|
if (
|
|
732
737
|
dropType === 'inner' ||
|
|
733
|
-
dropNode.
|
|
738
|
+
dropNode._parent?._id !== draggingNode._parent?._id
|
|
734
739
|
) {
|
|
735
740
|
const dropNodeRs = this.findDropNodeRS(
|
|
736
|
-
dropInNode.
|
|
741
|
+
dropInNode._nodeId,
|
|
737
742
|
draggingNodeModel.appDataEntityId!,
|
|
738
743
|
);
|
|
739
744
|
if (dropNodeRs) {
|
|
740
745
|
// 修改关系属性的值为父节点的主键和树节点id
|
|
741
|
-
draggingNode.
|
|
746
|
+
draggingNode._deData![dropNodeRs.pickupDEFName] = dropInNode._value;
|
|
742
747
|
modifiedNodeDatas.push(draggingNode);
|
|
743
748
|
orderNodeModel = this.getNodeModel(dropNodeRs.childDETreeNodeId)!;
|
|
744
749
|
}
|
|
@@ -746,33 +751,33 @@ export class TreeController<
|
|
|
746
751
|
|
|
747
752
|
// *修改节点数据
|
|
748
753
|
// 所有情况都先从原来的父的子集合里删除自己
|
|
749
|
-
const originArr = draggingNode.
|
|
754
|
+
const originArr = draggingNode._parent!._children!;
|
|
750
755
|
originArr.splice(originArr.indexOf(draggingNode), 1);
|
|
751
756
|
|
|
752
757
|
if (dropType === 'inner') {
|
|
753
758
|
// 移入时放到最后
|
|
754
|
-
if (!dropNode.
|
|
755
|
-
dropNode.
|
|
756
|
-
dropNode.
|
|
757
|
-
this.state.expandedKeys.push(dropNode.
|
|
759
|
+
if (!dropNode._children) {
|
|
760
|
+
dropNode._children = [];
|
|
761
|
+
dropNode._leaf = true;
|
|
762
|
+
this.state.expandedKeys.push(dropNode._id);
|
|
758
763
|
}
|
|
759
764
|
|
|
760
|
-
dropNode.
|
|
765
|
+
dropNode._children.push(draggingNode);
|
|
761
766
|
} else {
|
|
762
767
|
// 非插入时,放入指定节点前后
|
|
763
|
-
let insertIndex = dropInNode.
|
|
768
|
+
let insertIndex = dropInNode._children!.indexOf(dropNode);
|
|
764
769
|
if (dropType === 'next') {
|
|
765
770
|
insertIndex += 1;
|
|
766
771
|
}
|
|
767
|
-
dropInNode.
|
|
772
|
+
dropInNode._children!.splice(insertIndex, 0, draggingNode);
|
|
768
773
|
}
|
|
769
774
|
|
|
770
775
|
//* 变更父节点后的,拖动节点调整
|
|
771
776
|
if (dropType === 'inner' || isChangedParent) {
|
|
772
777
|
// 更改父节点
|
|
773
|
-
draggingNode.
|
|
778
|
+
draggingNode._parent = dropInNode;
|
|
774
779
|
// 修改指向的节点模型
|
|
775
|
-
draggingNode.
|
|
780
|
+
draggingNode._nodeId = orderNodeModel.id!;
|
|
776
781
|
// 维护拖拽的节点和其子孙的展开,维护拖入节点的展开
|
|
777
782
|
this.state.expandedKeys = this.calcExpandedKeys([dropInNode]);
|
|
778
783
|
}
|
|
@@ -788,7 +793,7 @@ export class TreeController<
|
|
|
788
793
|
const sortField = sortAppDEFieldId.toLowerCase();
|
|
789
794
|
const isAsc = sortDir === 'ASC';
|
|
790
795
|
|
|
791
|
-
const changedArr = [...dropInNode.
|
|
796
|
+
const changedArr = [...dropInNode._children!];
|
|
792
797
|
|
|
793
798
|
// 降序把数组反转,保证两个数组都是从小到大排
|
|
794
799
|
if (!isAsc) {
|
|
@@ -812,7 +817,7 @@ export class TreeController<
|
|
|
812
817
|
|
|
813
818
|
let lastSort: number;
|
|
814
819
|
changedArr.forEach((item, index) => {
|
|
815
|
-
const deData = item.
|
|
820
|
+
const deData = item._deData!;
|
|
816
821
|
if (lastSort === undefined) {
|
|
817
822
|
// 第一次出现要调整顺序的时候一定是从拖拽节点开始
|
|
818
823
|
if (item === draggingNode) {
|
|
@@ -821,7 +826,7 @@ export class TreeController<
|
|
|
821
826
|
lastSort = 100;
|
|
822
827
|
} else {
|
|
823
828
|
// 最后一个时,把前一个的排序值加100
|
|
824
|
-
lastSort = getNextSort(getSort(changedArr[index - 1].
|
|
829
|
+
lastSort = getNextSort(getSort(changedArr[index - 1]._deData!));
|
|
825
830
|
}
|
|
826
831
|
deData[sortField] = lastSort;
|
|
827
832
|
|
|
@@ -859,8 +864,8 @@ export class TreeController<
|
|
|
859
864
|
const app = ibiz.hub.getApp(this.context.srfappid);
|
|
860
865
|
await Promise.all(
|
|
861
866
|
nodeDatas.map(async node => {
|
|
862
|
-
const model = this.getNodeModel(node.
|
|
863
|
-
const deData = node.
|
|
867
|
+
const model = this.getNodeModel(node._nodeId)!;
|
|
868
|
+
const deData = node._deData!;
|
|
864
869
|
// 往上下文添加主键
|
|
865
870
|
const deName = calcDeCodeNameById(model.appDataEntityId!);
|
|
866
871
|
const tempContext = this.context.clone();
|
|
@@ -876,7 +881,7 @@ export class TreeController<
|
|
|
876
881
|
|
|
877
882
|
// 更新完之后更新state里的数据。
|
|
878
883
|
if (res.data) {
|
|
879
|
-
node.
|
|
884
|
+
node._deData = res.data;
|
|
880
885
|
}
|
|
881
886
|
}),
|
|
882
887
|
);
|
|
@@ -891,15 +896,15 @@ export class TreeController<
|
|
|
891
896
|
* @return {*} {Promise<void>}
|
|
892
897
|
*/
|
|
893
898
|
async modifyNodeText(nodeData: ITreeNodeData, text: string): Promise<void> {
|
|
894
|
-
const model = this.getNodeModel(nodeData.
|
|
899
|
+
const model = this.getNodeModel(nodeData._nodeId)! as IDETreeDataSetNode;
|
|
895
900
|
if (!model.allowEditText) {
|
|
896
901
|
throw new RuntimeModelError(model, '树节点没有配置编辑模式:名称');
|
|
897
902
|
}
|
|
898
|
-
if (!nodeData.
|
|
903
|
+
if (!nodeData._deData) {
|
|
899
904
|
throw new RuntimeError('不是实体树节点数据');
|
|
900
905
|
}
|
|
901
|
-
nodeData.
|
|
902
|
-
nodeData.
|
|
906
|
+
nodeData._text = text;
|
|
907
|
+
nodeData._deData[model.textAppDEFieldId!] = text;
|
|
903
908
|
await this.updateDeNodeData([nodeData]);
|
|
904
909
|
}
|
|
905
910
|
}
|
|
@@ -99,7 +99,7 @@ export class TreeService<
|
|
|
99
99
|
} else {
|
|
100
100
|
// 有父节点的计算节点关系查询对应节点数据并合并
|
|
101
101
|
const childNodeRSs = getChildNodeRSs(this.model, {
|
|
102
|
-
parentId: parentNodeData?.
|
|
102
|
+
parentId: parentNodeData?._nodeId,
|
|
103
103
|
hasQuery,
|
|
104
104
|
});
|
|
105
105
|
|
|
@@ -201,14 +201,14 @@ export class TreeService<
|
|
|
201
201
|
(expanded && // 全展开合只展开首节点expanded都为true
|
|
202
202
|
(!expandFirstOnly || (expandFirstOnly && index === 0))) ||
|
|
203
203
|
(opts.defaultExpandedKeys?.length &&
|
|
204
|
-
opts.defaultExpandedKeys.includes(childNode.
|
|
204
|
+
opts.defaultExpandedKeys.includes(childNode._id)) || // 外部回显给的默认展开节点集合有的展开
|
|
205
205
|
isExpandedRoot
|
|
206
206
|
) {
|
|
207
207
|
const subChildrenNodes = await this.fetchChildNodes(
|
|
208
208
|
childNode,
|
|
209
209
|
opts,
|
|
210
210
|
);
|
|
211
|
-
childNode.
|
|
211
|
+
childNode._children = subChildrenNodes;
|
|
212
212
|
}
|
|
213
213
|
}),
|
|
214
214
|
);
|
|
@@ -275,7 +275,7 @@ export class TreeService<
|
|
|
275
275
|
// 合并部件上下文和父节点资源上下文
|
|
276
276
|
const context = {
|
|
277
277
|
...opts.context,
|
|
278
|
-
...(parentNodeData?.
|
|
278
|
+
...(parentNodeData?._context || {}),
|
|
279
279
|
};
|
|
280
280
|
|
|
281
281
|
// 计算关系过滤用到的实体数据
|
|
@@ -285,18 +285,18 @@ export class TreeService<
|
|
|
285
285
|
if (parentNodeData) {
|
|
286
286
|
parentData = parentNodeData;
|
|
287
287
|
for (let index = 1; index < parentValueLevel!; index++) {
|
|
288
|
-
parentData = parentData?.
|
|
288
|
+
parentData = parentData?._parent;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
let derValue;
|
|
292
292
|
let deName;
|
|
293
293
|
if (parentData) {
|
|
294
|
-
data = parentData.
|
|
295
|
-
const parentNodeModel = getTreeNode(this.model, parentData.
|
|
294
|
+
data = parentData._deData || {};
|
|
295
|
+
const parentNodeModel = getTreeNode(this.model, parentData._nodeId);
|
|
296
296
|
if (parentNodeModel.appDataEntityId) {
|
|
297
297
|
deName = calcDeCodeNameById(parentNodeModel.appDataEntityId);
|
|
298
298
|
}
|
|
299
|
-
derValue = parentData.
|
|
299
|
+
derValue = parentData._value;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
// 导航相关参数处理
|