kts-component-invoice-operate 3.2.2 → 3.2.4
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.
- package/dist/Invoice/{ui/digtal/GoodsList.o/ui/AddRowButton → Invoice-digtal/_test/prefab}/index.d.ts +1 -0
- package/dist/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.d.ts +1 -1
- package/dist/index.esm.js +21 -5
- package/dist/index.js +21 -5
- package/package.json +2 -2
- package/src/Invoice/Invoice-digtal/_test/prefab/index.tsx +150 -0
- package/src/Invoice/Invoice-digtal/index.md +3 -0
- package/src/Invoice/ui/digtal/GoodsList/hook/useRowSelection/index.tsx +12 -2
- package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +1 -0
- package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useEmptyRefill/index.tsx +1 -0
- package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useReselectInvoiceType/index.tsx +1 -0
- package/src/Invoice/ui/digtal/Stakeholder/index.tsx +5 -1
- package/src/InvoiceTypeModal/index.tsx +2 -1
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/autoFillFn/index.d.ts +0 -35
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/index.d.ts +0 -3
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.d.ts +0 -7
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowEditButton/index.d.ts +0 -6
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.d.ts +0 -4
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.d.ts +0 -7
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useDelItem/index.d.ts +0 -7
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +0 -7
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.d.ts +0 -7
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowSaveButton/index.d.ts +0 -6
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/TitleText/index.d.ts +0 -8
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useDeduction/index.d.ts +0 -8
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useOnRow/index.d.ts +0 -8
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useRowSelection/index.d.ts +0 -8
- package/dist/Invoice/ui/digtal/GoodsList.o/hook/useWindowClick/index.d.ts +0 -8
- package/dist/Invoice/ui/digtal/GoodsList.o/index.d.ts +0 -20
- package/dist/Invoice/ui/digtal/GoodsList.o/ui/TableRow/index.d.ts +0 -2
- package/dist/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.d.ts +0 -4
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/autoFillFn/index.ts +0 -520
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/index.tsx +0 -624
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.less +0 -10
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/ItemNameInput/index.tsx +0 -19
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowEditButton/index.tsx +0 -30
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/_useAddComparison/index.tsx +0 -43
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx +0 -76
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +0 -41
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +0 -34
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.less +0 -13
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/index.tsx +0 -98
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/spot.svg +0 -1
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowSaveButton/index.tsx +0 -14
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/TitleText/index.tsx +0 -20
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useDeduction/index.tsx +0 -24
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useOnRow/index.tsx +0 -39
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useRowSelection/index.tsx +0 -112
- package/src/Invoice/ui/digtal/GoodsList.o/hook/useWindowClick/index.tsx +0 -23
- package/src/Invoice/ui/digtal/GoodsList.o/index.less +0 -7
- package/src/Invoice/ui/digtal/GoodsList.o/index.tsx +0 -132
- package/src/Invoice/ui/digtal/GoodsList.o/ui/AddRowButton/index.tsx +0 -66
- package/src/Invoice/ui/digtal/GoodsList.o/ui/TableRow/index.tsx +0 -28
- package/src/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.less +0 -43
- package/src/Invoice/ui/digtal/GoodsList.o/ui/TableVirtual/index.tsx +0 -109
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/** 添加商品对照 */
|
|
2
|
-
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Menu, message, Typography } from 'kts-components-antd-x3';
|
|
5
|
-
import { IGood, LineAttributeType } from '../../../../../../../../InvoiceController';
|
|
6
|
-
import Invoice from '../../../../../../../../';
|
|
7
|
-
|
|
8
|
-
const { Text } = Typography;
|
|
9
|
-
|
|
10
|
-
export default (goods: IGood) => {
|
|
11
|
-
|
|
12
|
-
const controller = Invoice.useInvoiceController();
|
|
13
|
-
|
|
14
|
-
const productComparison = controller.useMemo(s => s.goodsListState.productComparison, []);
|
|
15
|
-
|
|
16
|
-
const onClick = React.useCallback(async () => {
|
|
17
|
-
await controller.saveEditGood();
|
|
18
|
-
await controller.wait();
|
|
19
|
-
await controller.run(async s => {
|
|
20
|
-
if (s.goodsListState.form) {
|
|
21
|
-
const err: any = s.goodsListState.form.getFieldsError();
|
|
22
|
-
for (let key in err) {
|
|
23
|
-
if (!err[key]) continue;
|
|
24
|
-
message.error(err[key][0]);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
s.goodsListState.addComparisonIndex = goods.$index;
|
|
29
|
-
})
|
|
30
|
-
}, [controller, goods.$index]);
|
|
31
|
-
|
|
32
|
-
if (!(goods.lineAttribute !== LineAttributeType.折扣行)) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return React.useMemo(() => {
|
|
37
|
-
if (productComparison.onComply) {
|
|
38
|
-
return <Menu.Item key="delItem" onClick={onClick}><Text strong>添加商品对照</Text></Menu.Item>
|
|
39
|
-
} else {
|
|
40
|
-
return <></>
|
|
41
|
-
}
|
|
42
|
-
}, [onClick, productComparison])
|
|
43
|
-
};
|
package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useAddDiscount/index.tsx
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Menu, message, Typography } from 'kts-components-antd-x3';
|
|
4
|
-
import { IGood, LineAttributeType } from '../../../../../../../../../InvoiceController';
|
|
5
|
-
import Invoice from '../../../../../../../../..';
|
|
6
|
-
|
|
7
|
-
const { Text } = Typography;
|
|
8
|
-
|
|
9
|
-
export default (goods: IGood) => {
|
|
10
|
-
|
|
11
|
-
const controller = Invoice.useInvoiceController();
|
|
12
|
-
|
|
13
|
-
const model = controller.useMemo(s => s.model, [])
|
|
14
|
-
|
|
15
|
-
/** 是否能添加折扣行 */
|
|
16
|
-
const isAddDiscount = controller.useMemo(s => s.goodsListState.isAddDiscount, [])
|
|
17
|
-
|
|
18
|
-
/** 点击了 添加折扣行 按钮 */
|
|
19
|
-
const onClick = React.useCallback(async e => {
|
|
20
|
-
e.stopPropagation()
|
|
21
|
-
await controller.wait();
|
|
22
|
-
await controller.saveEditGood();
|
|
23
|
-
await controller.run(async s => {
|
|
24
|
-
if (s.goodsListState.form && s.goodsListState.editGood?.$index === goods?.$index) {
|
|
25
|
-
const err: any = s.goodsListState.form.getFieldsError();
|
|
26
|
-
for (let key in err) {
|
|
27
|
-
if (!err[key]) continue;
|
|
28
|
-
message.error(err[key][0]);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
goods = s.goodsListState.goodsMap.get(goods.$index) as any;
|
|
33
|
-
if (goods.taxRate === 0 && s.goodsListState.endowCode.isTaxFreeTypeNeeded && !goods.taxFreeType) {
|
|
34
|
-
message.error({ content: '零税率需要设置免税类型,请在赋码中设置!', key: '零税率需要设置免税类型,请在赋码中设置!' });
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (`${goods.lineAmountIncludeTax}` === '0') {
|
|
38
|
-
message.error({ content: '金额为0不能添加折扣行', key: '金额为0不能添加折扣行' });
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
s.goodsListState.discountGoodIndex = [goods.$index];
|
|
42
|
-
})
|
|
43
|
-
}, [controller, goods.$index]);
|
|
44
|
-
|
|
45
|
-
if (goods.lineAttribute !== LineAttributeType.正常) {
|
|
46
|
-
return undefined
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!(model !== 'prefab')) {
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (!(isAddDiscount !== false)) {
|
|
54
|
-
return undefined
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (goods.lineAttribute !== LineAttributeType.正常) {
|
|
58
|
-
return undefined
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
key:'addDiscount',
|
|
63
|
-
title:'折扣',
|
|
64
|
-
onClick,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// return React.useMemo(() => {
|
|
68
|
-
// if (goods.lineAttribute !== LineAttributeType.正常) {
|
|
69
|
-
// return undefined
|
|
70
|
-
// }
|
|
71
|
-
|
|
72
|
-
// return (
|
|
73
|
-
// <Menu.Item key="addDiscount" onClick={onClick}><Text strong>折扣</Text></Menu.Item>
|
|
74
|
-
// );
|
|
75
|
-
// }, [onClick, goods.lineAttribute]);
|
|
76
|
-
};
|
package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
// import { Menu, Typography } from 'kts-components-antd-x3';
|
|
3
|
-
import { IGood, LineAttributeType } from '../../../../../../../../../InvoiceController';
|
|
4
|
-
import Invoice from '../../../../../../../../..';
|
|
5
|
-
|
|
6
|
-
// const { Text } = Typography;
|
|
7
|
-
|
|
8
|
-
export default (goods: IGood) => {
|
|
9
|
-
|
|
10
|
-
const controller = Invoice.useInvoiceController();
|
|
11
|
-
|
|
12
|
-
const model = controller.useMemo(s => s.model, [])
|
|
13
|
-
|
|
14
|
-
const isRemRow = controller.useMemo(s => s.goodsListState.isRemRow, [])
|
|
15
|
-
|
|
16
|
-
const onClick = React.useCallback(() => {
|
|
17
|
-
controller.delGood(goods.$index);
|
|
18
|
-
}, [controller, goods.$index]);
|
|
19
|
-
|
|
20
|
-
if (goods.lineAttribute === LineAttributeType.被折扣行) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if(isRemRow === false) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!(model !== 'prefab')) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
key:'delItem',
|
|
34
|
-
title:'删除',
|
|
35
|
-
onClick,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// return React.useMemo(() => {
|
|
39
|
-
// return <Menu.Item key="delItem" onClick={onClick}><Text strong type="danger">删除</Text></Menu.Item>
|
|
40
|
-
// }, [onClick])
|
|
41
|
-
};
|
package/src/Invoice/ui/digtal/GoodsList.o/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
// import { Button } from 'kts-components-antd-x3';
|
|
3
|
-
import Invoice from '../../../../../../../../..';
|
|
4
|
-
import { IGood } from '../../../../../../../../../InvoiceController';
|
|
5
|
-
import { endowCode } from '../../../../autoFillFn';
|
|
6
|
-
|
|
7
|
-
// const { Text } = Typography;
|
|
8
|
-
|
|
9
|
-
export default (goods: IGood) => {
|
|
10
|
-
|
|
11
|
-
const controller = Invoice.useInvoiceController();
|
|
12
|
-
|
|
13
|
-
const onClick = React.useCallback(async () => {
|
|
14
|
-
endowCode(controller, goods);
|
|
15
|
-
}, [controller, goods]);
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
key: 'endowCode',
|
|
19
|
-
title: '赋码',
|
|
20
|
-
onClick,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// return React.useMemo(() => {
|
|
24
|
-
// return (
|
|
25
|
-
// <Menu.Item key="endowCode" onClick={onClick} ><Text strong>赋码</Text></Menu.Item>
|
|
26
|
-
// );
|
|
27
|
-
// }, [goods.lineAttribute, onClick])
|
|
28
|
-
|
|
29
|
-
// return React.useMemo(() => {
|
|
30
|
-
// return (
|
|
31
|
-
// <Button key="endowCode" type="link" onClick={onClick} >赋码</Button>
|
|
32
|
-
// );
|
|
33
|
-
// }, [goods.lineAttribute, onClick])
|
|
34
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
.ktsAnt3x-btn.kts-invoice-operate-goods-list-columns-row-menu:focus,
|
|
2
|
-
.ktsAnt3x-btn.kts-invoice-operate-goods-list-columns-row-menu:hover,
|
|
3
|
-
.ktsAnt3x-btn.kts-invoice-operate-goods-list-columns-row-menu {
|
|
4
|
-
font-size: 16px;
|
|
5
|
-
color: #000;
|
|
6
|
-
text-align: center;
|
|
7
|
-
padding: 0;
|
|
8
|
-
}
|
|
9
|
-
.ktsAnt3x-btn.kts-invoice-operate-goods-list-columns-row-menu:hover,
|
|
10
|
-
.ktsAnt3x-btn.kts-invoice-operate-goods-list-columns-row-menu.ktsAnt3x-dropdown-open{
|
|
11
|
-
background: #ebebeb;
|
|
12
|
-
border-radius: 9999px;
|
|
13
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button, Menu, Dropdown, Icon, Typography } from 'kts-components-antd-x3';
|
|
3
|
-
import Invoice from '../../../../../../..';
|
|
4
|
-
import { IGood } from '../../../../../../../InvoiceController';
|
|
5
|
-
import { ReactComponent as SpotSvg } from './spot.svg';
|
|
6
|
-
|
|
7
|
-
import useDelItem from './hook/useDelItem';
|
|
8
|
-
import useAddDiscount from './hook/useAddDiscount';
|
|
9
|
-
import useEndowCode from './hook/useEndowCode';
|
|
10
|
-
// import useAddComparison from './hook/useAddComparison';
|
|
11
|
-
|
|
12
|
-
import './index.less';
|
|
13
|
-
|
|
14
|
-
const { Text } = Typography;
|
|
15
|
-
|
|
16
|
-
export default (props: { goods: IGood }) => {
|
|
17
|
-
|
|
18
|
-
const controller = Invoice.useInvoiceController();
|
|
19
|
-
|
|
20
|
-
const model = controller.useMemo(s => s.model, [])
|
|
21
|
-
|
|
22
|
-
/** 是否能添加折扣行 */
|
|
23
|
-
const isAddDiscount = controller.useMemo(s => s.goodsListState.isAddDiscount, [])
|
|
24
|
-
|
|
25
|
-
const goodsMenuExpand = controller.useMemo(s => s.goodsListState.goodsMenuExpand, []);
|
|
26
|
-
|
|
27
|
-
const delItem = useDelItem(props.goods);
|
|
28
|
-
const addDiscount = useAddDiscount(props.goods);
|
|
29
|
-
const endowCode = useEndowCode(props.goods);
|
|
30
|
-
// const addComparison = useAddComparison(props.goods);
|
|
31
|
-
|
|
32
|
-
const itemList = React.useMemo(() => {
|
|
33
|
-
const arr: any[] = [];
|
|
34
|
-
|
|
35
|
-
endowCode && arr.push(endowCode); // 赋码
|
|
36
|
-
addDiscount && arr.push(addDiscount); // 添加折扣行
|
|
37
|
-
delItem && arr.push(delItem); // 删除
|
|
38
|
-
|
|
39
|
-
// addComparison && arr.push(addComparison); // 添加商品对照
|
|
40
|
-
|
|
41
|
-
if (!goodsMenuExpand || goodsMenuExpand.length === 0) return arr;
|
|
42
|
-
|
|
43
|
-
arr.unshift(<Menu.Divider key="divider-1" />);
|
|
44
|
-
|
|
45
|
-
for (let i = goodsMenuExpand.length - 1; i >= 0; i--) {
|
|
46
|
-
const fn = goodsMenuExpand[i];
|
|
47
|
-
arr.unshift(fn(props.goods.$index, controller));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return arr;
|
|
51
|
-
}, [controller, endowCode, addDiscount, delItem, goodsMenuExpand, props.goods, model, isAddDiscount])
|
|
52
|
-
|
|
53
|
-
const overlay = React.useMemo(() => {
|
|
54
|
-
if (itemList.length <= 2) {
|
|
55
|
-
return undefined
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Menu>
|
|
60
|
-
{itemList.slice(2).map(e => {
|
|
61
|
-
return <Menu.Item key={e.key} onClick={e.onClick} ><Text strong>{e.title}</Text></Menu.Item>
|
|
62
|
-
})}
|
|
63
|
-
</Menu>
|
|
64
|
-
)
|
|
65
|
-
}, [itemList])
|
|
66
|
-
|
|
67
|
-
const buttonList = React.useMemo(() => {
|
|
68
|
-
return (
|
|
69
|
-
<div style={{ flex: 1, textAlign: 'left', display: 'flex', gap: 10 }} >
|
|
70
|
-
{
|
|
71
|
-
itemList.slice(0, 2).map(e => {
|
|
72
|
-
return (
|
|
73
|
-
<Button key={e.key} type='link' onClick={e.onClick} style={{ padding: 0 }} >
|
|
74
|
-
{e.title}
|
|
75
|
-
</Button>
|
|
76
|
-
)
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
</div>
|
|
80
|
-
)
|
|
81
|
-
}, [itemList])
|
|
82
|
-
|
|
83
|
-
if (itemList.length === 0) { return (<></>) }
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<span style={{ padding: '0 0 0 10px', display: 'flex' }}>
|
|
87
|
-
{buttonList}
|
|
88
|
-
{
|
|
89
|
-
overlay &&
|
|
90
|
-
<Dropdown overlay={overlay} trigger={['click']}>
|
|
91
|
-
<Button className="kts-invoice-operate-goods-list-columns-row-menu ant-btn-icon-only" type="link">
|
|
92
|
-
<Icon component={SpotSvg} />
|
|
93
|
-
</Button>
|
|
94
|
-
</Dropdown>
|
|
95
|
-
}
|
|
96
|
-
</span>
|
|
97
|
-
);
|
|
98
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1574652728953" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4119" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M512 512m-96 0a1.5 1.5 0 1 0 192 0 1.5 1.5 0 1 0-192 0Z" p-id="4120"></path><path d="M512 96.64m-96 0a1.5 1.5 0 1 0 192 0 1.5 1.5 0 1 0-192 0Z" p-id="4121"></path><path d="M512 927.36m-96 0a1.5 1.5 0 1 0 192 0 1.5 1.5 0 1 0-192 0Z" p-id="4122"></path></svg>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button } from 'kts-components-antd-x3';
|
|
3
|
-
import Invoice from '../../../../../../';
|
|
4
|
-
import { IGood } from '../../../../../../InvoiceController';
|
|
5
|
-
|
|
6
|
-
export default (props: { goods: IGood }) => {
|
|
7
|
-
const controller = Invoice.useInvoiceController();
|
|
8
|
-
|
|
9
|
-
const onClick = React.useCallback(() => {
|
|
10
|
-
controller.saveEditGood();
|
|
11
|
-
}, [controller]);
|
|
12
|
-
|
|
13
|
-
return <Button type="link" icon="save" onClick={onClick} />;
|
|
14
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Typography } from 'kts-components-antd-x3';
|
|
4
|
-
import { ValidationRule } from 'kts-components-antd-x3/lib/form';
|
|
5
|
-
|
|
6
|
-
const { Text } = Typography;
|
|
7
|
-
|
|
8
|
-
export default (props: { children?: React.ReactNode, required?: boolean, rules?: ValidationRule[] }) => {
|
|
9
|
-
|
|
10
|
-
const { rules, children } = props;
|
|
11
|
-
|
|
12
|
-
const required = React.useMemo(() => rules?.some(e => !!e.required) || props.required, [rules, props.required]);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
{required ? <Text type="danger">*</Text> : <></>}
|
|
17
|
-
{children}
|
|
18
|
-
</>
|
|
19
|
-
)
|
|
20
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* 扣除额 相关业务
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { InvoiceController } from "../../../../../";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 扣除额 相关业务
|
|
11
|
-
*/
|
|
12
|
-
export default function useDeduction(controller: InvoiceController, deduction = 0) {
|
|
13
|
-
|
|
14
|
-
// 更新 扣除额
|
|
15
|
-
React.useEffect(() => { controller.pipeline(async s => s.goodsListState.deduction = deduction)(); }, [controller, deduction]);
|
|
16
|
-
|
|
17
|
-
// 重新计算
|
|
18
|
-
React.useEffect(()=>{
|
|
19
|
-
controller.pipeline(async s=>{
|
|
20
|
-
s.goodsListState.editGood = undefined;
|
|
21
|
-
s.goodsListState.goodsList = [];
|
|
22
|
-
})()
|
|
23
|
-
}, [controller, deduction])
|
|
24
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 表格行事件
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import Invoice from '../../../../..';
|
|
7
|
-
import IGood from '../../../../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
|
|
8
|
-
import { LineAttributeType } from '../../../../../InvoiceController';
|
|
9
|
-
|
|
10
|
-
export default () => {
|
|
11
|
-
/** 控制器 */
|
|
12
|
-
const controller = Invoice.useInvoiceController();
|
|
13
|
-
|
|
14
|
-
const model = controller.useMemo(s => s.model, []);
|
|
15
|
-
|
|
16
|
-
const onClick = React.useCallback(
|
|
17
|
-
async (record: IGood) => {
|
|
18
|
-
if (model === 'prefab') return;
|
|
19
|
-
if (model === 'readOnly') return;
|
|
20
|
-
|
|
21
|
-
const editGood = controller.state.goodsListState.editGood;
|
|
22
|
-
if (record.lineAttribute !== LineAttributeType.正常) return;
|
|
23
|
-
|
|
24
|
-
if (editGood) {
|
|
25
|
-
if (editGood.$index === record.$index) return;
|
|
26
|
-
await controller.saveEditGood();
|
|
27
|
-
await controller.wait();
|
|
28
|
-
await controller.pipeline(async s => { s.goodsListState.editGood || (await controller.setEditGood(record)) })();
|
|
29
|
-
} else {
|
|
30
|
-
await controller.setEditGood(record);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
[controller, model],
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
onClick,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Checkbox } from 'kts-components-antd-x3';
|
|
4
|
-
import { LineAttributeType } from '../../../../../InvoiceController';
|
|
5
|
-
import Invoice from '../../../../..';
|
|
6
|
-
|
|
7
|
-
export default () => {
|
|
8
|
-
|
|
9
|
-
/** 控制器 */
|
|
10
|
-
const controller = Invoice.useInvoiceController();
|
|
11
|
-
|
|
12
|
-
/** 列表选中的货物索引列表 */
|
|
13
|
-
const selectedRowKeys = controller.useMemo(s => s.goodsListState.selectedGoodIndex, []);
|
|
14
|
-
|
|
15
|
-
/** 货物列表 */
|
|
16
|
-
const goodsList = controller.useMemo(s => s.goodsListState.goodsList, []);
|
|
17
|
-
|
|
18
|
-
/** 搜索条件 */
|
|
19
|
-
const searchValue = controller.useMemo(s => s.goodsListState.searchValue, []);
|
|
20
|
-
|
|
21
|
-
/** 是否全选 */
|
|
22
|
-
// const isAll = controller.useMemo(s => s.goodsListState.goodsList.length > 0 && s.goodsListState.selectedGoodIndex.length === s.goodsListState.goodsList.length, [])
|
|
23
|
-
const isAll = controller.useMemo(s => {
|
|
24
|
-
if (s.goodsListState.selectedGoodIndex.length <= 0) return false;
|
|
25
|
-
const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index);
|
|
26
|
-
const selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e => seeGoodsIndex.some(t => e === t));
|
|
27
|
-
return selectedGoodIndex.length === seeGoodsIndex.length
|
|
28
|
-
}, [])
|
|
29
|
-
|
|
30
|
-
const indeterminate = controller.useMemo(s => {
|
|
31
|
-
const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index);
|
|
32
|
-
const selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e => seeGoodsIndex.some(t => e === t));
|
|
33
|
-
if (selectedGoodIndex.length === 0) return false;
|
|
34
|
-
return selectedGoodIndex.length < seeGoodsIndex.length
|
|
35
|
-
}, [])
|
|
36
|
-
|
|
37
|
-
/** 点击了全选 */
|
|
38
|
-
const onClickSelectAll = React.useCallback(async () => {
|
|
39
|
-
if (isAll) {
|
|
40
|
-
await controller.pipeline(async s => {
|
|
41
|
-
const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index)
|
|
42
|
-
|
|
43
|
-
s.goodsListState.selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e=>!seeGoodsIndex.some(t => e === t));
|
|
44
|
-
})()
|
|
45
|
-
} else {
|
|
46
|
-
await controller.pipeline(async s => {
|
|
47
|
-
const seeGoodsIndex = controller.getGoodsSearch(s.goodsListState.goodsList, s.goodsListState.searchValue, s.goodsListState.isTaxIncluded).map(e => e.$index)
|
|
48
|
-
|
|
49
|
-
s.goodsListState.selectedGoodIndex = [...s.goodsListState.selectedGoodIndex, ...seeGoodsIndex];
|
|
50
|
-
s.goodsListState.selectedGoodIndex = Array.from(new Set(s.goodsListState.selectedGoodIndex));
|
|
51
|
-
})()
|
|
52
|
-
}
|
|
53
|
-
await sortOut(true);
|
|
54
|
-
}, [controller, isAll])
|
|
55
|
-
|
|
56
|
-
const onSelect = React.useCallback(async (record, selected) => {
|
|
57
|
-
if (selected) {
|
|
58
|
-
await controller.pipeline(async s => {
|
|
59
|
-
s.goodsListState.selectedGoodIndex = [...s.goodsListState.selectedGoodIndex, record.$index];
|
|
60
|
-
s.goodsListState = { ...s.goodsListState };
|
|
61
|
-
})()
|
|
62
|
-
} else {
|
|
63
|
-
await controller.pipeline(async s => {
|
|
64
|
-
s.goodsListState.selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e => e !== record.$index);
|
|
65
|
-
s.goodsListState = { ...s.goodsListState };
|
|
66
|
-
})()
|
|
67
|
-
}
|
|
68
|
-
await sortOut(selected);
|
|
69
|
-
}, [controller])
|
|
70
|
-
|
|
71
|
-
const columnTitle = React.useMemo(() => {
|
|
72
|
-
return (
|
|
73
|
-
<Checkbox
|
|
74
|
-
onChange={onClickSelectAll}
|
|
75
|
-
indeterminate={indeterminate}
|
|
76
|
-
checked={isAll}
|
|
77
|
-
></Checkbox>
|
|
78
|
-
)
|
|
79
|
-
}, [goodsList, selectedRowKeys, onClickSelectAll, isAll, indeterminate])
|
|
80
|
-
|
|
81
|
-
/** 选择了商品后 调整 折扣行 和 被折扣行 */
|
|
82
|
-
const sortOut = React.useCallback(async (selected: boolean) => {
|
|
83
|
-
await controller.wait();
|
|
84
|
-
await controller.pipeline(async s => {
|
|
85
|
-
s.goodsListState.selectedGoodIndex.forEach($index => {
|
|
86
|
-
const goods = s.goodsListState.goodsMap.get($index);
|
|
87
|
-
if (!goods || goods.lineAttribute === LineAttributeType.正常) return;
|
|
88
|
-
|
|
89
|
-
// 数组位置
|
|
90
|
-
let t = s.goodsListState.goodsList.indexOf(goods);
|
|
91
|
-
goods.lineAttribute === LineAttributeType.折扣行 ? t-- : t++;
|
|
92
|
-
const i = s.goodsListState.goodsList[t].$index;
|
|
93
|
-
if (selected) {
|
|
94
|
-
if (s.goodsListState.selectedGoodIndex.indexOf(i) < 0) s.goodsListState.selectedGoodIndex = [...s.goodsListState.selectedGoodIndex, i];
|
|
95
|
-
} else {
|
|
96
|
-
if (s.goodsListState.selectedGoodIndex.indexOf(i) < 0) s.goodsListState.selectedGoodIndex = s.goodsListState.selectedGoodIndex.filter(e => e !== $index);
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
})()
|
|
100
|
-
}, [controller])
|
|
101
|
-
|
|
102
|
-
React.useEffect(() => {
|
|
103
|
-
sortOut(true);
|
|
104
|
-
}, [sortOut, goodsList])
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
columnWidth: 45,
|
|
108
|
-
columnTitle,
|
|
109
|
-
onSelect,
|
|
110
|
-
selectedRowKeys,
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* 点击组件外部 保存正在编辑的货物
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from "react";
|
|
7
|
-
import { InvoiceController } from "../../../../../";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 点击组件外部 保存正在编辑的货物
|
|
11
|
-
*/
|
|
12
|
-
export default function useWindowClick(controller: InvoiceController) {
|
|
13
|
-
|
|
14
|
-
/** 点击组件外部 保存正在编辑的货物 */
|
|
15
|
-
React.useEffect(() => {
|
|
16
|
-
const click = () => { setTimeout(controller.saveEditGood) };
|
|
17
|
-
|
|
18
|
-
window.addEventListener('click', click);
|
|
19
|
-
return () => {
|
|
20
|
-
window.removeEventListener('click', click);
|
|
21
|
-
};
|
|
22
|
-
}, [controller]);
|
|
23
|
-
}
|