kts-component-invoice-operate 3.1.0 → 3.1.2
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/InvoiceController/InvoiceControllerState/index.d.ts +2 -0
- package/dist/index.esm.js +126 -37
- package/dist/index.js +124 -35
- package/docs-dist/umi.css +1 -1
- package/docs-dist/umi.js +1 -1
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +3 -0
- package/src/Invoice/InvoiceController/fns/saveEditGood.ts +1 -1
- package/src/Invoice/index.tsx +1 -1
- package/src/Invoice/ui/GoodsList/index.less +5 -0
- package/src/Invoice/ui/GoodsList/ui/AddRowButton/index.tsx +31 -18
- package/src/Invoice/ui/GoodsList/ui/Statistics/index.tsx +2 -2
- package/src/Invoice/ui/GoodsList/ui/TaxIncludedSwitch/index.tsx +1 -3
package/package.json
CHANGED
package/src/Invoice/index.tsx
CHANGED
|
@@ -84,7 +84,7 @@ const Main = (props: IInvoiceProps) => {
|
|
|
84
84
|
return (
|
|
85
85
|
<InvoiceContext.Provider key={key} value={controller}>
|
|
86
86
|
|
|
87
|
-
<div className="kts-invoice-operate">
|
|
87
|
+
<div className="kts-invoice-operate" ref={controller.pipeline<HTMLDivElement | null>(async (s, e) => { s.rootElement = e })} >
|
|
88
88
|
{props.invoiceHeader || <InvoiceHeader /> /** 发票头 */}
|
|
89
89
|
{props.buyer || <Buyer /> /** 购买方 */}
|
|
90
90
|
{props.goodsList || <GoodsList /> /** 货物列表 */}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Invoice from '../../../../';
|
|
3
3
|
import { Button, message } from 'kts-components-antd-x3';
|
|
4
|
-
import { LineAttributeType } from '../../../../InvoiceController';
|
|
4
|
+
import InvoiceController, { LineAttributeType } from '../../../../InvoiceController';
|
|
5
5
|
|
|
6
6
|
export default () => {
|
|
7
7
|
const controller = Invoice.useInvoiceController();
|
|
8
8
|
|
|
9
9
|
const model = controller.useMemo(s => s.model, []);
|
|
10
10
|
|
|
11
|
+
const rootElement = controller.useMemo(s => s.rootElement, []);
|
|
12
|
+
|
|
11
13
|
/** 产品数据量 */
|
|
12
14
|
const goodsNum = controller.useMemo(s => s.goodsListState.goodsList.length, []);
|
|
13
15
|
|
|
@@ -18,25 +20,12 @@ export default () => {
|
|
|
18
20
|
const goodMax = controller.useMemo(s => s.goodsListState.goodMax, []);
|
|
19
21
|
|
|
20
22
|
/** 按钮是否禁用 */
|
|
21
|
-
const disabled = React.useMemo(() =>
|
|
22
|
-
return typeof goodMax === 'number' ? goodsNum >= goodMax : !!searchValue;
|
|
23
|
-
}, [goodMax, goodsNum, searchValue])
|
|
23
|
+
const disabled = React.useMemo(() => typeof goodMax === 'number' ? goodsNum >= goodMax : !!searchValue, [goodMax, goodsNum, searchValue])
|
|
24
24
|
|
|
25
25
|
const onClick = React.useCallback(async () => {
|
|
26
|
-
await controller
|
|
27
|
-
await controller
|
|
28
|
-
|
|
29
|
-
if (s.goodsListState.editGood) {
|
|
30
|
-
message.error({
|
|
31
|
-
content: '你正在编辑一个货物',
|
|
32
|
-
key: '你正在编辑一个货物',
|
|
33
|
-
});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
s.goodsListState.editGood = await controller.addGood({ taxRate: s.goodsListState.defaultRate, lineAttribute: LineAttributeType.正常 });
|
|
38
|
-
})();
|
|
39
|
-
}, [controller]);
|
|
26
|
+
await addGood(controller);
|
|
27
|
+
await rollBottom(controller, rootElement);
|
|
28
|
+
}, [controller, rootElement]);
|
|
40
29
|
|
|
41
30
|
if (model === 'prefab') return <></>;
|
|
42
31
|
if (model === 'readOnly') return <></>;
|
|
@@ -47,3 +36,27 @@ export default () => {
|
|
|
47
36
|
</Button>
|
|
48
37
|
);
|
|
49
38
|
};
|
|
39
|
+
|
|
40
|
+
/** 添加一个空货物 */
|
|
41
|
+
async function addGood(controller: InvoiceController) {
|
|
42
|
+
await controller.saveEditGood();
|
|
43
|
+
await controller.wait();
|
|
44
|
+
await controller.run(async (s) => {
|
|
45
|
+
if (s.goodsListState.editGood) {
|
|
46
|
+
message.error({
|
|
47
|
+
content: '你正在编辑一个货物',
|
|
48
|
+
key: '你正在编辑一个货物',
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
s.goodsListState.editGood = await controller.addGood({ taxRate: s.goodsListState.defaultRate, lineAttribute: LineAttributeType.正常 });
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 货物列表,滚动到底部 */
|
|
57
|
+
async function rollBottom(controller: InvoiceController, rootElement: HTMLDivElement | null | undefined) {
|
|
58
|
+
await controller.wait();
|
|
59
|
+
const cont = rootElement?.querySelector('.ktsAntX-table-body');
|
|
60
|
+
if (!cont) return;
|
|
61
|
+
cont.scrollTop = cont.scrollHeight;
|
|
62
|
+
}
|
|
@@ -77,7 +77,7 @@ export default () => {
|
|
|
77
77
|
return (
|
|
78
78
|
<div className="kts-invoice-operate-goods-list-statistics">
|
|
79
79
|
<div className="kts-invoice-operate-goods-list-statistics-row">
|
|
80
|
-
<div style={{ width: 45 }} />
|
|
80
|
+
<div style={{ width: 45.92 }} />
|
|
81
81
|
<div style={{ flex: 1 }}>
|
|
82
82
|
<label>合计</label>
|
|
83
83
|
</div>
|
|
@@ -93,7 +93,7 @@ export default () => {
|
|
|
93
93
|
<div style={{ width: 111, border: 'none' }} />
|
|
94
94
|
</div>
|
|
95
95
|
<div className="kts-invoice-operate-goods-list-statistics-row">
|
|
96
|
-
<div style={{ width: 45 }} />
|
|
96
|
+
<div style={{ width: 45.92 }} />
|
|
97
97
|
<div style={{ flex: 5, border: 'none' }}>
|
|
98
98
|
<label>价税合计(大写)</label>
|
|
99
99
|
<label>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Switch } from 'kts-
|
|
3
|
+
import { Switch } from 'kts-xui';
|
|
4
4
|
import Invoice from '../../../../';
|
|
5
5
|
|
|
6
6
|
export default () => {
|
|
@@ -23,8 +23,6 @@ export default () => {
|
|
|
23
23
|
<Switch
|
|
24
24
|
disabled={isSwitchTax === false}
|
|
25
25
|
checked={isTaxIncluded}
|
|
26
|
-
checkedChildren="开"
|
|
27
|
-
unCheckedChildren="关"
|
|
28
26
|
defaultChecked
|
|
29
27
|
onChange={onChange}
|
|
30
28
|
/>
|