@bit-sun/business-component 2.1.4 → 2.1.6

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 (137) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +174 -174
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/components/Functional/SearchSelect/utils.d.ts +1 -0
  9. package/dist/index.esm.js +9257 -9242
  10. package/dist/index.js +9256 -9241
  11. package/docs/index.md +21 -21
  12. package/lib/assets/drag.svg +17 -17
  13. package/lib/assets/exportFail.svg +37 -37
  14. package/lib/assets/exportProcessing.svg +28 -28
  15. package/lib/assets/exportSuccess.svg +34 -34
  16. package/lib/assets/label_icon_bottom.svg +25 -25
  17. package/lib/assets/upExport.svg +22 -22
  18. package/package.json +71 -71
  19. package/src/assets/32.svg +27 -27
  20. package/src/assets/addIcon.svg +17 -17
  21. package/src/assets/allfunc.svg +27 -27
  22. package/src/assets/arrowRight.svg +24 -24
  23. package/src/assets/btn-delete.svg +29 -29
  24. package/src/assets/btn-edit.svg +19 -19
  25. package/src/assets/btn-more.svg +17 -17
  26. package/src/assets/btn-submit.svg +19 -19
  27. package/src/assets/caidan.svg +11 -11
  28. package/src/assets/close.svg +26 -26
  29. package/src/assets/drag.svg +17 -17
  30. package/src/assets/exportFail.svg +37 -37
  31. package/src/assets/exportProcessing.svg +28 -28
  32. package/src/assets/exportSuccess.svg +34 -34
  33. package/src/assets/fixed-left-active.svg +11 -11
  34. package/src/assets/fixed-left.svg +15 -15
  35. package/src/assets/fixed-right-active.svg +11 -11
  36. package/src/assets/fixed-right.svg +15 -15
  37. package/src/assets/guanbi.svg +15 -15
  38. package/src/assets/icon-quanping.svg +15 -15
  39. package/src/assets/icon-shezhi.svg +17 -17
  40. package/src/assets/label_icon_bottom.svg +25 -25
  41. package/src/assets/list-no-img.svg +21 -21
  42. package/src/assets/morentouxiang-32.svg +23 -23
  43. package/src/assets/scanning.svg +24 -24
  44. package/src/assets/upExport.svg +22 -22
  45. package/src/components/Business/AddSelectBusiness/index.md +41 -41
  46. package/src/components/Business/AddSelectBusiness/index.tsx +290 -290
  47. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  48. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  49. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  50. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  51. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  52. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  59. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  60. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  61. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  62. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  63. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -156
  64. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  65. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  66. package/src/components/Business/BsLayouts/index.less +79 -79
  67. package/src/components/Business/BsLayouts/index.tsx +1469 -1469
  68. package/src/components/Business/BsLayouts/service.ts +10 -10
  69. package/src/components/Business/BsLayouts/utils.tsx +210 -210
  70. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  71. package/src/components/Business/BsSulaQueryTable/index.tsx +505 -505
  72. package/src/components/Business/BsSulaQueryTable/setting.tsx +799 -799
  73. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  74. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  75. package/src/components/Business/CommodityEntry/index.md +70 -70
  76. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  77. package/src/components/Business/CommonAlert/index.tsx +23 -23
  78. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  79. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  80. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  81. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  82. package/src/components/Business/DetailPageWrapper/index.tsx +335 -335
  83. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  84. package/src/components/Business/HomePageWrapper/index.less +33 -33
  85. package/src/components/Business/HomePageWrapper/index.md +45 -45
  86. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  87. package/src/components/Business/SearchSelect/BusinessUtils.ts +1461 -1458
  88. package/src/components/Business/SearchSelect/common.ts +53 -53
  89. package/src/components/Business/SearchSelect/index.md +1137 -1137
  90. package/src/components/Business/SearchSelect/index.tsx +51 -51
  91. package/src/components/Business/SearchSelect/utils.ts +100 -100
  92. package/src/components/Business/StateFlow/index.less +130 -130
  93. package/src/components/Business/StateFlow/index.md +60 -60
  94. package/src/components/Business/StateFlow/index.tsx +29 -29
  95. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  96. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  97. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  98. package/src/components/Business/columnSettingTable/columnSetting.tsx +763 -763
  99. package/src/components/Business/columnSettingTable/index.less +247 -247
  100. package/src/components/Business/columnSettingTable/index.md +357 -357
  101. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  102. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  103. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  104. package/src/components/Functional/AddSelect/index.less +367 -367
  105. package/src/components/Functional/AddSelect/index.md +122 -122
  106. package/src/components/Functional/AddSelect/index.tsx +992 -992
  107. package/src/components/Functional/BillEntry/index.less +371 -371
  108. package/src/components/Functional/BillEntry/index.md +39 -39
  109. package/src/components/Functional/BillEntry/index.tsx +643 -643
  110. package/src/components/Functional/DataImport/index.less +63 -63
  111. package/src/components/Functional/DataImport/index.md +44 -44
  112. package/src/components/Functional/DataImport/index.tsx +695 -689
  113. package/src/components/Functional/DataValidation/index.less +63 -63
  114. package/src/components/Functional/DataValidation/index.md +39 -38
  115. package/src/components/Functional/DataValidation/index.tsx +687 -681
  116. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  117. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  118. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  119. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  120. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  121. package/src/components/Functional/SearchSelect/index.less +115 -115
  122. package/src/components/Functional/SearchSelect/index.md +141 -141
  123. package/src/components/Functional/SearchSelect/index.tsx +813 -812
  124. package/src/components/Functional/SearchSelect/utils.ts +6 -0
  125. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  126. package/src/components/Functional/TreeSearchSelect/index.tsx +149 -149
  127. package/src/index.ts +31 -31
  128. package/src/styles/bsDefault.less +1906 -1906
  129. package/src/utils/CheckOneUser/index.md +39 -39
  130. package/src/utils/CheckOneUser/index.ts +51 -51
  131. package/src/utils/checkUtils.ts +39 -39
  132. package/src/utils/enumConfig.ts +10 -10
  133. package/src/utils/index.ts +2 -2
  134. package/src/utils/requestUtils.ts +33 -33
  135. package/src/utils/utils.ts +57 -57
  136. package/tsconfig.json +29 -29
  137. package/typings.d.ts +4 -4
@@ -1,1469 +1,1469 @@
1
- // @ts-nocheck
2
- import type {
3
- MenuDataItem,
4
- BasicLayoutProps as ProLayoutProps,
5
- Settings,
6
- } from '@ant-design/pro-layout';
7
- import ProLayout from '@ant-design/pro-layout';
8
- import React, { useState, createRef, useRef } from 'react';
9
- import {
10
- Tabs,
11
- Dropdown,
12
- Menu,
13
- } from 'antd';
14
- import {
15
- Link,
16
- useIntl,
17
- history,
18
- useModel,
19
- } from 'umi';
20
- import {
21
- DashOutlined,
22
- MenuUnfoldOutlined,
23
- CaretLeftOutlined,
24
- HomeOutlined,
25
- DoubleLeftOutlined,
26
- DoubleRightOutlined,
27
- } from '@ant-design/icons';
28
- import SearchFunc from './Components/SearchFunc';
29
- import { debounce } from 'lodash';
30
-
31
- import AllFunc from './Components/AllFunc';
32
- import {
33
- getBreadcrumbNameMap,
34
- ergodicMenuRoutes,
35
- matchPath,
36
- } from './utils';
37
- import moment from 'moment';
38
- import GlobalHeaderCom from './Components/GlobalHeader';
39
- import CustomerMenu from './Components/CustomerMenu';
40
- import CustomerMenuHeader from './Components/CustomerMenu/globalMenu/customMenuHeader';
41
- import './index.less';
42
- import { DndProvider, useDrag, useDrop } from 'react-dnd';
43
- import { HTML5Backend } from 'react-dnd-html5-backend';
44
- import ENUM from '@/utils/enumConfig';
45
- import { memoizeOneFormatter } from '@/utils/utils';
46
-
47
- const { TabPane } = Tabs;
48
-
49
- export const RouterContext = React.createContext({});
50
-
51
- export type BasicLayoutProps = {
52
- breadcrumbNameMap: Record<string, MenuDataItem>;
53
- route: ProLayoutProps['route'] & {
54
- authority: string[];
55
- };
56
- settings: Settings;
57
- } & ProLayoutProps;
58
-
59
- export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
60
- breadcrumbNameMap: Record<string, MenuDataItem>;
61
- };
62
-
63
- const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
64
- menuList.map((item) => {
65
- return {
66
- ...item,
67
- children: item.children ? menuDataRender(item.children) : undefined,
68
- };
69
- });
70
-
71
- let UN_LISTTEN_DRP;
72
- let routerArray = [];
73
- let lastTwoRouterArray = [1, 2];
74
-
75
- let draggerTabKeys = [];
76
-
77
- const type = 'DraggableTabNode';
78
- const DraggableTabNode = ({ index, children, moveNode }) => {
79
- const ref = useRef(null);
80
- const [{ isOver, dropClassName }, drop] = useDrop({
81
- accept: type,
82
- collect: (monitor) => {
83
- const { index: dragIndex } = monitor.getItem() || {};
84
-
85
- if (dragIndex === index) {
86
- return {};
87
- }
88
-
89
- return {
90
- isOver: monitor.isOver(),
91
- dropClassName: 'dropping',
92
- };
93
- },
94
- drop: (item) => {
95
- moveNode(item.index, index);
96
- },
97
- });
98
- const [, drag] = useDrag({
99
- type,
100
- item: {
101
- index,
102
- },
103
- collect: (monitor) => ({
104
- isDragging: monitor.isDragging(),
105
- }),
106
- });
107
- drop(drag(ref));
108
- return (
109
- <div
110
- ref={ref}
111
- style={{
112
- marginRight: 24,
113
- }}
114
- className={isOver ? dropClassName : ''}
115
- >
116
- {children}
117
- </div>
118
- );
119
- };
120
-
121
- const DraggableTabs = (props) => {
122
- const { children, changeListenRouterState } = props;
123
- const [order, setOrder] = useState([]);
124
-
125
- const moveTabNode = (dragKey, hoverKey) => {
126
- const newOrder = order.slice();
127
- React.Children.forEach(children, (c) => {
128
- if (c.key && newOrder.indexOf(c.key) === -1) {
129
- newOrder.push(c.key);
130
- }
131
- });
132
- const dragIndex = newOrder.indexOf(dragKey);
133
- const hoverIndex = newOrder.indexOf(hoverKey);
134
- newOrder.splice(dragIndex, 1);
135
- newOrder.splice(hoverIndex, 0, dragKey);
136
- changeListenRouterState(dragIndex, hoverIndex);
137
- setOrder(newOrder);
138
- };
139
-
140
- const renderTabBar = (tabBarProps, DefaultTabBar) => (
141
- <DefaultTabBar {...tabBarProps}>
142
- {(node) => (
143
- <DraggableTabNode
144
- key={node.key}
145
- index={node.key}
146
- moveNode={moveTabNode}
147
- >
148
- {node}
149
- </DraggableTabNode>
150
- )}
151
- </DefaultTabBar>
152
- );
153
-
154
- const tabs = [];
155
- React.Children.forEach(children, (c) => {
156
- tabs.push(c);
157
- });
158
- const orderTabs = tabs.slice().sort((a, b) => {
159
- const orderA = order.indexOf(a.key);
160
- const orderB = order.indexOf(b.key);
161
-
162
- if (orderA !== -1 && orderB !== -1) {
163
- return orderA - orderB;
164
- }
165
-
166
- if (orderA !== -1) {
167
- return -1;
168
- }
169
-
170
- if (orderB !== -1) {
171
- return 1;
172
- }
173
-
174
- const ia = tabs.indexOf(a);
175
- const ib = tabs.indexOf(b);
176
- return ia - ib;
177
- });
178
- return (
179
- <DndProvider backend={HTML5Backend}>
180
- <Tabs renderTabBar={renderTabBar} {...props}>
181
- {orderTabs}
182
- </Tabs>
183
- </DndProvider>
184
- );
185
- };
186
-
187
- const ItemMenu = (props) => {
188
- const {
189
- info: { key },
190
- operateFun,
191
- listenRouterState,
192
- } = props;
193
- let index = listenRouterState.findIndex((item) => item.key === key);
194
-
195
- const menu = (
196
- <Menu>
197
- <Menu.Item key="0" style={{ fontSize: '12px', textAlign: 'center' }}>
198
- <a
199
- onClick={(e) => {
200
- e.stopPropagation();
201
- operateFun(key, 'self');
202
- }}
203
- >
204
- 关闭当前标签
205
- </a>
206
- </Menu.Item>
207
- <Menu.Item
208
- disabled={index === 0}
209
- key="1"
210
- style={{ fontSize: '12px', textAlign: 'center' }}
211
- >
212
- <a
213
- onClick={(e) => {
214
- e.stopPropagation();
215
- operateFun(key, 'left');
216
- }}
217
- >
218
- 关闭其左侧标签
219
- </a>
220
- </Menu.Item>
221
- <Menu.Item
222
- disabled={index === listenRouterState.length - 1}
223
- key="2"
224
- style={{ fontSize: '12px', textAlign: 'center' }}
225
- >
226
- <a
227
- onClick={(e) => {
228
- e.stopPropagation();
229
- operateFun(key, 'right');
230
- }}
231
- >
232
- 关闭其右侧标签
233
- </a>
234
- </Menu.Item>
235
- <Menu.Item
236
- disabled={index === listenRouterState.length - 1}
237
- key="3"
238
- style={{ fontSize: '12px', textAlign: 'center' }}
239
- >
240
- <a
241
- onClick={(e) => {
242
- e.stopPropagation();
243
- operateFun(key, 'other');
244
- }}
245
- >
246
- 关闭其他标签
247
- </a>
248
- </Menu.Item>
249
- <Menu.Item
250
- disabled={index === listenRouterState.length - 1}
251
- key="4"
252
- style={{ fontSize: '12px', textAlign: 'center' }}
253
- >
254
- <a
255
- onClick={(e) => {
256
- e.stopPropagation();
257
- operateFun(key, 'all');
258
- }}
259
- >
260
- 关闭全部标签
261
- </a>
262
- </Menu.Item>
263
- </Menu>
264
- );
265
- return (
266
- <Dropdown overlay={menu} trigger={['hover']}>
267
- <a
268
- className="ant-dropdown-link"
269
- onClick={(e) => {
270
- e.preventDefault();
271
- e.stopPropagation();
272
- }}
273
- >
274
- <img style={{ marginRight: '-12px' }} src="./biaoqian-icon.svg" />
275
- </a>
276
- </Dropdown>
277
- );
278
- };
279
-
280
- class BasicLayout extends React.PureComponent {
281
- allFunc: any = createRef('');
282
- customerMenuRef: any = createRef('');
283
- actionRef: any = createRef<{
284
- reload: () => void;
285
- }>();
286
- constructor(props) {
287
- super(props);
288
- routerArray = this.updateTree(props.route.routes);
289
- const homeRouter = routerArray.filter(
290
- (itemroute) => itemroute.key === '/',
291
- )[0];
292
- const breadcrumbNameMap = getBreadcrumbNameMap(
293
- memoizeOneFormatter(props.route.routes, ''),
294
- );
295
- const hideMenuArray = ergodicMenuRoutes(props.route.routes);
296
-
297
- this.state = {
298
- listenRouterState: [
299
- { ...homeRouter, key: '/', tab: '欢迎', closable: false },
300
- ],
301
- listenRouterKey: ['/'],
302
- activeKey: '/',
303
- homeRouter,
304
- customerMatchs: [],
305
- breadcrumbNameMap,
306
- hideMenuArray,
307
- keyWord: '',
308
- collapse: false,
309
- drawerLeftParams: {
310
- visible: false,
311
- width: 690,
312
- title: '搜索',
313
- onClose: () => {
314
- this.setState({
315
- drawerLeftParams: {
316
- ...this.state.drawerLeftParams,
317
- visible: false,
318
- },
319
- });
320
- },
321
- },
322
- currentSubMenuData: [],
323
- showSubMenu: false,
324
- isSlider: false,
325
- };
326
- }
327
-
328
- componentDidMount() {
329
- const {
330
- history,
331
- location,
332
- itemPath,
333
- pathToRegexp,
334
- } = this.props;
335
-
336
- let istParent = 0;
337
-
338
- var self = this;
339
-
340
- window.top != window &&
341
- window.addEventListener('message', function (e) {
342
- istParent = 1;
343
- if (localStorage.getItem(ENUM.BROWSER_CACHE.CHILD_APP_BACK)) {
344
- localStorage.removeItem(ENUM.BROWSER_CACHE.CHILD_APP_BACK);
345
- } else {
346
- localStorage.setItem('isTabChange', true);
347
- }
348
-
349
- if (typeof e.data === 'string') {
350
- history.push(e.data.replace(/^\/\w+\//, '/'));
351
- } else {
352
- const info = e.data;
353
- if (info.type === 'remove') {
354
- self.tabActions['remove'](info.key.replace(/^\/\w+\//, '/'));
355
- }
356
- }
357
- });
358
-
359
- UN_LISTTEN_DRP = history.listen((route) => {
360
- if ((window as any).__POWERED_BY_QIANKUN__) {
361
- if (window.location.href.indexOf(`/${itemPath}`) === -1) return;
362
- }
363
- const {
364
- listenRouterState,
365
- listenRouterKey,
366
- customerMatchs,
367
- hideMenuArray,
368
- } = this.state;
369
- let newListenRouterState = [...listenRouterState];
370
- let newListenRouterKey = [...listenRouterKey];
371
-
372
- let replaceRouter = routerArray.filter((itemRoute) =>
373
- pathToRegexp(itemRoute.key || '').test(route.pathname),
374
- )[0];
375
-
376
- if (!istParent) {
377
- if (route.pathname === '/') return;
378
- window.parent.postMessage(`/parent/${itemPath}${route.pathname}`, '*');
379
- }
380
-
381
- let currentKey = '';
382
-
383
- if (replaceRouter && replaceRouter.isOnlyOnePage) {
384
- // 处理中英文和特殊字符
385
- currentKey = decodeURIComponent(route.pathname);
386
- } else {
387
- currentKey = decodeURIComponent(
388
- route.pathname + this.parseQueryString(route.search),
389
- );
390
- }
391
-
392
- // 防止出错
393
- if (listenRouterKey.length !== listenRouterState.length) {
394
- listenRouterState.forEach((item, index) => {
395
- listenRouterKey[index] = item.key;
396
- });
397
- }
398
-
399
- if (!listenRouterKey.includes(currentKey)) {
400
- if (!replaceRouter) {
401
- replaceRouter = routerArray.filter(
402
- (itemroute) => itemroute.key === '/404',
403
- )?.[0];
404
-
405
- this.setState(
406
- {
407
- listenRouterState: [
408
- ...listenRouterState,
409
- { ...replaceRouter, key: currentKey, tab: '404' },
410
- ],
411
- activeKey: currentKey,
412
- listenRouterKey: [...listenRouterKey, currentKey],
413
- },
414
- () => {
415
- this.checkisNavSlide();
416
- },
417
- );
418
- } else {
419
- const match = matchPath(route.pathname, { path: replaceRouter.key }, pathToRegexp);
420
- newListenRouterState = [
421
- ...newListenRouterState,
422
- {
423
- ...replaceRouter,
424
- query: route.query,
425
- match: match,
426
- key: currentKey,
427
- tab: this.getPageTitle(route.pathname) + '',
428
- },
429
- ];
430
- newListenRouterKey = [...listenRouterKey, currentKey];
431
- }
432
- }
433
-
434
- // 处理hideMenu页面自动关闭
435
- lastTwoRouterArray.push(route.pathname);
436
- lastTwoRouterArray.shift();
437
- if (
438
- !localStorage.getItem('isTabChange') &&
439
- !localStorage.getItem('isMenuClick')
440
- ) {
441
- if (
442
- lastTwoRouterArray[0] &&
443
- typeof lastTwoRouterArray[0] === 'string'
444
- ) {
445
- let needRemoveKeyArray = hideMenuArray.filter((itemRoute) =>
446
- pathToRegexp(itemRoute.path || '').test(lastTwoRouterArray[0]),
447
- );
448
- // lastTwoRouterArray[0] != lastTwoRouterArray[1] 该判断条件用于判断是否是tab删除操作,如果是tab页删除操作,删除的是不是最后一个打开的tab页,执行history.push会导致错误的将最后打开的那个tab页也删除掉
449
- if (
450
- needRemoveKeyArray.length &&
451
- lastTwoRouterArray[0] != lastTwoRouterArray[1]
452
- ) {
453
- if (
454
- (!(
455
- lastTwoRouterArray[0].indexOf('/order/mainOrder/supplement') >=
456
- 0
457
- ) ||
458
- !pathToRegexp(
459
- '/order/mainOrder/:parmode/separateOrder/:id',
460
- ).test(lastTwoRouterArray[1])) &&
461
- (!pathToRegexp(
462
- '/order/mainOrder/:parmode/separateOrder/:id',
463
- ).test(lastTwoRouterArray[0]) ||
464
- !(
465
- lastTwoRouterArray[1].indexOf(
466
- 'order/mainOrder/separateOrder/',
467
- ) >= 0
468
- ))
469
- ) {
470
- if (!route.state?.thisHideInMenuDoNotClose) {
471
- newListenRouterState = newListenRouterState.filter((item) => {
472
- const [pathname] = item.key ? item.key.split('?') : [];
473
- return pathname && pathname !== lastTwoRouterArray[0];
474
- });
475
- newListenRouterKey = newListenRouterKey.filter((item) => {
476
- const [pathname] = item ? item.split('?') : [];
477
- return pathname && pathname !== lastTwoRouterArray[0];
478
- });
479
- }
480
- }
481
- }
482
- }
483
- // refs?.tableRef?.current?.refreshTable();
484
- } else {
485
- setTimeout(() => {
486
- // 处理页面刷新两面
487
- localStorage.removeItem('isTabChange');
488
- localStorage.removeItem('isMenuClick');
489
- }, 0);
490
- }
491
- this.setState(
492
- {
493
- //路由监听函数最后执行setState,避免处理hideMenu类型页面自动关闭的逻辑块内获取不到最新state的listenRouterState和listenRouterKey
494
- activeKey: currentKey,
495
- listenRouterState: newListenRouterState,
496
- listenRouterKey: newListenRouterKey,
497
- },
498
- () => {
499
- this.checkisNavSlide();
500
- },
501
- );
502
-
503
- istParent = 0;
504
- });
505
-
506
- if (
507
- localStorage.getItem('firstPage') &&
508
- localStorage.getItem('firstPage')?.startsWith(`#/${itemPath}/`)
509
- ) {
510
- istParent = 1;
511
- history.push(
512
- localStorage
513
- .getItem('firstPage')
514
- ?.slice(1)
515
- .replace(/^\/\w+\//, '/'),
516
- );
517
- } else {
518
- history.push(location);
519
- }
520
- }
521
-
522
- componentWillUnmount() {
523
- // eslint-disable-next-line no-unused-expressions
524
- UN_LISTTEN_DRP && UN_LISTTEN_DRP();
525
- }
526
-
527
- parseQueryString = (queryString) => {
528
- if (!queryString) {
529
- return '';
530
- }
531
-
532
- if (queryString.indexOf('?') < 0) {
533
- return `?${queryString}`;
534
- }
535
-
536
- return queryString;
537
- };
538
-
539
- updateTree = (Tree) => {
540
- const treeData = Tree;
541
- const treeList = [];
542
- // 递归获取树列表
543
- const getTreeList = (data) => {
544
- data.forEach((node) => {
545
- if (node.routes && node.routes.length > 0) {
546
- getTreeList(node.routes);
547
- } else {
548
- treeList.push({
549
- tab: node.locale,
550
- key: node.path,
551
- locale: node.locale,
552
- closable: true,
553
- content: node.component,
554
- name: node.name,
555
- hideInMenu: node.hideInMenu,
556
- isOnlyOnePage: node.isOnlyOnePage,
557
- });
558
- }
559
- });
560
- };
561
- getTreeList(treeData);
562
- return treeList;
563
- };
564
-
565
- getDictionarySource = (dicCode: string, needConvertInterger = false) => {
566
- const { dictionaryData } = this.props;
567
-
568
- let dicData = {};
569
-
570
- if (!dictionaryData) {
571
- let storageDic = localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES)
572
- ? JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES))
573
- : {};
574
- dicData = storageDic[dicCode];
575
- } else {
576
- dicData = dictionaryData[dicCode];
577
- }
578
- // if (!dicData || !dicData.length) {
579
- // throw new Error(`当前没有${dicCode}字典值`);
580
- // }
581
-
582
- try {
583
- if (needConvertInterger) {
584
- dicData = dicData.map((item: { text: string; value: string }) => ({
585
- ...item,
586
- value: parseFloat(item.value),
587
- }));
588
- }
589
- } catch (e) { }
590
-
591
- return dicData;
592
- };
593
-
594
- getDictionaryTextByValue = (dicCode: string, value: string) => {
595
- let dicData = [];
596
- let dictionaryData: any;
597
- if (!dictionaryData) {
598
- let storageDic = localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES)
599
- ? JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES))
600
- : {};
601
- dicData = storageDic[dicCode];
602
- } else {
603
- dicData = dictionaryData[dicCode];
604
- }
605
-
606
- if (!dicData || !dicData.length) {
607
- // throw new Error(`当前没有${dicCode}字典值`);
608
- }
609
-
610
- if (value === undefined) return '- -';
611
-
612
- const dicItemArray = dicData?.filter(
613
- (item: { value: string }) => item.value === value.toString(),
614
- );
615
-
616
- if (!dicItemArray?.length) {
617
- // throw new Error(`当前${dicCode}字典值合没有${value}的数据`)
618
- return value;
619
- }
620
-
621
- return dicItemArray[0].text;
622
- };
623
-
624
- timeFormat = (timeStr, format, notNeedConvertTimeZone) => {
625
- if (!timeStr) return '- -';
626
-
627
- if (notNeedConvertTimeZone) {
628
- return moment(timeStr).format(format);
629
- }
630
-
631
- return moment(timeStr).add(8, 'hours').format(format) || '- -';
632
- };
633
-
634
- onChange = (key) => {
635
- // console.log('onChange');
636
- if (key !== this.state.activeKey) {
637
- this.setState({
638
- activeKey: key,
639
- });
640
- localStorage.setItem('isTabChange', '1');
641
- history.push(key);
642
- }
643
- };
644
-
645
- getPageTitle = (pathname) => {
646
- const { formatMessage } = this.props;
647
- const { breadcrumbNameMap } = this.state;
648
- const currRouterData = this.matchParamsPath(pathname, breadcrumbNameMap);
649
-
650
- if (!currRouterData) {
651
- return '';
652
- }
653
- const pageName = formatMessage({
654
- id: currRouterData.locale || currRouterData.name,
655
- defaultMessage: currRouterData.name,
656
- });
657
-
658
- return `${pageName}`;
659
- };
660
-
661
- matchParamsPath = (pathname, breadcrumbNameMap) => {
662
- const { pathToRegexp } = this.props;
663
- const pathKey = Object.keys(breadcrumbNameMap).find((key) =>
664
- pathToRegexp(key).test(pathname),
665
- );
666
- return breadcrumbNameMap[pathKey];
667
- };
668
-
669
- onEdit = (
670
- targetKey: React.MouseEvent | React.KeyboardEvent | string,
671
- action: string,
672
- ) => {
673
- this.tabActions[action](targetKey);
674
- };
675
-
676
- tabActions: any = {
677
- remove: (targetKey: string) => {
678
- const { listenRouterState, activeKey, customerMatchs, listenRouterKey } =
679
- this.state;
680
-
681
- let lastIndex: number = 0;
682
- let newActiveKey: string | undefined = activeKey;
683
- let newListenRouterState = [];
684
- let newListenRouterKey = [];
685
-
686
- if (targetKey === activeKey) {
687
- listenRouterState.forEach((pane, i) => {
688
- if (pane.key === targetKey) {
689
- lastIndex = i - 1;
690
- }
691
- });
692
-
693
- newListenRouterState = listenRouterState.filter(
694
- (item) => item.key !== targetKey,
695
- );
696
- newListenRouterKey = listenRouterKey.filter(
697
- (item) => item !== targetKey,
698
- );
699
-
700
- if (lastIndex < 0) {
701
- lastIndex = 0;
702
- }
703
-
704
- newActiveKey = newListenRouterState[lastIndex].key;
705
- } else {
706
- newListenRouterState = listenRouterState.filter(
707
- (item) => item.key !== targetKey,
708
- );
709
- newListenRouterKey = listenRouterKey.filter(
710
- (item) => item !== targetKey,
711
- );
712
- }
713
-
714
- this.setState(
715
- {
716
- activeKey: newActiveKey,
717
- listenRouterState: newListenRouterState,
718
- listenRouterKey: newListenRouterKey,
719
- },
720
- () => {
721
- history.push({
722
- pathname: newActiveKey,
723
- });
724
- this.checkisNavSlide();
725
- },
726
- );
727
- },
728
- };
729
-
730
- updateState = (newListenRouterState, newListenRouterKey, cb) => {
731
- this.setState(
732
- {
733
- listenRouterState: newListenRouterState,
734
- listenRouterKey: newListenRouterKey,
735
- },
736
- () => {
737
- this.checkisNavSlide();
738
- if (cb) cb();
739
- },
740
- );
741
- };
742
-
743
- handleClose = () => {
744
- this.setState({
745
- drawerLeftParams: {
746
- ...this.state.drawerLeftParams,
747
- visible: false,
748
- },
749
- isCollapse: true,
750
- });
751
- this.allFunc.current?.close?.();
752
- this.customerMenuRef.current?.close?.();
753
- };
754
-
755
- handleMenuClick = (item: any) => {
756
- if (item.children || !item.component) return;
757
- history.push({
758
- pathname: item.path,
759
- });
760
- this.setShowMenu(false);
761
- };
762
-
763
- getMenuDom = (menuData) => {
764
- return menuData.map((item) => (
765
- <div>
766
- <div
767
- onClick={() => {
768
- this.handleMenuClick(item);
769
- }}
770
- className={`${'menu_item'} ${item.children || !item.component ? '' : 'link_style'
771
- }`}
772
- style={{
773
- fontWeight: item.children || !item.component ? 'bolder' : '400',
774
- paddingLeft: '10px',
775
- marginTop: item.children || !item.component ? '5px' : '0px',
776
- fontSize: item.children || !item.component ? '14px' : '12px',
777
- }}
778
- >
779
- {item.name}
780
- </div>
781
- {!!item.children &&
782
- !!item.children.length &&
783
- this.getMenuDom(item.children)}
784
- </div>
785
- ));
786
- };
787
-
788
- setShowMenu = debounce((isShow) => {
789
- this.setState({
790
- showSubMenu: isShow,
791
- });
792
- }, 500);
793
-
794
- //设置tabs标签左右滚动
795
- setTabNavTransLate = (num) => {
796
- let globalTabsNav = document
797
- .getElementById('globalTabs')
798
- ?.getElementsByClassName('ant-tabs-nav-list')?.[0];
799
- let globalTabsNavWrap = document
800
- .getElementById('globalTabs')
801
- ?.getElementsByClassName('ant-tabs-nav-wrap')?.[0];
802
- let wrapWidth = globalTabsNavWrap.offsetWidth; //tabsNav父节点宽度
803
- let navListWidth = globalTabsNav.offsetWidth; //tabsNav总宽度
804
- if (navListWidth - wrapWidth <= 0) return;
805
- let maxTransX = navListWidth - wrapWidth; // 允许移动最大宽度
806
- let transXStr = document.defaultView?.getComputedStyle(
807
- globalTabsNav,
808
- null,
809
- ).transform;
810
- let transx = transXStr?.split(',')[4]; //当前translateX的值
811
-
812
- let targetTransX = Math.abs(Number(transx)) + num;
813
- if (targetTransX <= 0) targetTransX = 0;
814
- if (targetTransX >= Number(maxTransX)) targetTransX = Number(maxTransX);
815
- globalTabsNav.style.transform = 'translateX(-' + targetTransX + 'px)';
816
- };
817
-
818
- checkisNavSlide = () => {
819
- if (window.top != window) return;
820
- //监听tabs页签总长度判断是否可点击滑动
821
- let globalTabsNav = document
822
- .getElementById('globalTabs')
823
- ?.getElementsByClassName('ant-tabs-nav-list')?.[0];
824
- let globalTabsNavWrap = document
825
- .getElementById('globalTabs')
826
- ?.getElementsByClassName('ant-tabs-nav-wrap')?.[0];
827
- let wrapWidth = globalTabsNavWrap?.offsetWidth; //tabsNav父节点宽度
828
- let navListWidth = globalTabsNav?.offsetWidth; //tabsNav总宽度
829
- if (navListWidth - wrapWidth <= 0) {
830
- this.setState({
831
- isSlider: false,
832
- });
833
- return;
834
- }
835
- this.setState({
836
- isSlider: true,
837
- });
838
- };
839
-
840
- changeListenRouterState = (dragIndex: number, hoverIndex: number) => {
841
- const { listenRouterState, listenRouterKey } = this.state;
842
- let dragItem = listenRouterState[dragIndex];
843
- let dragKeyItem = listenRouterKey[dragIndex];
844
-
845
- listenRouterState.splice(dragIndex, 1);
846
- listenRouterState.splice(hoverIndex, 0, dragItem);
847
-
848
- listenRouterKey.splice(dragIndex, 1);
849
- listenRouterKey.splice(hoverIndex, 0, dragKeyItem);
850
- };
851
-
852
- operateFun = (key, type) => {
853
- const { listenRouterState, activeKey, listenRouterKey } = this.state;
854
- let deleteKey = '';
855
- let newlistenRouterState = [];
856
- let newlistenRouterKey = [];
857
- let newActiveKey = '';
858
- let deleteIndex = 0;
859
- if (type === 'self') {
860
- deleteIndex = listenRouterState.findIndex((item) => item.key === key);
861
- deleteKey = key;
862
- if (deleteIndex > 0) {
863
- newActiveKey = listenRouterState[deleteIndex - 1].key;
864
- } else {
865
- newActiveKey = listenRouterState[1].key;
866
- }
867
- newlistenRouterState = listenRouterState.filter((d) => d.key !== key);
868
- newlistenRouterKey = listenRouterKey.filter((d) => d !== key);
869
- this.updateState(newlistenRouterState, newlistenRouterKey, () => {
870
- if (deleteKey === activeKey) {
871
- history.push({
872
- pathname: newActiveKey,
873
- });
874
- }
875
- });
876
- }
877
- if (type === 'left') {
878
- const index = listenRouterState.findIndex((item) => item.key === key);
879
- newlistenRouterState = listenRouterState.filter(
880
- (d: any, i: number) => i >= index || d.key === '/',
881
- );
882
- newlistenRouterKey = listenRouterKey.filter(
883
- (d: any, i: number) => i >= index || d === '/',
884
- );
885
- this.updateState(newlistenRouterState, newlistenRouterKey, () => {
886
- if (newlistenRouterKey.find((item) => item === activeKey)) {
887
- return;
888
- } else {
889
- history.push({
890
- pathname: key,
891
- });
892
- }
893
- });
894
- }
895
- if (type === 'right') {
896
- const index = listenRouterState.findIndex((item) => item.key === key);
897
- newlistenRouterState = listenRouterState.filter(
898
- (d: any, i: number) => i <= index || d.key === '/',
899
- );
900
- newlistenRouterKey = listenRouterKey.filter(
901
- (d: any, i: number) => i <= index || d === '/',
902
- );
903
- this.updateState(
904
- listenRouterState.filter(
905
- (d: any, i: number) => i <= index || d.key === '/',
906
- ),
907
- listenRouterKey.filter((d: any, i: number) => i <= index || d === '/'),
908
- () => {
909
- if (newlistenRouterKey.find((item) => item === activeKey)) {
910
- return;
911
- } else {
912
- history.push({
913
- pathname: key,
914
- });
915
- }
916
- },
917
- );
918
- }
919
- if (type === 'all') {
920
- this.updateState(
921
- listenRouterState.filter((item) => item.key === '/'),
922
- listenRouterKey.filter((item) => item === '/'),
923
- () => {
924
- history.push({
925
- pathname: '/',
926
- });
927
- },
928
- );
929
- }
930
- if (type === 'other') {
931
- this.updateState(
932
- listenRouterState.filter(
933
- (item) => item.key === key || item.key === '/',
934
- ),
935
- listenRouterKey.filter((item) => item === key || item === '/'),
936
- () => {
937
- if (key !== activeKey) {
938
- history.push({
939
- pathname: key,
940
- });
941
- }
942
- },
943
- );
944
- }
945
- };
946
-
947
- render() {
948
- const {
949
- listenRouterState,
950
- activeKey,
951
- listenRouterKey,
952
- drawerLeftParams,
953
- collapse,
954
- currentSubMenuData,
955
- showSubMenu,
956
- currentSubPath,
957
- } = this.state;
958
- const { originRoutes, itemPath, defaultSettings, transparentProps={} } = this.props;
959
- const TabTitle: React.FC<{}> = ({ item, index, updateState }) => {
960
- return (
961
- <div className="tab_title_content">
962
- {item.tab}
963
- {item.key !== '/' && (
964
- <ItemMenu
965
- info={item}
966
- operateFun={this.operateFun}
967
- listenRouterState={listenRouterState}
968
- />
969
- )}
970
- </div>
971
- );
972
- };
973
-
974
- // 左侧菜单 route
975
- const dataShowRoute = this.props.routes.find(
976
- (route) => route.path === '/homePage/data-show',
977
- ); // 添加数据大屏
978
- const { route, ...restPrpos } = this.props;
979
- const exist = route.routes.find(
980
- (route) => route.path === '/homePage/data-show',
981
- );
982
- if (dataShowRoute && !exist) {
983
- route.routes.splice(1, 0, dataShowRoute);
984
- }
985
-
986
- const menu = (
987
- <Menu>
988
- <Menu.Item
989
- key="0"
990
- style={{
991
- background: '#FFFFFF',
992
- color: '#848484',
993
- fontSize: '12px',
994
- textAlign: 'center',
995
- }}
996
- >
997
- <div>已打开的页签数: {listenRouterState.length}</div>
998
- </Menu.Item>
999
- <Menu.Item key="1" style={{ fontSize: '12px', textAlign: 'center' }}>
1000
- <a
1001
- onClick={() => {
1002
- // 关闭全部
1003
- this.updateState(
1004
- [
1005
- {
1006
- ...this.state.homeRouter,
1007
- key: '/',
1008
- tab: '欢迎',
1009
- closable: false,
1010
- },
1011
- ],
1012
- ['/'],
1013
- () => {
1014
- history.push('/');
1015
- },
1016
- );
1017
- }}
1018
- >
1019
- 关闭全部标签
1020
- </a>
1021
- </Menu.Item>
1022
- <Menu.Item key="2" style={{ fontSize: '12px', textAlign: 'center' }}>
1023
- <a
1024
- onClick={() => {
1025
- if (activeKey === '/') return;
1026
- const index = listenRouterState.findIndex(
1027
- (item) => item.key === activeKey,
1028
- );
1029
- let newActiveKey = '';
1030
- if (index > 0) {
1031
- newActiveKey = listenRouterState[index - 1].key;
1032
- } else {
1033
- newActiveKey = listenRouterState[1].key;
1034
- }
1035
- this.updateState(
1036
- listenRouterState.filter((d) => d.key !== activeKey),
1037
- listenRouterKey.filter((d) => d !== activeKey),
1038
- () => {
1039
- history.push({
1040
- pathname: newActiveKey,
1041
- });
1042
- },
1043
- );
1044
- }}
1045
- >
1046
- 关闭当前标签
1047
- </a>
1048
- </Menu.Item>
1049
- <Menu.Item key="3" style={{ fontSize: '12px', textAlign: 'center' }}>
1050
- <a
1051
- onClick={() => {
1052
- const index = listenRouterState.findIndex(
1053
- (item) => item.key === activeKey,
1054
- );
1055
- // let deleteKey = listenRouterState[index - 1]?.key;
1056
- // if (deleteKey === '/') {
1057
- // message.warning('首页不可关闭。');
1058
- // return;
1059
- // }
1060
-
1061
- this.updateState(
1062
- listenRouterState.filter(
1063
- (d: any, i: number) => i >= index || d.key === '/',
1064
- ),
1065
- listenRouterKey.filter(
1066
- (d: any, i: number) => i >= index || d === '/',
1067
- ),
1068
- );
1069
- }}
1070
- >
1071
- 关闭其左侧标签
1072
- </a>
1073
- </Menu.Item>
1074
- <Menu.Item key="4" style={{ fontSize: '12px', textAlign: 'center' }}>
1075
- <a
1076
- onClick={() => {
1077
- let index = listenRouterState.findIndex(
1078
- (item) => item.key === activeKey,
1079
- );
1080
- this.updateState(
1081
- listenRouterState.filter(
1082
- (d: any, i: number) => i <= index || d.key === '/',
1083
- ),
1084
- listenRouterKey.filter(
1085
- (d: any, i: number) => i <= index || d === '/',
1086
- ),
1087
- );
1088
- }}
1089
- >
1090
- 关闭其右侧标签
1091
- </a>
1092
- </Menu.Item>
1093
- </Menu>
1094
- );
1095
-
1096
- const filterByMenuDate = (
1097
- data: MenuDataItem[],
1098
- keyWord: string,
1099
- ): MenuDataItem[] =>
1100
- data
1101
- .map((item) => {
1102
- if (item.name && item.name.includes(keyWord)) {
1103
- return {
1104
- ...item,
1105
- };
1106
- }
1107
- return undefined;
1108
- })
1109
- .filter((item) => item) as MenuDataItem[];
1110
-
1111
- let weiqianduanProps = {};
1112
- let isWeiqianduan = false;
1113
-
1114
- if (window.top != window) {
1115
- isWeiqianduan = true;
1116
- weiqianduanProps = {
1117
- headerRender: false,
1118
- footerRender: false,
1119
- menuRender: false,
1120
- menuHeaderRender: false,
1121
- menuExtraRender: false,
1122
- };
1123
- }
1124
-
1125
- const OperationsSlot: Record<PositionType, React.ReactNode> = {
1126
- left: (
1127
- <div className={'tab_left_operate'}>
1128
- <div
1129
- onClick={() => {
1130
- history.push({
1131
- pathname: '/',
1132
- });
1133
- }}
1134
- >
1135
- <HomeOutlined />
1136
- </div>
1137
- <div
1138
- style={{ opacity: this.state.isSlider ? 1 : 0.5 }}
1139
- onClick={() => {
1140
- this.setTabNavTransLate(-100);
1141
- }}
1142
- >
1143
- <DoubleLeftOutlined />
1144
- </div>
1145
- </div>
1146
- ),
1147
- right: (
1148
- <div
1149
- style={{ opacity: this.state.isSlider ? 1 : 0.5 }}
1150
- className={'tab_right_operate'}
1151
- onClick={() => {
1152
- this.setTabNavTransLate(100);
1153
- }}
1154
- >
1155
- <DoubleRightOutlined />
1156
- </div>
1157
- ),
1158
- };
1159
-
1160
- return (
1161
- <ProLayout
1162
- actionRef={this.actionRef}
1163
- onMenuHeaderClick={() => history.push('/')}
1164
- menuHeaderRender={({ }) => (
1165
- <CustomerMenuHeader
1166
- originRoutes={originRoutes}
1167
- itemPath={itemPath}
1168
- handleClose={this.handleClose}
1169
- collapsed={collapse}
1170
- />
1171
- )}
1172
- menuExtraRender={() => {
1173
- if (!collapse) {
1174
- return (
1175
- <div>
1176
- <CustomerMenu
1177
- originRoutes={originRoutes}
1178
- itemPath={itemPath}
1179
- ref={this.customerMenuRef}
1180
- actionRef={this.actionRef}
1181
- handleClose={this.handleClose}
1182
- isCollapse={this.state.collapse}
1183
- />
1184
- </div>
1185
- );
1186
- }
1187
- return (
1188
- <div className="collapse_icon_close">
1189
- <span
1190
- className="collapse_icon"
1191
- onClick={() => {
1192
- this.setState({
1193
- collapse: !collapse,
1194
- });
1195
- }}
1196
- >
1197
- <MenuUnfoldOutlined />
1198
- </span>
1199
- </div>
1200
- );
1201
- }}
1202
- menuProps={{
1203
- onClick: () => {
1204
- localStorage.setItem('isMenuClick', 'true');
1205
- },
1206
- }}
1207
- collapsed={collapse}
1208
- onCollapse={(boo: boolean) => {
1209
- this.setState({
1210
- collapse: boo,
1211
- });
1212
- }}
1213
- menuItemRender={(menuItemProps, defaultDom) => {
1214
- if (menuItemProps?.path === '/') {
1215
- return (
1216
- <>
1217
- <div className="one_menu_wrap">
1218
- <Link
1219
- onClick={() => {
1220
- localStorage.setItem('isMenuClick', 'true');
1221
- }}
1222
- to={menuItemProps.path}
1223
- >
1224
- {defaultDom}
1225
- </Link>
1226
- </div>
1227
- </>
1228
- );
1229
- }
1230
- return (
1231
- <Link
1232
- onClick={() => {
1233
- localStorage.setItem('isMenuClick', 'true');
1234
- }}
1235
- to={menuItemProps.path}
1236
- >
1237
- {defaultDom}
1238
- </Link>
1239
- );
1240
- }}
1241
- subMenuItemRender={(menuItemProps, defaultDom) => {
1242
- return (
1243
- <div
1244
- style={{
1245
- height: '40px',
1246
- lineHeight: '40px',
1247
- position: 'relative',
1248
- overflow: 'hidden',
1249
- textOverflow: 'ellipsis',
1250
- whiteSpace: 'nowrap',
1251
- boxSizing: 'border-box',
1252
- paddingRight: '10px',
1253
- }}
1254
- onMouseEnter={() => {
1255
- if (
1256
- menuItemProps.pro_layout_parentKeys &&
1257
- menuItemProps.pro_layout_parentKeys.length
1258
- )
1259
- return;
1260
- this.setState({
1261
- currentSubMenuData: menuItemProps.children,
1262
- currentSubPath: menuItemProps.path,
1263
- });
1264
- this.setShowMenu(true);
1265
- }}
1266
- onMouseLeave={() => {
1267
- this.setShowMenu(false);
1268
- }}
1269
- >
1270
- {defaultDom}
1271
- {showSubMenu &&
1272
- currentSubPath === menuItemProps.path &&
1273
- !collapse && (
1274
- <CaretLeftOutlined
1275
- style={{ position: 'absolute', top: '14px', right: '-4px' }}
1276
- />
1277
- )}
1278
- </div>
1279
- );
1280
- }}
1281
- collapsedButtonRender={() => {
1282
- return (
1283
- <div
1284
- onClick={(e) => {
1285
- e.stopPropagation();
1286
- }}
1287
- className="banquan"
1288
- >
1289
- {''}
1290
- </div>
1291
- );
1292
- }}
1293
- postMenuData={(menus) => {
1294
- return [...filterByMenuDate(menus || [], this.state.keyWord)];
1295
- }}
1296
- links={[
1297
- !this.state.collapse ? (
1298
- <AllFunc
1299
- ref={this.allFunc}
1300
- itemPath={itemPath}
1301
- handleClose={this.handleClose}
1302
- isCollapse={this.state.collapse}
1303
- />
1304
- ) : (
1305
- ''
1306
- ),
1307
- ]}
1308
- onPageChange={() => {
1309
- const { location } = history;
1310
- // 如果没有登录,重定向到 login
1311
- if (
1312
- !localStorage.getItem(ENUM.BROWSER_CACHE.USER_INFO) &&
1313
- location.pathname !== '/user/login'
1314
- ) {
1315
- history.push('/user/login');
1316
- }
1317
- }}
1318
- headerRender={(props) => <GlobalHeaderCom {...props} />}
1319
- menu={{
1320
- request: async () => {
1321
- return JSON.parse(
1322
- localStorage.getItem(`customerMenu_${itemPath}_front`) || '[]',
1323
- );
1324
- },
1325
- type: 'group',
1326
- }}
1327
- route={route}
1328
- {...restPrpos}
1329
- {...defaultSettings}
1330
- {...weiqianduanProps}
1331
- >
1332
- <div id="globalTabsContent" className="globalTabs">
1333
- <DraggableTabs
1334
- activeKey={activeKey}
1335
- id="globalTabs"
1336
- onChange={this.onChange}
1337
- // tabBarExtraContent={operations}
1338
- type="editable-card"
1339
- tabBarStyle={{
1340
- background: '#f3f3f3',
1341
- height: '28px',
1342
- marginRight: 0,
1343
- fontSize: '12px',
1344
- color: '#2C2F2E70',
1345
- marginBottom: '-2px',
1346
- position: 'fixed',
1347
- top: 50,
1348
- zIndex: 10,
1349
- width: collapse ? 'calc(100% - 75px)' : 'calc(100% - 167px)',
1350
- display: isWeiqianduan ? 'none' : 'flex',
1351
- }}
1352
- tabPosition="top"
1353
- tabBarGutter={8}
1354
- onEdit={this.onEdit}
1355
- tabBarExtraContent={OperationsSlot}
1356
- animated={false}
1357
- hideAdd
1358
- >
1359
- {listenRouterState.map((item, index) => (
1360
- <TabPane
1361
- tab={
1362
- <TabTitle
1363
- item={item}
1364
- index={index}
1365
- updateState={this.updateState}
1366
- />
1367
- }
1368
- style={{ marginTop: isWeiqianduan ? 0 : 30 }}
1369
- key={item.key}
1370
- closable={item.key !== '/'}
1371
- closeIcon={<img src="./biaoqian-guanbi-icon.svg" />}
1372
- >
1373
- <WrapperComponent
1374
- item={item}
1375
- routerProps={this.props}
1376
- getDictionarySource={this.getDictionarySource}
1377
- getDictionaryTextByValue={this.getDictionaryTextByValue}
1378
- timeFormat={this.timeFormat}
1379
- transparentProps={transparentProps}
1380
- />
1381
- </TabPane>
1382
- ))}
1383
- </DraggableTabs>
1384
- <div
1385
- className="globalTabsOper"
1386
- style={{
1387
- position: 'fixed',
1388
- top: '50px',
1389
- zIndex: 10,
1390
- background: '#fff',
1391
- display: isWeiqianduan ? 'none' : 'block',
1392
- borderLeft: '1px solid #E4E4E4',
1393
- }}
1394
- >
1395
- <Dropdown overlay={menu} trigger={['click']}>
1396
- <a
1397
- className="ant-dropdown-link"
1398
- onClick={(e) => e.preventDefault()}
1399
- >
1400
- <DashOutlined />
1401
- </a>
1402
- </Dropdown>
1403
- </div>
1404
- <SearchFunc itemPath={itemPath} {...drawerLeftParams}></SearchFunc>
1405
- <div
1406
- onMouseEnter={() => {
1407
- this.setShowMenu(true);
1408
- }}
1409
- onMouseLeave={() => {
1410
- this.setShowMenu(false);
1411
- }}
1412
- className={'sub_menu_content'}
1413
- style={{ display: showSubMenu && !collapse ? 'block' : 'none' }}
1414
- >
1415
- {this.getMenuDom(currentSubMenuData)}
1416
- </div>
1417
- </div>
1418
- </ProLayout>
1419
- );
1420
- }
1421
- }
1422
-
1423
- class WrapperComponent extends React.Component {
1424
- constructor(props) {
1425
- super(props);
1426
- }
1427
-
1428
- shouldComponentUpdate() {
1429
- return false;
1430
- }
1431
-
1432
- render() {
1433
- const {
1434
- item,
1435
- routerProps,
1436
- getDictionarySource,
1437
- getDictionaryTextByValue,
1438
- timeFormat,
1439
- transparentProps,
1440
- } = this.props;
1441
- return (
1442
- <>
1443
- {React.createElement(item.content, {
1444
- getDictionarySource: getDictionarySource,
1445
- getDictionaryTextByValue: getDictionaryTextByValue,
1446
- timeFormat: timeFormat,
1447
- ...routerProps,
1448
- ...transparentProps,
1449
- match: item.match,
1450
- })}
1451
- </>
1452
- );
1453
- }
1454
- }
1455
-
1456
- export default (props) => {
1457
- const { initialState = {} } = useModel('@@initialState');
1458
-
1459
- const { dictionaryData } = initialState;
1460
- const intl = useIntl();
1461
- const { formatMessage } = intl;
1462
- return (
1463
- <BasicLayout
1464
- {...props}
1465
- dictionaryData={dictionaryData}
1466
- formatMessage={formatMessage}
1467
- />
1468
- );
1469
- };
1
+ // @ts-nocheck
2
+ import type {
3
+ MenuDataItem,
4
+ BasicLayoutProps as ProLayoutProps,
5
+ Settings,
6
+ } from '@ant-design/pro-layout';
7
+ import ProLayout from '@ant-design/pro-layout';
8
+ import React, { useState, createRef, useRef } from 'react';
9
+ import {
10
+ Tabs,
11
+ Dropdown,
12
+ Menu,
13
+ } from 'antd';
14
+ import {
15
+ Link,
16
+ useIntl,
17
+ history,
18
+ useModel,
19
+ } from 'umi';
20
+ import {
21
+ DashOutlined,
22
+ MenuUnfoldOutlined,
23
+ CaretLeftOutlined,
24
+ HomeOutlined,
25
+ DoubleLeftOutlined,
26
+ DoubleRightOutlined,
27
+ } from '@ant-design/icons';
28
+ import SearchFunc from './Components/SearchFunc';
29
+ import { debounce } from 'lodash';
30
+
31
+ import AllFunc from './Components/AllFunc';
32
+ import {
33
+ getBreadcrumbNameMap,
34
+ ergodicMenuRoutes,
35
+ matchPath,
36
+ } from './utils';
37
+ import moment from 'moment';
38
+ import GlobalHeaderCom from './Components/GlobalHeader';
39
+ import CustomerMenu from './Components/CustomerMenu';
40
+ import CustomerMenuHeader from './Components/CustomerMenu/globalMenu/customMenuHeader';
41
+ import './index.less';
42
+ import { DndProvider, useDrag, useDrop } from 'react-dnd';
43
+ import { HTML5Backend } from 'react-dnd-html5-backend';
44
+ import ENUM from '@/utils/enumConfig';
45
+ import { memoizeOneFormatter } from '@/utils/utils';
46
+
47
+ const { TabPane } = Tabs;
48
+
49
+ export const RouterContext = React.createContext({});
50
+
51
+ export type BasicLayoutProps = {
52
+ breadcrumbNameMap: Record<string, MenuDataItem>;
53
+ route: ProLayoutProps['route'] & {
54
+ authority: string[];
55
+ };
56
+ settings: Settings;
57
+ } & ProLayoutProps;
58
+
59
+ export type BasicLayoutContext = { [K in 'location']: BasicLayoutProps[K] } & {
60
+ breadcrumbNameMap: Record<string, MenuDataItem>;
61
+ };
62
+
63
+ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] =>
64
+ menuList.map((item) => {
65
+ return {
66
+ ...item,
67
+ children: item.children ? menuDataRender(item.children) : undefined,
68
+ };
69
+ });
70
+
71
+ let UN_LISTTEN_DRP;
72
+ let routerArray = [];
73
+ let lastTwoRouterArray = [1, 2];
74
+
75
+ let draggerTabKeys = [];
76
+
77
+ const type = 'DraggableTabNode';
78
+ const DraggableTabNode = ({ index, children, moveNode }) => {
79
+ const ref = useRef(null);
80
+ const [{ isOver, dropClassName }, drop] = useDrop({
81
+ accept: type,
82
+ collect: (monitor) => {
83
+ const { index: dragIndex } = monitor.getItem() || {};
84
+
85
+ if (dragIndex === index) {
86
+ return {};
87
+ }
88
+
89
+ return {
90
+ isOver: monitor.isOver(),
91
+ dropClassName: 'dropping',
92
+ };
93
+ },
94
+ drop: (item) => {
95
+ moveNode(item.index, index);
96
+ },
97
+ });
98
+ const [, drag] = useDrag({
99
+ type,
100
+ item: {
101
+ index,
102
+ },
103
+ collect: (monitor) => ({
104
+ isDragging: monitor.isDragging(),
105
+ }),
106
+ });
107
+ drop(drag(ref));
108
+ return (
109
+ <div
110
+ ref={ref}
111
+ style={{
112
+ marginRight: 24,
113
+ }}
114
+ className={isOver ? dropClassName : ''}
115
+ >
116
+ {children}
117
+ </div>
118
+ );
119
+ };
120
+
121
+ const DraggableTabs = (props) => {
122
+ const { children, changeListenRouterState } = props;
123
+ const [order, setOrder] = useState([]);
124
+
125
+ const moveTabNode = (dragKey, hoverKey) => {
126
+ const newOrder = order.slice();
127
+ React.Children.forEach(children, (c) => {
128
+ if (c.key && newOrder.indexOf(c.key) === -1) {
129
+ newOrder.push(c.key);
130
+ }
131
+ });
132
+ const dragIndex = newOrder.indexOf(dragKey);
133
+ const hoverIndex = newOrder.indexOf(hoverKey);
134
+ newOrder.splice(dragIndex, 1);
135
+ newOrder.splice(hoverIndex, 0, dragKey);
136
+ changeListenRouterState(dragIndex, hoverIndex);
137
+ setOrder(newOrder);
138
+ };
139
+
140
+ const renderTabBar = (tabBarProps, DefaultTabBar) => (
141
+ <DefaultTabBar {...tabBarProps}>
142
+ {(node) => (
143
+ <DraggableTabNode
144
+ key={node.key}
145
+ index={node.key}
146
+ moveNode={moveTabNode}
147
+ >
148
+ {node}
149
+ </DraggableTabNode>
150
+ )}
151
+ </DefaultTabBar>
152
+ );
153
+
154
+ const tabs = [];
155
+ React.Children.forEach(children, (c) => {
156
+ tabs.push(c);
157
+ });
158
+ const orderTabs = tabs.slice().sort((a, b) => {
159
+ const orderA = order.indexOf(a.key);
160
+ const orderB = order.indexOf(b.key);
161
+
162
+ if (orderA !== -1 && orderB !== -1) {
163
+ return orderA - orderB;
164
+ }
165
+
166
+ if (orderA !== -1) {
167
+ return -1;
168
+ }
169
+
170
+ if (orderB !== -1) {
171
+ return 1;
172
+ }
173
+
174
+ const ia = tabs.indexOf(a);
175
+ const ib = tabs.indexOf(b);
176
+ return ia - ib;
177
+ });
178
+ return (
179
+ <DndProvider backend={HTML5Backend}>
180
+ <Tabs renderTabBar={renderTabBar} {...props}>
181
+ {orderTabs}
182
+ </Tabs>
183
+ </DndProvider>
184
+ );
185
+ };
186
+
187
+ const ItemMenu = (props) => {
188
+ const {
189
+ info: { key },
190
+ operateFun,
191
+ listenRouterState,
192
+ } = props;
193
+ let index = listenRouterState.findIndex((item) => item.key === key);
194
+
195
+ const menu = (
196
+ <Menu>
197
+ <Menu.Item key="0" style={{ fontSize: '12px', textAlign: 'center' }}>
198
+ <a
199
+ onClick={(e) => {
200
+ e.stopPropagation();
201
+ operateFun(key, 'self');
202
+ }}
203
+ >
204
+ 关闭当前标签
205
+ </a>
206
+ </Menu.Item>
207
+ <Menu.Item
208
+ disabled={index === 0}
209
+ key="1"
210
+ style={{ fontSize: '12px', textAlign: 'center' }}
211
+ >
212
+ <a
213
+ onClick={(e) => {
214
+ e.stopPropagation();
215
+ operateFun(key, 'left');
216
+ }}
217
+ >
218
+ 关闭其左侧标签
219
+ </a>
220
+ </Menu.Item>
221
+ <Menu.Item
222
+ disabled={index === listenRouterState.length - 1}
223
+ key="2"
224
+ style={{ fontSize: '12px', textAlign: 'center' }}
225
+ >
226
+ <a
227
+ onClick={(e) => {
228
+ e.stopPropagation();
229
+ operateFun(key, 'right');
230
+ }}
231
+ >
232
+ 关闭其右侧标签
233
+ </a>
234
+ </Menu.Item>
235
+ <Menu.Item
236
+ disabled={index === listenRouterState.length - 1}
237
+ key="3"
238
+ style={{ fontSize: '12px', textAlign: 'center' }}
239
+ >
240
+ <a
241
+ onClick={(e) => {
242
+ e.stopPropagation();
243
+ operateFun(key, 'other');
244
+ }}
245
+ >
246
+ 关闭其他标签
247
+ </a>
248
+ </Menu.Item>
249
+ <Menu.Item
250
+ disabled={index === listenRouterState.length - 1}
251
+ key="4"
252
+ style={{ fontSize: '12px', textAlign: 'center' }}
253
+ >
254
+ <a
255
+ onClick={(e) => {
256
+ e.stopPropagation();
257
+ operateFun(key, 'all');
258
+ }}
259
+ >
260
+ 关闭全部标签
261
+ </a>
262
+ </Menu.Item>
263
+ </Menu>
264
+ );
265
+ return (
266
+ <Dropdown overlay={menu} trigger={['hover']}>
267
+ <a
268
+ className="ant-dropdown-link"
269
+ onClick={(e) => {
270
+ e.preventDefault();
271
+ e.stopPropagation();
272
+ }}
273
+ >
274
+ <img style={{ marginRight: '-12px' }} src="./biaoqian-icon.svg" />
275
+ </a>
276
+ </Dropdown>
277
+ );
278
+ };
279
+
280
+ class BasicLayout extends React.PureComponent {
281
+ allFunc: any = createRef('');
282
+ customerMenuRef: any = createRef('');
283
+ actionRef: any = createRef<{
284
+ reload: () => void;
285
+ }>();
286
+ constructor(props) {
287
+ super(props);
288
+ routerArray = this.updateTree(props.route.routes);
289
+ const homeRouter = routerArray.filter(
290
+ (itemroute) => itemroute.key === '/',
291
+ )[0];
292
+ const breadcrumbNameMap = getBreadcrumbNameMap(
293
+ memoizeOneFormatter(props.route.routes, ''),
294
+ );
295
+ const hideMenuArray = ergodicMenuRoutes(props.route.routes);
296
+
297
+ this.state = {
298
+ listenRouterState: [
299
+ { ...homeRouter, key: '/', tab: '欢迎', closable: false },
300
+ ],
301
+ listenRouterKey: ['/'],
302
+ activeKey: '/',
303
+ homeRouter,
304
+ customerMatchs: [],
305
+ breadcrumbNameMap,
306
+ hideMenuArray,
307
+ keyWord: '',
308
+ collapse: false,
309
+ drawerLeftParams: {
310
+ visible: false,
311
+ width: 690,
312
+ title: '搜索',
313
+ onClose: () => {
314
+ this.setState({
315
+ drawerLeftParams: {
316
+ ...this.state.drawerLeftParams,
317
+ visible: false,
318
+ },
319
+ });
320
+ },
321
+ },
322
+ currentSubMenuData: [],
323
+ showSubMenu: false,
324
+ isSlider: false,
325
+ };
326
+ }
327
+
328
+ componentDidMount() {
329
+ const {
330
+ history,
331
+ location,
332
+ itemPath,
333
+ pathToRegexp,
334
+ } = this.props;
335
+
336
+ let istParent = 0;
337
+
338
+ var self = this;
339
+
340
+ window.top != window &&
341
+ window.addEventListener('message', function (e) {
342
+ istParent = 1;
343
+ if (localStorage.getItem(ENUM.BROWSER_CACHE.CHILD_APP_BACK)) {
344
+ localStorage.removeItem(ENUM.BROWSER_CACHE.CHILD_APP_BACK);
345
+ } else {
346
+ localStorage.setItem('isTabChange', true);
347
+ }
348
+
349
+ if (typeof e.data === 'string') {
350
+ history.push(e.data.replace(/^\/\w+\//, '/'));
351
+ } else {
352
+ const info = e.data;
353
+ if (info.type === 'remove') {
354
+ self.tabActions['remove'](info.key.replace(/^\/\w+\//, '/'));
355
+ }
356
+ }
357
+ });
358
+
359
+ UN_LISTTEN_DRP = history.listen((route) => {
360
+ if ((window as any).__POWERED_BY_QIANKUN__) {
361
+ if (window.location.href.indexOf(`/${itemPath}`) === -1) return;
362
+ }
363
+ const {
364
+ listenRouterState,
365
+ listenRouterKey,
366
+ customerMatchs,
367
+ hideMenuArray,
368
+ } = this.state;
369
+ let newListenRouterState = [...listenRouterState];
370
+ let newListenRouterKey = [...listenRouterKey];
371
+
372
+ let replaceRouter = routerArray.filter((itemRoute) =>
373
+ pathToRegexp(itemRoute.key || '').test(route.pathname),
374
+ )[0];
375
+
376
+ if (!istParent) {
377
+ if (route.pathname === '/') return;
378
+ window.parent.postMessage(`/parent/${itemPath}${route.pathname}`, '*');
379
+ }
380
+
381
+ let currentKey = '';
382
+
383
+ if (replaceRouter && replaceRouter.isOnlyOnePage) {
384
+ // 处理中英文和特殊字符
385
+ currentKey = decodeURIComponent(route.pathname);
386
+ } else {
387
+ currentKey = decodeURIComponent(
388
+ route.pathname + this.parseQueryString(route.search),
389
+ );
390
+ }
391
+
392
+ // 防止出错
393
+ if (listenRouterKey.length !== listenRouterState.length) {
394
+ listenRouterState.forEach((item, index) => {
395
+ listenRouterKey[index] = item.key;
396
+ });
397
+ }
398
+
399
+ if (!listenRouterKey.includes(currentKey)) {
400
+ if (!replaceRouter) {
401
+ replaceRouter = routerArray.filter(
402
+ (itemroute) => itemroute.key === '/404',
403
+ )?.[0];
404
+
405
+ this.setState(
406
+ {
407
+ listenRouterState: [
408
+ ...listenRouterState,
409
+ { ...replaceRouter, key: currentKey, tab: '404' },
410
+ ],
411
+ activeKey: currentKey,
412
+ listenRouterKey: [...listenRouterKey, currentKey],
413
+ },
414
+ () => {
415
+ this.checkisNavSlide();
416
+ },
417
+ );
418
+ } else {
419
+ const match = matchPath(route.pathname, { path: replaceRouter.key }, pathToRegexp);
420
+ newListenRouterState = [
421
+ ...newListenRouterState,
422
+ {
423
+ ...replaceRouter,
424
+ query: route.query,
425
+ match: match,
426
+ key: currentKey,
427
+ tab: this.getPageTitle(route.pathname) + '',
428
+ },
429
+ ];
430
+ newListenRouterKey = [...listenRouterKey, currentKey];
431
+ }
432
+ }
433
+
434
+ // 处理hideMenu页面自动关闭
435
+ lastTwoRouterArray.push(route.pathname);
436
+ lastTwoRouterArray.shift();
437
+ if (
438
+ !localStorage.getItem('isTabChange') &&
439
+ !localStorage.getItem('isMenuClick')
440
+ ) {
441
+ if (
442
+ lastTwoRouterArray[0] &&
443
+ typeof lastTwoRouterArray[0] === 'string'
444
+ ) {
445
+ let needRemoveKeyArray = hideMenuArray.filter((itemRoute) =>
446
+ pathToRegexp(itemRoute.path || '').test(lastTwoRouterArray[0]),
447
+ );
448
+ // lastTwoRouterArray[0] != lastTwoRouterArray[1] 该判断条件用于判断是否是tab删除操作,如果是tab页删除操作,删除的是不是最后一个打开的tab页,执行history.push会导致错误的将最后打开的那个tab页也删除掉
449
+ if (
450
+ needRemoveKeyArray.length &&
451
+ lastTwoRouterArray[0] != lastTwoRouterArray[1]
452
+ ) {
453
+ if (
454
+ (!(
455
+ lastTwoRouterArray[0].indexOf('/order/mainOrder/supplement') >=
456
+ 0
457
+ ) ||
458
+ !pathToRegexp(
459
+ '/order/mainOrder/:parmode/separateOrder/:id',
460
+ ).test(lastTwoRouterArray[1])) &&
461
+ (!pathToRegexp(
462
+ '/order/mainOrder/:parmode/separateOrder/:id',
463
+ ).test(lastTwoRouterArray[0]) ||
464
+ !(
465
+ lastTwoRouterArray[1].indexOf(
466
+ 'order/mainOrder/separateOrder/',
467
+ ) >= 0
468
+ ))
469
+ ) {
470
+ if (!route.state?.thisHideInMenuDoNotClose) {
471
+ newListenRouterState = newListenRouterState.filter((item) => {
472
+ const [pathname] = item.key ? item.key.split('?') : [];
473
+ return pathname && pathname !== lastTwoRouterArray[0];
474
+ });
475
+ newListenRouterKey = newListenRouterKey.filter((item) => {
476
+ const [pathname] = item ? item.split('?') : [];
477
+ return pathname && pathname !== lastTwoRouterArray[0];
478
+ });
479
+ }
480
+ }
481
+ }
482
+ }
483
+ // refs?.tableRef?.current?.refreshTable();
484
+ } else {
485
+ setTimeout(() => {
486
+ // 处理页面刷新两面
487
+ localStorage.removeItem('isTabChange');
488
+ localStorage.removeItem('isMenuClick');
489
+ }, 0);
490
+ }
491
+ this.setState(
492
+ {
493
+ //路由监听函数最后执行setState,避免处理hideMenu类型页面自动关闭的逻辑块内获取不到最新state的listenRouterState和listenRouterKey
494
+ activeKey: currentKey,
495
+ listenRouterState: newListenRouterState,
496
+ listenRouterKey: newListenRouterKey,
497
+ },
498
+ () => {
499
+ this.checkisNavSlide();
500
+ },
501
+ );
502
+
503
+ istParent = 0;
504
+ });
505
+
506
+ if (
507
+ localStorage.getItem('firstPage') &&
508
+ localStorage.getItem('firstPage')?.startsWith(`#/${itemPath}/`)
509
+ ) {
510
+ istParent = 1;
511
+ history.push(
512
+ localStorage
513
+ .getItem('firstPage')
514
+ ?.slice(1)
515
+ .replace(/^\/\w+\//, '/'),
516
+ );
517
+ } else {
518
+ history.push(location);
519
+ }
520
+ }
521
+
522
+ componentWillUnmount() {
523
+ // eslint-disable-next-line no-unused-expressions
524
+ UN_LISTTEN_DRP && UN_LISTTEN_DRP();
525
+ }
526
+
527
+ parseQueryString = (queryString) => {
528
+ if (!queryString) {
529
+ return '';
530
+ }
531
+
532
+ if (queryString.indexOf('?') < 0) {
533
+ return `?${queryString}`;
534
+ }
535
+
536
+ return queryString;
537
+ };
538
+
539
+ updateTree = (Tree) => {
540
+ const treeData = Tree;
541
+ const treeList = [];
542
+ // 递归获取树列表
543
+ const getTreeList = (data) => {
544
+ data.forEach((node) => {
545
+ if (node.routes && node.routes.length > 0) {
546
+ getTreeList(node.routes);
547
+ } else {
548
+ treeList.push({
549
+ tab: node.locale,
550
+ key: node.path,
551
+ locale: node.locale,
552
+ closable: true,
553
+ content: node.component,
554
+ name: node.name,
555
+ hideInMenu: node.hideInMenu,
556
+ isOnlyOnePage: node.isOnlyOnePage,
557
+ });
558
+ }
559
+ });
560
+ };
561
+ getTreeList(treeData);
562
+ return treeList;
563
+ };
564
+
565
+ getDictionarySource = (dicCode: string, needConvertInterger = false) => {
566
+ const { dictionaryData } = this.props;
567
+
568
+ let dicData = {};
569
+
570
+ if (!dictionaryData) {
571
+ let storageDic = localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES)
572
+ ? JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES))
573
+ : {};
574
+ dicData = storageDic[dicCode];
575
+ } else {
576
+ dicData = dictionaryData[dicCode];
577
+ }
578
+ // if (!dicData || !dicData.length) {
579
+ // throw new Error(`当前没有${dicCode}字典值`);
580
+ // }
581
+
582
+ try {
583
+ if (needConvertInterger) {
584
+ dicData = dicData.map((item: { text: string; value: string }) => ({
585
+ ...item,
586
+ value: parseFloat(item.value),
587
+ }));
588
+ }
589
+ } catch (e) { }
590
+
591
+ return dicData;
592
+ };
593
+
594
+ getDictionaryTextByValue = (dicCode: string, value: string) => {
595
+ let dicData = [];
596
+ let dictionaryData: any;
597
+ if (!dictionaryData) {
598
+ let storageDic = localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES)
599
+ ? JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.DICT_CODES))
600
+ : {};
601
+ dicData = storageDic[dicCode];
602
+ } else {
603
+ dicData = dictionaryData[dicCode];
604
+ }
605
+
606
+ if (!dicData || !dicData.length) {
607
+ // throw new Error(`当前没有${dicCode}字典值`);
608
+ }
609
+
610
+ if (value === undefined) return '- -';
611
+
612
+ const dicItemArray = dicData?.filter(
613
+ (item: { value: string }) => item.value === value.toString(),
614
+ );
615
+
616
+ if (!dicItemArray?.length) {
617
+ // throw new Error(`当前${dicCode}字典值合没有${value}的数据`)
618
+ return value;
619
+ }
620
+
621
+ return dicItemArray[0].text;
622
+ };
623
+
624
+ timeFormat = (timeStr, format, notNeedConvertTimeZone) => {
625
+ if (!timeStr) return '- -';
626
+
627
+ if (notNeedConvertTimeZone) {
628
+ return moment(timeStr).format(format);
629
+ }
630
+
631
+ return moment(timeStr).add(8, 'hours').format(format) || '- -';
632
+ };
633
+
634
+ onChange = (key) => {
635
+ // console.log('onChange');
636
+ if (key !== this.state.activeKey) {
637
+ this.setState({
638
+ activeKey: key,
639
+ });
640
+ localStorage.setItem('isTabChange', '1');
641
+ history.push(key);
642
+ }
643
+ };
644
+
645
+ getPageTitle = (pathname) => {
646
+ const { formatMessage } = this.props;
647
+ const { breadcrumbNameMap } = this.state;
648
+ const currRouterData = this.matchParamsPath(pathname, breadcrumbNameMap);
649
+
650
+ if (!currRouterData) {
651
+ return '';
652
+ }
653
+ const pageName = formatMessage({
654
+ id: currRouterData.locale || currRouterData.name,
655
+ defaultMessage: currRouterData.name,
656
+ });
657
+
658
+ return `${pageName}`;
659
+ };
660
+
661
+ matchParamsPath = (pathname, breadcrumbNameMap) => {
662
+ const { pathToRegexp } = this.props;
663
+ const pathKey = Object.keys(breadcrumbNameMap).find((key) =>
664
+ pathToRegexp(key).test(pathname),
665
+ );
666
+ return breadcrumbNameMap[pathKey];
667
+ };
668
+
669
+ onEdit = (
670
+ targetKey: React.MouseEvent | React.KeyboardEvent | string,
671
+ action: string,
672
+ ) => {
673
+ this.tabActions[action](targetKey);
674
+ };
675
+
676
+ tabActions: any = {
677
+ remove: (targetKey: string) => {
678
+ const { listenRouterState, activeKey, customerMatchs, listenRouterKey } =
679
+ this.state;
680
+
681
+ let lastIndex: number = 0;
682
+ let newActiveKey: string | undefined = activeKey;
683
+ let newListenRouterState = [];
684
+ let newListenRouterKey = [];
685
+
686
+ if (targetKey === activeKey) {
687
+ listenRouterState.forEach((pane, i) => {
688
+ if (pane.key === targetKey) {
689
+ lastIndex = i - 1;
690
+ }
691
+ });
692
+
693
+ newListenRouterState = listenRouterState.filter(
694
+ (item) => item.key !== targetKey,
695
+ );
696
+ newListenRouterKey = listenRouterKey.filter(
697
+ (item) => item !== targetKey,
698
+ );
699
+
700
+ if (lastIndex < 0) {
701
+ lastIndex = 0;
702
+ }
703
+
704
+ newActiveKey = newListenRouterState[lastIndex].key;
705
+ } else {
706
+ newListenRouterState = listenRouterState.filter(
707
+ (item) => item.key !== targetKey,
708
+ );
709
+ newListenRouterKey = listenRouterKey.filter(
710
+ (item) => item !== targetKey,
711
+ );
712
+ }
713
+
714
+ this.setState(
715
+ {
716
+ activeKey: newActiveKey,
717
+ listenRouterState: newListenRouterState,
718
+ listenRouterKey: newListenRouterKey,
719
+ },
720
+ () => {
721
+ history.push({
722
+ pathname: newActiveKey,
723
+ });
724
+ this.checkisNavSlide();
725
+ },
726
+ );
727
+ },
728
+ };
729
+
730
+ updateState = (newListenRouterState, newListenRouterKey, cb) => {
731
+ this.setState(
732
+ {
733
+ listenRouterState: newListenRouterState,
734
+ listenRouterKey: newListenRouterKey,
735
+ },
736
+ () => {
737
+ this.checkisNavSlide();
738
+ if (cb) cb();
739
+ },
740
+ );
741
+ };
742
+
743
+ handleClose = () => {
744
+ this.setState({
745
+ drawerLeftParams: {
746
+ ...this.state.drawerLeftParams,
747
+ visible: false,
748
+ },
749
+ isCollapse: true,
750
+ });
751
+ this.allFunc.current?.close?.();
752
+ this.customerMenuRef.current?.close?.();
753
+ };
754
+
755
+ handleMenuClick = (item: any) => {
756
+ if (item.children || !item.component) return;
757
+ history.push({
758
+ pathname: item.path,
759
+ });
760
+ this.setShowMenu(false);
761
+ };
762
+
763
+ getMenuDom = (menuData) => {
764
+ return menuData.map((item) => (
765
+ <div>
766
+ <div
767
+ onClick={() => {
768
+ this.handleMenuClick(item);
769
+ }}
770
+ className={`${'menu_item'} ${item.children || !item.component ? '' : 'link_style'
771
+ }`}
772
+ style={{
773
+ fontWeight: item.children || !item.component ? 'bolder' : '400',
774
+ paddingLeft: '10px',
775
+ marginTop: item.children || !item.component ? '5px' : '0px',
776
+ fontSize: item.children || !item.component ? '14px' : '12px',
777
+ }}
778
+ >
779
+ {item.name}
780
+ </div>
781
+ {!!item.children &&
782
+ !!item.children.length &&
783
+ this.getMenuDom(item.children)}
784
+ </div>
785
+ ));
786
+ };
787
+
788
+ setShowMenu = debounce((isShow) => {
789
+ this.setState({
790
+ showSubMenu: isShow,
791
+ });
792
+ }, 500);
793
+
794
+ //设置tabs标签左右滚动
795
+ setTabNavTransLate = (num) => {
796
+ let globalTabsNav = document
797
+ .getElementById('globalTabs')
798
+ ?.getElementsByClassName('ant-tabs-nav-list')?.[0];
799
+ let globalTabsNavWrap = document
800
+ .getElementById('globalTabs')
801
+ ?.getElementsByClassName('ant-tabs-nav-wrap')?.[0];
802
+ let wrapWidth = globalTabsNavWrap.offsetWidth; //tabsNav父节点宽度
803
+ let navListWidth = globalTabsNav.offsetWidth; //tabsNav总宽度
804
+ if (navListWidth - wrapWidth <= 0) return;
805
+ let maxTransX = navListWidth - wrapWidth; // 允许移动最大宽度
806
+ let transXStr = document.defaultView?.getComputedStyle(
807
+ globalTabsNav,
808
+ null,
809
+ ).transform;
810
+ let transx = transXStr?.split(',')[4]; //当前translateX的值
811
+
812
+ let targetTransX = Math.abs(Number(transx)) + num;
813
+ if (targetTransX <= 0) targetTransX = 0;
814
+ if (targetTransX >= Number(maxTransX)) targetTransX = Number(maxTransX);
815
+ globalTabsNav.style.transform = 'translateX(-' + targetTransX + 'px)';
816
+ };
817
+
818
+ checkisNavSlide = () => {
819
+ if (window.top != window) return;
820
+ //监听tabs页签总长度判断是否可点击滑动
821
+ let globalTabsNav = document
822
+ .getElementById('globalTabs')
823
+ ?.getElementsByClassName('ant-tabs-nav-list')?.[0];
824
+ let globalTabsNavWrap = document
825
+ .getElementById('globalTabs')
826
+ ?.getElementsByClassName('ant-tabs-nav-wrap')?.[0];
827
+ let wrapWidth = globalTabsNavWrap?.offsetWidth; //tabsNav父节点宽度
828
+ let navListWidth = globalTabsNav?.offsetWidth; //tabsNav总宽度
829
+ if (navListWidth - wrapWidth <= 0) {
830
+ this.setState({
831
+ isSlider: false,
832
+ });
833
+ return;
834
+ }
835
+ this.setState({
836
+ isSlider: true,
837
+ });
838
+ };
839
+
840
+ changeListenRouterState = (dragIndex: number, hoverIndex: number) => {
841
+ const { listenRouterState, listenRouterKey } = this.state;
842
+ let dragItem = listenRouterState[dragIndex];
843
+ let dragKeyItem = listenRouterKey[dragIndex];
844
+
845
+ listenRouterState.splice(dragIndex, 1);
846
+ listenRouterState.splice(hoverIndex, 0, dragItem);
847
+
848
+ listenRouterKey.splice(dragIndex, 1);
849
+ listenRouterKey.splice(hoverIndex, 0, dragKeyItem);
850
+ };
851
+
852
+ operateFun = (key, type) => {
853
+ const { listenRouterState, activeKey, listenRouterKey } = this.state;
854
+ let deleteKey = '';
855
+ let newlistenRouterState = [];
856
+ let newlistenRouterKey = [];
857
+ let newActiveKey = '';
858
+ let deleteIndex = 0;
859
+ if (type === 'self') {
860
+ deleteIndex = listenRouterState.findIndex((item) => item.key === key);
861
+ deleteKey = key;
862
+ if (deleteIndex > 0) {
863
+ newActiveKey = listenRouterState[deleteIndex - 1].key;
864
+ } else {
865
+ newActiveKey = listenRouterState[1].key;
866
+ }
867
+ newlistenRouterState = listenRouterState.filter((d) => d.key !== key);
868
+ newlistenRouterKey = listenRouterKey.filter((d) => d !== key);
869
+ this.updateState(newlistenRouterState, newlistenRouterKey, () => {
870
+ if (deleteKey === activeKey) {
871
+ history.push({
872
+ pathname: newActiveKey,
873
+ });
874
+ }
875
+ });
876
+ }
877
+ if (type === 'left') {
878
+ const index = listenRouterState.findIndex((item) => item.key === key);
879
+ newlistenRouterState = listenRouterState.filter(
880
+ (d: any, i: number) => i >= index || d.key === '/',
881
+ );
882
+ newlistenRouterKey = listenRouterKey.filter(
883
+ (d: any, i: number) => i >= index || d === '/',
884
+ );
885
+ this.updateState(newlistenRouterState, newlistenRouterKey, () => {
886
+ if (newlistenRouterKey.find((item) => item === activeKey)) {
887
+ return;
888
+ } else {
889
+ history.push({
890
+ pathname: key,
891
+ });
892
+ }
893
+ });
894
+ }
895
+ if (type === 'right') {
896
+ const index = listenRouterState.findIndex((item) => item.key === key);
897
+ newlistenRouterState = listenRouterState.filter(
898
+ (d: any, i: number) => i <= index || d.key === '/',
899
+ );
900
+ newlistenRouterKey = listenRouterKey.filter(
901
+ (d: any, i: number) => i <= index || d === '/',
902
+ );
903
+ this.updateState(
904
+ listenRouterState.filter(
905
+ (d: any, i: number) => i <= index || d.key === '/',
906
+ ),
907
+ listenRouterKey.filter((d: any, i: number) => i <= index || d === '/'),
908
+ () => {
909
+ if (newlistenRouterKey.find((item) => item === activeKey)) {
910
+ return;
911
+ } else {
912
+ history.push({
913
+ pathname: key,
914
+ });
915
+ }
916
+ },
917
+ );
918
+ }
919
+ if (type === 'all') {
920
+ this.updateState(
921
+ listenRouterState.filter((item) => item.key === '/'),
922
+ listenRouterKey.filter((item) => item === '/'),
923
+ () => {
924
+ history.push({
925
+ pathname: '/',
926
+ });
927
+ },
928
+ );
929
+ }
930
+ if (type === 'other') {
931
+ this.updateState(
932
+ listenRouterState.filter(
933
+ (item) => item.key === key || item.key === '/',
934
+ ),
935
+ listenRouterKey.filter((item) => item === key || item === '/'),
936
+ () => {
937
+ if (key !== activeKey) {
938
+ history.push({
939
+ pathname: key,
940
+ });
941
+ }
942
+ },
943
+ );
944
+ }
945
+ };
946
+
947
+ render() {
948
+ const {
949
+ listenRouterState,
950
+ activeKey,
951
+ listenRouterKey,
952
+ drawerLeftParams,
953
+ collapse,
954
+ currentSubMenuData,
955
+ showSubMenu,
956
+ currentSubPath,
957
+ } = this.state;
958
+ const { originRoutes, itemPath, defaultSettings, transparentProps={} } = this.props;
959
+ const TabTitle: React.FC<{}> = ({ item, index, updateState }) => {
960
+ return (
961
+ <div className="tab_title_content">
962
+ {item.tab}
963
+ {item.key !== '/' && (
964
+ <ItemMenu
965
+ info={item}
966
+ operateFun={this.operateFun}
967
+ listenRouterState={listenRouterState}
968
+ />
969
+ )}
970
+ </div>
971
+ );
972
+ };
973
+
974
+ // 左侧菜单 route
975
+ const dataShowRoute = this.props.routes.find(
976
+ (route) => route.path === '/homePage/data-show',
977
+ ); // 添加数据大屏
978
+ const { route, ...restPrpos } = this.props;
979
+ const exist = route.routes.find(
980
+ (route) => route.path === '/homePage/data-show',
981
+ );
982
+ if (dataShowRoute && !exist) {
983
+ route.routes.splice(1, 0, dataShowRoute);
984
+ }
985
+
986
+ const menu = (
987
+ <Menu>
988
+ <Menu.Item
989
+ key="0"
990
+ style={{
991
+ background: '#FFFFFF',
992
+ color: '#848484',
993
+ fontSize: '12px',
994
+ textAlign: 'center',
995
+ }}
996
+ >
997
+ <div>已打开的页签数: {listenRouterState.length}</div>
998
+ </Menu.Item>
999
+ <Menu.Item key="1" style={{ fontSize: '12px', textAlign: 'center' }}>
1000
+ <a
1001
+ onClick={() => {
1002
+ // 关闭全部
1003
+ this.updateState(
1004
+ [
1005
+ {
1006
+ ...this.state.homeRouter,
1007
+ key: '/',
1008
+ tab: '欢迎',
1009
+ closable: false,
1010
+ },
1011
+ ],
1012
+ ['/'],
1013
+ () => {
1014
+ history.push('/');
1015
+ },
1016
+ );
1017
+ }}
1018
+ >
1019
+ 关闭全部标签
1020
+ </a>
1021
+ </Menu.Item>
1022
+ <Menu.Item key="2" style={{ fontSize: '12px', textAlign: 'center' }}>
1023
+ <a
1024
+ onClick={() => {
1025
+ if (activeKey === '/') return;
1026
+ const index = listenRouterState.findIndex(
1027
+ (item) => item.key === activeKey,
1028
+ );
1029
+ let newActiveKey = '';
1030
+ if (index > 0) {
1031
+ newActiveKey = listenRouterState[index - 1].key;
1032
+ } else {
1033
+ newActiveKey = listenRouterState[1].key;
1034
+ }
1035
+ this.updateState(
1036
+ listenRouterState.filter((d) => d.key !== activeKey),
1037
+ listenRouterKey.filter((d) => d !== activeKey),
1038
+ () => {
1039
+ history.push({
1040
+ pathname: newActiveKey,
1041
+ });
1042
+ },
1043
+ );
1044
+ }}
1045
+ >
1046
+ 关闭当前标签
1047
+ </a>
1048
+ </Menu.Item>
1049
+ <Menu.Item key="3" style={{ fontSize: '12px', textAlign: 'center' }}>
1050
+ <a
1051
+ onClick={() => {
1052
+ const index = listenRouterState.findIndex(
1053
+ (item) => item.key === activeKey,
1054
+ );
1055
+ // let deleteKey = listenRouterState[index - 1]?.key;
1056
+ // if (deleteKey === '/') {
1057
+ // message.warning('首页不可关闭。');
1058
+ // return;
1059
+ // }
1060
+
1061
+ this.updateState(
1062
+ listenRouterState.filter(
1063
+ (d: any, i: number) => i >= index || d.key === '/',
1064
+ ),
1065
+ listenRouterKey.filter(
1066
+ (d: any, i: number) => i >= index || d === '/',
1067
+ ),
1068
+ );
1069
+ }}
1070
+ >
1071
+ 关闭其左侧标签
1072
+ </a>
1073
+ </Menu.Item>
1074
+ <Menu.Item key="4" style={{ fontSize: '12px', textAlign: 'center' }}>
1075
+ <a
1076
+ onClick={() => {
1077
+ let index = listenRouterState.findIndex(
1078
+ (item) => item.key === activeKey,
1079
+ );
1080
+ this.updateState(
1081
+ listenRouterState.filter(
1082
+ (d: any, i: number) => i <= index || d.key === '/',
1083
+ ),
1084
+ listenRouterKey.filter(
1085
+ (d: any, i: number) => i <= index || d === '/',
1086
+ ),
1087
+ );
1088
+ }}
1089
+ >
1090
+ 关闭其右侧标签
1091
+ </a>
1092
+ </Menu.Item>
1093
+ </Menu>
1094
+ );
1095
+
1096
+ const filterByMenuDate = (
1097
+ data: MenuDataItem[],
1098
+ keyWord: string,
1099
+ ): MenuDataItem[] =>
1100
+ data
1101
+ .map((item) => {
1102
+ if (item.name && item.name.includes(keyWord)) {
1103
+ return {
1104
+ ...item,
1105
+ };
1106
+ }
1107
+ return undefined;
1108
+ })
1109
+ .filter((item) => item) as MenuDataItem[];
1110
+
1111
+ let weiqianduanProps = {};
1112
+ let isWeiqianduan = false;
1113
+
1114
+ if (window.top != window) {
1115
+ isWeiqianduan = true;
1116
+ weiqianduanProps = {
1117
+ headerRender: false,
1118
+ footerRender: false,
1119
+ menuRender: false,
1120
+ menuHeaderRender: false,
1121
+ menuExtraRender: false,
1122
+ };
1123
+ }
1124
+
1125
+ const OperationsSlot: Record<PositionType, React.ReactNode> = {
1126
+ left: (
1127
+ <div className={'tab_left_operate'}>
1128
+ <div
1129
+ onClick={() => {
1130
+ history.push({
1131
+ pathname: '/',
1132
+ });
1133
+ }}
1134
+ >
1135
+ <HomeOutlined />
1136
+ </div>
1137
+ <div
1138
+ style={{ opacity: this.state.isSlider ? 1 : 0.5 }}
1139
+ onClick={() => {
1140
+ this.setTabNavTransLate(-100);
1141
+ }}
1142
+ >
1143
+ <DoubleLeftOutlined />
1144
+ </div>
1145
+ </div>
1146
+ ),
1147
+ right: (
1148
+ <div
1149
+ style={{ opacity: this.state.isSlider ? 1 : 0.5 }}
1150
+ className={'tab_right_operate'}
1151
+ onClick={() => {
1152
+ this.setTabNavTransLate(100);
1153
+ }}
1154
+ >
1155
+ <DoubleRightOutlined />
1156
+ </div>
1157
+ ),
1158
+ };
1159
+
1160
+ return (
1161
+ <ProLayout
1162
+ actionRef={this.actionRef}
1163
+ onMenuHeaderClick={() => history.push('/')}
1164
+ menuHeaderRender={({ }) => (
1165
+ <CustomerMenuHeader
1166
+ originRoutes={originRoutes}
1167
+ itemPath={itemPath}
1168
+ handleClose={this.handleClose}
1169
+ collapsed={collapse}
1170
+ />
1171
+ )}
1172
+ menuExtraRender={() => {
1173
+ if (!collapse) {
1174
+ return (
1175
+ <div>
1176
+ <CustomerMenu
1177
+ originRoutes={originRoutes}
1178
+ itemPath={itemPath}
1179
+ ref={this.customerMenuRef}
1180
+ actionRef={this.actionRef}
1181
+ handleClose={this.handleClose}
1182
+ isCollapse={this.state.collapse}
1183
+ />
1184
+ </div>
1185
+ );
1186
+ }
1187
+ return (
1188
+ <div className="collapse_icon_close">
1189
+ <span
1190
+ className="collapse_icon"
1191
+ onClick={() => {
1192
+ this.setState({
1193
+ collapse: !collapse,
1194
+ });
1195
+ }}
1196
+ >
1197
+ <MenuUnfoldOutlined />
1198
+ </span>
1199
+ </div>
1200
+ );
1201
+ }}
1202
+ menuProps={{
1203
+ onClick: () => {
1204
+ localStorage.setItem('isMenuClick', 'true');
1205
+ },
1206
+ }}
1207
+ collapsed={collapse}
1208
+ onCollapse={(boo: boolean) => {
1209
+ this.setState({
1210
+ collapse: boo,
1211
+ });
1212
+ }}
1213
+ menuItemRender={(menuItemProps, defaultDom) => {
1214
+ if (menuItemProps?.path === '/') {
1215
+ return (
1216
+ <>
1217
+ <div className="one_menu_wrap">
1218
+ <Link
1219
+ onClick={() => {
1220
+ localStorage.setItem('isMenuClick', 'true');
1221
+ }}
1222
+ to={menuItemProps.path}
1223
+ >
1224
+ {defaultDom}
1225
+ </Link>
1226
+ </div>
1227
+ </>
1228
+ );
1229
+ }
1230
+ return (
1231
+ <Link
1232
+ onClick={() => {
1233
+ localStorage.setItem('isMenuClick', 'true');
1234
+ }}
1235
+ to={menuItemProps.path}
1236
+ >
1237
+ {defaultDom}
1238
+ </Link>
1239
+ );
1240
+ }}
1241
+ subMenuItemRender={(menuItemProps, defaultDom) => {
1242
+ return (
1243
+ <div
1244
+ style={{
1245
+ height: '40px',
1246
+ lineHeight: '40px',
1247
+ position: 'relative',
1248
+ overflow: 'hidden',
1249
+ textOverflow: 'ellipsis',
1250
+ whiteSpace: 'nowrap',
1251
+ boxSizing: 'border-box',
1252
+ paddingRight: '10px',
1253
+ }}
1254
+ onMouseEnter={() => {
1255
+ if (
1256
+ menuItemProps.pro_layout_parentKeys &&
1257
+ menuItemProps.pro_layout_parentKeys.length
1258
+ )
1259
+ return;
1260
+ this.setState({
1261
+ currentSubMenuData: menuItemProps.children,
1262
+ currentSubPath: menuItemProps.path,
1263
+ });
1264
+ this.setShowMenu(true);
1265
+ }}
1266
+ onMouseLeave={() => {
1267
+ this.setShowMenu(false);
1268
+ }}
1269
+ >
1270
+ {defaultDom}
1271
+ {showSubMenu &&
1272
+ currentSubPath === menuItemProps.path &&
1273
+ !collapse && (
1274
+ <CaretLeftOutlined
1275
+ style={{ position: 'absolute', top: '14px', right: '-4px' }}
1276
+ />
1277
+ )}
1278
+ </div>
1279
+ );
1280
+ }}
1281
+ collapsedButtonRender={() => {
1282
+ return (
1283
+ <div
1284
+ onClick={(e) => {
1285
+ e.stopPropagation();
1286
+ }}
1287
+ className="banquan"
1288
+ >
1289
+ {''}
1290
+ </div>
1291
+ );
1292
+ }}
1293
+ postMenuData={(menus) => {
1294
+ return [...filterByMenuDate(menus || [], this.state.keyWord)];
1295
+ }}
1296
+ links={[
1297
+ !this.state.collapse ? (
1298
+ <AllFunc
1299
+ ref={this.allFunc}
1300
+ itemPath={itemPath}
1301
+ handleClose={this.handleClose}
1302
+ isCollapse={this.state.collapse}
1303
+ />
1304
+ ) : (
1305
+ ''
1306
+ ),
1307
+ ]}
1308
+ onPageChange={() => {
1309
+ const { location } = history;
1310
+ // 如果没有登录,重定向到 login
1311
+ if (
1312
+ !localStorage.getItem(ENUM.BROWSER_CACHE.USER_INFO) &&
1313
+ location.pathname !== '/user/login'
1314
+ ) {
1315
+ history.push('/user/login');
1316
+ }
1317
+ }}
1318
+ headerRender={(props) => <GlobalHeaderCom {...props} />}
1319
+ menu={{
1320
+ request: async () => {
1321
+ return JSON.parse(
1322
+ localStorage.getItem(`customerMenu_${itemPath}_front`) || '[]',
1323
+ );
1324
+ },
1325
+ type: 'group',
1326
+ }}
1327
+ route={route}
1328
+ {...restPrpos}
1329
+ {...defaultSettings}
1330
+ {...weiqianduanProps}
1331
+ >
1332
+ <div id="globalTabsContent" className="globalTabs">
1333
+ <DraggableTabs
1334
+ activeKey={activeKey}
1335
+ id="globalTabs"
1336
+ onChange={this.onChange}
1337
+ // tabBarExtraContent={operations}
1338
+ type="editable-card"
1339
+ tabBarStyle={{
1340
+ background: '#f3f3f3',
1341
+ height: '28px',
1342
+ marginRight: 0,
1343
+ fontSize: '12px',
1344
+ color: '#2C2F2E70',
1345
+ marginBottom: '-2px',
1346
+ position: 'fixed',
1347
+ top: 50,
1348
+ zIndex: 10,
1349
+ width: collapse ? 'calc(100% - 75px)' : 'calc(100% - 167px)',
1350
+ display: isWeiqianduan ? 'none' : 'flex',
1351
+ }}
1352
+ tabPosition="top"
1353
+ tabBarGutter={8}
1354
+ onEdit={this.onEdit}
1355
+ tabBarExtraContent={OperationsSlot}
1356
+ animated={false}
1357
+ hideAdd
1358
+ >
1359
+ {listenRouterState.map((item, index) => (
1360
+ <TabPane
1361
+ tab={
1362
+ <TabTitle
1363
+ item={item}
1364
+ index={index}
1365
+ updateState={this.updateState}
1366
+ />
1367
+ }
1368
+ style={{ marginTop: isWeiqianduan ? 0 : 30 }}
1369
+ key={item.key}
1370
+ closable={item.key !== '/'}
1371
+ closeIcon={<img src="./biaoqian-guanbi-icon.svg" />}
1372
+ >
1373
+ <WrapperComponent
1374
+ item={item}
1375
+ routerProps={this.props}
1376
+ getDictionarySource={this.getDictionarySource}
1377
+ getDictionaryTextByValue={this.getDictionaryTextByValue}
1378
+ timeFormat={this.timeFormat}
1379
+ transparentProps={transparentProps}
1380
+ />
1381
+ </TabPane>
1382
+ ))}
1383
+ </DraggableTabs>
1384
+ <div
1385
+ className="globalTabsOper"
1386
+ style={{
1387
+ position: 'fixed',
1388
+ top: '50px',
1389
+ zIndex: 10,
1390
+ background: '#fff',
1391
+ display: isWeiqianduan ? 'none' : 'block',
1392
+ borderLeft: '1px solid #E4E4E4',
1393
+ }}
1394
+ >
1395
+ <Dropdown overlay={menu} trigger={['click']}>
1396
+ <a
1397
+ className="ant-dropdown-link"
1398
+ onClick={(e) => e.preventDefault()}
1399
+ >
1400
+ <DashOutlined />
1401
+ </a>
1402
+ </Dropdown>
1403
+ </div>
1404
+ <SearchFunc itemPath={itemPath} {...drawerLeftParams}></SearchFunc>
1405
+ <div
1406
+ onMouseEnter={() => {
1407
+ this.setShowMenu(true);
1408
+ }}
1409
+ onMouseLeave={() => {
1410
+ this.setShowMenu(false);
1411
+ }}
1412
+ className={'sub_menu_content'}
1413
+ style={{ display: showSubMenu && !collapse ? 'block' : 'none' }}
1414
+ >
1415
+ {this.getMenuDom(currentSubMenuData)}
1416
+ </div>
1417
+ </div>
1418
+ </ProLayout>
1419
+ );
1420
+ }
1421
+ }
1422
+
1423
+ class WrapperComponent extends React.Component {
1424
+ constructor(props) {
1425
+ super(props);
1426
+ }
1427
+
1428
+ shouldComponentUpdate() {
1429
+ return false;
1430
+ }
1431
+
1432
+ render() {
1433
+ const {
1434
+ item,
1435
+ routerProps,
1436
+ getDictionarySource,
1437
+ getDictionaryTextByValue,
1438
+ timeFormat,
1439
+ transparentProps,
1440
+ } = this.props;
1441
+ return (
1442
+ <>
1443
+ {React.createElement(item.content, {
1444
+ getDictionarySource: getDictionarySource,
1445
+ getDictionaryTextByValue: getDictionaryTextByValue,
1446
+ timeFormat: timeFormat,
1447
+ ...routerProps,
1448
+ ...transparentProps,
1449
+ match: item.match,
1450
+ })}
1451
+ </>
1452
+ );
1453
+ }
1454
+ }
1455
+
1456
+ export default (props) => {
1457
+ const { initialState = {} } = useModel('@@initialState');
1458
+
1459
+ const { dictionaryData } = initialState;
1460
+ const intl = useIntl();
1461
+ const { formatMessage } = intl;
1462
+ return (
1463
+ <BasicLayout
1464
+ {...props}
1465
+ dictionaryData={dictionaryData}
1466
+ formatMessage={formatMessage}
1467
+ />
1468
+ );
1469
+ };