@bit-sun/business-component 2.2.1 → 2.2.3

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 (180) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.esm.js +6152 -5276
  10. package/dist/index.js +6151 -5274
  11. package/dist/plugin/TableColumnSetting/index.d.ts +64 -0
  12. package/dist/plugin/TableColumnSetting/utils.d.ts +1 -0
  13. package/dist/utils/LocalstorageUtils.d.ts +2 -0
  14. package/docs/index.md +21 -21
  15. package/lib/assets/drag.svg +17 -17
  16. package/lib/assets/exportFail.svg +37 -37
  17. package/lib/assets/exportProcessing.svg +28 -28
  18. package/lib/assets/exportSuccess.svg +34 -34
  19. package/lib/assets/label_icon_bottom.svg +25 -25
  20. package/lib/assets/upExport.svg +22 -22
  21. package/package.json +77 -77
  22. package/src/assets/32.svg +27 -27
  23. package/src/assets/addIcon.svg +17 -17
  24. package/src/assets/allfunc.svg +27 -27
  25. package/src/assets/arrowRight.svg +24 -24
  26. package/src/assets/btn-delete.svg +29 -29
  27. package/src/assets/btn-edit.svg +19 -19
  28. package/src/assets/btn-more.svg +17 -17
  29. package/src/assets/btn-submit.svg +19 -19
  30. package/src/assets/caidan.svg +11 -11
  31. package/src/assets/close.svg +26 -26
  32. package/src/assets/drag.svg +17 -17
  33. package/src/assets/exportFail.svg +37 -37
  34. package/src/assets/exportProcessing.svg +28 -28
  35. package/src/assets/exportSuccess.svg +34 -34
  36. package/src/assets/fixed-left-active.svg +11 -11
  37. package/src/assets/fixed-left.svg +15 -15
  38. package/src/assets/fixed-right-active.svg +11 -11
  39. package/src/assets/fixed-right.svg +15 -15
  40. package/src/assets/guanbi.svg +15 -15
  41. package/src/assets/icon-quanping.svg +15 -15
  42. package/src/assets/icon-shezhi.svg +17 -17
  43. package/src/assets/label_icon_bottom.svg +25 -25
  44. package/src/assets/list-no-img.svg +21 -21
  45. package/src/assets/morentouxiang-32.svg +23 -23
  46. package/src/assets/scanning.svg +24 -24
  47. package/src/assets/upExport.svg +22 -22
  48. package/src/components/Business/AddSelectBusiness/index.md +63 -42
  49. package/src/components/Business/AddSelectBusiness/index.tsx +344 -341
  50. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  51. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  52. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  61. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  62. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  63. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  64. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  65. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  66. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -156
  67. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  68. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  69. package/src/components/Business/BsLayouts/index.less +79 -79
  70. package/src/components/Business/BsLayouts/index.tsx +1479 -1479
  71. package/src/components/Business/BsLayouts/service.ts +10 -10
  72. package/src/components/Business/BsLayouts/utils.tsx +230 -230
  73. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  74. package/src/components/Business/BsSulaQueryTable/index.tsx +480 -480
  75. package/src/components/Business/BsSulaQueryTable/setting.tsx +802 -802
  76. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  77. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  78. package/src/components/Business/CommodityEntry/index.md +70 -70
  79. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  80. package/src/components/Business/CommonAlert/index.tsx +23 -23
  81. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  82. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  83. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  84. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  85. package/src/components/Business/DetailPageWrapper/index.tsx +335 -335
  86. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  87. package/src/components/Business/HomePageWrapper/index.less +33 -33
  88. package/src/components/Business/HomePageWrapper/index.md +45 -45
  89. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  90. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  91. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -201
  92. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  93. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  94. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  95. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  96. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  97. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  98. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  99. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  100. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  101. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  102. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  103. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  104. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  105. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  106. package/src/components/Business/JsonQueryTable/index.less +16 -16
  107. package/src/components/Business/JsonQueryTable/index.md +328 -328
  108. package/src/components/Business/JsonQueryTable/index.tsx +320 -320
  109. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  110. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  111. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  112. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  113. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  114. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  115. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  116. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  117. package/src/components/Business/JsonQueryTable/static.ts +356 -356
  118. package/src/components/Business/SearchSelect/BusinessUtils.ts +1586 -1586
  119. package/src/components/Business/SearchSelect/common.ts +53 -53
  120. package/src/components/Business/SearchSelect/index.md +1254 -1254
  121. package/src/components/Business/SearchSelect/index.tsx +51 -51
  122. package/src/components/Business/SearchSelect/utils.ts +100 -100
  123. package/src/components/Business/StateFlow/index.less +130 -130
  124. package/src/components/Business/StateFlow/index.md +60 -60
  125. package/src/components/Business/StateFlow/index.tsx +29 -29
  126. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  127. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  128. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  129. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  130. package/src/components/Business/columnSettingTable/index.less +247 -247
  131. package/src/components/Business/columnSettingTable/index.md +357 -357
  132. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  133. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  134. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  135. package/src/components/Business/moreTreeTable/index.less +99 -99
  136. package/src/components/Business/moreTreeTable/index.md +508 -508
  137. package/src/components/Business/moreTreeTable/index.tsx +315 -315
  138. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  139. package/src/components/Functional/AddSelect/index.less +367 -367
  140. package/src/components/Functional/AddSelect/index.md +155 -154
  141. package/src/components/Functional/AddSelect/index.tsx +1072 -994
  142. package/src/components/Functional/BillEntry/index.less +371 -371
  143. package/src/components/Functional/BillEntry/index.md +39 -39
  144. package/src/components/Functional/BillEntry/index.tsx +766 -670
  145. package/src/components/Functional/DataImport/index.less +63 -63
  146. package/src/components/Functional/DataImport/index.md +44 -44
  147. package/src/components/Functional/DataImport/index.tsx +695 -695
  148. package/src/components/Functional/DataValidation/index.less +63 -63
  149. package/src/components/Functional/DataValidation/index.md +39 -39
  150. package/src/components/Functional/DataValidation/index.tsx +687 -687
  151. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  152. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  153. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  154. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  155. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  156. package/src/components/Functional/SearchSelect/index.less +115 -115
  157. package/src/components/Functional/SearchSelect/index.md +141 -141
  158. package/src/components/Functional/SearchSelect/index.tsx +813 -813
  159. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  160. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  161. package/src/components/Functional/TreeSearchSelect/index.tsx +149 -149
  162. package/src/index.ts +34 -34
  163. package/src/plugin/TableColumnSetting/index.less +247 -0
  164. package/src/plugin/TableColumnSetting/index.md +50 -0
  165. package/src/plugin/TableColumnSetting/index.tsx +724 -0
  166. package/src/plugin/TableColumnSetting/utils.ts +19 -0
  167. package/src/styles/bsDefault.less +1906 -1906
  168. package/src/utils/CheckOneUser/index.md +39 -39
  169. package/src/utils/CheckOneUser/index.ts +51 -51
  170. package/src/utils/LocalstorageUtils.ts +33 -0
  171. package/src/utils/TableUtils.tsx +18 -18
  172. package/src/utils/checkUtils.ts +39 -39
  173. package/src/utils/enumConfig.ts +10 -10
  174. package/src/utils/getFormMode.js +12 -12
  175. package/src/utils/index.ts +2 -2
  176. package/src/utils/requestUtils.ts +33 -33
  177. package/src/utils/serialize.js +7 -7
  178. package/src/utils/utils.ts +183 -183
  179. package/tsconfig.json +29 -29
  180. package/typings.d.ts +4 -4
@@ -1,336 +1,336 @@
1
- // @ts-nocheck
2
- import {
3
- ArrowLeftOutlined,
4
- } from '@ant-design/icons';
5
- import { Anchor, Tooltip, Button, Menu, Dropdown, Breadcrumb } from 'antd';
6
- import React, { useEffect, useState, useMemo } from 'react';
7
- import { history } from 'umi';
8
- import { getMainCrumbNameMap, doDetailPageAction, judgeIsEmpty } from './utils';
9
- import { memoizeOneFormatter, go2BackAndClose } from '@/utils/utils';
10
- import './index.less';
11
- import quanping from '../../../assets/icon-quanping.svg';
12
- import scanning from '../../../assets/scanning.svg';
13
- import editIcon from '../../../assets/btn-edit.svg';
14
- import submitIcon from '../../../assets/btn-submit.svg';
15
- import deleteIcon from '../../../assets/btn-delete.svg';
16
- import moreIcon from '../../../assets/btn-more.svg';
17
- import { useLocation, formatMessage } from 'umi';
18
- import CommonAlert from '../CommonAlert';
19
- import ENUM from '@/utils/enumConfig';
20
-
21
- interface actionItem {
22
- type?: string;
23
- name: string;
24
- icon?: string;
25
- visible?: boolean | string;
26
- disabled?: boolean;
27
- code?: string; //权限过滤todo
28
- action: object;
29
- }
30
-
31
- export const iconMap = {
32
- edit: <img src={editIcon} />,
33
- delete: <img src={deleteIcon} />,
34
- submit: <img src={submitIcon} />,
35
- more: <img src={moreIcon} />,
36
- };
37
-
38
- export default (props: any) => {
39
- const { pathname } = useLocation();
40
- const [id]: any = useState(pathname + 'id');
41
- const { children, ...restProps } = props;
42
-
43
- return (
44
- <div id={id} className={'detail_page_wrapper'}>
45
- <DetailWrapper
46
- pathname={pathname}
47
- {
48
- ...restProps
49
- }
50
- />
51
- {children}
52
- </div>
53
- );
54
- };
55
-
56
- const DetailWrapper = React.memo(
57
- ({
58
- pathname,
59
- actionList=[],
60
- routes=[],
61
- itemPath,
62
- alertProps,
63
- donotNeedShowScreenIcon=false,
64
- title,
65
- pathToRegexp,
66
- }: any) => {
67
- const [isFullScreen, setIsFnllScreen]: any = useState(false);
68
- const [breadcrumbArr, setBreadCrumbArr]: any = useState([]);
69
-
70
- const basePath = window.top == window ? '' : `/${itemPath}`;
71
-
72
- const menuRoutes =
73
- window.top == window
74
- ? routes.find((item) => item.path === '/')?.routes || []
75
- : JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.LIMIT_MENU_DATA) || '[]');
76
-
77
- const breadcrumbNameMap = getMainCrumbNameMap(
78
- memoizeOneFormatter(menuRoutes, ''),
79
- );
80
- const matchParamsPath = (pathname: string, breadcrumbNameMap: object) => {
81
- const pathKey: any = Object.keys(breadcrumbNameMap).find((key) =>
82
- pathToRegexp ? pathToRegexp(key).test(pathname) : false
83
- );
84
- return pathKey ? breadcrumbNameMap[pathKey] : undefined;
85
- };
86
-
87
- const getPageTitle = (pathname: string) => {
88
- const currRouterData = matchParamsPath(
89
- `${basePath}${pathname}`,
90
- breadcrumbNameMap,
91
- );
92
-
93
- if (!currRouterData) {
94
- return '';
95
- }
96
-
97
- let breadcrumbArrs = currRouterData.nameMap || [];
98
- if (title && breadcrumbArrs.length) {
99
- breadcrumbArrs.pop();
100
- breadcrumbArrs.push(title)
101
- }
102
- setBreadCrumbArr([...breadcrumbArrs])
103
-
104
- const pageName = formatMessage({
105
- id: currRouterData.locale || currRouterData.name,
106
- defaultMessage: currRouterData.name,
107
- });
108
-
109
- return title ? title : window.top === window ? pageName : `${currRouterData.name}`;
110
- };
111
-
112
- const pageTitle = useMemo(() => getPageTitle(pathname), [pathname, title]);
113
-
114
- // const breadcrumbArr = `${basePath}${pathname}`
115
- // .split('/')
116
- // .slice(1)
117
- // .map((_item, index, arr) =>
118
- // matchParamsPath(
119
- // `/${arr.slice(0, index + 1).join('/')}`,
120
- // breadcrumbNameMap,
121
- // ),
122
- // )
123
- // .filter((item) => item);
124
-
125
- useEffect(() => {}, []);
126
-
127
- const ShowFullScreen = () => {
128
- if (window.top != window) {
129
- window.parent.postMessage(
130
- {
131
- type: 'screenChange',
132
- id: itemPath,
133
- },
134
- '*',
135
- );
136
- setIsFnllScreen(!isFullScreen);
137
- } else {
138
- const isFullScreen: any =
139
- document.fullScreen ||
140
- document.webkitIsFullScreen ||
141
- document.mozFullScreen;
142
- let contentEle: any = document.querySelector(`body`);
143
- // addTabsNavStyle(isFullScreen);
144
- if (contentEle && !isFullScreen) {
145
- let fullScreenEle =
146
- contentEle.requestFullscreen ||
147
- contentEle.mozRequestFullScreen ||
148
- contentEle.webkitRequestFullScreen ||
149
- contentEle.msRequestFullscreen;
150
- if (fullScreenEle) {
151
- fullScreenEle.call(contentEle);
152
- setIsFnllScreen(true);
153
- return;
154
- }
155
- }
156
- if (document && isFullScreen) {
157
- let exitFullScreen =
158
- document.exitFullscreen ||
159
- document.mozCancelFullScreen ||
160
- document.webkitCancelFullScreen ||
161
- document.msExitFullscreen;
162
- if (exitFullScreen) {
163
- exitFullScreen.call(document);
164
- setIsFnllScreen(false);
165
- return;
166
- }
167
- }
168
- }
169
- };
170
-
171
- const renderPageActionList = (actionLists: Array<actionItem>) => {
172
- const authButton = localStorage.getItem(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES)
173
- ? JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES) as string)
174
- : [];
175
- let visibleActions = actionLists.filter(
176
- (action) =>
177
- ((action.visible && action.visible !== 'false') || judgeIsEmpty(action.visible)) &&
178
- (judgeIsEmpty(action.code) || authButton.filter(item => item === action.code)),
179
- );
180
-
181
- const renderButton = (item: actionItem, type?: any) => {
182
- return (
183
- <Button
184
- type={type || 'primary'}
185
- icon={item.icon ? iconMap[item.icon] : ''}
186
- danger={item.name === '删除' ? true : false}
187
- disabled={item.disabled}
188
- onClick={() => {
189
- if (typeof item.action === 'function') {
190
- item.action();
191
- } else {
192
- doDetailPageAction(item.action);
193
- }
194
- }}
195
- >
196
- {item.name}
197
- </Button>
198
- );
199
- };
200
-
201
- if (visibleActions.length <= 3) {
202
- return visibleActions.map((item) => {
203
- return renderButton(item);
204
- });
205
- }
206
-
207
- let moreOperate = visibleActions.splice(3);
208
- const menu = (
209
- <Menu>
210
- {moreOperate.map((item: any, index: number) => (
211
- <Menu.Item className="more-btn-action" key={index}>
212
- {renderButton(item, 'link')}
213
- </Menu.Item>
214
- ))}
215
- </Menu>
216
- );
217
- //按钮操作3个显示更多
218
- return (
219
- <div className="detail_btn_wrapper">
220
- {visibleActions.map((item: any, index: number) => {
221
- return renderButton(item);
222
- })}
223
- <Dropdown style={{ padding: '0px' }} overlay={menu}>
224
- <Button type="primary">
225
- <span style={{ margin: '0px' }}>更多</span>
226
- <img src={moreIcon} />
227
- </Button>
228
- </Dropdown>
229
- </div>
230
- );
231
- };
232
-
233
- return (
234
- <Anchor
235
- key={`${pathname}_anchor`}
236
- offsetTop={window.top == window ? 78 : 0}
237
- >
238
- <div>
239
- <div className={'detail_page_head'}>
240
- <div
241
- className={'back_home_img_content'}
242
- onClick={() => {
243
- go2BackAndClose();
244
- // history.goBack();
245
- }}
246
- >
247
- <ArrowLeftOutlined />
248
- </div>
249
- <div className={'detail_page_title_box'}>
250
- <div className={'detail_page_title'}>{pageTitle}</div>
251
- <Breadcrumb>
252
- {breadcrumbArr.map((item) => (
253
- <Breadcrumb.Item
254
- key={item}
255
- onClick={() => {
256
- // if (
257
- // item.path &&
258
- // !item.children &&
259
- // !pathToRegexp(item.path).test(`${basePath}${pathname}`)
260
- // ) {
261
- // history.push({
262
- // pathname: item.path.replace(basePath, ''),
263
- // });
264
- // }
265
- }}
266
- >
267
- <span
268
- style={{
269
- // color:
270
- // item.path &&
271
- // pathToRegexp(item.path).test(`${basePath}${pathname}`)
272
- // ? '#000000d9'
273
- // : '',
274
- }}
275
- className="bread_name"
276
- >
277
- {item}
278
- </span>
279
- </Breadcrumb.Item>
280
- ))}
281
- </Breadcrumb>
282
- </div>
283
- <div
284
- className={'detail_page_btns'}
285
- style={{ marginRight: '20px', display: 'flex', gap: '8px' }}
286
- >
287
- {renderPageActionList(actionList)}
288
- {
289
- !donotNeedShowScreenIcon ? ( <a>
290
- {isFullScreen ? (
291
- <Tooltip title="取消全屏">
292
- <img
293
- onClick={() => {
294
- ShowFullScreen();
295
- }}
296
- width={32}
297
- src={scanning}
298
- />
299
- </Tooltip>
300
- ) : (
301
- <Tooltip title="全屏">
302
- <img
303
- onClick={() => {
304
- ShowFullScreen();
305
- }}
306
- width={32}
307
- src={quanping}
308
- />
309
- </Tooltip>
310
- )}
311
- </a>) : null
312
- }
313
- </div>
314
- </div>
315
- {
316
- alertProps && (
317
- <CommonAlert
318
- {
319
- ...alertProps
320
- }
321
- />
322
- )
323
- }
324
- </div>
325
- </Anchor>
326
- );
327
- },
328
- (prevProps, nextProps) => {
329
- if (
330
- (JSON.stringify(prevProps.actionList) != JSON.stringify(nextProps.actionList)) || prevProps.title !== nextProps.title
331
- ) {
332
- return false;
333
- }
334
- return true;
335
- },
1
+ // @ts-nocheck
2
+ import {
3
+ ArrowLeftOutlined,
4
+ } from '@ant-design/icons';
5
+ import { Anchor, Tooltip, Button, Menu, Dropdown, Breadcrumb } from 'antd';
6
+ import React, { useEffect, useState, useMemo } from 'react';
7
+ import { history } from 'umi';
8
+ import { getMainCrumbNameMap, doDetailPageAction, judgeIsEmpty } from './utils';
9
+ import { memoizeOneFormatter, go2BackAndClose } from '@/utils/utils';
10
+ import './index.less';
11
+ import quanping from '../../../assets/icon-quanping.svg';
12
+ import scanning from '../../../assets/scanning.svg';
13
+ import editIcon from '../../../assets/btn-edit.svg';
14
+ import submitIcon from '../../../assets/btn-submit.svg';
15
+ import deleteIcon from '../../../assets/btn-delete.svg';
16
+ import moreIcon from '../../../assets/btn-more.svg';
17
+ import { useLocation, formatMessage } from 'umi';
18
+ import CommonAlert from '../CommonAlert';
19
+ import ENUM from '@/utils/enumConfig';
20
+
21
+ interface actionItem {
22
+ type?: string;
23
+ name: string;
24
+ icon?: string;
25
+ visible?: boolean | string;
26
+ disabled?: boolean;
27
+ code?: string; //权限过滤todo
28
+ action: object;
29
+ }
30
+
31
+ export const iconMap = {
32
+ edit: <img src={editIcon} />,
33
+ delete: <img src={deleteIcon} />,
34
+ submit: <img src={submitIcon} />,
35
+ more: <img src={moreIcon} />,
36
+ };
37
+
38
+ export default (props: any) => {
39
+ const { pathname } = useLocation();
40
+ const [id]: any = useState(pathname + 'id');
41
+ const { children, ...restProps } = props;
42
+
43
+ return (
44
+ <div id={id} className={'detail_page_wrapper'}>
45
+ <DetailWrapper
46
+ pathname={pathname}
47
+ {
48
+ ...restProps
49
+ }
50
+ />
51
+ {children}
52
+ </div>
53
+ );
54
+ };
55
+
56
+ const DetailWrapper = React.memo(
57
+ ({
58
+ pathname,
59
+ actionList=[],
60
+ routes=[],
61
+ itemPath,
62
+ alertProps,
63
+ donotNeedShowScreenIcon=false,
64
+ title,
65
+ pathToRegexp,
66
+ }: any) => {
67
+ const [isFullScreen, setIsFnllScreen]: any = useState(false);
68
+ const [breadcrumbArr, setBreadCrumbArr]: any = useState([]);
69
+
70
+ const basePath = window.top == window ? '' : `/${itemPath}`;
71
+
72
+ const menuRoutes =
73
+ window.top == window
74
+ ? routes.find((item) => item.path === '/')?.routes || []
75
+ : JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.LIMIT_MENU_DATA) || '[]');
76
+
77
+ const breadcrumbNameMap = getMainCrumbNameMap(
78
+ memoizeOneFormatter(menuRoutes, ''),
79
+ );
80
+ const matchParamsPath = (pathname: string, breadcrumbNameMap: object) => {
81
+ const pathKey: any = Object.keys(breadcrumbNameMap).find((key) =>
82
+ pathToRegexp ? pathToRegexp(key).test(pathname) : false
83
+ );
84
+ return pathKey ? breadcrumbNameMap[pathKey] : undefined;
85
+ };
86
+
87
+ const getPageTitle = (pathname: string) => {
88
+ const currRouterData = matchParamsPath(
89
+ `${basePath}${pathname}`,
90
+ breadcrumbNameMap,
91
+ );
92
+
93
+ if (!currRouterData) {
94
+ return '';
95
+ }
96
+
97
+ let breadcrumbArrs = currRouterData.nameMap || [];
98
+ if (title && breadcrumbArrs.length) {
99
+ breadcrumbArrs.pop();
100
+ breadcrumbArrs.push(title)
101
+ }
102
+ setBreadCrumbArr([...breadcrumbArrs])
103
+
104
+ const pageName = formatMessage({
105
+ id: currRouterData.locale || currRouterData.name,
106
+ defaultMessage: currRouterData.name,
107
+ });
108
+
109
+ return title ? title : window.top === window ? pageName : `${currRouterData.name}`;
110
+ };
111
+
112
+ const pageTitle = useMemo(() => getPageTitle(pathname), [pathname, title]);
113
+
114
+ // const breadcrumbArr = `${basePath}${pathname}`
115
+ // .split('/')
116
+ // .slice(1)
117
+ // .map((_item, index, arr) =>
118
+ // matchParamsPath(
119
+ // `/${arr.slice(0, index + 1).join('/')}`,
120
+ // breadcrumbNameMap,
121
+ // ),
122
+ // )
123
+ // .filter((item) => item);
124
+
125
+ useEffect(() => {}, []);
126
+
127
+ const ShowFullScreen = () => {
128
+ if (window.top != window) {
129
+ window.parent.postMessage(
130
+ {
131
+ type: 'screenChange',
132
+ id: itemPath,
133
+ },
134
+ '*',
135
+ );
136
+ setIsFnllScreen(!isFullScreen);
137
+ } else {
138
+ const isFullScreen: any =
139
+ document.fullScreen ||
140
+ document.webkitIsFullScreen ||
141
+ document.mozFullScreen;
142
+ let contentEle: any = document.querySelector(`body`);
143
+ // addTabsNavStyle(isFullScreen);
144
+ if (contentEle && !isFullScreen) {
145
+ let fullScreenEle =
146
+ contentEle.requestFullscreen ||
147
+ contentEle.mozRequestFullScreen ||
148
+ contentEle.webkitRequestFullScreen ||
149
+ contentEle.msRequestFullscreen;
150
+ if (fullScreenEle) {
151
+ fullScreenEle.call(contentEle);
152
+ setIsFnllScreen(true);
153
+ return;
154
+ }
155
+ }
156
+ if (document && isFullScreen) {
157
+ let exitFullScreen =
158
+ document.exitFullscreen ||
159
+ document.mozCancelFullScreen ||
160
+ document.webkitCancelFullScreen ||
161
+ document.msExitFullscreen;
162
+ if (exitFullScreen) {
163
+ exitFullScreen.call(document);
164
+ setIsFnllScreen(false);
165
+ return;
166
+ }
167
+ }
168
+ }
169
+ };
170
+
171
+ const renderPageActionList = (actionLists: Array<actionItem>) => {
172
+ const authButton = localStorage.getItem(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES)
173
+ ? JSON.parse(localStorage.getItem(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES) as string)
174
+ : [];
175
+ let visibleActions = actionLists.filter(
176
+ (action) =>
177
+ ((action.visible && action.visible !== 'false') || judgeIsEmpty(action.visible)) &&
178
+ (judgeIsEmpty(action.code) || authButton.filter(item => item === action.code)),
179
+ );
180
+
181
+ const renderButton = (item: actionItem, type?: any) => {
182
+ return (
183
+ <Button
184
+ type={type || 'primary'}
185
+ icon={item.icon ? iconMap[item.icon] : ''}
186
+ danger={item.name === '删除' ? true : false}
187
+ disabled={item.disabled}
188
+ onClick={() => {
189
+ if (typeof item.action === 'function') {
190
+ item.action();
191
+ } else {
192
+ doDetailPageAction(item.action);
193
+ }
194
+ }}
195
+ >
196
+ {item.name}
197
+ </Button>
198
+ );
199
+ };
200
+
201
+ if (visibleActions.length <= 3) {
202
+ return visibleActions.map((item) => {
203
+ return renderButton(item);
204
+ });
205
+ }
206
+
207
+ let moreOperate = visibleActions.splice(3);
208
+ const menu = (
209
+ <Menu>
210
+ {moreOperate.map((item: any, index: number) => (
211
+ <Menu.Item className="more-btn-action" key={index}>
212
+ {renderButton(item, 'link')}
213
+ </Menu.Item>
214
+ ))}
215
+ </Menu>
216
+ );
217
+ //按钮操作3个显示更多
218
+ return (
219
+ <div className="detail_btn_wrapper">
220
+ {visibleActions.map((item: any, index: number) => {
221
+ return renderButton(item);
222
+ })}
223
+ <Dropdown style={{ padding: '0px' }} overlay={menu}>
224
+ <Button type="primary">
225
+ <span style={{ margin: '0px' }}>更多</span>
226
+ <img src={moreIcon} />
227
+ </Button>
228
+ </Dropdown>
229
+ </div>
230
+ );
231
+ };
232
+
233
+ return (
234
+ <Anchor
235
+ key={`${pathname}_anchor`}
236
+ offsetTop={window.top == window ? 78 : 0}
237
+ >
238
+ <div>
239
+ <div className={'detail_page_head'}>
240
+ <div
241
+ className={'back_home_img_content'}
242
+ onClick={() => {
243
+ go2BackAndClose();
244
+ // history.goBack();
245
+ }}
246
+ >
247
+ <ArrowLeftOutlined />
248
+ </div>
249
+ <div className={'detail_page_title_box'}>
250
+ <div className={'detail_page_title'}>{pageTitle}</div>
251
+ <Breadcrumb>
252
+ {breadcrumbArr.map((item) => (
253
+ <Breadcrumb.Item
254
+ key={item}
255
+ onClick={() => {
256
+ // if (
257
+ // item.path &&
258
+ // !item.children &&
259
+ // !pathToRegexp(item.path).test(`${basePath}${pathname}`)
260
+ // ) {
261
+ // history.push({
262
+ // pathname: item.path.replace(basePath, ''),
263
+ // });
264
+ // }
265
+ }}
266
+ >
267
+ <span
268
+ style={{
269
+ // color:
270
+ // item.path &&
271
+ // pathToRegexp(item.path).test(`${basePath}${pathname}`)
272
+ // ? '#000000d9'
273
+ // : '',
274
+ }}
275
+ className="bread_name"
276
+ >
277
+ {item}
278
+ </span>
279
+ </Breadcrumb.Item>
280
+ ))}
281
+ </Breadcrumb>
282
+ </div>
283
+ <div
284
+ className={'detail_page_btns'}
285
+ style={{ marginRight: '20px', display: 'flex', gap: '8px' }}
286
+ >
287
+ {renderPageActionList(actionList)}
288
+ {
289
+ !donotNeedShowScreenIcon ? ( <a>
290
+ {isFullScreen ? (
291
+ <Tooltip title="取消全屏">
292
+ <img
293
+ onClick={() => {
294
+ ShowFullScreen();
295
+ }}
296
+ width={32}
297
+ src={scanning}
298
+ />
299
+ </Tooltip>
300
+ ) : (
301
+ <Tooltip title="全屏">
302
+ <img
303
+ onClick={() => {
304
+ ShowFullScreen();
305
+ }}
306
+ width={32}
307
+ src={quanping}
308
+ />
309
+ </Tooltip>
310
+ )}
311
+ </a>) : null
312
+ }
313
+ </div>
314
+ </div>
315
+ {
316
+ alertProps && (
317
+ <CommonAlert
318
+ {
319
+ ...alertProps
320
+ }
321
+ />
322
+ )
323
+ }
324
+ </div>
325
+ </Anchor>
326
+ );
327
+ },
328
+ (prevProps, nextProps) => {
329
+ if (
330
+ (JSON.stringify(prevProps.actionList) != JSON.stringify(nextProps.actionList)) || prevProps.title !== nextProps.title
331
+ ) {
332
+ return false;
333
+ }
334
+ return true;
335
+ },
336
336
  );