aldehyde 0.2.74 → 0.2.76
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/lib/controls/action/index.d.ts.map +1 -1
- package/lib/controls/action/index.js.map +1 -1
- package/lib/controls/action/utils.d.ts.map +1 -1
- package/lib/controls/action/utils.js +13 -20
- package/lib/controls/action/utils.js.map +1 -1
- package/lib/custom-page/custom-page-router.d.ts.map +1 -1
- package/lib/custom-page/custom-page-router.js +0 -1
- package/lib/custom-page/custom-page-router.js.map +1 -1
- package/lib/form/dtmpl-form.d.ts.map +1 -1
- package/lib/form/dtmpl-form.js.map +1 -1
- package/lib/import/excel-import.d.ts.map +1 -1
- package/lib/import/excel-import.js +45 -37
- package/lib/import/excel-import.js.map +1 -1
- package/lib/module/dtmpl-view-card.js +1 -1
- package/lib/module/dtmpl-view-card.js.map +1 -1
- package/lib/routable/ttmpl-route.d.ts +2 -4
- package/lib/routable/ttmpl-route.d.ts.map +1 -1
- package/lib/routable/ttmpl-route.js +20 -128
- package/lib/routable/ttmpl-route.js.map +1 -1
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/query-table.js +1 -1
- package/lib/table/query-table.js.map +1 -1
- package/lib/tmpl/hc-data-source.d.ts +2 -1
- package/lib/tmpl/hc-data-source.d.ts.map +1 -1
- package/lib/tmpl/hc-data-source.js +11 -0
- package/lib/tmpl/hc-data-source.js.map +1 -1
- package/lib/tmpl/hcservice-v3.d.ts +2 -0
- package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
- package/lib/tmpl/hcservice-v3.js +30 -7
- package/lib/tmpl/hcservice-v3.js.map +1 -1
- package/lib/tmpl/interface.d.ts +13 -5
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tmpl/interface.js.map +1 -1
- package/lib/tree/act-tree.d.ts +40 -0
- package/lib/tree/act-tree.d.ts.map +1 -1
- package/lib/tree/act-tree.js +119 -112
- package/lib/tree/act-tree.js.map +1 -1
- package/lib/tree/index.css +21 -0
- package/lib/tree/tmpl-tree.d.ts +61 -0
- package/lib/tree/tmpl-tree.d.ts.map +1 -1
- package/lib/tree/tmpl-tree.js +341 -481
- package/lib/tree/tmpl-tree.js.map +1 -1
- package/lib/tree/tree-node.d.ts +22 -0
- package/lib/tree/tree-node.d.ts.map +1 -0
- package/lib/tree/tree-node.js +62 -0
- package/lib/tree/tree-node.js.map +1 -0
- package/lib/tree/tree-utils.d.ts +55 -0
- package/lib/tree/tree-utils.d.ts.map +1 -0
- package/lib/tree/tree-utils.js +142 -0
- package/lib/tree/tree-utils.js.map +1 -0
- package/package.json +1 -1
- package/src/aldehyde/controls/action/index.tsx +1 -0
- package/src/aldehyde/controls/action/utils.tsx +14 -20
- package/src/aldehyde/custom-page/custom-page-router.tsx +0 -1
- package/src/aldehyde/form/dtmpl-form.tsx +0 -1
- package/src/aldehyde/import/excel-import.tsx +42 -35
- package/src/aldehyde/module/dtmpl-view-card.tsx +1 -1
- package/src/aldehyde/routable/ttmpl-route.tsx +24 -154
- package/src/aldehyde/table/act-table.tsx +1 -0
- package/src/aldehyde/table/query-table.tsx +1 -1
- package/src/aldehyde/tmpl/hc-data-source.tsx +11 -1
- package/src/aldehyde/tmpl/hcservice-v3.tsx +29 -7
- package/src/aldehyde/tmpl/interface.tsx +14 -5
- package/src/aldehyde/tree/act-tree.tsx +149 -111
- package/src/aldehyde/tree/index.css +21 -0
- package/src/aldehyde/tree/tmpl-tree.tsx +397 -480
- package/src/aldehyde/tree/tree-node.tsx +78 -0
- package/src/aldehyde/tree/tree-utils.tsx +166 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {Avatar, Card, Col, message, Row, Space,Badge} from 'antd'
|
|
3
|
+
import {} from '@ant-design/icons'
|
|
4
|
+
import {TreeDataNode} from "./tree-utils";
|
|
5
|
+
import {OrderableTmplBase} from "../tmpl/interface";
|
|
6
|
+
export interface TreeNodeProps {
|
|
7
|
+
currentActiveKey?:(string|number)[],
|
|
8
|
+
nodeData: TreeDataNode,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface TreeNodeState {
|
|
12
|
+
sorts: Array<OrderableTmplBase>,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const treeCardTitleBody0 = {
|
|
16
|
+
padding: '4px 4px 4px 4px',
|
|
17
|
+
maxWidth: '300px',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const buttonIcon={color:'#597ef7'}
|
|
22
|
+
|
|
23
|
+
class TreeNode extends React.PureComponent<TreeNodeProps, TreeNodeState> {
|
|
24
|
+
state = {
|
|
25
|
+
sorts: [],
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async componentDidMount() {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async componentDidUpdate(preProps) {
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async componentWillUnmount() {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onDelete = async (nodeData:TreeDataNode) => {
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
const {nodeData,currentActiveKey} = this.props;
|
|
46
|
+
const {sorts} = this.state;
|
|
47
|
+
let backgroundColor = '#fff';
|
|
48
|
+
let avatarBackgroundColor = '#fff';
|
|
49
|
+
let bodyCss = treeCardTitleBody0;
|
|
50
|
+
if (nodeData.level == 0) {
|
|
51
|
+
avatarBackgroundColor = '#fff';
|
|
52
|
+
bodyCss = treeCardTitleBody0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
return <Card bordered={nodeData.level==2?false:false} bodyStyle={bodyCss} style={{marginBottom:2,backgroundColor}} className={'tree-node'}>
|
|
59
|
+
<Row>
|
|
60
|
+
<Col span={24}>
|
|
61
|
+
<Space>
|
|
62
|
+
{nodeData.avatar ? nodeData.avatar : <Avatar shape="square" size={10} style={{
|
|
63
|
+
backgroundColor: avatarBackgroundColor,
|
|
64
|
+
height: 24,
|
|
65
|
+
width: 10
|
|
66
|
+
}}></Avatar>}{nodeData.title}{
|
|
67
|
+
currentActiveKey && currentActiveKey.indexOf(nodeData.key) >= 0 ?<Badge key={"red"} color={'red'} />:null
|
|
68
|
+
}
|
|
69
|
+
</Space>
|
|
70
|
+
</Col>
|
|
71
|
+
</Row>
|
|
72
|
+
|
|
73
|
+
</Card>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default TreeNode
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {DataNode} from "antd/es/tree";
|
|
3
|
+
import {HydrocarbonService} from "../index";
|
|
4
|
+
import {DtmplData, LtmplConfig, LtmplConfigRes, TtmplConfig} from "../tmpl/interface";
|
|
5
|
+
import HCDataSource from "../tmpl/hc-data-source";
|
|
6
|
+
|
|
7
|
+
export interface TtmplNodeConfig extends TtmplConfig{
|
|
8
|
+
leafTitleId?:string,
|
|
9
|
+
branchTitleId?:string,
|
|
10
|
+
rootTitleId?:string,
|
|
11
|
+
rootLTmplConfig?:LtmplConfig,
|
|
12
|
+
branchLTmplConfig?:LtmplConfig,
|
|
13
|
+
leafLTmplConfig?:LtmplConfig,
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface TreeDataNode extends DataNode{
|
|
18
|
+
parent:TreeDataNode,
|
|
19
|
+
code:string,
|
|
20
|
+
name:string,
|
|
21
|
+
avatar:any,
|
|
22
|
+
level:number,
|
|
23
|
+
children:any,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default class TreeUtils {
|
|
27
|
+
|
|
28
|
+
static initTtmplNodeConfig = async (config: TtmplConfig) => {
|
|
29
|
+
|
|
30
|
+
if(!config){
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
let ttmplNodeConfig:TtmplNodeConfig={...config}
|
|
34
|
+
if(ttmplNodeConfig.rootGtmplId){
|
|
35
|
+
let res:LtmplConfigRes =await HCDataSource.requestLtmplConfig(null,ttmplNodeConfig.rootGtmplId);
|
|
36
|
+
let rootLTmplConfig: LtmplConfig=res.ltmplConfig;
|
|
37
|
+
ttmplNodeConfig.rootLTmplConfig=rootLTmplConfig;
|
|
38
|
+
ttmplNodeConfig.rootTitleId=rootLTmplConfig.primaryColumn.id;
|
|
39
|
+
}
|
|
40
|
+
if(ttmplNodeConfig.branchRatmplId){
|
|
41
|
+
let res:LtmplConfigRes =await HCDataSource.requestLtmplConfig(null,ttmplNodeConfig.branchRatmplId);
|
|
42
|
+
let branchLTmplConfig: LtmplConfig=res.ltmplConfig;
|
|
43
|
+
ttmplNodeConfig.branchLTmplConfig=branchLTmplConfig;
|
|
44
|
+
ttmplNodeConfig.branchTitleId=branchLTmplConfig.primaryColumn.id;
|
|
45
|
+
}
|
|
46
|
+
if(ttmplNodeConfig.leafRatmplId){
|
|
47
|
+
let res:LtmplConfigRes =await HCDataSource.requestLtmplConfig(null,ttmplNodeConfig.leafRatmplId);
|
|
48
|
+
let leafLTmplConfig: LtmplConfig =res.ltmplConfig;
|
|
49
|
+
ttmplNodeConfig.leafLTmplConfig=leafLTmplConfig;
|
|
50
|
+
ttmplNodeConfig.leafTitleId=leafLTmplConfig.primaryColumn.id;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return ttmplNodeConfig;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static loadRootNodeData = async (config: TtmplNodeConfig) => {
|
|
57
|
+
let res = await HydrocarbonService.requestTtmplRootData(null, config.id, {});
|
|
58
|
+
let data = [];
|
|
59
|
+
//组织data
|
|
60
|
+
if (res.entities) {
|
|
61
|
+
res.entities.forEach((item, index) => {
|
|
62
|
+
data.push(this.toTreeNodeData(item,config.rootTitleId,null,false));
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static pushNodeData = (parentNode: TreeDataNode, config: TtmplNodeConfig,brancEntities:any[],leafEntities:any[]) => {
|
|
69
|
+
//先查询branch
|
|
70
|
+
parentNode.children.splice(0,parentNode.children.length);
|
|
71
|
+
if (brancEntities) {
|
|
72
|
+
brancEntities.forEach((item, index) => {
|
|
73
|
+
parentNode.children.push(this.toBanchTreeNodeData(item, config, parentNode));
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
//debugger
|
|
77
|
+
//再查询leaf
|
|
78
|
+
if (leafEntities) {
|
|
79
|
+
leafEntities.forEach((item, index) => {
|
|
80
|
+
parentNode.children.push(this.toLeafTreeNodeData(item, config, parentNode));
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static pushSameCodeNodeData = async (parentNodes: TreeDataNode[], config: TtmplNodeConfig) => {
|
|
87
|
+
if (parentNodes.length > 0) {
|
|
88
|
+
//先查询branch
|
|
89
|
+
let brancEntities: any[];
|
|
90
|
+
if(config.branchRatmplId){
|
|
91
|
+
let res = await HydrocarbonService.requestLtmplQueryTop(null, config.branchRatmplId, {mainCode: parentNodes[0].code});
|
|
92
|
+
brancEntities = res.entities;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let res1 = await HydrocarbonService.requestLtmplQueryTop(null, config.leafRatmplId, {mainCode: parentNodes[0].code});
|
|
96
|
+
let leafEntities: any[] = res1.entities;
|
|
97
|
+
for(let parentNode of parentNodes){
|
|
98
|
+
this.pushNodeData(parentNode, config,brancEntities,leafEntities);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
static toLeafTreeNodeData = (item: DtmplData,config:TtmplNodeConfig, parent: TreeDataNode) => {
|
|
105
|
+
let d= this.toTreeNodeData(item,config.leafTitleId,parent,true);
|
|
106
|
+
return d;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static toBanchTreeNodeData = (item: DtmplData,config:TtmplNodeConfig, parent: TreeDataNode) => {
|
|
110
|
+
let d= this.toTreeNodeData(item,config.branchTitleId,parent,false);
|
|
111
|
+
return d;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static toTreeNodeData = (item: DtmplData,titleId:string, parent: TreeDataNode,isLeaf:boolean) => {
|
|
115
|
+
let name = item.fieldMap[titleId];
|
|
116
|
+
let d = {
|
|
117
|
+
code: item.code,
|
|
118
|
+
key: parent?.code+item.code,
|
|
119
|
+
name,
|
|
120
|
+
title: <><span>{name?name:item.code}</span></>,
|
|
121
|
+
children: [],
|
|
122
|
+
isLeaf,
|
|
123
|
+
parent,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return d;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
static filterNode = (node, searchValue: string) => {
|
|
130
|
+
let children = [...node.children];
|
|
131
|
+
let newNodes: TreeDataNode[] = [];
|
|
132
|
+
let tagNodes: TreeDataNode[] = [];
|
|
133
|
+
|
|
134
|
+
children.forEach((no) => {
|
|
135
|
+
let n = {...no};
|
|
136
|
+
let v=n.searchValue?n.searchValue:n.name;
|
|
137
|
+
if (v.indexOf(searchValue) >= 0) {
|
|
138
|
+
newNodes.push(n);
|
|
139
|
+
}
|
|
140
|
+
if (n.children && n.children.length > 0) {
|
|
141
|
+
let retNodes: TreeDataNode[] = this.filterNode(n, searchValue);
|
|
142
|
+
if (retNodes.length > 0) {
|
|
143
|
+
n.children = retNodes;
|
|
144
|
+
//补充父没有的
|
|
145
|
+
if ((n.searchValue?n.searchValue:n.name).indexOf(searchValue) < 0) {
|
|
146
|
+
newNodes.push(n);
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
// 没有子节点情况
|
|
150
|
+
n.children = [];
|
|
151
|
+
// 标记,循环结束后删除
|
|
152
|
+
tagNodes.push(n);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
node.children = newNodes;
|
|
157
|
+
return newNodes;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static filterTree = (nodes: any[], searchValue: string) => {
|
|
161
|
+
let root = {code: "", config: undefined, key: undefined, children: [...nodes]};
|
|
162
|
+
this.filterNode(root, searchValue);
|
|
163
|
+
return root.children;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
}
|