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.
Files changed (69) hide show
  1. package/lib/controls/action/index.d.ts.map +1 -1
  2. package/lib/controls/action/index.js.map +1 -1
  3. package/lib/controls/action/utils.d.ts.map +1 -1
  4. package/lib/controls/action/utils.js +13 -20
  5. package/lib/controls/action/utils.js.map +1 -1
  6. package/lib/custom-page/custom-page-router.d.ts.map +1 -1
  7. package/lib/custom-page/custom-page-router.js +0 -1
  8. package/lib/custom-page/custom-page-router.js.map +1 -1
  9. package/lib/form/dtmpl-form.d.ts.map +1 -1
  10. package/lib/form/dtmpl-form.js.map +1 -1
  11. package/lib/import/excel-import.d.ts.map +1 -1
  12. package/lib/import/excel-import.js +45 -37
  13. package/lib/import/excel-import.js.map +1 -1
  14. package/lib/module/dtmpl-view-card.js +1 -1
  15. package/lib/module/dtmpl-view-card.js.map +1 -1
  16. package/lib/routable/ttmpl-route.d.ts +2 -4
  17. package/lib/routable/ttmpl-route.d.ts.map +1 -1
  18. package/lib/routable/ttmpl-route.js +20 -128
  19. package/lib/routable/ttmpl-route.js.map +1 -1
  20. package/lib/table/act-table.d.ts.map +1 -1
  21. package/lib/table/act-table.js.map +1 -1
  22. package/lib/table/query-table.js +1 -1
  23. package/lib/table/query-table.js.map +1 -1
  24. package/lib/tmpl/hc-data-source.d.ts +2 -1
  25. package/lib/tmpl/hc-data-source.d.ts.map +1 -1
  26. package/lib/tmpl/hc-data-source.js +11 -0
  27. package/lib/tmpl/hc-data-source.js.map +1 -1
  28. package/lib/tmpl/hcservice-v3.d.ts +2 -0
  29. package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
  30. package/lib/tmpl/hcservice-v3.js +30 -7
  31. package/lib/tmpl/hcservice-v3.js.map +1 -1
  32. package/lib/tmpl/interface.d.ts +13 -5
  33. package/lib/tmpl/interface.d.ts.map +1 -1
  34. package/lib/tmpl/interface.js.map +1 -1
  35. package/lib/tree/act-tree.d.ts +40 -0
  36. package/lib/tree/act-tree.d.ts.map +1 -1
  37. package/lib/tree/act-tree.js +119 -112
  38. package/lib/tree/act-tree.js.map +1 -1
  39. package/lib/tree/index.css +21 -0
  40. package/lib/tree/tmpl-tree.d.ts +61 -0
  41. package/lib/tree/tmpl-tree.d.ts.map +1 -1
  42. package/lib/tree/tmpl-tree.js +341 -481
  43. package/lib/tree/tmpl-tree.js.map +1 -1
  44. package/lib/tree/tree-node.d.ts +22 -0
  45. package/lib/tree/tree-node.d.ts.map +1 -0
  46. package/lib/tree/tree-node.js +62 -0
  47. package/lib/tree/tree-node.js.map +1 -0
  48. package/lib/tree/tree-utils.d.ts +55 -0
  49. package/lib/tree/tree-utils.d.ts.map +1 -0
  50. package/lib/tree/tree-utils.js +142 -0
  51. package/lib/tree/tree-utils.js.map +1 -0
  52. package/package.json +1 -1
  53. package/src/aldehyde/controls/action/index.tsx +1 -0
  54. package/src/aldehyde/controls/action/utils.tsx +14 -20
  55. package/src/aldehyde/custom-page/custom-page-router.tsx +0 -1
  56. package/src/aldehyde/form/dtmpl-form.tsx +0 -1
  57. package/src/aldehyde/import/excel-import.tsx +42 -35
  58. package/src/aldehyde/module/dtmpl-view-card.tsx +1 -1
  59. package/src/aldehyde/routable/ttmpl-route.tsx +24 -154
  60. package/src/aldehyde/table/act-table.tsx +1 -0
  61. package/src/aldehyde/table/query-table.tsx +1 -1
  62. package/src/aldehyde/tmpl/hc-data-source.tsx +11 -1
  63. package/src/aldehyde/tmpl/hcservice-v3.tsx +29 -7
  64. package/src/aldehyde/tmpl/interface.tsx +14 -5
  65. package/src/aldehyde/tree/act-tree.tsx +149 -111
  66. package/src/aldehyde/tree/index.css +21 -0
  67. package/src/aldehyde/tree/tmpl-tree.tsx +397 -480
  68. package/src/aldehyde/tree/tree-node.tsx +78 -0
  69. package/src/aldehyde/tree/tree-utils.tsx +166 -0
@@ -1,18 +1,16 @@
1
1
  import React from 'react'
2
- import {AddOrUpdate, LtmplConfigRes, RouterCompProps} from '../tmpl/interface';
3
- import Units from "../units";
4
- import ActTable from '../table/act-table'
5
- // import StatActTable from '../table/stat-act-table'
2
+ import {AddOrUpdate, LtmplConfigRes, RouterCompProps, TtmplConfig} from '../tmpl/interface';
3
+
6
4
  import HCDataSource from "../tmpl/hc-data-source";
7
5
  import withRouter from "../routable/withroute";
6
+ import ActTree from "../tree/act-tree";
7
+ import {Card} from "antd";
8
8
  export interface TtmplRouteProps extends RouterCompProps {
9
9
 
10
10
  };
11
11
 
12
12
  export interface TtmplRouteState {
13
- ltmplConfigRes?: LtmplConfigRes,
14
- pageNo?: number,
15
- pageSize?: number,
13
+ ttmplConfig?: TtmplConfig,
16
14
  };
17
15
 
18
16
  class TtmplRoute extends React.PureComponent<TtmplRouteProps, TtmplRouteState> {
@@ -20,9 +18,7 @@ class TtmplRoute extends React.PureComponent<TtmplRouteProps, TtmplRouteState> {
20
18
  basePath: "",
21
19
  }
22
20
  state = {
23
- ltmplConfigRes: undefined,
24
- pageNo: undefined,
25
- pageSize: undefined,
21
+ ttmplConfig: undefined,
26
22
  }
27
23
 
28
24
  async componentDidMount() {
@@ -42,10 +38,15 @@ class TtmplRoute extends React.PureComponent<TtmplRouteProps, TtmplRouteState> {
42
38
  loadData = async () => {
43
39
  const {params} = this.props;
44
40
  const {sourceId} = params;
45
- let ltmplConfigRes:LtmplConfigRes = await HCDataSource.requestLtmplConfig(null,sourceId);
46
- this.setState({
47
- ltmplConfigRes:ltmplConfigRes,
48
- })
41
+ let ttmplConfig:TtmplConfig = await HCDataSource.requestTtmplConfig(null,sourceId);
42
+ //debugger
43
+ if(ttmplConfig.type=='1M'){
44
+ this.props.navigate(`/${ttmplConfig.id}/act-table`);
45
+ }else{
46
+ this.setState({
47
+ ttmplConfig:{...ttmplConfig},
48
+ })
49
+ }
49
50
  }
50
51
 
51
52
  async componentDidUpdate(prevProps) {
@@ -53,151 +54,20 @@ class TtmplRoute extends React.PureComponent<TtmplRouteProps, TtmplRouteState> {
53
54
  const {sourceId} = params;
54
55
  let {sourceId: preSourceId} = prevProps.params;
55
56
  let {location: preLocation} = prevProps;
56
- if (!sourceId ||
57
- (!preSourceId && this.state.ltmplConfigRes)
58
- || (location.pathname == preLocation.pathname && location.search == preLocation.search)
59
- ) {
60
- return;
61
- }
62
- this.loadData();
63
- }
64
-
65
- showView = (code: string, toCustomPage: boolean = false) => {
66
- const {basePath} = this.props;
67
- const {sourceId} = this.props.params;
68
- const {ltmplConfigRes} = this.state;
69
- let path = `${basePath}/${sourceId}/detail-view?code=${code}&menuId=${this.getMenuId()}`;
70
- if (toCustomPage && ltmplConfigRes.ltmplConfig.customViewPagePath) {
71
- path = `${basePath}${ltmplConfigRes.ltmplConfig.customViewPagePath}?menuId=${this.getMenuId()}&sourceId=${sourceId}`;
72
- }
73
- this.onRoute(path);
74
- }
75
-
76
- doEdit = (code: string, mode: AddOrUpdate, toCustomPage: boolean = false) => {
77
- const {basePath} = this.props;
78
- const {sourceId} = this.props.params;
79
- const {ltmplConfigRes} = this.state;
80
- let mainCode = this.getMainCode();
81
-
82
- let path = `${basePath}/${sourceId}/detail-edit?code=${code}&menuId=${this.getMenuId()}&mode=${mode}`;
83
- if (toCustomPage && ltmplConfigRes.ltmplConfig.customEditPagePath) {
84
- path = `${basePath}/page/${sourceId}${ltmplConfigRes.ltmplConfig.customEditPagePath}?code=${code}&menuId=${this.getMenuId()}`;
85
- }
86
- if (mainCode) {
87
- path = path + `&mainCode=${mainCode}`;
88
- }
89
- this.onRoute(path);
90
- }
91
-
92
- getMainCode = () => {
93
- const {searchParams} = this.props;
94
- let mainCode = undefined;
95
- // let criteriaData = Units.transQueryStrToParams(search);
96
- let mcode=searchParams.get('mainCode');
97
- if (mcode) {
98
- // criteriaData = Units.transQueryStrToParams(search);
99
- mainCode = mcode;
100
- }
101
- return mainCode;
102
- }
103
-
104
- doCreate = (toCustomPage: boolean = false) => {
105
- const {basePath} = this.props;
106
- const {sourceId} = this.props.params;
107
- const {ltmplConfigRes} = this.state;
108
- let path = `${basePath}/${sourceId}/detail-edit?menuId=${this.getMenuId()}`;
109
- if (toCustomPage && ltmplConfigRes.ltmplConfig.customEditPagePath) {
110
- path = `${basePath}/page/${sourceId}${ltmplConfigRes.ltmplConfig.customEditPagePath}?menuId=${this.getMenuId()}`;
111
- }
112
- let mainCode = this.getMainCode();
113
- if (mainCode) {
114
- path = path + `&mainCode=${mainCode}`;
115
- }
116
- this.onRoute(path);
117
- }
118
-
119
- doRAction = (ractionId: string, mainCode: String) => {
120
- const {basePath} = this.props;
121
- let path = `${basePath}/${ractionId}/act-table?mainCode=${mainCode}&menuId=${this.getMenuId()}`;
122
- this.onRoute(path);
123
- }
124
57
 
125
- doSearch = (params_) => {
126
- const {basePath} = this.props;
127
- const {sourceId} = this.props.params;
128
- let params = {...params_}
129
- //params['sourceId'] = sourceId;
130
- const newfliter = Units.transQueryParamsToStr(params);
131
- this.props.navigate(`${basePath}/${sourceId}/act-table?${newfliter}`,{replace:true})
132
-
133
- }
134
- onChangeSearch = (params_) => {
135
- let params = {...params_}
136
- //追加过滤条件,hiddenColIds,innerQueryKey
137
- const {searchParams} = this.props;
138
- let mcode=searchParams.get("mainCode");
139
- if (mcode) {
140
- params['mainCode'] = mcode;
141
- }
142
- const {pageSize,pageNo} = this.state;
143
- if(pageSize){
144
- params['pageNo'] = pageNo;
58
+ if (sourceId && preSourceId && sourceId==preSourceId) {
59
+ return;
145
60
  }
146
- if(pageNo){
147
- params['pageSize'] = pageSize;
148
- }
149
- params['menuId']=this.getMenuId();
150
- params['sourceId']=this.getMenuId();
151
- this.doSearch(params);
61
+ await this.loadData();
152
62
  }
153
63
 
154
- onChangePage = (pageNo: number, pageSize: number) => {
155
- const {location} = this.props;
156
- let search = location.search;
157
- let params = Units.transQueryStrToParams(search);
158
- params['pageNo'] = pageNo;
159
- params['pageSize'] = pageSize;
160
- this.doSearch(params);
161
-
162
- // this.setState({
163
- // pageNo,
164
- // pageSize
165
- // })
166
- }
167
-
168
-
169
64
  render() {
170
- const {ltmplConfigRes} = this.state;
171
- const {location, params} = this.props;
172
- const {sourceId} = params;
173
- //let menuId = undefined;
174
- let mainCode = undefined;
175
-
176
- let search = location.search;
177
- let criteriaData = Units.transQueryStrToParams(search);
178
- // if (search.indexOf('menuId') > 0) {
179
- // menuId = criteriaData['menuId'];
180
- // criteriaData['menuId'] = undefined;
181
- // } else {
182
- // menuId = sourceId;
183
- // }
184
- let pageSize = criteriaData['pageSize'];
185
- let pageNo = criteriaData['pageNo'];
186
-
187
- if (search.indexOf('mainCode') > 0) {
188
- //criteriaData = Units.transQueryStrToParams(search);
189
- mainCode = criteriaData['mainCode'];
190
- }
191
- if (!ltmplConfigRes) {
192
- return <></>;
193
- } else {
194
- return <ActTable serverKey={null} pageSize={pageSize} pageNo={pageNo} onChangePage={this.onChangePage}
195
- menuId={this.getMenuId()} mainCode={mainCode} showView={this.showView}
196
- doSearch={this.onChangeSearch} doEdit={this.doEdit} doCreate={this.doCreate}
197
- sourceId={sourceId} criteriaData={criteriaData}
198
- ltmplConfig={ltmplConfigRes?ltmplConfigRes.ltmplConfig:null}
199
- doRAction={this.doRAction}
200
- />
65
+ const { } = this.props;
66
+ const {ttmplConfig}=this.state;
67
+ if(!ttmplConfig){
68
+ return <Card loading={true}></Card>
69
+ }else{
70
+ return <><ActTree ttmplConfig={ttmplConfig}></ActTree></>;
201
71
  }
202
72
 
203
73
  }
@@ -301,6 +301,7 @@ class ActTable extends React.PureComponent<ActTableProps, ActTableStat> {
301
301
  }) : ""}
302
302
  {ltmplConfig.rowActions && ltmplConfig.rowActions.length > 0 ?
303
303
  ltmplConfig.rowActions.map((action) => {
304
+
304
305
  return <Action serverKey={serverKey} iconType={'icon'} key={action.id} data={[record]} actionConfig={action}
305
306
  doAction={this.doRowAction} buttonSize={'small'} serial={1}></Action>
306
307
  }) : ""}
@@ -242,7 +242,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
242
242
  }
243
243
  })
244
244
  selectedRows.forEach((item) => {
245
- selectedRows_.push({code: item.code, title: item[titleColId]});
245
+ selectedRows_.push({code: item['code'], title: item[titleColId]});
246
246
  selectedDatas.push(item);
247
247
  })
248
248
  if (onChangeRowSelection) {
@@ -8,7 +8,7 @@ import {
8
8
  Level2Menu,
9
9
  LtmplConfig,
10
10
  LtmplConfigRes,
11
- SelectConfig
11
+ SelectConfig, TtmplConfig
12
12
  } from "./interface";
13
13
  import HcserviceV3 from './hcservice-v3';
14
14
  import ControlTypeSupportor from './control-type-supportor'
@@ -25,6 +25,7 @@ const selectConfigMap: Map<string, SelectConfig> = new Map<string, SelectConfig>
25
25
  const ltmplConfigMap: Map<string, LtmplConfigRes> = new Map<string, LtmplConfigRes>();
26
26
  const l2LtmplConfigMap: Map<string, LtmplConfigRes> = new Map<string, LtmplConfigRes>();
27
27
  const dtmplConfigMap: Map<string, DtmplConfig> = new Map<string, DtmplConfig>();
28
+ const ttmplConfigMap: Map<string, TtmplConfig> = new Map<string, TtmplConfig>();
28
29
  const viewDtmplConfigMap: Map<string, DtmplConfig> = new Map<string, DtmplConfig>();
29
30
  const addDtmplConfigMap: Map<string, DtmplConfig> = new Map<string, DtmplConfig>();
30
31
  const objctCacheMap: Map<string, DtmplData> = new Map<string, DtmplData>();
@@ -195,6 +196,15 @@ HCDataSource.requestDtmplConfig = async function (serverKey:string,sourceId: str
195
196
  return dtmplConfigMap.get(sourceId);
196
197
  };
197
198
 
199
+ HCDataSource.requestTtmplConfig = async function (serverKey:string,sourceId: string) {
200
+ if (!ttmplConfigMap.has(sourceId)) {
201
+ let res= await HcserviceV3.requestTtmplConfig(serverKey,sourceId);
202
+ ttmplConfigMap.set(sourceId, res);
203
+ ttmplConfigMap.set(res.id, res);
204
+ }
205
+ return ttmplConfigMap.get(sourceId);
206
+ };
207
+
198
208
  HCDataSource.requestViewDtmplConfig = async function (serverKey:string,sourceId: string) {
199
209
  if (!viewDtmplConfigMap.has(sourceId)) {
200
210
  viewDtmplConfigMap.set(sourceId, await HcserviceV3.requestViewDtmplConfig(serverKey,sourceId));
@@ -48,6 +48,18 @@ export default class HcserviceV3 {
48
48
  return res.dtmplConfig;
49
49
  }
50
50
 
51
+ static async requestTtmplConfig(serverKey:string,sourceId: string) {
52
+
53
+ let url = `/v3/ttmpl/config`
54
+ let res = await Super.super({
55
+ url,
56
+ serverKey,
57
+ method: "GET",
58
+ query: {sourceId}
59
+ });
60
+ return res.ttmplConfig;
61
+ }
62
+
51
63
  static async requestViewDtmplConfig(serverKey:string,sourceId: string) {
52
64
 
53
65
  let url = `/v3/view-dtmpl/config`
@@ -122,6 +134,11 @@ export default class HcserviceV3 {
122
134
  return await this.requestCommonLtmplQueryTop(serverKey,sourceId, condition, url);
123
135
  }
124
136
 
137
+ static async requestTtmplRootData(serverKey:string,sourceId:string, condition) {
138
+ let url = `/v3/ttmpl/root-data`
139
+ return await this.requestCommonLtmplQueryTop(serverKey,sourceId, condition, url);
140
+ }
141
+
125
142
  static async requestMstrucLtmplQueryTop(serverKey:string,sourceId:string, condition) {
126
143
  //console.log('condition:',condition);
127
144
  let url = `/v3/mstruc/ltmpl/top-data`
@@ -139,13 +156,18 @@ export default class HcserviceV3 {
139
156
 
140
157
  static async requestCommonLtmplQueryTop(serverKey:string,sourceId:string, condition, url) {
141
158
 
142
- let res = await Super.super({
143
- url: url,
144
- serverKey,
145
- method: 'GET',
146
- query: {...condition, sourceId}
147
- });
148
- return res;
159
+ if(!sourceId){
160
+ message.error("SourceId is undefined!");
161
+ }else{
162
+ let res = await Super.super({
163
+ url: url,
164
+ serverKey,
165
+ method: 'GET',
166
+ query: {...condition, sourceId}
167
+ });
168
+ return res;
169
+ }
170
+
149
171
  }
150
172
 
151
173
  static async requestSelectedData(serverKey:string,sourceId:string, codes) {
@@ -154,7 +154,7 @@ export interface DtmplConfig extends TmplBase {
154
154
  onValuesChange:(changedValues,allValues:DtmplData,formInstance:FormInstance)=>void
155
155
  }
156
156
 
157
- export type Comparator = 'equal' | 'unequal' | 'includeOne' | 'exclude' | 'noLess' | 'noGreater';
157
+ export type Comparator ='contain'| 'equal' | 'equals' |'unequal' |'unequals' | 'includeOne'|'include_anyone'|'noless'|'nogreater' | 'exclude' | 'noLess' | 'noGreater';
158
158
 
159
159
  export type FieldAction = 'add' | 'delete' | 'edit' | 'detail'|'table';
160
160
 
@@ -188,6 +188,12 @@ export interface SelectConfig extends TmplBase {
188
188
  orderColumn:ColumnConfig;
189
189
  }
190
190
 
191
+ export interface TtmplConfigRes {
192
+ sourceId: string;
193
+ ltmplConfig?: LtmplConfig;
194
+ parentLtmplConfig?: LtmplConfig;
195
+ }
196
+
191
197
  export interface RActionConfig extends OrderableTmplBase {
192
198
 
193
199
  }
@@ -200,10 +206,13 @@ export interface LtmplConfigRes {
200
206
  ltmplConfig?: LtmplConfig;
201
207
  }
202
208
 
203
- export interface TtmplConfigRes {
204
- sourceId: string;
205
- ltmplConfig?: LtmplConfig;
206
- parentLtmplConfig?: LtmplConfig;
209
+ export interface TtmplConfig extends TmplBase {
210
+ type:"2M"|'1M'|'2MR',
211
+ leafTitle:string,
212
+ branchTitle:string,
213
+ rootGtmplId:string,
214
+ branchRatmplId:string,
215
+ leafRatmplId:string,
207
216
  }
208
217
 
209
218
  // export interface StatViewConfig extends SelectConfig {
@@ -1,111 +1,149 @@
1
- // import React from 'react'
2
- // import {Col, Empty, Layout, Row, Tabs, Button, Affix, Space, Card, Typography} from 'antd';
3
- // import ModelService from "../utils/modelService";
4
- // import {DndProvider} from 'react-dnd';
5
- // import {HTML5Backend} from 'react-dnd-html5-backend';
6
- // import TmplTree from "../tree/module-group-tree";
7
- // import './index.css';
8
- // import {DtmplEditCard, DtmplEditPage} from "aldehyde";
9
- // import HydrogenConstant from "../hydrogen-constant";
10
- // const {Content, Sider} = Layout;
11
- // const {Text, Title} = Typography
12
- // interface PageConfigProps {
13
- //
14
- // }
15
- //
16
- // interface PageConfigState {
17
- // pageCode: string,
18
- // moduleCode:string,
19
- // moduleType: string,
20
- // moduleName:string,
21
- // titleClickedKey: string | number,
22
- // activeKey: string,
23
- // pageSearchValue:string,
24
- // menuSearchValue:string,
25
- // }
26
- //
27
- // export default class ActTree extends React.PureComponent<PageConfigProps, PageConfigState> {
28
- //
29
- // static defaultProps = {}
30
- // state = {
31
- // pageCode: undefined,
32
- // moduleCode:undefined,
33
- // moduleType: undefined,
34
- // moduleName:undefined,
35
- // currentPage: "workbench",
36
- // titleClickedKey: undefined,
37
- // activeKey: "menu-config",
38
- // pageSearchValue:undefined,
39
- // menuSearchValue:undefined,
40
- //
41
- // }
42
- //
43
- // refGtmplTree:any=React.createRef();
44
- //
45
- // async componentDidMount() {
46
- // }
47
- //
48
- // onChangeModule=(moduleCode:string,pageCode:string)=>{
49
- // this.setState({moduleCode,pageCode})
50
- // }
51
- //
52
- //
53
- // componentDidUpdate(preProps){
54
- //
55
- // }
56
- //
57
- // getGtmplRatmplSourceId=(moduleType:string)=>{
58
- // return moduleType=='SQL统计模型'?HydrogenConstant.moduleGstmplRatmpl.sourceId:moduleType=='SQL查询模型'?HydrogenConstant.moduleGqtmplRatmpl.sourceId: HydrogenConstant.moduleGtmplRatmpl.sourceId;
59
- // }
60
- //
61
- // render() {
62
- // const {} = this.props;
63
- // const {titleClickedKey,pageSearchValue,menuSearchValue,moduleType,moduleCode,pageCode,moduleName} = this.state;
64
- // return (<Layout hasSider style={{backgroundColor: '#fff'}}>
65
- // <DndProvider backend={HTML5Backend}>
66
- // <Sider width={360} theme={'light'}
67
- // style={{
68
- // height: '100vh',
69
- // position: 'fixed',
70
- // left: 0,
71
- // top: 0,
72
- // bottom: 0,
73
- // marginLeft:184
74
- // }}
75
- // >
76
- // <div style={{height: 30, margin: 16, background: 'rgba(0, 0, 0, 0.2)'}}/>
77
- // <TmplTree
78
- // onChangeSearchValue={(pageSearchValue)=>this.setState({pageSearchValue})}
79
- // searchValue={pageSearchValue}
80
- // onEditPage={(moduleCode,moduleName,moduleType,pageCode)=>this.setState({
81
- // moduleCode,moduleType,pageCode,moduleName
82
- // })}
83
- // ref={this.refGtmplTree}
84
- // draggable={false}></TmplTree>
85
- // </Sider>
86
- // <Layout style={{marginLeft:382, backgroundColor: '#fff'}}>
87
- // <Content style={{overflow: 'initial'}}>
88
- // {moduleType? <DtmplEditCard title={<>{pageCode?"编辑 页面":"添加 页面"} - {'当前模块:'+moduleName}</>}
89
- // mainCode={moduleCode}
90
- // sourceId={this.getGtmplRatmplSourceId(moduleType)}
91
- // code={pageCode} onOk={(pageCode)=>{this.refGtmplTree?.current?.refresh();
92
- // this.setState({pageCode})
93
- // }}
94
- // />:
95
- // <Card style={{marginTop:14}} bodyStyle={{padding: '12px 6px 6px 6px'}}>
96
- // <Space direction="vertical">
97
- // <Title level={5}>【页面定义】使用说明</Title>
98
- // <span><Text
99
- // type="danger">1.模型生成页面:</Text><Text>鼠标悬停在【模型节点】的【名称】上,点击气泡卡片的【同步默认页面】按钮。</Text></span>
100
- // <span><Text
101
- // type="danger">2.创建页面:</Text><Text>鼠标悬停在【模型节点】的【名称】上,点击气泡卡片的【+创建页面】按钮,填写并保存右边弹出的抽屉页面。</Text></span>
102
- // <span><Text
103
- // type="danger">3.复制页面:</Text><Text>鼠标悬停在【页面节点】的【名称】上,点击气泡卡片的【复制】按钮。</Text></span>
104
- // </Space>
105
- // </Card>}
106
- // </Content>
107
- // </Layout>
108
- // </DndProvider>
109
- // </Layout>)
110
- // }
111
- // }
1
+ import React from 'react'
2
+ import {Card, Layout, Typography} from 'antd';
3
+ import TmplTree from "./tmpl-tree";
4
+ import TreeUtils, {TtmplNodeConfig} from "./tree-utils";
5
+ import {TtmplConfig} from "../tmpl/interface";
6
+ import {DtmplEditCard, DtmplViewCard} from "../index";
7
+ import HcserviceV3 from "../tmpl/hcservice-v3";
8
+
9
+ const {Content, Sider} = Layout;
10
+ const {Text, Title} = Typography
11
+
12
+ interface ActTreeProps {
13
+ ttmplConfig: TtmplConfig,
14
+ }
15
+
16
+ interface ActTreeState {
17
+ ttmplNodeConfig?: TtmplNodeConfig,
18
+ showEdit?: boolean,
19
+ showView?:boolean,
20
+ recordCode?: string,
21
+ mainCode?: string,
22
+ sourceId?: string,
23
+ cardtitle?:string,
24
+ }
25
+
26
+ export default class ActTree extends React.PureComponent<ActTreeProps, ActTreeState> {
27
+
28
+ static defaultProps = {}
29
+ state = {
30
+ ttmplNodeConfig: undefined,
31
+ recordCode: undefined,
32
+ showEdit: false,
33
+ showView:false,
34
+ mainCode: undefined,
35
+ sourceId: undefined,
36
+ cardtitle:undefined,
37
+ }
38
+
39
+ refTmplTree: any = React.createRef();
40
+
41
+ async componentDidMount() {
42
+
43
+ await this.loadData();
44
+ }
45
+
46
+ loadData=async ()=>{
47
+ const {ttmplConfig} = this.props;
48
+ let ttmplNodeConfig = await TreeUtils.initTtmplNodeConfig(ttmplConfig);
49
+ this.setState({
50
+ ttmplNodeConfig,
51
+ showEdit:false,
52
+ showView:false,
53
+ })
54
+ }
55
+
56
+ async componentDidUpdate(prevProps) {
57
+ let {ttmplConfig: prettmplConfig} = prevProps;
58
+ let {ttmplConfig} = this.props;
59
+
60
+ if (ttmplConfig && prettmplConfig && ttmplConfig.id==prettmplConfig.id) {
61
+ return;
62
+ }
63
+ await this.loadData();
64
+ }
65
+
66
+ onEditRoot = (title:string,code?: string) => {
67
+ const {ttmplConfig} = this.props;
68
+ this.showCard(title,ttmplConfig.rootGtmplId,null,code,true,false);
69
+ };
70
+ showCard=(cardtitle,sourceId,mainCode,recordCode,showEdit,showView)=>{
71
+ this.setState({
72
+ mainCode,
73
+ cardtitle,
74
+ recordCode,
75
+ showEdit,
76
+ showView,
77
+ sourceId,
78
+ })
79
+ }
80
+ onViewRoot = (title:string,code?: string) => {
81
+ const {ttmplConfig} = this.props;
82
+ this.showCard(title,ttmplConfig.rootGtmplId,null,code,false,true);
83
+ };
84
+
85
+ onEditSub = (title:string,sourceId:string,mainCode:string,recordCode?: string) => {
86
+ this.showCard(title,sourceId,mainCode,recordCode,true,false);
87
+ };
88
+
89
+ onViewSub = (title:string,sourceId:string,mainCode:string,recordCode?: string) => {
90
+
91
+ this.showCard(title,sourceId,mainCode,recordCode,false,true);
92
+ };
93
+
94
+ onDelete=(sourceId:string,recordCode?: string) => {
95
+ HcserviceV3.deleteByCode(null,sourceId, [recordCode]);
96
+ };
97
+ onAddSub=(title:string,sourceId:string,mainCode: string) => {
98
+
99
+ this.showCard(title,sourceId,mainCode,null,true,false);
100
+ };
101
+
102
+ render() {
103
+ const {} = this.props;
104
+
105
+ const {ttmplNodeConfig,showView, showEdit, recordCode, mainCode, sourceId,cardtitle} = this.state;
106
+ if (!ttmplNodeConfig) {
107
+ return <Card loading={true}></Card>
108
+ }
109
+ return (<Layout hasSider style={{backgroundColor: '#fff'}}>
110
+ <Sider width={360} theme={'light'}
111
+ style={{
112
+ height: '90vh',
113
+ position: 'fixed',
114
+ left: 0,
115
+ top: 66,
116
+ bottom: 0,
117
+ marginLeft: 210
118
+ }}
119
+ ><TmplTree doEditRoot={this.onEditRoot}
120
+ doEditSub={this.onEditSub}
121
+ doDelete={this.onDelete}
122
+ doViewRoot={this.onViewRoot}
123
+ doViewSub={this.onViewSub}
124
+ doAddSub={this.onAddSub}
125
+ ttmplNodeConfig={ttmplNodeConfig}
126
+ ref={this.refTmplTree}
127
+ ></TmplTree>
128
+ </Sider>
129
+ <Layout style={{marginLeft: 382, backgroundColor: '#fff'}}>
130
+ <Content style={{overflow: 'initial'}}>
131
+ {showEdit ? <DtmplEditCard title={<>{recordCode ? <>编辑 {cardtitle?cardtitle:""}</> : <>添加 {cardtitle?cardtitle:""}</>} </>}
132
+ mainCode={mainCode}
133
+ sourceId={sourceId}
134
+ code={recordCode}
135
+ onOk={(recordCode) => {
136
+ let a=this.refTmplTree?.current?.reloadData(mainCode);
137
+ this.setState({recordCode})
138
+ }}
139
+ /> : null}
140
+ {showView ? <DtmplViewCard
141
+ mainCode={mainCode}
142
+ sourceId={sourceId}
143
+ code={recordCode}
144
+ /> : null}
145
+ </Content>
146
+ </Layout>
147
+ </Layout>)
148
+ }
149
+ }
@@ -0,0 +1,21 @@
1
+ .tree-container {
2
+ box-shadow:1px 0 0px 1px rgba(0,0,0,0.3) ;
3
+ }
4
+
5
+ .tree-node{
6
+ box-shadow:0.4px 0px 0px 0.4px rgba(0,0,0,0.2) ;
7
+ margin-bottom: 2px;
8
+ }
9
+
10
+
11
+
12
+ .tree-card-title-body {
13
+ padding:2px;
14
+ min-width: 280px;
15
+ }
16
+ .ant-tree-node-selected{
17
+ background-color: white !important;
18
+ }
19
+ .ant-avatar-string{
20
+ transform: scale(0.8) translateX(-50%) !important;
21
+ }