@bit-sun/business-component 2.0.37 → 2.0.39-alpha.0

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