kts-component-invoice-operate 3.2.60 → 3.2.62

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 (28) hide show
  1. package/README.md +4 -1
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.d.ts +2 -0
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.d.ts +2 -1
  4. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  5. package/dist/Invoice/tools/coolingFn/index.d.ts +1 -1
  6. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +1 -1
  7. package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.d.ts +6 -0
  8. package/dist/index.esm.js +358 -118
  9. package/dist/index.js +358 -118
  10. package/package.json +1 -1
  11. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +3 -0
  12. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +2 -1
  13. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +4 -1
  14. package/src/Invoice/_test/endowCode/index.tsx +53 -2
  15. package/src/Invoice/tools/coolingFn/index.ts +1 -1
  16. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +24 -21
  17. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +4 -0
  18. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +5 -1
  19. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +1 -1
  20. package/src/Invoice/ui/default/GoodsList/index.tsx +7 -0
  21. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.tsx +104 -0
  22. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +8 -1
  23. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.less +16 -1
  24. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +12 -1
  25. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.tsx +56 -37
  26. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +0 -2
  27. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.less +16 -1
  28. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +14 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.60",
3
+ "version": "3.2.62",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -10,4 +10,7 @@ export default class Drag {
10
10
 
11
11
  /** 准备插入的货物索引 */
12
12
  container?: string;
13
+
14
+ /** 插入位置 */
15
+ site?: 'u' | 'd'
13
16
  }
@@ -1,6 +1,7 @@
1
1
  enum LineAttributeType {
2
2
  正常 = 0,
3
3
  折扣行 = 1,
4
- 被折扣行 = 2
4
+ 被折扣行 = 2,
5
+ 折让行 = 3,
5
6
  }
6
7
  export default LineAttributeType;
@@ -43,7 +43,7 @@ export default class GoodsListState {
43
43
  columnsReplenish: { [key: string]: IColumnsReplenish } = {};
44
44
 
45
45
  /** 商品表格隐藏列 */
46
- columnshide:string[] = ['itemCode'];
46
+ columnshide: string[] = ['itemCode'];
47
47
 
48
48
  /** 单位列表 */
49
49
  unitList: string[] = [];
@@ -99,6 +99,9 @@ export default class GoodsListState {
99
99
  /** 是否可以合并折扣 */
100
100
  isMergeDiscount = false;
101
101
 
102
+ /** 是否可以销售折让 */
103
+ isSalesDiscount = false;
104
+
102
105
  /** 正在 添加商品对照 的货物 */
103
106
  addComparisonIndex?: string;
104
107
 
@@ -149,7 +149,7 @@ const lines: any[] = [
149
149
  "itemName": "*配电控制设备*公牛(BULL)",
150
150
  "lineAmountExcludeTax": 443365.88,
151
151
  "lineAmountIncludeTax": 501003.53,
152
- "lineAttribute": "2",
152
+ "lineAttribute": 0,
153
153
  "lineDiscountExcludeTax": 4433.66,
154
154
  "lineDiscountRate": null,
155
155
  "lineId": "1740823580142206976",
@@ -200,7 +200,7 @@ const lines: any[] = [
200
200
  "itemName": "*配电控制设备*公牛(BULL)",
201
201
  "lineAmountExcludeTax": -4433.66,
202
202
  "lineAmountIncludeTax": -5010.04,
203
- "lineAttribute": "1",
203
+ "lineAttribute": 0,
204
204
  "lineDiscountExcludeTax": null,
205
205
  "lineDiscountRate": null,
206
206
  "lineId": "1740823580142206976",
@@ -234,6 +234,57 @@ const lines: any[] = [
234
234
  "taxRate": 13,
235
235
  "unit": "",
236
236
  "zeroTaxRateFlag": null
237
+ },
238
+ {
239
+ "buyersItemCode": null,
240
+ "buyersItemModelName": "GN-G32Z104",
241
+ "buyersItemName": "打折",
242
+ "buyersItemUnit": null,
243
+ "discount": null,
244
+ "discountGroup": "31b6d887-4877-4926-abe8-ab49ef6902da",
245
+ "dispatchDocumentReference": null,
246
+ "dispatchLineReference": null,
247
+ "favouredPolicyMark": "0",
248
+ "favouredPolicyName": null,
249
+ "id": "40823568750477313",
250
+ "itemModelName": "",
251
+ "itemName": "打折",
252
+ "lineAmountExcludeTax": -100,
253
+ "lineAmountIncludeTax": -100,
254
+ "lineAttribute": 3,
255
+ "lineDiscountExcludeTax": null,
256
+ "lineDiscountRate": null,
257
+ "lineId": "1740823580142206976",
258
+ "lineOrder": 2,
259
+ "materialCode": null,
260
+ "noticeCodeNo": null,
261
+ "noticeLineId": null,
262
+ "orderLineId": null,
263
+ "orderLineReference": null,
264
+ "orderNo": null,
265
+ "orderReference": null,
266
+ "priceExcludeTax": null,
267
+ "priceIncludeTax": null,
268
+ "quantity": null,
269
+ "receiptDocumentReference": null,
270
+ "receiptLineReference": null,
271
+ "reconciliationDocumentReference": null,
272
+ "reconciliationSheetLineReference": null,
273
+ "relationReferences": null,
274
+ "requisitionLineNo": null,
275
+ "sellersItemCode": null,
276
+ "sellersItemModelName": null,
277
+ "sellersItemName": "*配电控制设备*1",
278
+ "sellersItemUnit": null,
279
+ "specialManagement": null,
280
+ "statementCode": null,
281
+ "statementLineId": null,
282
+ "taxAmount": -576.38,
283
+ "taxClassificationCode": "1090407030000000000",
284
+ "taxDiscount": null,
285
+ "taxRate": 0,
286
+ "unit": "",
287
+ "zeroTaxRateFlag": null
237
288
  }
238
289
  ]
239
290
 
@@ -4,9 +4,9 @@ const keys: { [key: string]: any } = {}
4
4
 
5
5
  /**
6
6
  * 有冷却时间的函数
7
- * @param fn 方法
8
7
  * @param key 方法key
9
8
  * @param delayed 冷却时间
9
+ * @param fn 方法
10
10
  */
11
11
  export default (key: string = 'default', delayed: number = 200, fn: Function) => {
12
12
  if (keys[key]) {
@@ -34,32 +34,30 @@ export default function Drag(props: IDragProps) {
34
34
  const currentGood = controller.state.goodsListState.goodsList.filter(e => e.$index === record.$index)[0];
35
35
  mounting(<DragDiv {...currentGood} />)
36
36
 
37
- // 监听移动
38
- rowList.forEach(e => { e.addEventListener('mouseover', onMouseover) });
39
- function onMouseover(e: MouseEvent) {
37
+ rowList.forEach(e => { e.addEventListener('mousemove', onMousemove) });
38
+ function onMousemove(e: MouseEvent) {
40
39
  controller.run(async s => {
41
- const container = s.goodsListState.drag.container = getRow(e.target)?.dataset?.rowKey;
42
- if (!container) return;
40
+ const rowDom = getRow(e.target);
41
+ const container = s.goodsListState.drag.container = rowDom?.dataset?.rowKey;
42
+
43
+ /** 准备插入的货物 */
44
+ const row = s.goodsListState.goodsMap.get(container); if (!row) return;
43
45
 
44
46
  // 不可以插入自己
45
47
  if (container === s.goodsListState.drag.current) {
46
- s.goodsListState.drag.container = undefined;
47
- return;
48
+ return s.goodsListState.drag.container = undefined;
48
49
  }
49
50
 
50
- const currentGood = s.goodsListState.drag.current && s.goodsListState.goodsMap.get(s.goodsListState.drag.current);
51
- if (!currentGood) return;
52
-
53
- const row = s.goodsListState.goodsMap.get(container);
54
- if (!row) return;
51
+ /** 当前拖动中的货品 */
52
+ const currentGood = s.goodsListState.drag.current && s.goodsListState.goodsMap.get(s.goodsListState.drag.current); if (!currentGood) return;
55
53
 
56
54
  // 折扣行 不可以插入 自己的被折扣行
57
55
  if (currentGood.lineAttribute === LineAttributeType.折扣行) {
58
56
  const currentIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(currentGood.$index)
59
57
  const containerIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(row.$index)
60
58
  if (currentIndex - 1 === containerIndex) {
61
- s.goodsListState.drag.container = undefined;
62
- return;
59
+ return s.goodsListState.drag.container = undefined;
60
+
63
61
  }
64
62
  }
65
63
 
@@ -68,8 +66,7 @@ export default function Drag(props: IDragProps) {
68
66
  const currentIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(currentGood.$index)
69
67
  const containerIndex = s.goodsListState.goodsList.map(e => e.$index).indexOf(row.$index)
70
68
  if (currentIndex + 1 === containerIndex) {
71
- s.goodsListState.drag.container = undefined;
72
- return;
69
+ return s.goodsListState.drag.container = undefined;
73
70
  }
74
71
  }
75
72
 
@@ -77,9 +74,15 @@ export default function Drag(props: IDragProps) {
77
74
  if (row.lineAttribute === LineAttributeType.折扣行) {
78
75
  const t = s.goodsListState.goodsList.map(e => e.$index).indexOf(container) - 1;
79
76
  s.goodsListState.drag.container = s.goodsListState.goodsList[t].$index;
77
+ s.goodsListState.drag.site = 'u'
78
+ } else if (row.lineAttribute === LineAttributeType.被折扣行) {
79
+ s.goodsListState.drag.site = 'd'
80
+ } else {
81
+ const rect = rowDom.getBoundingClientRect();
82
+ const mouseY = e.clientY - rect.top;
83
+ s.goodsListState.drag.site = mouseY > 15 ? 'd' : 'u';
80
84
  }
81
- });
82
-
85
+ })
83
86
 
84
87
  const getRow = (t: any): any => {
85
88
  try {
@@ -100,7 +103,7 @@ export default function Drag(props: IDragProps) {
100
103
  insert();
101
104
  controller.run(async s => s.goodsListState.drag.current = undefined);
102
105
  window.removeEventListener('mouseup', onMouseup);
103
- rowList.forEach(e => { e.removeEventListener('mouseover', onMouseover) });
106
+ rowList.forEach(e => { e.removeEventListener('mousemove', onMousemove) });
104
107
  // window.document.body.removeChild(rowDiv);
105
108
  }
106
109
 
@@ -108,7 +111,7 @@ export default function Drag(props: IDragProps) {
108
111
  function insert() {
109
112
  mounting(<></>);
110
113
  controller.run(async s => {
111
- const { container, current } = s.goodsListState.drag;
114
+ const { container, current, site } = s.goodsListState.drag;
112
115
  if (!container || !current) return;
113
116
  if (container !== current) {
114
117
  const goodsList = s.goodsListState.goodsList;
@@ -126,7 +129,7 @@ export default function Drag(props: IDragProps) {
126
129
 
127
130
  (() => {
128
131
  const g = s.goodsListState.goodsList.filter(e => moveGoods.indexOf(e.$index) < 0);
129
- const t = g.map(e => e.$index).indexOf(container);
132
+ const t = site === 'u' ? g.map(e => e.$index).indexOf(container) : g.map(e => e.$index).indexOf(container) + 1;
130
133
  const m = moveGoods.map(e => goodsMap.get(e)).filter(e => !!e) as IGood[];
131
134
  s.goodsListState.goodsList = (g.splice.apply(g, [t, 0, ...m]), g);
132
135
  })()
@@ -17,6 +17,10 @@ export default (goods: IGood) => {
17
17
  controller.delGood(goods.$index);
18
18
  }, [controller, goods.$index]);
19
19
 
20
+ if (goods.lineAttribute === LineAttributeType.折让行) {
21
+ return undefined;
22
+ }
23
+
20
24
  if (goods.lineAttribute === LineAttributeType.被折扣行) {
21
25
  return undefined;
22
26
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  // import { Button } from 'kts-components-antd-x3';
3
3
  import Invoice from '../../../../../../../../..';
4
- import { IGood } from '../../../../../../../../../InvoiceController';
4
+ import { IGood, LineAttributeType } from '../../../../../../../../../InvoiceController';
5
5
  import { endowCode } from '../../../../autoFillFn';
6
6
 
7
7
  // const { Text } = Typography;
@@ -14,6 +14,10 @@ export default (goods: IGood) => {
14
14
  endowCode(controller, goods);
15
15
  }, [controller, goods]);
16
16
 
17
+ if (goods.lineAttribute === LineAttributeType.折让行) {
18
+ return undefined;
19
+ }
20
+
17
21
  return {
18
22
  key: 'endowCode',
19
23
  title: '赋码',
@@ -84,7 +84,7 @@ export default () => {
84
84
  await controller.pipeline(async s => {
85
85
  s.goodsListState.selectedGoodIndex.forEach($index => {
86
86
  const goods = s.goodsListState.goodsMap.get($index);
87
- if (!goods || goods.lineAttribute === LineAttributeType.正常) return;
87
+ if (!goods || (goods.lineAttribute !== LineAttributeType.折扣行 && goods.lineAttribute !== LineAttributeType.被折扣行)) return;
88
88
 
89
89
  // 数组位置
90
90
  let t = s.goodsListState.goodsList.indexOf(goods);
@@ -29,6 +29,7 @@ import useDelRowButton from './ui/BulkMenu/hooks/useDelRowButton';
29
29
  import useAddDiscountRowButton from './ui/BulkMenu/hooks/useAddDiscountRowButton';
30
30
  import useMergeDetails from './ui/BulkMenu/hooks/useMergeDetails';
31
31
  import useMergeDiscount from './ui/BulkMenu/hooks/useMergeDiscount';
32
+ import uaeSalesDiscount from './ui/BulkMenu/hooks/uaeSalesDiscount';
32
33
 
33
34
  export interface IGoodsListProps {
34
35
  /** 扩展部分 */
@@ -91,6 +92,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
91
92
  /** 全单合并折扣 */
92
93
  const mergeDiscount = useMergeDiscount()
93
94
 
95
+ /** 销售折让 */
96
+ const salesDiscount = uaeSalesDiscount()
97
+
94
98
  /** 清空自动赋码缓存 */
95
99
  React.useEffect(() => {
96
100
  controller.run(async s => { s.goodsListState.endowCode.cache = {} });
@@ -149,6 +153,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
149
153
  {/* 添加折扣行 */}
150
154
  {addDiscountRowButton.drawer}
151
155
 
156
+ {/* 销售折让 */}
157
+ {salesDiscount.button}
158
+
152
159
  {/* 搜索 */}
153
160
  <Search />
154
161
  </div>
@@ -0,0 +1,104 @@
1
+
2
+ import React from "react"
3
+ import { Button, message } from "kts-components-antd-x3"
4
+ import { chain, bignumber } from 'mathjs';
5
+ import Invoice from '../../../../../../..'
6
+ import { LineAttributeType } from "../../../../../../../InvoiceController";
7
+
8
+ /** 销售折让 */
9
+ export default function uaeSalesDiscount() {
10
+
11
+ const controller = Invoice.useInvoiceController();
12
+
13
+ const selectedGoodIndex = controller.useMemo(s => s.goodsListState.selectedGoodIndex, []);
14
+
15
+ const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, []);
16
+
17
+ const isSalesDiscount = controller.useMemo(s => s.goodsListState.isSalesDiscount, []);
18
+
19
+ const onClick = React.useCallback(async () => {
20
+ const selectedGood = selectedGoodIndex.map(e => goodsMap.get(e));
21
+
22
+ /** 折让行 */
23
+ const concession = selectedGood.filter(e => e?.lineAttribute === LineAttributeType.折让行)[0];
24
+ if (!concession) {
25
+ const content = '未选择折让行';
26
+ message.error({ content, key: content })
27
+ return;
28
+ }
29
+
30
+ /** 准备添加折扣的货物列表 */
31
+ const discountGood = selectedGood.filter(e => e?.lineAttribute !== LineAttributeType.折让行);
32
+
33
+ /** 折扣总金额 */
34
+ const totalDiscoline = chain(bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
35
+
36
+ let discolinesSum = chain(bignumber(0));
37
+
38
+ /** 总金额 */
39
+ const totalAmount = (() => {
40
+ let sum = 0;
41
+ discountGood.forEach(e => { sum += e?.lineAmountIncludeTax ?? 0 });
42
+ return sum;
43
+ })()
44
+
45
+ // 每行的折扣金额
46
+ const discolines: number[] = discountGood.map((e, i) => {
47
+ // 折扣金额占比
48
+ const share = chain(bignumber(e?.lineAmountIncludeTax ?? 0))
49
+ .divide(bignumber(totalAmount));
50
+
51
+ // 折扣金额
52
+ const value = totalDiscoline
53
+ .multiply(share.done())
54
+
55
+ .multiply(bignumber(100))
56
+ .round()
57
+ .divide(bignumber(100))
58
+
59
+ .done();
60
+
61
+ discolinesSum = discolinesSum.add(value);
62
+ return value.toNumber();
63
+ });
64
+
65
+ // 剩余折扣金额
66
+ let surplus = totalDiscoline.subtract(discolinesSum.done());
67
+
68
+ // 补充剩余折扣金
69
+ for (let i = 0; i < discolines.length; i++) {
70
+ if (surplus.smaller(0.01).done()) break;
71
+ discolines[i] = chain(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
72
+ surplus = surplus.subtract(bignumber(0.01));
73
+ }
74
+
75
+ // 清楚折让行
76
+ await controller.run(async s => { s.goodsListState.goodsList = s.goodsListState.goodsList.filter(e => e.$index !== concession.$index) })
77
+ await controller.run(async s => { s.goodsListState.selectedGoodIndex = [] });
78
+
79
+ // 给一组货物添加折扣行
80
+ await controller.addGoodDiscountV2(discolines.map((e, i) => {
81
+ return {
82
+ $index: discountGood[i]?.$index as string,
83
+ discolineAmountunt: e as number,
84
+ }
85
+ }))
86
+ }, [controller, selectedGoodIndex, goodsMap])
87
+
88
+ const button = React.useMemo(() => {
89
+ if (!isSalesDiscount) return <></>;
90
+ return (
91
+ <Button
92
+ onClick={onClick}
93
+ disabled={selectedGoodIndex.length <= 1}
94
+ >
95
+ 销售折让
96
+ </Button>
97
+ )
98
+ }, [selectedGoodIndex.length, isSalesDiscount])
99
+
100
+ return {
101
+ /** 按钮 */
102
+ button,
103
+ }
104
+ }
@@ -2,9 +2,10 @@ import React from 'react';
2
2
  import Invoice from '../../../../../../..';
3
3
  import { message, Menu, Button } from 'kts-components-antd-x3';
4
4
  import coolingFn from '../../../../../../../tools/coolingFn';
5
+ import { LineAttributeType } from '../../../../../../../InvoiceController';
5
6
 
6
7
  export default () => {
7
-
8
+
8
9
  const controller = Invoice.useInvoiceController();
9
10
 
10
11
  const model = controller.useMemo(s => s.model, []);
@@ -31,6 +32,12 @@ export default () => {
31
32
  return;
32
33
  }
33
34
 
35
+ // 折让行 不能赋码
36
+ if (s.goodsListState.selectedGoodIndex.map(e => s.goodsListState.goodsMap.get(e)).every(e => e?.lineAttribute !== LineAttributeType.折让行) === false) {
37
+ coolingFn('折让行不能赋码', 3000, () => { message.error('折让行不能赋码') });
38
+ return;
39
+ }
40
+
34
41
  // 设置赋码
35
42
  s.goodsListState.endowCode.endowcodeGoodIndex = s.goodsListState.selectedGoodIndex;
36
43
  })();
@@ -1,4 +1,4 @@
1
- .kts-invoice-operate-goods-list-itemName-drag-container {
1
+ .kts-invoice-operate-goods-list-itemName-drag-container-u {
2
2
  position: relative;
3
3
 
4
4
  &::after {
@@ -11,4 +11,19 @@
11
11
  top : 0;
12
12
  z-index : 9999;
13
13
  }
14
+ }
15
+
16
+ .kts-invoice-operate-goods-list-itemName-drag-container-d {
17
+ position: relative;
18
+
19
+ &::after {
20
+ content : " ";
21
+ width : 100%;
22
+ height : 2px;
23
+ background: #0074ff;
24
+ position : absolute;
25
+ left : 0;
26
+ bottom : 0;
27
+ z-index : 9999;
28
+ }
14
29
  }
@@ -12,8 +12,13 @@ export default function TableRow(props: any) {
12
12
 
13
13
  const goodsMap = controller.useMemo(s => s.goodsListState.goodsMap, [])
14
14
 
15
+ /** 当前拖动中的货品索引 */
15
16
  const current = controller.useMemo(s => s.goodsListState.drag.current, [])
16
17
 
18
+ /** 当前拖动中的货品索引 */
19
+ const site = controller.useMemo(s => s.goodsListState.drag.site, [])
20
+
21
+ /** 准备插入的货物索引 */
17
22
  const container = controller.useMemo(s => s.goodsListState.drag.container, [])
18
23
 
19
24
  const good = React.useMemo(() => goodsMap?.get(rowKey), [rowKey, goodsMap])
@@ -40,7 +45,13 @@ export default function TableRow(props: any) {
40
45
  ) : (
41
46
  <tr
42
47
  {...props}
43
- className={classnames(props.className, discount, (rowKey === container && current) ? 'kts-invoice-operate-goods-list-itemName-drag-container' : undefined)}
48
+ className={classnames(
49
+ props.className,
50
+ discount,
51
+ (rowKey === container && current)
52
+ ? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site
53
+ : undefined
54
+ )}
44
55
  />
45
56
  )
46
57
  )