@bit-sun/business-component 2.2.4 → 2.2.6

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 (179) 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/BsSulaQueryTable/SearchItemSetting.d.ts +59 -0
  9. package/dist/index.esm.js +547 -28
  10. package/dist/index.js +547 -28
  11. package/dist/utils/enumConfig.d.ts +1 -0
  12. package/docs/index.md +21 -21
  13. package/lib/assets/drag.svg +17 -17
  14. package/lib/assets/exportFail.svg +37 -37
  15. package/lib/assets/exportProcessing.svg +28 -28
  16. package/lib/assets/exportSuccess.svg +34 -34
  17. package/lib/assets/label_icon_bottom.svg +25 -25
  18. package/lib/assets/upExport.svg +22 -22
  19. package/package.json +77 -77
  20. package/src/assets/32.svg +27 -27
  21. package/src/assets/addIcon.svg +17 -17
  22. package/src/assets/allfunc.svg +27 -27
  23. package/src/assets/arrowRight.svg +24 -24
  24. package/src/assets/btn-delete.svg +29 -29
  25. package/src/assets/btn-edit.svg +19 -19
  26. package/src/assets/btn-more.svg +17 -17
  27. package/src/assets/btn-submit.svg +19 -19
  28. package/src/assets/caidan.svg +11 -11
  29. package/src/assets/close.svg +26 -26
  30. package/src/assets/drag.svg +17 -17
  31. package/src/assets/exportFail.svg +37 -37
  32. package/src/assets/exportProcessing.svg +28 -28
  33. package/src/assets/exportSuccess.svg +34 -34
  34. package/src/assets/fixed-left-active.svg +11 -11
  35. package/src/assets/fixed-left.svg +15 -15
  36. package/src/assets/fixed-right-active.svg +11 -11
  37. package/src/assets/fixed-right.svg +15 -15
  38. package/src/assets/guanbi.svg +15 -15
  39. package/src/assets/icon-quanping.svg +15 -15
  40. package/src/assets/icon-shezhi.svg +17 -17
  41. package/src/assets/label_icon_bottom.svg +25 -25
  42. package/src/assets/list-no-img.svg +21 -21
  43. package/src/assets/morentouxiang-32.svg +23 -23
  44. package/src/assets/scanning.svg +24 -24
  45. package/src/assets/upExport.svg +22 -22
  46. package/src/components/Business/AddSelectBusiness/index.md +63 -63
  47. package/src/components/Business/AddSelectBusiness/index.tsx +344 -344
  48. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  49. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  50. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  51. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  52. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  60. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  61. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  62. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  63. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  64. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -156
  65. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  66. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  67. package/src/components/Business/BsLayouts/index.less +79 -79
  68. package/src/components/Business/BsLayouts/index.tsx +1479 -1479
  69. package/src/components/Business/BsLayouts/service.ts +10 -10
  70. package/src/components/Business/BsLayouts/utils.tsx +230 -230
  71. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +538 -0
  72. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  73. package/src/components/Business/BsSulaQueryTable/index.tsx +529 -480
  74. package/src/components/Business/BsSulaQueryTable/setting.tsx +802 -802
  75. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  76. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  77. package/src/components/Business/CommodityEntry/index.md +70 -70
  78. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  79. package/src/components/Business/CommonAlert/index.tsx +23 -23
  80. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  81. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  82. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  83. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  84. package/src/components/Business/DetailPageWrapper/index.tsx +335 -335
  85. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  86. package/src/components/Business/HomePageWrapper/index.less +33 -33
  87. package/src/components/Business/HomePageWrapper/index.md +45 -45
  88. package/src/components/Business/HomePageWrapper/index.tsx +162 -162
  89. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  90. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +201 -201
  91. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -205
  92. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  93. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -20
  94. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -25
  95. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -30
  96. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -82
  97. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -44
  98. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -57
  99. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -124
  100. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -29
  101. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -22
  102. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -116
  103. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -12
  104. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  105. package/src/components/Business/JsonQueryTable/index.less +16 -16
  106. package/src/components/Business/JsonQueryTable/index.md +328 -328
  107. package/src/components/Business/JsonQueryTable/index.tsx +320 -320
  108. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -346
  109. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -22
  110. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -147
  111. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -389
  112. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -118
  113. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -22
  114. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -21
  115. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -65
  116. package/src/components/Business/JsonQueryTable/static.ts +356 -356
  117. package/src/components/Business/SearchSelect/BusinessUtils.ts +1586 -1586
  118. package/src/components/Business/SearchSelect/common.ts +53 -53
  119. package/src/components/Business/SearchSelect/index.md +1254 -1254
  120. package/src/components/Business/SearchSelect/index.tsx +51 -51
  121. package/src/components/Business/SearchSelect/utils.ts +100 -100
  122. package/src/components/Business/StateFlow/index.less +130 -130
  123. package/src/components/Business/StateFlow/index.md +60 -60
  124. package/src/components/Business/StateFlow/index.tsx +29 -29
  125. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  126. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  127. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  128. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  129. package/src/components/Business/columnSettingTable/index.less +247 -247
  130. package/src/components/Business/columnSettingTable/index.md +357 -357
  131. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  132. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  133. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  134. package/src/components/Business/moreTreeTable/index.less +99 -99
  135. package/src/components/Business/moreTreeTable/index.md +508 -508
  136. package/src/components/Business/moreTreeTable/index.tsx +315 -315
  137. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  138. package/src/components/Functional/AddSelect/index.less +367 -367
  139. package/src/components/Functional/AddSelect/index.md +155 -155
  140. package/src/components/Functional/AddSelect/index.tsx +1072 -1072
  141. package/src/components/Functional/BillEntry/index.less +371 -371
  142. package/src/components/Functional/BillEntry/index.md +39 -39
  143. package/src/components/Functional/BillEntry/index.tsx +766 -766
  144. package/src/components/Functional/DataImport/index.less +63 -63
  145. package/src/components/Functional/DataImport/index.md +44 -44
  146. package/src/components/Functional/DataImport/index.tsx +695 -695
  147. package/src/components/Functional/DataValidation/index.less +63 -63
  148. package/src/components/Functional/DataValidation/index.md +39 -39
  149. package/src/components/Functional/DataValidation/index.tsx +687 -687
  150. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  151. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  152. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  153. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  154. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  155. package/src/components/Functional/SearchSelect/index.less +115 -115
  156. package/src/components/Functional/SearchSelect/index.md +141 -141
  157. package/src/components/Functional/SearchSelect/index.tsx +813 -813
  158. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  159. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  160. package/src/components/Functional/TreeSearchSelect/index.tsx +160 -160
  161. package/src/index.ts +34 -34
  162. package/src/plugin/TableColumnSetting/index.less +247 -247
  163. package/src/plugin/TableColumnSetting/index.md +50 -50
  164. package/src/plugin/TableColumnSetting/index.tsx +724 -724
  165. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  166. package/src/styles/bsDefault.less +1906 -1906
  167. package/src/utils/CheckOneUser/index.md +39 -39
  168. package/src/utils/CheckOneUser/index.ts +51 -51
  169. package/src/utils/LocalstorageUtils.ts +33 -33
  170. package/src/utils/TableUtils.tsx +18 -18
  171. package/src/utils/checkUtils.ts +39 -39
  172. package/src/utils/enumConfig.ts +11 -10
  173. package/src/utils/getFormMode.js +12 -12
  174. package/src/utils/index.ts +2 -2
  175. package/src/utils/requestUtils.ts +33 -33
  176. package/src/utils/serialize.js +7 -7
  177. package/src/utils/utils.ts +183 -183
  178. package/tsconfig.json +29 -29
  179. 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
  );