kts-component-invoice-operate 1.0.85 → 1.0.86
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/GoodsListState/EndowCode.d.ts +6 -2
- package/dist/index.esm.js +25 -23
- package/dist/index.js +25 -23
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/EndowCode.tsx +6 -2
- package/src/Invoice/_test/endowCode/index.tsx +42 -7
- package/src/Invoice/index.tsx +10 -2
- package/src/Invoice/ui/EndowCodeDrawer/index.tsx +7 -7
- package/src/Invoice/ui/GoodsList/index.tsx +3 -3
|
@@ -10,8 +10,12 @@ export default class EndowCode {
|
|
|
10
10
|
}[]>;
|
|
11
11
|
/** 税率 是否可以编辑 */
|
|
12
12
|
getReadOnlyTaxRate?: (value?: GoodsListState) => boolean;
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 获取赋码时候的默认值
|
|
15
|
+
* @param value 商品信息
|
|
16
|
+
* @param length 商品数量
|
|
17
|
+
* */
|
|
18
|
+
getDefaultValue?: (value: IGood, length: number) => Promise<IGood>;
|
|
15
19
|
/** 税率 是否可以编辑 校验函数 */
|
|
16
20
|
readonly readOnlyTaxRateMap: {
|
|
17
21
|
[key: string]: (value?: GoodsListState) => boolean;
|
package/dist/index.esm.js
CHANGED
|
@@ -4492,7 +4492,7 @@ var Main = decorator(Form.create())(function (props) {
|
|
|
4492
4492
|
},
|
|
4493
4493
|
dataSource: controller.useMemo(function (s) {
|
|
4494
4494
|
return s.goodsListState.goodsList;
|
|
4495
|
-
}, []),
|
|
4495
|
+
}, [controller]),
|
|
4496
4496
|
columns: useColumns(props.form),
|
|
4497
4497
|
rowSelection: useRowSelection(),
|
|
4498
4498
|
onRow: function onRow(record) {
|
|
@@ -5264,41 +5264,33 @@ var EndowCodeDrawer = (function () {
|
|
|
5264
5264
|
return _context2.abrupt("return");
|
|
5265
5265
|
|
|
5266
5266
|
case 4:
|
|
5267
|
-
if (!(endowcodeGoodIndex.length === 1)) {
|
|
5268
|
-
_context2.next = 17;
|
|
5269
|
-
break;
|
|
5270
|
-
}
|
|
5271
|
-
|
|
5272
5267
|
getDefaultValue = s.goodsListState.endowCode.getDefaultValue;
|
|
5273
5268
|
|
|
5274
5269
|
if (!getDefaultValue) {
|
|
5275
|
-
_context2.next =
|
|
5270
|
+
_context2.next = 13;
|
|
5276
5271
|
break;
|
|
5277
5272
|
}
|
|
5278
5273
|
|
|
5279
5274
|
_context2.t0 = setDefaultValue;
|
|
5280
|
-
_context2.next =
|
|
5281
|
-
return getDefaultValue(_objectSpread2({}, good));
|
|
5275
|
+
_context2.next = 9;
|
|
5276
|
+
return getDefaultValue(_objectSpread2({}, good), endowcodeGoodIndex.length);
|
|
5282
5277
|
|
|
5283
|
-
case
|
|
5278
|
+
case 9:
|
|
5284
5279
|
_context2.t1 = _context2.sent;
|
|
5285
5280
|
(0, _context2.t0)(_context2.t1);
|
|
5286
|
-
_context2.next =
|
|
5287
|
-
break;
|
|
5288
|
-
|
|
5289
|
-
case 14:
|
|
5290
|
-
setDefaultValue(good);
|
|
5291
|
-
|
|
5292
|
-
case 15:
|
|
5293
|
-
_context2.next = 18;
|
|
5281
|
+
_context2.next = 14;
|
|
5294
5282
|
break;
|
|
5295
5283
|
|
|
5296
|
-
case
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
}
|
|
5284
|
+
case 13:
|
|
5285
|
+
if (endowcodeGoodIndex.length === 1) {
|
|
5286
|
+
setDefaultValue(good);
|
|
5287
|
+
} else {
|
|
5288
|
+
setDefaultValue({
|
|
5289
|
+
taxRate: good.taxRate
|
|
5290
|
+
});
|
|
5291
|
+
}
|
|
5300
5292
|
|
|
5301
|
-
case
|
|
5293
|
+
case 14:
|
|
5302
5294
|
case "end":
|
|
5303
5295
|
return _context2.stop();
|
|
5304
5296
|
}
|
|
@@ -5773,7 +5765,17 @@ var Main$3 = function Main(props) {
|
|
|
5773
5765
|
var controller = React.useMemo(function () {
|
|
5774
5766
|
return props.controller || new InvoiceController();
|
|
5775
5767
|
}, [props.controller]);
|
|
5768
|
+
|
|
5769
|
+
var _React$useState = React.useState(0),
|
|
5770
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
5771
|
+
key = _React$useState2[0],
|
|
5772
|
+
setKey = _React$useState2[1];
|
|
5773
|
+
|
|
5774
|
+
React.useEffect(function () {
|
|
5775
|
+
setKey(key + 1);
|
|
5776
|
+
}, [controller]);
|
|
5776
5777
|
return /*#__PURE__*/React.createElement(InvoiceContext.Provider, {
|
|
5778
|
+
key: key,
|
|
5777
5779
|
value: controller
|
|
5778
5780
|
}, /*#__PURE__*/React.createElement("div", {
|
|
5779
5781
|
className: "kts-invoice-operate"
|
package/dist/index.js
CHANGED
|
@@ -4502,7 +4502,7 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
|
|
|
4502
4502
|
},
|
|
4503
4503
|
dataSource: controller.useMemo(function (s) {
|
|
4504
4504
|
return s.goodsListState.goodsList;
|
|
4505
|
-
}, []),
|
|
4505
|
+
}, [controller]),
|
|
4506
4506
|
columns: useColumns(props.form),
|
|
4507
4507
|
rowSelection: useRowSelection(),
|
|
4508
4508
|
onRow: function onRow(record) {
|
|
@@ -5274,41 +5274,33 @@ var EndowCodeDrawer = (function () {
|
|
|
5274
5274
|
return _context2.abrupt("return");
|
|
5275
5275
|
|
|
5276
5276
|
case 4:
|
|
5277
|
-
if (!(endowcodeGoodIndex.length === 1)) {
|
|
5278
|
-
_context2.next = 17;
|
|
5279
|
-
break;
|
|
5280
|
-
}
|
|
5281
|
-
|
|
5282
5277
|
getDefaultValue = s.goodsListState.endowCode.getDefaultValue;
|
|
5283
5278
|
|
|
5284
5279
|
if (!getDefaultValue) {
|
|
5285
|
-
_context2.next =
|
|
5280
|
+
_context2.next = 13;
|
|
5286
5281
|
break;
|
|
5287
5282
|
}
|
|
5288
5283
|
|
|
5289
5284
|
_context2.t0 = setDefaultValue;
|
|
5290
|
-
_context2.next =
|
|
5291
|
-
return getDefaultValue(_objectSpread2({}, good));
|
|
5285
|
+
_context2.next = 9;
|
|
5286
|
+
return getDefaultValue(_objectSpread2({}, good), endowcodeGoodIndex.length);
|
|
5292
5287
|
|
|
5293
|
-
case
|
|
5288
|
+
case 9:
|
|
5294
5289
|
_context2.t1 = _context2.sent;
|
|
5295
5290
|
(0, _context2.t0)(_context2.t1);
|
|
5296
|
-
_context2.next =
|
|
5297
|
-
break;
|
|
5298
|
-
|
|
5299
|
-
case 14:
|
|
5300
|
-
setDefaultValue(good);
|
|
5301
|
-
|
|
5302
|
-
case 15:
|
|
5303
|
-
_context2.next = 18;
|
|
5291
|
+
_context2.next = 14;
|
|
5304
5292
|
break;
|
|
5305
5293
|
|
|
5306
|
-
case
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
}
|
|
5294
|
+
case 13:
|
|
5295
|
+
if (endowcodeGoodIndex.length === 1) {
|
|
5296
|
+
setDefaultValue(good);
|
|
5297
|
+
} else {
|
|
5298
|
+
setDefaultValue({
|
|
5299
|
+
taxRate: good.taxRate
|
|
5300
|
+
});
|
|
5301
|
+
}
|
|
5310
5302
|
|
|
5311
|
-
case
|
|
5303
|
+
case 14:
|
|
5312
5304
|
case "end":
|
|
5313
5305
|
return _context2.stop();
|
|
5314
5306
|
}
|
|
@@ -5783,7 +5775,17 @@ var Main$3 = function Main(props) {
|
|
|
5783
5775
|
var controller = React__default['default'].useMemo(function () {
|
|
5784
5776
|
return props.controller || new InvoiceController();
|
|
5785
5777
|
}, [props.controller]);
|
|
5778
|
+
|
|
5779
|
+
var _React$useState = React__default['default'].useState(0),
|
|
5780
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
5781
|
+
key = _React$useState2[0],
|
|
5782
|
+
setKey = _React$useState2[1];
|
|
5783
|
+
|
|
5784
|
+
React__default['default'].useEffect(function () {
|
|
5785
|
+
setKey(key + 1);
|
|
5786
|
+
}, [controller]);
|
|
5786
5787
|
return /*#__PURE__*/React__default['default'].createElement(InvoiceContext.Provider, {
|
|
5788
|
+
key: key,
|
|
5787
5789
|
value: controller
|
|
5788
5790
|
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
5789
5791
|
className: "kts-invoice-operate"
|
package/package.json
CHANGED
|
@@ -13,8 +13,12 @@ export default class EndowCode {
|
|
|
13
13
|
/** 税率 是否可以编辑 */
|
|
14
14
|
getReadOnlyTaxRate?: (value?: GoodsListState) => boolean;
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 获取赋码时候的默认值
|
|
18
|
+
* @param value 商品信息
|
|
19
|
+
* @param length 商品数量
|
|
20
|
+
* */
|
|
21
|
+
getDefaultValue?: (value: IGood, length:number) => Promise<IGood>;
|
|
18
22
|
|
|
19
23
|
/** 税率 是否可以编辑 校验函数 */
|
|
20
24
|
readonly readOnlyTaxRateMap: { [key: string]: (value?: GoodsListState) => boolean } = {
|
|
@@ -5,7 +5,11 @@ import { LineAttributeType } from '../../../Invoice/InvoiceController';
|
|
|
5
5
|
import { Button, Switch } from 'kts-components-antd-x3';
|
|
6
6
|
|
|
7
7
|
export default () => {
|
|
8
|
-
const
|
|
8
|
+
const controller1 = React.useMemo(() => new MyController1(), []);
|
|
9
|
+
|
|
10
|
+
const controller2 = React.useMemo(() => new MyController2(), []);
|
|
11
|
+
|
|
12
|
+
const [controller, setController] = React.useState(controller1)
|
|
9
13
|
|
|
10
14
|
const onClick1 = React.useCallback(() => {
|
|
11
15
|
controller.pipeline(async (s) => {
|
|
@@ -41,7 +45,7 @@ export default () => {
|
|
|
41
45
|
<Button onClick={onClick2} style={{ marginBottom: 20 }}>
|
|
42
46
|
模拟生成数据
|
|
43
47
|
</Button>
|
|
44
|
-
<Switch checkedChildren="预制" unCheckedChildren="默认" onChange={
|
|
48
|
+
<Switch checkedChildren="预制" unCheckedChildren="默认" onChange={e => { e ? setController(controller2) : setController(controller1) }} ></Switch>
|
|
45
49
|
<Button onClick={controller.pipeline(async s => { s.goodsListState.endowCode.getReadOnlyTaxRate = s.goodsListState.endowCode.readOnlyTaxRateMap.DRAFT })} >税率(草稿)</Button>
|
|
46
50
|
<Button onClick={controller.pipeline(async s => { s.goodsListState.endowCode.getReadOnlyTaxRate = () => true })} >税率(预制)</Button>
|
|
47
51
|
<Invoice controller={controller} />
|
|
@@ -50,11 +54,42 @@ export default () => {
|
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
// 税收分类编码列表
|
|
53
|
-
class
|
|
57
|
+
class MyController1 extends Invoice.InvoiceController {
|
|
58
|
+
|
|
59
|
+
constructor(){
|
|
60
|
+
super()
|
|
61
|
+
this.state.model = 'default'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getTaxCategoryCodeList = this.pipeline(async (s) => {
|
|
65
|
+
console.log('===> 准备赋码的货物索引列表', s.goodsListState.endowCode.endowcodeGoodIndex);
|
|
66
|
+
|
|
67
|
+
s.goodsListState.endowCode.getTaxCategoryCodeList = async (value) => {
|
|
68
|
+
console.log('===>搜索条件', value);
|
|
69
|
+
return [
|
|
70
|
+
{ label: '3040201990000000000/aaa/bbb', value: '3040201990000000000', taxRate: 3, shorthand: 'aaa' },
|
|
71
|
+
{ label: '3040201990000000001/aaa/bbb', value: '3040201990000000001', taxRate: 3, shorthand: 'aaa' },
|
|
72
|
+
{ label: '3040201990000000002/aaa/bbb', value: '3040201990000000002', taxRate: 3, shorthand: 'aaa' },
|
|
73
|
+
{ label: '3040201990000000003/aaa/bbb', value: '3040201990000000003', taxRate: 3, shorthand: 'aaa' },
|
|
74
|
+
{ label: '3040201990000000004/aaa/bbb', value: '3040201990000000004', taxRate: 3, shorthand: 'aaa' },
|
|
75
|
+
{ label: '3040201990000000005/aaa/bbb', value: '3040201990000000005', taxRate: 3, shorthand: 'aaa' },
|
|
76
|
+
{ label: '3040201990000000006/aaa/bbb', value: '3040201990000000006', taxRate: 3, shorthand: 'aaa' },
|
|
77
|
+
{ label: '3040201990000000007/aaa/bbb', value: '3040201990000000007', taxRate: 3, shorthand: 'aaa' },
|
|
78
|
+
{ label: '3040201990000000008/aaa/bbb', value: '3040201990000000008', taxRate: 3, shorthand: 'aaa' },
|
|
79
|
+
{ label: '3040201990000000009/aaa/bbb', value: '3040201990000000009', taxRate: 3, shorthand: 'aaa' },
|
|
80
|
+
{ label: '3040201990000000010/aaa/bbb', value: '3040201990000000010', taxRate: 3, shorthand: 'aaa' },
|
|
81
|
+
{ label: '3040201990000000011/aaa/bbb', value: '3040201990000000011', taxRate: 3, shorthand: 'aaa' },
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class MyController2 extends Invoice.InvoiceController {
|
|
54
89
|
|
|
55
|
-
constructor()
|
|
56
|
-
super()
|
|
57
|
-
this.state.model = 'prefab'
|
|
90
|
+
constructor(){
|
|
91
|
+
super()
|
|
92
|
+
this.state.model = 'prefab'
|
|
58
93
|
}
|
|
59
94
|
|
|
60
95
|
getTaxCategoryCodeList = this.pipeline(async (s) => {
|
|
@@ -106,7 +141,7 @@ const lines: any[] = [
|
|
|
106
141
|
"itemName": "*研发和技术服务*技术服务费",
|
|
107
142
|
"lineAmountExcludeTax": 94.34,
|
|
108
143
|
"lineAmountIncludeTax": 100.00,
|
|
109
|
-
"lineAttribute":
|
|
144
|
+
"lineAttribute": '0',
|
|
110
145
|
"lineDiscountExcludeTax": null,
|
|
111
146
|
"lineDiscountRate": null,
|
|
112
147
|
"lineId": "1449262336593362944",
|
package/src/Invoice/index.tsx
CHANGED
|
@@ -72,9 +72,17 @@ export default class extends React.PureComponent<IInvoiceProps> {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const Main = (props: IInvoiceProps) => {
|
|
75
|
+
|
|
75
76
|
const controller = React.useMemo(() => props.controller || new InvoiceController(), [props.controller]);
|
|
77
|
+
|
|
78
|
+
const [key, setKey] = React.useState(0)
|
|
79
|
+
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
setKey(key + 1);
|
|
82
|
+
}, [controller])
|
|
83
|
+
|
|
76
84
|
return (
|
|
77
|
-
<InvoiceContext.Provider value={controller}>
|
|
85
|
+
<InvoiceContext.Provider key={key} value={controller}>
|
|
78
86
|
<div className="kts-invoice-operate">
|
|
79
87
|
{props.invoiceHeader || <InvoiceHeader /> /** 发票头 */}
|
|
80
88
|
{props.buyer || <Buyer /> /** 购买方 */}
|
|
@@ -94,4 +102,4 @@ const Main = (props: IInvoiceProps) => {
|
|
|
94
102
|
<EndowCodeDrawer />
|
|
95
103
|
</InvoiceContext.Provider>
|
|
96
104
|
);
|
|
97
|
-
};
|
|
105
|
+
};
|
|
@@ -42,15 +42,15 @@ export default () => {
|
|
|
42
42
|
const good = s.goodsListState.goodsMap.get(s.goodsListState.endowCode.endowcodeGoodIndex[0]);
|
|
43
43
|
if (!good) return;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const getDefaultValue = s.goodsListState.endowCode.getDefaultValue;
|
|
46
|
+
if (getDefaultValue) {
|
|
47
|
+
setDefaultValue(await getDefaultValue({ ...good }, endowcodeGoodIndex.length))
|
|
48
|
+
} else {
|
|
49
|
+
if (endowcodeGoodIndex.length === 1) {
|
|
50
50
|
setDefaultValue(good);
|
|
51
|
+
} else {
|
|
52
|
+
setDefaultValue({ taxRate: good.taxRate } as any);
|
|
51
53
|
}
|
|
52
|
-
} else {
|
|
53
|
-
setDefaultValue({ taxRate: good.taxRate } as any);
|
|
54
54
|
}
|
|
55
55
|
})()
|
|
56
56
|
} else {
|
|
@@ -33,9 +33,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
|
|
|
33
33
|
/** 控制器 */
|
|
34
34
|
const controller = Invoice.useInvoiceController();
|
|
35
35
|
|
|
36
|
-
const goodsList = controller.useMemo(
|
|
36
|
+
const goodsList = controller.useMemo(s => s.goodsListState.goodsList, []);
|
|
37
37
|
|
|
38
|
-
const isprefab = controller.useMemo(
|
|
38
|
+
const isprefab = controller.useMemo(s => s.model === 'prefab', []);
|
|
39
39
|
|
|
40
40
|
/** 表格行事件 */
|
|
41
41
|
const onRow = useOnRow();
|
|
@@ -101,7 +101,7 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
|
|
|
101
101
|
pagination={false}
|
|
102
102
|
scroll={{ y: 240 }}
|
|
103
103
|
components={{ body: { row: TableRow } }}
|
|
104
|
-
dataSource={controller.useMemo((s) => s.goodsListState.goodsList, [])}
|
|
104
|
+
dataSource={controller.useMemo((s) => s.goodsListState.goodsList, [controller])}
|
|
105
105
|
columns={useColumns(props.form)}
|
|
106
106
|
rowSelection={useRowSelection()}
|
|
107
107
|
onRow={(record) => ({
|