@bit-sun/business-component 2.4.31-alpha.9 → 2.4.32

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 (210) 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 +0 -1
  9. package/dist/index.esm.js +950 -1044
  10. package/dist/index.js +954 -1051
  11. package/dist/utils/auth.d.ts +0 -1
  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 +80 -83
  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/common/ENUM.ts +41 -41
  47. package/src/components/Business/AddSelectBusiness/index.md +162 -398
  48. package/src/components/Business/AddSelectBusiness/index.tsx +1062 -1099
  49. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -112
  50. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  51. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  52. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  53. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  54. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  55. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  56. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  61. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  62. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +158 -157
  63. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  64. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  65. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +155 -155
  66. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  67. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  68. package/src/components/Business/BsLayouts/index.less +79 -79
  69. package/src/components/Business/BsLayouts/index.tsx +1484 -1572
  70. package/src/components/Business/BsLayouts/service.ts +10 -10
  71. package/src/components/Business/BsLayouts/utils.tsx +203 -205
  72. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +566 -566
  73. package/src/components/Business/BsSulaQueryTable/index.less +221 -221
  74. package/src/components/Business/BsSulaQueryTable/index.tsx +606 -560
  75. package/src/components/Business/BsSulaQueryTable/setting.tsx +854 -854
  76. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  77. package/src/components/Business/BsSulaQueryTable/utils.tsx +690 -690
  78. package/src/components/Business/CommodityEntry/index.md +70 -84
  79. package/src/components/Business/CommodityEntry/index.tsx +81 -82
  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 +315 -316
  86. package/src/components/Business/DetailPageWrapper/utils.tsx +164 -164
  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 +205 -205
  92. package/src/components/Business/JsonQueryTable/components/Formula.tsx +206 -206
  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 +537 -537
  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 +450 -450
  118. package/src/components/Business/SearchSelect/BusinessUtils.tsx +2120 -2120
  119. package/src/components/Business/SearchSelect/common.ts +134 -134
  120. package/src/components/Business/SearchSelect/index.md +1503 -1512
  121. package/src/components/Business/SearchSelect/index.tsx +55 -55
  122. package/src/components/Business/SearchSelect/utils.ts +101 -101
  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 +185 -185
  127. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  128. package/src/components/Business/TreeSearchSelect/utils.ts +104 -104
  129. package/src/components/Business/columnSettingTable/columnSetting.tsx +766 -766
  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 +235 -235
  133. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +243 -243
  134. package/src/components/Business/columnSettingTable/utils.tsx +71 -71
  135. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -87
  136. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -21
  137. package/src/components/Business/moreTreeTable/index.less +99 -99
  138. package/src/components/Business/moreTreeTable/index.md +448 -448
  139. package/src/components/Business/moreTreeTable/index.tsx +387 -387
  140. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  141. package/src/components/Functional/AddSelect/helps.ts +80 -80
  142. package/src/components/Functional/AddSelect/index.less +367 -367
  143. package/src/components/Functional/AddSelect/index.md +155 -155
  144. package/src/components/Functional/AddSelect/index.tsx +1171 -1011
  145. package/src/components/Functional/BillEntry/index.less +371 -371
  146. package/src/components/Functional/BillEntry/index.md +39 -39
  147. package/src/components/Functional/BillEntry/index.tsx +773 -773
  148. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -62
  149. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -178
  150. package/src/components/Functional/BsAntdSula/index.ts +2 -2
  151. package/src/components/Functional/DataImport/index.less +63 -63
  152. package/src/components/Functional/DataImport/index.md +44 -44
  153. package/src/components/Functional/DataImport/index.tsx +696 -701
  154. package/src/components/Functional/DataValidation/index.less +63 -63
  155. package/src/components/Functional/DataValidation/index.md +39 -52
  156. package/src/components/Functional/DataValidation/index.tsx +688 -701
  157. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -5
  158. package/src/components/Functional/EllipsisTooltip/index.js +36 -36
  159. package/src/components/Functional/EllipsisTooltip/index.md +30 -30
  160. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  161. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +60 -60
  162. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  163. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  164. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  165. package/src/components/Functional/SearchSelect/index.less +115 -115
  166. package/src/components/Functional/SearchSelect/index.md +141 -141
  167. package/src/components/Functional/SearchSelect/index.tsx +897 -896
  168. package/src/components/Functional/SearchSelect/utils.ts +3 -3
  169. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  170. package/src/components/Functional/TreeSearchSelect/index.tsx +204 -204
  171. package/src/components/Solution/RuleComponent/Formula.tsx +335 -335
  172. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -62
  173. package/src/components/Solution/RuleComponent/index.d.ts +29 -29
  174. package/src/components/Solution/RuleComponent/index.js +2103 -2103
  175. package/src/components/Solution/RuleComponent/index.less +229 -229
  176. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  177. package/src/components/Solution/RuleComponent/ruleFiled.js +2293 -2293
  178. package/src/components/Solution/RuleComponent/services.ts +13 -13
  179. package/src/components/Solution/RuleComponent/util.js +143 -143
  180. package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -6
  181. package/src/components/Solution/RuleSetter/baseRule.tsx +368 -368
  182. package/src/components/Solution/RuleSetter/function.ts +336 -336
  183. package/src/components/Solution/RuleSetter/index.less +221 -221
  184. package/src/components/Solution/RuleSetter/index.tsx +208 -208
  185. package/src/components/Solution/RuleSetter/service.js +276 -276
  186. package/src/index.ts +40 -41
  187. package/src/plugin/TableColumnSetting/index.less +247 -247
  188. package/src/plugin/TableColumnSetting/index.md +50 -50
  189. package/src/plugin/TableColumnSetting/index.tsx +725 -725
  190. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  191. package/src/styles/bsDefault.less +1912 -1912
  192. package/src/utils/CheckOneUser/index.md +39 -39
  193. package/src/utils/CheckOneUser/index.ts +51 -51
  194. package/src/utils/CustomLoginInfo.ts +55 -55
  195. package/src/utils/LocalstorageUtils.ts +128 -128
  196. package/src/utils/TableUtils.tsx +18 -18
  197. package/src/utils/auth.ts +32 -38
  198. package/src/utils/checkUtils.ts +39 -39
  199. package/src/utils/enumConfig.ts +16 -16
  200. package/src/utils/getFormMode.js +12 -12
  201. package/src/utils/index.ts +12 -12
  202. package/src/utils/requestUtils.ts +166 -166
  203. package/src/utils/serialize.js +7 -7
  204. package/src/utils/utils.ts +195 -195
  205. package/tsconfig.json +29 -29
  206. package/typings.d.ts +4 -4
  207. package/dist/components/Functional/AccessWrapper/index.d.ts +0 -5
  208. package/dist/components/Functional/AuthButton/index.d.ts +0 -3
  209. package/src/components/Functional/AccessWrapper/index.tsx +0 -34
  210. package/src/components/Functional/AuthButton/index.tsx +0 -15
@@ -1,560 +1,606 @@
1
- // @ts-nocheck
2
- import React, { useState, useEffect, useRef, useMemo } from 'react';
3
- import { useLocation } from 'umi';
4
- import { QueryTable } from 'bssula';
5
- import {
6
- userColumns,
7
- getItemDefaultWidth,
8
- authFn,
9
- queryParams,
10
- } from './utils';
11
- import { Menu, Tooltip, Dropdown } from 'antd';
12
- import SortableTable from './setting';
13
- import SearchItemTable from "./SearchItemSetting";
14
- import { Resizable } from 'react-resizable';
15
- import quanping from '../../../assets/icon-quanping.svg';
16
- import scanning from '../../../assets/scanning.svg';
17
- import shezhi from '../../../assets/icon-shezhi.svg';
18
- import { debounce } from 'lodash';
19
- import ExportIcon from '@/components/Functional/ExportFunctions/ExportIcon';
20
- import ENUM from '@/utils/enumConfig';
21
- import { handleBssulaColumnsSpecialParams } from '@/utils/utils';
22
- import { getMenuAuthDataKey } from '@/utils/LocalstorageUtils';
23
- import { shouldUseAuth } from '@/utils';
24
-
25
- const MemoQueryTable = React.memo(QueryTable);
26
-
27
- const ResizeableTitle = (props) => {
28
- const { onResize, width, ...restProps } = props;
29
-
30
- if (!width) {
31
- return <th {...restProps} />;
32
- }
33
- return (
34
- <Resizable
35
- width={width}
36
- height={0}
37
- onResize={onResize}
38
- draggableOpts={{ enableUserSelectHack: false }}
39
- >
40
- <th {...restProps} />
41
- </Resizable>
42
- );
43
- };
44
-
45
- export default (props: any) => {
46
- const bsTableCode = props?.tableCode || window.location.hash; //设置列字段的唯一标识
47
- const getConfigFromlocalstorage = (type: string) => {
48
- let config = localStorage.getItem(type) || '[]';
49
- let configArray = JSON.parse(config);
50
- let configSetting = configArray.filter(
51
- (item) => item.code === bsTableCode,
52
- );
53
-
54
- if (configSetting.length && configSetting[0].detail) {
55
- return JSON.parse(configSetting[0].detail);
56
- }
57
- return [];
58
- };
59
- const getInitialSearchFieldsInfo = () =>{
60
- //获取搜索字段的缓存配置
61
- const { fields = [] } = props;
62
- let searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
63
- let showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map((item) => {
64
- let inner = fields.filter(
65
- (inneritem) => {
66
- let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : inneritem.name;
67
- let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : item.name;
68
- return innerKey && innerKey === itemKey;
69
- }
70
- )[0];
71
-
72
- return {
73
- ...inner,
74
- ...item,
75
- };
76
- }) : fields;
77
- return [...showSearchFields]
78
- }
79
- const refs = useRef(null);
80
- const [pagePath, setPagePath] = useState('');
81
- // 获取 table columns中所有的 key 防止有的地方是 dataindex
82
- const [checkedList, setCheckedList] = useState(
83
- props.columns.filter((col: any) => !col.hidden).map((d: any) => Array.isArray(d.key || d.dataIndex) ? JSON.stringify(d.key || d.dataIndex) : (d.key || d.dataIndex)),
84
- );
85
- const { pathname } = useLocation();
86
- const [id]: any = useState(
87
- Number(Math.random().toString().substr(2, 0) + Date.now()).toString(36),
88
- );
89
- const [isFullScreen, setIsFnllScreen]: any = useState(false);
90
- // @ts-nocheck
91
- const [value, setValue]: any = useState(props);
92
- const [showColumn, setShowColumns] = useState([]); // 列字段
93
- const originSearchFields = getInitialSearchFieldsInfo();
94
- const [showSearchFields, setShowSearchFields] = useState(originSearchFields); //搜索项字段
95
- const { isPage = true, pagination, tableCode, appRequestConfig } = props;
96
-
97
- const [height, setHeight]: any = useState('100vh');
98
- const sortTableRef = useRef(null);
99
- const searchTableRef = useRef(null);
100
-
101
- // 获取table高度
102
- const getTableHeight = () => {
103
- setTimeout(() => {
104
- const cancelHeight = window.top == window ? 303 : 223;
105
- const isFullScreen: any =
106
- window.top.document.fullScreen ||
107
- window.top.document.webkitIsFullScreen ||
108
- window.top.document.mozFullScreen;
109
-
110
- // wujie子应用iframe首次加载获取不到client以及dom元素高度兼容处理
111
- let realIframeClientHeight = document.body.clientHeight ? document.body.clientHeight : window.top?.document.body.clientHeight - 76;
112
- let summaryHeight = document.querySelector(`.ant-tabs-tabpane-active .table-bssula-summary`) ?
113
- (document.querySelector(`.ant-tabs-tabpane-active .table-bssula-summary`)?.clientHeight || 22) : 0;
114
- let listTabHeight = document.querySelector(`.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`) ?
115
- (document.querySelector(`.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`)?.clientHeight || 48) : 0;
116
-
117
-
118
- const h =
119
- realIframeClientHeight - summaryHeight - listTabHeight -
120
- (document.querySelector(`.ant-tabs-tabpane-active .ant-form ant-form-horizontal`)?.clientHeight ||
121
- 0) -
122
- (isFullScreen
123
- ? 0
124
- : document.querySelector(`.ant-tabs-tabpane-active .ant-pro-page-container-warp`)
125
- ?.clientHeight || 0) -
126
- cancelHeight +
127
- 'px';
128
- setHeight(h);
129
- setValue({ ...value });
130
- }, 0)
131
- };
132
-
133
- //监测是否按下esc键
134
- function checkFull() {
135
- let globalDocument = window?.parent?.document || document;
136
- var isFull =
137
- globalDocument.fullscreenElement ||
138
- globalDocument.mozFullScreenElement ||
139
- globalDocument.webkitFullscreenElement;
140
- if (isFull == undefined) isFull = false;
141
- return isFull;
142
- }
143
-
144
- const setInitialTableInfo = () => {
145
- const resourceCodeArray = {};
146
- if (props.actionsRender && props.actionsRender.length) {
147
- props.actionsRender.forEach((item: any) => {
148
- if (item.code) {
149
- if (resourceCodeArray[item.code]) {
150
- resourceCodeArray[item.code + 1] = item;
151
- } else {
152
- resourceCodeArray[item.code] = item;
153
- }
154
- }
155
- });
156
- }
157
- if (props.columns && props.columns.length) {
158
- props.columns.forEach((d: any) => {
159
- if (d.isPermissionColumn && d.render && d.render.length) {
160
- d.render.forEach((inneritem: any) => {
161
- if (inneritem.code) {
162
- if (resourceCodeArray[inneritem.code]) {
163
- resourceCodeArray[inneritem.code + 1] = inneritem;
164
- } else {
165
- resourceCodeArray[inneritem.code] = inneritem;
166
- }
167
- }
168
- });
169
- }
170
- handleBssulaColumnsSpecialParams(d);
171
- });
172
- setCommonRenderFn(props.columns);
173
- const authButton = localStorage.getItem(getMenuAuthDataKey())
174
- ? JSON.parse(localStorage.getItem(getMenuAuthDataKey()) as string)
175
- : [];
176
- Object.keys(resourceCodeArray).forEach((item: any) => {
177
- let Item = item;
178
- if (Number(item.slice(-1)) >= 1) {
179
- Item = item.substr(0, item.length - 1);
180
- }
181
- if (shouldUseAuth() && !authButton.filter((itemInner: any) => Item === itemInner).length) {
182
- resourceCodeArray[item].visible = false;
183
- }
184
- });
185
-
186
- }
187
- setValue({
188
- ...value,
189
- columns: [...props.columns],
190
- });
191
- const { columns } = props;
192
- let columnConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.COLUMN_CONDITION);
193
- let showColumns = columnConfig.length ? columnConfig.map((item) => {
194
- let inner = columns.filter(
195
- (inneritem) => {
196
- let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex) ? JSON.stringify(inneritem.key || inneritem.dataIndex) : (inneritem.key || inneritem.dataIndex);
197
- let itemKey = Array.isArray(item.key || item.dataIndex) ? JSON.stringify(item.key || item.dataIndex) : (item.key || item.dataIndex);
198
- return innerKey && innerKey === itemKey;
199
- }
200
- )[0];
201
-
202
- return {
203
- ...inner,
204
- ...item,
205
- };
206
- }) : columns.filter(
207
- (column) => {
208
- let columnKey = Array.isArray(column.key || column.dataIndex) ? JSON.stringify(column.key || column.dataIndex) : (column.key || column.dataIndex);
209
- return column.notRegularCheckList || checkedList.indexOf(columnKey) > -1;
210
- }
211
- )
212
-
213
- showColumns.forEach((item, index) => {
214
- item.width = item.width || getItemDefaultWidth(item);
215
- handleBssulaColumnsSpecialParams(item);
216
- item.onHeaderCell = (column) => ({
217
- ...item,
218
- width:
219
- typeof column.width === 'number'
220
- ? column.width
221
- : parseInt(column.width.replace('px', '')),
222
- onResize: handleResize(index),
223
- });
224
- });
225
- setShowColumns([...showColumns]);
226
-
227
- }
228
-
229
- const setInitialSearchFieldsInfo = () =>{
230
- //获取搜索字段的缓存配置
231
- const { fields = [] } = props;
232
- let searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
233
- let showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map((item) => {
234
- let inner = fields.filter(
235
- (inneritem) => {
236
- let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : inneritem.name;
237
- let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : item.name;
238
- return innerKey && innerKey === itemKey;
239
- }
240
- )[0];
241
-
242
- return {
243
- ...inner,
244
- ...item,
245
- };
246
- }) : fields;
247
- setShowSearchFields([...showSearchFields])
248
- }
249
-
250
- //组件初始挂载
251
- useEffect(() => {
252
- getTableHeight();
253
- setInitialTableInfo();
254
- setInitialSearchFieldsInfo();
255
- window.addEventListener('resize', (e) => {
256
- watchWinResize();
257
- });
258
-
259
- setPagePath(pathname); // 做处理,记录当前页面渲染的初始pathname,用于进行判断当前列表页面数据是否需要重新渲染
260
- }, []);
261
-
262
- useEffect(() => {
263
- if (props?.columns && value?.columns) {
264
- let newKeys = props.columns.map((d: any) => Array.isArray(d.key || d.dataIndex) ? JSON.stringify(d.key || d.dataIndex) : (d.key || d.dataIndex));
265
- let oldKeys = value.columns.map((d: any) => Array.isArray(d.key || d.dataIndex) ? JSON.stringify(d.key || d.dataIndex) : (d.key || d.dataIndex));
266
- JSON.stringify(newKeys) !== JSON.stringify(oldKeys) && setInitialTableInfo();
267
- }
268
- }, [props?.columns])
269
-
270
- useEffect(() => {
271
- if (props?.fields && value?.fields) {
272
- let newKeys = props.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
273
- let oldKeys = value.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
274
- JSON.stringify(newKeys) !== JSON.stringify(oldKeys) && setInitialSearchFieldsInfo();
275
- }
276
- },[props?.fields])
277
-
278
- useEffect(() => {
279
- setInitialTableInfo();
280
- }, [props?.refreshColumns]);
281
-
282
-
283
- const watchWinResize = debounce(() => {
284
- getTableHeight();
285
- if (!checkFull()) {
286
- // addTabsNavStyle(true);
287
- // 全屏下按键esc后要执行的动作
288
- // isFullScreen 为true 此时为全屏状态 false 为非全屏状态
289
- if (!isFullScreen) {
290
- // 按下esc键退出全屏
291
- setIsFnllScreen(false);
292
- } else {
293
- setIsFnllScreen(false);
294
- }
295
- }
296
- }, 10);
297
-
298
- const setCommonRenderFn = (columns: any[]) => {
299
- columns.forEach((column) => {
300
- if (column.showDetailUserInfo) {
301
- column.render = ({ text }: any) => userColumns({ name: text });
302
- }
303
- });
304
- };
305
-
306
- // 处理 table 基本参数
307
- const setTableProps = () => {
308
- let tableProps = value.tableProps || {};
309
- tableProps = {
310
- ...tableProps,
311
- size: value.size || 'middle',
312
- defaultPageSize: 20,
313
- pageSize: 20,
314
- initialPaging: {
315
- pagination: pagination
316
- ? false
317
- : {
318
- defaultPageSize: 20,
319
- pageSize: 20,
320
- showTotal: (total: any) => `共 ${total} 条`,
321
- showQuickJumper: true,
322
- hideOnSinglePage: value.hideOnSinglePage || false,
323
- },
324
- },
325
- initialSelectedRowKeys: value.initialSelectedRowKeys || [],
326
- expandable: value.expandable,
327
- scroll: { x: props.overScrollX || 'max-content', y: height },
328
- bordered: value.bordered || false,
329
- sticky: true,
330
- rowClassName: (record: object | null | undefined, index: number) =>
331
- index % 2 === 0 ? 'table_base' : 'table_odd',
332
- ...value.tableProps,
333
- components: {
334
- header: {
335
- cell: ResizeableTitle,
336
- },
337
- },
338
- };
339
-
340
- // @ts-ignore
341
- if (tableProps?.initialPaging?.pagination) {
342
- // @ts-ignore
343
- tableProps.initialPaging.pagination.showSizeChanger = true;
344
- }
345
- return tableProps;
346
- };
347
-
348
-
349
- const ShowFullScreen = () => {
350
- const isFullScreen: any =
351
- window.top.document.fullScreen ||
352
- window.top.document.webkitIsFullScreen ||
353
- window.top.document.mozFullScreen;
354
- let contentEle: any = window.top.document.querySelector(`body`);
355
- // addTabsNavStyle(isFullScreen);
356
- if (contentEle && !isFullScreen) {
357
- let fullScreenEle =
358
- contentEle.requestFullscreen ||
359
- contentEle.mozRequestFullScreen ||
360
- contentEle.webkitRequestFullScreen ||
361
- contentEle.msRequestFullscreen;
362
- if (fullScreenEle) {
363
- fullScreenEle.call(contentEle);
364
- setIsFnllScreen(true);
365
- // getTableHeight(true);
366
- return;
367
- }
368
- }
369
- if (window.top.document && isFullScreen) {
370
- let exitFullScreen =
371
- window.top.document.exitFullscreen ||
372
- window.top.document.mozCancelFullScreen ||
373
- window.top.document.webkitCancelFullScreen ||
374
- window.top.document.msExitFullscreen;
375
- if (exitFullScreen) {
376
- exitFullScreen.call(window.top.document);
377
- setIsFnllScreen(false);
378
- // getTableHeight();
379
- return;
380
- }
381
- }
382
- };
383
-
384
- const handleTimeValue = () => {
385
- let actionsRender = value.actionsRender || [];
386
- actionsRender = [
387
- ...actionsRender,
388
- {
389
- type: 'text',
390
- props: {
391
- children: (
392
- <span className="ant-dropdown-link">
393
- <Dropdown overlay={
394
- <Menu>
395
- <Menu.Item>
396
- <div
397
- onClick={sortTableRef?.current?.showModal}
398
- style={{fontSize:14, textAlign: 'center'}}
399
- >列设置</div>
400
- </Menu.Item>
401
- <Menu.Item>
402
- <SearchItemTable
403
- ref={searchTableRef}
404
- setShowSearchFields={setShowSearchFields}
405
- showSearchFields={showSearchFields}
406
- datasource={value?.fields || []}
407
- bsTableCode={bsTableCode}
408
- appRequestConfig={appRequestConfig}
409
- />
410
- </Menu.Item>
411
- </Menu>
412
- } placement="bottomRight" >
413
- <span className="ant-dropdown-link">
414
- <img width={32} src={shezhi} />
415
- </span>
416
- </Dropdown>
417
- </span>
418
- ),
419
- },
420
- },
421
- {
422
- type: 'text',
423
- props: {
424
- children: (
425
- <a>
426
- {isFullScreen ? (
427
- <Tooltip title="取消全屏">
428
- <img
429
- onClick={() => {
430
- ShowFullScreen();
431
- }}
432
- width={32}
433
- src={scanning}
434
- />
435
- </Tooltip>
436
- ) : (
437
- <Tooltip title="全屏">
438
- <img
439
- onClick={() => {
440
- ShowFullScreen();
441
- }}
442
- width={32}
443
- src={quanping}
444
- />
445
- </Tooltip>
446
- )}
447
- </a>
448
- ),
449
- },
450
- },
451
- {
452
- type: 'text',
453
- props: {
454
- children:
455
- value?.exportConfig && authFn(value?.exportConfig?.code) ? (
456
- <ExportIcon
457
- request={{
458
- url: `/oms-ops/excel/exportAsync/${value?.exportConfig?.type}`,
459
- params: value?.exportConfig?.params || queryParams,
460
- }}
461
- tableRef={props.forwardedRef || refs}
462
- />
463
- ) : (
464
- <span />
465
- ),
466
- },
467
- },
468
- ];
469
- if (value.rowSelection) {
470
- value.rowSelection.columnWidth = 50;
471
- }
472
- return {
473
- ...value,
474
- actionsRender,
475
- };
476
- };
477
-
478
- const handleResize =
479
- (index) =>
480
- (e, { size }) => {
481
- setShowColumns((columns: any) => {
482
- let newColumns = [...columns];
483
- newColumns[index] = {
484
- ...newColumns[index],
485
- width: size.width,
486
- };
487
- newColumns.forEach((d: any) => {
488
- handleBssulaColumnsSpecialParams(d);
489
- })
490
- return [...newColumns];
491
- });
492
- };
493
-
494
- const setVisibleColumn = (columnTitle: string) => {
495
- sortTableRef?.current?.handleTableHeadHidden?.(columnTitle);
496
- };
497
-
498
- const config = {
499
- visibleFieldsCount: 3,
500
- tableWrapperStyle: {
501
- padding: '10px',
502
- background: '#f3f3f3',
503
- },
504
- setVisibleColumn: setVisibleColumn,
505
- itemLayout: {
506
- span: 8, // 栅格占位格数
507
- labelCol: {
508
- // label标签布局;可设置 span、offset
509
- span: 8,
510
- },
511
- wrapperCol: {
512
- // value布局, 方式同labelCol(horizontal状态下配置)
513
- span: 16,
514
- },
515
- },
516
- rowSelection: false, // 默认无多选
517
- ...handleTimeValue(),
518
- tableProps: setTableProps(),
519
- columns: [...showColumn],
520
- fields: [...showSearchFields],
521
- ref: props.forwardedRef || refs,
522
- isFullScreen,
523
- };
524
-
525
- useEffect(() => {
526
- if (!localStorage.getItem('isTabChange')) {
527
- if (pagePath === pathname) {
528
- // @ts-ignore
529
- config.ref?.current?.tableRef?.current?.refreshTable();
530
- }
531
- } else {
532
- setTimeout(() => {
533
- // 处理页面刷新两面
534
- localStorage.removeItem('isTabChange');
535
- }, 0);
536
- }
537
- }, [pathname]);
538
-
539
- const memoConfig = useMemo(
540
- () => ({
541
- ...config,
542
- summary: props.summary,
543
- statusMapping: props.statusMapping,
544
- appRequestConfig: props.appRequestConfig
545
- }),
546
- [value, checkedList, showColumn, props.statusMapping, showSearchFields],
547
- );
548
- return <>
549
- <MemoQueryTable {...memoConfig} />
550
- <SortableTable
551
- ref={sortTableRef}
552
- setShowColumns={setShowColumns}
553
- showColumn={showColumn}
554
- datasource={value?.columns || []}
555
- bsTableCode={bsTableCode}
556
- appRequestConfig={appRequestConfig}
557
- onlyModal
558
- />
559
- </>;
560
- };
1
+ // @ts-nocheck
2
+ import React, { useState, useEffect, useRef, useMemo } from 'react';
3
+ import { useLocation } from 'umi';
4
+ import { QueryTable } from 'bssula';
5
+ import {
6
+ userColumns,
7
+ getItemDefaultWidth,
8
+ authFn,
9
+ queryParams,
10
+ } from './utils';
11
+ import { Menu, Tooltip, Dropdown } from 'antd';
12
+ import SortableTable from './setting';
13
+ import SearchItemTable from "./SearchItemSetting";
14
+ import { Resizable } from 'react-resizable';
15
+ import quanping from '../../../assets/icon-quanping.svg';
16
+ import scanning from '../../../assets/scanning.svg';
17
+ import shezhi from '../../../assets/icon-shezhi.svg';
18
+ import { debounce } from 'lodash';
19
+ import ExportIcon from '@/components/Functional/ExportFunctions/ExportIcon';
20
+ import ENUM from '@/utils/enumConfig';
21
+ import { handleBssulaColumnsSpecialParams } from '@/utils/utils';
22
+ import { getMenuAuthDataKey } from '@/utils/LocalstorageUtils';
23
+
24
+ interface Field {
25
+ name: string;
26
+ label: string;
27
+ field: any;
28
+ }
29
+
30
+ interface Column {
31
+ key?: string | string[];
32
+ dataIndex?: string | string[];
33
+ notRegularCheckList?: boolean;
34
+ width?: number | string;
35
+ onHeaderCell?: (column: Column) => any; // 仅作示例,具体类型根据实际情况定义
36
+ }
37
+
38
+ const MemoQueryTable = React.memo(QueryTable);
39
+
40
+ const ResizeableTitle = (props) => {
41
+ const { onResize, width, ...restProps } = props;
42
+
43
+ if (!width) {
44
+ return <th {...restProps} />;
45
+ }
46
+ return (
47
+ <Resizable
48
+ width={width}
49
+ height={0}
50
+ onResize={onResize}
51
+ draggableOpts={{ enableUserSelectHack: false }}
52
+ >
53
+ <th {...restProps} />
54
+ </Resizable>
55
+ );
56
+ };
57
+
58
+ export default (props: any) => {
59
+ const bsTableCode = props?.tableCode || window.location.hash; //设置列字段的唯一标识
60
+
61
+ // 获取 table columns中所有的 key 防止有的地方是 dataindex
62
+ const checkedList = useMemo(
63
+ () =>
64
+ props.columns
65
+ .filter((col: any) => !col.hidden)
66
+ .map((d: any) =>
67
+ Array.isArray(d.key || d.dataIndex)
68
+ ? JSON.stringify(d.key || d.dataIndex)
69
+ : d.key || d.dataIndex,
70
+ ),
71
+ [props.columns],
72
+ );
73
+
74
+ const getConfigFromlocalstorage = (type: string) => {
75
+ let config = localStorage.getItem(type) || '[]';
76
+ let configArray = JSON.parse(config);
77
+ let configSetting = configArray.filter(
78
+ (item) => item.code === bsTableCode,
79
+ );
80
+
81
+ if (configSetting.length && configSetting[0].detail) {
82
+ return JSON.parse(configSetting[0].detail);
83
+ }
84
+ return [];
85
+ };
86
+
87
+ /**
88
+ * 根据保存的配置和原始配置,获取设置的字段或列。
89
+ * @param savedConfig 保存的配置数组,可能包含字段或列的配置。
90
+ * @param originConfig 原始配置数组,包含完整的字段或列信息。
91
+ * @param type 字段或列的类型,用于确定配置的属性。
92
+ * @returns 返回根据保存的配置处理后的字段或列数组,如果未保存任何配置,则返回原始配置。
93
+ */
94
+ const getSettingFieldOrColumn = (savedConfig, originConfig, type: string) => {
95
+ /**
96
+ * 判断值是否为字符串数组。
97
+ * @param value 待判断的值。
98
+ * @returns 如果值是字符串数组,则返回true,否则返回false。
99
+ */
100
+ const isStringArray = (value: any): value is string[] => {
101
+ return Array.isArray(value) && value.every(v => typeof v === 'string');
102
+ }
103
+
104
+ /**
105
+ * 根据配置项和类型,获取配置项的键。
106
+ * @param config 配置项,可以是字段或列。
107
+ * @param type 配置项的类型。
108
+ * @returns 返回配置项的键,如果无法获取,则返回空字符串。
109
+ */
110
+ const getItemKey = (config: Column | Field, type: string): string => {
111
+ try {
112
+ if (type === 'columns') {
113
+ return isStringArray(config.key) ? JSON.stringify(config.key) : isStringArray(config.dataIndex) ? JSON.stringify(config.dataIndex) : config.key || config.dataIndex || '';
114
+ }
115
+ return isStringArray(config.name) ? JSON.stringify(config.name) : config.name || '';
116
+ } catch(e) {}
117
+ return '';
118
+ }
119
+
120
+ const newConfig = [];
121
+
122
+ if (savedConfig.length) {
123
+ const hash = originConfig.reduce((prev, inneritem) => {
124
+ prev[getItemKey(inneritem, type)] = inneritem;
125
+ return prev;
126
+ }, {} as { [key: string]: Column | Field });
127
+
128
+ savedConfig.forEach((config, index) => {
129
+ let inner = hash[getItemKey(config, type)];
130
+ inner && newConfig.push({ ...inner, ...config });
131
+ })
132
+ }
133
+
134
+ if (newConfig.length) return newConfig;
135
+
136
+ if (type === 'columns') {
137
+ return originConfig.filter(column => {
138
+ const columnKey = getItemKey(column, type);
139
+ return column.notRegularCheckList || checkedList.indexOf(columnKey) > -1;
140
+ });
141
+ }
142
+
143
+ return [...originConfig];
144
+ }
145
+
146
+ const refs = useRef(null);
147
+ const [pagePath, setPagePath] = useState('');
148
+ const { pathname } = useLocation();
149
+ const [id]: any = useState(
150
+ Number(Math.random().toString().substr(2, 0) + Date.now()).toString(36),
151
+ );
152
+ const [isFullScreen, setIsFnllScreen]: any = useState(false);
153
+ // @ts-nocheck
154
+ const [value, setValue]: any = useState(props);
155
+ const { fields = [] } = props;
156
+ const [showColumn, setShowColumns] = useState([]); // 列字段
157
+ const originSearchFields = getSettingFieldOrColumn(getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION), fields, 'searchFields');
158
+ const [showSearchFields, setShowSearchFields] = useState(originSearchFields); //搜索项字段
159
+ const { isPage = true, pagination, tableCode, appRequestConfig } = props;
160
+
161
+ const [height, setHeight]: any = useState('100vh');
162
+ const sortTableRef = useRef(null);
163
+ const searchTableRef = useRef(null);
164
+
165
+ // 获取table高度
166
+ const getTableHeight = () => {
167
+ setTimeout(() => {
168
+ const cancelHeight = window.top == window ? 303 : 223;
169
+ const isFullScreen: any =
170
+ window.top.document.fullScreen ||
171
+ window.top.document.webkitIsFullScreen ||
172
+ window.top.document.mozFullScreen;
173
+
174
+ // wujie子应用iframe首次加载获取不到client以及dom元素高度兼容处理
175
+ let realIframeClientHeight = document.body.clientHeight ? document.body.clientHeight : window.top?.document.body.clientHeight - 76;
176
+ let summaryHeight = document.querySelector(`.ant-tabs-tabpane-active .table-bssula-summary`) ?
177
+ (document.querySelector(`.ant-tabs-tabpane-active .table-bssula-summary`)?.clientHeight || 22) : 0;
178
+ let listTabHeight = document.querySelector(`.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`) ?
179
+ (document.querySelector(`.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`)?.clientHeight || 48) : 0;
180
+
181
+
182
+ const h =
183
+ realIframeClientHeight - summaryHeight - listTabHeight -
184
+ (document.querySelector(`.ant-tabs-tabpane-active .ant-form ant-form-horizontal`)?.clientHeight ||
185
+ 0) -
186
+ (isFullScreen
187
+ ? 0
188
+ : document.querySelector(`.ant-tabs-tabpane-active .ant-pro-page-container-warp`)
189
+ ?.clientHeight || 0) -
190
+ cancelHeight +
191
+ 'px';
192
+ setHeight(h);
193
+ setValue({ ...value });
194
+ }, 0)
195
+ };
196
+
197
+ //监测是否按下esc键
198
+ function checkFull() {
199
+ let globalDocument = window?.parent?.document || document;
200
+ var isFull =
201
+ globalDocument.fullscreenElement ||
202
+ globalDocument.mozFullScreenElement ||
203
+ globalDocument.webkitFullscreenElement;
204
+ if (isFull == undefined) isFull = false;
205
+ return isFull;
206
+ }
207
+
208
+ const setInitialTableInfo = () => {
209
+ const resourceCodeArray = {};
210
+ if (props.actionsRender && props.actionsRender.length) {
211
+ props.actionsRender.forEach((item: any) => {
212
+ if (item.code) {
213
+ if (resourceCodeArray[item.code]) {
214
+ resourceCodeArray[item.code + 1] = item;
215
+ } else {
216
+ resourceCodeArray[item.code] = item;
217
+ }
218
+ }
219
+ });
220
+ }
221
+ if (props.columns && props.columns.length) {
222
+ props.columns.forEach((d: any) => {
223
+ if (d.isPermissionColumn && d.render && d.render.length) {
224
+ d.render.forEach((inneritem: any) => {
225
+ if (inneritem.code) {
226
+ if (resourceCodeArray[inneritem.code]) {
227
+ resourceCodeArray[inneritem.code + 1] = inneritem;
228
+ } else {
229
+ resourceCodeArray[inneritem.code] = inneritem;
230
+ }
231
+ }
232
+ });
233
+ }
234
+ handleBssulaColumnsSpecialParams(d);
235
+ });
236
+ setCommonRenderFn(props.columns);
237
+ const authButton = localStorage.getItem(getMenuAuthDataKey())
238
+ ? JSON.parse(localStorage.getItem(getMenuAuthDataKey()) as string)
239
+ : [];
240
+ Object.keys(resourceCodeArray).forEach((item: any) => {
241
+ let Item = item;
242
+ if (Number(item.slice(-1)) >= 1) {
243
+ Item = item.substr(0, item.length - 1);
244
+ }
245
+ if (!authButton.filter((itemInner: any) => Item === itemInner).length) {
246
+ resourceCodeArray[item].visible = false;
247
+ }
248
+ });
249
+
250
+ }
251
+ setValue({
252
+ ...value,
253
+ columns: [...props.columns],
254
+ });
255
+ const { columns } = props;
256
+ let columnConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.COLUMN_CONDITION);
257
+ let showColumns = getSettingFieldOrColumn(columnConfig, columns, 'columns');
258
+
259
+ showColumns.forEach((item, index) => {
260
+ item.width = item.width || getItemDefaultWidth(item);
261
+ handleBssulaColumnsSpecialParams(item);
262
+ item.onHeaderCell = (column) => ({
263
+ ...item,
264
+ width:
265
+ typeof column.width === 'number'
266
+ ? column.width
267
+ : parseInt(column.width.replace('px', '')),
268
+ onResize: handleResize(index),
269
+ });
270
+ });
271
+ setShowColumns([...showColumns]);
272
+
273
+ }
274
+
275
+ const setInitialSearchFieldsInfo = () =>{
276
+ //获取搜索字段的缓存配置
277
+ const { fields = [] } = props;
278
+ let searchFieldsConfig = getConfigFromlocalstorage(ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION);
279
+ let showSearchFields = searchFieldsConfig.length ? searchFieldsConfig.map((item) => {
280
+ let inner = fields.filter(
281
+ (inneritem) => {
282
+ let innerKey = Array.isArray(inneritem.name) ? JSON.stringify(inneritem.name) : inneritem.name;
283
+ let itemKey = Array.isArray(item.name) ? JSON.stringify(item.name) : item.name;
284
+ return innerKey && innerKey === itemKey;
285
+ }
286
+ )[0];
287
+
288
+ return {
289
+ ...inner,
290
+ ...item,
291
+ };
292
+ }) : fields;
293
+ setShowSearchFields([...showSearchFields])
294
+ }
295
+
296
+ //组件初始挂载
297
+ useEffect(() => {
298
+ getTableHeight();
299
+ setInitialTableInfo();
300
+ setInitialSearchFieldsInfo();
301
+ window.addEventListener('resize', (e) => {
302
+ watchWinResize();
303
+ });
304
+
305
+ setPagePath(pathname); // 做处理,记录当前页面渲染的初始pathname,用于进行判断当前列表页面数据是否需要重新渲染
306
+ }, []);
307
+
308
+ useEffect(() => {
309
+ if (props?.columns && value?.columns) {
310
+ let newKeys = props.columns.map((d: any) => Array.isArray(d.key || d.dataIndex) ? JSON.stringify(d.key || d.dataIndex) : (d.key || d.dataIndex));
311
+ let oldKeys = value.columns.map((d: any) => Array.isArray(d.key || d.dataIndex) ? JSON.stringify(d.key || d.dataIndex) : (d.key || d.dataIndex));
312
+ JSON.stringify(newKeys) !== JSON.stringify(oldKeys) && setInitialTableInfo();
313
+ }
314
+ }, [props?.columns])
315
+
316
+ useEffect(() => {
317
+ if (props?.fields && value?.fields) {
318
+ let newKeys = props.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
319
+ let oldKeys = value.fields.map((d: any) => Array.isArray(d.name) ? JSON.stringify(d.name) : (d.name));
320
+ JSON.stringify(newKeys) !== JSON.stringify(oldKeys) && setInitialSearchFieldsInfo();
321
+ }
322
+ },[props?.fields])
323
+
324
+ useEffect(() => {
325
+ setInitialTableInfo();
326
+ }, [props?.refreshColumns]);
327
+
328
+
329
+ const watchWinResize = debounce(() => {
330
+ getTableHeight();
331
+ if (!checkFull()) {
332
+ // addTabsNavStyle(true);
333
+ // 全屏下按键esc后要执行的动作
334
+ // isFullScreen 为true 此时为全屏状态 false 为非全屏状态
335
+ if (!isFullScreen) {
336
+ // 按下esc键退出全屏
337
+ setIsFnllScreen(false);
338
+ } else {
339
+ setIsFnllScreen(false);
340
+ }
341
+ }
342
+ }, 10);
343
+
344
+ const setCommonRenderFn = (columns: any[]) => {
345
+ columns.forEach((column) => {
346
+ if (column.showDetailUserInfo) {
347
+ column.render = ({ text }: any) => userColumns({ name: text });
348
+ }
349
+ });
350
+ };
351
+
352
+ // 处理 table 基本参数
353
+ const setTableProps = () => {
354
+ let tableProps = value.tableProps || {};
355
+ tableProps = {
356
+ ...tableProps,
357
+ size: value.size || 'middle',
358
+ defaultPageSize: 20,
359
+ pageSize: 20,
360
+ initialPaging: {
361
+ pagination: pagination
362
+ ? false
363
+ : {
364
+ defaultPageSize: 20,
365
+ pageSize: 20,
366
+ showTotal: (total: any) => `共 ${total} 条`,
367
+ showQuickJumper: true,
368
+ hideOnSinglePage: value.hideOnSinglePage || false,
369
+ },
370
+ },
371
+ initialSelectedRowKeys: value.initialSelectedRowKeys || [],
372
+ expandable: value.expandable,
373
+ scroll: { x: props.overScrollX || 'max-content', y: height },
374
+ bordered: value.bordered || false,
375
+ sticky: true,
376
+ rowClassName: (record: object | null | undefined, index: number) =>
377
+ index % 2 === 0 ? 'table_base' : 'table_odd',
378
+ ...value.tableProps,
379
+ components: {
380
+ header: {
381
+ cell: ResizeableTitle,
382
+ },
383
+ },
384
+ };
385
+
386
+ // @ts-ignore
387
+ if (tableProps?.initialPaging?.pagination) {
388
+ // @ts-ignore
389
+ tableProps.initialPaging.pagination.showSizeChanger = true;
390
+ }
391
+ return tableProps;
392
+ };
393
+
394
+
395
+ const ShowFullScreen = () => {
396
+ const isFullScreen: any =
397
+ window.top.document.fullScreen ||
398
+ window.top.document.webkitIsFullScreen ||
399
+ window.top.document.mozFullScreen;
400
+ let contentEle: any = window.top.document.querySelector(`body`);
401
+ // addTabsNavStyle(isFullScreen);
402
+ if (contentEle && !isFullScreen) {
403
+ let fullScreenEle =
404
+ contentEle.requestFullscreen ||
405
+ contentEle.mozRequestFullScreen ||
406
+ contentEle.webkitRequestFullScreen ||
407
+ contentEle.msRequestFullscreen;
408
+ if (fullScreenEle) {
409
+ fullScreenEle.call(contentEle);
410
+ setIsFnllScreen(true);
411
+ // getTableHeight(true);
412
+ return;
413
+ }
414
+ }
415
+ if (window.top.document && isFullScreen) {
416
+ let exitFullScreen =
417
+ window.top.document.exitFullscreen ||
418
+ window.top.document.mozCancelFullScreen ||
419
+ window.top.document.webkitCancelFullScreen ||
420
+ window.top.document.msExitFullscreen;
421
+ if (exitFullScreen) {
422
+ exitFullScreen.call(window.top.document);
423
+ setIsFnllScreen(false);
424
+ // getTableHeight();
425
+ return;
426
+ }
427
+ }
428
+ };
429
+
430
+ const handleTimeValue = () => {
431
+ let actionsRender = value.actionsRender || [];
432
+ actionsRender = [
433
+ ...actionsRender,
434
+ {
435
+ type: 'text',
436
+ props: {
437
+ children: (
438
+ <span className="ant-dropdown-link">
439
+ <Dropdown overlay={
440
+ <Menu>
441
+ <Menu.Item>
442
+ <div
443
+ onClick={sortTableRef?.current?.showModal}
444
+ style={{fontSize:14, textAlign: 'center'}}
445
+ >列设置</div>
446
+ </Menu.Item>
447
+ <Menu.Item>
448
+ <SearchItemTable
449
+ ref={searchTableRef}
450
+ setShowSearchFields={setShowSearchFields}
451
+ showSearchFields={showSearchFields}
452
+ datasource={value?.fields || []}
453
+ bsTableCode={bsTableCode}
454
+ appRequestConfig={appRequestConfig}
455
+ />
456
+ </Menu.Item>
457
+ </Menu>
458
+ } placement="bottomRight" >
459
+ <span className="ant-dropdown-link">
460
+ <img width={32} src={shezhi} />
461
+ </span>
462
+ </Dropdown>
463
+ </span>
464
+ ),
465
+ },
466
+ },
467
+ {
468
+ type: 'text',
469
+ props: {
470
+ children: (
471
+ <a>
472
+ {isFullScreen ? (
473
+ <Tooltip title="取消全屏">
474
+ <img
475
+ onClick={() => {
476
+ ShowFullScreen();
477
+ }}
478
+ width={32}
479
+ src={scanning}
480
+ />
481
+ </Tooltip>
482
+ ) : (
483
+ <Tooltip title="全屏">
484
+ <img
485
+ onClick={() => {
486
+ ShowFullScreen();
487
+ }}
488
+ width={32}
489
+ src={quanping}
490
+ />
491
+ </Tooltip>
492
+ )}
493
+ </a>
494
+ ),
495
+ },
496
+ },
497
+ {
498
+ type: 'text',
499
+ props: {
500
+ children:
501
+ value?.exportConfig && authFn(value?.exportConfig?.code) ? (
502
+ <ExportIcon
503
+ request={{
504
+ url: `/oms-ops/excel/exportAsync/${value?.exportConfig?.type}`,
505
+ params: value?.exportConfig?.params || queryParams,
506
+ }}
507
+ tableRef={props.forwardedRef || refs}
508
+ />
509
+ ) : (
510
+ <span />
511
+ ),
512
+ },
513
+ },
514
+ ];
515
+ if (value.rowSelection) {
516
+ value.rowSelection.columnWidth = 50;
517
+ }
518
+ return {
519
+ ...value,
520
+ actionsRender,
521
+ };
522
+ };
523
+
524
+ const handleResize =
525
+ (index) =>
526
+ (e, { size }) => {
527
+ setShowColumns((columns: any) => {
528
+ let newColumns = [...columns];
529
+ newColumns[index] = {
530
+ ...newColumns[index],
531
+ width: size.width,
532
+ };
533
+ newColumns.forEach((d: any) => {
534
+ handleBssulaColumnsSpecialParams(d);
535
+ })
536
+ return [...newColumns];
537
+ });
538
+ };
539
+
540
+ const setVisibleColumn = (columnTitle: string) => {
541
+ sortTableRef?.current?.handleTableHeadHidden?.(columnTitle);
542
+ };
543
+
544
+ const config = {
545
+ visibleFieldsCount: 3,
546
+ tableWrapperStyle: {
547
+ padding: '10px',
548
+ background: '#f3f3f3',
549
+ },
550
+ setVisibleColumn: setVisibleColumn,
551
+ itemLayout: {
552
+ span: 8, // 栅格占位格数
553
+ labelCol: {
554
+ // label标签布局;可设置 span、offset
555
+ span: 8,
556
+ },
557
+ wrapperCol: {
558
+ // value布局, 方式同labelCol(horizontal状态下配置)
559
+ span: 16,
560
+ },
561
+ },
562
+ rowSelection: false, // 默认无多选
563
+ ...handleTimeValue(),
564
+ tableProps: setTableProps(),
565
+ columns: [...showColumn],
566
+ fields: [...showSearchFields],
567
+ ref: props.forwardedRef || refs,
568
+ isFullScreen,
569
+ };
570
+
571
+ useEffect(() => {
572
+ if (!localStorage.getItem('isTabChange')) {
573
+ if (pagePath === pathname) {
574
+ // @ts-ignore
575
+ config.ref?.current?.tableRef?.current?.refreshTable();
576
+ }
577
+ } else {
578
+ setTimeout(() => {
579
+ // 处理页面刷新两面
580
+ localStorage.removeItem('isTabChange');
581
+ }, 0);
582
+ }
583
+ }, [pathname]);
584
+
585
+ const memoConfig = useMemo(
586
+ () => ({
587
+ ...config,
588
+ summary: props.summary,
589
+ statusMapping: props.statusMapping,
590
+ appRequestConfig: props.appRequestConfig
591
+ }),
592
+ [value, checkedList, showColumn, props.statusMapping, showSearchFields],
593
+ );
594
+ return <>
595
+ <MemoQueryTable {...memoConfig} />
596
+ <SortableTable
597
+ ref={sortTableRef}
598
+ setShowColumns={setShowColumns}
599
+ showColumn={showColumn}
600
+ datasource={value?.columns || []}
601
+ bsTableCode={bsTableCode}
602
+ appRequestConfig={appRequestConfig}
603
+ onlyModal
604
+ />
605
+ </>;
606
+ };