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
package/lib/tree/tmpl-tree.js
CHANGED
|
@@ -1,482 +1,342 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
//
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// loading: false,
|
|
343
|
-
// loadedKeys
|
|
344
|
-
// })
|
|
345
|
-
// }
|
|
346
|
-
//
|
|
347
|
-
// async componentWillUnmount() {
|
|
348
|
-
//
|
|
349
|
-
// }
|
|
350
|
-
//
|
|
351
|
-
// onChange = async (node?:DataNode) => {
|
|
352
|
-
// const {expandedKeys,parentNodeData,currentNodeData} = this.state;
|
|
353
|
-
// const {onPageChange}=this.props;
|
|
354
|
-
// let nood=node?node:currentNodeData;
|
|
355
|
-
// if(nood && nood['hasMenu'] && onPageChange ){
|
|
356
|
-
// onPageChange();
|
|
357
|
-
// }
|
|
358
|
-
// await this.refresh();
|
|
359
|
-
// this.setState({expandedKeys: [parentNodeData.key, ...expandedKeys]})
|
|
360
|
-
// }
|
|
361
|
-
//
|
|
362
|
-
// onExpand = (expandedKeys) => {
|
|
363
|
-
// this.setState({
|
|
364
|
-
// expandedKeys
|
|
365
|
-
// })
|
|
366
|
-
// }
|
|
367
|
-
//
|
|
368
|
-
//
|
|
369
|
-
// doSync = async (moduleCode: string) => {
|
|
370
|
-
// this.setState({
|
|
371
|
-
// loading: true,
|
|
372
|
-
// })
|
|
373
|
-
// await Hcservice.doSync(moduleCode);
|
|
374
|
-
// await this.refresh();
|
|
375
|
-
// this.setState({
|
|
376
|
-
// currentModelKey: moduleCode
|
|
377
|
-
// })
|
|
378
|
-
// }
|
|
379
|
-
//
|
|
380
|
-
// doCopy = async (code: string) => {
|
|
381
|
-
// this.setState({
|
|
382
|
-
// loading: true,
|
|
383
|
-
// })
|
|
384
|
-
// await Hcservice.doCopy(HydrogenConstant.groupTmpl.sourceId, code);
|
|
385
|
-
// await this.refresh();
|
|
386
|
-
// this.setState({
|
|
387
|
-
// currentPageKey: code
|
|
388
|
-
// })
|
|
389
|
-
// }
|
|
390
|
-
//
|
|
391
|
-
//
|
|
392
|
-
// render() {
|
|
393
|
-
// const {draggable, searchValue, onChangeSearchValue,readOnly} = this.props;
|
|
394
|
-
// const {
|
|
395
|
-
// data, loadedKeys, loading, showDraw,
|
|
396
|
-
// drawSourceId,
|
|
397
|
-
// drawCode,
|
|
398
|
-
// drawMainCode, drawTitle, currentModelKey, currentPageKey
|
|
399
|
-
// } = this.state;
|
|
400
|
-
// let treeData = data;
|
|
401
|
-
// if (searchValue) {
|
|
402
|
-
// treeData = TreeUtils.filterTree(data, searchValue);
|
|
403
|
-
// }
|
|
404
|
-
// return <>
|
|
405
|
-
// <Row>
|
|
406
|
-
// <Col span={24}>
|
|
407
|
-
// <Card style={{marginBottom: 0, width: '100%'}} bordered={false}
|
|
408
|
-
// bodyStyle={{padding: '4px 2px 4px 8px'}}>
|
|
409
|
-
// <Row align="middle">
|
|
410
|
-
// <Col span={6}>
|
|
411
|
-
// <Avatar shape="square" size={10}
|
|
412
|
-
// icon={<BlockOutlined style={{fontSize: '18px', color: '#389e0d'}}/>}
|
|
413
|
-
// style={{backgroundColor: '#fff', height: 24, width: 20, paddingLeft: '10'}}/>
|
|
414
|
-
// <span style={{fontSize: 18, fontWeight: 560}}>页面</span>
|
|
415
|
-
// </Col>
|
|
416
|
-
// <Col span={18}>
|
|
417
|
-
// <Input.Search value={searchValue} allowClear placeholder="输入名称查找" onChange={(e) => {
|
|
418
|
-
// onChangeSearchValue(e.target.value)
|
|
419
|
-
// }} onSearch={(value) => {
|
|
420
|
-
// this.refresh()
|
|
421
|
-
// }} enterButton={<ReloadOutlined />}/>
|
|
422
|
-
// </Col>
|
|
423
|
-
// </Row>
|
|
424
|
-
// </Card>
|
|
425
|
-
// </Col>
|
|
426
|
-
// </Row>
|
|
427
|
-
// <Row>
|
|
428
|
-
// <Col span={24}>
|
|
429
|
-
// {treeData && treeData.length>0 ?
|
|
430
|
-
// <Card bodyStyle={{padding: '4px 4px 4px 16px', height: '80vh', minWidth: '320px'}}
|
|
431
|
-
// loading={loading}>
|
|
432
|
-
// <Scrollbars style={{height: '80vh'}} autoHide autoHideTimeout={1000}>
|
|
433
|
-
// <Tree defaultExpandAll={true} switcherIcon={<DownOutlined/>}
|
|
434
|
-
// checkable={false}
|
|
435
|
-
// loadedKeys={loadedKeys}
|
|
436
|
-
// onExpand={this.onExpand}
|
|
437
|
-
// showLine={false}
|
|
438
|
-
// titleRender={(nodeData) => {
|
|
439
|
-
// return draggable ?
|
|
440
|
-
// <TmplGroupDragTreeNode currentActiveKey={[currentModelKey, currentPageKey]}
|
|
441
|
-
// syncButtonTip={'更新默认页面'}
|
|
442
|
-
// nodeData={nodeData}/> :
|
|
443
|
-
// <TreeNode currentActiveKey={[currentModelKey, currentPageKey]}
|
|
444
|
-
// syncButtonTip={'更新默认页面'}
|
|
445
|
-
// nodeData={nodeData}></TreeNode>
|
|
446
|
-
//
|
|
447
|
-
// }}
|
|
448
|
-
// treeData={treeData}
|
|
449
|
-
// />
|
|
450
|
-
// {/*{readOnly?null:*/}
|
|
451
|
-
// {/*<Card style={{marginTop:24}} bodyStyle={{padding: '12px 6px 6px 6px'}}>*/}
|
|
452
|
-
// {/* <Space direction="vertical">*/}
|
|
453
|
-
// {/* <Title level={5}>【页面定义】使用说明</Title>*/}
|
|
454
|
-
// {/* <span><Text*/}
|
|
455
|
-
// {/* type="danger">1.模型生成页面:</Text><Text>鼠标悬停在【模型节点】的【名称】上,点击气泡卡片的【同步默认页面】按钮。</Text></span>*/}
|
|
456
|
-
// {/* <span><Text*/}
|
|
457
|
-
// {/* type="danger">2.创建页面:</Text><Text>鼠标悬停在【模型节点】的【名称】上,点击气泡卡片的【+创建页面】按钮,填写并保存右边弹出的抽屉页面。</Text></span>*/}
|
|
458
|
-
// {/* <span><Text*/}
|
|
459
|
-
// {/* type="danger">3.复制页面:</Text><Text>鼠标悬停在【页面节点】的【名称】上,点击气泡卡片的【复制】按钮。</Text></span>*/}
|
|
460
|
-
// {/* </Space>*/}
|
|
461
|
-
// {/*</Card>}*/}
|
|
462
|
-
// </Scrollbars>
|
|
463
|
-
// </Card>: <Card><Space><Text type={'danger'}>* 页面配置需基于模型。请先创建一个或多个模型。</Text>
|
|
464
|
-
// <Button href={'#/application-workbench/carbon-model-def'} type={'primary'}><DeploymentUnitOutlined />模 型</Button></Space>
|
|
465
|
-
// </Card>}
|
|
466
|
-
// </Col>
|
|
467
|
-
// </Row>
|
|
468
|
-
//
|
|
469
|
-
// {drawSourceId ? <DtmplEditPage title={drawTitle} maxColsOnRow={1} pageType={"drawer"} placement={'right'}
|
|
470
|
-
// open={showDraw}
|
|
471
|
-
// onCancel={this.doClose}
|
|
472
|
-
// width={640} mainCode={drawMainCode}
|
|
473
|
-
// sourceId={drawSourceId}
|
|
474
|
-
// code={drawCode}
|
|
475
|
-
// onOk={this.drawSubmited}/> : null}
|
|
476
|
-
//
|
|
477
|
-
// </>
|
|
478
|
-
// }
|
|
479
|
-
// }
|
|
480
|
-
//
|
|
481
|
-
// export default TmplTree
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { Button, Card, Col, Input, Popconfirm, Popover, Row, Space, Tooltip, Tree, Typography } from 'antd';
|
|
12
|
+
import { AlignLeftOutlined, DeleteOutlined, EditOutlined, PlusOutlined, PlusSquareOutlined, ReloadOutlined } from '@ant-design/icons';
|
|
13
|
+
// import './index.css';
|
|
14
|
+
import Scrollbars from 'react-custom-scrollbars';
|
|
15
|
+
import { HydrocarbonService } from "../index";
|
|
16
|
+
import TreeUtils from "./tree-utils";
|
|
17
|
+
const { Text, Title } = Typography;
|
|
18
|
+
class TmplTree extends React.PureComponent {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.state = {
|
|
22
|
+
data: [],
|
|
23
|
+
expandedKeys: [],
|
|
24
|
+
loadedKeys: [],
|
|
25
|
+
loading: false,
|
|
26
|
+
currentEditKey: undefined,
|
|
27
|
+
parentNodeData: undefined,
|
|
28
|
+
currentNodeData: undefined,
|
|
29
|
+
rootAddable: false,
|
|
30
|
+
searchValue: undefined,
|
|
31
|
+
};
|
|
32
|
+
this.doDelete = (node) => __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
let { ttmplNodeConfig } = this.props;
|
|
34
|
+
let sourceId;
|
|
35
|
+
if (node.isLeaf) {
|
|
36
|
+
sourceId = ttmplNodeConfig.leafRatmplId;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
sourceId = ttmplNodeConfig.branchRatmplId;
|
|
40
|
+
}
|
|
41
|
+
let res = yield HydrocarbonService.deleteByCode(null, sourceId, [node.code]);
|
|
42
|
+
if (node.parent) {
|
|
43
|
+
yield this.reloadData(node.parent.code);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
this.loadRootNodeData = () => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const { ttmplNodeConfig } = this.props;
|
|
48
|
+
let data = yield TreeUtils.loadRootNodeData(ttmplNodeConfig);
|
|
49
|
+
return data;
|
|
50
|
+
});
|
|
51
|
+
this.onExpand = (expandedKeys, current) => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const { ttmplNodeConfig } = this.props;
|
|
53
|
+
const { data } = this.state;
|
|
54
|
+
if (current.expanded) {
|
|
55
|
+
yield TreeUtils.pushSameCodeNodeData([current.node], ttmplNodeConfig);
|
|
56
|
+
}
|
|
57
|
+
this.setState({
|
|
58
|
+
data: [...data],
|
|
59
|
+
expandedKeys
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
this.onClickNode = (dataNode) => {
|
|
63
|
+
const { doEditRoot, doViewRoot, doViewSub, doEditSub, ttmplNodeConfig } = this.props;
|
|
64
|
+
if (dataNode.parent) { //说明是sub
|
|
65
|
+
if (dataNode.isLeaf) {
|
|
66
|
+
if (ttmplNodeConfig.leafLTmplConfig.buttons.indexOf("dtmplEdit") > 0) {
|
|
67
|
+
doEditSub(ttmplNodeConfig.leafTitle, ttmplNodeConfig.leafRatmplId, dataNode.parent.code, dataNode.code);
|
|
68
|
+
}
|
|
69
|
+
else if (ttmplNodeConfig.leafLTmplConfig.buttons.indexOf("detail") > 0) {
|
|
70
|
+
doViewSub(ttmplNodeConfig.leafTitle, ttmplNodeConfig.leafRatmplId, dataNode.parent.code, dataNode.code);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
if (ttmplNodeConfig.branchLTmplConfig.buttons.indexOf("dtmplEdit") > 0) {
|
|
75
|
+
doEditSub(ttmplNodeConfig.branchTitle, ttmplNodeConfig.branchRatmplId, dataNode.parent.code, dataNode.code);
|
|
76
|
+
}
|
|
77
|
+
else if (ttmplNodeConfig.branchLTmplConfig.buttons.indexOf("detail") > 0) {
|
|
78
|
+
doViewSub(ttmplNodeConfig.branchTitle, ttmplNodeConfig.branchRatmplId, dataNode.parent.code, dataNode.code);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else { //说明是root
|
|
83
|
+
//判断是否允许编辑
|
|
84
|
+
if (ttmplNodeConfig.rootLTmplConfig.buttons.indexOf("dtmplEdit") > 0) {
|
|
85
|
+
doEditRoot(ttmplNodeConfig.branchTitle, dataNode.code);
|
|
86
|
+
}
|
|
87
|
+
else if (ttmplNodeConfig.rootLTmplConfig.buttons.indexOf("detail") > 0) {
|
|
88
|
+
doViewRoot(ttmplNodeConfig.branchTitle, dataNode.code);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
this.stopPropagation = (e) => {
|
|
93
|
+
if (e.stopPropagation) { //如果提供了事件对象,则这是一个非IE浏览器
|
|
94
|
+
e.stopPropagation();
|
|
95
|
+
}
|
|
96
|
+
else { //兼容IE的方式来取消事件冒泡
|
|
97
|
+
window.event.cancelBubble = true;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
this.reloadData = (branchCode) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const { ttmplNodeConfig } = this.props;
|
|
102
|
+
const { data, expandedKeys } = this.state;
|
|
103
|
+
let newData;
|
|
104
|
+
if (branchCode == null) { //加载根
|
|
105
|
+
newData = yield this.loadRootNodeData();
|
|
106
|
+
this.mergeRootData(data, newData);
|
|
107
|
+
this.setState({
|
|
108
|
+
data: newData
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else { //重新加载 await
|
|
112
|
+
//先找到树节点
|
|
113
|
+
let rdatas = [];
|
|
114
|
+
this.searchNode(data, branchCode, rdatas);
|
|
115
|
+
yield TreeUtils.pushSameCodeNodeData(rdatas, ttmplNodeConfig);
|
|
116
|
+
let newExpandeds = [];
|
|
117
|
+
for (let d of rdatas) {
|
|
118
|
+
newExpandeds.push(d.key);
|
|
119
|
+
}
|
|
120
|
+
this.setState({
|
|
121
|
+
expandedKeys: [...expandedKeys, ...newExpandeds],
|
|
122
|
+
data: [...data]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
this.mergeRootData = (data, newData) => {
|
|
127
|
+
if (newData && data) {
|
|
128
|
+
for (let nd of newData) {
|
|
129
|
+
for (let d of data) {
|
|
130
|
+
if (nd.code == d.code) {
|
|
131
|
+
nd.children = d.children;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
this.searchNode = (data, brachCode, result) => {
|
|
139
|
+
if (!data) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
for (let d of data) {
|
|
143
|
+
if (d.code == brachCode) {
|
|
144
|
+
result.push(d);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
else if (d.children.length > 0) { //继续寻找
|
|
148
|
+
this.searchNode(d.children, brachCode, result);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
this.getDeleteButton = (sourceId, code) => {
|
|
153
|
+
const { doDelete } = this.props;
|
|
154
|
+
return React.createElement("div", { onClick: (e) => {
|
|
155
|
+
this.stopPropagation(e);
|
|
156
|
+
} },
|
|
157
|
+
React.createElement(Popconfirm, { placement: "topLeft", title: `确定要删除吗?`, onConfirm: () => {
|
|
158
|
+
doDelete(sourceId, code);
|
|
159
|
+
}, okText: "\u786E\u5B9A", cancelText: "\u53D6\u6D88" },
|
|
160
|
+
React.createElement(Tooltip, null,
|
|
161
|
+
React.createElement(Button, { size: 'small', danger: true },
|
|
162
|
+
React.createElement(DeleteOutlined, null)))));
|
|
163
|
+
};
|
|
164
|
+
this.getAddButton = (title, icon, ratmplId, mainCode) => {
|
|
165
|
+
const { doAddSub } = this.props;
|
|
166
|
+
return React.createElement(Button, { onClick: (e) => {
|
|
167
|
+
this.stopPropagation(e);
|
|
168
|
+
doAddSub(title, ratmplId, mainCode);
|
|
169
|
+
}, size: 'small' },
|
|
170
|
+
icon,
|
|
171
|
+
title);
|
|
172
|
+
};
|
|
173
|
+
this.packageTitle = (dataNode) => {
|
|
174
|
+
const { doEditRoot, doViewRoot, doViewSub, doEditSub, ttmplNodeConfig } = this.props;
|
|
175
|
+
let buttons = [];
|
|
176
|
+
if (dataNode.parent) { //说明是sub
|
|
177
|
+
if (dataNode.isLeaf) {
|
|
178
|
+
if (ttmplNodeConfig.leafLTmplConfig.buttons.indexOf("dtmplEdit") > 0) {
|
|
179
|
+
buttons.push(React.createElement(Button, { onClick: (e) => {
|
|
180
|
+
this.stopPropagation(e);
|
|
181
|
+
doEditSub(ttmplNodeConfig.leafTitle, ttmplNodeConfig.leafRatmplId, dataNode.parent.code, dataNode.code);
|
|
182
|
+
}, size: 'small' },
|
|
183
|
+
React.createElement(EditOutlined, null),
|
|
184
|
+
"\u7F16\u8F91"));
|
|
185
|
+
}
|
|
186
|
+
if (ttmplNodeConfig.leafLTmplConfig.buttons.indexOf("detail") > 0) {
|
|
187
|
+
buttons.push(React.createElement(Button, { onClick: (e) => {
|
|
188
|
+
this.stopPropagation(e);
|
|
189
|
+
doViewSub(ttmplNodeConfig.leafTitle, ttmplNodeConfig.leafRatmplId, dataNode.parent.code, dataNode.code);
|
|
190
|
+
}, size: 'small' },
|
|
191
|
+
React.createElement(AlignLeftOutlined, null),
|
|
192
|
+
"\u67E5\u770B"));
|
|
193
|
+
}
|
|
194
|
+
if (ttmplNodeConfig.leafLTmplConfig.buttons.indexOf("singleDelete") > 0) {
|
|
195
|
+
buttons.push(this.getDeleteButton(ttmplNodeConfig.leafRatmplId, dataNode.code));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (ttmplNodeConfig.branchLTmplConfig) {
|
|
199
|
+
if (ttmplNodeConfig.branchLTmplConfig.buttons.indexOf("dtmplEdit") > 0) {
|
|
200
|
+
buttons.push(React.createElement(Button, { onClick: (e) => {
|
|
201
|
+
this.stopPropagation(e);
|
|
202
|
+
doEditSub(ttmplNodeConfig.branchTitle, ttmplNodeConfig.branchRatmplId, dataNode.parent.code, dataNode.code);
|
|
203
|
+
}, size: 'small' },
|
|
204
|
+
React.createElement(EditOutlined, null),
|
|
205
|
+
"\u7F16\u8F91"));
|
|
206
|
+
}
|
|
207
|
+
if (ttmplNodeConfig.branchLTmplConfig.buttons.indexOf("detail") > 0) {
|
|
208
|
+
buttons.push(React.createElement(Button, { onClick: (e) => {
|
|
209
|
+
this.stopPropagation(e);
|
|
210
|
+
doViewSub(ttmplNodeConfig.branchTitle, ttmplNodeConfig.branchRatmplId, dataNode.parent.code, dataNode.code);
|
|
211
|
+
}, size: 'small' },
|
|
212
|
+
React.createElement(AlignLeftOutlined, null),
|
|
213
|
+
"\u67E5\u770B"));
|
|
214
|
+
}
|
|
215
|
+
if (ttmplNodeConfig.branchLTmplConfig.buttons.indexOf("dtmplAdd") > 0) {
|
|
216
|
+
buttons.push(this.getAddButton(ttmplNodeConfig.branchTitle, React.createElement(PlusSquareOutlined, null), ttmplNodeConfig.branchRatmplId, dataNode.code));
|
|
217
|
+
}
|
|
218
|
+
if (ttmplNodeConfig.leafLTmplConfig.buttons.indexOf("dtmplAdd") > 0) {
|
|
219
|
+
buttons.push(this.getAddButton(ttmplNodeConfig.leafTitle, React.createElement(PlusOutlined, null), ttmplNodeConfig.leafRatmplId, dataNode.code));
|
|
220
|
+
}
|
|
221
|
+
if (ttmplNodeConfig.branchLTmplConfig.buttons.indexOf("singleDelete") > 0) {
|
|
222
|
+
buttons.push(this.getDeleteButton(ttmplNodeConfig.branchRatmplId, dataNode.code));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else { //说明是root
|
|
227
|
+
//判断是否允许编辑
|
|
228
|
+
if (ttmplNodeConfig.rootLTmplConfig.buttons.indexOf("dtmplEdit") > 0) {
|
|
229
|
+
buttons.push(React.createElement(Button, { onClick: (e) => {
|
|
230
|
+
this.stopPropagation(e);
|
|
231
|
+
doEditRoot(ttmplNodeConfig.branchTitle, dataNode.code);
|
|
232
|
+
}, size: 'small' },
|
|
233
|
+
React.createElement(EditOutlined, { style: { color: 'blue' } }),
|
|
234
|
+
"\u7F16\u8F91"));
|
|
235
|
+
}
|
|
236
|
+
if (ttmplNodeConfig.rootLTmplConfig.buttons.indexOf("detail") > 0) {
|
|
237
|
+
buttons.push(React.createElement(Button, { onClick: (e) => {
|
|
238
|
+
this.stopPropagation(e);
|
|
239
|
+
doViewRoot(ttmplNodeConfig.branchTitle, dataNode.code);
|
|
240
|
+
}, size: 'small' },
|
|
241
|
+
React.createElement(AlignLeftOutlined, null),
|
|
242
|
+
"\u67E5\u770B"));
|
|
243
|
+
}
|
|
244
|
+
if (ttmplNodeConfig.branchLTmplConfig) {
|
|
245
|
+
if (ttmplNodeConfig.rootLTmplConfig.buttons.indexOf("dtmplAdd") > 0) {
|
|
246
|
+
buttons.push(this.getAddButton(ttmplNodeConfig.branchTitle, React.createElement(PlusSquareOutlined, null), ttmplNodeConfig.branchRatmplId, dataNode.code));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (ttmplNodeConfig.leafLTmplConfig.buttons.indexOf("dtmplAdd") > 0) {
|
|
250
|
+
buttons.push(this.getAddButton(ttmplNodeConfig.leafTitle, React.createElement(PlusOutlined, null), ttmplNodeConfig.leafRatmplId, dataNode.code));
|
|
251
|
+
}
|
|
252
|
+
if (ttmplNodeConfig.rootLTmplConfig.buttons.indexOf("singleDelete") > 0) {
|
|
253
|
+
buttons.push(this.getDeleteButton(ttmplNodeConfig.branchRatmplId, dataNode.code));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (buttons.length == 0) {
|
|
257
|
+
return dataNode.title;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
return React.createElement(Popover, { zIndex: 100, content: React.createElement(React.Fragment, null,
|
|
261
|
+
React.createElement(Space, null, buttons)), arrow: false }, dataNode.title);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
componentDidMount() {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
yield this.refresh();
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
componentDidUpdate(prevProps) {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
debugger;
|
|
273
|
+
let { ttmplNodeConfig: preTtmplNodeConfig } = prevProps;
|
|
274
|
+
let { ttmplNodeConfig } = this.props;
|
|
275
|
+
debugger;
|
|
276
|
+
if (!ttmplNodeConfig || (preTtmplNodeConfig && ttmplNodeConfig.id == preTtmplNodeConfig.id)) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
yield this.refresh();
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
refresh() {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
+
debugger;
|
|
285
|
+
const { ttmplNodeConfig } = this.props;
|
|
286
|
+
if (!ttmplNodeConfig) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
this.setState({
|
|
290
|
+
loading: true,
|
|
291
|
+
});
|
|
292
|
+
//let loadedKeys = [];
|
|
293
|
+
let data = yield this.loadRootNodeData();
|
|
294
|
+
this.setState({
|
|
295
|
+
searchValue: null,
|
|
296
|
+
data,
|
|
297
|
+
rootAddable: ttmplNodeConfig.rootLTmplConfig.buttons.indexOf("dtmplAdd") > 0,
|
|
298
|
+
loading: false,
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
componentWillUnmount() {
|
|
303
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
render() {
|
|
307
|
+
const { doEditRoot, ttmplNodeConfig } = this.props;
|
|
308
|
+
const { data, loading, expandedKeys, rootAddable, searchValue } = this.state;
|
|
309
|
+
let treeData = data;
|
|
310
|
+
if (searchValue) {
|
|
311
|
+
treeData = TreeUtils.filterTree(data, searchValue);
|
|
312
|
+
}
|
|
313
|
+
return React.createElement(React.Fragment, null,
|
|
314
|
+
React.createElement(Row, null,
|
|
315
|
+
React.createElement(Col, { span: 24 },
|
|
316
|
+
React.createElement(Card, { style: { marginBottom: 0, width: '100%' }, bordered: false, bodyStyle: { padding: '4px 2px 4px 8px' } },
|
|
317
|
+
React.createElement(Row, { align: "middle" },
|
|
318
|
+
React.createElement(Col, { span: 8 }, rootAddable && doEditRoot ?
|
|
319
|
+
React.createElement(Button, { type: 'link', onClick: () => doEditRoot(ttmplNodeConfig.branchTitle) }, "\u6DFB\u52A0") : null),
|
|
320
|
+
React.createElement(Col, { span: 16 },
|
|
321
|
+
React.createElement(Input.Search, { value: searchValue, allowClear: true, placeholder: "\u8F93\u5165\u67E5\u627E\u5185\u5BB9", onChange: (e) => {
|
|
322
|
+
this.setState({
|
|
323
|
+
searchValue: e.target.value
|
|
324
|
+
});
|
|
325
|
+
}, onSearch: (value) => {
|
|
326
|
+
this.refresh();
|
|
327
|
+
}, enterButton: React.createElement(ReloadOutlined, null) })))))),
|
|
328
|
+
React.createElement(Row, null,
|
|
329
|
+
React.createElement(Col, { span: 24 },
|
|
330
|
+
React.createElement(Card, { bodyStyle: { padding: '4px 4px 4px 16px', height: '80vh', minWidth: '320px' }, loading: loading }, treeData.length == 0 ? '没有找到数据' :
|
|
331
|
+
React.createElement(Scrollbars, { style: { height: '80vh' }, autoHide: true, autoHideTimeout: 1000 },
|
|
332
|
+
React.createElement(Tree, { blockNode: true, checkable: false, expandedKeys: expandedKeys, onExpand: this.onExpand, titleRender: (nodeData) => {
|
|
333
|
+
return React.createElement("div", { onClick: () => this.onClickNode(nodeData) }, this.packageTitle(nodeData));
|
|
334
|
+
}, treeData: treeData }))))));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
TmplTree.defaultProps = {
|
|
338
|
+
draggable: false,
|
|
339
|
+
readOnly: false
|
|
340
|
+
};
|
|
341
|
+
export default TmplTree;
|
|
482
342
|
//# sourceMappingURL=tmpl-tree.js.map
|