@bit-sun/business-component 2.2.13 → 2.2.14

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