@bit-sun/business-component 2.2.26 → 2.2.28

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