kts-component-invoice-operate 3.2.153 → 3.2.154

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 (26) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.d.ts +4 -0
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  3. package/dist/Invoice/_test/children/index.d.ts +4 -0
  4. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/index.d.ts +6 -0
  5. package/dist/Invoice/ui/default/GoodsList/hook/useRowSelection/index.d.ts +6 -0
  6. package/dist/index.esm.js +253 -60
  7. package/dist/index.js +252 -59
  8. package/docs-dist/static/I001.4ff48f20.svg +1 -0
  9. package/docs-dist/static/I002.38b94da1.svg +1 -0
  10. package/docs-dist/umi.css +1 -1
  11. package/docs-dist/umi.js +1 -1
  12. package/package.json +1 -1
  13. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +6 -0
  14. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +3 -0
  15. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +1 -1
  16. package/src/Invoice/_test/children/index.tsx +203 -0
  17. package/src/Invoice/index.md +3 -0
  18. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +14 -1
  19. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/index.tsx +53 -0
  20. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/svg/I001.svg +1 -0
  21. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/svg/I002.svg +1 -0
  22. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +1 -0
  23. package/src/Invoice/ui/default/GoodsList/hook/useOnRow/index.tsx +1 -0
  24. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +8 -2
  25. package/src/Invoice/ui/default/GoodsList/index.less +8 -1
  26. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.tsx +35 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.153",
3
+ "version": "3.2.154",
4
4
  "scripts": {
5
5
  "dev": "dumi dev --max-old-space-size=6096",
6
6
  "start": "dumi dev",
@@ -4,6 +4,9 @@ export default interface IGood {
4
4
  /** 数据索引 */
5
5
  $index: string;
6
6
 
7
+ /** 级别 */
8
+ level?: number;
9
+
7
10
  /** 序号 */
8
11
  serialNo?: number;
9
12
 
@@ -75,4 +78,7 @@ export default interface IGood {
75
78
 
76
79
  /** 税收分类名称 */
77
80
  productName?: string;
81
+
82
+ /** 孩子 */
83
+ children?: IGood[];
78
84
  }
@@ -74,6 +74,9 @@ export default class GoodsListState {
74
74
  /** 货物字典 */
75
75
  goodsMap = new Map<string, IGood>();
76
76
 
77
+ /** 子级展开的货物 */
78
+ expandedRowKeys: string[] = [];
79
+
77
80
  /** 货物菜单扩展 */
78
81
  goodsMenuExpand: ((index: string, controller: InvoiceController) => React.ReactNode)[] = [];
79
82
 
@@ -4,7 +4,7 @@ import { InvoiceControllerState } from '../';
4
4
  * 保存正在编辑的货物
5
5
  */
6
6
  export default async (state: InvoiceControllerState) => {
7
-
7
+
8
8
  const editGood = state.goodsListState.editGood;
9
9
  const form = state.goodsListState.form;
10
10
 
@@ -0,0 +1,203 @@
1
+ import React from 'react';
2
+ import { Invoice } from '../../..';
3
+ import 'antd/dist/antd.css';
4
+ import { LineAttributeType } from '@/Invoice/InvoiceController';
5
+ import idGenerator from '@/Invoice/tools/idGenerator';
6
+
7
+ export default () => {
8
+
9
+ const invoiceController = React.useMemo(() => new Invoice.InvoiceController(), [])
10
+
11
+ React.useEffect(() => {
12
+ setTimeout(() => {
13
+ invoiceController.run(async s => {
14
+ s.goodsListState.goodsList = lines.map(e => ({ $index: idGenerator(), ...e }));
15
+ })
16
+ }, 1000)
17
+ }, [])
18
+
19
+ return (
20
+ <Invoice controller={invoiceController} />
21
+ )
22
+ };
23
+
24
+ const children = []
25
+ for (let i = 0; i <= 10; i++) {
26
+ children.push({
27
+ itemName: `项目名称${i}`,
28
+ lineAttribute: LineAttributeType.正常,
29
+ lineAmountExcludeTax: 9.99,
30
+ lineAmountIncludeTax: 10.29,
31
+ taxRate: 3,
32
+ taxAmount: 0.3,
33
+ });
34
+ }
35
+
36
+
37
+ const lines: any[] = [
38
+ {
39
+ "serialNumber": "1714491422279110656",
40
+ "lineNumber": 1,
41
+ "taxCode": "3070401000000000000",
42
+ "taxName": "信息技术服务",
43
+ "specification": null,
44
+ "itemName": "技术服务费",
45
+ "itemCode": "z",
46
+ "unit": "套",
47
+ "quantity": 1.0000000000001,
48
+ "taxRate": 0.06,
49
+ "priceExcludeTax": 0.0000000000001,
50
+ "priceIncludeTax": 2.12,
51
+ "amountTax": 0.3,
52
+ "lineAmountExcludeTax": 5,
53
+ "lineAmountIncludeTax": 5.3,
54
+ "lineAttribute": LineAttributeType.正常,
55
+ "discountGroup": "1714491422291693568",
56
+ "favouredPolicyMark": false,
57
+ "favouredPolicyName": null,
58
+ "zeroTaxRateFlag": null,
59
+ "referenceLines": null,
60
+ "version": 0,
61
+ "taxAmount": 1
62
+ },
63
+ {
64
+ "serialNumber": "1714491422279110656",
65
+ "lineNumber": 2,
66
+ "taxCode": "3070401000000000000",
67
+ "taxName": "信息技术服务",
68
+ "specification": "",
69
+ "itemName": "技术服务费",
70
+ "itemCode": "z",
71
+ "unit": "",
72
+ "quantity": -1,
73
+ "taxRate": 0.06,
74
+ "priceExcludeTax": null,
75
+ "priceIncludeTax": null,
76
+ "amountTax": -0.06,
77
+ "lineAmountExcludeTax": 2,
78
+ "lineAmountIncludeTax": 2.3,
79
+ "lineAttribute": LineAttributeType.正常,
80
+ "discountGroup": "1714491422291693568",
81
+ "favouredPolicyMark": false,
82
+ "favouredPolicyName": null,
83
+ "zeroTaxRateFlag": null,
84
+ "referenceLines": null,
85
+ "version": 0,
86
+ "taxAmount": 1,
87
+ "children": children.map(e => ({ ...e, $index: idGenerator(), }))
88
+ },
89
+ {
90
+ "serialNumber": "1714491422279110656",
91
+ "lineNumber": 3,
92
+ "taxCode": "3070401000000000000",
93
+ "taxName": "信息技术服务",
94
+ "specification": null,
95
+ "itemName": "技术服务费",
96
+ "itemCode": "z",
97
+ "unit": "套",
98
+ "quantity": 1,
99
+ "taxRate": 0.06,
100
+ "priceExcludeTax": 2,
101
+ "priceIncludeTax": 2.12,
102
+ "amountTax": 0.12,
103
+ "lineAmountExcludeTax": 5,
104
+ "lineAmountIncludeTax": 5.3,
105
+ "lineAttribute": LineAttributeType.正常,
106
+ "discountGroup": null,
107
+ "favouredPolicyMark": false,
108
+ "favouredPolicyName": null,
109
+ "zeroTaxRateFlag": null,
110
+ "referenceLines": null,
111
+ "version": 0,
112
+ "taxAmount": 1
113
+ },
114
+ {
115
+ "serialNumber": "1714491422279110656",
116
+ "lineNumber": 3,
117
+ "taxCode": "3070401000000000000",
118
+ "taxName": "信息技术服务",
119
+ "specification": null,
120
+ "itemName": "技术服务费",
121
+ "itemCode": "z",
122
+ "unit": "套",
123
+ "quantity": 1,
124
+ "taxRate": 0.06,
125
+ "priceExcludeTax": 2,
126
+ "priceIncludeTax": 2.12,
127
+ "amountTax": 0.12,
128
+ "lineAmountExcludeTax": 5,
129
+ "lineAmountIncludeTax": 5.3,
130
+ "lineAttribute": LineAttributeType.正常,
131
+ "discountGroup": null,
132
+ "favouredPolicyMark": false,
133
+ "favouredPolicyName": null,
134
+ "zeroTaxRateFlag": null,
135
+ "referenceLines": null,
136
+ "version": 0,
137
+ "taxAmount": 1,
138
+ "children": children.map(e => ({ ...e, $index: idGenerator(), }))
139
+ },
140
+ {
141
+ "serialNumber": "1714491422279110656",
142
+ "lineNumber": 3,
143
+ "taxCode": "3070401000000000000",
144
+ "taxName": "信息技术服务",
145
+ "specification": null,
146
+ "itemName": "技术服务费",
147
+ "itemCode": "z",
148
+ "unit": "套",
149
+ "quantity": 1,
150
+ "taxRate": 0.06,
151
+ "priceExcludeTax": 2,
152
+ "priceIncludeTax": 2.12,
153
+ "amountTax": 0.12,
154
+ "lineAmountExcludeTax": 5,
155
+ "lineAmountIncludeTax": 5.3,
156
+ "lineAttribute": LineAttributeType.正常,
157
+ "discountGroup": null,
158
+ "favouredPolicyMark": false,
159
+ "favouredPolicyName": null,
160
+ "zeroTaxRateFlag": null,
161
+ "referenceLines": null,
162
+ "version": 0,
163
+ "taxAmount": 1
164
+ },
165
+ {
166
+ "serialNumber": "1714491422279110656",
167
+ "lineNumber": 3,
168
+ "taxCode": "3070401000000000000",
169
+ "taxName": "信息技术服务",
170
+ "specification": null,
171
+ "itemName": "技术服务费",
172
+ "itemCode": "z",
173
+ "unit": "套",
174
+ "quantity": 1,
175
+ "taxRate": 0.06,
176
+ "priceExcludeTax": 2,
177
+ "priceIncludeTax": 2.12,
178
+ "amountTax": 0.12,
179
+ "lineAmountExcludeTax": 5,
180
+ "lineAmountIncludeTax": 5.3,
181
+ "lineAttribute": LineAttributeType.正常,
182
+ "discountGroup": null,
183
+ "favouredPolicyMark": false,
184
+ "favouredPolicyName": null,
185
+ "zeroTaxRateFlag": null,
186
+ "referenceLines": null,
187
+ "version": 0,
188
+ "shorthand": "布料",
189
+ "taxAmount": 1
190
+ }
191
+ ]
192
+
193
+ for (let i = 0; i <= 100; i++) {
194
+ lines.push({
195
+ $index: idGenerator(),
196
+ itemName: `项目名称${100 + i}`,
197
+ lineAttribute: LineAttributeType.正常,
198
+ lineAmountExcludeTax: 9.99,
199
+ lineAmountIncludeTax: 10.29,
200
+ taxRate: 3,
201
+ taxAmount: 0.3,
202
+ });
203
+ }
@@ -24,6 +24,9 @@
24
24
  ## 替换发票头 UI
25
25
  <code src="./_test/replaceHead/index.tsx" title="其他UI的替换类型,请查看API" ></code>
26
26
 
27
+ ## 子表格
28
+ <code src="./_test/children/index.tsx" title="其他UI的替换类型,请查看API" ></code>
29
+
27
30
  ## 销售方 预设、自动补全、禁用
28
31
  <code src="./_test/seller/index.tsx"></code>
29
32
 
@@ -21,6 +21,7 @@ import {
21
21
  import { getItemNameWithShorthand } from '../../../../../tools/itemName';
22
22
  import Drag from './ui/Drag';
23
23
  import { nonScientificNotation } from '../../../../../tools/calculate';
24
+ import Expand from './ui/Expand';
24
25
 
25
26
  export default (form: WrappedFormUtils) => {
26
27
  const { getFieldDecorator, getFieldValue } = form;
@@ -47,6 +48,9 @@ export default (form: WrappedFormUtils) => {
47
48
  /** 正在编辑的货物 */
48
49
  const editGood = controller.useMemo((e) => e.goodsListState.editGood, []);
49
50
 
51
+ /** 正在编辑的货物 */
52
+ const goodsList = controller.useMemo((e) => e.goodsListState.goodsList, []);
53
+
50
54
  /** 商品表格隐藏列 */
51
55
  const columnshide = controller.useMemo((e) => e.goodsListState.columnshide, []);
52
56
 
@@ -96,6 +100,13 @@ export default (form: WrappedFormUtils) => {
96
100
  align: 'center',
97
101
  render: (_: any, record: IGood) => <Drag record={record} />
98
102
  },
103
+ {
104
+ title: ' ',
105
+ key: 'expand',
106
+ width: 40,
107
+ align: 'center',
108
+ render: (_: any, record: IGood) => <Expand record={record} />
109
+ },
99
110
  {
100
111
  title: '序号',
101
112
  key: 'serialNo',
@@ -584,6 +595,8 @@ export default (form: WrappedFormUtils) => {
584
595
  })
585
596
  // 是否启动拖拽
586
597
  .filter(e => e.key !== 'drag' || isStart)
598
+ // 是否启动展开
599
+ .filter(e => e.key === 'expand' ? goodsList.some(e => !!e.children) : true)
587
600
  // 只读
588
601
  .filter(e => {
589
602
  if (model === 'readOnly') {
@@ -598,7 +611,7 @@ export default (form: WrappedFormUtils) => {
598
611
  ellipsis: true,
599
612
  };
600
613
  }) as any[];
601
- }, [isTaxIncluded, editGood, controller, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, columnshide, isStart]);
614
+ }, [isTaxIncluded, editGood, goodsList, controller, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, columnshide, isStart]);
602
615
  return columns;
603
616
  };
604
617
 
@@ -0,0 +1,53 @@
1
+
2
+
3
+ import React from 'react';
4
+ import { Button } from 'kts-xui';
5
+ import Icon from '@ant-design/icons';
6
+ import { ReactComponent as I001Svg } from './svg/I001.svg';
7
+ import { ReactComponent as I002Svg } from './svg/I002.svg';
8
+ import { IGood, Invoice } from '../../../../../../../..';
9
+
10
+ export interface IExpandProps {
11
+ record: IGood
12
+ }
13
+
14
+ export default function Expand(props: IExpandProps) {
15
+
16
+ const { record } = props;
17
+
18
+ const controller = Invoice.useInvoiceController();
19
+
20
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
21
+
22
+ const expandedRowKeys = controller.useMemo(s => s.goodsListState.expandedRowKeys, []);
23
+
24
+ if (goodsMap.get(record.$index)?.children) {
25
+ if (expandedRowKeys.includes(record.$index)) {
26
+ return (
27
+ <Button
28
+ type='text'
29
+ style={{ width: 'auto', color: "#0074ff" }}
30
+ icon={<Icon component={I002Svg} />}
31
+ onClick={controller.pipeline(async (s, e) => {
32
+ e?.stopPropagation()
33
+ s.goodsListState.expandedRowKeys = s.goodsListState.expandedRowKeys.filter(e => e !== record.$index)
34
+ })}
35
+ />
36
+ )
37
+ } else {
38
+ return (
39
+ <Button
40
+ type='text'
41
+ style={{ width: 'auto', color: "#0074ff" }}
42
+ icon={<Icon component={I001Svg} />}
43
+ onClick={controller.pipeline(async (s, e) => {
44
+ e?.stopPropagation()
45
+ s.goodsListState.expandedRowKeys = [...s.goodsListState.expandedRowKeys, record.$index]
46
+ })}
47
+ />
48
+ )
49
+ }
50
+ } else {
51
+ return <></>
52
+ }
53
+ }
@@ -0,0 +1 @@
1
+ <svg t="1719031046892" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5456" width="200" height="200"><path d="M879.9725037 997.08776297H146.45475555c-67.23508148 0-122.2125037-54.97742222-122.2125037-122.21250372V141.23614815c0-67.23508148 54.97742222-122.2125037 122.2125037-122.2125037h733.63911112c67.23508148 0 122.2125037 54.97742222 122.2125037 122.2125037V874.87525925c0 67.11371852-54.97742222 122.2125037-122.33386667 122.21250372zM146.45475555 80.06921482c-36.65161482 0-61.16693333 24.39395555-61.16693333 61.16693333V874.87525925c0 36.65161482 24.39395555 61.16693333 61.16693333 61.16693334h733.63911112c36.65161482 0 61.16693333-24.39395555 61.16693333-61.16693334V141.23614815c0-36.65161482-24.39395555-61.16693333-61.16693333-61.16693333H146.45475555z m0 0" p-id="5457"></path><path d="M757.76 538.57848889h-489.09274075c-18.32580741 0-30.58346667-12.25765925-30.58346666-30.58346667s12.25765925-30.58346667 30.58346666-30.58346667h489.09274075c18.32580741 0 30.58346667 12.25765925 30.58346667 30.58346667s-12.25765925 30.58346667-30.58346667 30.58346667z m0 0" p-id="5458"></path><path d="M513.21362963 783.12485925c-18.32580741 0-30.58346667-12.25765925-30.58346666-30.58346666v-489.09274074c0-18.32580741 12.25765925-30.58346667 30.58346666-30.58346667s30.58346667 12.25765925 30.58346667 30.58346667v489.09274074c0 18.32580741-12.25765925 30.58346667-30.58346667 30.58346666z m0 0" p-id="5459"></path></svg>
@@ -0,0 +1 @@
1
+ <svg t="1719031078613" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5605" width="200" height="200"><path d="M879.9725037 997.08776297H146.45475555c-67.23508148 0-122.2125037-54.97742222-122.2125037-122.21250372V141.23614815c0-67.23508148 54.97742222-122.2125037 122.2125037-122.2125037h733.63911112c67.23508148 0 122.2125037 54.97742222 122.2125037 122.2125037V874.87525925c0 67.11371852-54.97742222 122.2125037-122.33386667 122.21250372zM146.45475555 80.06921482c-36.65161482 0-61.16693333 24.39395555-61.16693333 61.16693333V874.87525925c0 36.65161482 24.39395555 61.16693333 61.16693333 61.16693334h733.63911112c36.65161482 0 61.16693333-24.39395555 61.16693333-61.16693334V141.23614815c0-36.65161482-24.39395555-61.16693333-61.16693333-61.16693333H146.45475555z m0 0" p-id="5606"></path><path d="M757.76 538.57848889h-489.09274075c-18.32580741 0-30.58346667-12.25765925-30.58346666-30.58346667s12.25765925-30.58346667 30.58346666-30.58346667h489.09274075c18.32580741 0 30.58346667 12.25765925 30.58346667 30.58346667s-12.25765925 30.58346667-30.58346667 30.58346667z m0 0" p-id="5607"></path></svg>
@@ -80,6 +80,7 @@ export default (props: { goods: IGood }) => {
80
80
  )
81
81
  }, [itemList])
82
82
 
83
+ if (props.goods.level && props.goods.level > 0) { return <></> }
83
84
  if (itemList.length === 0) { return (<></>) }
84
85
 
85
86
  return (
@@ -16,6 +16,7 @@ export default () => {
16
16
  const onClick = React.useCallback(
17
17
  async (record: IGood) => {
18
18
  // if (model === 'prefab') return;
19
+ if (record.level && record.level > 0) return;
19
20
  if (model === 'readOnly') return;
20
21
 
21
22
  const editGood = controller.state.goodsListState.editGood;
@@ -74,7 +74,7 @@ export default () => {
74
74
  onChange={onClickSelectAll}
75
75
  indeterminate={indeterminate}
76
76
  checked={isAll}
77
- ></Checkbox>
77
+ />
78
78
  )
79
79
  }, [goodsList, selectedRowKeys, onClickSelectAll, isAll, indeterminate])
80
80
 
@@ -85,7 +85,6 @@ export default () => {
85
85
  s.goodsListState.selectedGoodIndex.forEach($index => {
86
86
  const goods = s.goodsListState.goodsMap.get($index);
87
87
 
88
-
89
88
  if (!goods || (goods.lineAttribute !== LineAttributeType.折扣行 && goods.lineAttribute !== LineAttributeType.被折扣行)) return;
90
89
 
91
90
  // 数组位置
@@ -111,5 +110,12 @@ export default () => {
111
110
  columnTitle,
112
111
  onSelect,
113
112
  selectedRowKeys,
113
+ getCheckboxProps: (record: any) => {
114
+ console.log('===> getCheckboxProps', record, record.level)
115
+ return {
116
+ disabled: record.level > 0,
117
+ style: record.level > 0 ? { display: 'none' } : undefined
118
+ }
119
+ },
114
120
  }
115
121
  }
@@ -43,6 +43,7 @@
43
43
  }
44
44
 
45
45
  .ktsAntX-table {
46
+
46
47
  .ktsAntX-table-row.kts-invoice-operate-goods-be-discount .ktsAntX-table-cell,
47
48
  .ktsAntX-table-row.kts-invoice-operate-goods-discount .ktsAntX-table-cell {
48
49
  background: #f5f5f5;
@@ -172,8 +173,14 @@
172
173
  height: 10px;
173
174
  }
174
175
  }
176
+
175
177
  .kts-invoice-operate-goods-list-table {
178
+ .ktsAntX-table-row-indent+.ktsAntX-table-row-expand-icon {
179
+ display: none;
180
+ }
181
+
176
182
  .ktsAnt3x-form-item-control.has-error {
177
183
  border: 1px solid #f00;
178
184
  }
179
- }
185
+
186
+ }
@@ -1,11 +1,17 @@
1
1
 
2
2
  import React from "react";
3
+ import Invoice from '../../../../..';
3
4
  import { TableManual, TableProps } from "kts-xui";
4
5
  import { Table } from 'kts-components-antd-x4-v4';
5
6
  import './index.less';
7
+ import { e } from "mathjs";
6
8
 
7
9
  export default function <T extends object = any>(props: TableProps<T>) {
8
10
 
11
+ const controller = Invoice.useInvoiceController();
12
+
13
+ const expandedRowKeys = controller.useMemo(s => s.goodsListState.expandedRowKeys, []);
14
+
9
15
  const [self, setSelf] = React.useState<HTMLSpanElement | null>(null);
10
16
 
11
17
  const tableBody = React.useMemo(() => {
@@ -38,13 +44,29 @@ export default function <T extends object = any>(props: TableProps<T>) {
38
44
  return placeholder;
39
45
  }, [self, tableBody]);
40
46
 
47
+ /** 处理扩展行 */
48
+ const goodsList = React.useMemo(() => {
49
+ if (!props.dataSource) return [];
50
+ const gl: any[] = props.dataSource.map(e => ({ ...e, level: 0 }));
51
+
52
+ for (let i = 0; i < gl.length; i++) {
53
+ const e = gl[i];
54
+ if (expandedRowKeys.includes(e.$index) && e.children) {
55
+ let c = e.children.map((t: any) => ({ ...t, level: 1 }));
56
+ gl.splice(i + 1, 0, ...c);
57
+ }
58
+ }
59
+
60
+ return gl;
61
+ }, [props.dataSource, expandedRowKeys])
62
+
41
63
  // 设置占位dom的搞
42
64
  const placeholderHeight = React.useMemo(() => {
43
- if (!self || !rowHeight || !props.dataSource || !placeholder) return;
44
- const placeholderHeight = rowHeight * props.dataSource.length;
65
+ if (!self || !rowHeight || !goodsList || !placeholder) return;
66
+ const placeholderHeight = rowHeight * goodsList.length;
45
67
  placeholder.style.height = `${placeholderHeight}px`;
46
68
  return placeholderHeight;
47
- }, [self, rowHeight, props.dataSource, placeholder]);
69
+ }, [self, rowHeight, goodsList, placeholder]);
48
70
 
49
71
  /** 可以容纳的行数 */
50
72
  const rowSize = React.useMemo(() => {
@@ -54,21 +76,20 @@ export default function <T extends object = any>(props: TableProps<T>) {
54
76
 
55
77
  // 计算渲染的行
56
78
  const dataSource = React.useMemo(() => {
57
- if (!props.dataSource) return [];
58
- if (props.dataSource.length < 10) return props.dataSource;
79
+ if (goodsList.length < 10) return goodsList;
59
80
 
60
- if (!rowSize) return [props.dataSource[0]];
61
- return props.dataSource?.slice(pointer, pointer + 2 * rowSize);
62
- }, [props.dataSource, pointer, rowSize]);
81
+ if (!rowSize) return [goodsList[0]];
82
+ return goodsList?.slice(pointer, pointer + 2 * rowSize);
83
+ }, [pointer, rowSize, goodsList]);
63
84
 
64
85
  // 监听滚动
65
86
  React.useEffect(() => {
66
- if (!self || !placeholder || !props.dataSource || !rowHeight || !tableBody)
87
+ if (!self || !placeholder || !goodsList || !rowHeight || !tableBody)
67
88
  return;
68
89
 
69
90
  const onScroll = () => {
70
- if (!props.dataSource || !tableBody) return;
71
- setPointer(Math.floor((props.dataSource.length - rowSize) * (tableBody.scrollTop / (placeholder.clientHeight - tableBody.clientHeight))));
91
+ if (!goodsList || !tableBody) return;
92
+ setPointer(Math.floor((goodsList.length - rowSize) * (tableBody.scrollTop / (placeholder.clientHeight - tableBody.clientHeight))));
72
93
  };
73
94
  onScroll();
74
95
 
@@ -76,7 +97,7 @@ export default function <T extends object = any>(props: TableProps<T>) {
76
97
  return () => {
77
98
  tableBody.removeEventListener('scroll', onScroll);
78
99
  };
79
- }, [self, placeholder, props.dataSource, rowHeight, rowSize]);
100
+ }, [self, placeholder, goodsList, rowHeight, rowSize]);
80
101
 
81
102
  // 移动列表
82
103
  React.useEffect(() => {
@@ -96,6 +117,8 @@ export default function <T extends object = any>(props: TableProps<T>) {
96
117
  cont.scrollTop = 0;
97
118
  }, [props.dataSource?.length])
98
119
 
120
+ console.log('===> pointer', pointer, dataSource);
121
+
99
122
  return (
100
123
  <span className="kts-invoice-operate-goods-table-virtual" ref={(e) => { setSelf(e) }} >
101
124
  <TableManual