kts-component-invoice-operate 3.2.153 → 3.2.155

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 (31) hide show
  1. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.d.ts +6 -0
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +4 -0
  3. package/dist/Invoice/InvoiceController/index.d.ts +2 -0
  4. package/dist/Invoice/_test/children/index.d.ts +4 -0
  5. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/index.d.ts +6 -0
  6. package/dist/Invoice/ui/default/GoodsList/hook/useRowSelection/index.d.ts +6 -0
  7. package/dist/index.esm.js +498 -185
  8. package/dist/index.js +497 -184
  9. package/docs-dist/static/I001.4ff48f20.svg +1 -0
  10. package/docs-dist/static/I002.38b94da1.svg +1 -0
  11. package/docs-dist/umi.css +1 -1
  12. package/docs-dist/umi.js +1 -1
  13. package/package.json +1 -1
  14. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +9 -0
  15. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +6 -0
  16. package/src/Invoice/InvoiceController/fns/saveEditGood.ts +1 -1
  17. package/src/Invoice/InvoiceController/index.ts +4 -0
  18. package/src/Invoice/_test/children/index.tsx +203 -0
  19. package/src/Invoice/index.md +3 -0
  20. package/src/Invoice/ui/default/EndowCodeDrawer/index.tsx +39 -3
  21. package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +15 -2
  22. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/index.tsx +53 -0
  23. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/svg/I001.svg +1 -0
  24. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Expand/svg/I002.svg +1 -0
  25. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +1 -0
  26. package/src/Invoice/ui/default/GoodsList/hook/useOnRow/index.tsx +13 -0
  27. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +8 -2
  28. package/src/Invoice/ui/default/GoodsList/index.less +8 -1
  29. package/src/Invoice/ui/default/GoodsList/ui/TableVirtual/index.tsx +35 -12
  30. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/index.tsx +14 -11
  31. package/src/Invoice/ui/digtal/GoodsList/hook/useOnRow/index.tsx +13 -1
@@ -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
@@ -35,6 +35,9 @@ export default (form: WrappedFormUtils) => {
35
35
  /** 组件模式 */
36
36
  const model = controller.useMemo(e => e.model, []);
37
37
 
38
+ /** 计算类型 */
39
+ const calculateType = controller.useMemo(e => e.goodsListState.calculateType, []);
40
+
38
41
  /** 是否显示我方 */
39
42
  const isMyShow = controller.useMemo(e => e.goodsListState.isMyShow, []);
40
43
 
@@ -104,7 +107,7 @@ export default (form: WrappedFormUtils) => {
104
107
  title: <TitleText required >项目名称</TitleText>,
105
108
  key: 'itemName',
106
109
  render: (_: string, record: IGood) => {
107
- if (editGood?.$index === record.$index && !disableds.includes('itemName')) {
110
+ if (editGood?.$index === record.$index && !disableds.includes('itemName') && model !== 'prefab') {
108
111
  return (
109
112
  <Form.Item>
110
113
  <div style={{ display: 'flex' }} >
@@ -165,7 +168,7 @@ export default (form: WrappedFormUtils) => {
165
168
  key: 'itemModelName',
166
169
  width: 119,
167
170
  render: (_: string, record: IGood) => {
168
- if (editGood?.$index === record.$index && !disableds.includes('itemModelName')) {
171
+ if (editGood?.$index === record.$index && !disableds.includes('itemModelName') && model !== 'prefab') {
169
172
  return (
170
173
  <Form.Item>
171
174
  {getFieldDecorator('itemModelName', {
@@ -200,7 +203,7 @@ export default (form: WrappedFormUtils) => {
200
203
  key: 'unit',
201
204
  width: 70,
202
205
  render: (_: string, record: IGood) => {
203
- if (editGood?.$index === record.$index && !disableds.includes('unit')) {
206
+ if (editGood?.$index === record.$index && !disableds.includes('unit') && model !== 'prefab') {
204
207
  return (
205
208
  <Form.Item>
206
209
  {getFieldDecorator('unit', {
@@ -231,7 +234,7 @@ export default (form: WrappedFormUtils) => {
231
234
  align: 'right',
232
235
  width: 149,
233
236
  render: (value: string, record: IGood) => {
234
- if (editGood?.$index === record.$index && !disableds.includes('quantity')) {
237
+ if (editGood?.$index === record.$index && !disableds.includes('quantity') && model !== 'prefab') {
235
238
  return (
236
239
  <Form.Item>
237
240
  {getFieldDecorator('quantity', {
@@ -275,7 +278,7 @@ export default (form: WrappedFormUtils) => {
275
278
  align: 'right',
276
279
  width: 149,
277
280
  render: (value: string, record: IGood) => {
278
- if (editGood?.$index === record.$index && !disableds.includes('priceIncludeTax')) {
281
+ if (editGood?.$index === record.$index && !disableds.includes('priceIncludeTax') && model !== 'prefab') {
279
282
  return (
280
283
  <Form.Item>
281
284
  {getFieldDecorator('priceIncludeTax', {
@@ -319,7 +322,7 @@ export default (form: WrappedFormUtils) => {
319
322
  align: 'right',
320
323
  width: 149,
321
324
  render: (value: string, record: IGood) => {
322
- if (editGood?.$index === record.$index && !disableds.includes('priceExcludeTax')) {
325
+ if (editGood?.$index === record.$index && !disableds.includes('priceExcludeTax') && model !== 'prefab') {
323
326
  return (
324
327
  <Form.Item>
325
328
  {getFieldDecorator('priceExcludeTax', {
@@ -363,7 +366,7 @@ export default (form: WrappedFormUtils) => {
363
366
  width: 119,
364
367
  align: 'right',
365
368
  render: (value: string, record: IGood) => {
366
- if (editGood?.$index === record.$index && !disableds.includes('lineAmountIncludeTax')) {
369
+ if (editGood?.$index === record.$index && !disableds.includes('lineAmountIncludeTax') && model !== 'prefab') {
367
370
  return (
368
371
  <Form.Item>
369
372
  {getFieldDecorator('lineAmountIncludeTax', {
@@ -412,7 +415,7 @@ export default (form: WrappedFormUtils) => {
412
415
  align: 'right',
413
416
  width: 119,
414
417
  render: (value: string, record: IGood) => {
415
- if (editGood?.$index === record.$index && !disableds.includes('lineAmountExcludeTax')) {
418
+ if (editGood?.$index === record.$index && !disableds.includes('lineAmountExcludeTax') && model !== 'prefab') {
416
419
  return (
417
420
  <Form.Item>
418
421
  {getFieldDecorator('lineAmountExcludeTax', {
@@ -454,7 +457,7 @@ export default (form: WrappedFormUtils) => {
454
457
  align: 'right',
455
458
  width: 70,
456
459
  render: (value: string, record: IGood) => {
457
- if (editGood?.$index === record.$index && !disableds.includes('taxRate')) {
460
+ if (editGood?.$index === record.$index && !disableds.includes('taxRate') && !(model === 'prefab' && calculateType === '3')) {
458
461
  return (
459
462
  <Form.Item>
460
463
  {getFieldDecorator('taxRate', {
@@ -476,7 +479,7 @@ export default (form: WrappedFormUtils) => {
476
479
  onChangeTaxRate(controller, form, record);
477
480
  }}
478
481
  >
479
- {taxRateList.map((e, i) => {
482
+ {(record.goodsTaxRateList || taxRateList).map((e, i) => {
480
483
  return (
481
484
  <Select.Option key={i} value={e}>
482
485
  {e}%
@@ -542,7 +545,7 @@ export default (form: WrappedFormUtils) => {
542
545
  ellipsis: true,
543
546
  };
544
547
  }) as any[];
545
- }, [isTaxIncluded, editGood, controller, taxRateList, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart]);
548
+ }, [isTaxIncluded, editGood, controller, taxRateList, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart, calculateType]);
546
549
 
547
550
  // React.useEffect(() => {
548
551
  // clearTimeout(t)
@@ -15,7 +15,7 @@ export default () => {
15
15
 
16
16
  const onClick = React.useCallback(
17
17
  async (record: IGood) => {
18
- if (model === 'prefab') return;
18
+ // if (model === 'prefab') return;
19
19
  if (model === 'readOnly') return;
20
20
 
21
21
  const editGood = controller.state.goodsListState.editGood;
@@ -25,8 +25,20 @@ export default () => {
25
25
  if (editGood.$index === record.$index) return;
26
26
  await controller.saveEditGood();
27
27
  await controller.wait();
28
+ if (controller.getGoodsTaxRateList && record.taxClassificationCode && !record.goodsTaxRateList ) {
29
+ record.goodsTaxRateList = await controller.getGoodsTaxRateList(record.taxClassificationCode);
30
+ // if (record.taxRate !== undefined && record.taxRate !== null && !record.goodsTaxRateList.includes(record.taxRate)) {
31
+ // record.taxRate = undefined;
32
+ // }
33
+ }
28
34
  await controller.pipeline(async s => { s.goodsListState.editGood || (await controller.setEditGood(record)) })();
29
35
  } else {
36
+ if (controller.getGoodsTaxRateList && record.taxClassificationCode && !record.goodsTaxRateList ) {
37
+ record.goodsTaxRateList = await controller.getGoodsTaxRateList(record.taxClassificationCode);
38
+ // if (record.taxRate !== undefined && record.taxRate !== null && !record.goodsTaxRateList.includes(record.taxRate)) {
39
+ // record.taxRate = undefined;
40
+ // }
41
+ }
30
42
  await controller.setEditGood(record);
31
43
  }
32
44
  },