@bit-sun/business-component 1.2.2 → 1.2.4-alpha.1
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/.fatherrc.ts +1 -0
- package/.umirc.ts +31 -16
- package/dist/components/Business/AddSelectBusiness/index.d.ts +1 -0
- package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +4 -0
- package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +4 -0
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +4 -0
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +17 -0
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +30 -0
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +3 -0
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +2 -0
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +4 -0
- package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +4 -0
- package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +2 -0
- package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +8 -0
- package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +8 -0
- package/dist/components/Business/BsLayouts/index.d.ts +18 -0
- package/dist/components/Business/BsLayouts/service.d.ts +1 -0
- package/dist/components/Business/BsLayouts/utils.d.ts +13 -0
- package/dist/components/Business/BsSulaQueryTable/index.d.ts +2 -0
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +58 -0
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +98 -0
- package/dist/components/Business/CommonAlert/index.d.ts +3 -0
- package/dist/components/Business/CommonGuideWrapper/index.d.ts +6 -0
- package/dist/components/Business/DetailPageWrapper/index.d.ts +9 -0
- package/dist/components/Business/DetailPageWrapper/utils.d.ts +8 -0
- package/dist/components/Business/HomePageWrapper/index.d.ts +3 -0
- package/dist/components/Business/SearchSelect/BusinessUtils.d.ts +1 -1
- package/dist/components/Business/SearchSelect/common.d.ts +5 -1
- package/dist/components/Business/SearchSelect/index.d.ts +1 -1
- package/dist/components/Business/SearchSelect/utils.d.ts +2 -1
- package/dist/components/Business/StateFlow/index.d.ts +3 -0
- package/dist/components/Business/TreeSearchSelect/index.d.ts +3 -0
- package/dist/components/Business/TreeSearchSelect/utils.d.ts +2 -0
- package/dist/components/Business/columnSettingTable/columnSetting.d.ts +54 -0
- package/dist/components/Business/columnSettingTable/index.d.ts +16 -0
- package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +17 -0
- package/dist/components/Business/columnSettingTable/utils.d.ts +8 -0
- package/dist/components/Functional/AddSelect/index.d.ts +3 -0
- package/dist/components/Functional/BillEntry/index.d.ts +4 -0
- package/dist/components/Functional/{DataValidation/DataImport.d.ts → DataImport/index.d.ts} +2 -2
- package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +12 -0
- package/dist/components/Functional/SearchSelect/index.d.ts +2 -1
- package/dist/components/Functional/TreeSearchSelect/index.d.ts +2 -0
- package/dist/index.d.ts +16 -1
- package/dist/index.esm.js +19315 -4349
- package/dist/index.js +19459 -4476
- package/dist/utils/CheckOneUser/index.d.ts +1 -1
- package/dist/utils/enumConfig.d.ts +10 -0
- package/dist/utils/requestUtils.d.ts +1 -0
- package/dist/utils/utils.d.ts +3 -0
- package/lib/assets/arrow_top.png +0 -0
- package/lib/assets/drag.svg +17 -0
- package/lib/assets/exportFail.svg +38 -0
- package/lib/assets/exportProcessing.svg +29 -0
- package/lib/assets/exportSuccess.svg +35 -0
- package/lib/assets/exportlogo.png +0 -0
- package/lib/assets/label_icon_bottom.svg +26 -0
- package/lib/assets/upExport.svg +23 -0
- package/package.json +26 -5
- package/src/assets/32.svg +28 -0
- package/src/assets/addIcon.svg +18 -0
- package/src/assets/allfunc.svg +28 -0
- package/src/assets/arrowRight.svg +25 -0
- package/src/assets/arrow_top.png +0 -0
- package/src/assets/btn-delete.svg +30 -0
- package/src/assets/btn-edit.svg +20 -0
- package/src/assets/btn-more.svg +18 -0
- package/src/assets/btn-submit.svg +20 -0
- package/src/assets/caidan.svg +12 -0
- package/src/assets/close.svg +26 -0
- package/src/assets/closeicon.png +0 -0
- package/src/assets/drag.svg +17 -0
- package/src/assets/exportFail.svg +38 -0
- package/src/assets/exportProcessing.svg +29 -0
- package/src/assets/exportSuccess.svg +35 -0
- package/src/assets/exportlogo.png +0 -0
- package/src/assets/fixed-left-active.svg +12 -0
- package/src/assets/fixed-left.svg +16 -0
- package/src/assets/fixed-right-active.svg +12 -0
- package/src/assets/fixed-right.svg +16 -0
- package/src/assets/guanbi.svg +16 -0
- package/src/assets/icon-quanping.svg +16 -0
- package/src/assets/icon-shezhi.svg +18 -0
- package/src/assets/label_icon_bottom.svg +26 -0
- package/src/assets/list-no-img.svg +22 -0
- package/src/assets/morentouxiang-32.svg +24 -0
- package/src/assets/right.png +0 -0
- package/src/assets/scanning.svg +25 -0
- package/src/assets/upExport.svg +23 -0
- package/src/assets/xinglan-icon-out.png +0 -0
- package/src/components/Business/AddSelectBusiness/index.md +41 -0
- package/src/components/Business/AddSelectBusiness/index.tsx +290 -0
- package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -0
- package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -0
- package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +38 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +243 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +385 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +286 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +75 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +171 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +65 -0
- package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +154 -0
- package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +73 -0
- package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +158 -0
- package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -0
- package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -0
- package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -0
- package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +161 -0
- package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +76 -0
- package/src/components/Business/BsLayouts/index.less +80 -0
- package/src/components/Business/BsLayouts/index.tsx +1465 -0
- package/src/components/Business/BsLayouts/service.ts +11 -0
- package/src/components/Business/BsLayouts/utils.tsx +211 -0
- package/src/components/Business/BsSulaQueryTable/index.less +220 -0
- package/src/components/Business/BsSulaQueryTable/index.tsx +505 -0
- package/src/components/Business/BsSulaQueryTable/setting.tsx +799 -0
- package/src/components/Business/BsSulaQueryTable/utils.less +65 -0
- package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -0
- package/src/components/Business/CommodityEntry/index.md +4 -3
- package/src/components/Business/CommodityEntry/index.tsx +7 -2
- package/src/components/Business/CommonAlert/index.less +0 -0
- package/src/components/Business/CommonAlert/index.tsx +23 -0
- package/src/components/Business/CommonGuideWrapper/index.less +112 -0
- package/src/components/Business/CommonGuideWrapper/index.md +39 -0
- package/src/components/Business/CommonGuideWrapper/index.tsx +84 -0
- package/src/components/Business/DetailPageWrapper/index.less +80 -0
- package/src/components/Business/DetailPageWrapper/index.tsx +335 -0
- package/src/components/Business/DetailPageWrapper/utils.tsx +101 -0
- package/src/components/Business/HomePageWrapper/index.less +33 -0
- package/src/components/Business/HomePageWrapper/index.md +45 -0
- package/src/components/Business/HomePageWrapper/index.tsx +162 -0
- package/src/components/Business/SearchSelect/BusinessUtils.ts +107 -14
- package/src/components/Business/SearchSelect/common.ts +20 -1
- package/src/components/Business/SearchSelect/index.md +60 -30
- package/src/components/Business/SearchSelect/index.tsx +21 -12
- package/src/components/Business/SearchSelect/utils.ts +30 -4
- package/src/components/Business/StateFlow/index.less +131 -0
- package/src/components/Business/StateFlow/index.md +60 -0
- package/src/components/Business/StateFlow/index.tsx +30 -0
- package/src/components/Business/TreeSearchSelect/index.md +126 -0
- package/src/components/Business/TreeSearchSelect/index.tsx +34 -0
- package/src/components/Business/TreeSearchSelect/utils.ts +60 -0
- package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -0
- package/src/components/Business/columnSettingTable/index.less +247 -0
- package/src/components/Business/columnSettingTable/index.md +358 -0
- package/src/components/Business/columnSettingTable/index.tsx +233 -0
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +241 -0
- package/src/components/Business/columnSettingTable/utils.tsx +69 -0
- package/src/components/Functional/AddSelect/index.less +367 -0
- package/src/components/Functional/AddSelect/index.md +122 -0
- package/src/components/Functional/AddSelect/index.tsx +962 -0
- package/src/components/Functional/BillEntry/index.less +371 -0
- package/src/components/Functional/BillEntry/index.md +39 -0
- package/src/components/Functional/BillEntry/index.tsx +613 -0
- package/src/components/Functional/DataImport/index.less +63 -0
- package/src/components/Functional/DataImport/index.md +44 -0
- package/src/components/Functional/{DataValidation/DataImport.tsx → DataImport/index.tsx} +10 -5
- package/src/components/Functional/DataValidation/index.md +1 -0
- package/src/components/Functional/DataValidation/index.tsx +17 -2
- package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -0
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -0
- package/src/components/Functional/SearchSelect/index.tsx +218 -121
- package/src/components/Functional/TreeSearchSelect/index.md +47 -0
- package/src/components/Functional/TreeSearchSelect/index.tsx +149 -0
- package/src/index.ts +16 -7
- package/src/styles/bsDefault.less +1907 -0
- package/src/utils/enumConfig.ts +10 -0
- package/src/utils/requestUtils.ts +33 -0
- package/src/utils/utils.ts +52 -0
- package/typings.d.ts +3 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
forwardRef,
|
|
4
|
+
useImperativeHandle
|
|
5
|
+
} from "react";
|
|
6
|
+
import './index.less';
|
|
7
|
+
import LeftTree from "./leftTree";
|
|
8
|
+
import RightTree from "./rightTree";
|
|
9
|
+
|
|
10
|
+
const MenuSetting = forwardRef(({actionRef, originRoutes, itemPath}: any, ref) => {
|
|
11
|
+
|
|
12
|
+
const [customerMenuData, setCustomerMenuData] = useState(
|
|
13
|
+
JSON.parse( localStorage.getItem(`customerMenu_${itemPath}_front`) || '[]')
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
useImperativeHandle(ref, () => ({
|
|
17
|
+
saveMenuData: () => {
|
|
18
|
+
localStorage.setItem(`customerMenu_${itemPath}_front`, JSON.stringify(customerMenuData));
|
|
19
|
+
actionRef.current?.reload();
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className={'setting_content'}>
|
|
25
|
+
<LeftTree
|
|
26
|
+
originRoutes={originRoutes}
|
|
27
|
+
customerMenuData={customerMenuData}
|
|
28
|
+
setCustomerMenuData={setCustomerMenuData}
|
|
29
|
+
/>
|
|
30
|
+
<RightTree
|
|
31
|
+
customerMenuData={customerMenuData}
|
|
32
|
+
setCustomerMenuData={setCustomerMenuData}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export default MenuSetting;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Tree, Input, Tooltip, message } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import './index.less';
|
|
5
|
+
import {
|
|
6
|
+
SearchOutlined,
|
|
7
|
+
FolderOutlined,
|
|
8
|
+
} from '@ant-design/icons';
|
|
9
|
+
import arrowRight from '../../../../../../assets/arrowRight.svg';
|
|
10
|
+
import {
|
|
11
|
+
setMenuTreeData,
|
|
12
|
+
} from '../../../utils';
|
|
13
|
+
import { memoizeOneFormatter } from '@/utils/utils';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const { TreeNode } = Tree;
|
|
17
|
+
const { Search } = Input;
|
|
18
|
+
|
|
19
|
+
const dataList: any[] = [];
|
|
20
|
+
const generateList = data => {
|
|
21
|
+
for (let i = 0; i < data.length; i++) {
|
|
22
|
+
const node = data[i];
|
|
23
|
+
const { path, name } = node;
|
|
24
|
+
dataList.push({ path, name });
|
|
25
|
+
if (node.children) {
|
|
26
|
+
generateList(node.children);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const getParentKey = (path, tree) => {
|
|
33
|
+
let parentKey;
|
|
34
|
+
for (let i = 0; i < tree.length; i++) {
|
|
35
|
+
const node = tree[i];
|
|
36
|
+
if (node.children) {
|
|
37
|
+
if (node.children.some(item => item.path === path)) {
|
|
38
|
+
parentKey = node.path;
|
|
39
|
+
} else if (getParentKey(path, node.children)) {
|
|
40
|
+
parentKey = getParentKey(path, node.children);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return parentKey;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
class LeftTree extends React.Component<any> {
|
|
48
|
+
state = {
|
|
49
|
+
treeData: [],
|
|
50
|
+
expandedKeys: [],
|
|
51
|
+
searchValue: '',
|
|
52
|
+
autoExpandParent: true,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
componentDidMount() {
|
|
57
|
+
const {originRoutes = [] } = this.props;
|
|
58
|
+
const showMenu = originRoutes.find(item => item.path === '/')?.routes || [];
|
|
59
|
+
let routesData = JSON.parse(JSON.stringify(memoizeOneFormatter(showMenu, '')));
|
|
60
|
+
setMenuTreeData(routesData);
|
|
61
|
+
generateList(routesData);
|
|
62
|
+
|
|
63
|
+
this.setState({
|
|
64
|
+
treeData: routesData
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
onExpand = expandedKeys => {
|
|
70
|
+
this.setState({
|
|
71
|
+
expandedKeys,
|
|
72
|
+
autoExpandParent: false,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
onChange = e => {
|
|
77
|
+
const { value } = e.target;
|
|
78
|
+
const { treeData } = this.state;
|
|
79
|
+
const expandedKeys = dataList
|
|
80
|
+
.map(item => {
|
|
81
|
+
if (item.name.indexOf(value) > -1) {
|
|
82
|
+
return getParentKey(item.path, treeData);
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
})
|
|
86
|
+
.filter((item, i, self) => item && self.indexOf(item) === i);
|
|
87
|
+
this.setState({
|
|
88
|
+
expandedKeys,
|
|
89
|
+
searchValue: value,
|
|
90
|
+
autoExpandParent: true,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
getPathList = (originData: any): Array<any> => {
|
|
95
|
+
let pathList: Array<any> = [];
|
|
96
|
+
const getList = (data) => {
|
|
97
|
+
if (Array.isArray(data)) {
|
|
98
|
+
data.forEach(item => {
|
|
99
|
+
pathList.push(item.path);
|
|
100
|
+
if (item.children) {
|
|
101
|
+
getList(item.children)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
} else {
|
|
105
|
+
pathList.push(data.path);
|
|
106
|
+
if (data.children) {
|
|
107
|
+
getList(data.children);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
getList(originData);
|
|
112
|
+
return pathList;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
handleAdd2Menu = (path: string) => {
|
|
117
|
+
const { treeData } = this.state;
|
|
118
|
+
const { customerMenuData, setCustomerMenuData } = this.props;
|
|
119
|
+
let filterItem;
|
|
120
|
+
const filterMenuItem = (menuData: Array<any>) => {
|
|
121
|
+
menuData.forEach(item => {
|
|
122
|
+
if (item.path === path) {
|
|
123
|
+
filterItem = { ...item };
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (item.children) {
|
|
127
|
+
filterMenuItem(item.children);
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
filterMenuItem(treeData);
|
|
132
|
+
let addPathList = this.getPathList(filterItem);
|
|
133
|
+
let oldPathList = this.getPathList(customerMenuData);
|
|
134
|
+
let isRepet = false;
|
|
135
|
+
oldPathList.forEach(oldPath => {
|
|
136
|
+
if (addPathList.find(newPath => newPath === oldPath)) {
|
|
137
|
+
isRepet = true;
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
if (isRepet) {
|
|
141
|
+
message.warning('存在已经添加的菜单,请检查!');
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
setCustomerMenuData([
|
|
145
|
+
...customerMenuData,
|
|
146
|
+
filterItem
|
|
147
|
+
])
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
render() {
|
|
152
|
+
const { searchValue, expandedKeys, autoExpandParent, treeData } = this.state;
|
|
153
|
+
const loop = data =>
|
|
154
|
+
data.map(item => {
|
|
155
|
+
const index = item.name.indexOf(searchValue);
|
|
156
|
+
const beforeStr = item.name.substr(0, index);
|
|
157
|
+
const afterStr = item.name.substr(index + searchValue.length);
|
|
158
|
+
const name =
|
|
159
|
+
index > -1 ? (
|
|
160
|
+
<span>
|
|
161
|
+
{beforeStr}
|
|
162
|
+
<span style={{ color: '#f50' }}>{searchValue}</span>
|
|
163
|
+
{afterStr}
|
|
164
|
+
</span>
|
|
165
|
+
) : (
|
|
166
|
+
<span>{item.name}</span>
|
|
167
|
+
);
|
|
168
|
+
if (item.children && item.children.length) {
|
|
169
|
+
return (
|
|
170
|
+
<TreeNode
|
|
171
|
+
path={item.path}
|
|
172
|
+
icon={<FolderOutlined />}
|
|
173
|
+
name={<div className={'node_title_content'}>
|
|
174
|
+
<span>{name}</span>
|
|
175
|
+
<div
|
|
176
|
+
className={'right_arrow'}
|
|
177
|
+
onClick={() => {
|
|
178
|
+
this.handleAdd2Menu(item.path);
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<Tooltip placement="topRight" title={'单击加入自定义菜单'}>
|
|
182
|
+
<img style={{ marginTop: '-3px' }} width={18} src={arrowRight} />
|
|
183
|
+
</Tooltip>
|
|
184
|
+
</div>
|
|
185
|
+
</div>}
|
|
186
|
+
>
|
|
187
|
+
{loop(item.children)}
|
|
188
|
+
</TreeNode>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
return <TreeNode
|
|
192
|
+
path={item.path}
|
|
193
|
+
// icon={<FileOutlined />}
|
|
194
|
+
name={<div className={'node_title_content'}>
|
|
195
|
+
<span>{name}</span>
|
|
196
|
+
<div
|
|
197
|
+
className={'right_arrow'}
|
|
198
|
+
onClick={() => {
|
|
199
|
+
this.handleAdd2Menu(item.path);
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<Tooltip placement="topRight" title={'单击加入自定义菜单'}>
|
|
203
|
+
<img style={{ marginTop: '-3px' }} width={18} src={arrowRight} />
|
|
204
|
+
</Tooltip>
|
|
205
|
+
</div>
|
|
206
|
+
</div>}
|
|
207
|
+
/>;
|
|
208
|
+
});
|
|
209
|
+
return (
|
|
210
|
+
<div className={'left_tree_content'}>
|
|
211
|
+
<div className={'tree_title'}>
|
|
212
|
+
<div>菜单列表(选中菜单,可快速设置)</div>
|
|
213
|
+
<Input
|
|
214
|
+
style={{ marginBottom: 8 }}
|
|
215
|
+
placeholder="请搜索"
|
|
216
|
+
allowClear
|
|
217
|
+
|
|
218
|
+
prefix={<SearchOutlined />}
|
|
219
|
+
onChange={this.onChange}
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
<div className={'tree_content'}>
|
|
223
|
+
<Tree
|
|
224
|
+
showIcon
|
|
225
|
+
showLine={true}
|
|
226
|
+
fieldNames={{
|
|
227
|
+
title: 'name',
|
|
228
|
+
key: 'path',
|
|
229
|
+
children: 'children'
|
|
230
|
+
}}
|
|
231
|
+
onExpand={this.onExpand}
|
|
232
|
+
expandedKeys={expandedKeys}
|
|
233
|
+
autoExpandParent={autoExpandParent}
|
|
234
|
+
>
|
|
235
|
+
{loop(treeData)}
|
|
236
|
+
</Tree>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export default LeftTree;
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { Tree, Button, Modal, Form, Row, Col, message, Input, Menu, Dropdown, Space } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { FormInstance } from 'antd/es/form';
|
|
5
|
+
import {
|
|
6
|
+
EllipsisOutlined,
|
|
7
|
+
FolderOutlined,
|
|
8
|
+
} from '@ant-design/icons';
|
|
9
|
+
import './index.less';
|
|
10
|
+
|
|
11
|
+
const { TreeNode } = Tree;
|
|
12
|
+
|
|
13
|
+
class rightTree extends React.Component<any> {
|
|
14
|
+
formRef = React.createRef<FormInstance>();
|
|
15
|
+
constructor(props: any) {
|
|
16
|
+
super(props)
|
|
17
|
+
}
|
|
18
|
+
state = {
|
|
19
|
+
// treeData: [],
|
|
20
|
+
expandedKeys: ['0-0', '0-0-0', '0-0-0-0'],
|
|
21
|
+
checkedKeys: [],
|
|
22
|
+
modalInfo: {
|
|
23
|
+
modalVisible: false,
|
|
24
|
+
type: 'create',
|
|
25
|
+
title: '',
|
|
26
|
+
callBack: null,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
onDragEnter = info => {
|
|
31
|
+
// console.log(info);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
onDrop = info => {
|
|
35
|
+
const dropKey = info.node.path;
|
|
36
|
+
const dragKey = info.dragNode.path;
|
|
37
|
+
const dropPos = info.node.pos.split('-');
|
|
38
|
+
const dropPosition = info.dropPosition - Number(dropPos[dropPos.length - 1]);
|
|
39
|
+
|
|
40
|
+
let dragObj;
|
|
41
|
+
let finalDropItem;
|
|
42
|
+
const loop = (data, path, callback) => {
|
|
43
|
+
for (let i = 0; i < data.length; i++) {
|
|
44
|
+
if (data[i].path === path) {
|
|
45
|
+
return callback(data[i], i, data);
|
|
46
|
+
}
|
|
47
|
+
if (data[i].children) {
|
|
48
|
+
loop(data[i].children, path, callback);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const data = JSON.parse(JSON.stringify(this.props.customerMenuData));
|
|
53
|
+
|
|
54
|
+
loop(data, dragKey, (item, index, arr) => {
|
|
55
|
+
arr.splice(index, 1);
|
|
56
|
+
dragObj = item;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (!info.dropToGap) {
|
|
60
|
+
// Drop on the content
|
|
61
|
+
loop(data, dropKey, item => {
|
|
62
|
+
item.children = item.children || [];
|
|
63
|
+
item.children.unshift(dragObj);
|
|
64
|
+
finalDropItem = {
|
|
65
|
+
...item
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
} else if (
|
|
69
|
+
(info.node.props.children || []).length > 0 && // Has children
|
|
70
|
+
info.node.props.expanded && // Is expanded
|
|
71
|
+
dropPosition === 1 // On the bottom gap
|
|
72
|
+
) {
|
|
73
|
+
loop(data, dropKey, item => {
|
|
74
|
+
item.children = item.children || [];
|
|
75
|
+
item.children.unshift(dragObj);
|
|
76
|
+
finalDropItem = {
|
|
77
|
+
...item
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
let ar;
|
|
82
|
+
let i;
|
|
83
|
+
loop(data, dropKey, (item, index, arr) => {
|
|
84
|
+
ar = arr;
|
|
85
|
+
i = index;
|
|
86
|
+
});
|
|
87
|
+
if (dropPosition === -1) {
|
|
88
|
+
ar.splice(i, 0, dragObj);
|
|
89
|
+
} else {
|
|
90
|
+
ar.splice(i + 1, 0, dragObj);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (finalDropItem && finalDropItem.component) {
|
|
94
|
+
message.warning('页面菜单不可存放其他其他菜单。');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.props.setCustomerMenuData([...data]);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
handleSubmit = () => {
|
|
101
|
+
|
|
102
|
+
const {
|
|
103
|
+
modalInfo: { callBack },
|
|
104
|
+
} = this.state;
|
|
105
|
+
this.formRef?.current?.validateFields()
|
|
106
|
+
.then(values => {
|
|
107
|
+
callBack && callBack(values.name);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
handleModalClose = () => {
|
|
113
|
+
this.setState({
|
|
114
|
+
modalInfo: {
|
|
115
|
+
modalVisible: false
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
handleEditTreeNode = (e, item) => {
|
|
121
|
+
const { modalInfo } = this.state;
|
|
122
|
+
const { customerMenuData } = this.props;
|
|
123
|
+
this.setState({
|
|
124
|
+
modalInfo: {
|
|
125
|
+
...modalInfo,
|
|
126
|
+
modalVisible: true,
|
|
127
|
+
title: '编辑名称',
|
|
128
|
+
callBack: (newName: string) => {
|
|
129
|
+
let oldTreeData = JSON.parse(JSON.stringify(customerMenuData));
|
|
130
|
+
const editTreeDataName = (oldTreeData: Array<any>) => {
|
|
131
|
+
oldTreeData.forEach(treeItem => {
|
|
132
|
+
if (treeItem.path === item.path) {
|
|
133
|
+
treeItem.name = newName;
|
|
134
|
+
}
|
|
135
|
+
if (treeItem.children) {
|
|
136
|
+
editTreeDataName(treeItem.children);
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
editTreeDataName(oldTreeData);
|
|
141
|
+
this.props.setCustomerMenuData([...oldTreeData]);
|
|
142
|
+
this.setState({
|
|
143
|
+
modalInfo: {
|
|
144
|
+
modalVisible: false
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
deleteNode = (oldTreeData: any[], path: string) => {
|
|
154
|
+
oldTreeData.forEach((node, index) => {
|
|
155
|
+
if (node.path === path) {
|
|
156
|
+
oldTreeData.splice(index, 1);
|
|
157
|
+
}
|
|
158
|
+
if (node.children) {
|
|
159
|
+
this.deleteNode(node.children, path)
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
handleDeleteTreeNode = (e, item) => {
|
|
165
|
+
const { customerMenuData } = this.props;
|
|
166
|
+
let oldTreeData = JSON.parse(JSON.stringify(customerMenuData));
|
|
167
|
+
this.deleteNode(oldTreeData, item.path);
|
|
168
|
+
this.props.setCustomerMenuData([...oldTreeData]);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
handleBatchDelete = () => {
|
|
173
|
+
const { checkedKeys } = this.state;
|
|
174
|
+
const { customerMenuData } = this.props;
|
|
175
|
+
let oldTreeData = JSON.parse(JSON.stringify(customerMenuData));
|
|
176
|
+
checkedKeys.forEach(key => {
|
|
177
|
+
this.deleteNode(oldTreeData, key);
|
|
178
|
+
})
|
|
179
|
+
this.props.setCustomerMenuData([...oldTreeData]);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
handleAddTreeNode = (e, item) => {
|
|
183
|
+
const { modalInfo } = this.state;
|
|
184
|
+
const { customerMenuData } = this.props;
|
|
185
|
+
this.setState({
|
|
186
|
+
modalInfo: {
|
|
187
|
+
...modalInfo,
|
|
188
|
+
modalVisible: true,
|
|
189
|
+
title: '新增子目录',
|
|
190
|
+
callBack: (newName: string) => {
|
|
191
|
+
let oldTreeData = JSON.parse(JSON.stringify(customerMenuData));
|
|
192
|
+
const addChildFolder = (oldTreeData: Array<any>) => {
|
|
193
|
+
oldTreeData.forEach(treeItem => {
|
|
194
|
+
if (treeItem.path === item.path) {
|
|
195
|
+
treeItem.children ?
|
|
196
|
+
treeItem.children.push({
|
|
197
|
+
path: Math.random() + 'folder',
|
|
198
|
+
name: newName,
|
|
199
|
+
}) :
|
|
200
|
+
treeItem.children = [{
|
|
201
|
+
path: Math.random() + 'folder',
|
|
202
|
+
name: newName,
|
|
203
|
+
}]
|
|
204
|
+
}
|
|
205
|
+
if (treeItem.children) {
|
|
206
|
+
addChildFolder(treeItem.children);
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
addChildFolder(oldTreeData);
|
|
211
|
+
this.props.setCustomerMenuData([...oldTreeData]);
|
|
212
|
+
this.setState({
|
|
213
|
+
modalInfo: {
|
|
214
|
+
modalVisible: false
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
onCheck = (checkedKeysValue: React.Key[]) => {
|
|
223
|
+
this.setState({
|
|
224
|
+
checkedKeys: checkedKeysValue
|
|
225
|
+
})
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
getChildMenu = (item: any) => {
|
|
229
|
+
|
|
230
|
+
let items = [
|
|
231
|
+
{
|
|
232
|
+
label: <Button type='link' onClick={(e) => { this.handleAddTreeNode(e, item) }} >新建文件夹</Button>,
|
|
233
|
+
key: '0',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
label: <Button type='link' onClick={(e) => { this.handleEditTreeNode(e, item) }} >重命名</Button>,
|
|
237
|
+
key: '1',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
label: <Button type='link' onClick={(e) => { this.handleDeleteTreeNode(e, item) }} >删除</Button>,
|
|
241
|
+
key: '2',
|
|
242
|
+
},
|
|
243
|
+
];
|
|
244
|
+
if (item && item.component) {
|
|
245
|
+
items.shift();
|
|
246
|
+
}
|
|
247
|
+
return (
|
|
248
|
+
<Menu
|
|
249
|
+
items={items}
|
|
250
|
+
/>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
render() {
|
|
254
|
+
const { modalInfo, checkedKeys } = this.state;
|
|
255
|
+
const loop = data =>
|
|
256
|
+
data.map(item => {
|
|
257
|
+
if (item.children && item.children.length) {
|
|
258
|
+
return (
|
|
259
|
+
<TreeNode
|
|
260
|
+
path={item.path}
|
|
261
|
+
icon={<FolderOutlined />}
|
|
262
|
+
name={<>
|
|
263
|
+
<span>{item.name}</span>
|
|
264
|
+
<span className={'tree_node_title'}>
|
|
265
|
+
<Dropdown overlay={this.getChildMenu(item)} trigger={['click']}>
|
|
266
|
+
<a onClick={e => { e.preventDefault(); e.stopPropagation();}}>
|
|
267
|
+
<Space>
|
|
268
|
+
<EllipsisOutlined />
|
|
269
|
+
</Space>
|
|
270
|
+
</a>
|
|
271
|
+
</Dropdown>
|
|
272
|
+
</span>
|
|
273
|
+
</>}
|
|
274
|
+
>
|
|
275
|
+
{loop(item.children)}
|
|
276
|
+
</TreeNode>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
return <TreeNode
|
|
280
|
+
path={item.path}
|
|
281
|
+
name={<>
|
|
282
|
+
<span>{item.name}</span>
|
|
283
|
+
<span className={'tree_node_title'}>
|
|
284
|
+
<Dropdown overlay={this.getChildMenu(item)} trigger={['click']}>
|
|
285
|
+
<a onClick={e => { e.preventDefault(); e.stopPropagation();}}>
|
|
286
|
+
<Space>
|
|
287
|
+
<EllipsisOutlined />
|
|
288
|
+
</Space>
|
|
289
|
+
</a>
|
|
290
|
+
</Dropdown>
|
|
291
|
+
</span>
|
|
292
|
+
</>}
|
|
293
|
+
/>;
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<div>
|
|
298
|
+
<div className={'tree_title'}>
|
|
299
|
+
<div>已设置自定义菜单(可拖动排序)</div>
|
|
300
|
+
<div style={{ overflow: 'hidden' }}>
|
|
301
|
+
<Button
|
|
302
|
+
disabled={checkedKeys.length ? false : true}
|
|
303
|
+
onClick={this.handleBatchDelete}
|
|
304
|
+
style={{ float: 'right', marginLeft: '10px' }}
|
|
305
|
+
>删除</Button>
|
|
306
|
+
<Button
|
|
307
|
+
type='primary'
|
|
308
|
+
ghost
|
|
309
|
+
style={{ float: 'right' }}
|
|
310
|
+
onClick={() => {
|
|
311
|
+
this.setState({
|
|
312
|
+
modalInfo: {
|
|
313
|
+
modalVisible: true,
|
|
314
|
+
type: 'create',
|
|
315
|
+
title: '新增一级目录',
|
|
316
|
+
callBack: (name: string) => {
|
|
317
|
+
const { modalInfo } = this.state;
|
|
318
|
+
const { customerMenuData } = this.props;
|
|
319
|
+
let newMenu = {
|
|
320
|
+
path: Math.random() + 'folder',
|
|
321
|
+
name: name,
|
|
322
|
+
};
|
|
323
|
+
this.props.setCustomerMenuData([...customerMenuData, newMenu]);
|
|
324
|
+
this.setState({
|
|
325
|
+
modalInfo: {
|
|
326
|
+
...modalInfo,
|
|
327
|
+
modalVisible: false
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
})
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
新建
|
|
336
|
+
</Button>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
<div className={`${'tree_content'} ${'right_tree_content'}`}>
|
|
340
|
+
<Tree
|
|
341
|
+
className="draggable-tree"
|
|
342
|
+
showIcon
|
|
343
|
+
showLine={true}
|
|
344
|
+
defaultExpandedKeys={this.state.expandedKeys}
|
|
345
|
+
draggable
|
|
346
|
+
blockNode
|
|
347
|
+
onDragEnter={this.onDragEnter}
|
|
348
|
+
checkable
|
|
349
|
+
onCheck={this.onCheck}
|
|
350
|
+
checkedKeys={checkedKeys}
|
|
351
|
+
fieldNames={{
|
|
352
|
+
title: 'name',
|
|
353
|
+
key: 'path',
|
|
354
|
+
children: 'children'
|
|
355
|
+
}}
|
|
356
|
+
onDrop={this.onDrop}
|
|
357
|
+
>
|
|
358
|
+
{loop(this.props.customerMenuData)}
|
|
359
|
+
</Tree>
|
|
360
|
+
</div>
|
|
361
|
+
<Modal
|
|
362
|
+
width={600}
|
|
363
|
+
bodyStyle={{ paddingTop: '32px', backgroundColor: '#F7F7F7' }}
|
|
364
|
+
destroyOnClose
|
|
365
|
+
title={modalInfo.title || ''}
|
|
366
|
+
visible={modalInfo.modalVisible}
|
|
367
|
+
onOk={this.handleSubmit}
|
|
368
|
+
onCancel={this.handleModalClose}
|
|
369
|
+
>
|
|
370
|
+
<Form ref={this.formRef}>
|
|
371
|
+
<Row>
|
|
372
|
+
<Col span={24}>
|
|
373
|
+
<Form.Item name='name' label="名称">
|
|
374
|
+
<Input style={{ width: '200px' }} />
|
|
375
|
+
</Form.Item>
|
|
376
|
+
</Col>
|
|
377
|
+
</Row>
|
|
378
|
+
</Form>
|
|
379
|
+
</Modal>
|
|
380
|
+
</div>
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export default rightTree;
|