kts-component-invoice-operate 3.2.21 → 3.2.23
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/index.d.ts +2 -0
- package/dist/Invoice/InvoiceController/fns/mergeDiscount.d.ts +2 -0
- package/dist/Invoice/InvoiceController/index.d.ts +2 -0
- package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDiscount/index.d.ts +6 -0
- package/dist/index.esm.js +109 -2
- package/dist/index.js +109 -2
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +3 -0
- package/src/Invoice/InvoiceController/fns/mergeDiscount.ts +29 -0
- package/src/Invoice/InvoiceController/index.ts +4 -0
- package/src/Invoice/ui/default/GoodsList/index.tsx +7 -0
- package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +1 -1
- package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDiscount/index.tsx +37 -0
|
@@ -24,6 +24,8 @@ export default class InvoiceController extends InvoiceControllerForm {
|
|
|
24
24
|
addGood: (option?: any) => Promise<any>;
|
|
25
25
|
/** 全单合并明细 */
|
|
26
26
|
mergeDetails: (option?: any) => Promise<any>;
|
|
27
|
+
/** 全单合并折扣 */
|
|
28
|
+
mergeDiscount: (option?: any) => Promise<any>;
|
|
27
29
|
/** 给一组货物添加折扣行 */
|
|
28
30
|
addGoodDiscount: (option?: import("./fns/addGoodDiscount").IOptions | undefined) => Promise<any>;
|
|
29
31
|
/** 给一组货物添加折扣行 */
|
package/dist/index.esm.js
CHANGED
|
@@ -1016,6 +1016,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
|
|
|
1016
1016
|
this.productComparison = new ProductComparison();
|
|
1017
1017
|
this.isVisibleDrawer = false;
|
|
1018
1018
|
this.isMergeDetails = false;
|
|
1019
|
+
this.isMergeDiscount = false;
|
|
1019
1020
|
this.addComparisonIndex = void 0;
|
|
1020
1021
|
});
|
|
1021
1022
|
|
|
@@ -2028,6 +2029,62 @@ function findMaxIndex(arr) {
|
|
|
2028
2029
|
return maxIndex;
|
|
2029
2030
|
}
|
|
2030
2031
|
|
|
2032
|
+
function mergeDiscount(_x) {
|
|
2033
|
+
return _mergeDiscount.apply(this, arguments);
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
function _mergeDiscount() {
|
|
2037
|
+
_mergeDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(state) {
|
|
2038
|
+
var goodsList, i, good, sum, zk;
|
|
2039
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2040
|
+
while (1) {
|
|
2041
|
+
switch (_context.prev = _context.next) {
|
|
2042
|
+
case 0:
|
|
2043
|
+
if (!(state.goodsListState.goodsList.length <= 1 || state.goodsListState.editGood)) {
|
|
2044
|
+
_context.next = 2;
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
return _context.abrupt("return");
|
|
2049
|
+
|
|
2050
|
+
case 2:
|
|
2051
|
+
goodsList = state.goodsListState.goodsList.slice();
|
|
2052
|
+
|
|
2053
|
+
for (i = 0; i < goodsList.length; i++) {
|
|
2054
|
+
good = goodsList[i];
|
|
2055
|
+
|
|
2056
|
+
if (good.lineAttribute * 1 === LineAttributeType$1.被折扣行) {
|
|
2057
|
+
sum = _objectSpread2(_objectSpread2({}, good), {}, {
|
|
2058
|
+
$index: idGenerator(),
|
|
2059
|
+
lineAttribute: LineAttributeType$1.正常,
|
|
2060
|
+
discountGroup: undefined
|
|
2061
|
+
});
|
|
2062
|
+
zk = goodsList[i + 1];
|
|
2063
|
+
sum.lineAmountExcludeTax = chain$1(bignumber(good.lineAmountExcludeTax)).subtract(bignumber(Math.abs(zk.lineAmountExcludeTax || 0))).done().toNumber();
|
|
2064
|
+
sum.lineAmountIncludeTax = chain$1(bignumber(good.lineAmountIncludeTax)).subtract(bignumber(Math.abs(zk.lineAmountIncludeTax || 0))).done().toNumber();
|
|
2065
|
+
sum.quantity = good.quantity;
|
|
2066
|
+
|
|
2067
|
+
if (sum.quantity) {
|
|
2068
|
+
sum.priceExcludeTax = chain$1(bignumber(good.lineAmountExcludeTax)).divide(bignumber(good.quantity)).done().toNumber();
|
|
2069
|
+
sum.priceIncludeTax = chain$1(bignumber(good.lineAmountIncludeTax)).divide(bignumber(good.quantity)).done().toNumber();
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
goodsList.splice(i, 2, sum);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
state.goodsListState.goodsList = goodsList;
|
|
2077
|
+
|
|
2078
|
+
case 5:
|
|
2079
|
+
case "end":
|
|
2080
|
+
return _context.stop();
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
}, _callee);
|
|
2084
|
+
}));
|
|
2085
|
+
return _mergeDiscount.apply(this, arguments);
|
|
2086
|
+
}
|
|
2087
|
+
|
|
2031
2088
|
var InvoiceController = /*#__PURE__*/function (_InvoiceControllerFor) {
|
|
2032
2089
|
_inherits(InvoiceController, _InvoiceControllerFor);
|
|
2033
2090
|
|
|
@@ -2049,6 +2106,7 @@ var InvoiceController = /*#__PURE__*/function (_InvoiceControllerFor) {
|
|
|
2049
2106
|
_this.delGood = _this.pipeline(delGood);
|
|
2050
2107
|
_this.addGood = _this.pipeline(addGood);
|
|
2051
2108
|
_this.mergeDetails = _this.pipeline(mergeDetails);
|
|
2109
|
+
_this.mergeDiscount = _this.pipeline(mergeDiscount);
|
|
2052
2110
|
_this.addGoodDiscount = _this.pipeline(addGoodDiscount);
|
|
2053
2111
|
_this.addGoodDiscountV2 = _this.pipeline(addGoodDiscountV2);
|
|
2054
2112
|
_this.getGoodsList = void 0;
|
|
@@ -12498,7 +12556,7 @@ function useMergeDetails() {
|
|
|
12498
12556
|
}
|
|
12499
12557
|
}
|
|
12500
12558
|
}, _callee);
|
|
12501
|
-
})), []);
|
|
12559
|
+
})), [controller]);
|
|
12502
12560
|
var button = React.useMemo(function () {
|
|
12503
12561
|
if (!isMergeDetails) return React.createElement(React.Fragment, null);
|
|
12504
12562
|
return React.createElement(Button, {
|
|
@@ -12512,6 +12570,52 @@ function useMergeDetails() {
|
|
|
12512
12570
|
};
|
|
12513
12571
|
}
|
|
12514
12572
|
|
|
12573
|
+
/** 全单合并折扣 */
|
|
12574
|
+
|
|
12575
|
+
function useMergeDiscount() {
|
|
12576
|
+
var controller = Invoice.useInvoiceController();
|
|
12577
|
+
var goodsList = controller.useMemo(function (s) {
|
|
12578
|
+
return s.goodsListState.goodsList;
|
|
12579
|
+
}, []);
|
|
12580
|
+
var isMergeDiscount = controller.useMemo(function (s) {
|
|
12581
|
+
return s.goodsListState.isMergeDiscount;
|
|
12582
|
+
}, []);
|
|
12583
|
+
var onClick = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12584
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12585
|
+
while (1) {
|
|
12586
|
+
switch (_context.prev = _context.next) {
|
|
12587
|
+
case 0:
|
|
12588
|
+
_context.next = 2;
|
|
12589
|
+
return controller.saveEditGood();
|
|
12590
|
+
|
|
12591
|
+
case 2:
|
|
12592
|
+
_context.next = 4;
|
|
12593
|
+
return controller.wait();
|
|
12594
|
+
|
|
12595
|
+
case 4:
|
|
12596
|
+
_context.next = 6;
|
|
12597
|
+
return controller.mergeDiscount();
|
|
12598
|
+
|
|
12599
|
+
case 6:
|
|
12600
|
+
case "end":
|
|
12601
|
+
return _context.stop();
|
|
12602
|
+
}
|
|
12603
|
+
}
|
|
12604
|
+
}, _callee);
|
|
12605
|
+
})), [controller]);
|
|
12606
|
+
var button = React.useMemo(function () {
|
|
12607
|
+
if (!isMergeDiscount) return React.createElement(React.Fragment, null);
|
|
12608
|
+
return React.createElement(Button, {
|
|
12609
|
+
onClick: onClick,
|
|
12610
|
+
disabled: goodsList.length <= 1
|
|
12611
|
+
}, "\u5408\u5E76\u6298\u6263");
|
|
12612
|
+
}, [goodsList.length]);
|
|
12613
|
+
return {
|
|
12614
|
+
/** 按钮 */
|
|
12615
|
+
button: button
|
|
12616
|
+
};
|
|
12617
|
+
}
|
|
12618
|
+
|
|
12515
12619
|
var GoodsList = /*#__PURE__*/function (_React$Component) {
|
|
12516
12620
|
_inherits(GoodsList, _React$Component);
|
|
12517
12621
|
|
|
@@ -12571,6 +12675,9 @@ var Main = decorator(Form.create())(function (props) {
|
|
|
12571
12675
|
/** 全单合并明细 */
|
|
12572
12676
|
|
|
12573
12677
|
var mergeDetails = useMergeDetails();
|
|
12678
|
+
/** 全单合并折扣 */
|
|
12679
|
+
|
|
12680
|
+
var mergeDiscount = useMergeDiscount();
|
|
12574
12681
|
/** 清空自动赋码缓存 */
|
|
12575
12682
|
|
|
12576
12683
|
React.useEffect(function () {
|
|
@@ -12728,7 +12835,7 @@ var Main = decorator(Form.create())(function (props) {
|
|
|
12728
12835
|
className: "kts-invoice-operate-goods-list-able"
|
|
12729
12836
|
}, React.createElement("div", {
|
|
12730
12837
|
className: "kts-invoice-operate-goods-list-able-list"
|
|
12731
|
-
}, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, addDiscountRowButton.drawer, React.createElement(Search, null)), React.createElement("div", {
|
|
12838
|
+
}, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, React.createElement(Search, null)), React.createElement("div", {
|
|
12732
12839
|
className: "kts-invoice-operate-goods-list-able-extend"
|
|
12733
12840
|
}, props.menuExpansion, React.createElement(DescribeSwitch, null), React.createElement(TaxIncludedSwitch, null))), React.createElement("div", {
|
|
12734
12841
|
className: classnames('kts-invoice-operate-goods-list-table', {
|
package/dist/index.js
CHANGED
|
@@ -1026,6 +1026,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
|
|
|
1026
1026
|
this.productComparison = new ProductComparison();
|
|
1027
1027
|
this.isVisibleDrawer = false;
|
|
1028
1028
|
this.isMergeDetails = false;
|
|
1029
|
+
this.isMergeDiscount = false;
|
|
1029
1030
|
this.addComparisonIndex = void 0;
|
|
1030
1031
|
});
|
|
1031
1032
|
|
|
@@ -2038,6 +2039,62 @@ function findMaxIndex(arr) {
|
|
|
2038
2039
|
return maxIndex;
|
|
2039
2040
|
}
|
|
2040
2041
|
|
|
2042
|
+
function mergeDiscount(_x) {
|
|
2043
|
+
return _mergeDiscount.apply(this, arguments);
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
function _mergeDiscount() {
|
|
2047
|
+
_mergeDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(state) {
|
|
2048
|
+
var goodsList, i, good, sum, zk;
|
|
2049
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2050
|
+
while (1) {
|
|
2051
|
+
switch (_context.prev = _context.next) {
|
|
2052
|
+
case 0:
|
|
2053
|
+
if (!(state.goodsListState.goodsList.length <= 1 || state.goodsListState.editGood)) {
|
|
2054
|
+
_context.next = 2;
|
|
2055
|
+
break;
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
return _context.abrupt("return");
|
|
2059
|
+
|
|
2060
|
+
case 2:
|
|
2061
|
+
goodsList = state.goodsListState.goodsList.slice();
|
|
2062
|
+
|
|
2063
|
+
for (i = 0; i < goodsList.length; i++) {
|
|
2064
|
+
good = goodsList[i];
|
|
2065
|
+
|
|
2066
|
+
if (good.lineAttribute * 1 === LineAttributeType$1.被折扣行) {
|
|
2067
|
+
sum = _objectSpread2(_objectSpread2({}, good), {}, {
|
|
2068
|
+
$index: idGenerator(),
|
|
2069
|
+
lineAttribute: LineAttributeType$1.正常,
|
|
2070
|
+
discountGroup: undefined
|
|
2071
|
+
});
|
|
2072
|
+
zk = goodsList[i + 1];
|
|
2073
|
+
sum.lineAmountExcludeTax = mathjs.chain(mathjs.bignumber(good.lineAmountExcludeTax)).subtract(mathjs.bignumber(Math.abs(zk.lineAmountExcludeTax || 0))).done().toNumber();
|
|
2074
|
+
sum.lineAmountIncludeTax = mathjs.chain(mathjs.bignumber(good.lineAmountIncludeTax)).subtract(mathjs.bignumber(Math.abs(zk.lineAmountIncludeTax || 0))).done().toNumber();
|
|
2075
|
+
sum.quantity = good.quantity;
|
|
2076
|
+
|
|
2077
|
+
if (sum.quantity) {
|
|
2078
|
+
sum.priceExcludeTax = mathjs.chain(mathjs.bignumber(good.lineAmountExcludeTax)).divide(mathjs.bignumber(good.quantity)).done().toNumber();
|
|
2079
|
+
sum.priceIncludeTax = mathjs.chain(mathjs.bignumber(good.lineAmountIncludeTax)).divide(mathjs.bignumber(good.quantity)).done().toNumber();
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
goodsList.splice(i, 2, sum);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
state.goodsListState.goodsList = goodsList;
|
|
2087
|
+
|
|
2088
|
+
case 5:
|
|
2089
|
+
case "end":
|
|
2090
|
+
return _context.stop();
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
}, _callee);
|
|
2094
|
+
}));
|
|
2095
|
+
return _mergeDiscount.apply(this, arguments);
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2041
2098
|
var InvoiceController = /*#__PURE__*/function (_InvoiceControllerFor) {
|
|
2042
2099
|
_inherits(InvoiceController, _InvoiceControllerFor);
|
|
2043
2100
|
|
|
@@ -2059,6 +2116,7 @@ var InvoiceController = /*#__PURE__*/function (_InvoiceControllerFor) {
|
|
|
2059
2116
|
_this.delGood = _this.pipeline(delGood);
|
|
2060
2117
|
_this.addGood = _this.pipeline(addGood);
|
|
2061
2118
|
_this.mergeDetails = _this.pipeline(mergeDetails);
|
|
2119
|
+
_this.mergeDiscount = _this.pipeline(mergeDiscount);
|
|
2062
2120
|
_this.addGoodDiscount = _this.pipeline(addGoodDiscount);
|
|
2063
2121
|
_this.addGoodDiscountV2 = _this.pipeline(addGoodDiscountV2);
|
|
2064
2122
|
_this.getGoodsList = void 0;
|
|
@@ -12508,7 +12566,7 @@ function useMergeDetails() {
|
|
|
12508
12566
|
}
|
|
12509
12567
|
}
|
|
12510
12568
|
}, _callee);
|
|
12511
|
-
})), []);
|
|
12569
|
+
})), [controller]);
|
|
12512
12570
|
var button = React__default['default'].useMemo(function () {
|
|
12513
12571
|
if (!isMergeDetails) return React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
12514
12572
|
return React__default['default'].createElement(ktsComponentsAntdX3.Button, {
|
|
@@ -12522,6 +12580,52 @@ function useMergeDetails() {
|
|
|
12522
12580
|
};
|
|
12523
12581
|
}
|
|
12524
12582
|
|
|
12583
|
+
/** 全单合并折扣 */
|
|
12584
|
+
|
|
12585
|
+
function useMergeDiscount() {
|
|
12586
|
+
var controller = Invoice.useInvoiceController();
|
|
12587
|
+
var goodsList = controller.useMemo(function (s) {
|
|
12588
|
+
return s.goodsListState.goodsList;
|
|
12589
|
+
}, []);
|
|
12590
|
+
var isMergeDiscount = controller.useMemo(function (s) {
|
|
12591
|
+
return s.goodsListState.isMergeDiscount;
|
|
12592
|
+
}, []);
|
|
12593
|
+
var onClick = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
12594
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12595
|
+
while (1) {
|
|
12596
|
+
switch (_context.prev = _context.next) {
|
|
12597
|
+
case 0:
|
|
12598
|
+
_context.next = 2;
|
|
12599
|
+
return controller.saveEditGood();
|
|
12600
|
+
|
|
12601
|
+
case 2:
|
|
12602
|
+
_context.next = 4;
|
|
12603
|
+
return controller.wait();
|
|
12604
|
+
|
|
12605
|
+
case 4:
|
|
12606
|
+
_context.next = 6;
|
|
12607
|
+
return controller.mergeDiscount();
|
|
12608
|
+
|
|
12609
|
+
case 6:
|
|
12610
|
+
case "end":
|
|
12611
|
+
return _context.stop();
|
|
12612
|
+
}
|
|
12613
|
+
}
|
|
12614
|
+
}, _callee);
|
|
12615
|
+
})), [controller]);
|
|
12616
|
+
var button = React__default['default'].useMemo(function () {
|
|
12617
|
+
if (!isMergeDiscount) return React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
12618
|
+
return React__default['default'].createElement(ktsComponentsAntdX3.Button, {
|
|
12619
|
+
onClick: onClick,
|
|
12620
|
+
disabled: goodsList.length <= 1
|
|
12621
|
+
}, "\u5408\u5E76\u6298\u6263");
|
|
12622
|
+
}, [goodsList.length]);
|
|
12623
|
+
return {
|
|
12624
|
+
/** 按钮 */
|
|
12625
|
+
button: button
|
|
12626
|
+
};
|
|
12627
|
+
}
|
|
12628
|
+
|
|
12525
12629
|
var GoodsList = /*#__PURE__*/function (_React$Component) {
|
|
12526
12630
|
_inherits(GoodsList, _React$Component);
|
|
12527
12631
|
|
|
@@ -12581,6 +12685,9 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
|
|
|
12581
12685
|
/** 全单合并明细 */
|
|
12582
12686
|
|
|
12583
12687
|
var mergeDetails = useMergeDetails();
|
|
12688
|
+
/** 全单合并折扣 */
|
|
12689
|
+
|
|
12690
|
+
var mergeDiscount = useMergeDiscount();
|
|
12584
12691
|
/** 清空自动赋码缓存 */
|
|
12585
12692
|
|
|
12586
12693
|
React__default['default'].useEffect(function () {
|
|
@@ -12738,7 +12845,7 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
|
|
|
12738
12845
|
className: "kts-invoice-operate-goods-list-able"
|
|
12739
12846
|
}, React__default['default'].createElement("div", {
|
|
12740
12847
|
className: "kts-invoice-operate-goods-list-able-list"
|
|
12741
|
-
}, React__default['default'].createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, addDiscountRowButton.drawer, React__default['default'].createElement(Search, null)), React__default['default'].createElement("div", {
|
|
12848
|
+
}, React__default['default'].createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, React__default['default'].createElement(Search, null)), React__default['default'].createElement("div", {
|
|
12742
12849
|
className: "kts-invoice-operate-goods-list-able-extend"
|
|
12743
12850
|
}, props.menuExpansion, React__default['default'].createElement(DescribeSwitch, null), React__default['default'].createElement(TaxIncludedSwitch, null))), React__default['default'].createElement("div", {
|
|
12744
12851
|
className: classnames__default['default']('kts-invoice-operate-goods-list-table', {
|
package/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { IGood, InvoiceControllerState, LineAttributeType } from '..';
|
|
4
|
+
import { chain, bignumber } from 'mathjs';
|
|
5
|
+
import idGenerator from '../../tools/idGenerator';
|
|
6
|
+
|
|
7
|
+
export default async function mergeDiscount(state: InvoiceControllerState) {
|
|
8
|
+
if (state.goodsListState.goodsList.length <= 1 || state.goodsListState.editGood) return;
|
|
9
|
+
|
|
10
|
+
const goodsList = state.goodsListState.goodsList.slice();
|
|
11
|
+
for (let i = 0; i < goodsList.length; i++) {
|
|
12
|
+
const good = goodsList[i];
|
|
13
|
+
if (good.lineAttribute * 1 === LineAttributeType.被折扣行) {
|
|
14
|
+
const sum: IGood = { ...good, $index: idGenerator(), lineAttribute: LineAttributeType.正常, discountGroup: undefined };
|
|
15
|
+
const zk = goodsList[i + 1];
|
|
16
|
+
|
|
17
|
+
sum.lineAmountExcludeTax = chain(bignumber(good.lineAmountExcludeTax)).subtract(bignumber(Math.abs(zk.lineAmountExcludeTax || 0))).done().toNumber();
|
|
18
|
+
sum.lineAmountIncludeTax = chain(bignumber(good.lineAmountIncludeTax)).subtract(bignumber(Math.abs(zk.lineAmountIncludeTax || 0))).done().toNumber();
|
|
19
|
+
sum.quantity = good.quantity;
|
|
20
|
+
if (sum.quantity) {
|
|
21
|
+
sum.priceExcludeTax = chain(bignumber(good.lineAmountExcludeTax)).divide(bignumber(good.quantity)).done().toNumber();
|
|
22
|
+
sum.priceIncludeTax = chain(bignumber(good.lineAmountIncludeTax)).divide(bignumber(good.quantity)).done().toNumber();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
goodsList.splice(i, 2, sum);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
state.goodsListState.goodsList = goodsList;
|
|
29
|
+
}
|
|
@@ -12,6 +12,7 @@ import addGood from './fns/addGood';
|
|
|
12
12
|
import saveEditGood from './fns/saveEditGood';
|
|
13
13
|
import getGoodsSearch from './fns/getGoodsSearch';
|
|
14
14
|
import mergeDetails from './fns/mergeDetails';
|
|
15
|
+
import mergeDiscount from './fns/mergeDiscount';
|
|
15
16
|
|
|
16
17
|
export { default as InvoiceControllerState } from './InvoiceControllerState';
|
|
17
18
|
export { default as IGood } from './InvoiceControllerState/GoodsListState/IGood';
|
|
@@ -52,6 +53,9 @@ export default class InvoiceController extends InvoiceControllerForm {
|
|
|
52
53
|
/** 全单合并明细 */
|
|
53
54
|
mergeDetails = this.pipeline<any>(mergeDetails);
|
|
54
55
|
|
|
56
|
+
/** 全单合并折扣 */
|
|
57
|
+
mergeDiscount = this.pipeline<any>(mergeDiscount);
|
|
58
|
+
|
|
55
59
|
/** 给一组货物添加折扣行 */
|
|
56
60
|
addGoodDiscount = this.pipeline(addGoodDiscount);
|
|
57
61
|
|
|
@@ -28,6 +28,7 @@ import useEndowCodeButton from './ui/BulkMenu/hooks/useEndowCodeButton';
|
|
|
28
28
|
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
|
+
import useMergeDiscount from './ui/BulkMenu/hooks/useMergeDiscount';
|
|
31
32
|
|
|
32
33
|
export interface IGoodsListProps {
|
|
33
34
|
/** 扩展部分 */
|
|
@@ -87,6 +88,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
|
|
|
87
88
|
/** 全单合并明细 */
|
|
88
89
|
const mergeDetails = useMergeDetails()
|
|
89
90
|
|
|
91
|
+
/** 全单合并折扣 */
|
|
92
|
+
const mergeDiscount = useMergeDiscount()
|
|
93
|
+
|
|
90
94
|
/** 清空自动赋码缓存 */
|
|
91
95
|
React.useEffect(() => {
|
|
92
96
|
controller.run(async s => { s.goodsListState.endowCode.cache = {} });
|
|
@@ -139,6 +143,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
|
|
|
139
143
|
{/* 全单合并明细 */}
|
|
140
144
|
{mergeDetails.button}
|
|
141
145
|
|
|
146
|
+
{/* 全单合并折扣 */}
|
|
147
|
+
{mergeDiscount.button}
|
|
148
|
+
|
|
142
149
|
{/* 添加折扣行 */}
|
|
143
150
|
{addDiscountRowButton.drawer}
|
|
144
151
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import React from "react"
|
|
3
|
+
import { Button } from "kts-components-antd-x3"
|
|
4
|
+
import Invoice from '../../../../../../..'
|
|
5
|
+
|
|
6
|
+
/** 全单合并折扣 */
|
|
7
|
+
export default function useMergeDiscount() {
|
|
8
|
+
|
|
9
|
+
const controller = Invoice.useInvoiceController();
|
|
10
|
+
|
|
11
|
+
const goodsList = controller.useMemo(s => s.goodsListState.goodsList, []);
|
|
12
|
+
|
|
13
|
+
const isMergeDiscount = controller.useMemo(s => s.goodsListState.isMergeDiscount, []);
|
|
14
|
+
|
|
15
|
+
const onClick = React.useCallback(async () => {
|
|
16
|
+
await controller.saveEditGood();
|
|
17
|
+
await controller.wait();
|
|
18
|
+
await controller.mergeDiscount();
|
|
19
|
+
}, [controller])
|
|
20
|
+
|
|
21
|
+
const button = React.useMemo(() => {
|
|
22
|
+
if (!isMergeDiscount) return <></>;
|
|
23
|
+
return (
|
|
24
|
+
<Button
|
|
25
|
+
onClick={onClick}
|
|
26
|
+
disabled={goodsList.length <= 1}
|
|
27
|
+
>
|
|
28
|
+
合并折扣
|
|
29
|
+
</Button>
|
|
30
|
+
)
|
|
31
|
+
}, [goodsList.length])
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
/** 按钮 */
|
|
35
|
+
button,
|
|
36
|
+
}
|
|
37
|
+
}
|