@bit-sun/business-component 3.1.5 → 3.1.7

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