@bit-sun/business-component 2.1.23 → 2.2.0

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