kts-component-invoice-operate 1.2.22 → 2.0.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.
- package/d.dio +2 -69
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{EndowCode.d.ts → EndowCode/index.d.ts} +2 -2
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{IGood.d.ts → IGood/index.d.ts} +15 -5
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{ImportGoods.d.ts → ImportGoods/index.d.ts} +0 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{LineAttributeType.d.ts → LineAttributeType/index.d.ts} +0 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.d.ts +7 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +9 -0
- package/dist/Invoice/InvoiceController/fns/getGoodsSearch.d.ts +2 -0
- package/dist/Invoice/InvoiceController/index.d.ts +3 -0
- package/dist/Invoice/index.d.ts +1 -1
- package/dist/Invoice/tools/itemName/index.d.ts +14 -0
- package/dist/Invoice/ui/AddComparisonDrawer/index.d.ts +3 -0
- package/dist/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.d.ts +2 -0
- package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddComparison/index.d.ts +4 -0
- package/dist/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.d.ts +4 -2
- package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.d.ts +4 -0
- package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useDelRowButton/index.d.ts +4 -0
- package/dist/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.d.ts +4 -0
- package/dist/Invoice/ui/GoodsList/ui/BulkMenu/index.d.ts +1 -0
- package/dist/Invoice/ui/GoodsList/ui/{DelRowButton → DescribeSwitch}/index.d.ts +0 -0
- package/dist/Invoice/ui/GoodsList/ui/Search/index.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +1650 -615
- package/dist/index.js +1649 -614
- package/docs/index.md +1 -1
- package/package.json +6 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{EndowCode.tsx → EndowCode/index.tsx} +3 -3
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{IGood.ts → IGood/index.ts} +20 -5
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{ImportGoods.ts → ImportGoods/index.ts} +0 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/{LineAttributeType.ts → LineAttributeType/index.ts} +0 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/ProductComparison/index.ts +10 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +14 -1
- package/src/Invoice/InvoiceController/fns/getGoodsSearch.ts +17 -0
- package/src/Invoice/InvoiceController/index.ts +4 -0
- package/src/Invoice/_test/importGoods/index.tsx +21 -3
- package/src/Invoice/index.tsx +5 -1
- package/src/Invoice/tools/itemName/index.ts +48 -0
- package/src/Invoice/ui/AddComparisonDrawer/index.tsx +175 -0
- package/src/Invoice/ui/EndowCodeDrawer/index.tsx +6 -17
- package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +15 -0
- package/src/Invoice/ui/GoodsList/hook/useColumns/index.tsx +100 -32
- package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/hook/useAddComparison/index.tsx +39 -0
- package/src/Invoice/ui/GoodsList/hook/useColumns/ui/RowMenu/index.tsx +5 -2
- package/src/Invoice/ui/GoodsList/hook/useRowSelection/index.tsx +34 -8
- package/src/Invoice/ui/GoodsList/index.less +42 -37
- package/src/Invoice/ui/GoodsList/index.tsx +21 -17
- package/src/Invoice/ui/GoodsList/ui/AddRowButton/index.tsx +5 -2
- package/src/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.less +0 -0
- package/src/Invoice/ui/GoodsList/ui/{AddDiscountRowButton → BulkMenu/hooks/useAddDiscountRowButton}/index.tsx +20 -17
- package/src/Invoice/ui/GoodsList/ui/BulkMenu/hooks/useCommodityComparisonButton/index.tsx +80 -0
- package/src/Invoice/ui/GoodsList/ui/{DelRowButton → BulkMenu/hooks/useDelRowButton}/index.tsx +15 -7
- package/src/Invoice/ui/GoodsList/ui/{EndowCodeButton → BulkMenu/hooks/useEndowCodeButton}/index.tsx +13 -9
- package/src/Invoice/ui/GoodsList/ui/BulkMenu/index.tsx +43 -0
- package/src/Invoice/ui/GoodsList/ui/DescribeSwitch/index.tsx +37 -0
- package/src/Invoice/ui/GoodsList/ui/Search/icon/magnifier.svg +1 -0
- package/src/Invoice/ui/GoodsList/ui/Search/index.less +10 -0
- package/src/Invoice/ui/GoodsList/ui/Search/index.tsx +47 -0
- package/src/Invoice/ui/GoodsList/ui/TaxIncludedSwitch/index.tsx +2 -2
- package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +70 -18
- package/src/index.ts +1 -0
- package/yarn.e.lock +14331 -0
- package/yarn.o.lock +14800 -0
- package/dist/Invoice/ui/GoodsList/ui/EndowCodeButton/index.d.ts +0 -2
- package/docs-dist/404.html +0 -33
- package/docs-dist/index.html +0 -33
- package/docs-dist/static/auto.a6cd905c.svg +0 -1
- package/docs-dist/static/spot.42e620e1.svg +0 -1
- package/docs-dist/umi.css +0 -20
- package/docs-dist/umi.js +0 -1
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { Button, Drawer, Form, message, Input, Typography } from 'kts-components-antd-x3';
|
|
10
|
+
import { Button, Drawer, Form, message, Input, Typography, Menu } from 'kts-components-antd-x3';
|
|
11
11
|
import { FormComponentProps } from 'kts-components-antd-x3/lib/form';
|
|
12
12
|
import { all, create } from 'mathjs';
|
|
13
13
|
import { decorator } from 'grey-react-box';
|
|
14
|
-
import Invoice from '
|
|
15
|
-
import lazyFn from '
|
|
16
|
-
import LineAttributeType from '
|
|
17
|
-
import evaluate from '
|
|
14
|
+
import Invoice from '../../../../../../';
|
|
15
|
+
import lazyFn from '../../../../../../tools/lazyFn';
|
|
16
|
+
import LineAttributeType from '../../../../../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
|
|
17
|
+
import evaluate from '../../../../../../../Invoice/tools/evaluate';
|
|
18
18
|
import './index.less';
|
|
19
19
|
|
|
20
20
|
const { Text } = Typography;
|
|
21
21
|
const { chain } = create(all, { number: 'BigNumber', precision: 20 }) as any;
|
|
22
22
|
|
|
23
|
-
export default
|
|
23
|
+
export default () => {
|
|
24
24
|
/** 控制器 */
|
|
25
25
|
const controller = Invoice.useInvoiceController();
|
|
26
26
|
|
|
@@ -86,15 +86,16 @@ export default decorator<{}, FormComponentProps>(Form.create())((props) => {
|
|
|
86
86
|
})();
|
|
87
87
|
}, [controller]);
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
const menuItem = React.useMemo(() => {
|
|
90
|
+
return model === 'prefab' ? <></> : isAddDiscount !== false ? (
|
|
91
|
+
<Menu.Item key="0" onClick={onClick} disabled={disabled}>
|
|
92
|
+
添加折扣行
|
|
93
|
+
</Menu.Item>
|
|
94
|
+
) : undefined
|
|
95
|
+
}, [isAddDiscount, disabled, onClick])
|
|
90
96
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
isAddDiscount !== false &&
|
|
95
|
-
<Button icon="plus-circle" disabled={disabled} onClick={onClick}>
|
|
96
|
-
添加折扣行
|
|
97
|
-
</Button>}
|
|
97
|
+
const drawer = React.useMemo(() => {
|
|
98
|
+
return (
|
|
98
99
|
<Drawer
|
|
99
100
|
className="kts-invoice-operate-goods-list-add-discount-row"
|
|
100
101
|
width={540}
|
|
@@ -106,9 +107,11 @@ export default decorator<{}, FormComponentProps>(Form.create())((props) => {
|
|
|
106
107
|
>
|
|
107
108
|
<DrawerBody />
|
|
108
109
|
</Drawer>
|
|
109
|
-
|
|
110
|
-
)
|
|
111
|
-
|
|
110
|
+
)
|
|
111
|
+
}, [visible, onClose])
|
|
112
|
+
|
|
113
|
+
return { menuItem, drawer }
|
|
114
|
+
};
|
|
112
115
|
|
|
113
116
|
const DrawerBody = decorator<{}, FormComponentProps>(Form.create())((props) => {
|
|
114
117
|
const { form } = props;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Menu, message } from 'kts-components-antd-x3';
|
|
3
|
+
import coolingFn from '../../../../../../tools/coolingFn'
|
|
4
|
+
import { getSN, setShorthand } from '../../../../../../tools/itemName'
|
|
5
|
+
import { Invoice, IGood } from '../../../../../../../';
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
|
|
9
|
+
const controller = Invoice.useInvoiceController();
|
|
10
|
+
|
|
11
|
+
const { onComply } = controller.useMemo(s => s.goodsListState.productComparison, [])
|
|
12
|
+
|
|
13
|
+
/** 是否禁用 */
|
|
14
|
+
const disabled = controller.useMemo((s) => {
|
|
15
|
+
if (s.goodsListState.selectedGoodIndex.length <= 0) return true;
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
/** 点击了 */
|
|
19
|
+
const onClick = React.useCallback(async () => {
|
|
20
|
+
await controller.saveEditGood();
|
|
21
|
+
await controller.wait();
|
|
22
|
+
await controller.run(async s => {
|
|
23
|
+
|
|
24
|
+
// 不能给正在编辑的货物对照
|
|
25
|
+
if (s.goodsListState.editGood && s.goodsListState.selectedGoodIndex.indexOf(s.goodsListState.editGood.$index) >= 0) {
|
|
26
|
+
coolingFn('不能给正在编辑的货物执行商品对照', 3000, () => { message.error('不能给正在编辑的货物执行商品对照') });
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (!s.goodsListState?.productComparison?.onComply) return;
|
|
31
|
+
|
|
32
|
+
const goods = s.goodsListState.selectedGoodIndex.map(e => {
|
|
33
|
+
const t = s.goodsListState.goodsMap.get(e);
|
|
34
|
+
if (!t) return undefined;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
...t,
|
|
38
|
+
itemName: getSN(t.itemName)?.full,
|
|
39
|
+
itemNameOther: getSN(t.itemNameOther)?.full,
|
|
40
|
+
} as IGood
|
|
41
|
+
}).filter(e => !!e) as IGood[]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// 比对后的商品
|
|
45
|
+
const newGoods = await s.goodsListState.productComparison.onComply(goods);
|
|
46
|
+
|
|
47
|
+
newGoods.filter(e => {
|
|
48
|
+
const vt = s.goodsListState.goodsMap.get(e.$index);
|
|
49
|
+
if (!vt) return undefined;
|
|
50
|
+
|
|
51
|
+
vt.itemName = e.itemName ? setShorthand(e.itemName, getSN(vt.itemName)?.shorthand) : vt.itemName;
|
|
52
|
+
vt.itemNameOther = e.itemNameOther ? setShorthand(e.itemNameOther, getSN(vt.itemNameOther)?.shorthand) : vt.itemNameOther;
|
|
53
|
+
|
|
54
|
+
vt.unit = e.unit ? e.unit : vt.unit;
|
|
55
|
+
vt.unitOther = e.unitOther ? e.unitOther : vt.unitOther;
|
|
56
|
+
|
|
57
|
+
vt.itemModelName = e.itemModelName ? e.itemModelName : vt.itemModelName;
|
|
58
|
+
vt.itemModelNameOther = e.itemModelNameOther ? e.itemModelNameOther : vt.itemModelNameOther;
|
|
59
|
+
|
|
60
|
+
vt.itemCode = e.itemCode ? e.itemCode : vt.itemCode;
|
|
61
|
+
vt.itemCodeOther = e.itemCodeOther ? e.itemCodeOther : vt.itemCodeOther;
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
}, [])
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
const menuItem = React.useMemo(() => {
|
|
68
|
+
|
|
69
|
+
// 没用 执行商品对照 的方法 不显示按钮
|
|
70
|
+
if (!onComply) return <></>;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Menu.Item key="3" disabled={disabled} onClick={onClick} >
|
|
74
|
+
执行商品对照
|
|
75
|
+
</Menu.Item>
|
|
76
|
+
);
|
|
77
|
+
}, [])
|
|
78
|
+
|
|
79
|
+
return { menuItem }
|
|
80
|
+
};
|
package/src/Invoice/ui/GoodsList/ui/{DelRowButton → BulkMenu/hooks/useDelRowButton}/index.tsx
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Invoice from '
|
|
3
|
-
import LineAttributeType from '
|
|
4
|
-
import {
|
|
2
|
+
import Invoice from '../../../../../../';
|
|
3
|
+
import LineAttributeType from '../../../../../../InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType';
|
|
4
|
+
import { Menu } from 'kts-components-antd-x3';
|
|
5
5
|
|
|
6
6
|
export default () => {
|
|
7
|
+
|
|
7
8
|
const controller = Invoice.useInvoiceController();
|
|
8
9
|
|
|
9
10
|
const model = controller.useMemo(s => s.model, []);
|
|
@@ -41,9 +42,16 @@ export default () => {
|
|
|
41
42
|
})();
|
|
42
43
|
}, [controller]);
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
const menuItem = React.useMemo(() => {
|
|
46
|
+
|
|
47
|
+
if (model === 'prefab') return <></>;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Menu.Item key="1" onClick={onClick} disabled={disabled}>
|
|
51
|
+
删除行
|
|
52
|
+
</Menu.Item>
|
|
53
|
+
)
|
|
54
|
+
}, [model, onClick, disabled])
|
|
45
55
|
|
|
46
|
-
return
|
|
47
|
-
<Button icon="delete" onClick={onClick} disabled={disabled}>删除行</Button>
|
|
48
|
-
);
|
|
56
|
+
return { menuItem };
|
|
49
57
|
};
|
package/src/Invoice/ui/GoodsList/ui/{EndowCodeButton → BulkMenu/hooks/useEndowCodeButton}/index.tsx
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Invoice from '
|
|
3
|
-
import {
|
|
4
|
-
import coolingFn from '
|
|
5
|
-
// import { LineAttributeType } from '../../../../InvoiceController';
|
|
2
|
+
import Invoice from '../../../../../../';
|
|
3
|
+
import { message ,Menu} from 'kts-components-antd-x3';
|
|
4
|
+
import coolingFn from '../../../../../../tools/coolingFn';
|
|
6
5
|
|
|
7
6
|
export default () => {
|
|
8
7
|
const controller = Invoice.useInvoiceController();
|
|
@@ -34,9 +33,14 @@ export default () => {
|
|
|
34
33
|
})();
|
|
35
34
|
}, [controller]);
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const menuItem = React.useMemo(() => {
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Menu.Item key="2" onClick={onClick} disabled={disabled}>
|
|
40
|
+
批量赋码
|
|
41
|
+
</Menu.Item>
|
|
42
|
+
)
|
|
43
|
+
}, [onClick, disabled])
|
|
44
|
+
|
|
45
|
+
return { menuItem };
|
|
42
46
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Button, Dropdown, Menu } from "kts-components-antd-x3";
|
|
4
|
+
|
|
5
|
+
import useDelRowButton from "./hooks/useDelRowButton";
|
|
6
|
+
import useAddDiscountRowButton from "./hooks/useAddDiscountRowButton";
|
|
7
|
+
import useEndowCodeButton from "./hooks/useEndowCodeButton";
|
|
8
|
+
import useCommodityComparisonButton from "./hooks/useCommodityComparisonButton";
|
|
9
|
+
|
|
10
|
+
export default function BulkMenu() {
|
|
11
|
+
|
|
12
|
+
/** 删除行 */
|
|
13
|
+
const delRowButton = useDelRowButton();
|
|
14
|
+
|
|
15
|
+
/** 添加折扣行 */
|
|
16
|
+
const addDiscountRowButton = useAddDiscountRowButton();
|
|
17
|
+
|
|
18
|
+
/** 批量赋码 */
|
|
19
|
+
const endowCodeButton = useEndowCodeButton();
|
|
20
|
+
|
|
21
|
+
/** 执行商品对照 */
|
|
22
|
+
const commodityComparisonButton = useCommodityComparisonButton();
|
|
23
|
+
|
|
24
|
+
const menu = (
|
|
25
|
+
<Menu>
|
|
26
|
+
{delRowButton.menuItem}
|
|
27
|
+
{addDiscountRowButton.menuItem}
|
|
28
|
+
{endowCodeButton.menuItem}
|
|
29
|
+
{commodityComparisonButton.menuItem}
|
|
30
|
+
</Menu>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<Dropdown overlay={menu}>
|
|
36
|
+
<Button>
|
|
37
|
+
批量操作行
|
|
38
|
+
</Button>
|
|
39
|
+
</Dropdown>
|
|
40
|
+
{addDiscountRowButton.drawer}
|
|
41
|
+
</>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Switch, Icon, Tooltip } from 'kts-components-antd-x3';
|
|
4
|
+
import Invoice from '../../../../';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
|
|
8
|
+
const controller = Invoice.useInvoiceController();
|
|
9
|
+
|
|
10
|
+
const productComparison = controller.useMemo(s => s.goodsListState.productComparison, [])
|
|
11
|
+
|
|
12
|
+
const isMyShow = controller.useMemo(s => s.goodsListState.isMyShow, []);
|
|
13
|
+
|
|
14
|
+
const onChange = React.useCallback(e => {
|
|
15
|
+
controller.run(async s => s.goodsListState.isMyShow = !s.goodsListState.isMyShow)
|
|
16
|
+
}, [])
|
|
17
|
+
|
|
18
|
+
if (!productComparison.onComply) return <></>;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<span>
|
|
22
|
+
<label style={{ marginRight: 2 }} >
|
|
23
|
+
<Tooltip title="蓝色代表我方商品描述,黑色代表对方的商品描述。">
|
|
24
|
+
<Icon style={{ marginRight: 3 }} type="info-circle" />
|
|
25
|
+
</Tooltip>
|
|
26
|
+
使用哪方商品描述:
|
|
27
|
+
</label>
|
|
28
|
+
<Switch
|
|
29
|
+
checked={isMyShow}
|
|
30
|
+
checkedChildren="我方"
|
|
31
|
+
unCheckedChildren="对方"
|
|
32
|
+
defaultChecked
|
|
33
|
+
onChange={onChange}
|
|
34
|
+
/>
|
|
35
|
+
</span>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg t="1656901778998" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9253" width="200" height="200"><path d="M985.781333 918.594133 820.773333 765.5264c27.3728-32.973867 49.6544-69.5776 66.436267-109.258667 22.933333-54.218667 34.561067-111.7952 34.561067-171.1296 0-59.333333-11.627733-116.910933-34.561067-171.1296-22.142933-52.354133-53.837867-99.365333-94.200533-139.729067S705.633067 102.222933 653.28 80.08c-54.218667-22.933333-111.7952-34.561067-171.1296-34.561067S365.240533 57.147733 311.021867 80.08c-52.354133 22.142933-99.365333 53.8368-139.729067 94.200533s-72.0576 87.374933-94.200533 139.729067c-22.932267 54.218667-34.56 111.7952-34.56 171.1296 0 59.3344 11.627733 116.910933 34.56 171.1296 22.144 52.354133 53.837867 99.365333 94.200533 139.729067s87.374933 72.0576 139.729067 94.200533c54.218667 22.932267 111.7952 34.56 171.1296 34.56s116.910933-11.627733 171.1296-34.56c45.352533-19.181867 86.686933-45.543467 123.172267-78.487467L942.256 965.514667c6.16 5.714133 13.966933 8.539733 21.755733 8.539733 8.593067 0 17.163733-3.441067 23.467733-10.237867C999.4976 950.8608 998.738133 930.612267 985.781333 918.594133zM482.151467 860.7584c-207.117867 0-375.620267-168.5024-375.620267-375.620267 0-207.1168 168.5024-375.6192 375.620267-375.6192S857.770667 278.021333 857.770667 485.138133C857.770667 692.256 689.268267 860.7584 482.151467 860.7584z" p-id="9254"></path></svg>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Icon, Input, message } from "kts-components-antd-x3";
|
|
4
|
+
import { ReactComponent as MagnifierSvg } from './icon/magnifier.svg';
|
|
5
|
+
import Invoice from '../../../../';
|
|
6
|
+
import './index.less';
|
|
7
|
+
|
|
8
|
+
export default function Search() {
|
|
9
|
+
|
|
10
|
+
const controller = Invoice.useInvoiceController();
|
|
11
|
+
|
|
12
|
+
const [value, setValue] = React.useState('');
|
|
13
|
+
|
|
14
|
+
const readOnly = controller.useMemo(s => !!s.goodsListState.editGood, [])
|
|
15
|
+
|
|
16
|
+
const onClick = React.useCallback(async () => {
|
|
17
|
+
await controller.saveEditGood();
|
|
18
|
+
await controller.wait();
|
|
19
|
+
if (controller.state.goodsListState.editGood) {
|
|
20
|
+
message.error({
|
|
21
|
+
content: '你正在编辑一个货物',
|
|
22
|
+
key: '你正在编辑一个货物',
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
28
|
+
React.useEffect(() => {
|
|
29
|
+
controller.run(async s => {
|
|
30
|
+
s.goodsListState.searchValue = value;
|
|
31
|
+
})
|
|
32
|
+
}, [value, controller])
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Input
|
|
36
|
+
size="small"
|
|
37
|
+
readOnly={readOnly}
|
|
38
|
+
value={value}
|
|
39
|
+
className="kts-invoice-operate-goods-list-search"
|
|
40
|
+
placeholder="请您输入货物名称、规格型号、金额(含税)搜索"
|
|
41
|
+
prefix={<Icon component={MagnifierSvg} style={{ color: "#b8b8b8" }} />}
|
|
42
|
+
onChange={e => { setValue(e.target.value); }}
|
|
43
|
+
onClick={onClick}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
@@ -14,12 +14,12 @@ export default () => {
|
|
|
14
14
|
const isSwitchTax = controller.useMemo(e => e.goodsListState.isSwitchTax, []);
|
|
15
15
|
|
|
16
16
|
const onChange = React.useCallback(e => {
|
|
17
|
-
controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded: e } })()
|
|
17
|
+
controller.pipeline(async s => { s.goodsListState = { ...s.goodsListState, isTaxIncluded: e } })();
|
|
18
18
|
}, [])
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<span>
|
|
22
|
-
<label>含税:</label>
|
|
22
|
+
<label style={{ marginRight: 2 }}>含税:</label>
|
|
23
23
|
<Switch
|
|
24
24
|
disabled={isSwitchTax === false}
|
|
25
25
|
checked={isTaxIncluded}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Drawer,
|
|
2
|
+
import { Drawer, Table } from 'kts-components-antd-x3';
|
|
3
3
|
import Invoice from '../../';
|
|
4
4
|
import { updateUnitPriceExcludingTax, updateUnitPriceTax, dutyFree, format15 } from '../GoodsList/hook/useColumns/autoFillFn';
|
|
5
5
|
import { countAmountIncludeTax } from '../../tools/calculate'
|
|
6
|
+
import { getSN } from '../../tools/itemName'
|
|
6
7
|
import { IGood } from '../../InvoiceController';
|
|
7
8
|
import evaluate from '../../tools/evaluate';
|
|
8
9
|
|
|
@@ -68,8 +69,10 @@ const DrawerBody = () => {
|
|
|
68
69
|
async s => {
|
|
69
70
|
Object.keys(record).filter(e => !record[e] && record[e] !== 0).forEach(e => { delete record[e] });
|
|
70
71
|
|
|
72
|
+
// 导入时校验函数
|
|
71
73
|
if (await s.goodsListState.importGoods.verifyFn(record) === false) return;
|
|
72
74
|
|
|
75
|
+
// 没用 被编辑的货物 和 form 就退出
|
|
73
76
|
if (!s.goodsListState.editGood || !s.goodsListState.form) return;
|
|
74
77
|
|
|
75
78
|
if (s.goodsListState.editGood.lineAmountExcludeTax || s.goodsListState.editGood.lineAmountIncludeTax) {
|
|
@@ -79,25 +82,42 @@ const DrawerBody = () => {
|
|
|
79
82
|
record.lineAmountIncludeTax = s.goodsListState.editGood.lineAmountIncludeTax;
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
// 中间数据
|
|
86
|
+
const between = { ...record };
|
|
87
|
+
between.itemName = getItemName(record, s.goodsListState.editGood);
|
|
88
|
+
between.itemNameOther = getItemNameOther(record, s.goodsListState.editGood);
|
|
84
89
|
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
// 设置编辑货物
|
|
91
|
+
const editGood: IGood = s.goodsListState.editGood = { ...s.goodsListState.editGood, ...between };
|
|
87
92
|
|
|
88
|
-
if (
|
|
89
|
-
s.goodsListState.editGood
|
|
90
|
-
|
|
93
|
+
if (editGood.taxRate) {
|
|
94
|
+
editGood.taxRate = dutyFree(controller, editGood.taxRate, s.goodsListState.form, editGood)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (`${editGood.priceIncludeTax}` === '0') {
|
|
98
|
+
editGood.priceIncludeTax = undefined;
|
|
99
|
+
editGood.priceExcludeTax = undefined;
|
|
91
100
|
} else {
|
|
92
|
-
|
|
101
|
+
editGood.priceExcludeTax = getPriceExcludeTax(editGood, record) as number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (editGood.quantity && editGood.priceIncludeTax) {
|
|
105
|
+
editGood.lineAmountIncludeTax = countAmountIncludeTax(editGood.quantity, editGood.priceIncludeTax);
|
|
93
106
|
}
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
// 导入FORM里
|
|
109
|
+
if (s.goodsListState.isMyShow) {
|
|
110
|
+
s.goodsListState.form.setFieldsValue(editGood);
|
|
111
|
+
} else {
|
|
112
|
+
s.goodsListState.form.setFieldsValue({
|
|
113
|
+
...editGood,
|
|
114
|
+
itemName: editGood.itemNameOther,
|
|
115
|
+
unit: editGood.unitOther,
|
|
116
|
+
itemModelName: editGood.itemModelNameOther,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
97
119
|
|
|
98
|
-
s.goodsListState.editGood.itemName = getItemName(record);
|
|
99
120
|
|
|
100
|
-
s.goodsListState.form.setFieldsValue(s.goodsListState.editGood as any);
|
|
101
121
|
s.goodsListState.importGoods.isVisibleDrawer = false;
|
|
102
122
|
|
|
103
123
|
s.goodsListState.isTaxIncluded
|
|
@@ -113,11 +133,11 @@ const DrawerBody = () => {
|
|
|
113
133
|
};
|
|
114
134
|
|
|
115
135
|
/** 货物名称 */
|
|
116
|
-
const getItemName = (record: any) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
136
|
+
// const getItemName = (record: any) => {
|
|
137
|
+
// return record.shorthand
|
|
138
|
+
// ? `*${record.shorthand}*${record.itemName}`
|
|
139
|
+
// : record.itemName;
|
|
140
|
+
// };
|
|
121
141
|
|
|
122
142
|
/** 货物单价,不含税 */
|
|
123
143
|
const getPriceExcludeTax = (s: IGood, record: any) => {
|
|
@@ -126,3 +146,35 @@ const getPriceExcludeTax = (s: IGood, record: any) => {
|
|
|
126
146
|
// 单价(含税)/(1+税率) = 单价(不含税)
|
|
127
147
|
return format15(evaluate(`${record.priceIncludeTax} / (1+${s.taxRate}/100)`));
|
|
128
148
|
};
|
|
149
|
+
|
|
150
|
+
// 获取我方名称
|
|
151
|
+
const getItemName = (record: any, editGood: IGood) => {
|
|
152
|
+
|
|
153
|
+
let shorthand;
|
|
154
|
+
|
|
155
|
+
shorthand = record.shorthand;
|
|
156
|
+
if (shorthand) {
|
|
157
|
+
return `*${shorthand}*${record.itemName}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
shorthand = getSN(editGood.itemNameOther)?.shorthand;
|
|
161
|
+
if (shorthand) {
|
|
162
|
+
return `*${shorthand}*${record.itemName}`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return record.itemName;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 获取他方名称
|
|
169
|
+
const getItemNameOther = (record: any, editGood: IGood) => {
|
|
170
|
+
if (!editGood.itemNameOther) return editGood.itemNameOther;
|
|
171
|
+
|
|
172
|
+
let shorthand;
|
|
173
|
+
|
|
174
|
+
shorthand = record.shorthand;
|
|
175
|
+
if (shorthand) {
|
|
176
|
+
return `*${shorthand}*${record.itemName}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return record.itemNameOther;
|
|
180
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,3 +3,4 @@ import 'kts-components-antd-x3/dist/kts-components-antd-x3.css';
|
|
|
3
3
|
|
|
4
4
|
export { default as Invoice } from './Invoice';
|
|
5
5
|
export { default as InvoiceController } from './Invoice/InvoiceController';
|
|
6
|
+
export type { default as IGood } from './Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood';
|