@bit-sun/business-component 4.0.13-alpha.8 → 4.2.0-aiwei-alpha.1

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/.umirc.ts +21 -10
  2. package/dist/components/Business/AddSelectBusiness/index.d.ts +3 -4
  3. package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -2
  4. package/dist/components/Business/BsLayouts/Components/ChooseStore/index.d.ts +1 -2
  5. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
  6. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +1 -1
  7. package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +2 -2
  8. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +1 -2
  9. package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +1 -2
  10. package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
  11. package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +1 -2
  12. package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +1 -2
  13. package/dist/components/Business/BsLayouts/index.d.ts +1 -1
  14. package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +5 -5
  15. package/dist/components/Business/BsSulaQueryTable/index.d.ts +1 -2
  16. package/dist/components/Business/BsSulaQueryTable/setting.d.ts +11 -8
  17. package/dist/components/Business/BsSulaQueryTable/utils.d.ts +14 -15
  18. package/dist/components/Business/CommodityEntry/index.d.ts +1 -2
  19. package/dist/components/Business/CommonAlert/index.d.ts +1 -2
  20. package/dist/components/Business/CommonGuideWrapper/index.d.ts +3 -3
  21. package/dist/components/Business/DetailPageWrapper/index.d.ts +11 -6
  22. package/dist/components/Business/HomePageWrapper/index.d.ts +1 -2
  23. package/dist/components/Business/ItemPropertySelector/index.d.ts +2 -0
  24. package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +1 -2
  25. package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +1 -2
  26. package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +1 -2
  27. package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +1 -2
  28. package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +1 -2
  29. package/dist/components/Business/ModalUtils/index.d.ts +8 -0
  30. package/dist/components/Business/PropertyModal/index.d.ts +1 -2
  31. package/dist/components/Business/PropertyModal/propertyGroup.d.ts +1 -1
  32. package/dist/components/Business/SearchSelect/index.d.ts +1 -1
  33. package/dist/components/Business/SearchSelect/utils.d.ts +4 -2
  34. package/dist/components/Business/StateFlow/index.d.ts +1 -2
  35. package/dist/components/Business/SystemLog/index.d.ts +78 -0
  36. package/dist/components/Business/TreeSearchSelect/index.d.ts +1 -1
  37. package/dist/components/Business/columnSettingTable/columnSetting.d.ts +9 -8
  38. package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +1 -2
  39. package/dist/components/Business/columnSettingTable/index.d.ts +21 -4
  40. package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +22 -5
  41. package/dist/components/Business/columnSettingTable/utils.d.ts +1 -2
  42. package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
  43. package/dist/components/Common/ParagraphCopier/index.d.ts +1 -1
  44. package/dist/components/Common/Section/index.d.ts +1 -1
  45. package/dist/components/Functional/AddSelect/index.d.ts +1 -2
  46. package/dist/components/Functional/AuthButton/index.d.ts +1 -2
  47. package/dist/components/Functional/DataImport/index.d.ts +3 -3
  48. package/dist/components/Functional/DataValidation/index.d.ts +15 -5
  49. package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +1 -2
  50. package/dist/components/Functional/QueryMutipleInput/index.d.ts +3 -3
  51. package/dist/components/Functional/QueryMutipleSelect/index.d.ts +1 -2
  52. package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
  53. package/dist/components/Functional/SearchSelect/utils.d.ts +4 -4
  54. package/dist/components/Functional/TreeSearchSelect/index.d.ts +1 -2
  55. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +1 -1
  56. package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +1 -2
  57. package/dist/components/Solution/RuleComponent/Formula.d.ts +1 -2
  58. package/dist/components/Solution/RuleComponent/InnerSelect.d.ts +1 -2
  59. package/dist/components/Solution/RuleComponent/RenderCompItem.d.ts +1 -2
  60. package/dist/components/Solution/RuleSetter/RuleInstance.d.ts +1 -2
  61. package/dist/components/Solution/RuleSetter/baseRule.d.ts +1 -1
  62. package/dist/components/Solution/RuleSetter/index.d.ts +1 -1
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.esm.js +4206 -2108
  65. package/dist/index.js +4215 -2106
  66. package/dist/plugin/TableColumnSetting/index.d.ts +6 -5
  67. package/dist/utils/RequestCacheManager.d.ts +82 -0
  68. package/dist/utils/TableUtils.d.ts +18 -19
  69. package/dist/utils/cachedRequest.d.ts +76 -0
  70. package/dist/utils/index.d.ts +1 -0
  71. package/dist/utils/utils.d.ts +41 -0
  72. package/package.json +16 -14
  73. package/src/assets/btn-cancel.svg +3 -0
  74. package/src/assets/btn-copy.svg +3 -0
  75. package/src/assets/btn-delete.svg +2 -29
  76. package/src/assets/btn-edit.svg +2 -19
  77. package/src/assets/btn-hangUp.svg +3 -0
  78. package/src/assets/btn-print.svg +3 -0
  79. package/src/assets/btn-refresh.svg +3 -0
  80. package/src/assets/btn-unhook.svg +3 -0
  81. package/src/components/Business/AddSelectBusiness/index.md +8 -2
  82. package/src/components/Business/AddSelectBusiness/index.tsx +4 -1
  83. package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +1 -1
  84. package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +1 -1
  85. package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +1 -1
  86. package/src/components/Business/BsLayouts/Components/RightContent/home.less +1 -1
  87. package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +2 -2
  88. package/src/components/Business/BsLayouts/service.ts +1 -1
  89. package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +6 -5
  90. package/src/components/Business/BsSulaQueryTable/index.less +5 -3
  91. package/src/components/Business/BsSulaQueryTable/index.md +45 -32
  92. package/src/components/Business/BsSulaQueryTable/index.tsx +154 -76
  93. package/src/components/Business/BsSulaQueryTable/setting.tsx +47 -11
  94. package/src/components/Business/BsSulaQueryTable/utils.less +1 -1
  95. package/src/components/Business/BsSulaQueryTable/utils.tsx +15 -12
  96. package/src/components/Business/CommodityEntry/index.md +1 -1
  97. package/src/components/Business/CommodityEntry/index.tsx +11 -9
  98. package/src/components/Business/DetailPageWrapper/index.less +1 -1
  99. package/src/components/Business/DetailPageWrapper/index.tsx +24 -5
  100. package/src/components/Business/DetailPageWrapper/utils.tsx +7 -2
  101. package/src/components/Business/HomePageWrapper/index.less +1 -1
  102. package/src/components/Business/ItemPropertySelector/index.tsx +88 -0
  103. package/src/components/Business/JsonQueryTable/function.ts +1 -1
  104. package/src/components/Business/JsonQueryTable/index.tsx +1 -1
  105. package/src/components/Business/ModalUtils/index.tsx +45 -0
  106. package/src/components/Business/PropertyModal/index.tsx +1 -1
  107. package/src/components/Business/SearchSelect/BusinessUtils.tsx +625 -76
  108. package/src/components/Business/SearchSelect/index.md +4 -4
  109. package/src/components/Business/SearchSelect/utils.ts +27 -5
  110. package/src/components/Business/SystemLog/index.md +37 -0
  111. package/src/components/Business/SystemLog/index.tsx +87 -0
  112. package/src/components/Business/columnSettingTable/columnSetting.tsx +28 -12
  113. package/src/components/Business/columnSettingTable/index.less +5 -3
  114. package/src/components/Business/columnSettingTable/index.md +200 -136
  115. package/src/components/Business/columnSettingTable/index.tsx +168 -39
  116. package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +188 -56
  117. package/src/components/Functional/AddSelect/helps.ts +1 -1
  118. package/src/components/Functional/AddSelect/index.tsx +132 -13
  119. package/src/components/Functional/BillEntry/index.less +3 -0
  120. package/src/components/Functional/BillEntry/index.tsx +1 -1
  121. package/src/components/Functional/DataImport/index.tsx +1 -1
  122. package/src/components/Functional/DataValidation/index.md +1 -0
  123. package/src/components/Functional/DataValidation/index.tsx +161 -27
  124. package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +1 -1
  125. package/src/components/Functional/QueryMutipleInput/index.tsx +12 -3
  126. package/src/components/Functional/QueryMutipleSelect/index.tsx +3 -2
  127. package/src/components/Functional/SearchSelect/index.less +4 -0
  128. package/src/components/Functional/SearchSelect/index.tsx +68 -24
  129. package/src/components/Functional/SearchSelect/utils.tsx +17 -11
  130. package/src/components/Functional/TreeSearchSelect/index.tsx +3 -2
  131. package/src/components/Solution/RuleComponent/InnerSelect.tsx +1 -0
  132. package/src/components/Solution/RuleComponent/RenderCompItem.tsx +11 -2
  133. package/src/components/Solution/RuleComponent/index.js +75 -4
  134. package/src/components/Solution/RuleComponent/ruleFiled.js +26 -2
  135. package/src/components/Solution/RuleComponent/services.ts +1 -1
  136. package/src/components/Solution/RuleSetter/service.js +1 -1
  137. package/src/index.ts +3 -0
  138. package/src/plugin/TableColumnSetting/index.less +5 -3
  139. package/src/plugin/TableColumnSetting/index.tsx +80 -13
  140. package/src/styles/bsDefault.less +9 -3
  141. package/src/utils/RequestCacheManager.ts +213 -0
  142. package/src/utils/RequestCache_Examples.md +137 -0
  143. package/src/utils/RequestCache_README.md +170 -0
  144. package/src/utils/TableUtils.less +1 -1
  145. package/src/utils/cachedRequest.ts +288 -0
  146. package/src/utils/index.ts +1 -0
  147. package/src/utils/request.ts +8 -4
  148. package/src/utils/requestUtils.ts +1 -1
  149. package/src/utils/utils.ts +41 -1
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
3
  import { Table as SulaTable, request } from 'bssula';
3
4
  import { Resizable } from 'react-resizable';
@@ -14,35 +15,46 @@ import TableSumComponent from './components/TableSumComponent';
14
15
  const { Text } = Typography;
15
16
 
16
17
  export default class ColumnSettingSulaTable extends React.Component {
17
- sulaTableRef: React.RefObject<unknown>;
18
+ sulaTableRef: React.RefObject<any>;
18
19
  state: any;
19
20
  constructor(props: any) {
20
21
  super(props);
21
22
  this.state = {
22
23
  showColumns: [],
24
+ selectedRowKeys: [], // 新增状态,用于跟踪选中的行的键
25
+ selectedRows: [],
26
+ showSummary: null
23
27
  }
24
- this.sulaTableRef = React.createRef();
28
+ this.sulaTableRef = React.createRef<any>();
25
29
  }
26
30
 
27
31
  componentDidMount() {
28
- const { columns }: any = this.props;
29
- this.setInitialShowColumn(columns || [])
32
+ const { columns, updateSummary }: any = this.props;
33
+ this.setInitialShowColumn(columns || [], () => {
34
+ // 首次加载时调用 recalculateSummary 方法
35
+ this.recalculateSummary(updateSummary || '');
36
+ });
30
37
  }
31
38
 
32
39
  componentWillReceiveProps(nextProps: any) {
33
40
  // if (JSON.stringify(this.props.columns) !== JSON.stringify(nextProps.columns)) {
34
41
  // }
35
- this.setInitialShowColumn(nextProps.columns || [])
36
- }
37
42
 
38
- setInitialShowColumn = (columns: any[]) => {
43
+ this.setInitialShowColumn(nextProps.columns || [], () => {
44
+ this.recalculateSummary(nextProps.updateSummary);
45
+ });
46
+ if(nextProps.newUpdateSummary){
47
+ this.recalculateSummary(nextProps.newUpdateSummary);
48
+ }
49
+ };
50
+
51
+ setInitialShowColumn = (columns: any[], callback?: () => void) => {
39
52
  // 获取当前列表定义数据
40
53
  let columnConfig = this.getConfigFromlocalstorage();
41
54
  let showColumns = getShowColumns(columns, columnConfig);
42
55
  this.setState({
43
- showColumns,
44
- })
45
-
56
+ showColumns
57
+ }, callback);
46
58
  }
47
59
 
48
60
  setShowColumns = (newColumns: Array<any>) => {
@@ -66,32 +78,98 @@ export default class ColumnSettingSulaTable extends React.Component {
66
78
  return [];
67
79
  };
68
80
 
81
+ /**
82
+ * 新增函数,用于根据传入的小数位数进行四舍五入
83
+ * @param number
84
+ * @param decimalPlaces
85
+ * @returns
86
+ */
87
+ roundToDecimalPlaces = (number: any, decimalPlaces: number) => {
88
+ const factor = Math.pow(10, (decimalPlaces || 2));
89
+ return Math.round(Number(number || 0) * factor) / factor;
90
+ };
91
+
92
+ /**
93
+ * 合计行逻辑
94
+ * @returns
95
+ */
69
96
  getTableSummaryInfo = () => {
70
- const { summary = undefined, rowSelection, expandable }: any = this.props;
71
- const { showColumns }: any = this.state;
72
- // let summaryRow = rowSelection ? [{}, ...showColumns] : [...showColumns];
73
- let summaryRow = rowSelection && expandable ? [{}, {}, ...showColumns] : rowSelection || expandable ? [{}, ...showColumns] : [...showColumns]; //兼容table配置展开expandable属性导致汇总列位置不对的问题
74
- let summaryInitial = summary().cont;
75
- let summaryDom: any = <Table.Summary fixed>
76
- <Table.Summary.Row>
77
- {
78
- [...summaryRow].map((item: any, index: number) => {
97
+ const { summary = undefined, rowSelection, expandable, isSpecial = false, modeType }: any = this.props;
98
+ const { showColumns } = this.state;
99
+
100
+ const generateSummaryRow = () => {
101
+ if (rowSelection && expandable) {
102
+ return [{}, {}, ...showColumns];
103
+ } else if (rowSelection || expandable || isSpecial) {
104
+ return [{}, ...showColumns];
105
+ }
106
+ return [...showColumns];
107
+ };
108
+
109
+ const summaryRow = generateSummaryRow();
110
+
111
+ let summaryInitial: any = [];
112
+ // 完善判断逻辑
113
+ if (typeof summary === 'function') {
114
+ const summaryResult = summary();
115
+ if (summaryResult.diy && !Array.isArray(summaryResult)) {
116
+ summaryInitial = summaryResult.cont;
117
+ }
118
+ } else if (typeof summary === 'object' && summary !== null && summary.diy && !Array.isArray(summary)) {
119
+ summaryInitial = summary.cont;
120
+ }
121
+
122
+ //let offset = 0;
123
+ let validSummaryRow = summaryRow;
124
+ // if (summaryInitial && summaryInitial.length > 0) {
125
+ // summaryRow.filter((item) => {
126
+ // if (Object.keys(item).length === 0) {
127
+ // offset++;
128
+ // return false;
129
+ // }
130
+ // return true;
131
+ // });
132
+ // }
133
+
134
+ const dataSource = this.sulaTableRef?.current?.getDataSource() || [];
135
+
136
+ const summaryDom = (
137
+ <Table.Summary fixed>
138
+ <Table.Summary.Row>
139
+ {validSummaryRow.map((item, index) => {
140
+ const actualIndex = index;
141
+ let cellContent;
142
+
143
+ if (item.showTotal) {
144
+ cellContent = <Text type="danger">合计</Text>;
145
+ } else if (summaryInitial && summaryInitial.length > 0) {
146
+ const matchedItem = summaryInitial.find((inner: any) => inner.key === item.dataIndex || inner.key === item.key);
147
+ cellContent = <Text type="danger">{matchedItem ? matchedItem.value : ''}</Text>;
148
+ } else {
149
+ if (item.showSummary) {
150
+ const sum = dataSource.reduce((acc: any, record: any) => {
151
+ const value = record[item.dataIndex];
152
+ return acc + Number(value || 0);
153
+ }, 0);
154
+ const decimalPlaces = item.showDigit || 2;
155
+ const roundedSum = this.roundToDecimalPlaces(sum, decimalPlaces);
156
+ cellContent = <Text type="danger">{roundedSum}</Text>;
157
+ } else {
158
+ cellContent = <Text type="danger"></Text>;
159
+ }
160
+ }
161
+
79
162
  return (
80
- <Table.Summary.Cell index={index}>
81
- <Text type="danger">
82
- {
83
- summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key).length ?
84
- `${item.title}: ${summaryInitial.filter((inner: any) => inner.key === item.dataIndex || inner.key === item.key)[0].value}` : ''
85
-
86
- }
87
- </Text>
163
+ <Table.Summary.Cell index={item.showTotal ? actualIndex + 1 : actualIndex}>
164
+ {cellContent}
88
165
  </Table.Summary.Cell>
89
- )
90
- })
91
- }
92
- </Table.Summary.Row >
93
- </Table.Summary>
94
- return () => summaryDom
166
+ );
167
+ })}
168
+ </Table.Summary.Row>
169
+ </Table.Summary>
170
+ );
171
+
172
+ return () => summaryDom;
95
173
  };
96
174
 
97
175
  handledynamicColumns = (col: any[]) => {
@@ -128,7 +206,7 @@ export default class ColumnSettingSulaTable extends React.Component {
128
206
 
129
207
  ResizeableTitle = (props: any) => {
130
208
  const { onResize, width, ...restProps } = props;
131
-
209
+
132
210
  const [innerWidth, setInnerWidth] = useState(width);
133
211
  const [isResizing, setIsResizing] = useState(false); // 标记是否正在拖拽
134
212
  const [isDragging, setIsDragging] = useState(false); // 标记拖拽句柄是否被拖拽
@@ -136,9 +214,9 @@ export default class ColumnSettingSulaTable extends React.Component {
136
214
  const markerPosition = useRef({ left: 0, top: 0 });
137
215
  const currentStart = useRef(0);
138
216
  const uuidref = useRef(uuid());
139
-
217
+
140
218
  const prevWidthRef = useRef(width);
141
-
219
+
142
220
  const handleMouseDown = (e: any) => {
143
221
  currentStart.current = e.clientX;
144
222
  markerPosition.current = { left: e.clientX, top: e.clientY }
@@ -146,53 +224,53 @@ export default class ColumnSettingSulaTable extends React.Component {
146
224
  document.addEventListener('mousemove', handleMouseMove);
147
225
  document.addEventListener('mouseup', handleMouseUp);
148
226
  };
149
-
227
+
150
228
  const handleMouseMove = (e: any) => {
151
229
  e.stopPropagation();
152
230
  e.preventDefault();
153
231
  // 更新标记位置
154
232
  markerPosition.current = { left: e.clientX, top: e.clientY }
155
233
  const dom: HTMLElement | null = document.getElementById('text1');
156
-
234
+
157
235
  if (dom && dom.style) {
158
236
  dom.style.left = `${e.clientX}px`;
159
237
  dom.style.top = `${e.clientY - 20}px`;
160
238
  }
161
239
  };
162
-
240
+
163
241
  const handleMouseUp = (e: any) => {
164
242
  document.removeEventListener('mousemove', handleMouseMove);
165
243
  document.removeEventListener('mouseup', handleMouseUp);
166
244
  setIsResizing(false);
167
245
  };
168
-
246
+
169
247
  const handleresize = (e: any, data: any, title: string) => {
170
248
  const newWidth = data?.size?.width || 0;
171
249
  setInnerWidth(newWidth); // 更新内部分宽度
172
250
  };
173
-
251
+
174
252
  const handleResizeStart = () => {
175
253
  setIsResizing(true);
176
254
  };
177
-
255
+
178
256
  const handleResizeStop = (e: any, data: any) => {
179
257
  setIsResizing(false);
180
258
  if (onResize) {
181
259
  onResize(e, data);
182
260
  }
183
261
  };
184
-
262
+
185
263
  useEffect(() => {
186
264
  if (width !== prevWidthRef.current) {
187
265
  prevWidthRef.current = width;
188
266
  setInnerWidth(width);
189
267
  }
190
268
  }, [width]);
191
-
269
+
192
270
  const thStyle = {
193
271
  boxShadow: isResizing ? '2px 2px 10px rgba(0, 0, 0, 0.3)' : 'none',
194
272
  };
195
-
273
+
196
274
  return (
197
275
  <Resizable
198
276
  width={innerWidth}
@@ -254,19 +332,53 @@ export default class ColumnSettingSulaTable extends React.Component {
254
332
  }
255
333
  };
256
334
 
335
+ /**
336
+ * 处理行点击事件
337
+ * @param record
338
+ */
339
+ handleRowClick = (record: any) => {
340
+ const { selectedRowKeys, selectedRows, } = this.state;
341
+ const { rowKey }: any = this.props;
342
+ let newSelectedRowKeys = [...selectedRowKeys];
343
+ let newSelectedRows = [...selectedRows];
344
+
345
+ const keyIndex = newSelectedRowKeys.indexOf(record[rowKey]);
346
+ if (keyIndex > -1) {
347
+ // 如果已经选中,则取消选中
348
+ newSelectedRowKeys.splice(keyIndex, 1);
349
+ newSelectedRows.splice(keyIndex, 1);
350
+ } else {
351
+ // 如果未选中,则添加到选中列表
352
+ newSelectedRowKeys.push(record[rowKey]);
353
+ newSelectedRows.push(record);
354
+ }
355
+ this.setState({
356
+ selectedRowKeys: newSelectedRowKeys,
357
+ selectedRows: newSelectedRows,
358
+ });
359
+
360
+ // 手动调用外部传入的 onChange 函数
361
+ const { rowSelection }: any = this.props;
362
+ if (rowSelection && typeof rowSelection.onChange === 'function') {
363
+ // 直接将 record 作为数组元素传递
364
+ rowSelection.onChange(newSelectedRowKeys, newSelectedRows);
365
+ }
366
+ };
367
+
368
+ recalculateSummary = (nextProps: any) => {
369
+ if (this.state.showColumns.length) {
370
+ const showSummary = this.getTableSummaryInfo();
371
+ this.setState({ showSummary });
372
+ }
373
+ };
374
+
257
375
  render() {
258
- const { style=null, columns, tableCode, appRequestConfig, summary = undefined, dynamicColumns = [], scroll={}, ...restProps }: any = this.props;
376
+ const { style=null, columns, tableCode, appRequestConfig, summary = undefined, dynamicColumns = [], scroll={}, rowSelection: propRowSelection, ...restProps }: any = this.props;
259
377
  let otherTableInfo = {
260
378
  ...restProps,
261
379
  };
262
- let showSummary = null;
263
- if (this.state.showColumns.length && !Array.isArray(summary)) {
264
- if (summary && summary().diy) {
265
- showSummary = this.getTableSummaryInfo();
266
- } else {
267
- showSummary = summary;
268
- }
269
- };
380
+
381
+ const { showSummary } = this.state;
270
382
 
271
383
  const handleColumns = (arr: any, indexArr: any[]) => {
272
384
  arr.forEach((item: any, index: any) => {
@@ -292,7 +404,7 @@ export default class ColumnSettingSulaTable extends React.Component {
292
404
  handleColumns(showCol, []);
293
405
  if (dynamicColumns.length) {
294
406
  showCol = this.handledynamicColumns(showCol);
295
- }
407
+ };
296
408
 
297
409
  otherTableInfo = {
298
410
  ...otherTableInfo,
@@ -304,8 +416,28 @@ export default class ColumnSettingSulaTable extends React.Component {
304
416
  sticky: true,
305
417
  ...(
306
418
  showSummary ? { summary: showSummary } : {}
307
- )
419
+ ),
420
+ rowSelection: propRowSelection ? {
421
+ ...propRowSelection,
422
+ selectedRowKeys: this.state.selectedRowKeys,
423
+ onChange: (selectedRowKeys: any, selectedRows: any) => {
424
+ this.setState({
425
+ selectedRowKeys,
426
+ selectedRows
427
+ });
428
+ if (propRowSelection && propRowSelection.onChange) {
429
+ propRowSelection.onChange(selectedRowKeys, selectedRows);
430
+ }
431
+ },
432
+ } : false,
433
+ onRow: (record: any) => {
434
+ return {
435
+ onClick: () => this.handleRowClick(record), // 绑定行点击事件
436
+ //onDoubleClick: () => this.handleRowDoubleClick(record), // 绑定行点击事件
437
+ };
438
+ },
308
439
  }
440
+
309
441
  return (
310
442
  <div style={{ position: 'relative' }}>
311
443
  <span style={{ position: 'absolute', zIndex: '10', right: '8px', top: '10px' }} className="ant-dropdown-link">
@@ -1,5 +1,5 @@
1
1
 
2
- import request from '@/utils/request';
2
+ import request from '@/utils/cachedRequest';
3
3
  import { stringify } from 'querystring';
4
4
  import { message } from 'antd';
5
5
  import { judgeIsRequestError } from '@/utils/requestUtils';
@@ -3,7 +3,7 @@ import React, { useState, useEffect } from 'react';
3
3
  import { useDebounceFn } from 'ahooks';
4
4
  import { Input, Button, Modal, Select, InputNumber, message, Spin, Form, Table, Checkbox, TreeSelect, Tooltip, Tag } from 'antd';
5
5
  import { SearchOutlined, CopyOutlined, CloseCircleOutlined } from '@ant-design/icons';
6
- import request from '@/utils/request';
6
+ import request from '@/utils/cachedRequest';
7
7
  import { stringify } from 'querystring';
8
8
  import _ from "lodash"
9
9
  import './index.less';
@@ -87,16 +87,18 @@ const AddSelect = (props: any) => {
87
87
  tableCodeList = [], // 非必填 默认取组件定义code,如需自定义----数组第一位为供选择商品的table的code,第二位为已选择商品的table的code
88
88
  businessType = 'sku',
89
89
  isAllowRepeatedSelect = false,
90
- clearTitle
90
+ clearTitle,
91
+ batchFormatCallback,
92
+ batchFormatBtnTitle,
91
93
  } = props;
92
- const { url, otherParams, isMap, mappingValueField = 'code' } = requestConfig || {};
94
+ const { url, method = 'get', sourceKey, otherParams, isMap, mappingValueField = 'code', extralHeaders = {} } = requestConfig || {};
93
95
  const realButtonProps = {type: "primary", ...buttonProps};
94
96
  const selectRowKey = isAllowRepeatedSelect ? 'uuid' : mappingValueField
95
97
 
96
98
  const selectMode = selectProps?.mode // 设定当前选择器 为单选或者多选模式 无设定为单选模式(默认)
97
99
  const initVal = value || (selectMode ? [] : null);
98
100
  const pageSize = 100 // 下拉框默认分页 条数
99
- const tableInitPageSize = 10 // 弹框默认分页 条数
101
+ const tableInitPageSize = modalTableProps?.topTablePagination?.pageSize || 10 // 弹框默认分页 条数
100
102
  const currentPage = 1
101
103
 
102
104
  const [fetching, setFetching] = useState(false);
@@ -108,7 +110,7 @@ const AddSelect = (props: any) => {
108
110
  const [tableSearchForm, setTableSearchForm] = useState<Array<SearchFormItem>>(modalTableProps?.tableSearchForm)
109
111
  const [caretLeftFlag, setCaretLeftFlag] = useState(true);
110
112
  const [tableData, setTableData] = useState([]);
111
- const [tablePagination, setTablePagination] = useState({ total: 0, size: "small", current: 1, pageSize: tableInitPageSize })
113
+ const [tablePagination, setTablePagination] = useState({ total: 0, size: "small", current: 1, pageSize: tableInitPageSize, ...(modalTableProps?.topTablePagination) })
112
114
  const [selectedRowKeys, setSelectedRowKeys] = useState([]);
113
115
  const [tableFormParams, setTableFormParams] = useState({});
114
116
  const [confirmLoading, setConfirmLoading] = useState(false);
@@ -214,9 +216,108 @@ const AddSelect = (props: any) => {
214
216
  // precision: unitAccuracy
215
217
  }
216
218
  }
219
+ // 如果属性为函数时,则执行该函数
220
+ const inputProps = Object.keys(item?.inputProps || {})?.reduce((acc, key) => {
221
+ const value = item?.inputProps?.[key];
222
+ acc[key] = typeof value === 'function' ? value?.(record) : value;
223
+ return acc;
224
+ }, {});
225
+
226
+ // 可输入非数字字符
227
+ if(item.canInputString) {
228
+ return (
229
+ <InputNumber
230
+ min={0}
231
+ precision={0}
232
+ controls={false}
233
+ {...inputProps}
234
+ value={text || ''}
235
+ keyboard={false}
236
+ onPressEnter={(e: any) => {
237
+ e.target.blur();
238
+ }}
239
+ onBlur={async (e: any) => {
240
+ const {
241
+ target: { value },
242
+ } = e;
243
+ record[item.dataIndex] = value
244
+ editRecord(record)
245
+ }}
246
+ onKeyDown={(e) => {
247
+ if(e.keyCode === 13 && e.ctrlKey) {
248
+ handleOk(true)
249
+ document.getElementById("first-query")?.focus()
250
+ }
251
+ if(e.keyCode === 8 && e.ctrlKey) {
252
+ message.success('删除当前行')
253
+ e.stopPropagation();
254
+ e.preventDefault();
255
+ let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
256
+ if (dom) {
257
+ dom.select();
258
+ dom.focus();
259
+ dom.scrollIntoView(false)
260
+ }
261
+ dom = null
262
+ deleteRecord(record, popvalue);
263
+ }
264
+ if (e.keyCode === 37 && e.shiftKey) { // 左滑动
265
+ e.stopPropagation();
266
+ e.preventDefault();
267
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex - 1]
268
+ if (dom) {
269
+ dom.select();
270
+ dom.focus();
271
+ dom.scrollIntoView(false)
272
+ }
273
+ dom = null
274
+ }
275
+ if (e.keyCode === 39 && e.shiftKey) { // 右滑
276
+ e.stopPropagation();
277
+ e.preventDefault();
278
+ let dom = e.nativeEvent.path[5].children[index + 1]?.getElementsByTagName('input')[currentIndex + 1]
279
+ if (dom) {
280
+ dom.select();
281
+ dom.focus();
282
+ dom.scrollIntoView(false)
283
+ }
284
+ dom = null
285
+ }
286
+ if (e.keyCode === 40) {
287
+ e.stopPropagation();
288
+ e.preventDefault();
289
+ let dom = e.nativeEvent.path[5].children[index + 2]?.getElementsByTagName('input')[currentIndex]
290
+ if (dom) {
291
+ dom.select();
292
+ dom.focus();
293
+ dom.scrollIntoView(false)
294
+ }
295
+ dom = null
296
+ } else if (e.keyCode === 38) {
297
+ e.stopPropagation();
298
+ e.preventDefault();
299
+ let dom1 = e.nativeEvent.path[5].children[index]?.getElementsByTagName('input')[currentIndex]
300
+ if (dom1) {
301
+ // dom1.value=""
302
+ // dom1.setSelectionRange(100, 0);
303
+ dom1.select();
304
+ dom1.focus();
305
+ dom1.scrollIntoViewIfNeeded(false)
306
+ // dom1.value=record['count']
307
+ }
308
+ dom1 = null
309
+ } else if (e.keyCode === 9 && index === selectedRowKeys.length - 1 && currentIndex === inputLength - 1) {
310
+ e.stopPropagation();
311
+ e.preventDefault();
312
+ }
313
+ }}
314
+ />
315
+ );
316
+ }
317
+
217
318
  return (
218
319
  <InputNumber
219
- {...item.inputProps}
320
+ {...inputProps}
220
321
  value={text || ''}
221
322
  min={0}
222
323
  autoFocus={record.needFocus}
@@ -518,9 +619,18 @@ const AddSelect = (props: any) => {
518
619
  }
519
620
  })
520
621
  }
521
- request
522
- .get(`${url}${url.includes("?")?"&":"?"}${stringify(queryParams)}`)
523
- .then((result: any) => {
622
+
623
+ let getRequest;
624
+ const methodName = method?.toLocaleLowerCase?.();
625
+ if(['post','patch','put'].includes(methodName)) {
626
+ getRequest = request[methodName](`${url}`,queryParams, { headers: { ...extralHeaders }})
627
+ } else {
628
+ getRequest = request.get( `${url}${url.includes("?")?"&":"?"}${stringify(queryParams)}`,{headers: { ...extralHeaders }})
629
+ }
630
+
631
+ if (!url || !getRequest) return;
632
+
633
+ getRequest.then((result: any) => {
524
634
  setFetching(false)
525
635
  result = result.data;
526
636
  if (judgeIsRequestError(result)) {
@@ -537,7 +647,7 @@ const AddSelect = (props: any) => {
537
647
  };
538
648
  });
539
649
  } else {
540
- const keys = res.list ? 'list' : 'items';
650
+ const keys = sourceKey ? sourceKey :res.list ? 'list' : 'items';
541
651
  source = res
542
652
  ? res[keys]
543
653
  ? res[keys].map((item: any) => {
@@ -557,7 +667,8 @@ const AddSelect = (props: any) => {
557
667
  })
558
668
  : [];
559
669
  }
560
- source = Array.isArray(source) ? source : []
670
+ // 数据源 不可以有重复key
671
+ source = Array.isArray(source) ? _.uniqBy(source, 'value') : [];
561
672
 
562
673
  setTableData(source)
563
674
  setTablePagination({ ...tablePagination, total: Number(res?.total || res?.totalCount || source.length), pageSize: Number(res?.size || res?.pageSize || (params?.pageSize || pageSize)), current: Number(res?.page || res?.currentPage || (params?.currentPage || currentPage)) })
@@ -605,6 +716,11 @@ const AddSelect = (props: any) => {
605
716
  }, 50)
606
717
  };
607
718
 
719
+ // 将格式化完的数据回显到 表格中
720
+ const batchFormatCallbackHandler = () => {
721
+ setPopValue([...batchFormatCallback?.(popvalue)]);
722
+ }
723
+
608
724
  const handleShowModal = () => {
609
725
  if(beforeShowModal) {
610
726
  beforeShowModal(popvalue).then(res => {
@@ -940,7 +1056,7 @@ const AddSelect = (props: any) => {
940
1056
  </div>
941
1057
  {isModalVisible && (
942
1058
  <Modal
943
- width='1200px'
1059
+ width={`calc(100% - 320px)`}
944
1060
  style={{ top: 20 }}
945
1061
  bodyStyle={{ padding: '0px' }}
946
1062
  visible={isModalVisible}
@@ -1039,7 +1155,10 @@ const AddSelect = (props: any) => {
1039
1155
  settingImgAttribute={{ width: 20, style: { marginTop: -2 } }}
1040
1156
  />
1041
1157
  </span>
1042
- <div style={{ marginRight: 8 }}><span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>{clearTitle??'清空所选商品'}</span></div>
1158
+ <div style={{ marginRight: 8, display: 'flex', gap: '5px' }}>
1159
+ <span hidden={!batchFormatCallback} onClick={batchFormatCallbackHandler} style={{ cursor: 'pointer' }}>{batchFormatBtnTitle ?? '一键填充'}</span>
1160
+ <span onClick={deleteSelectRows} style={{ ...themeColor, cursor: 'pointer' }}>{clearTitle ?? '清空所选商品'}</span>
1161
+ </div>
1043
1162
  </div>
1044
1163
  </div>
1045
1164
  <Table
@@ -361,6 +361,9 @@
361
361
  .table_odd {
362
362
  background: #f7f8fb;
363
363
  }
364
+ .table_gray {
365
+ background: #C0C0C0;
366
+ }
364
367
 
365
368
  // 浮起的列 设置斑马
366
369
  .ant-table-cell-fix-left,
@@ -4,7 +4,7 @@ import React, { useState, useRef, useEffect } from 'react';
4
4
  import { SearchOutlined, CopyOutlined, CloseCircleOutlined } from '@ant-design/icons';
5
5
  import { stringify } from 'querystring';
6
6
  import './index.less';
7
- import request from '@/utils/request';
7
+ import request from '@/utils/cachedRequest';
8
8
  import { Resizable } from 'react-resizable';
9
9
  import { checkQuantityAccuracy, precisionQuantity } from '@/utils/checkUtils';
10
10
  import { tableColumnsImage } from '@/components/Business/BsSulaQueryTable/utils';
@@ -26,7 +26,7 @@ import {
26
26
  ProfileTwoTone,
27
27
  UnorderedListOutlined,
28
28
  } from '@ant-design/icons';
29
- import request from '@/utils/request';
29
+ import request from '@/utils/cachedRequest';
30
30
  import './index.less';
31
31
  import _ from "lodash"
32
32
  import { judgeIsRequestError } from '@/utils/requestUtils';
@@ -43,6 +43,7 @@ export default () => {
43
43
  onRef={(ref) => {
44
44
  dataValidationRef = ref;
45
45
  }}
46
+ getTemplate={() => {}}
46
47
  />
47
48
  </div>
48
49
  );