aldehyde 0.2.62 → 0.2.64
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/layout/MainPage.d.ts.map +1 -1
- package/lib/layout/MainPage.js +50 -10
- package/lib/layout/MainPage.js.map +1 -1
- package/lib/layout/menu/block.d.ts +1 -1
- package/lib/layout/menu/block.d.ts.map +1 -1
- package/lib/layout/menu/block.js +21 -9
- package/lib/layout/menu/block.js.map +1 -1
- package/lib/layout/menu/menu-2layers.js +5 -5
- package/lib/layout/menu/menu-2layers.js.map +1 -1
- package/lib/layout/menu/menu-render.d.ts +6 -4
- package/lib/layout/menu/menu-render.d.ts.map +1 -1
- package/lib/layout/menu/menu-render.js +85 -30
- package/lib/layout/menu/menu-render.js.map +1 -1
- package/lib/table/act-table.d.ts +1 -1
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +7 -15
- package/lib/table/act-table.js.map +1 -1
- package/lib/tmpl/interface.d.ts +2 -0
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tmpl/interface.js.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/layout/MainPage.tsx +87 -49
- package/src/aldehyde/layout/menu/block.tsx +20 -12
- package/src/aldehyde/layout/menu/menu-2layers.tsx +5 -5
- package/src/aldehyde/layout/menu/menu-render.tsx +108 -48
- package/src/aldehyde/table/act-table.tsx +9 -15
- package/src/aldehyde/tmpl/interface.tsx +3 -1
- package/lib/layout/menu/block1.d.ts +0 -18
- package/lib/layout/menu/block1.d.ts.map +0 -1
- package/lib/layout/menu/block1.js +0 -46
- package/lib/layout/menu/block1.js.map +0 -1
- package/src/aldehyde/layout/menu/block1.tsx +0 -81
|
@@ -1,46 +1,84 @@
|
|
|
1
|
-
import {Level1Menu, Level2Menu} from "../../tmpl/interface";
|
|
1
|
+
import {BlockMenu, Level1Menu, Level2Menu} from "../../tmpl/interface";
|
|
2
2
|
import {Menu} from "antd";
|
|
3
|
+
import type {MenuProps} from "antd";
|
|
3
4
|
import React from "react";
|
|
4
5
|
import {NavLink} from 'react-router-dom';
|
|
5
6
|
import Units from "../../units";
|
|
6
|
-
|
|
7
|
+
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
|
|
11
|
+
getMenu(blockMenu: BlockMenu , target, basePath = ""){
|
|
12
|
+
if(blockMenu.l1Menus){
|
|
13
|
+
return this.toL1Menu(blockMenu.l1Menus, target, basePath = "")
|
|
14
|
+
}else{
|
|
15
|
+
return this.toSubMenu(blockMenu.items, target, basePath = "");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
toL1Menu(subMenus: (Level1Menu)[], target, basePath = "") {
|
|
21
|
+
let menus:MenuProps['items'] =[];
|
|
22
|
+
let menu;
|
|
23
|
+
if(subMenus){
|
|
24
|
+
subMenus.map((item) => {
|
|
25
|
+
menu = {key: item.id};
|
|
26
|
+
let subItems = item.l2Menus;
|
|
27
|
+
if (subItems) {//菜单
|
|
28
|
+
menu.label = item.title;
|
|
29
|
+
menu.children = this.toSubMenu(subItems, target, basePath);
|
|
30
|
+
}
|
|
31
|
+
menus.push(menu);
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
return menus;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
toSubMenu(subMenus: (Level2Menu |BlockMenu)[], target, basePath = "") {
|
|
38
|
+
let menus:MenuProps['items'] =[];
|
|
39
|
+
let menu;
|
|
40
|
+
if(subMenus){
|
|
41
|
+
subMenus.map((item) => {
|
|
42
|
+
menu = {key: item.id};
|
|
43
|
+
let subItems = item.items;
|
|
44
|
+
if (subItems) {//菜单
|
|
45
|
+
menu.label = item.title;
|
|
46
|
+
menu.children = this.toSubMenu(subItems, target, basePath);
|
|
47
|
+
} else {
|
|
48
|
+
let i:Level2Menu=item as Level2Menu;
|
|
49
|
+
menu.label = this.toL2MenuTitle(i , target, basePath);
|
|
50
|
+
}
|
|
51
|
+
menus.push(menu);
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
return menus;
|
|
17
55
|
},
|
|
18
|
-
getRoutePath(menu:Level2Menu,basePath,defaultCriteriaData){
|
|
19
|
-
if(menu){
|
|
20
|
-
let pageType=menu.pageType;
|
|
56
|
+
getRoutePath(menu: Level2Menu, basePath, defaultCriteriaData) {
|
|
57
|
+
if (menu) {
|
|
58
|
+
let pageType = menu.pageType;
|
|
21
59
|
|
|
22
|
-
let routePath='act-table';
|
|
60
|
+
let routePath = 'act-table';
|
|
23
61
|
|
|
24
|
-
let codeSource='';
|
|
62
|
+
let codeSource = '';
|
|
25
63
|
switch (pageType) {
|
|
26
64
|
case "列表":
|
|
27
|
-
routePath='act-table';
|
|
65
|
+
routePath = 'act-table';
|
|
28
66
|
break;
|
|
29
67
|
case "添加":
|
|
30
|
-
routePath='detail-edit';
|
|
31
|
-
codeSource='&codeSource=new';
|
|
68
|
+
routePath = 'detail-edit';
|
|
69
|
+
codeSource = '&codeSource=new';
|
|
32
70
|
break;
|
|
33
71
|
case "编辑":
|
|
34
|
-
routePath='detail-edit';
|
|
35
|
-
codeSource='&codeSource=listop';
|
|
72
|
+
routePath = 'detail-edit';
|
|
73
|
+
codeSource = '&codeSource=listop';
|
|
36
74
|
break;
|
|
37
75
|
case "编辑或添加":
|
|
38
|
-
routePath='detail-edit';
|
|
39
|
-
codeSource='&codeSource=listop-new';
|
|
76
|
+
routePath = 'detail-edit';
|
|
77
|
+
codeSource = '&codeSource=listop-new';
|
|
40
78
|
break;
|
|
41
79
|
case "详情":
|
|
42
|
-
routePath='detail-view';
|
|
43
|
-
codeSource='&codeSource=listop';
|
|
80
|
+
routePath = 'detail-view';
|
|
81
|
+
codeSource = '&codeSource=listop';
|
|
44
82
|
break;
|
|
45
83
|
}
|
|
46
84
|
|
|
@@ -49,37 +87,59 @@ export default {
|
|
|
49
87
|
}
|
|
50
88
|
return null;
|
|
51
89
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
defaultCriteriaData='&'+ Units.transQueryParamsToStr(item.defaultCriteriaValue);
|
|
90
|
+
toL2MenuTitle(item: Level2Menu, target, basePath = "") {
|
|
91
|
+
|
|
92
|
+
if(!item){
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let delimiter = "/";
|
|
97
|
+
let customPath = item.customPath;
|
|
98
|
+
if (customPath) {
|
|
99
|
+
if (customPath.startsWith('/') || customPath.startsWith('\\')) {
|
|
100
|
+
delimiter = "";
|
|
64
101
|
}
|
|
102
|
+
}
|
|
103
|
+
let defaultCriteriaData = "";
|
|
104
|
+
if (item['defaultCriteriaValue']) {
|
|
105
|
+
defaultCriteriaData = '&' + Units.transQueryParamsToStr(item.defaultCriteriaValue);
|
|
106
|
+
}
|
|
65
107
|
|
|
66
|
-
|
|
108
|
+
let path = customPath ? `${basePath}/page/${item.id}${delimiter}${customPath}?menuId=${item.id}` : this.getRoutePath(item, basePath, defaultCriteriaData);
|
|
67
109
|
|
|
68
|
-
|
|
69
|
-
<NavLink to={path} target={target} >{item.title}</NavLink>
|
|
70
|
-
</Menu.Item>
|
|
71
|
-
})
|
|
110
|
+
return <NavLink to={path} target={target}>{item.title}</NavLink>;
|
|
72
111
|
},
|
|
73
|
-
findOpenId(
|
|
74
|
-
let openL2MenuId:string=undefined;
|
|
75
|
-
|
|
76
|
-
for(const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
112
|
+
findOpenId(blockMenu: BlockMenu, currentL2MenuId: string) {
|
|
113
|
+
let openL2MenuId: string = undefined;
|
|
114
|
+
if(blockMenu.l1Menus){
|
|
115
|
+
for (const menul1 of blockMenu.l1Menus) {
|
|
116
|
+
for (const menul2 of menul1.l2Menus) {
|
|
117
|
+
if (menul2.id == currentL2MenuId) {
|
|
118
|
+
openL2MenuId = menul1.id;
|
|
119
|
+
return openL2MenuId;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}else{
|
|
124
|
+
for (const menul1 of blockMenu.items) {
|
|
125
|
+
if(menul1.items){
|
|
126
|
+
for (const menul2 of menul1.items) {
|
|
127
|
+
if (menul2.id == currentL2MenuId) {
|
|
128
|
+
openL2MenuId = menul1.id;
|
|
129
|
+
return openL2MenuId;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}else{
|
|
133
|
+
if (menul1.id == currentL2MenuId) {
|
|
134
|
+
openL2MenuId = menul1.id;
|
|
135
|
+
return openL2MenuId;
|
|
136
|
+
}
|
|
80
137
|
}
|
|
138
|
+
|
|
81
139
|
}
|
|
82
140
|
}
|
|
141
|
+
|
|
142
|
+
|
|
83
143
|
return openL2MenuId;
|
|
84
144
|
}
|
|
85
145
|
}
|
|
@@ -486,16 +486,10 @@ class ActTable extends React.PureComponent<ActTableProps, ActTableStat> {
|
|
|
486
486
|
doSelectedCQuery = async (cqueryId: string) => {
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
-
doJump = async (jump: JumpConfig,
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
// if (result.status === "success") {
|
|
494
|
-
// let hydrocarbonToken = Units.hydrocarbonToken();
|
|
495
|
-
// let url = result.url + "hydrocarbon_token=" + Units.hydrocarbonToken();
|
|
496
|
-
// // console.log(url);
|
|
497
|
-
// window.open(url);
|
|
498
|
-
// }
|
|
489
|
+
doJump = async (jump: JumpConfig, record_: DtmplData) => {
|
|
490
|
+
|
|
491
|
+
let record=record_.fieldMap?record_.fieldMap:record_
|
|
492
|
+
|
|
499
493
|
let url=null;
|
|
500
494
|
|
|
501
495
|
let path=jump.path;
|
|
@@ -520,7 +514,7 @@ class ActTable extends React.PureComponent<ActTableProps, ActTableStat> {
|
|
|
520
514
|
//根据参数名匹配参数
|
|
521
515
|
for(let p of routeParamConfigs){
|
|
522
516
|
if(p && pa == p.title){//赋值替换
|
|
523
|
-
paths[i]=record.
|
|
517
|
+
paths[i]=record[p.id]?record[p.id]:p.defaultValue;
|
|
524
518
|
break;
|
|
525
519
|
}
|
|
526
520
|
}
|
|
@@ -543,7 +537,7 @@ class ActTable extends React.PureComponent<ActTableProps, ActTableStat> {
|
|
|
543
537
|
let initSearchLength=searchs.length
|
|
544
538
|
for(let i=0;i<searchParamConfigs.length;i++){
|
|
545
539
|
let p= searchParamConfigs[i];
|
|
546
|
-
searchs[initSearchLength+i]=p.title+"="+ (record
|
|
540
|
+
searchs[initSearchLength+i]=p.title+"="+ (record[p.id]?record[p.id]:p.defaultValue);
|
|
547
541
|
}
|
|
548
542
|
}
|
|
549
543
|
if(searchs.length>0){
|
|
@@ -561,9 +555,9 @@ class ActTable extends React.PureComponent<ActTableProps, ActTableStat> {
|
|
|
561
555
|
}
|
|
562
556
|
|
|
563
557
|
doSelectedJump = async (jump: JumpConfig) => {
|
|
564
|
-
const {
|
|
565
|
-
if (
|
|
566
|
-
this.doJump(jump,
|
|
558
|
+
const {selectedDatas} = this.state;
|
|
559
|
+
if (selectedDatas.length == 1) {
|
|
560
|
+
this.doJump(jump, selectedDatas[0])
|
|
567
561
|
}
|
|
568
562
|
}
|
|
569
563
|
|
|
@@ -79,6 +79,7 @@ export interface JumpConfig extends OrderableTmplBase {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export interface Level2Menu extends MenuBase {
|
|
82
|
+
items:(BlockMenu|Level2Menu)[],
|
|
82
83
|
customPath?: string;
|
|
83
84
|
displayTotal?: boolean;
|
|
84
85
|
count?:number;
|
|
@@ -95,7 +96,8 @@ export interface MenuBase extends OrderableTmplBase {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
export interface BlockMenu extends MenuBase {
|
|
98
|
-
l1Menus: Level1Menu[]
|
|
99
|
+
l1Menus: Level1Menu[],
|
|
100
|
+
items:(BlockMenu|Level2Menu)[]
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
export interface CriteriaConfig extends FieldConfig {
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { BlockMenu } from "../../tmpl/interface";
|
|
3
|
-
export interface BlockProps {
|
|
4
|
-
blocks: BlockMenu[];
|
|
5
|
-
currentBlockId?: string;
|
|
6
|
-
currentL2MenuId?: string;
|
|
7
|
-
activeColor?: string;
|
|
8
|
-
}
|
|
9
|
-
interface BlockState {
|
|
10
|
-
}
|
|
11
|
-
declare class Block extends React.PureComponent<BlockProps, BlockState> {
|
|
12
|
-
constructor(props: any);
|
|
13
|
-
renderBlockMenu: (blockMenu: BlockMenu) => React.JSX.Element;
|
|
14
|
-
findBlockId: (blocks: BlockMenu[], currentL2MenuId: string) => string;
|
|
15
|
-
render(): React.JSX.Element | React.JSX.Element[];
|
|
16
|
-
}
|
|
17
|
-
export default Block;
|
|
18
|
-
//# sourceMappingURL=block1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block1.d.ts","sourceRoot":"","sources":["../../../../../src/aldehyde/layout/menu/block1.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAI/C,MAAM,WAAW,UAAU;IACvB,MAAM,EAAC,SAAS,EAAE,CAAC;IACnB,cAAc,CAAC,EAAC,MAAM,CAAC;IACvB,eAAe,CAAC,EAAC,MAAM,CAAC;IACxB,WAAW,CAAC,EAAC,MAAM,CAAC;CACvB;AACD,UAAU,UAAU;CAEnB;AAED,cAAM,KAAM,SAAQ,KAAK,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC;gBAE/C,KAAK,KAAA;IAIjB,eAAe,cAAc,SAAS,uBAKrC;IAGD,WAAW,WAAW,SAAS,EAAE,mBAAiB,MAAM,YAavD;IAED,MAAM;CAiCT;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Dropdown, Menu } from 'antd';
|
|
3
|
-
import MenuRender from './menu-render';
|
|
4
|
-
class Block extends React.PureComponent {
|
|
5
|
-
constructor(props) {
|
|
6
|
-
super(props);
|
|
7
|
-
this.renderBlockMenu = (blockMenu) => {
|
|
8
|
-
return React.createElement(Menu, null, MenuRender.renderL1Menu(blockMenu.l1Menus, null));
|
|
9
|
-
};
|
|
10
|
-
this.findBlockId = (blocks, currentL2MenuId) => {
|
|
11
|
-
let blockId = undefined;
|
|
12
|
-
for (const block of blocks) {
|
|
13
|
-
for (const menul1 of block.l1Menus) {
|
|
14
|
-
for (const menul2 of menul1.l2Menus) {
|
|
15
|
-
if (menul2.id === currentL2MenuId) {
|
|
16
|
-
blockId = block.id;
|
|
17
|
-
return blockId;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return blockId;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
render() {
|
|
26
|
-
const { currentBlockId, blocks, currentL2MenuId, activeColor } = this.props;
|
|
27
|
-
const syyy = { '--header-block-active-bottom-color': activeColor ? activeColor : "#1E90FF", '--header-top-active-background': activeColor ? activeColor : "#1E90FF" };
|
|
28
|
-
if (!blocks || blocks.length < 1) {
|
|
29
|
-
return React.createElement(React.Fragment, null);
|
|
30
|
-
}
|
|
31
|
-
let blockId = currentBlockId;
|
|
32
|
-
if (currentL2MenuId && !blockId) {
|
|
33
|
-
blockId = this.findBlockId(blocks, currentL2MenuId);
|
|
34
|
-
}
|
|
35
|
-
if (!blockId) {
|
|
36
|
-
blockId = blocks.at(0).id;
|
|
37
|
-
}
|
|
38
|
-
return (blocks.map((item, index) => {
|
|
39
|
-
return React.createElement("div", { key: index, className: `${item.id == blockId ? "active" : ""} header-block`, style: syyy },
|
|
40
|
-
React.createElement(Dropdown, { overlay: this.renderBlockMenu(item) },
|
|
41
|
-
React.createElement("a", { className: "dropdown-link", style: item.id == blockId ? { color: '#fff' } : { color: activeColor }, rel: "noopener noreferrer" }, item.title)));
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export default Block;
|
|
46
|
-
//# sourceMappingURL=block1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"block1.js","sourceRoot":"","sources":["../../../../../src/aldehyde/layout/menu/block1.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAC,MAAM,MAAM,CAAC;AAErC,OAAO,UAAU,MAAM,eAAe,CAAC;AAavC,MAAM,KAAM,SAAQ,KAAK,CAAC,aAAqC;IAE3D,YAAY,KAAK;QACb,KAAK,CAAC,KAAK,CAAC,CAAC;QAGjB,oBAAe,GAAG,CAAC,SAAmB,EAAC,EAAE;YACrC,OAAO,oBAAC,IAAI,QACP,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAC,IAAI,CAAC,CAC7C,CAAA;QAEX,CAAC,CAAA;QAGD,gBAAW,GAAG,CAAC,MAAkB,EAAC,eAAsB,EAAE,EAAE;YACxD,IAAI,OAAO,GAAQ,SAAS,CAAC;YAC7B,KAAI,MAAM,KAAK,IAAI,MAAM,EAAC;gBACtB,KAAI,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAC;oBAC9B,KAAI,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAC;wBAC/B,IAAG,MAAM,CAAC,EAAE,KAAG,eAAe,EAAC;4BAC3B,OAAO,GAAC,KAAK,CAAC,EAAE,CAAC;4BACjB,OAAO,OAAO,CAAC;yBAClB;qBACJ;iBACJ;aACJ;YACD,OAAO,OAAO,CAAC;QACnB,CAAC,CAAA;IAvBD,CAAC;IAyBD,MAAM;QACF,MAAM,EAAC,cAAc,EAAC,MAAM,EAAC,eAAe,EAAC,WAAW,EAAC,GAAC,IAAI,CAAC,KAAK,CAAC;QAErE,MAAM,IAAI,GAAC,EAAC,oCAAoC,EAAC,WAAW,CAAA,CAAC,CAAA,WAAW,CAAA,CAAC,CAAA,SAAS,EAAC,gCAAgC,EAAC,WAAW,CAAA,CAAC,CAAA,WAAW,CAAA,CAAC,CAAA,SAAS,EAAkB,CAAA;QAEvK,IAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAC,CAAC,EAAC;YAC1B,OAAO,yCAAK,CAAC;SAChB;QACD,IAAI,OAAO,GAAC,cAAc,CAAC;QAC3B,IAAG,eAAe,IAAI,CAAC,OAAO,EAAC;YAC3B,OAAO,GAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAC,eAAe,CAAC,CAAC;SACpD;QACD,IAAG,CAAC,OAAO,EAAC;YACR,OAAO,GAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3B;QAED,OAAO,CACP,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YACvB,OAAO,6BAAK,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,eAAe,EAAG,KAAK,EAAE,IAAI;gBACrF,oBAAC,QAAQ,IAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;oBACzC,2BAAI,SAAS,EAAC,eAAe,EACzB,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,OAAO,CAAA,CAAC,CAAA,EAAC,KAAK,EAAC,MAAM,EAAC,CAAA,CAAC,CAAA,EAAC,KAAK,EAAC,WAAW,EAAC,EAC7D,GAAG,EAAC,qBAAqB,IAEvB,IAAI,CAAC,KAAK,CACX,CACG,CACT,CAAA;QACV,CAAC,CAAC,CACD,CAAC;IACN,CAAC;CAEJ;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React, {CSSProperties} from "react";
|
|
2
|
-
import { Dropdown, Menu} from 'antd';
|
|
3
|
-
import {BlockMenu} from "../../tmpl/interface";
|
|
4
|
-
import MenuRender from './menu-render';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export interface BlockProps{
|
|
8
|
-
blocks:BlockMenu[];
|
|
9
|
-
currentBlockId?:string;
|
|
10
|
-
currentL2MenuId?:string;
|
|
11
|
-
activeColor?:string;
|
|
12
|
-
}
|
|
13
|
-
interface BlockState{
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class Block extends React.PureComponent<BlockProps, BlockState> {
|
|
18
|
-
|
|
19
|
-
constructor(props) {
|
|
20
|
-
super(props);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
renderBlockMenu = (blockMenu:BlockMenu)=>{
|
|
24
|
-
return <Menu>
|
|
25
|
-
{MenuRender.renderL1Menu(blockMenu.l1Menus,null)}
|
|
26
|
-
</Menu>
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
findBlockId = (blocks:BlockMenu[],currentL2MenuId:string) => {
|
|
32
|
-
let blockId:string=undefined;
|
|
33
|
-
for(const block of blocks){
|
|
34
|
-
for(const menul1 of block.l1Menus){
|
|
35
|
-
for(const menul2 of menul1.l2Menus){
|
|
36
|
-
if(menul2.id===currentL2MenuId){
|
|
37
|
-
blockId=block.id;
|
|
38
|
-
return blockId;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return blockId;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
render(){
|
|
47
|
-
const {currentBlockId,blocks,currentL2MenuId,activeColor}=this.props;
|
|
48
|
-
|
|
49
|
-
const syyy={'--header-block-active-bottom-color':activeColor?activeColor:"#1E90FF",'--header-top-active-background':activeColor?activeColor:"#1E90FF"} as CSSProperties
|
|
50
|
-
|
|
51
|
-
if(!blocks || blocks.length<1){
|
|
52
|
-
return <></>;
|
|
53
|
-
}
|
|
54
|
-
let blockId=currentBlockId;
|
|
55
|
-
if(currentL2MenuId && !blockId){
|
|
56
|
-
blockId=this.findBlockId(blocks,currentL2MenuId);
|
|
57
|
-
}
|
|
58
|
-
if(!blockId){
|
|
59
|
-
blockId=blocks.at(0).id;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
blocks.map((item, index) => {
|
|
64
|
-
return <div key={index}
|
|
65
|
-
className={`${item.id == blockId ? "active" : ""} header-block`} style={syyy}>
|
|
66
|
-
<Dropdown overlay={this.renderBlockMenu(item)}>
|
|
67
|
-
<a className="dropdown-link"
|
|
68
|
-
style={item.id == blockId?{color:'#fff'}:{color:activeColor}}
|
|
69
|
-
rel="noopener noreferrer"
|
|
70
|
-
>
|
|
71
|
-
{item.title}
|
|
72
|
-
</a>
|
|
73
|
-
</Dropdown>
|
|
74
|
-
</div>
|
|
75
|
-
})
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export default Block;
|