@bit-sun/business-component 2.1.21 → 2.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) 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/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -1
  9. package/dist/components/Business/BsLayouts/Components/AllFunc/index.d.ts +1 -1
  10. package/dist/components/Business/BsLayouts/Components/RightContent/index.d.ts +2 -2
  11. package/dist/components/Business/BsLayouts/Components/SearchFunc/index.d.ts +2 -2
  12. package/dist/components/Business/BsLayouts/index.d.ts +2 -2
  13. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +2 -2
  14. package/dist/index.esm.js +15948 -19270
  15. package/dist/index.js +15945 -19267
  16. package/dist/utils/TableUtils.d.ts +2 -2
  17. package/dist/utils/utils.d.ts +1 -1
  18. package/docs/index.md +21 -21
  19. package/lib/assets/drag.svg +17 -17
  20. package/lib/assets/exportFail.svg +37 -37
  21. package/lib/assets/exportProcessing.svg +28 -28
  22. package/lib/assets/exportSuccess.svg +34 -34
  23. package/lib/assets/label_icon_bottom.svg +25 -25
  24. package/lib/assets/upExport.svg +22 -22
  25. package/package.json +71 -71
  26. package/src/assets/32.svg +27 -27
  27. package/src/assets/addIcon.svg +17 -17
  28. package/src/assets/allfunc.svg +27 -27
  29. package/src/assets/arrowRight.svg +24 -24
  30. package/src/assets/btn-delete.svg +29 -29
  31. package/src/assets/btn-edit.svg +19 -19
  32. package/src/assets/btn-more.svg +17 -17
  33. package/src/assets/btn-submit.svg +19 -19
  34. package/src/assets/caidan.svg +11 -11
  35. package/src/assets/close.svg +26 -26
  36. package/src/assets/drag.svg +17 -17
  37. package/src/assets/exportFail.svg +37 -37
  38. package/src/assets/exportProcessing.svg +28 -28
  39. package/src/assets/exportSuccess.svg +34 -34
  40. package/src/assets/fixed-left-active.svg +11 -11
  41. package/src/assets/fixed-left.svg +15 -15
  42. package/src/assets/fixed-right-active.svg +11 -11
  43. package/src/assets/fixed-right.svg +15 -15
  44. package/src/assets/guanbi.svg +15 -15
  45. package/src/assets/icon-quanping.svg +15 -15
  46. package/src/assets/icon-shezhi.svg +17 -17
  47. package/src/assets/label_icon_bottom.svg +25 -25
  48. package/src/assets/list-no-img.svg +21 -21
  49. package/src/assets/morentouxiang-32.svg +23 -23
  50. package/src/assets/scanning.svg +24 -24
  51. package/src/assets/upExport.svg +22 -22
  52. package/src/components/Business/AddSelectBusiness/index.md +42 -41
  53. package/src/components/Business/AddSelectBusiness/index.tsx +341 -341
  54. package/src/components/Business/BsLayouts/Components/AllFunc/drawContent.tsx +111 -111
  55. package/src/components/Business/BsLayouts/Components/AllFunc/index.less +153 -153
  56. package/src/components/Business/BsLayouts/Components/AllFunc/index.tsx +70 -70
  57. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.less +90 -90
  58. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.tsx +37 -37
  59. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.tsx +242 -242
  60. package/src/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.tsx +384 -384
  61. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.tsx +285 -285
  62. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.tsx +74 -74
  63. package/src/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/drawContent.less +170 -170
  64. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.less +64 -64
  65. package/src/components/Business/BsLayouts/Components/CustomerMenu/index.tsx +153 -153
  66. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +72 -72
  67. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.tsx +157 -157
  68. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +85 -85
  69. package/src/components/Business/BsLayouts/Components/RightContent/home.less +218 -218
  70. package/src/components/Business/BsLayouts/Components/RightContent/index.tsx +156 -156
  71. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +160 -160
  72. package/src/components/Business/BsLayouts/Components/SearchFunc/index.tsx +75 -75
  73. package/src/components/Business/BsLayouts/index.less +79 -79
  74. package/src/components/Business/BsLayouts/index.tsx +1479 -1479
  75. package/src/components/Business/BsLayouts/service.ts +10 -10
  76. package/src/components/Business/BsLayouts/utils.tsx +230 -230
  77. package/src/components/Business/BsSulaQueryTable/index.less +219 -219
  78. package/src/components/Business/BsSulaQueryTable/index.tsx +476 -476
  79. package/src/components/Business/BsSulaQueryTable/setting.tsx +802 -802
  80. package/src/components/Business/BsSulaQueryTable/utils.less +65 -65
  81. package/src/components/Business/BsSulaQueryTable/utils.tsx +688 -688
  82. package/src/components/Business/CommodityEntry/index.md +70 -70
  83. package/src/components/Business/CommodityEntry/index.tsx +80 -80
  84. package/src/components/Business/CommonAlert/index.tsx +23 -23
  85. package/src/components/Business/CommonGuideWrapper/index.less +111 -111
  86. package/src/components/Business/CommonGuideWrapper/index.md +39 -39
  87. package/src/components/Business/CommonGuideWrapper/index.tsx +83 -83
  88. package/src/components/Business/DetailPageWrapper/index.less +79 -79
  89. package/src/components/Business/DetailPageWrapper/index.tsx +335 -335
  90. package/src/components/Business/DetailPageWrapper/utils.tsx +100 -100
  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/SearchSelect/BusinessUtils.ts +1586 -1586
  95. package/src/components/Business/SearchSelect/common.ts +53 -53
  96. package/src/components/Business/SearchSelect/index.md +1254 -1254
  97. package/src/components/Business/SearchSelect/index.tsx +51 -51
  98. package/src/components/Business/SearchSelect/utils.ts +100 -100
  99. package/src/components/Business/StateFlow/index.less +130 -130
  100. package/src/components/Business/StateFlow/index.md +60 -60
  101. package/src/components/Business/StateFlow/index.tsx +29 -29
  102. package/src/components/Business/TreeSearchSelect/index.md +126 -126
  103. package/src/components/Business/TreeSearchSelect/index.tsx +34 -34
  104. package/src/components/Business/TreeSearchSelect/utils.ts +60 -60
  105. package/src/components/Business/columnSettingTable/columnSetting.tsx +764 -764
  106. package/src/components/Business/columnSettingTable/index.less +247 -247
  107. package/src/components/Business/columnSettingTable/index.md +357 -357
  108. package/src/components/Business/columnSettingTable/index.tsx +232 -232
  109. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +240 -240
  110. package/src/components/Business/columnSettingTable/utils.tsx +68 -68
  111. package/src/components/Business/moreTreeTable/index.less +99 -99
  112. package/src/components/Business/moreTreeTable/index.md +508 -508
  113. package/src/components/Business/moreTreeTable/index.tsx +315 -315
  114. package/src/components/Business/moreTreeTable/utils.ts +126 -126
  115. package/src/components/Functional/AddSelect/index.less +367 -367
  116. package/src/components/Functional/AddSelect/index.md +154 -154
  117. package/src/components/Functional/AddSelect/index.tsx +994 -992
  118. package/src/components/Functional/BillEntry/index.less +371 -371
  119. package/src/components/Functional/BillEntry/index.md +39 -39
  120. package/src/components/Functional/BillEntry/index.tsx +671 -671
  121. package/src/components/Functional/DataImport/index.less +63 -63
  122. package/src/components/Functional/DataImport/index.md +44 -44
  123. package/src/components/Functional/DataImport/index.tsx +695 -695
  124. package/src/components/Functional/DataValidation/index.less +63 -63
  125. package/src/components/Functional/DataValidation/index.md +39 -39
  126. package/src/components/Functional/DataValidation/index.tsx +687 -687
  127. package/src/components/Functional/ExportFunctions/ExportIcon/index.md +37 -37
  128. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +59 -59
  129. package/src/components/Functional/QueryMutipleInput/index.less +37 -37
  130. package/src/components/Functional/QueryMutipleInput/index.md +33 -33
  131. package/src/components/Functional/QueryMutipleInput/index.tsx +128 -128
  132. package/src/components/Functional/SearchSelect/index.less +115 -115
  133. package/src/components/Functional/SearchSelect/index.md +141 -141
  134. package/src/components/Functional/SearchSelect/index.tsx +813 -813
  135. package/src/components/Functional/SearchSelect/utils.ts +6 -6
  136. package/src/components/Functional/TreeSearchSelect/index.md +47 -47
  137. package/src/components/Functional/TreeSearchSelect/index.tsx +149 -149
  138. package/src/index.ts +32 -32
  139. package/src/styles/bsDefault.less +1906 -1906
  140. package/src/utils/CheckOneUser/index.md +39 -39
  141. package/src/utils/CheckOneUser/index.ts +51 -51
  142. package/src/utils/TableUtils.tsx +18 -18
  143. package/src/utils/checkUtils.ts +39 -39
  144. package/src/utils/enumConfig.ts +10 -10
  145. package/src/utils/index.ts +2 -2
  146. package/src/utils/requestUtils.ts +33 -33
  147. package/src/utils/utils.ts +142 -142
  148. package/tsconfig.json +29 -29
  149. package/typings.d.ts +4 -4
@@ -1,241 +1,241 @@
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, handleTextOverflow } 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 } 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 = columnConfig.length ? columnConfig.map((item:any) => {
40
- let inner = columns.filter(innerItem => (
41
- innerItem.dataIndex && innerItem.dataIndex === item.dataIndex
42
- ) || (innerItem.key && innerItem.key === item.key))[0];
43
- return {
44
- ...inner,
45
- ...item,
46
- }
47
- }).filter((item: any) => !item.hidden)
48
- :
49
- (columns || []).filter((item: any) => !item.hidden);
50
- this.setState({
51
- showColumns,
52
- })
53
-
54
- }
55
-
56
- setShowColumns = (newColumns: Array<any>) => {
57
- this.setState({
58
- showColumns: [...newColumns]
59
- })
60
- }
61
-
62
- getConfigFromlocalstorage = () => {
63
- const { tableCode }:any = this.props;
64
- if (!tableCode) return [];
65
- let config = localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]';
66
- let configArray = JSON.parse(config);
67
- let configSetting = configArray.filter(
68
- (item: any) => item.code === tableCode,
69
- );
70
-
71
- if (configSetting.length) {
72
- return JSON.parse(configSetting[0].detail || '[]');
73
- }
74
- return [];
75
- };
76
-
77
- getTableSummaryInfo = () => {
78
- const { summary = undefined, rowSelection }: any = this.props;
79
- const { showColumns }: any = this.state;
80
- let summaryRow = rowSelection ? [{}, ...showColumns] : [...showColumns];
81
- let summaryInitial = summary().cont;
82
- let summaryDom: any = <Table.Summary fixed>
83
- <Table.Summary.Row>
84
- {
85
- [...summaryRow].map((item: any, index: number) => {
86
- return (
87
- <Table.Summary.Cell index={index}>
88
- <Text type="danger">
89
- {
90
- summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key).length ?
91
- `${item.title}: ${summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key)[0].value}` : ''
92
-
93
- }
94
- </Text>
95
- </Table.Summary.Cell>
96
- )
97
- })
98
- }
99
- </Table.Summary.Row >
100
- </Table.Summary>
101
- return () => summaryDom
102
- };
103
-
104
- handledynamicColumns = (col: any[]) => {
105
- let { dynamicColumns, modeType }: any = this.props;
106
- col = col.map((item: any) => {
107
- let target = dynamicColumns.find((d: any) => item.dataIndex === d.key || item.key === d.key)
108
- if (modeType === 'view' && target) {
109
- item.render = target?.render;
110
- }
111
- return { ...item };
112
- })
113
- return [...col]
114
- };
115
-
116
- handleResize = (index: any) => (_: any, { size }: any) => {
117
- let newColumns = this.state.showColumns.map((col: any) => ({ ...col }));
118
- const handleIndex = (arr: any, indexArr: any) => {
119
- let i = indexArr.shift();
120
- if (indexArr.length > 0) {
121
- handleIndex(arr[i].children, indexArr);
122
- } else {
123
- arr[i] = {
124
- ...arr[i],
125
- width: size.width,
126
- };
127
- handleBssulaColumnsSpecialParams(arr[i]);
128
- }
129
- };
130
- handleIndex(newColumns, [...index]);
131
- this.setState({
132
- showColumns: [...newColumns]
133
- })
134
- };
135
-
136
- ResizeableTitle = (props: any) => {
137
- const { onResize, width, ...restProps } = props;
138
-
139
- if (!width) {
140
- return <th {...restProps} />;
141
- }
142
- return (
143
- <Resizable
144
- width={width}
145
- height={0}
146
- onResize={onResize}
147
- draggableOpts={{ enableUserSelectHack: false }}
148
- >
149
- <th {...restProps} />
150
- </Resizable>
151
- );
152
- }
153
-
154
- getTableScrollXWidth = (cols: any[]) => {
155
- if (cols.every((item: any) => item.width)) {
156
- return cols.reduce((cur: any, obj: any) => cur += obj.width, 0)
157
- } else {
158
- return 'max-content'
159
- }
160
- };
161
-
162
- render() {
163
- const { style=null, columns, tableCode, summary = undefined, dynamicColumns = [], scroll={}, ...restProps }: any = this.props;
164
- let otherTableInfo = {
165
- ...restProps,
166
- };
167
- let showSummary = null;
168
- if (this.state.showColumns.length) {
169
- if (summary && summary().diy) {
170
- showSummary = this.getTableSummaryInfo();
171
- } else {
172
- showSummary = summary;
173
- }
174
- };
175
-
176
- const handleColumns = (arr: any, indexArr: any[]) => {
177
- arr.forEach((item: any, index: any) => {
178
- let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
179
- if (noEmptyArray(item.children)) {
180
- handleColumns(item.children, indexArrInside);
181
- } else {
182
- item.width = item.width || getItemDefaultWidth(item);
183
- item.onHeaderCell = (column: any) => ({
184
- ...item,
185
- width:
186
- typeof column.width === 'number'
187
- ? column.width
188
- : parseInt(column.width.replace('px', '')),
189
- onResize: this.handleResize(indexArrInside),
190
- });
191
- }
192
- })
193
- };
194
- let showCol = this.state.showColumns.map((item: any) => {
195
- handleBssulaColumnsSpecialParams(item);
196
- return ({ ...item })
197
- })
198
- handleColumns(showCol, []);
199
- if (dynamicColumns.length) {
200
- showCol = this.handledynamicColumns(showCol);
201
- }
202
-
203
- otherTableInfo = {
204
- ...otherTableInfo,
205
- scroll: {
206
- y: 400,
207
- ...scroll,
208
- x: restProps.overScrollX || this.getTableScrollXWidth(showCol)
209
- },
210
- summary: showSummary,
211
- }
212
- return (
213
- <div>
214
- <div style={{ overflow: 'hidden', padding: '0 8px 10px 0' }}>
215
- <span style={{ float: 'right' }} className="ant-dropdown-link">
216
- <ColumnSetting
217
- setShowColumns={this.setShowColumns}
218
- showColumns={this.state.showColumns}
219
- datasource={columns || []}
220
- tableCode={tableCode}
221
- />
222
- </span>
223
- </div>
224
- <SulaTable
225
- ref={this.sulaTableRef}
226
- style={style}
227
- columns={showCol}
228
- components={{
229
- header: {
230
- cell: this.ResizeableTitle,
231
- },
232
- }}
233
- {
234
- ...otherTableInfo
235
- }
236
- />
237
- </div >
238
- )
239
- }
240
-
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, handleTextOverflow } 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 } 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 = columnConfig.length ? columnConfig.map((item:any) => {
40
+ let inner = columns.filter(innerItem => (
41
+ innerItem.dataIndex && innerItem.dataIndex === item.dataIndex
42
+ ) || (innerItem.key && innerItem.key === item.key))[0];
43
+ return {
44
+ ...inner,
45
+ ...item,
46
+ }
47
+ }).filter((item: any) => !item.hidden)
48
+ :
49
+ (columns || []).filter((item: any) => !item.hidden);
50
+ this.setState({
51
+ showColumns,
52
+ })
53
+
54
+ }
55
+
56
+ setShowColumns = (newColumns: Array<any>) => {
57
+ this.setState({
58
+ showColumns: [...newColumns]
59
+ })
60
+ }
61
+
62
+ getConfigFromlocalstorage = () => {
63
+ const { tableCode }:any = this.props;
64
+ if (!tableCode) return [];
65
+ let config = localStorage.getItem(ENUM.BROWSER_CACHE.COLUMN_CONDITION) || '[]';
66
+ let configArray = JSON.parse(config);
67
+ let configSetting = configArray.filter(
68
+ (item: any) => item.code === tableCode,
69
+ );
70
+
71
+ if (configSetting.length) {
72
+ return JSON.parse(configSetting[0].detail || '[]');
73
+ }
74
+ return [];
75
+ };
76
+
77
+ getTableSummaryInfo = () => {
78
+ const { summary = undefined, rowSelection }: any = this.props;
79
+ const { showColumns }: any = this.state;
80
+ let summaryRow = rowSelection ? [{}, ...showColumns] : [...showColumns];
81
+ let summaryInitial = summary().cont;
82
+ let summaryDom: any = <Table.Summary fixed>
83
+ <Table.Summary.Row>
84
+ {
85
+ [...summaryRow].map((item: any, index: number) => {
86
+ return (
87
+ <Table.Summary.Cell index={index}>
88
+ <Text type="danger">
89
+ {
90
+ summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key).length ?
91
+ `${item.title}: ${summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key)[0].value}` : ''
92
+
93
+ }
94
+ </Text>
95
+ </Table.Summary.Cell>
96
+ )
97
+ })
98
+ }
99
+ </Table.Summary.Row >
100
+ </Table.Summary>
101
+ return () => summaryDom
102
+ };
103
+
104
+ handledynamicColumns = (col: any[]) => {
105
+ let { dynamicColumns, modeType }: any = this.props;
106
+ col = col.map((item: any) => {
107
+ let target = dynamicColumns.find((d: any) => item.dataIndex === d.key || item.key === d.key)
108
+ if (modeType === 'view' && target) {
109
+ item.render = target?.render;
110
+ }
111
+ return { ...item };
112
+ })
113
+ return [...col]
114
+ };
115
+
116
+ handleResize = (index: any) => (_: any, { size }: any) => {
117
+ let newColumns = this.state.showColumns.map((col: any) => ({ ...col }));
118
+ const handleIndex = (arr: any, indexArr: any) => {
119
+ let i = indexArr.shift();
120
+ if (indexArr.length > 0) {
121
+ handleIndex(arr[i].children, indexArr);
122
+ } else {
123
+ arr[i] = {
124
+ ...arr[i],
125
+ width: size.width,
126
+ };
127
+ handleBssulaColumnsSpecialParams(arr[i]);
128
+ }
129
+ };
130
+ handleIndex(newColumns, [...index]);
131
+ this.setState({
132
+ showColumns: [...newColumns]
133
+ })
134
+ };
135
+
136
+ ResizeableTitle = (props: any) => {
137
+ const { onResize, width, ...restProps } = props;
138
+
139
+ if (!width) {
140
+ return <th {...restProps} />;
141
+ }
142
+ return (
143
+ <Resizable
144
+ width={width}
145
+ height={0}
146
+ onResize={onResize}
147
+ draggableOpts={{ enableUserSelectHack: false }}
148
+ >
149
+ <th {...restProps} />
150
+ </Resizable>
151
+ );
152
+ }
153
+
154
+ getTableScrollXWidth = (cols: any[]) => {
155
+ if (cols.every((item: any) => item.width)) {
156
+ return cols.reduce((cur: any, obj: any) => cur += obj.width, 0)
157
+ } else {
158
+ return 'max-content'
159
+ }
160
+ };
161
+
162
+ render() {
163
+ const { style=null, columns, tableCode, summary = undefined, dynamicColumns = [], scroll={}, ...restProps }: any = this.props;
164
+ let otherTableInfo = {
165
+ ...restProps,
166
+ };
167
+ let showSummary = null;
168
+ if (this.state.showColumns.length) {
169
+ if (summary && summary().diy) {
170
+ showSummary = this.getTableSummaryInfo();
171
+ } else {
172
+ showSummary = summary;
173
+ }
174
+ };
175
+
176
+ const handleColumns = (arr: any, indexArr: any[]) => {
177
+ arr.forEach((item: any, index: any) => {
178
+ let indexArrInside = [...indexArr, index].filter((i: any) => i || i === 0)
179
+ if (noEmptyArray(item.children)) {
180
+ handleColumns(item.children, indexArrInside);
181
+ } else {
182
+ item.width = item.width || getItemDefaultWidth(item);
183
+ item.onHeaderCell = (column: any) => ({
184
+ ...item,
185
+ width:
186
+ typeof column.width === 'number'
187
+ ? column.width
188
+ : parseInt(column.width.replace('px', '')),
189
+ onResize: this.handleResize(indexArrInside),
190
+ });
191
+ }
192
+ })
193
+ };
194
+ let showCol = this.state.showColumns.map((item: any) => {
195
+ handleBssulaColumnsSpecialParams(item);
196
+ return ({ ...item })
197
+ })
198
+ handleColumns(showCol, []);
199
+ if (dynamicColumns.length) {
200
+ showCol = this.handledynamicColumns(showCol);
201
+ }
202
+
203
+ otherTableInfo = {
204
+ ...otherTableInfo,
205
+ scroll: {
206
+ y: 400,
207
+ ...scroll,
208
+ x: restProps.overScrollX || this.getTableScrollXWidth(showCol)
209
+ },
210
+ summary: showSummary,
211
+ }
212
+ return (
213
+ <div>
214
+ <div style={{ overflow: 'hidden', padding: '0 8px 10px 0' }}>
215
+ <span style={{ float: 'right' }} className="ant-dropdown-link">
216
+ <ColumnSetting
217
+ setShowColumns={this.setShowColumns}
218
+ showColumns={this.state.showColumns}
219
+ datasource={columns || []}
220
+ tableCode={tableCode}
221
+ />
222
+ </span>
223
+ </div>
224
+ <SulaTable
225
+ ref={this.sulaTableRef}
226
+ style={style}
227
+ columns={showCol}
228
+ components={{
229
+ header: {
230
+ cell: this.ResizeableTitle,
231
+ },
232
+ }}
233
+ {
234
+ ...otherTableInfo
235
+ }
236
+ />
237
+ </div >
238
+ )
239
+ }
240
+
241
241
  }
@@ -1,69 +1,69 @@
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
- let lowerCaseKey = (item.key || item.dataIndex).toLowerCase();
17
- switch (true) {
18
- case item?.title === '操作' || lowerCaseKey === 'operate':
19
- defaultWidth = 60;
20
- break;
21
- case lowerCaseKey.indexOf('number') > -1:
22
- case lowerCaseKey.indexOf('quantity') > -1:
23
- case lowerCaseKey.indexOf('amount') > -1:
24
- defaultWidth = 90;
25
- break;
26
- case (lowerCaseKey.indexOf('no') > -1):
27
- defaultWidth = 200;
28
- break;
29
- case lowerCaseKey.indexOf('code') > -1:
30
- defaultWidth = 170;
31
- break;
32
- case lowerCaseKey.indexOf('time') > -1:
33
- defaultWidth = 130;
34
- break;
35
- case lowerCaseKey.indexOf('status') > -1:
36
- defaultWidth = 100;
37
- break;
38
- case lowerCaseKey.indexOf('user') > -1:
39
- defaultWidth = 130;
40
- break;
41
- default:
42
- break;
43
- }
44
- return defaultWidth;
45
- };
46
-
47
- // 带有toptile 清提示 ...
48
- export const handleTextOverflow = (
49
- text: string | undefined,
50
- width: number = 130,
51
- ) => {
52
- return (
53
- <Tooltip title={text || '- -'}>
54
- <span
55
- style={{
56
- width: width ? width + 'px' : '130px',
57
- display: 'inline-block',
58
- textOverflow: 'ellipsis',
59
- overflow: 'hidden',
60
- whiteSpace: 'nowrap',
61
- position: 'relative',
62
- top: '5px',
63
- }}
64
- >
65
- {text || '- -'}
66
- </span>
67
- </Tooltip>
68
- );
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
+ let lowerCaseKey = (item.key || item.dataIndex).toLowerCase();
17
+ switch (true) {
18
+ case item?.title === '操作' || lowerCaseKey === 'operate':
19
+ defaultWidth = 60;
20
+ break;
21
+ case lowerCaseKey.indexOf('number') > -1:
22
+ case lowerCaseKey.indexOf('quantity') > -1:
23
+ case lowerCaseKey.indexOf('amount') > -1:
24
+ defaultWidth = 90;
25
+ break;
26
+ case (lowerCaseKey.indexOf('no') > -1):
27
+ defaultWidth = 200;
28
+ break;
29
+ case lowerCaseKey.indexOf('code') > -1:
30
+ defaultWidth = 170;
31
+ break;
32
+ case lowerCaseKey.indexOf('time') > -1:
33
+ defaultWidth = 130;
34
+ break;
35
+ case lowerCaseKey.indexOf('status') > -1:
36
+ defaultWidth = 100;
37
+ break;
38
+ case lowerCaseKey.indexOf('user') > -1:
39
+ defaultWidth = 130;
40
+ break;
41
+ default:
42
+ break;
43
+ }
44
+ return defaultWidth;
45
+ };
46
+
47
+ // 带有toptile 清提示 ...
48
+ export const handleTextOverflow = (
49
+ text: string | undefined,
50
+ width: number = 130,
51
+ ) => {
52
+ return (
53
+ <Tooltip title={text || '- -'}>
54
+ <span
55
+ style={{
56
+ width: width ? width + 'px' : '130px',
57
+ display: 'inline-block',
58
+ textOverflow: 'ellipsis',
59
+ overflow: 'hidden',
60
+ whiteSpace: 'nowrap',
61
+ position: 'relative',
62
+ top: '5px',
63
+ }}
64
+ >
65
+ {text || '- -'}
66
+ </span>
67
+ </Tooltip>
68
+ );
69
69
  };