@bit-sun/business-component 2.0.37 → 2.0.39-alpha.0
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/.editorconfig +16 -16
- package/.fatherrc.ts +5 -4
- package/.gitlab-ci.yml +174 -174
- package/.prettierignore +7 -7
- package/.prettierrc +11 -11
- package/.umirc.ts +77 -74
- package/README.md +27 -27
- 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 +22 -0
- package/dist/components/Business/DetailPageWrapper/utils.d.ts +1 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +11703 -44
- package/dist/index.js +11678 -11
- package/dist/utils/enumConfig.d.ts +10 -0
- package/dist/utils/utils.d.ts +2 -1
- package/docs/index.md +21 -21
- package/lib/assets/drag.svg +17 -17
- package/lib/assets/exportFail.svg +37 -37
- package/lib/assets/exportProcessing.svg +28 -28
- package/lib/assets/exportSuccess.svg +34 -34
- package/lib/assets/label_icon_bottom.svg +25 -25
- package/lib/assets/upExport.svg +22 -22
- package/package.json +70 -66
- 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/btn-delete.svg +29 -29
- package/src/assets/btn-edit.svg +19 -19
- package/src/assets/btn-more.svg +17 -17
- package/src/assets/btn-submit.svg +19 -19
- package/src/assets/caidan.svg +12 -0
- package/src/assets/close.svg +26 -26
- package/src/assets/closeicon.png +0 -0
- package/src/assets/drag.svg +17 -17
- package/src/assets/exportFail.svg +37 -37
- package/src/assets/exportProcessing.svg +28 -28
- package/src/assets/exportSuccess.svg +34 -34
- package/src/assets/fixed-left-active.svg +11 -11
- package/src/assets/fixed-left.svg +15 -15
- package/src/assets/fixed-right-active.svg +11 -11
- package/src/assets/fixed-right.svg +15 -15
- package/src/assets/guanbi.svg +16 -0
- package/src/assets/icon-quanping.svg +15 -15
- package/src/assets/icon-shezhi.svg +17 -17
- package/src/assets/label_icon_bottom.svg +25 -25
- package/src/assets/morentouxiang-32.svg +24 -0
- package/src/assets/right.png +0 -0
- package/src/assets/scanning.svg +24 -24
- package/src/assets/upExport.svg +22 -22
- package/src/assets/xinglan-icon-out.png +0 -0
- package/src/components/Business/AddSelectBusiness/index.md +41 -41
- package/src/components/Business/AddSelectBusiness/index.tsx +290 -290
- 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 +162 -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 +1495 -0
- package/src/components/Business/BsLayouts/service.ts +11 -0
- package/src/components/Business/BsLayouts/utils.tsx +350 -0
- package/src/components/Business/BsSulaQueryTable/index.less +219 -219
- package/src/components/Business/BsSulaQueryTable/index.tsx +535 -534
- package/src/components/Business/BsSulaQueryTable/setting.tsx +818 -817
- package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
- package/src/components/Business/BsSulaQueryTable/utils.tsx +691 -690
- package/src/components/Business/CommodityEntry/index.md +70 -70
- package/src/components/Business/CommodityEntry/index.tsx +80 -80
- package/src/components/Business/CommonAlert/index.tsx +23 -23
- package/src/components/Business/CommonGuideWrapper/index.less +111 -111
- package/src/components/Business/CommonGuideWrapper/index.md +39 -39
- package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
- package/src/components/Business/DetailPageWrapper/index.less +79 -79
- package/src/components/Business/DetailPageWrapper/index.tsx +335 -324
- package/src/components/Business/DetailPageWrapper/utils.tsx +101 -111
- package/src/components/Business/HomePageWrapper/index.less +33 -33
- package/src/components/Business/HomePageWrapper/index.md +45 -45
- package/src/components/Business/HomePageWrapper/index.tsx +162 -150
- package/src/components/Business/SearchSelect/BusinessUtils.ts +1458 -1457
- package/src/components/Business/SearchSelect/common.ts +53 -53
- package/src/components/Business/SearchSelect/index.md +1137 -1137
- package/src/components/Business/SearchSelect/index.tsx +51 -51
- package/src/components/Business/SearchSelect/utils.ts +100 -99
- package/src/components/Business/StateFlow/index.less +130 -130
- package/src/components/Business/StateFlow/index.md +60 -60
- package/src/components/Business/StateFlow/index.tsx +29 -29
- package/src/components/Business/TreeSearchSelect/index.md +126 -126
- package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
- package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
- package/src/components/Business/columnSettingTable/columnSetting.tsx +763 -762
- package/src/components/Business/columnSettingTable/index.less +247 -247
- package/src/components/Business/columnSettingTable/index.md +357 -357
- package/src/components/Business/columnSettingTable/index.tsx +226 -225
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +234 -233
- package/src/components/Business/columnSettingTable/utils.tsx +68 -68
- package/src/components/Functional/AddSelect/index.less +367 -367
- package/src/components/Functional/AddSelect/index.md +122 -122
- package/src/components/Functional/AddSelect/index.tsx +962 -962
- package/src/components/Functional/BillEntry/index.less +371 -371
- package/src/components/Functional/BillEntry/index.md +39 -39
- package/src/components/Functional/BillEntry/index.tsx +613 -607
- package/src/components/Functional/DataImport/index.less +63 -63
- package/src/components/Functional/DataImport/index.md +44 -44
- package/src/components/Functional/DataImport/index.tsx +689 -689
- package/src/components/Functional/DataValidation/index.less +63 -63
- package/src/components/Functional/DataValidation/index.md +38 -38
- package/src/components/Functional/DataValidation/index.tsx +681 -681
- package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
- package/src/components/Functional/QueryMutipleInput/index.less +37 -37
- package/src/components/Functional/QueryMutipleInput/index.md +33 -33
- package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
- package/src/components/Functional/SearchSelect/index.less +115 -115
- package/src/components/Functional/SearchSelect/index.md +141 -141
- package/src/components/Functional/SearchSelect/index.tsx +812 -812
- package/src/components/Functional/TreeSearchSelect/index.md +47 -47
- package/src/components/Functional/TreeSearchSelect/index.tsx +149 -149
- package/src/index.ts +31 -30
- package/src/utils/CheckOneUser/index.md +39 -39
- package/src/utils/CheckOneUser/index.ts +51 -51
- package/src/utils/enumConfig.ts +10 -0
- package/src/utils/requestUtils.ts +33 -32
- package/src/utils/utils.ts +52 -22
- package/tsconfig.json +29 -29
- package/typings.d.ts +4 -4
|
@@ -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;
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React, { useEffect, useState, useLayoutEffect, useImperativeHandle } from 'react';
|
|
3
|
+
import { List, Tooltip, Input, Button } from 'antd';
|
|
4
|
+
import { Link, formatMessage, history } from 'umi';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { debounce } from 'lodash';
|
|
7
|
+
import {
|
|
8
|
+
setMenuTreeData,
|
|
9
|
+
searchMenuData,
|
|
10
|
+
} from '../../../utils';
|
|
11
|
+
import { memoizeOneFormatter } from '@/utils/utils';
|
|
12
|
+
import { SearchOutlined, CaretDownOutlined } from '@ant-design/icons';
|
|
13
|
+
import './drawContent.less';
|
|
14
|
+
import right from '../../../../../../assets/right.png';
|
|
15
|
+
import closeicon from '../../../../../../assets/closeicon.png';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const DrawContent = ({onClose, originRoutes=[], itemPath}: any) => {
|
|
19
|
+
const [homepageData, sethomepageData]: any[] = useState([]);
|
|
20
|
+
const [routesData, setroutesData]: any[] = useState([]);
|
|
21
|
+
const [authorityMenu, setAuthorityMenu]: any[] = useState([]);
|
|
22
|
+
|
|
23
|
+
const [currentOneLevel, setCurrentOneLevel] = useState<string>('');
|
|
24
|
+
const [SearhData, setSearchMenuData] = useState<any[]>([]);
|
|
25
|
+
const [rightMenuHeight, setHeight] = useState<number>(600);
|
|
26
|
+
const [drawHeight, setDrawHeight] = useState<number>(900);
|
|
27
|
+
|
|
28
|
+
const [moreBtnShow, setMoreBtnShow] = useState(false);
|
|
29
|
+
const [showScroll, setShowScroll] = useState(false);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
getMenuContentHeight();
|
|
33
|
+
const homepageDataList: any[] = []; //不含子集的菜单
|
|
34
|
+
const routesDataList: any[] = []; //含子集的菜单
|
|
35
|
+
const authorityMenuList: any[] = []; //当前权限可以看到的所有菜单
|
|
36
|
+
|
|
37
|
+
const showMenu = originRoutes.find(item => item.path === '/')?.routes || [];
|
|
38
|
+
let routesData = JSON.parse(JSON.stringify(memoizeOneFormatter(showMenu, '')));
|
|
39
|
+
setMenuTreeData(routesData);
|
|
40
|
+
|
|
41
|
+
routesData.forEach(item => {
|
|
42
|
+
if (item.children) {
|
|
43
|
+
routesDataList.push(item);
|
|
44
|
+
authorityMenuList.push(item)
|
|
45
|
+
} else {
|
|
46
|
+
homepageDataList.push(item);
|
|
47
|
+
authorityMenuList.push(item)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
sethomepageData(homepageDataList)
|
|
51
|
+
setroutesData(routesDataList)
|
|
52
|
+
setAuthorityMenu(authorityMenuList)
|
|
53
|
+
|
|
54
|
+
window.onresize = () => {
|
|
55
|
+
getMenuContentHeight();
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
let drawContentHeight=document.getElementById("drawContent").scrollHeight;
|
|
62
|
+
if (drawContentHeight > rightMenuHeight) {
|
|
63
|
+
setMoreBtnShow(true);
|
|
64
|
+
}
|
|
65
|
+
}, 0)
|
|
66
|
+
}, [])
|
|
67
|
+
|
|
68
|
+
const getMenuContentHeight = () => {
|
|
69
|
+
let clientHeight = document.body.clientHeight;
|
|
70
|
+
setHeight(clientHeight - 190);
|
|
71
|
+
setDrawHeight(clientHeight - 70)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
const renderChildItem = (child) => {
|
|
76
|
+
if (!child.hideInMenu && child.children) {
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
<List.Item style={{ color: '#000', fontWeight: 'bold' }}>
|
|
80
|
+
{formatMessage({ id: `${child.locale}` })}
|
|
81
|
+
</List.Item>
|
|
82
|
+
{child.children.map((menuItem: any) => {
|
|
83
|
+
return renderChildItem(menuItem)
|
|
84
|
+
})}
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
} else if (!child.hideInMenu && child.path) {
|
|
88
|
+
return (
|
|
89
|
+
<List.Item style={{fontSize: '12px'}} className="allFuncOnMouserover">
|
|
90
|
+
<Link to={child.path} onClick={(e) => {onMenuClick(e, child);}}>
|
|
91
|
+
<Tooltip
|
|
92
|
+
title={formatMessage({ id: `${child.locale}` })}
|
|
93
|
+
>
|
|
94
|
+
{formatMessage({ id: `${child.locale}` }).length > 10
|
|
95
|
+
? `${formatMessage({
|
|
96
|
+
id: `${child.name}`,
|
|
97
|
+
}).slice(0, 10)}...`
|
|
98
|
+
: formatMessage({ id: `${child.locale}` })}
|
|
99
|
+
</Tooltip>
|
|
100
|
+
<img className="allFuncOnMouseroverImg" src={right}></img>
|
|
101
|
+
</Link>
|
|
102
|
+
</List.Item>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const onMenuClick = (e, item) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
let searchHistory = JSON.parse(localStorage.getItem(`${itemPath}_search_history`) || '[]');
|
|
111
|
+
if (searchHistory.every(hisItem => item.path !== hisItem.padth)) {
|
|
112
|
+
if (searchHistory.length < 10 ) {
|
|
113
|
+
searchHistory.push({
|
|
114
|
+
name: item.name,
|
|
115
|
+
path: item.path
|
|
116
|
+
})
|
|
117
|
+
} else {
|
|
118
|
+
searchHistory.pop();
|
|
119
|
+
searchHistory.unshift({
|
|
120
|
+
name: item.name,
|
|
121
|
+
path: item.path
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
localStorage.setItem(`${itemPath}_search_history`, JSON.stringify(searchHistory))
|
|
126
|
+
history.push({
|
|
127
|
+
pathname: item.path
|
|
128
|
+
})
|
|
129
|
+
onClose();
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
let searchHistoryList = JSON.parse(localStorage.getItem(`${itemPath}_search_history`) || '[]');
|
|
134
|
+
return (
|
|
135
|
+
<div style={{height: `${drawHeight}px`}} className={'global_menu_draw_content'}>
|
|
136
|
+
<div className={'drawerWarp_left'}>
|
|
137
|
+
<div className={'left_item_title'} >一级菜单</div>
|
|
138
|
+
{
|
|
139
|
+
authorityMenu.map(item => (
|
|
140
|
+
<div
|
|
141
|
+
className={'left_item'}
|
|
142
|
+
style={{
|
|
143
|
+
borderLeft: currentOneLevel === item.path ? '2px solid #1890ff' : 'none',
|
|
144
|
+
color: currentOneLevel === item.path ? '#1890ff' : '#000000'
|
|
145
|
+
}}
|
|
146
|
+
onClick={(e) => {
|
|
147
|
+
e.stopPropagation();
|
|
148
|
+
e.preventDefault()
|
|
149
|
+
if (item.component) {
|
|
150
|
+
history.push({
|
|
151
|
+
pathname: item.path
|
|
152
|
+
})
|
|
153
|
+
onClose();
|
|
154
|
+
} else {
|
|
155
|
+
setCurrentOneLevel(item.path);
|
|
156
|
+
let currentDom = document.getElementById(item.path);
|
|
157
|
+
currentDom && currentDom.scrollIntoView();
|
|
158
|
+
}
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
{item.name}
|
|
162
|
+
</div>))
|
|
163
|
+
}
|
|
164
|
+
</div>
|
|
165
|
+
<div style={{flexGrow: 1, position: 'relative'}}>
|
|
166
|
+
<img
|
|
167
|
+
onClick={() => {onClose()}}
|
|
168
|
+
style={{position: 'absolute', right: '15px', top: '17px', cursor: 'pointer'}} width={24} src={closeicon} />
|
|
169
|
+
|
|
170
|
+
<div style={{ padding: '10px', marginBottom: '10px', width: '100%', }}>
|
|
171
|
+
<Input
|
|
172
|
+
style={{ height: '36px', borderRadius: '4px', width: '830px' }}
|
|
173
|
+
placeholder="请输入关键词"
|
|
174
|
+
allowClear
|
|
175
|
+
prefix={<SearchOutlined />}
|
|
176
|
+
onChange={debounce((e: any) => {
|
|
177
|
+
searchMenuData(authorityMenu, e.target.value, setSearchMenuData);
|
|
178
|
+
}, 600)}
|
|
179
|
+
/>
|
|
180
|
+
<div style={{marginTop: '10px'}}>
|
|
181
|
+
<span style={{ color: '#8c8c8c', opacity: '0.6' }}>最近访问: </span>
|
|
182
|
+
{
|
|
183
|
+
searchHistoryList.map(item => {
|
|
184
|
+
return (
|
|
185
|
+
<Link style={{color: '#000000', marginRight: '10px'}} to={item.path} onClick={(e) => {onMenuClick(e, item);}}>
|
|
186
|
+
{item.name}
|
|
187
|
+
</Link>)
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
{
|
|
193
|
+
!!SearhData.length ?
|
|
194
|
+
(<div className={'search_menu_content'}>
|
|
195
|
+
{
|
|
196
|
+
SearhData.map((item: any) => (
|
|
197
|
+
<div onClick={(e) => {
|
|
198
|
+
onMenuClick(e, item);
|
|
199
|
+
}} key={item.path}>{item.name}</div>
|
|
200
|
+
))
|
|
201
|
+
}
|
|
202
|
+
</div>) : (
|
|
203
|
+
<div>
|
|
204
|
+
<div
|
|
205
|
+
style={{
|
|
206
|
+
height: `${rightMenuHeight}px`,
|
|
207
|
+
overflowY: 'scroll',
|
|
208
|
+
position: 'relative',
|
|
209
|
+
width: '100%'
|
|
210
|
+
}}
|
|
211
|
+
>
|
|
212
|
+
<div id='drawContent' className={'drawerWarp_right'}>
|
|
213
|
+
{homepageData && homepageData.filter((d) => !d.hideInMenu).length > 0 && (
|
|
214
|
+
<List
|
|
215
|
+
className={classNames('allFunsList', 'allFunsListWarp')}
|
|
216
|
+
dataSource={homepageData}
|
|
217
|
+
renderItem={(child: any) => {
|
|
218
|
+
if (!child.hideInMenu && child.path) {
|
|
219
|
+
return (
|
|
220
|
+
<div className={classNames('allFunsListWarp')}>
|
|
221
|
+
<List.Item
|
|
222
|
+
className={classNames('allFuncOnMouserover')}
|
|
223
|
+
style={{ padding: '12px 24px' }}
|
|
224
|
+
>
|
|
225
|
+
<Link to={child.path} onClick={(e) => {onMenuClick(e, child);}}>
|
|
226
|
+
{formatMessage({ id: `${child.name}` })}
|
|
227
|
+
<img className="allFuncOnMouseroverImg" src={right}></img>
|
|
228
|
+
</Link>
|
|
229
|
+
</List.Item>
|
|
230
|
+
</div>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
}}
|
|
234
|
+
/>
|
|
235
|
+
)}
|
|
236
|
+
{routesData.map((item, index) => {
|
|
237
|
+
return (
|
|
238
|
+
<List
|
|
239
|
+
// className={classNames('allFunsList', 'allFunsListWarp', )}
|
|
240
|
+
className={`allFunsList allFunsListWarp ${currentOneLevel === item.path ? 'choosedStyle' : ''}`}
|
|
241
|
+
id={item.path}
|
|
242
|
+
style={{
|
|
243
|
+
color: currentOneLevel === item.path ? '#fff' : '#005CFF',
|
|
244
|
+
}}
|
|
245
|
+
header={<b>{formatMessage({ id: `${item.name}` })}</b>}
|
|
246
|
+
bordered
|
|
247
|
+
dataSource={item.children}
|
|
248
|
+
renderItem={(child: any) => {
|
|
249
|
+
return renderChildItem(child)
|
|
250
|
+
}}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
})}
|
|
254
|
+
</div>
|
|
255
|
+
<div style={{
|
|
256
|
+
display: moreBtnShow ? 'block' : 'none',
|
|
257
|
+
// position: 'absolute',
|
|
258
|
+
textAlign: 'center',
|
|
259
|
+
bottom: 0,
|
|
260
|
+
background: '#ffffff',
|
|
261
|
+
width: '100%',
|
|
262
|
+
height: '30px'
|
|
263
|
+
}}>
|
|
264
|
+
<span
|
|
265
|
+
onClick={() => {
|
|
266
|
+
setShowScroll(true);
|
|
267
|
+
setMoreBtnShow(false);
|
|
268
|
+
}}
|
|
269
|
+
style={{color: '#8c8c8c'}}
|
|
270
|
+
>
|
|
271
|
+
<CaretDownOutlined />
|
|
272
|
+
下滑加载更多
|
|
273
|
+
</span>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
</div>
|
|
281
|
+
</div>
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export default DrawContent;
|