@bit-sun/business-component 3.0.0-alpha.21 → 3.0.0-alpha.23

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 (117) 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.esm.js +1271 -1236
  9. package/dist/index.js +345 -310
  10. package/docs/index.md +21 -21
  11. package/lib/assets/drag.svg +17 -17
  12. package/lib/assets/exportFail.svg +37 -37
  13. package/lib/assets/exportProcessing.svg +28 -28
  14. package/lib/assets/exportSuccess.svg +34 -34
  15. package/lib/assets/label_icon_bottom.svg +25 -25
  16. package/lib/assets/upExport.svg +22 -22
  17. package/package.json +82 -82
  18. package/src/assets/arrow_top.svg +17 -17
  19. package/src/assets/caidan.svg +11 -11
  20. package/src/assets/exportFail.svg +37 -37
  21. package/src/assets/exportProcessing.svg +28 -28
  22. package/src/assets/exportSuccess.svg +34 -34
  23. package/src/assets/fixed-left-active.svg +11 -11
  24. package/src/assets/fixed-right-active.svg +11 -11
  25. package/src/components/Business/AddSelectBusiness/index.md +162 -162
  26. package/src/components/Business/AddSelectBusiness/index.tsx +1079 -1079
  27. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  28. package/src/components/Business/BsLayouts/Components/ChooseStore/index.tsx +193 -193
  29. package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +10 -10
  30. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  31. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  32. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  33. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +163 -163
  34. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  35. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  36. package/src/components/Business/BsLayouts/Components/RightContent/i18n.ts +8 -8
  37. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +172 -172
  38. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  39. package/src/components/Business/BsLayouts/index.tsx +1494 -1494
  40. package/src/components/Business/BsLayouts/service.ts +10 -10
  41. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +566 -566
  42. package/src/components/Business/BsSulaQueryTable/bssulaquerytable.less +5 -5
  43. package/src/components/Business/BsSulaQueryTable/index.tsx +729 -729
  44. package/src/components/Business/BsSulaQueryTable/setting.tsx +892 -892
  45. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  46. package/src/components/Business/BsSulaQueryTable/utils.tsx +713 -713
  47. package/src/components/Business/CommodityEntry/index.tsx +3 -2
  48. package/src/components/Business/CommonAlert/index.tsx +23 -23
  49. package/src/components/Business/CommonGuideWrapper/index.less +121 -121
  50. package/src/components/Business/CommonGuideWrapper/index.tsx +94 -94
  51. package/src/components/Business/DetailPageWrapper/index.less +88 -88
  52. package/src/components/Business/DetailPageWrapper/index.tsx +326 -326
  53. package/src/components/Business/DetailPageWrapper/utils.tsx +164 -164
  54. package/src/components/Business/HomePageWrapper/index.less +33 -33
  55. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +824 -824
  56. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +205 -205
  57. package/src/components/Business/JsonQueryTable/components/Formula.tsx +206 -206
  58. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -127
  59. package/src/components/Business/JsonQueryTable/function.ts +62 -62
  60. package/src/components/Business/JsonQueryTable/index.tsx +535 -535
  61. package/src/components/Business/JsonQueryTable/static.ts +450 -450
  62. package/src/components/Business/SearchSelect/{BusinessUtils.ts → BusinessUtils.tsx} +2139 -2076
  63. package/src/components/Business/SearchSelect/common.ts +134 -134
  64. package/src/components/Business/SearchSelect/index.md +1503 -1444
  65. package/src/components/Business/SearchSelect/index.tsx +55 -55
  66. package/src/components/Business/SearchSelect/utils.ts +101 -101
  67. package/src/components/Business/StateFlow/index.less +130 -130
  68. package/src/components/Business/TreeSearchSelect/index.md +185 -185
  69. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  70. package/src/components/Business/TreeSearchSelect/utils.ts +104 -104
  71. package/src/components/Business/columnSettingTable/columnSetting.tsx +767 -767
  72. package/src/components/Business/columnSettingTable/index.tsx +235 -235
  73. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +243 -243
  74. package/src/components/Business/columnSettingTable/utils.tsx +70 -70
  75. package/src/components/Business/moreTreeTable/index.md +448 -448
  76. package/src/components/Functional/AddSelect/helps.ts +81 -81
  77. package/src/components/Functional/AddSelect/index.md +155 -155
  78. package/src/components/Functional/AddSelect/index.tsx +1217 -1217
  79. package/src/components/Functional/BillEntry/index.md +39 -39
  80. package/src/components/Functional/BillEntry/index.tsx +773 -773
  81. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -62
  82. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -178
  83. package/src/components/Functional/DataImport/index.md +44 -44
  84. package/src/components/Functional/DataImport/index.tsx +696 -696
  85. package/src/components/Functional/DataValidation/index.md +39 -39
  86. package/src/components/Functional/DataValidation/index.tsx +688 -688
  87. package/src/components/Functional/EllipsisTooltip/index.md +30 -30
  88. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  89. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +65 -65
  90. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  91. package/src/components/Functional/QueryMutipleInput/index.tsx +129 -129
  92. package/src/components/Functional/SearchSelect/index.less +121 -121
  93. package/src/components/Functional/SearchSelect/index.md +141 -141
  94. package/src/components/Functional/SearchSelect/index.tsx +1003 -1003
  95. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  96. package/src/components/Functional/TreeSearchSelect/index.tsx +206 -206
  97. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -62
  98. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +637 -637
  99. package/src/components/Solution/RuleComponent/index.js +1428 -1428
  100. package/src/components/Solution/RuleComponent/ruleFiled.js +2281 -2281
  101. package/src/components/Solution/RuleComponent/services.ts +13 -13
  102. package/src/components/Solution/RuleComponent/util.js +143 -143
  103. package/src/index.ts +38 -38
  104. package/src/plugin/TableColumnSetting/index.tsx +725 -725
  105. package/src/styles/bsDefault.less +1912 -1912
  106. package/src/utils/CustomLoginInfo.ts +55 -55
  107. package/src/utils/LocalstorageUtils.ts +95 -95
  108. package/src/utils/TableUtils.less +51 -51
  109. package/src/utils/TableUtils.tsx +691 -691
  110. package/src/utils/businessUtils.ts +441 -441
  111. package/src/utils/constant.ts +38 -38
  112. package/src/utils/index.ts +6 -6
  113. package/src/utils/request.ts +53 -53
  114. package/src/utils/requestUtils.ts +193 -193
  115. package/src/utils/utils.ts +238 -238
  116. package/tsconfig.json +29 -29
  117. package/typings.d.ts +4 -4
@@ -1,729 +1,729 @@
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
- renderToString,
11
- } from './utils';
12
- import { Menu, Tooltip, Dropdown, Table, Typography } from 'antd';
13
- import SortableTable from './setting';
14
- import SearchItemTable from './SearchItemSetting';
15
- import { Resizable } from 'react-resizable';
16
- import quanping from '../../../assets/icon-quanping.svg';
17
- import scanning from '../../../assets/scanning.svg';
18
- import shezhi from '../../../assets/icon-shezhi.svg';
19
- import { debounce } from 'lodash';
20
- import ExportIcon from '@/components/Functional/ExportFunctions/ExportIcon';
21
- import ENUM from '@/utils/enumConfig';
22
- import { handleBssulaColumnsSpecialParams } from '@/utils/utils';
23
- import './bssulaquerytable.less';
24
- const MemoQueryTable = React.memo(QueryTable);
25
- const { Text } = Typography;
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 { isPage = true, pagination, tableCode } = props;
47
- const refs = useRef(null);
48
- const [pagePath, setPagePath] = useState('');
49
- // 获取 table columns中所有的 key 防止有的地方是 dataindex
50
- const checkedList = props.columns
51
- .filter((col: any) => !col.hidden)
52
- .map((d: any) =>
53
- Array.isArray(d.key || d.dataIndex)
54
- ? JSON.stringify(d.key || d.dataIndex)
55
- : d.key || d.dataIndex,
56
- );
57
-
58
- const { pathname, state = {} } = useLocation();
59
- const [isFullScreen, setIsFnllScreen]: any = useState(false);
60
- // @ts-nocheck
61
- const value = props;
62
- const [showColumn, setShowColumns] = useState([]); // 列字段
63
- const [showSearchFields, setShowSearchFields] = useState(props.fields || []); //搜索项字段
64
- const [showExportColumn, setShowExportColumns] = useState([]); // 导出列字段
65
-
66
- const [height, setHeight]: any = useState('100vh');
67
- const sortTableRef = useRef(null);
68
- const searchTableRef = useRef(null);
69
- const exportTableRef = useRef<any>(null);
70
-
71
- const bsTableCode = tableCode || window.location.hash; //设置列字段的唯一标识
72
- const bsTableCodeExport = `${bsTableCode}___Export`; //设置导出列字段的唯一标识
73
- // 获取table高度
74
- const getTableHeight = () => {
75
- setTimeout(() => {
76
- const cancelHeight = window.top == window ? 303 : 223;
77
- const isFullScreen: any =
78
- window.top.document.fullScreen ||
79
- window.top.document.webkitIsFullScreen ||
80
- window.top.document.mozFullScreen;
81
-
82
- // wujie子应用iframe首次加载获取不到client以及dom元素高度兼容处理
83
- let realIframeClientHeight = document.body.clientHeight
84
- ? document.body.clientHeight
85
- : window.top?.document.body.clientHeight - 76;
86
- let summaryHeight = document.querySelector(
87
- `.ant-tabs-tabpane-active .table-bssula-summary`,
88
- )
89
- ? document.querySelector(
90
- `.ant-tabs-tabpane-active .table-bssula-summary`,
91
- )?.clientHeight || 22
92
- : 0;
93
- let listTabHeight = document.querySelector(
94
- `.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`,
95
- )
96
- ? document.querySelector(
97
- `.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`,
98
- )?.clientHeight || 48
99
- : 0;
100
-
101
- const h =
102
- realIframeClientHeight -
103
- summaryHeight -
104
- listTabHeight -
105
- (document.querySelector(
106
- `.ant-tabs-tabpane-active .ant-form ant-form-horizontal`,
107
- )?.clientHeight || 0) -
108
- (isFullScreen
109
- ? 0
110
- : document.querySelector(
111
- `.ant-tabs-tabpane-active .ant-pro-page-container-warp`,
112
- )?.clientHeight || 0) -
113
- cancelHeight +
114
- 'px';
115
- setHeight(h);
116
- }, 0);
117
- };
118
-
119
- //监测是否按下esc键
120
- function checkFull() {
121
- let globalDocument = window?.parent?.document || document;
122
- var isFull =
123
- globalDocument.fullscreenElement ||
124
- globalDocument.mozFullScreenElement ||
125
- globalDocument.webkitFullscreenElement;
126
- if (isFull == undefined) isFull = false;
127
- return isFull;
128
- }
129
-
130
- const getConfigFromlocalstorage = (
131
- type: string,
132
- tableCode: string = bsTableCode,
133
- ) => {
134
- let config = localStorage.getItem(type) || '[]';
135
- let configArray = JSON.parse(config);
136
- let configSetting = configArray.filter((item) => item.code === tableCode);
137
-
138
- if (configSetting.length && configSetting[0].detail) {
139
- return JSON.parse(configSetting[0].detail);
140
- }
141
- return [];
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(
174
- ENUM.BROWSER_CACHE.MAIN_AUTH_CODES,
175
- )
176
- ? JSON.parse(
177
- localStorage.getItem(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES) as string,
178
- )
179
- : [];
180
- Object.keys(resourceCodeArray).forEach((item: any) => {
181
- let Item = item;
182
- if (Number(item.slice(-1)) >= 1) {
183
- Item = item.substr(0, item.length - 1);
184
- }
185
- if (!authButton.filter((itemInner: any) => Item === itemInner).length) {
186
- resourceCodeArray[item].visible = false;
187
- }
188
- });
189
- }
190
- const { columns, exportColumns } = props;
191
-
192
- const getShowColumns = (columnConfig: any, columns: any) => {
193
- return columnConfig.length
194
- ? columnConfig.map((item) => {
195
- let inner = columns.filter((inneritem) => {
196
- let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex)
197
- ? JSON.stringify(inneritem.key || inneritem.dataIndex)
198
- : inneritem.key || inneritem.dataIndex;
199
- let itemKey = Array.isArray(item.key || item.dataIndex)
200
- ? JSON.stringify(item.key || item.dataIndex)
201
- : item.key || item.dataIndex;
202
- return innerKey && innerKey === itemKey;
203
- })[0];
204
-
205
- return {
206
- ...inner,
207
- ...item,
208
- };
209
- })
210
- : columns.filter((column) => {
211
- let columnKey = Array.isArray(column.key || column.dataIndex)
212
- ? JSON.stringify(column.key || column.dataIndex)
213
- : column.key || column.dataIndex;
214
- return (
215
- column.notRegularCheckList || checkedList.indexOf(columnKey) > -1
216
- );
217
- });
218
- };
219
-
220
- let columnConfig = getConfigFromlocalstorage(
221
- ENUM.BROWSER_CACHE.COLUMN_CONDITION,
222
- );
223
- let showColumns = getShowColumns(columnConfig, columns);
224
-
225
- showColumns.forEach((item, index) => {
226
- item.width = item.width || getItemDefaultWidth(item);
227
- handleBssulaColumnsSpecialParams(item);
228
- item.onHeaderCell = (column) => ({
229
- ...item,
230
- width:
231
- typeof column.width === 'number'
232
- ? column.width
233
- : parseInt(column.width.replace('px', '')),
234
- onResize: handleResize(index),
235
- });
236
- });
237
- setShowColumns([...showColumns]);
238
-
239
- let exportColumnConfig = getConfigFromlocalstorage(
240
- ENUM.BROWSER_CACHE.COLUMN_CONDITION,
241
- bsTableCodeExport,
242
- );
243
- let showExportColumns = getShowColumns(exportColumnConfig, columns);
244
-
245
- showExportColumns.forEach((item, index) => {
246
- item.width = item.width || getItemDefaultWidth(item);
247
- handleBssulaColumnsSpecialParams(item);
248
- item.onHeaderCell = (column) => ({
249
- ...item,
250
- width:
251
- typeof column.width === 'number'
252
- ? column.width
253
- : parseInt(column.width.replace('px', '')),
254
- onResize: handleResize(index),
255
- });
256
- });
257
- setShowExportColumns([...showExportColumns]);
258
- };
259
-
260
- const setInitialSearchFieldsInfo = () => {
261
- //获取搜索字段的缓存配置
262
- const { fields = [] } = props;
263
- let searchFieldsConfig = getConfigFromlocalstorage(
264
- ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION,
265
- );
266
- let showSearchFields = searchFieldsConfig.length
267
- ? searchFieldsConfig.map((item) => {
268
- let inner = fields.filter((inneritem) => {
269
- let innerKey = Array.isArray(inneritem.name)
270
- ? JSON.stringify(inneritem.name)
271
- : inneritem.name;
272
- let itemKey = Array.isArray(item.name)
273
- ? JSON.stringify(item.name)
274
- : item.name;
275
- return innerKey && innerKey === itemKey;
276
- })[0];
277
-
278
- return {
279
- ...inner,
280
- ...item,
281
- };
282
- })
283
- : fields;
284
- setShowSearchFields([...showSearchFields]);
285
- };
286
-
287
- //组件初始挂载
288
- useEffect(() => {
289
- getTableHeight();
290
- setInitialTableInfo();
291
- setInitialSearchFieldsInfo();
292
- window.addEventListener('resize', (e) => {
293
- watchWinResize();
294
- });
295
-
296
- setPagePath(pathname); // 做处理,记录当前页面渲染的初始pathname,用于进行判断当前列表页面数据是否需要重新渲染
297
- }, []);
298
-
299
- useEffect(() => {
300
- if (props?.columns && value?.columns) {
301
- let newKeys = props.columns.map((d: any) =>
302
- Array.isArray(d.key || d.dataIndex)
303
- ? JSON.stringify(d.key || d.dataIndex)
304
- : d.key || d.dataIndex,
305
- );
306
- let oldKeys = value.columns.map((d: any) =>
307
- Array.isArray(d.key || d.dataIndex)
308
- ? JSON.stringify(d.key || d.dataIndex)
309
- : d.key || d.dataIndex,
310
- );
311
- JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
312
- setInitialTableInfo();
313
- }
314
- }, [props?.columns]);
315
-
316
- useEffect(() => {
317
- if (props?.fields && value?.fields) {
318
- let newKeys = props.fields.map((d: any) =>
319
- Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
320
- );
321
- let oldKeys = value.fields.map((d: any) =>
322
- Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
323
- );
324
- JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
325
- setInitialSearchFieldsInfo();
326
- }
327
- }, [props?.fields]);
328
-
329
- useEffect(() => {
330
- setInitialTableInfo();
331
- }, [props?.refreshColumns]);
332
-
333
- const watchWinResize = debounce(() => {
334
- getTableHeight();
335
- if (!checkFull()) {
336
- // addTabsNavStyle(true);
337
- // 全屏下按键esc后要执行的动作
338
- // isFullScreen 为true 此时为全屏状态 false 为非全屏状态
339
- if (!isFullScreen) {
340
- // 按下esc键退出全屏
341
- setIsFnllScreen(false);
342
- } else {
343
- setIsFnllScreen(false);
344
- }
345
- }
346
- }, 10);
347
-
348
- const setCommonRenderFn = (columns: any[]) => {
349
- columns.forEach((column) => {
350
- if (column.showDetailUserInfo) {
351
- column.render = ({ text }: any) => userColumns({ name: text });
352
- }
353
- });
354
- };
355
-
356
- // 处理 table 基本参数
357
- const setTableProps = () => {
358
- let tableProps = value.tableProps || {};
359
- tableProps = {
360
- ...tableProps,
361
- size: value.size || 'middle',
362
- defaultPageSize: 20,
363
- pageSize: 20,
364
- initialPaging: {
365
- pagination: pagination
366
- ? false
367
- : {
368
- defaultPageSize: 20,
369
- pageSize: 20,
370
- showTotal: (total: any) => `共 ${total} 条`,
371
- showQuickJumper: true,
372
- hideOnSinglePage: value.hideOnSinglePage || false,
373
- },
374
- },
375
- initialSelectedRowKeys: value.initialSelectedRowKeys || [],
376
- expandable: props.expandable,
377
- scroll: { x: props.overScrollX || 'max-content', y: height },
378
- bordered: value.bordered || false,
379
- sticky: true,
380
- rowClassName: (record: object | null | undefined, index: number) =>
381
- index % 2 === 0 ? 'table_base' : 'table_odd',
382
- ...value.tableProps,
383
- components: {
384
- header: {
385
- cell: ResizeableTitle,
386
- },
387
- },
388
- };
389
-
390
- // @ts-ignore
391
- if (tableProps?.initialPaging?.pagination) {
392
- // @ts-ignore
393
- tableProps.initialPaging.pagination.showSizeChanger = true;
394
- }
395
- return tableProps;
396
- };
397
-
398
- const ShowFullScreen = () => {
399
- const isFullScreen: any =
400
- window.top.document.fullScreen ||
401
- window.top.document.webkitIsFullScreen ||
402
- window.top.document.mozFullScreen;
403
- let contentEle: any = window.top.document.querySelector(`body`);
404
- // addTabsNavStyle(isFullScreen);
405
- if (contentEle && !isFullScreen) {
406
- let fullScreenEle =
407
- contentEle.requestFullscreen ||
408
- contentEle.mozRequestFullScreen ||
409
- contentEle.webkitRequestFullScreen ||
410
- contentEle.msRequestFullscreen;
411
- if (fullScreenEle) {
412
- fullScreenEle.call(contentEle);
413
- setIsFnllScreen(true);
414
- // getTableHeight(true);
415
- return;
416
- }
417
- }
418
- if (window.top.document && isFullScreen) {
419
- let exitFullScreen =
420
- window.top.document.exitFullscreen ||
421
- window.top.document.mozCancelFullScreen ||
422
- window.top.document.webkitCancelFullScreen ||
423
- window.top.document.msExitFullscreen;
424
- if (exitFullScreen) {
425
- exitFullScreen.call(window.top.document);
426
- setIsFnllScreen(false);
427
- // getTableHeight();
428
- return;
429
- }
430
- }
431
- };
432
-
433
- const handleTimeValue = () => {
434
- let actionsRender = value.actionsRender || [];
435
- actionsRender = [
436
- ...actionsRender,
437
- {
438
- type: 'text',
439
- props: {
440
- children: (
441
- <span className="ant-dropdown-link">
442
- <Dropdown
443
- overlay={
444
- <Menu>
445
- <Menu.Item>
446
- <div
447
- onClick={sortTableRef?.current?.showModal}
448
- style={{ fontSize: 14, textAlign: 'center' }}
449
- >
450
- 列设置
451
- </div>
452
- </Menu.Item>
453
- <Menu.Item>
454
- <SearchItemTable
455
- ref={searchTableRef}
456
- setShowSearchFields={setShowSearchFields}
457
- showSearchFields={showSearchFields}
458
- datasource={value?.fields || []}
459
- bsTableCode={bsTableCode}
460
- />
461
- </Menu.Item>
462
- {value?.exportConfig?.settingColumns && (
463
- <Menu.Item>
464
- <div
465
- onClick={exportTableRef?.current?.showModal}
466
- style={{ fontSize: 14, textAlign: 'center' }}
467
- >
468
- 导出字段设置
469
- </div>
470
- </Menu.Item>
471
- )}
472
- </Menu>
473
- }
474
- placement="bottomRight"
475
- >
476
- <span className="ant-dropdown-link">
477
- <img width={32} src={shezhi} />
478
- </span>
479
- </Dropdown>
480
- </span>
481
- ),
482
- },
483
- },
484
- {
485
- type: 'text',
486
- props: {
487
- children: (
488
- <a>
489
- {isFullScreen ? (
490
- <Tooltip title="取消全屏">
491
- <img
492
- onClick={() => {
493
- ShowFullScreen();
494
- }}
495
- width={32}
496
- src={scanning}
497
- />
498
- </Tooltip>
499
- ) : (
500
- <Tooltip title="全屏">
501
- <img
502
- onClick={() => {
503
- ShowFullScreen();
504
- }}
505
- width={32}
506
- src={quanping}
507
- />
508
- </Tooltip>
509
- )}
510
- </a>
511
- ),
512
- },
513
- },
514
- {
515
- type: 'text',
516
- props: {
517
- children:
518
- value?.exportConfig && authFn(value?.exportConfig?.code) ? (
519
- <ExportIcon
520
- request={{
521
- url:
522
- value?.exportConfig?.url ||
523
- `/oms-ops/excel/exportAsync/${value?.exportConfig?.type}`,
524
- params: value?.exportConfig?.params,
525
- }}
526
- tableRef={props.forwardedRef || refs}
527
- allowSelect={value?.exportConfig?.allowSelect}
528
- columnsRowKey={value?.rowKey}
529
- />
530
- ) : (
531
- <span />
532
- ),
533
- },
534
- },
535
- ];
536
- if (value.rowSelection) {
537
- value.rowSelection.columnWidth = 50;
538
- }
539
- return {
540
- ...value,
541
- actionsRender,
542
- };
543
- };
544
-
545
- const handleResize =
546
- (index) =>
547
- (e, { size }) => {
548
- setShowColumns((columns: any) => {
549
- let newColumns = [...columns];
550
- newColumns[index] = {
551
- ...newColumns[index],
552
- width: size.width,
553
- };
554
- newColumns.forEach((d: any) => {
555
- handleBssulaColumnsSpecialParams(d);
556
- });
557
- return [...newColumns];
558
- });
559
- };
560
-
561
- const setVisibleColumn = (columnTitle: string) => {
562
- sortTableRef?.current?.handleTableHeadHidden?.(columnTitle);
563
- };
564
- const toMapByKey = (
565
- arr: any[],
566
- key: string,
567
- fn?: (item: any, index: number) => any,
568
- ) => {
569
- const map = {};
570
- arr.forEach((i: any) => (map[renderToString(i[key])] = i));
571
- return map;
572
- };
573
- const getColumns = () => {
574
- // 优化一下 减少复杂度
575
- const titleMap = toMapByKey(value.columns, 'title');
576
- // 加上排序
577
- const cols = showColumn.map((i) => ({
578
- ...i,
579
- isPermissionColumn: titleMap[renderToString(i.title)]?.isPermissionColumn,
580
- render: titleMap[renderToString(i.title)]?.render,
581
- }));
582
- cols.forEach((i) => handleBssulaColumnsSpecialParams(i));
583
- return cols;
584
- };
585
-
586
- const config = {
587
- visibleFieldsCount: 3,
588
- tableWrapperStyle: {
589
- padding: '10px',
590
- background: '#f3f3f3',
591
- },
592
- setVisibleColumn: setVisibleColumn,
593
- itemLayout: {
594
- span: 8, // 栅格占位格数
595
- labelCol: {
596
- // label标签布局;可设置 span、offset
597
- span: 8,
598
- },
599
- wrapperCol: {
600
- // value布局, 方式同labelCol(horizontal状态下配置)
601
- span: 16,
602
- },
603
- },
604
- rowSelection: false, // 默认无多选
605
- ...handleTimeValue(),
606
- tableProps: setTableProps(),
607
- columns: getColumns(),
608
- fields: [...showSearchFields],
609
- ref: props.forwardedRef || refs,
610
- isFullScreen,
611
- };
612
-
613
- useEffect(() => {
614
- if (!localStorage.getItem('isTabChange') || state?.updateCurrentPage) {
615
- if (pagePath === pathname) {
616
- // @ts-ignore
617
- config.ref?.current?.tableRef?.current?.refreshTable();
618
- }
619
- }
620
- setTimeout(() => {
621
- // 处理页面刷新两面
622
- localStorage.removeItem('isTabChange');
623
- }, 0);
624
- }, [pathname]);
625
-
626
- const expandedRowKeys = props?.expandable?.expandedRowKeys;
627
-
628
- //todo summary属性已经被使用,为了兼容之前的,现在使用 summaryList
629
- //结构为了实现多行总结栏 定义如下(lableShow: boolean 是否显示列文本)
630
- /**
631
- * [
632
- * {
633
- * cont:[{key: 'spuCode',value: 100,labelShow: false}]
634
- * }
635
- * ]
636
- * @returns []
637
- */
638
- const getTableSummaryInfo = () => {
639
- const { summaryList, rowSelection,expandable }: any = props;
640
- if (summaryList && Array.isArray(summaryList)) {
641
- const summaryRow = (rowSelection) ? [{}, ...showColumn] : [...showColumn];
642
- if(expandable){
643
- summaryRow.unshift({});
644
- }
645
- // let summaryInitial = summary().cont;
646
- return (
647
- <Table.Summary fixed>
648
- {Array.isArray(summaryList) &&
649
- summaryList.map((summaryItem, summaryIndex) => (
650
- <Table.Summary.Row key={summaryIndex}>
651
- {summaryRow.map((item: any, index: number) => {
652
- const { cout = [] } = summaryItem;
653
- const target = cout.filter(
654
- (inner: any) =>
655
- inner.key &&
656
- (inner.key === item.dataIndex || inner.key === item.key),
657
- )[0];
658
- if (target) {
659
- const labelText = target.labelShow ? `${item.title}:` :``;
660
- return (
661
- <Table.Summary.Cell
662
- index={index}
663
- key={`Table.Summary.Cell_${item.index}`}
664
- >
665
- <Text type="danger">
666
- {`${labelText} ${target.value ?? ''}`}
667
- </Text>
668
- </Table.Summary.Cell>
669
- );
670
- } else {
671
- return (
672
- <Table.Summary.Cell
673
- index={index}
674
- key={`Table.Summary.Cell_${item.index}`}
675
- >
676
- <Text type="danger">{` `}</Text>
677
- </Table.Summary.Cell>
678
- );
679
- }
680
- })}
681
- </Table.Summary.Row>
682
- ))}
683
- </Table.Summary>
684
- );
685
- } else {
686
- return undefined;
687
- }
688
- };
689
-
690
- const memoConfig = useMemo(
691
- () => ({
692
- ...config,
693
- summary: props.summary,
694
- summaryList: props.summaryList ? getTableSummaryInfo : undefined,
695
- statusMapping: props.statusMapping,
696
- }),
697
- [
698
- // value,
699
- checkedList,
700
- showColumn,
701
- props.statusMapping,
702
- showSearchFields,
703
- expandedRowKeys,
704
- ],
705
- );
706
- return (
707
- <div id="bs-sula-query-table">
708
- <MemoQueryTable {...memoConfig} />
709
- <SortableTable
710
- ref={sortTableRef}
711
- setShowColumns={setShowColumns}
712
- showColumn={showColumn}
713
- datasource={value?.columns || []}
714
- bsTableCode={bsTableCode}
715
- onlyModal
716
- />
717
- {value?.exportConfig?.settingColumns && (
718
- <SortableTable
719
- ref={exportTableRef}
720
- setShowColumns={setShowExportColumns}
721
- showColumn={showExportColumn}
722
- datasource={value?.columns || []}
723
- bsTableCode={bsTableCodeExport}
724
- onlyModal
725
- />
726
- )}
727
- </div>
728
- );
729
- };
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
+ renderToString,
11
+ } from './utils';
12
+ import { Menu, Tooltip, Dropdown, Table, Typography } from 'antd';
13
+ import SortableTable from './setting';
14
+ import SearchItemTable from './SearchItemSetting';
15
+ import { Resizable } from 'react-resizable';
16
+ import quanping from '../../../assets/icon-quanping.svg';
17
+ import scanning from '../../../assets/scanning.svg';
18
+ import shezhi from '../../../assets/icon-shezhi.svg';
19
+ import { debounce } from 'lodash';
20
+ import ExportIcon from '@/components/Functional/ExportFunctions/ExportIcon';
21
+ import ENUM from '@/utils/enumConfig';
22
+ import { handleBssulaColumnsSpecialParams } from '@/utils/utils';
23
+ import './bssulaquerytable.less';
24
+ const MemoQueryTable = React.memo(QueryTable);
25
+ const { Text } = Typography;
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 { isPage = true, pagination, tableCode } = props;
47
+ const refs = useRef(null);
48
+ const [pagePath, setPagePath] = useState('');
49
+ // 获取 table columns中所有的 key 防止有的地方是 dataindex
50
+ const checkedList = props.columns
51
+ .filter((col: any) => !col.hidden)
52
+ .map((d: any) =>
53
+ Array.isArray(d.key || d.dataIndex)
54
+ ? JSON.stringify(d.key || d.dataIndex)
55
+ : d.key || d.dataIndex,
56
+ );
57
+
58
+ const { pathname, state = {} } = useLocation();
59
+ const [isFullScreen, setIsFnllScreen]: any = useState(false);
60
+ // @ts-nocheck
61
+ const value = props;
62
+ const [showColumn, setShowColumns] = useState([]); // 列字段
63
+ const [showSearchFields, setShowSearchFields] = useState(props.fields || []); //搜索项字段
64
+ const [showExportColumn, setShowExportColumns] = useState([]); // 导出列字段
65
+
66
+ const [height, setHeight]: any = useState('100vh');
67
+ const sortTableRef = useRef(null);
68
+ const searchTableRef = useRef(null);
69
+ const exportTableRef = useRef<any>(null);
70
+
71
+ const bsTableCode = tableCode || window.location.hash; //设置列字段的唯一标识
72
+ const bsTableCodeExport = `${bsTableCode}___Export`; //设置导出列字段的唯一标识
73
+ // 获取table高度
74
+ const getTableHeight = () => {
75
+ setTimeout(() => {
76
+ const cancelHeight = window.top == window ? 303 : 223;
77
+ const isFullScreen: any =
78
+ window.top.document.fullScreen ||
79
+ window.top.document.webkitIsFullScreen ||
80
+ window.top.document.mozFullScreen;
81
+
82
+ // wujie子应用iframe首次加载获取不到client以及dom元素高度兼容处理
83
+ let realIframeClientHeight = document.body.clientHeight
84
+ ? document.body.clientHeight
85
+ : window.top?.document.body.clientHeight - 76;
86
+ let summaryHeight = document.querySelector(
87
+ `.ant-tabs-tabpane-active .table-bssula-summary`,
88
+ )
89
+ ? document.querySelector(
90
+ `.ant-tabs-tabpane-active .table-bssula-summary`,
91
+ )?.clientHeight || 22
92
+ : 0;
93
+ let listTabHeight = document.querySelector(
94
+ `.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`,
95
+ )
96
+ ? document.querySelector(
97
+ `.ant-tabs-tabpane-active .list_top_tab .ant-tabs-nav`,
98
+ )?.clientHeight || 48
99
+ : 0;
100
+
101
+ const h =
102
+ realIframeClientHeight -
103
+ summaryHeight -
104
+ listTabHeight -
105
+ (document.querySelector(
106
+ `.ant-tabs-tabpane-active .ant-form ant-form-horizontal`,
107
+ )?.clientHeight || 0) -
108
+ (isFullScreen
109
+ ? 0
110
+ : document.querySelector(
111
+ `.ant-tabs-tabpane-active .ant-pro-page-container-warp`,
112
+ )?.clientHeight || 0) -
113
+ cancelHeight +
114
+ 'px';
115
+ setHeight(h);
116
+ }, 0);
117
+ };
118
+
119
+ //监测是否按下esc键
120
+ function checkFull() {
121
+ let globalDocument = window?.parent?.document || document;
122
+ var isFull =
123
+ globalDocument.fullscreenElement ||
124
+ globalDocument.mozFullScreenElement ||
125
+ globalDocument.webkitFullscreenElement;
126
+ if (isFull == undefined) isFull = false;
127
+ return isFull;
128
+ }
129
+
130
+ const getConfigFromlocalstorage = (
131
+ type: string,
132
+ tableCode: string = bsTableCode,
133
+ ) => {
134
+ let config = localStorage.getItem(type) || '[]';
135
+ let configArray = JSON.parse(config);
136
+ let configSetting = configArray.filter((item) => item.code === tableCode);
137
+
138
+ if (configSetting.length && configSetting[0].detail) {
139
+ return JSON.parse(configSetting[0].detail);
140
+ }
141
+ return [];
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(
174
+ ENUM.BROWSER_CACHE.MAIN_AUTH_CODES,
175
+ )
176
+ ? JSON.parse(
177
+ localStorage.getItem(ENUM.BROWSER_CACHE.MAIN_AUTH_CODES) as string,
178
+ )
179
+ : [];
180
+ Object.keys(resourceCodeArray).forEach((item: any) => {
181
+ let Item = item;
182
+ if (Number(item.slice(-1)) >= 1) {
183
+ Item = item.substr(0, item.length - 1);
184
+ }
185
+ if (!authButton.filter((itemInner: any) => Item === itemInner).length) {
186
+ resourceCodeArray[item].visible = false;
187
+ }
188
+ });
189
+ }
190
+ const { columns, exportColumns } = props;
191
+
192
+ const getShowColumns = (columnConfig: any, columns: any) => {
193
+ return columnConfig.length
194
+ ? columnConfig.map((item) => {
195
+ let inner = columns.filter((inneritem) => {
196
+ let innerKey = Array.isArray(inneritem.key || inneritem.dataIndex)
197
+ ? JSON.stringify(inneritem.key || inneritem.dataIndex)
198
+ : inneritem.key || inneritem.dataIndex;
199
+ let itemKey = Array.isArray(item.key || item.dataIndex)
200
+ ? JSON.stringify(item.key || item.dataIndex)
201
+ : item.key || item.dataIndex;
202
+ return innerKey && innerKey === itemKey;
203
+ })[0];
204
+
205
+ return {
206
+ ...inner,
207
+ ...item,
208
+ };
209
+ })
210
+ : columns.filter((column) => {
211
+ let columnKey = Array.isArray(column.key || column.dataIndex)
212
+ ? JSON.stringify(column.key || column.dataIndex)
213
+ : column.key || column.dataIndex;
214
+ return (
215
+ column.notRegularCheckList || checkedList.indexOf(columnKey) > -1
216
+ );
217
+ });
218
+ };
219
+
220
+ let columnConfig = getConfigFromlocalstorage(
221
+ ENUM.BROWSER_CACHE.COLUMN_CONDITION,
222
+ );
223
+ let showColumns = getShowColumns(columnConfig, columns);
224
+
225
+ showColumns.forEach((item, index) => {
226
+ item.width = item.width || getItemDefaultWidth(item);
227
+ handleBssulaColumnsSpecialParams(item);
228
+ item.onHeaderCell = (column) => ({
229
+ ...item,
230
+ width:
231
+ typeof column.width === 'number'
232
+ ? column.width
233
+ : parseInt(column.width.replace('px', '')),
234
+ onResize: handleResize(index),
235
+ });
236
+ });
237
+ setShowColumns([...showColumns]);
238
+
239
+ let exportColumnConfig = getConfigFromlocalstorage(
240
+ ENUM.BROWSER_CACHE.COLUMN_CONDITION,
241
+ bsTableCodeExport,
242
+ );
243
+ let showExportColumns = getShowColumns(exportColumnConfig, columns);
244
+
245
+ showExportColumns.forEach((item, index) => {
246
+ item.width = item.width || getItemDefaultWidth(item);
247
+ handleBssulaColumnsSpecialParams(item);
248
+ item.onHeaderCell = (column) => ({
249
+ ...item,
250
+ width:
251
+ typeof column.width === 'number'
252
+ ? column.width
253
+ : parseInt(column.width.replace('px', '')),
254
+ onResize: handleResize(index),
255
+ });
256
+ });
257
+ setShowExportColumns([...showExportColumns]);
258
+ };
259
+
260
+ const setInitialSearchFieldsInfo = () => {
261
+ //获取搜索字段的缓存配置
262
+ const { fields = [] } = props;
263
+ let searchFieldsConfig = getConfigFromlocalstorage(
264
+ ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION,
265
+ );
266
+ let showSearchFields = searchFieldsConfig.length
267
+ ? searchFieldsConfig.map((item) => {
268
+ let inner = fields.filter((inneritem) => {
269
+ let innerKey = Array.isArray(inneritem.name)
270
+ ? JSON.stringify(inneritem.name)
271
+ : inneritem.name;
272
+ let itemKey = Array.isArray(item.name)
273
+ ? JSON.stringify(item.name)
274
+ : item.name;
275
+ return innerKey && innerKey === itemKey;
276
+ })[0];
277
+
278
+ return {
279
+ ...inner,
280
+ ...item,
281
+ };
282
+ })
283
+ : fields;
284
+ setShowSearchFields([...showSearchFields]);
285
+ };
286
+
287
+ //组件初始挂载
288
+ useEffect(() => {
289
+ getTableHeight();
290
+ setInitialTableInfo();
291
+ setInitialSearchFieldsInfo();
292
+ window.addEventListener('resize', (e) => {
293
+ watchWinResize();
294
+ });
295
+
296
+ setPagePath(pathname); // 做处理,记录当前页面渲染的初始pathname,用于进行判断当前列表页面数据是否需要重新渲染
297
+ }, []);
298
+
299
+ useEffect(() => {
300
+ if (props?.columns && value?.columns) {
301
+ let newKeys = props.columns.map((d: any) =>
302
+ Array.isArray(d.key || d.dataIndex)
303
+ ? JSON.stringify(d.key || d.dataIndex)
304
+ : d.key || d.dataIndex,
305
+ );
306
+ let oldKeys = value.columns.map((d: any) =>
307
+ Array.isArray(d.key || d.dataIndex)
308
+ ? JSON.stringify(d.key || d.dataIndex)
309
+ : d.key || d.dataIndex,
310
+ );
311
+ JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
312
+ setInitialTableInfo();
313
+ }
314
+ }, [props?.columns]);
315
+
316
+ useEffect(() => {
317
+ if (props?.fields && value?.fields) {
318
+ let newKeys = props.fields.map((d: any) =>
319
+ Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
320
+ );
321
+ let oldKeys = value.fields.map((d: any) =>
322
+ Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
323
+ );
324
+ JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
325
+ setInitialSearchFieldsInfo();
326
+ }
327
+ }, [props?.fields]);
328
+
329
+ useEffect(() => {
330
+ setInitialTableInfo();
331
+ }, [props?.refreshColumns]);
332
+
333
+ const watchWinResize = debounce(() => {
334
+ getTableHeight();
335
+ if (!checkFull()) {
336
+ // addTabsNavStyle(true);
337
+ // 全屏下按键esc后要执行的动作
338
+ // isFullScreen 为true 此时为全屏状态 false 为非全屏状态
339
+ if (!isFullScreen) {
340
+ // 按下esc键退出全屏
341
+ setIsFnllScreen(false);
342
+ } else {
343
+ setIsFnllScreen(false);
344
+ }
345
+ }
346
+ }, 10);
347
+
348
+ const setCommonRenderFn = (columns: any[]) => {
349
+ columns.forEach((column) => {
350
+ if (column.showDetailUserInfo) {
351
+ column.render = ({ text }: any) => userColumns({ name: text });
352
+ }
353
+ });
354
+ };
355
+
356
+ // 处理 table 基本参数
357
+ const setTableProps = () => {
358
+ let tableProps = value.tableProps || {};
359
+ tableProps = {
360
+ ...tableProps,
361
+ size: value.size || 'middle',
362
+ defaultPageSize: 20,
363
+ pageSize: 20,
364
+ initialPaging: {
365
+ pagination: pagination
366
+ ? false
367
+ : {
368
+ defaultPageSize: 20,
369
+ pageSize: 20,
370
+ showTotal: (total: any) => `共 ${total} 条`,
371
+ showQuickJumper: true,
372
+ hideOnSinglePage: value.hideOnSinglePage || false,
373
+ },
374
+ },
375
+ initialSelectedRowKeys: value.initialSelectedRowKeys || [],
376
+ expandable: props.expandable,
377
+ scroll: { x: props.overScrollX || 'max-content', y: height },
378
+ bordered: value.bordered || false,
379
+ sticky: true,
380
+ rowClassName: (record: object | null | undefined, index: number) =>
381
+ index % 2 === 0 ? 'table_base' : 'table_odd',
382
+ ...value.tableProps,
383
+ components: {
384
+ header: {
385
+ cell: ResizeableTitle,
386
+ },
387
+ },
388
+ };
389
+
390
+ // @ts-ignore
391
+ if (tableProps?.initialPaging?.pagination) {
392
+ // @ts-ignore
393
+ tableProps.initialPaging.pagination.showSizeChanger = true;
394
+ }
395
+ return tableProps;
396
+ };
397
+
398
+ const ShowFullScreen = () => {
399
+ const isFullScreen: any =
400
+ window.top.document.fullScreen ||
401
+ window.top.document.webkitIsFullScreen ||
402
+ window.top.document.mozFullScreen;
403
+ let contentEle: any = window.top.document.querySelector(`body`);
404
+ // addTabsNavStyle(isFullScreen);
405
+ if (contentEle && !isFullScreen) {
406
+ let fullScreenEle =
407
+ contentEle.requestFullscreen ||
408
+ contentEle.mozRequestFullScreen ||
409
+ contentEle.webkitRequestFullScreen ||
410
+ contentEle.msRequestFullscreen;
411
+ if (fullScreenEle) {
412
+ fullScreenEle.call(contentEle);
413
+ setIsFnllScreen(true);
414
+ // getTableHeight(true);
415
+ return;
416
+ }
417
+ }
418
+ if (window.top.document && isFullScreen) {
419
+ let exitFullScreen =
420
+ window.top.document.exitFullscreen ||
421
+ window.top.document.mozCancelFullScreen ||
422
+ window.top.document.webkitCancelFullScreen ||
423
+ window.top.document.msExitFullscreen;
424
+ if (exitFullScreen) {
425
+ exitFullScreen.call(window.top.document);
426
+ setIsFnllScreen(false);
427
+ // getTableHeight();
428
+ return;
429
+ }
430
+ }
431
+ };
432
+
433
+ const handleTimeValue = () => {
434
+ let actionsRender = value.actionsRender || [];
435
+ actionsRender = [
436
+ ...actionsRender,
437
+ {
438
+ type: 'text',
439
+ props: {
440
+ children: (
441
+ <span className="ant-dropdown-link">
442
+ <Dropdown
443
+ overlay={
444
+ <Menu>
445
+ <Menu.Item>
446
+ <div
447
+ onClick={sortTableRef?.current?.showModal}
448
+ style={{ fontSize: 14, textAlign: 'center' }}
449
+ >
450
+ 列设置
451
+ </div>
452
+ </Menu.Item>
453
+ <Menu.Item>
454
+ <SearchItemTable
455
+ ref={searchTableRef}
456
+ setShowSearchFields={setShowSearchFields}
457
+ showSearchFields={showSearchFields}
458
+ datasource={value?.fields || []}
459
+ bsTableCode={bsTableCode}
460
+ />
461
+ </Menu.Item>
462
+ {value?.exportConfig?.settingColumns && (
463
+ <Menu.Item>
464
+ <div
465
+ onClick={exportTableRef?.current?.showModal}
466
+ style={{ fontSize: 14, textAlign: 'center' }}
467
+ >
468
+ 导出字段设置
469
+ </div>
470
+ </Menu.Item>
471
+ )}
472
+ </Menu>
473
+ }
474
+ placement="bottomRight"
475
+ >
476
+ <span className="ant-dropdown-link">
477
+ <img width={32} src={shezhi} />
478
+ </span>
479
+ </Dropdown>
480
+ </span>
481
+ ),
482
+ },
483
+ },
484
+ {
485
+ type: 'text',
486
+ props: {
487
+ children: (
488
+ <a>
489
+ {isFullScreen ? (
490
+ <Tooltip title="取消全屏">
491
+ <img
492
+ onClick={() => {
493
+ ShowFullScreen();
494
+ }}
495
+ width={32}
496
+ src={scanning}
497
+ />
498
+ </Tooltip>
499
+ ) : (
500
+ <Tooltip title="全屏">
501
+ <img
502
+ onClick={() => {
503
+ ShowFullScreen();
504
+ }}
505
+ width={32}
506
+ src={quanping}
507
+ />
508
+ </Tooltip>
509
+ )}
510
+ </a>
511
+ ),
512
+ },
513
+ },
514
+ {
515
+ type: 'text',
516
+ props: {
517
+ children:
518
+ value?.exportConfig && authFn(value?.exportConfig?.code) ? (
519
+ <ExportIcon
520
+ request={{
521
+ url:
522
+ value?.exportConfig?.url ||
523
+ `/oms-ops/excel/exportAsync/${value?.exportConfig?.type}`,
524
+ params: value?.exportConfig?.params,
525
+ }}
526
+ tableRef={props.forwardedRef || refs}
527
+ allowSelect={value?.exportConfig?.allowSelect}
528
+ columnsRowKey={value?.rowKey}
529
+ />
530
+ ) : (
531
+ <span />
532
+ ),
533
+ },
534
+ },
535
+ ];
536
+ if (value.rowSelection) {
537
+ value.rowSelection.columnWidth = 50;
538
+ }
539
+ return {
540
+ ...value,
541
+ actionsRender,
542
+ };
543
+ };
544
+
545
+ const handleResize =
546
+ (index) =>
547
+ (e, { size }) => {
548
+ setShowColumns((columns: any) => {
549
+ let newColumns = [...columns];
550
+ newColumns[index] = {
551
+ ...newColumns[index],
552
+ width: size.width,
553
+ };
554
+ newColumns.forEach((d: any) => {
555
+ handleBssulaColumnsSpecialParams(d);
556
+ });
557
+ return [...newColumns];
558
+ });
559
+ };
560
+
561
+ const setVisibleColumn = (columnTitle: string) => {
562
+ sortTableRef?.current?.handleTableHeadHidden?.(columnTitle);
563
+ };
564
+ const toMapByKey = (
565
+ arr: any[],
566
+ key: string,
567
+ fn?: (item: any, index: number) => any,
568
+ ) => {
569
+ const map = {};
570
+ arr.forEach((i: any) => (map[renderToString(i[key])] = i));
571
+ return map;
572
+ };
573
+ const getColumns = () => {
574
+ // 优化一下 减少复杂度
575
+ const titleMap = toMapByKey(value.columns, 'title');
576
+ // 加上排序
577
+ const cols = showColumn.map((i) => ({
578
+ ...i,
579
+ isPermissionColumn: titleMap[renderToString(i.title)]?.isPermissionColumn,
580
+ render: titleMap[renderToString(i.title)]?.render,
581
+ }));
582
+ cols.forEach((i) => handleBssulaColumnsSpecialParams(i));
583
+ return cols;
584
+ };
585
+
586
+ const config = {
587
+ visibleFieldsCount: 3,
588
+ tableWrapperStyle: {
589
+ padding: '10px',
590
+ background: '#f3f3f3',
591
+ },
592
+ setVisibleColumn: setVisibleColumn,
593
+ itemLayout: {
594
+ span: 8, // 栅格占位格数
595
+ labelCol: {
596
+ // label标签布局;可设置 span、offset
597
+ span: 8,
598
+ },
599
+ wrapperCol: {
600
+ // value布局, 方式同labelCol(horizontal状态下配置)
601
+ span: 16,
602
+ },
603
+ },
604
+ rowSelection: false, // 默认无多选
605
+ ...handleTimeValue(),
606
+ tableProps: setTableProps(),
607
+ columns: getColumns(),
608
+ fields: [...showSearchFields],
609
+ ref: props.forwardedRef || refs,
610
+ isFullScreen,
611
+ };
612
+
613
+ useEffect(() => {
614
+ if (!localStorage.getItem('isTabChange') || state?.updateCurrentPage) {
615
+ if (pagePath === pathname) {
616
+ // @ts-ignore
617
+ config.ref?.current?.tableRef?.current?.refreshTable();
618
+ }
619
+ }
620
+ setTimeout(() => {
621
+ // 处理页面刷新两面
622
+ localStorage.removeItem('isTabChange');
623
+ }, 0);
624
+ }, [pathname]);
625
+
626
+ const expandedRowKeys = props?.expandable?.expandedRowKeys;
627
+
628
+ //todo summary属性已经被使用,为了兼容之前的,现在使用 summaryList
629
+ //结构为了实现多行总结栏 定义如下(lableShow: boolean 是否显示列文本)
630
+ /**
631
+ * [
632
+ * {
633
+ * cont:[{key: 'spuCode',value: 100,labelShow: false}]
634
+ * }
635
+ * ]
636
+ * @returns []
637
+ */
638
+ const getTableSummaryInfo = () => {
639
+ const { summaryList, rowSelection,expandable }: any = props;
640
+ if (summaryList && Array.isArray(summaryList)) {
641
+ const summaryRow = (rowSelection) ? [{}, ...showColumn] : [...showColumn];
642
+ if(expandable){
643
+ summaryRow.unshift({});
644
+ }
645
+ // let summaryInitial = summary().cont;
646
+ return (
647
+ <Table.Summary fixed>
648
+ {Array.isArray(summaryList) &&
649
+ summaryList.map((summaryItem, summaryIndex) => (
650
+ <Table.Summary.Row key={summaryIndex}>
651
+ {summaryRow.map((item: any, index: number) => {
652
+ const { cout = [] } = summaryItem;
653
+ const target = cout.filter(
654
+ (inner: any) =>
655
+ inner.key &&
656
+ (inner.key === item.dataIndex || inner.key === item.key),
657
+ )[0];
658
+ if (target) {
659
+ const labelText = target.labelShow ? `${item.title}:` :``;
660
+ return (
661
+ <Table.Summary.Cell
662
+ index={index}
663
+ key={`Table.Summary.Cell_${item.index}`}
664
+ >
665
+ <Text type="danger">
666
+ {`${labelText} ${target.value ?? ''}`}
667
+ </Text>
668
+ </Table.Summary.Cell>
669
+ );
670
+ } else {
671
+ return (
672
+ <Table.Summary.Cell
673
+ index={index}
674
+ key={`Table.Summary.Cell_${item.index}`}
675
+ >
676
+ <Text type="danger">{` `}</Text>
677
+ </Table.Summary.Cell>
678
+ );
679
+ }
680
+ })}
681
+ </Table.Summary.Row>
682
+ ))}
683
+ </Table.Summary>
684
+ );
685
+ } else {
686
+ return undefined;
687
+ }
688
+ };
689
+
690
+ const memoConfig = useMemo(
691
+ () => ({
692
+ ...config,
693
+ summary: props.summary,
694
+ summaryList: props.summaryList ? getTableSummaryInfo : undefined,
695
+ statusMapping: props.statusMapping,
696
+ }),
697
+ [
698
+ // value,
699
+ checkedList,
700
+ showColumn,
701
+ props.statusMapping,
702
+ showSearchFields,
703
+ expandedRowKeys,
704
+ ],
705
+ );
706
+ return (
707
+ <div id="bs-sula-query-table">
708
+ <MemoQueryTable {...memoConfig} />
709
+ <SortableTable
710
+ ref={sortTableRef}
711
+ setShowColumns={setShowColumns}
712
+ showColumn={showColumn}
713
+ datasource={value?.columns || []}
714
+ bsTableCode={bsTableCode}
715
+ onlyModal
716
+ />
717
+ {value?.exportConfig?.settingColumns && (
718
+ <SortableTable
719
+ ref={exportTableRef}
720
+ setShowColumns={setShowExportColumns}
721
+ showColumn={showExportColumn}
722
+ datasource={value?.columns || []}
723
+ bsTableCode={bsTableCodeExport}
724
+ onlyModal
725
+ />
726
+ )}
727
+ </div>
728
+ );
729
+ };