@bit-sun/business-component 3.0.0-alpha.21 → 3.0.0-alpha.23

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