@bit-sun/business-component 3.1.10-alpha.1 → 3.1.10-alpha.11

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 (223) hide show
  1. package/.editorconfig +16 -16
  2. package/.fatherrc.ts +5 -5
  3. package/.gitlab-ci.yml +179 -179
  4. package/.prettierignore +7 -7
  5. package/.prettierrc +11 -11
  6. package/.umirc.ts +74 -74
  7. package/README.md +27 -27
  8. package/dist/components/Functional/AddSelect/index.d.ts +1 -1
  9. package/dist/index.esm.js +485 -205
  10. package/dist/index.js +486 -206
  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 +568 -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 +767 -767
  79. package/src/components/Business/BsSulaQueryTable/setting.tsx +890 -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 +2326 -2318
  123. package/src/components/Business/SearchSelect/common.ts +134 -134
  124. package/src/components/Business/SearchSelect/index.md +1570 -1570
  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 +239 -239
  131. package/src/components/Business/TreeSearchSelect/index.tsx +33 -33
  132. package/src/components/Business/TreeSearchSelect/utils.ts +115 -115
  133. package/src/components/Business/columnSettingTable/columnSetting.tsx +818 -816
  134. package/src/components/Business/columnSettingTable/index.less +253 -253
  135. package/src/components/Business/columnSettingTable/index.md +372 -372
  136. package/src/components/Business/columnSettingTable/index.tsx +225 -225
  137. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +232 -232
  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 +1088 -1072
  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 +771 -771
  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 +782 -782
  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 -788
  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 +1050 -1046
  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/CustomPlugin/CustomSelector/CustomSelectorModal.tsx +358 -358
  178. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/function.js +255 -255
  179. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.tsx +57 -57
  180. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.tsx +129 -129
  181. package/src/components/Solution/RuleComponent/Formula.tsx +335 -335
  182. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -62
  183. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +774 -774
  184. package/src/components/Solution/RuleComponent/index.d.ts +34 -29
  185. package/src/components/Solution/RuleComponent/index.js +1680 -1663
  186. package/src/components/Solution/RuleComponent/index.less +247 -247
  187. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -99
  188. package/src/components/Solution/RuleComponent/ruleFiled.js +2695 -2695
  189. package/src/components/Solution/RuleComponent/services.ts +13 -13
  190. package/src/components/Solution/RuleComponent/util.js +143 -143
  191. package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -6
  192. package/src/components/Solution/RuleSetter/baseRule.tsx +414 -414
  193. package/src/components/Solution/RuleSetter/function.ts +467 -467
  194. package/src/components/Solution/RuleSetter/index.less +221 -221
  195. package/src/components/Solution/RuleSetter/index.tsx +210 -210
  196. package/src/components/Solution/RuleSetter/service.js +276 -276
  197. package/src/index.ts +42 -42
  198. package/src/plugin/TableColumnSetting/index.less +247 -247
  199. package/src/plugin/TableColumnSetting/index.md +50 -50
  200. package/src/plugin/TableColumnSetting/index.tsx +725 -725
  201. package/src/plugin/TableColumnSetting/utils.ts +19 -19
  202. package/src/styles/bsDefault.less +1933 -1933
  203. package/src/utils/CheckOneUser/index.md +39 -39
  204. package/src/utils/CheckOneUser/index.ts +51 -51
  205. package/src/utils/CustomLoginInfo.ts +55 -55
  206. package/src/utils/LocalstorageUtils.ts +134 -134
  207. package/src/utils/TableUtils.less +51 -51
  208. package/src/utils/TableUtils.tsx +691 -691
  209. package/src/utils/TreeUtils.ts +12 -12
  210. package/src/utils/auth.ts +38 -38
  211. package/src/utils/businessUtils.ts +434 -434
  212. package/src/utils/checkUtils.ts +39 -39
  213. package/src/utils/constant.ts +38 -38
  214. package/src/utils/enumConfig.ts +17 -17
  215. package/src/utils/getFormMode.js +12 -12
  216. package/src/utils/index.ts +21 -21
  217. package/src/utils/request.ts +53 -53
  218. package/src/utils/requestUtils.ts +197 -197
  219. package/src/utils/serialize.js +7 -7
  220. package/src/utils/utils.ts +266 -266
  221. package/src/utils/xlsxUtil.tsx +145 -145
  222. package/tsconfig.json +29 -29
  223. package/typings.d.ts +4 -4
@@ -1,767 +1,767 @@
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, parseWidth } 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('');
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
- let showColumns = getSettingFieldOrColumn(columnConfig, columns, 'columns');
269
-
270
- showColumns.forEach((item, index) => {
271
- item.width = item.width || getItemDefaultWidth(item);
272
- handleBssulaColumnsSpecialParams(item);
273
- item.onHeaderCell = (column) => ({
274
- ...item,
275
- width: typeof column.width === 'number'
276
- ? column.width
277
- : parseWidth(column.width),
278
- onResize: handleResize(index),
279
- });
280
- });
281
- setShowColumns([...showColumns]);
282
-
283
- let exportColumnConfig = getConfigFromlocalstorage(
284
- ENUM.BROWSER_CACHE.COLUMN_CONDITION,
285
- bsTableCodeExport,
286
- );
287
- let showExportColumns = getSettingFieldOrColumn(exportColumnConfig, columns, 'columns');
288
-
289
- showExportColumns.forEach((item, index) => {
290
- item.width = item.width || getItemDefaultWidth(item);
291
- handleBssulaColumnsSpecialParams(item);
292
- item.onHeaderCell = (column) => ({
293
- ...item,
294
- width: typeof column.width === 'number'
295
- ? column.width
296
- : parseWidth(column.width),
297
- onResize: handleResize(index),
298
- });
299
- });
300
- setShowExportColumns([...showExportColumns]);
301
- };
302
-
303
- const setInitialSearchFieldsInfo = () => {
304
- //获取搜索字段的缓存配置
305
- const { fields = [] } = props;
306
- let searchFieldsConfig = getConfigFromlocalstorage(
307
- ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION,
308
- );
309
- const showSearchFields = getSettingFieldOrColumn(searchFieldsConfig, fields, 'searchFields');
310
- setShowSearchFields([...showSearchFields]);
311
- };
312
-
313
- //组件初始挂载
314
- useEffect(() => {
315
- // getTableHeight();
316
- setInitialTableInfo();
317
- setInitialSearchFieldsInfo();
318
- window.addEventListener('resize', (e) => {
319
- watchWinResize();
320
- });
321
-
322
- setPagePath(pathname); // 做处理,记录当前页面渲染的初始pathname,用于进行判断当前列表页面数据是否需要重新渲染
323
- }, []);
324
-
325
- useEffect(() => {
326
- if (props?.columns && value?.columns) {
327
- let newKeys = props.columns.map((d: any) =>
328
- Array.isArray(d.key || d.dataIndex)
329
- ? JSON.stringify(d.key || d.dataIndex)
330
- : d.key || d.dataIndex,
331
- );
332
- let oldKeys = value.columns.map((d: any) =>
333
- Array.isArray(d.key || d.dataIndex)
334
- ? JSON.stringify(d.key || d.dataIndex)
335
- : d.key || d.dataIndex,
336
- );
337
- JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
338
- setInitialTableInfo();
339
- }
340
- }, [props?.columns]);
341
-
342
- useEffect(() => {
343
- if (props?.fields && value?.fields) {
344
- let newKeys = props.fields.map((d: any) =>
345
- Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
346
- );
347
- let oldKeys = value.fields.map((d: any) =>
348
- Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
349
- );
350
- JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
351
- setInitialSearchFieldsInfo();
352
- }
353
- }, [props?.fields]);
354
-
355
- useEffect(() => {
356
- setInitialTableInfo();
357
- }, [props?.refreshColumns]);
358
-
359
- const watchWinResize = debounce(() => {
360
- getTableHeight();
361
- if (!checkFull()) {
362
- // addTabsNavStyle(true);
363
- // 全屏下按键esc后要执行的动作
364
- // isFullScreen 为true 此时为全屏状态 false 为非全屏状态
365
- if (!isFullScreen) {
366
- // 按下esc键退出全屏
367
- setIsFnllScreen(false);
368
- } else {
369
- setIsFnllScreen(false);
370
- }
371
- }
372
- }, 10);
373
-
374
- const setCommonRenderFn = (columns: any[]) => {
375
- columns.forEach((column) => {
376
- if (column.showDetailUserInfo) {
377
- column.render = ({ text }: any) => userColumns({ name: text });
378
- }
379
- });
380
- };
381
-
382
- // 处理 table 基本参数
383
- const setTableProps = () => {
384
- let tableProps = value.tableProps || {};
385
- tableProps = {
386
- ...tableProps,
387
- size: value.size || 'middle',
388
- defaultPageSize: 20,
389
- pageSize: 20,
390
- initialPaging: {
391
- pagination: props?.pagination
392
- ? false
393
- : {
394
- defaultPageSize: 20,
395
- pageSize: 20,
396
- showTotal: (total: any) => `共 ${total} 条`,
397
- showQuickJumper: true,
398
- hideOnSinglePage: value.hideOnSinglePage || false,
399
-
400
- ...tableProps?.initialPaging?.pagination
401
- },
402
- },
403
- initialSelectedRowKeys: value.initialSelectedRowKeys || [],
404
- expandable: props.expandable,
405
- scroll: { x: props.overScrollX || 'max-content', y: props?.overScrollY || height },
406
- bordered: value.bordered || false,
407
- sticky: true,
408
- rowClassName: (record: object | null | undefined, index: number) =>
409
- index % 2 === 0 ? 'table_base' : 'table_odd',
410
- components: {
411
- header: {
412
- cell: ResizeableTitle,
413
- },
414
- ...tableProps?.components,
415
- },
416
- };
417
-
418
- // @ts-ignore
419
- if (tableProps?.initialPaging?.pagination) {
420
- // @ts-ignore
421
- tableProps.initialPaging.pagination.showSizeChanger = true;
422
- }
423
- return tableProps;
424
- };
425
-
426
- const ShowFullScreen = () => {
427
- const isFullScreen: any =
428
- window.top.document.fullScreen ||
429
- window.top.document.webkitIsFullScreen ||
430
- window.top.document.mozFullScreen;
431
- let contentEle: any = window.top.document.querySelector(`body`);
432
- // addTabsNavStyle(isFullScreen);
433
- if (contentEle && !isFullScreen) {
434
- let fullScreenEle =
435
- contentEle.requestFullscreen ||
436
- contentEle.mozRequestFullScreen ||
437
- contentEle.webkitRequestFullScreen ||
438
- contentEle.msRequestFullscreen;
439
- if (fullScreenEle) {
440
- fullScreenEle.call(contentEle);
441
- setIsFnllScreen(true);
442
- // getTableHeight(true);
443
- return;
444
- }
445
- }
446
- if (window.top.document && isFullScreen) {
447
- let exitFullScreen =
448
- window.top.document.exitFullscreen ||
449
- window.top.document.mozCancelFullScreen ||
450
- window.top.document.webkitCancelFullScreen ||
451
- window.top.document.msExitFullscreen;
452
- if (exitFullScreen) {
453
- exitFullScreen.call(window.top.document);
454
- setIsFnllScreen(false);
455
- // getTableHeight();
456
- return;
457
- }
458
- }
459
- };
460
-
461
- const handleTimeValue = () => {
462
-
463
-
464
- let actionsRender = (value.actionsRender ?? []).map((x) => ({
465
- ...x,
466
- position: x.position ?? 'left',
467
- })).filter((x) => authFn(x?.code));
468
-
469
- if (value?.exportConfig && authFn(value?.exportConfig?.code)) {
470
- actionsRender = actionsRender.concat([
471
- {
472
- type: 'text',
473
- props: {
474
- children: (
475
- <ExportIcon
476
- request={{
477
- url:
478
- value?.exportConfig?.url ||
479
- `/oms-ops/excel/exportAsync/${value?.exportConfig?.type}`,
480
- params: value?.exportConfig?.params,
481
- }}
482
- tableRef={props.forwardedRef || refs}
483
- allowSelect={value?.exportConfig?.allowSelect ?? true}
484
- columnsRowKey={value?.rowKey}
485
- />
486
- ),
487
- },
488
- },
489
- ]);
490
- }
491
-
492
- actionsRender = actionsRender.concat([
493
- {
494
- type: 'text',
495
- props: {
496
- children: (
497
- <a>
498
- {isFullScreen ? (
499
- <Tooltip title="取消全屏">
500
- <img
501
- onClick={() => {
502
- ShowFullScreen();
503
- }}
504
- width={32}
505
- src={scanning}
506
- />
507
- </Tooltip>
508
- ) : (
509
- <Tooltip title="全屏">
510
- <img
511
- onClick={() => {
512
- ShowFullScreen();
513
- }}
514
- width={32}
515
- src={quanping}
516
- />
517
- </Tooltip>
518
- )}
519
- </a>
520
- ),
521
- },
522
- },
523
- {
524
- type: 'text',
525
- props: {
526
- children: (
527
- <span className="ant-dropdown-link">
528
- <Dropdown
529
- overlay={
530
- <Menu>
531
- <Menu.Item>
532
- <div
533
- onClick={sortTableRef?.current?.showModal}
534
- style={{ fontSize: 14, textAlign: 'center' }}
535
- >
536
- 列设置
537
- </div>
538
- </Menu.Item>
539
- {!value?.searchConfig?.isHidden && (
540
- <Menu.Item>
541
- <SearchItemTable
542
- ref={searchTableRef}
543
- setShowSearchFields={setShowSearchFields}
544
- showSearchFields={showSearchFields}
545
- datasource={value?.fields || []}
546
- bsTableCode={bsTableCode}
547
- />
548
- </Menu.Item>
549
- )}
550
- {value?.exportConfig?.settingColumns && (
551
- <Menu.Item>
552
- <div
553
- onClick={exportTableRef?.current?.showModal}
554
- style={{ fontSize: 14, textAlign: 'center' }}
555
- >
556
- 导出字段设置
557
- </div>
558
- </Menu.Item>
559
- )}
560
- </Menu>
561
- }
562
- placement="bottomRight"
563
- >
564
- <div className="ant-dropdown-link">
565
- <img width={32} src={shezhi} />
566
- </div>
567
- </Dropdown>
568
- </span>
569
- ),
570
- },
571
- },
572
- ]);
573
- if (value.rowSelection) {
574
- value.rowSelection.columnWidth = 50;
575
- }
576
- return {
577
- ...value,
578
- actionsRender,
579
- };
580
- };
581
-
582
- const handleResize =
583
- (index) =>
584
- (e, { size }) => {
585
- setShowColumns((columns: any) => {
586
- let newColumns = [...columns];
587
- newColumns[index] = {
588
- ...newColumns[index],
589
- width: size.width,
590
- };
591
- newColumns.forEach((d: any) => {
592
- handleBssulaColumnsSpecialParams(d);
593
- });
594
- return [...newColumns];
595
- });
596
- };
597
-
598
- const setVisibleColumn = (columnTitle: string) => {
599
- sortTableRef?.current?.handleTableHeadHidden?.(columnTitle);
600
- };
601
- const toMapByKey = (
602
- arr: any[],
603
- key: string,
604
- fn?: (item: any, index: number) => any,
605
- ) => {
606
- const map = {};
607
- arr.forEach((i: any) => (map[renderToString(i[key])] = i));
608
- return map;
609
- };
610
- const getColumns = () => {
611
- // 优化一下 减少复杂度
612
- const titleMap = toMapByKey(value.columns, 'title');
613
- // 加上排序
614
- const cols = showColumn.map((i) => ({
615
- ...i,
616
- isPermissionColumn: titleMap[renderToString(i.title)]?.isPermissionColumn,
617
- render: titleMap[renderToString(i.title)]?.render,
618
- }));
619
- cols.forEach((i) => handleBssulaColumnsSpecialParams(i));
620
- return cols;
621
- };
622
-
623
- const config = {
624
- visibleFieldsCount: 3,
625
- tableWrapperStyle: {
626
- padding: '10px',
627
- // background: '#f3f3f3',
628
- },
629
- setVisibleColumn: setVisibleColumn,
630
- itemLayout: {
631
- span: 8, // 栅格占位格数
632
- labelCol: {
633
- // label标签布局;可设置 span、offset
634
- span: 8,
635
- },
636
- wrapperCol: {
637
- // value布局, 方式同labelCol(horizontal状态下配置)
638
- span: 16,
639
- },
640
- },
641
- rowSelection: false, // 默认无多选
642
- ...handleTimeValue(),
643
- tableProps: setTableProps(),
644
- columns: getColumns(),
645
- fields: [...showSearchFields],
646
- ref: props.forwardedRef || refs,
647
- isFullScreen,
648
- };
649
-
650
- useEffect(() => {
651
- if (!localStorage.getItem('isTabChange') || state?.updateCurrentPage) {
652
- if (pagePath === pathname) {
653
- // @ts-ignore
654
- config.ref?.current?.tableRef?.current?.refreshTable();
655
- }
656
- }
657
- setTimeout(() => {
658
- // 处理页面刷新两面
659
- localStorage.removeItem('isTabChange');
660
- }, 0);
661
- }, [pathname]);
662
-
663
- const expandedRowKeys = props?.expandable?.expandedRowKeys;
664
-
665
- //todo summary属性已经被使用,为了兼容之前的,现在使用 summaryList
666
- //结构为了实现多行总结栏 定义如下(lableShow: boolean 是否显示列文本)
667
- /**
668
- * [
669
- * {
670
- * cont:[{key: 'spuCode',value: 100,labelShow: false}]
671
- * }
672
- * ]
673
- * @returns []
674
- */
675
- const getTableSummaryInfo = () => {
676
- const { summaryList, rowSelection,expandable }: any = props;
677
- if (summaryList && Array.isArray(summaryList)) {
678
- const summaryRow = (rowSelection) ? [{}, ...showColumn] : [...showColumn];
679
- if(expandable){
680
- summaryRow.unshift({});
681
- }
682
- // let summaryInitial = summary().cont;
683
- return (
684
- <Table.Summary fixed>
685
- {Array.isArray(summaryList) &&
686
- summaryList.map((summaryItem, summaryIndex) => (
687
- <Table.Summary.Row key={summaryIndex}>
688
- {summaryRow.map((item: any, index: number) => {
689
- const { cout = [] } = summaryItem;
690
- const target = cout.filter(
691
- (inner: any) =>
692
- inner.key &&
693
- (inner.key === item.dataIndex || inner.key === item.key),
694
- )[0];
695
- if (target) {
696
- const labelText = target.labelShow ? `${item.title}:` :``;
697
- return (
698
- <Table.Summary.Cell
699
- index={index}
700
- key={`Table.Summary.Cell_${item.index}`}
701
- >
702
- <Text type="danger">
703
- {`${labelText} ${target.value ?? ''}`}
704
- </Text>
705
- </Table.Summary.Cell>
706
- );
707
- } else {
708
- return (
709
- <Table.Summary.Cell
710
- index={index}
711
- key={`Table.Summary.Cell_${item.index}`}
712
- >
713
- <Text type="danger">{` `}</Text>
714
- </Table.Summary.Cell>
715
- );
716
- }
717
- })}
718
- </Table.Summary.Row>
719
- ))}
720
- </Table.Summary>
721
- );
722
- } else {
723
- return undefined;
724
- }
725
- };
726
-
727
- const memoConfig = useMemo(
728
- () => ({
729
- ...config,
730
- summary: props.summary,
731
- summaryList: props.summaryList ? getTableSummaryInfo : undefined,
732
- statusMapping: props.statusMapping,
733
- isBsSulaQueryTable: true,
734
- }),
735
- [
736
- // value,
737
- checkedList,
738
- showColumn,
739
- props.statusMapping,
740
- showSearchFields,
741
- expandedRowKeys,
742
- ],
743
- );
744
- return (
745
- <div id="bs-sula-query-table">
746
- <MemoQueryTable {...memoConfig} />
747
- <SortableTable
748
- ref={sortTableRef}
749
- setShowColumns={setShowColumns}
750
- showColumn={showColumn}
751
- datasource={value?.columns || []}
752
- bsTableCode={bsTableCode}
753
- onlyModal
754
- />
755
- {value?.exportConfig?.settingColumns && (
756
- <SortableTable
757
- ref={exportTableRef}
758
- setShowColumns={setShowExportColumns}
759
- showColumn={showExportColumn}
760
- datasource={value?.columns || []}
761
- bsTableCode={bsTableCodeExport}
762
- onlyModal
763
- />
764
- )}
765
- </div>
766
- );
767
- };
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, parseWidth } 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('');
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
+ let showColumns = getSettingFieldOrColumn(columnConfig, columns, 'columns');
269
+
270
+ showColumns.forEach((item, index) => {
271
+ item.width = item.width || getItemDefaultWidth(item);
272
+ handleBssulaColumnsSpecialParams(item);
273
+ item.onHeaderCell = (column) => ({
274
+ ...item,
275
+ width: typeof column.width === 'number'
276
+ ? column.width
277
+ : parseWidth(column.width),
278
+ onResize: handleResize(index),
279
+ });
280
+ });
281
+ setShowColumns([...showColumns]);
282
+
283
+ let exportColumnConfig = getConfigFromlocalstorage(
284
+ ENUM.BROWSER_CACHE.COLUMN_CONDITION,
285
+ bsTableCodeExport,
286
+ );
287
+ let showExportColumns = getSettingFieldOrColumn(exportColumnConfig, columns, 'columns');
288
+
289
+ showExportColumns.forEach((item, index) => {
290
+ item.width = item.width || getItemDefaultWidth(item);
291
+ handleBssulaColumnsSpecialParams(item);
292
+ item.onHeaderCell = (column) => ({
293
+ ...item,
294
+ width: typeof column.width === 'number'
295
+ ? column.width
296
+ : parseWidth(column.width),
297
+ onResize: handleResize(index),
298
+ });
299
+ });
300
+ setShowExportColumns([...showExportColumns]);
301
+ };
302
+
303
+ const setInitialSearchFieldsInfo = () => {
304
+ //获取搜索字段的缓存配置
305
+ const { fields = [] } = props;
306
+ let searchFieldsConfig = getConfigFromlocalstorage(
307
+ ENUM.BROWSER_CACHE.SEARCH_FIELDS_CONDITION,
308
+ );
309
+ const showSearchFields = getSettingFieldOrColumn(searchFieldsConfig, fields, 'searchFields');
310
+ setShowSearchFields([...showSearchFields]);
311
+ };
312
+
313
+ //组件初始挂载
314
+ useEffect(() => {
315
+ // getTableHeight();
316
+ setInitialTableInfo();
317
+ setInitialSearchFieldsInfo();
318
+ window.addEventListener('resize', (e) => {
319
+ watchWinResize();
320
+ });
321
+
322
+ setPagePath(pathname); // 做处理,记录当前页面渲染的初始pathname,用于进行判断当前列表页面数据是否需要重新渲染
323
+ }, []);
324
+
325
+ useEffect(() => {
326
+ if (props?.columns && value?.columns) {
327
+ let newKeys = props.columns.map((d: any) =>
328
+ Array.isArray(d.key || d.dataIndex)
329
+ ? JSON.stringify(d.key || d.dataIndex)
330
+ : d.key || d.dataIndex,
331
+ );
332
+ let oldKeys = value.columns.map((d: any) =>
333
+ Array.isArray(d.key || d.dataIndex)
334
+ ? JSON.stringify(d.key || d.dataIndex)
335
+ : d.key || d.dataIndex,
336
+ );
337
+ JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
338
+ setInitialTableInfo();
339
+ }
340
+ }, [props?.columns]);
341
+
342
+ useEffect(() => {
343
+ if (props?.fields && value?.fields) {
344
+ let newKeys = props.fields.map((d: any) =>
345
+ Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
346
+ );
347
+ let oldKeys = value.fields.map((d: any) =>
348
+ Array.isArray(d.name) ? JSON.stringify(d.name) : d.name,
349
+ );
350
+ JSON.stringify(newKeys) !== JSON.stringify(oldKeys) &&
351
+ setInitialSearchFieldsInfo();
352
+ }
353
+ }, [props?.fields]);
354
+
355
+ useEffect(() => {
356
+ setInitialTableInfo();
357
+ }, [props?.refreshColumns]);
358
+
359
+ const watchWinResize = debounce(() => {
360
+ getTableHeight();
361
+ if (!checkFull()) {
362
+ // addTabsNavStyle(true);
363
+ // 全屏下按键esc后要执行的动作
364
+ // isFullScreen 为true 此时为全屏状态 false 为非全屏状态
365
+ if (!isFullScreen) {
366
+ // 按下esc键退出全屏
367
+ setIsFnllScreen(false);
368
+ } else {
369
+ setIsFnllScreen(false);
370
+ }
371
+ }
372
+ }, 10);
373
+
374
+ const setCommonRenderFn = (columns: any[]) => {
375
+ columns.forEach((column) => {
376
+ if (column.showDetailUserInfo) {
377
+ column.render = ({ text }: any) => userColumns({ name: text });
378
+ }
379
+ });
380
+ };
381
+
382
+ // 处理 table 基本参数
383
+ const setTableProps = () => {
384
+ let tableProps = value.tableProps || {};
385
+ tableProps = {
386
+ ...tableProps,
387
+ size: value.size || 'middle',
388
+ defaultPageSize: 20,
389
+ pageSize: 20,
390
+ initialPaging: {
391
+ pagination: props?.pagination
392
+ ? false
393
+ : {
394
+ defaultPageSize: 20,
395
+ pageSize: 20,
396
+ showTotal: (total: any) => `共 ${total} 条`,
397
+ showQuickJumper: true,
398
+ hideOnSinglePage: value.hideOnSinglePage || false,
399
+
400
+ ...tableProps?.initialPaging?.pagination
401
+ },
402
+ },
403
+ initialSelectedRowKeys: value.initialSelectedRowKeys || [],
404
+ expandable: props.expandable,
405
+ scroll: { x: props.overScrollX || 'max-content', y: props?.overScrollY || height },
406
+ bordered: value.bordered || false,
407
+ sticky: true,
408
+ rowClassName: (record: object | null | undefined, index: number) =>
409
+ index % 2 === 0 ? 'table_base' : 'table_odd',
410
+ components: {
411
+ header: {
412
+ cell: ResizeableTitle,
413
+ },
414
+ ...tableProps?.components,
415
+ },
416
+ };
417
+
418
+ // @ts-ignore
419
+ if (tableProps?.initialPaging?.pagination) {
420
+ // @ts-ignore
421
+ tableProps.initialPaging.pagination.showSizeChanger = true;
422
+ }
423
+ return tableProps;
424
+ };
425
+
426
+ const ShowFullScreen = () => {
427
+ const isFullScreen: any =
428
+ window.top.document.fullScreen ||
429
+ window.top.document.webkitIsFullScreen ||
430
+ window.top.document.mozFullScreen;
431
+ let contentEle: any = window.top.document.querySelector(`body`);
432
+ // addTabsNavStyle(isFullScreen);
433
+ if (contentEle && !isFullScreen) {
434
+ let fullScreenEle =
435
+ contentEle.requestFullscreen ||
436
+ contentEle.mozRequestFullScreen ||
437
+ contentEle.webkitRequestFullScreen ||
438
+ contentEle.msRequestFullscreen;
439
+ if (fullScreenEle) {
440
+ fullScreenEle.call(contentEle);
441
+ setIsFnllScreen(true);
442
+ // getTableHeight(true);
443
+ return;
444
+ }
445
+ }
446
+ if (window.top.document && isFullScreen) {
447
+ let exitFullScreen =
448
+ window.top.document.exitFullscreen ||
449
+ window.top.document.mozCancelFullScreen ||
450
+ window.top.document.webkitCancelFullScreen ||
451
+ window.top.document.msExitFullscreen;
452
+ if (exitFullScreen) {
453
+ exitFullScreen.call(window.top.document);
454
+ setIsFnllScreen(false);
455
+ // getTableHeight();
456
+ return;
457
+ }
458
+ }
459
+ };
460
+
461
+ const handleTimeValue = () => {
462
+
463
+
464
+ let actionsRender = (value.actionsRender ?? []).map((x) => ({
465
+ ...x,
466
+ position: x.position ?? 'left',
467
+ })).filter((x) => authFn(x?.code));
468
+
469
+ if (value?.exportConfig && authFn(value?.exportConfig?.code)) {
470
+ actionsRender = actionsRender.concat([
471
+ {
472
+ type: 'text',
473
+ props: {
474
+ children: (
475
+ <ExportIcon
476
+ request={{
477
+ url:
478
+ value?.exportConfig?.url ||
479
+ `/oms-ops/excel/exportAsync/${value?.exportConfig?.type}`,
480
+ params: value?.exportConfig?.params,
481
+ }}
482
+ tableRef={props.forwardedRef || refs}
483
+ allowSelect={value?.exportConfig?.allowSelect ?? true}
484
+ columnsRowKey={value?.rowKey}
485
+ />
486
+ ),
487
+ },
488
+ },
489
+ ]);
490
+ }
491
+
492
+ actionsRender = actionsRender.concat([
493
+ {
494
+ type: 'text',
495
+ props: {
496
+ children: (
497
+ <a>
498
+ {isFullScreen ? (
499
+ <Tooltip title="取消全屏">
500
+ <img
501
+ onClick={() => {
502
+ ShowFullScreen();
503
+ }}
504
+ width={32}
505
+ src={scanning}
506
+ />
507
+ </Tooltip>
508
+ ) : (
509
+ <Tooltip title="全屏">
510
+ <img
511
+ onClick={() => {
512
+ ShowFullScreen();
513
+ }}
514
+ width={32}
515
+ src={quanping}
516
+ />
517
+ </Tooltip>
518
+ )}
519
+ </a>
520
+ ),
521
+ },
522
+ },
523
+ {
524
+ type: 'text',
525
+ props: {
526
+ children: (
527
+ <span className="ant-dropdown-link">
528
+ <Dropdown
529
+ overlay={
530
+ <Menu>
531
+ <Menu.Item>
532
+ <div
533
+ onClick={sortTableRef?.current?.showModal}
534
+ style={{ fontSize: 14, textAlign: 'center' }}
535
+ >
536
+ 列设置
537
+ </div>
538
+ </Menu.Item>
539
+ {!value?.searchConfig?.isHidden && (
540
+ <Menu.Item>
541
+ <SearchItemTable
542
+ ref={searchTableRef}
543
+ setShowSearchFields={setShowSearchFields}
544
+ showSearchFields={showSearchFields}
545
+ datasource={value?.fields || []}
546
+ bsTableCode={bsTableCode}
547
+ />
548
+ </Menu.Item>
549
+ )}
550
+ {value?.exportConfig?.settingColumns && (
551
+ <Menu.Item>
552
+ <div
553
+ onClick={exportTableRef?.current?.showModal}
554
+ style={{ fontSize: 14, textAlign: 'center' }}
555
+ >
556
+ 导出字段设置
557
+ </div>
558
+ </Menu.Item>
559
+ )}
560
+ </Menu>
561
+ }
562
+ placement="bottomRight"
563
+ >
564
+ <div className="ant-dropdown-link">
565
+ <img width={32} src={shezhi} />
566
+ </div>
567
+ </Dropdown>
568
+ </span>
569
+ ),
570
+ },
571
+ },
572
+ ]);
573
+ if (value.rowSelection) {
574
+ value.rowSelection.columnWidth = 50;
575
+ }
576
+ return {
577
+ ...value,
578
+ actionsRender,
579
+ };
580
+ };
581
+
582
+ const handleResize =
583
+ (index) =>
584
+ (e, { size }) => {
585
+ setShowColumns((columns: any) => {
586
+ let newColumns = [...columns];
587
+ newColumns[index] = {
588
+ ...newColumns[index],
589
+ width: size.width,
590
+ };
591
+ newColumns.forEach((d: any) => {
592
+ handleBssulaColumnsSpecialParams(d);
593
+ });
594
+ return [...newColumns];
595
+ });
596
+ };
597
+
598
+ const setVisibleColumn = (columnTitle: string) => {
599
+ sortTableRef?.current?.handleTableHeadHidden?.(columnTitle);
600
+ };
601
+ const toMapByKey = (
602
+ arr: any[],
603
+ key: string,
604
+ fn?: (item: any, index: number) => any,
605
+ ) => {
606
+ const map = {};
607
+ arr.forEach((i: any) => (map[renderToString(i[key])] = i));
608
+ return map;
609
+ };
610
+ const getColumns = () => {
611
+ // 优化一下 减少复杂度
612
+ const titleMap = toMapByKey(value.columns, 'title');
613
+ // 加上排序
614
+ const cols = showColumn.map((i) => ({
615
+ ...i,
616
+ isPermissionColumn: titleMap[renderToString(i.title)]?.isPermissionColumn,
617
+ render: titleMap[renderToString(i.title)]?.render,
618
+ }));
619
+ cols.forEach((i) => handleBssulaColumnsSpecialParams(i));
620
+ return cols;
621
+ };
622
+
623
+ const config = {
624
+ visibleFieldsCount: 3,
625
+ tableWrapperStyle: {
626
+ padding: '10px',
627
+ // background: '#f3f3f3',
628
+ },
629
+ setVisibleColumn: setVisibleColumn,
630
+ itemLayout: {
631
+ span: 8, // 栅格占位格数
632
+ labelCol: {
633
+ // label标签布局;可设置 span、offset
634
+ span: 8,
635
+ },
636
+ wrapperCol: {
637
+ // value布局, 方式同labelCol(horizontal状态下配置)
638
+ span: 16,
639
+ },
640
+ },
641
+ rowSelection: false, // 默认无多选
642
+ ...handleTimeValue(),
643
+ tableProps: setTableProps(),
644
+ columns: getColumns(),
645
+ fields: [...showSearchFields],
646
+ ref: props.forwardedRef || refs,
647
+ isFullScreen,
648
+ };
649
+
650
+ useEffect(() => {
651
+ if (!localStorage.getItem('isTabChange') || state?.updateCurrentPage) {
652
+ if (pagePath === pathname) {
653
+ // @ts-ignore
654
+ config.ref?.current?.tableRef?.current?.refreshTable();
655
+ }
656
+ }
657
+ setTimeout(() => {
658
+ // 处理页面刷新两面
659
+ localStorage.removeItem('isTabChange');
660
+ }, 0);
661
+ }, [pathname]);
662
+
663
+ const expandedRowKeys = props?.expandable?.expandedRowKeys;
664
+
665
+ //todo summary属性已经被使用,为了兼容之前的,现在使用 summaryList
666
+ //结构为了实现多行总结栏 定义如下(lableShow: boolean 是否显示列文本)
667
+ /**
668
+ * [
669
+ * {
670
+ * cont:[{key: 'spuCode',value: 100,labelShow: false}]
671
+ * }
672
+ * ]
673
+ * @returns []
674
+ */
675
+ const getTableSummaryInfo = () => {
676
+ const { summaryList, rowSelection,expandable }: any = props;
677
+ if (summaryList && Array.isArray(summaryList)) {
678
+ const summaryRow = (rowSelection) ? [{}, ...showColumn] : [...showColumn];
679
+ if(expandable){
680
+ summaryRow.unshift({});
681
+ }
682
+ // let summaryInitial = summary().cont;
683
+ return (
684
+ <Table.Summary fixed>
685
+ {Array.isArray(summaryList) &&
686
+ summaryList.map((summaryItem, summaryIndex) => (
687
+ <Table.Summary.Row key={summaryIndex}>
688
+ {summaryRow.map((item: any, index: number) => {
689
+ const { cout = [] } = summaryItem;
690
+ const target = cout.filter(
691
+ (inner: any) =>
692
+ inner.key &&
693
+ (inner.key === item.dataIndex || inner.key === item.key),
694
+ )[0];
695
+ if (target) {
696
+ const labelText = target.labelShow ? `${item.title}:` :``;
697
+ return (
698
+ <Table.Summary.Cell
699
+ index={index}
700
+ key={`Table.Summary.Cell_${item.index}`}
701
+ >
702
+ <Text type="danger">
703
+ {`${labelText} ${target.value ?? ''}`}
704
+ </Text>
705
+ </Table.Summary.Cell>
706
+ );
707
+ } else {
708
+ return (
709
+ <Table.Summary.Cell
710
+ index={index}
711
+ key={`Table.Summary.Cell_${item.index}`}
712
+ >
713
+ <Text type="danger">{` `}</Text>
714
+ </Table.Summary.Cell>
715
+ );
716
+ }
717
+ })}
718
+ </Table.Summary.Row>
719
+ ))}
720
+ </Table.Summary>
721
+ );
722
+ } else {
723
+ return undefined;
724
+ }
725
+ };
726
+
727
+ const memoConfig = useMemo(
728
+ () => ({
729
+ ...config,
730
+ summary: props.summary,
731
+ summaryList: props.summaryList ? getTableSummaryInfo : undefined,
732
+ statusMapping: props.statusMapping,
733
+ isBsSulaQueryTable: true,
734
+ }),
735
+ [
736
+ // value,
737
+ checkedList,
738
+ showColumn,
739
+ props.statusMapping,
740
+ showSearchFields,
741
+ expandedRowKeys,
742
+ ],
743
+ );
744
+ return (
745
+ <div id="bs-sula-query-table">
746
+ <MemoQueryTable {...memoConfig} />
747
+ <SortableTable
748
+ ref={sortTableRef}
749
+ setShowColumns={setShowColumns}
750
+ showColumn={showColumn}
751
+ datasource={value?.columns || []}
752
+ bsTableCode={bsTableCode}
753
+ onlyModal
754
+ />
755
+ {value?.exportConfig?.settingColumns && (
756
+ <SortableTable
757
+ ref={exportTableRef}
758
+ setShowColumns={setShowExportColumns}
759
+ showColumn={showExportColumn}
760
+ datasource={value?.columns || []}
761
+ bsTableCode={bsTableCodeExport}
762
+ onlyModal
763
+ />
764
+ )}
765
+ </div>
766
+ );
767
+ };