@bit-sun/business-component 4.0.0-alpha.3 → 4.0.2

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 (241) hide show
  1. package/.editorconfig +16 -0
  2. package/.fatherrc.ts +5 -0
  3. package/.gitlab-ci.yml +179 -0
  4. package/.prettierignore +7 -0
  5. package/.prettierrc +11 -0
  6. package/.umirc.ts +74 -0
  7. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +1 -1
  8. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +1 -1
  9. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +1 -1
  10. package/dist/components/Business/columnSettingTable/index.d.ts +1 -0
  11. package/dist/components/Common/ParagraphCopier/index.d.ts +8 -0
  12. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +3 -0
  13. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.d.ts +2 -0
  14. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +3 -0
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.esm.js +1901 -639
  17. package/dist/index.js +1903 -636
  18. package/dist/utils/requestUtils.d.ts +1 -0
  19. package/dist/utils/utils.d.ts +3 -0
  20. package/docs/index.md +21 -0
  21. package/package.json +9 -14
  22. package/src/assets/32.svg +28 -0
  23. package/src/assets/addIcon.svg +18 -0
  24. package/src/assets/allfunc.svg +28 -0
  25. package/src/assets/arrowRight.svg +25 -0
  26. package/src/assets/arrow_top.png +0 -0
  27. package/src/assets/arrow_top.svg +18 -0
  28. package/src/assets/btn-delete.svg +30 -0
  29. package/src/assets/btn-edit.svg +20 -0
  30. package/src/assets/btn-more.svg +18 -0
  31. package/src/assets/btn-submit.svg +20 -0
  32. package/src/assets/caidan.svg +12 -0
  33. package/src/assets/close.svg +26 -0
  34. package/src/assets/closeicon.png +0 -0
  35. package/src/assets/drag.svg +17 -0
  36. package/src/assets/exportFail.svg +38 -0
  37. package/src/assets/exportProcessing.svg +29 -0
  38. package/src/assets/exportSuccess.svg +35 -0
  39. package/src/assets/exportlogo.png +0 -0
  40. package/src/assets/fixed-left-active.svg +12 -0
  41. package/src/assets/fixed-left.svg +16 -0
  42. package/src/assets/fixed-right-active.svg +12 -0
  43. package/src/assets/fixed-right.svg +16 -0
  44. package/src/assets/guanbi.svg +16 -0
  45. package/src/assets/icon-quanping.svg +16 -0
  46. package/src/assets/icon-shezhi.svg +18 -0
  47. package/src/assets/label_icon_bottom.svg +26 -0
  48. package/src/assets/list-no-img.svg +22 -0
  49. package/src/assets/morentouxiang-32.svg +24 -0
  50. package/src/assets/right.png +0 -0
  51. package/src/assets/scanning.svg +25 -0
  52. package/src/assets/upExport.svg +23 -0
  53. package/src/assets/xinglan-icon-out.png +0 -0
  54. package/src/common/ENUM.ts +41 -0
  55. package/src/components/Business/AddSelectBusiness/index.md +398 -0
  56. package/src/components/Business/AddSelectBusiness/index.tsx +1116 -0
  57. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +112 -0
  58. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -0
  59. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -0
  60. package/src/components/Business/BsLayouts/Components/ChooseStore/index.less +0 -0
  61. package/src/components/Business/BsLayouts/Components/ChooseStore/index.tsx +193 -0
  62. package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +10 -0
  63. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -0
  64. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +38 -0
  65. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +243 -0
  66. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +385 -0
  67. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +286 -0
  68. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +75 -0
  69. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +171 -0
  70. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +65 -0
  71. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +154 -0
  72. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +73 -0
  73. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +163 -0
  74. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -0
  75. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -0
  76. package/src/components/Business/BsLayouts/Components/RightContent/i18n.ts +9 -0
  77. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +172 -0
  78. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +161 -0
  79. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +76 -0
  80. package/src/components/Business/BsLayouts/index.less +80 -0
  81. package/src/components/Business/BsLayouts/index.tsx +1602 -0
  82. package/src/components/Business/BsLayouts/service.ts +11 -0
  83. package/src/components/Business/BsLayouts/utils.tsx +205 -0
  84. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +566 -0
  85. package/src/components/Business/BsSulaQueryTable/bssulaquerytable.less +5 -0
  86. package/src/components/Business/BsSulaQueryTable/index.less +228 -0
  87. package/src/components/Business/BsSulaQueryTable/index.tsx +817 -0
  88. package/src/components/Business/BsSulaQueryTable/setting.tsx +937 -0
  89. package/src/components/Business/BsSulaQueryTable/utils.less +65 -0
  90. package/src/components/Business/BsSulaQueryTable/utils.tsx +709 -0
  91. package/src/components/Business/CommodityEntry/index.md +84 -0
  92. package/src/components/Business/CommodityEntry/index.tsx +82 -0
  93. package/src/components/Business/CommonAlert/index.less +0 -0
  94. package/src/components/Business/CommonAlert/index.tsx +23 -0
  95. package/src/components/Business/CommonGuideWrapper/index.less +156 -0
  96. package/src/components/Business/CommonGuideWrapper/index.md +61 -0
  97. package/src/components/Business/CommonGuideWrapper/index.tsx +108 -0
  98. package/src/components/Business/DetailPageWrapper/index.less +89 -0
  99. package/src/components/Business/DetailPageWrapper/index.tsx +306 -0
  100. package/src/components/Business/DetailPageWrapper/utils.tsx +166 -0
  101. package/src/components/Business/HomePageWrapper/index.less +36 -0
  102. package/src/components/Business/HomePageWrapper/index.md +45 -0
  103. package/src/components/Business/HomePageWrapper/index.tsx +130 -0
  104. package/src/components/Business/JsonQueryTable/components/FieldsModifyModal.tsx +823 -0
  105. package/src/components/Business/JsonQueryTable/components/FieldsSettingsTable.tsx +206 -0
  106. package/src/components/Business/JsonQueryTable/components/Formula.tsx +205 -0
  107. package/src/components/Business/JsonQueryTable/components/MaintainOptions.tsx +127 -0
  108. package/src/components/Business/JsonQueryTable/configButton/index.js +20 -0
  109. package/src/components/Business/JsonQueryTable/configTree/component/compactArrayView.js +25 -0
  110. package/src/components/Business/JsonQueryTable/configTree/component/compactObjectView.js +30 -0
  111. package/src/components/Business/JsonQueryTable/configTree/index.js +82 -0
  112. package/src/components/Business/JsonQueryTable/configTree/index.less +44 -0
  113. package/src/components/Business/JsonQueryTable/configTree/parser/highlight.js +57 -0
  114. package/src/components/Business/JsonQueryTable/configTree/parser/index.js +124 -0
  115. package/src/components/Business/JsonQueryTable/configTree/render/iconRender.js +29 -0
  116. package/src/components/Business/JsonQueryTable/configTree/render/nameRender.js +22 -0
  117. package/src/components/Business/JsonQueryTable/configTree/treeNode.js +116 -0
  118. package/src/components/Business/JsonQueryTable/drawer/index.tsx +12 -0
  119. package/src/components/Business/JsonQueryTable/function.ts +62 -0
  120. package/src/components/Business/JsonQueryTable/index.less +17 -0
  121. package/src/components/Business/JsonQueryTable/index.md +328 -0
  122. package/src/components/Business/JsonQueryTable/index.tsx +534 -0
  123. package/src/components/Business/JsonQueryTable/jsonEditor/index.js +346 -0
  124. package/src/components/Business/JsonQueryTable/jsonEditor/index.less +22 -0
  125. package/src/components/Business/JsonQueryTable/jsonEditor/lint/basicType.js +147 -0
  126. package/src/components/Business/JsonQueryTable/jsonEditor/lint/index.js +389 -0
  127. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/actions.js +118 -0
  128. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/dependency.js +22 -0
  129. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/index.js +21 -0
  130. package/src/components/Business/JsonQueryTable/jsonEditor/suggestions/request.js +65 -0
  131. package/src/components/Business/JsonQueryTable/static.ts +450 -0
  132. package/src/components/Business/SearchSelect/BusinessUtils.tsx +2207 -0
  133. package/src/components/Business/SearchSelect/common.ts +134 -0
  134. package/src/components/Business/SearchSelect/index.md +1570 -0
  135. package/src/components/Business/SearchSelect/index.tsx +55 -0
  136. package/src/components/Business/SearchSelect/utils.ts +125 -0
  137. package/src/components/Business/StateFlow/index.less +131 -0
  138. package/src/components/Business/StateFlow/index.md +60 -0
  139. package/src/components/Business/StateFlow/index.tsx +30 -0
  140. package/src/components/Business/TreeSearchSelect/index.md +239 -0
  141. package/src/components/Business/TreeSearchSelect/index.tsx +33 -0
  142. package/src/components/Business/TreeSearchSelect/utils.ts +115 -0
  143. package/src/components/Business/columnSettingTable/columnSetting.tsx +869 -0
  144. package/src/components/Business/columnSettingTable/index.less +253 -0
  145. package/src/components/Business/columnSettingTable/index.md +373 -0
  146. package/src/components/Business/columnSettingTable/index.tsx +235 -0
  147. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +232 -0
  148. package/src/components/Business/columnSettingTable/utils.tsx +88 -0
  149. package/src/components/Business/moreTreeTable/FixedScrollBar.tsx +87 -0
  150. package/src/components/Business/moreTreeTable/hooks/useSticky.ts +21 -0
  151. package/src/components/Business/moreTreeTable/index.less +100 -0
  152. package/src/components/Business/moreTreeTable/index.md +448 -0
  153. package/src/components/Business/moreTreeTable/index.tsx +387 -0
  154. package/src/components/Business/moreTreeTable/utils.ts +127 -0
  155. package/src/components/Common/ExtendedCollapse/ExtendedPanel.tsx +51 -0
  156. package/src/components/Common/ExtendedCollapse/index.less +33 -0
  157. package/src/components/Common/ExtendedCollapse/index.md +136 -0
  158. package/src/components/Common/ExtendedCollapse/index.tsx +25 -0
  159. package/src/components/Common/ParagraphCopier/index.md +81 -0
  160. package/src/components/Common/ParagraphCopier/index.tsx +56 -0
  161. package/src/components/Common/Section/index.md +120 -0
  162. package/src/components/Common/Section/index.module.less +16 -0
  163. package/src/components/Common/Section/index.tsx +70 -0
  164. package/src/components/Functional/AccessWrapper/index.tsx +34 -0
  165. package/src/components/Functional/AddSelect/helps.ts +81 -0
  166. package/src/components/Functional/AddSelect/index.less +367 -0
  167. package/src/components/Functional/AddSelect/index.md +155 -0
  168. package/src/components/Functional/AddSelect/index.tsx +1072 -0
  169. package/src/components/Functional/AuthButton/index.tsx +15 -0
  170. package/src/components/Functional/BillEntry/index.less +371 -0
  171. package/src/components/Functional/BillEntry/index.md +39 -0
  172. package/src/components/Functional/BillEntry/index.tsx +771 -0
  173. package/src/components/Functional/BsAntdSula/BsCascader/index.md +62 -0
  174. package/src/components/Functional/BsAntdSula/BsCascader/index.tsx +178 -0
  175. package/src/components/Functional/BsAntdSula/index.ts +2 -0
  176. package/src/components/Functional/DataImport/index.less +63 -0
  177. package/src/components/Functional/DataImport/index.md +44 -0
  178. package/src/components/Functional/DataImport/index.tsx +782 -0
  179. package/src/components/Functional/DataValidation/index.less +63 -0
  180. package/src/components/Functional/DataValidation/index.md +52 -0
  181. package/src/components/Functional/DataValidation/index.tsx +788 -0
  182. package/src/components/Functional/EllipsisTooltip/index.d.ts +5 -0
  183. package/src/components/Functional/EllipsisTooltip/index.js +36 -0
  184. package/src/components/Functional/EllipsisTooltip/index.md +30 -0
  185. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -0
  186. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +65 -0
  187. package/src/components/Functional/QueryMutipleInput/index.less +37 -0
  188. package/src/components/Functional/QueryMutipleInput/index.md +33 -0
  189. package/src/components/Functional/QueryMutipleInput/index.tsx +129 -0
  190. package/src/components/Functional/SearchSelect/index.less +121 -0
  191. package/src/components/Functional/SearchSelect/index.md +141 -0
  192. package/src/components/Functional/SearchSelect/index.tsx +1041 -0
  193. package/src/components/Functional/SearchSelect/utils.ts +3 -0
  194. package/src/components/Functional/TreeSearchSelect/index.md +47 -0
  195. package/src/components/Functional/TreeSearchSelect/index.tsx +224 -0
  196. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.tsx +358 -0
  197. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/function.js +255 -0
  198. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/helps.tsx +58 -0
  199. package/src/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.tsx +129 -0
  200. package/src/components/Solution/RuleComponent/Formula.tsx +335 -0
  201. package/src/components/Solution/RuleComponent/InnerSelect.tsx +62 -0
  202. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +743 -0
  203. package/src/components/Solution/RuleComponent/index.d.ts +29 -0
  204. package/src/components/Solution/RuleComponent/index.js +1614 -0
  205. package/src/components/Solution/RuleComponent/index.less +247 -0
  206. package/src/components/Solution/RuleComponent/renderSpecificAction.js +99 -0
  207. package/src/components/Solution/RuleComponent/ruleFiled.js +2587 -0
  208. package/src/components/Solution/RuleComponent/services.ts +13 -0
  209. package/src/components/Solution/RuleComponent/util.js +143 -0
  210. package/src/components/Solution/RuleSetter/RuleInstance.tsx +6 -0
  211. package/src/components/Solution/RuleSetter/baseRule.tsx +394 -0
  212. package/src/components/Solution/RuleSetter/function.ts +437 -0
  213. package/src/components/Solution/RuleSetter/index.less +221 -0
  214. package/src/components/Solution/RuleSetter/index.tsx +208 -0
  215. package/src/components/Solution/RuleSetter/service.js +276 -0
  216. package/src/index.ts +46 -0
  217. package/src/plugin/TableColumnSetting/index.less +247 -0
  218. package/src/plugin/TableColumnSetting/index.md +50 -0
  219. package/src/plugin/TableColumnSetting/index.tsx +725 -0
  220. package/src/plugin/TableColumnSetting/utils.ts +19 -0
  221. package/src/styles/bsDefault.less +32 -12
  222. package/src/utils/CheckOneUser/index.md +39 -0
  223. package/src/utils/CheckOneUser/index.ts +52 -0
  224. package/src/utils/CustomLoginInfo.ts +55 -0
  225. package/src/utils/LocalstorageUtils.ts +134 -0
  226. package/src/utils/TableUtils.less +52 -0
  227. package/src/utils/TableUtils.tsx +691 -0
  228. package/src/utils/auth.ts +39 -0
  229. package/src/utils/businessUtils.ts +434 -0
  230. package/src/utils/checkUtils.ts +39 -0
  231. package/src/utils/constant.ts +38 -0
  232. package/src/utils/enumConfig.ts +17 -0
  233. package/src/utils/getFormMode.js +12 -0
  234. package/src/utils/index.ts +19 -0
  235. package/src/utils/request.ts +53 -0
  236. package/src/utils/requestUtils.ts +197 -0
  237. package/src/utils/serialize.js +7 -0
  238. package/src/utils/utils.ts +267 -0
  239. package/src/utils/xlsxUtil.tsx +146 -0
  240. package/tsconfig.json +29 -0
  241. package/typings.d.ts +5 -0
@@ -0,0 +1,235 @@
1
+ import React, { useState } from 'react';
2
+ import { Table, Tooltip, Typography } from 'antd';
3
+ import { Resizable } from 'react-resizable';
4
+ import ColumnSetting from './columnSetting';
5
+ import { getItemDefaultWidth, getShowColumns, handleTextOverflow } from './utils';
6
+ import { noEmptyArray } from './utils';
7
+ import ENUM from '@/utils/enumConfig';
8
+ import { handleAntdColumnsSpecialParams } from '@/utils/utils';
9
+ const { Text } = Typography;
10
+ export default class ColumnSettingTable extends React.Component {
11
+ state: any;
12
+ constructor(props: any) {
13
+ super(props);
14
+ this.state = {
15
+ showColumns: [],
16
+ }
17
+ }
18
+
19
+ componentDidMount() {
20
+ const { columns }: any = this.props;
21
+ this.setInitialShowColumn(columns || [])
22
+ }
23
+
24
+
25
+ componentWillReceiveProps(nextProps: any) {
26
+ // if (JSON.stringify(this.props.columns) !== JSON.stringify(nextProps.columns)) {
27
+ // }
28
+ this.setInitialShowColumn(nextProps.columns || [])
29
+ }
30
+
31
+ setInitialShowColumn = (columns: any[]) => {
32
+ // 获取当前列表定义数据
33
+ let columnConfig = this.getConfigFromlocalstorage();
34
+ let showColumns = getShowColumns(columns, columnConfig);
35
+ this.setState({
36
+ showColumns,
37
+ })
38
+ }
39
+
40
+ reSetInitialShowColumn = () => {
41
+ const { columns }: any = this.props;
42
+
43
+ let showColumns = getShowColumns(columns, []);
44
+ this.setState({
45
+ showColumns,
46
+ })
47
+ }
48
+
49
+ setShowColumns = (newColumns: Array<any>) => {
50
+ this.setState({
51
+ showColumns: [...newColumns]
52
+ })
53
+ }
54
+
55
+ getConfigFromlocalstorage = () => {
56
+ const { tableCode }: any = this.props;
57
+ if (!tableCode) return [];
58
+ let config = localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]';
59
+ let configArray = JSON.parse(config);
60
+ let configSetting = configArray.filter(
61
+ (item:any) => item.code === tableCode,
62
+ );
63
+
64
+ if (configSetting.length) {
65
+ return JSON.parse(configSetting[0].detail || '[]');
66
+ }
67
+ return [];
68
+ };
69
+
70
+ getTableSummaryInfo = () => {
71
+ const { summary = undefined, rowSelection, expandable }: any = this.props;
72
+ const { showColumns }: any = this.state;
73
+ // let summaryRow = rowSelection ? [{}, ...showColumns] : [...showColumns];
74
+ let summaryRow = rowSelection && expandable ? [{}, {}, ...showColumns] : rowSelection || expandable ? [{}, ...showColumns] : [...showColumns]; //兼容table配置展开expandable属性导致汇总列位置不对的问题
75
+ let summaryInitial = summary().cont;
76
+ let summaryDom: any = <Table.Summary fixed>
77
+ <Table.Summary.Row>
78
+ {
79
+ [...summaryRow].map((item: any, index: number) => {
80
+ return (
81
+ <Table.Summary.Cell index={index}>
82
+ <Text type="danger">
83
+ {
84
+ summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key).length ?
85
+ `${item.title}: ${summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key)[0].value}` : ''
86
+
87
+ }
88
+ </Text>
89
+ </Table.Summary.Cell>
90
+ )
91
+ })
92
+ }
93
+ </Table.Summary.Row >
94
+ </Table.Summary>
95
+ return () => summaryDom
96
+ };
97
+
98
+ handledynamicColumns = (col: any[]) => {
99
+ let { dynamicColumns, modeType }: any = this.props;
100
+ col = col.map((item: any) => {
101
+ let target = dynamicColumns.find((d: any) => item.dataIndex === d.key || item.key === d.key)
102
+ if (modeType === 'view' && target) {
103
+ item.render = target?.render;
104
+ }
105
+ return { ...item };
106
+ })
107
+ return [...col]
108
+ };
109
+
110
+ handleResize = (index: any) => (_: any, { size }: any) => {
111
+ let newColumns = this.state.showColumns.map((col: any) => ({ ...col }));
112
+ const handleIndex = (arr: any, indexArr: any) => {
113
+ let i = indexArr.shift();
114
+ if (indexArr.length > 0) {
115
+ handleIndex(arr[i].children, indexArr);
116
+ } else {
117
+ arr[i] = {
118
+ ...arr[i],
119
+ width: size.width,
120
+ };
121
+ handleAntdColumnsSpecialParams(arr[i]);
122
+ }
123
+ };
124
+ handleIndex(newColumns, [...index]);
125
+ this.setState({
126
+ showColumns: [...newColumns]
127
+ })
128
+ };
129
+
130
+ ResizeableTitle = (props: any) => {
131
+ const { onResize, width, ...restProps } = props;
132
+
133
+ if (!width) {
134
+ return <th {...restProps} />;
135
+ }
136
+ return (
137
+ <Resizable
138
+ width={width}
139
+ height={0}
140
+ onResize={onResize}
141
+ draggableOpts={{ enableUserSelectHack: false }}
142
+ >
143
+ <th {...restProps} />
144
+ </Resizable>
145
+ );
146
+ }
147
+
148
+ getTableScrollXWidth = (cols: any[]) => {
149
+ if (cols.every((item: any) => item.width)) {
150
+ return cols.reduce((cur: any, obj: any) => cur += obj.width, 0)
151
+ } else {
152
+ return 'max-content'
153
+ }
154
+ };
155
+
156
+ render() {
157
+ const { columns, tableCode, appRequestConfig, summary = undefined, dynamicColumns = [], scroll={}, ...restProps }: any = this.props;
158
+ let otherTableInfo = {
159
+ ...restProps,
160
+ };
161
+ let showSummary = null;
162
+ if (this.state.showColumns.length) {
163
+ if (summary && summary().diy) {
164
+ showSummary = this.getTableSummaryInfo();
165
+ } else {
166
+ showSummary = summary;
167
+ }
168
+ };
169
+
170
+ const handleColumns = (arr: any, indexArr: any[]) => {
171
+ arr.forEach((item: any, index: any) => {
172
+ let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
173
+ if (noEmptyArray(item.children)) {
174
+ handleColumns(item.children, indexArrInside);
175
+ } else {
176
+ item.width = item.width || getItemDefaultWidth(item);
177
+ item.onHeaderCell = (column: any) => ({
178
+ ...item,
179
+ width:
180
+ typeof column.width === 'number'
181
+ ? column.width
182
+ : parseInt(column.width.replace('px', '')),
183
+ onResize: this.handleResize(indexArrInside),
184
+ });
185
+ }
186
+ })
187
+ };
188
+ let showCol = this.state.showColumns.map((item: any) => {
189
+ handleAntdColumnsSpecialParams(item);
190
+ return ({ ...item })
191
+ })
192
+ handleColumns(showCol, []);
193
+ if (dynamicColumns.length) {
194
+ showCol = this.handledynamicColumns(showCol);
195
+ }
196
+
197
+ otherTableInfo = {
198
+ ...otherTableInfo,
199
+ scroll: {
200
+ y: 400,
201
+ ...scroll,
202
+ x: restProps.overScrollX || this.getTableScrollXWidth(showCol)
203
+ },
204
+ summary: showSummary,
205
+ }
206
+ return (
207
+ <div>
208
+ <div style={{ overflow: 'hidden', padding: '0 8px 10px 0' }}>
209
+ <span style={{ float: 'right' }} className="ant-dropdown-link">
210
+ <ColumnSetting
211
+ setShowColumns={this.setShowColumns}
212
+ showColumns={this.state.showColumns}
213
+ datasource={columns || []}
214
+ reSetInitialShowColumn={this.reSetInitialShowColumn}
215
+ tableCode={tableCode}
216
+ appRequestConfig={appRequestConfig}
217
+ />
218
+ </span>
219
+ </div>
220
+ <Table
221
+ columns={showCol}
222
+ components={{
223
+ header: {
224
+ cell: this.ResizeableTitle,
225
+ },
226
+ }}
227
+ {
228
+ ...otherTableInfo
229
+ }
230
+ />
231
+ </div >
232
+ )
233
+ }
234
+
235
+ }
@@ -0,0 +1,232 @@
1
+ import React, { useState } from 'react';
2
+ import { Table as SulaTable, request } from 'bssula';
3
+ import { Resizable } from 'react-resizable';
4
+ import ColumnSetting from './columnSetting';
5
+ import { getItemDefaultWidth, getShowColumns } from './utils';
6
+ import { noEmptyArray } from './utils';
7
+ import {
8
+ Table,
9
+ Typography,
10
+ } from 'antd';
11
+ import ENUM from '@/utils/enumConfig';
12
+ import { handleBssulaColumnsSpecialParams, parseWidth } from '@/utils/utils';
13
+ const { Text } = Typography;
14
+ export default class ColumnSettingSulaTable extends React.Component {
15
+ sulaTableRef: React.RefObject<unknown>;
16
+ state: any;
17
+ constructor(props: any) {
18
+ super(props);
19
+ this.state = {
20
+ showColumns: [],
21
+ }
22
+ this.sulaTableRef = React.createRef();
23
+ }
24
+
25
+ componentDidMount() {
26
+ const { columns }: any = this.props;
27
+ this.setInitialShowColumn(columns || [])
28
+ }
29
+
30
+ componentWillReceiveProps(nextProps: any) {
31
+ // if (JSON.stringify(this.props.columns) !== JSON.stringify(nextProps.columns)) {
32
+ // }
33
+ this.setInitialShowColumn(nextProps.columns || [])
34
+ }
35
+
36
+ setInitialShowColumn = (columns: any[]) => {
37
+ // 获取当前列表定义数据
38
+ let columnConfig = this.getConfigFromlocalstorage();
39
+ let showColumns = getShowColumns(columns, columnConfig);
40
+ this.setState({
41
+ showColumns,
42
+ })
43
+
44
+ }
45
+
46
+ setShowColumns = (newColumns: Array<any>) => {
47
+ this.setState({
48
+ showColumns: [...newColumns]
49
+ })
50
+ }
51
+
52
+ getConfigFromlocalstorage = () => {
53
+ const { tableCode }:any = this.props;
54
+ if (!tableCode) return [];
55
+ let config = localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]';
56
+ let configArray = JSON.parse(config);
57
+ let configSetting = configArray.filter(
58
+ (item: any) => item.code === tableCode,
59
+ );
60
+
61
+ if (configSetting.length) {
62
+ return JSON.parse(configSetting[0].detail || '[]');
63
+ }
64
+ return [];
65
+ };
66
+
67
+ getTableSummaryInfo = () => {
68
+ const { summary = undefined, rowSelection, expandable }: any = this.props;
69
+ const { showColumns }: any = this.state;
70
+ // let summaryRow = rowSelection ? [{}, ...showColumns] : [...showColumns];
71
+ let summaryRow = rowSelection && expandable ? [{}, {}, ...showColumns] : rowSelection || expandable ? [{}, ...showColumns] : [...showColumns]; //兼容table配置展开expandable属性导致汇总列位置不对的问题
72
+ let summaryInitial = summary().cont;
73
+ let summaryDom: any = <Table.Summary fixed>
74
+ <Table.Summary.Row>
75
+ {
76
+ [...summaryRow].map((item: any, index: number) => {
77
+ return (
78
+ <Table.Summary.Cell index={index}>
79
+ <Text type="danger">
80
+ {
81
+ summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key).length ?
82
+ `${item.title}: ${summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key)[0].value}` : ''
83
+
84
+ }
85
+ </Text>
86
+ </Table.Summary.Cell>
87
+ )
88
+ })
89
+ }
90
+ </Table.Summary.Row >
91
+ </Table.Summary>
92
+ return () => summaryDom
93
+ };
94
+
95
+ handledynamicColumns = (col: any[]) => {
96
+ let { dynamicColumns, modeType }: any = this.props;
97
+ col = col.map((item: any) => {
98
+ let target = dynamicColumns.find((d: any) => item.dataIndex === d.key || item.key === d.key)
99
+ if (modeType === 'view' && target) {
100
+ item.render = target?.render;
101
+ }
102
+ return { ...item };
103
+ })
104
+ return [...col]
105
+ };
106
+
107
+ handleResize = (index: any) => (_: any, { size }: any) => {
108
+ let newColumns = this.state.showColumns.map((col: any) => ({ ...col }));
109
+ const handleIndex = (arr: any, indexArr: any) => {
110
+ let i = indexArr.shift();
111
+ if (indexArr.length > 0) {
112
+ handleIndex(arr[i].children, indexArr);
113
+ } else {
114
+ arr[i] = {
115
+ ...arr[i],
116
+ width: size.width,
117
+ };
118
+ handleBssulaColumnsSpecialParams(arr[i]);
119
+ }
120
+ };
121
+ handleIndex(newColumns, [...index]);
122
+ this.setState({
123
+ showColumns: [...newColumns]
124
+ })
125
+ };
126
+
127
+ ResizeableTitle = (props: any) => {
128
+ const { onResize, width, ...restProps } = props;
129
+
130
+ if (!width) {
131
+ return <th {...restProps} />;
132
+ }
133
+ return (
134
+ <Resizable
135
+ width={width}
136
+ height={0}
137
+ onResize={onResize}
138
+ draggableOpts={{ enableUserSelectHack: false }}
139
+ >
140
+ <th {...restProps} />
141
+ </Resizable>
142
+ );
143
+ }
144
+
145
+ getTableScrollXWidth = (cols: any[]) => {
146
+ if (cols.every((item: any) => item.width)) {
147
+ return cols.reduce((cur: any, obj: any) => cur += obj.width, 0)
148
+ } else {
149
+ return 'max-content'
150
+ }
151
+ };
152
+
153
+ render() {
154
+ const { style=null, columns, tableCode, appRequestConfig, summary = undefined, dynamicColumns = [], scroll={}, ...restProps }: any = this.props;
155
+ let otherTableInfo = {
156
+ ...restProps,
157
+ };
158
+ let showSummary = null;
159
+ if (this.state.showColumns.length) {
160
+ if (summary && summary().diy) {
161
+ showSummary = this.getTableSummaryInfo();
162
+ } else {
163
+ showSummary = summary;
164
+ }
165
+ };
166
+
167
+ const handleColumns = (arr: any, indexArr: any[]) => {
168
+ arr.forEach((item: any, index: any) => {
169
+ let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
170
+ if (noEmptyArray(item.children)) {
171
+ handleColumns(item.children, indexArrInside);
172
+ } else {
173
+ item.width = item.width || getItemDefaultWidth(item);
174
+ item.onHeaderCell = (column: any) => ({
175
+ ...item,
176
+ width: typeof column.width === 'number'
177
+ ? column.width
178
+ : parseWidth(column.width),
179
+ onResize: this.handleResize(indexArrInside),
180
+ });
181
+ }
182
+ })
183
+ };
184
+ let showCol = this.state.showColumns.map((item: any) => {
185
+ handleBssulaColumnsSpecialParams(item);
186
+ return ({ ...item })
187
+ })
188
+ handleColumns(showCol, []);
189
+ if (dynamicColumns.length) {
190
+ showCol = this.handledynamicColumns(showCol);
191
+ }
192
+
193
+ otherTableInfo = {
194
+ ...otherTableInfo,
195
+ scroll: {
196
+ y: 400,
197
+ ...scroll,
198
+ x: restProps.overScrollX || this.getTableScrollXWidth(showCol)
199
+ },
200
+ summary: showSummary,
201
+ }
202
+ return (
203
+ <div>
204
+ <div style={{ overflow: 'hidden', padding: '0 8px 10px 0' }}>
205
+ <span style={{ float: 'right' }} className="ant-dropdown-link">
206
+ <ColumnSetting
207
+ setShowColumns={this.setShowColumns}
208
+ showColumns={this.state.showColumns}
209
+ datasource={columns || []}
210
+ tableCode={tableCode}
211
+ appRequestConfig={appRequestConfig}
212
+ />
213
+ </span>
214
+ </div>
215
+ <SulaTable
216
+ ref={this.sulaTableRef}
217
+ style={style}
218
+ columns={showCol}
219
+ components={{
220
+ header: {
221
+ cell: this.ResizeableTitle,
222
+ },
223
+ }}
224
+ {
225
+ ...otherTableInfo
226
+ }
227
+ />
228
+ </div >
229
+ )
230
+ }
231
+
232
+ }
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import {
3
+ Tooltip,
4
+ } from 'antd';
5
+ /**
6
+ * 非空数组
7
+ * @param arr 要判断的数据
8
+ * @returns boolean
9
+ */
10
+ export const noEmptyArray = (arr: any[]) =>
11
+ Array.isArray(arr) && arr.length > 0;
12
+
13
+ //设置queryTable默认列宽
14
+ export const getItemDefaultWidth = (item: any) => {
15
+ let defaultWidth = 200;
16
+ if (Array.isArray(item.key) || Array.isArray(item.dataIndex)) return defaultWidth;
17
+ let lowerCaseKey = (item.key || item.dataIndex)?.toLowerCase();
18
+ if (!lowerCaseKey) return defaultWidth;
19
+ switch (true) {
20
+ case item?.title === '操作' || lowerCaseKey === 'operate':
21
+ defaultWidth = 60;
22
+ break;
23
+ case lowerCaseKey.indexOf('number') > -1:
24
+ case lowerCaseKey.indexOf('quantity') > -1:
25
+ case lowerCaseKey.indexOf('amount') > -1:
26
+ defaultWidth = 90;
27
+ break;
28
+ case (lowerCaseKey.indexOf('no') > -1):
29
+ defaultWidth = 200;
30
+ break;
31
+ case lowerCaseKey.indexOf('code') > -1:
32
+ defaultWidth = 170;
33
+ break;
34
+ case lowerCaseKey.indexOf('time') > -1:
35
+ defaultWidth = 130;
36
+ break;
37
+ case lowerCaseKey.indexOf('status') > -1:
38
+ defaultWidth = 100;
39
+ break;
40
+ case lowerCaseKey.indexOf('user') > -1:
41
+ defaultWidth = 130;
42
+ break;
43
+ default:
44
+ break;
45
+ }
46
+ return defaultWidth;
47
+ };
48
+
49
+ // 带有toptile 清提示 ...
50
+ export const handleTextOverflow = (
51
+ text: string | undefined,
52
+ width: number = 130,
53
+ ) => {
54
+ return (
55
+ <Tooltip title={text || '-'}>
56
+ <span
57
+ style={{
58
+ width: width ? width + 'px' : '130px',
59
+ display: 'inline-block',
60
+ textOverflow: 'ellipsis',
61
+ overflow: 'hidden',
62
+ whiteSpace: 'nowrap',
63
+ position: 'relative',
64
+ top: '5px',
65
+ }}
66
+ >
67
+ {text || '-'}
68
+ </span>
69
+ </Tooltip>
70
+ );
71
+ };
72
+
73
+ export const getShowColumns = (originColumns: any[], configs: any[]) => {
74
+ let showColumns: any[] = [];
75
+ if (configs.length) {
76
+ configs.forEach(config => {
77
+ let inner = originColumns.filter(innerItem => (
78
+ innerItem.dataIndex && innerItem.dataIndex === config.dataIndex
79
+ ) || (innerItem.key && innerItem.key === config.key))[0];
80
+ inner && showColumns.push({
81
+ ...inner,
82
+ ...config,
83
+ });
84
+ })
85
+ }
86
+ if (showColumns.length) return showColumns;
87
+ return (originColumns || []).filter((item: any) => !item.hidden);
88
+ }
@@ -0,0 +1,87 @@
1
+ import React, {useEffect, useImperativeHandle, useRef, useState} from 'react'
2
+ import {throttle} from "lodash";
3
+ import useSticky from "./hooks/useSticky";
4
+
5
+ function getOffset(node: any) {
6
+ const box = node.getBoundingClientRect();
7
+ const docElem = document.documentElement;
8
+ // < ie8 不支持 win.pageXOffset, 则使用 docElem.scrollLeft
9
+ return {
10
+ left: box.left + (window.pageXOffset || docElem.scrollLeft) -
11
+ (docElem.clientLeft || document.body.clientLeft || 0),
12
+ top: box.top + (window.pageYOffset || docElem.scrollTop) -
13
+ (docElem.clientTop || document.body.clientTop || 0),
14
+ };
15
+ }
16
+
17
+ const FixedScrollBar = ({viewPort, stickyProps}: any, ref: any) => {
18
+ const {isSticky, container} = useSticky(stickyProps)
19
+ const [scrollState, setScrollState] = useState({
20
+ isHiddenScrollBar: !isSticky
21
+ })
22
+ const onContainerScroll = () => {
23
+ if (!viewPort.current) {
24
+ return;
25
+ }
26
+ const tableOffsetTop = getOffset(viewPort.current).top;
27
+ const tableBottomOffset = tableOffsetTop + viewPort.current.offsetHeight;
28
+ const currentClientOffset = document.documentElement.scrollTop + window.innerHeight
29
+ if (
30
+ tableBottomOffset - 1 <= currentClientOffset ||
31
+ tableOffsetTop >= currentClientOffset
32
+ ) {
33
+ setScrollState(state => ({
34
+ ...state,
35
+ isHiddenScrollBar: true,
36
+ }));
37
+ } else {
38
+ ref.current?.scrollTo(viewPort.current.scrollLeft, 0)
39
+ setScrollState(state => ({
40
+ ...state,
41
+ isHiddenScrollBar: false,
42
+ }));
43
+ }
44
+ };
45
+
46
+ useEffect(() => {
47
+ onContainerScroll()
48
+ const onscroll = throttle(onContainerScroll, 50)
49
+ container.addEventListener('scroll', onscroll)
50
+ return () => {
51
+ container.removeEventListener('scroll', onscroll)
52
+ }
53
+ },[])
54
+
55
+ if(scrollState.isHiddenScrollBar){
56
+ return null
57
+ }
58
+
59
+ return (
60
+ <div
61
+ ref={ref}
62
+ onScroll={throttle((e) => {
63
+ // @ts-ignore
64
+ viewPort.current.scrollTo(e.target.scrollLeft, 0)
65
+ }, 50)}
66
+ style={{
67
+ position:'fixed',
68
+ zIndex: '9999',
69
+ bottom: '45px',
70
+ overflowY: 'hidden',
71
+ overflowX: 'auto',
72
+ width: viewPort.current?.offsetWidth || 0,
73
+ background:'#fff',
74
+ opacity: 0.6,
75
+ }}>
76
+ <div
77
+ className={'ant-table-sticky-scroll-bar'}
78
+ style={{
79
+ height: '1px',
80
+ backgroundColor: '#fff',
81
+ width: viewPort.current?.scrollWidth || 0,
82
+ }}></div>
83
+ </div>
84
+ )
85
+ }
86
+
87
+ export default React.forwardRef(FixedScrollBar)
@@ -0,0 +1,21 @@
1
+ import React from 'react'
2
+
3
+ interface TableSticky{
4
+ getContainer?: () => Window | HTMLElement;
5
+ }
6
+
7
+ const useSticky = (sticky: boolean | TableSticky) => {
8
+ const {getContainer = () => window.document} = typeof sticky === 'object' ? sticky : {}
9
+
10
+ const container = getContainer()
11
+ return React.useMemo(() => {
12
+ const isSticky = !!sticky
13
+ return {
14
+ isSticky,
15
+ container,
16
+ }
17
+ },[sticky])
18
+
19
+ }
20
+
21
+ export default useSticky