kts-component-invoice-operate 3.2.70 → 3.2.71
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/ui/default/GoodsList/ui/BulkMenu/hooks/useSalesGifts/index.d.ts +1 -1
- package/dist/index.esm.js +106 -6
- package/dist/index.js +106 -6
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +3 -0
- package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useSalesGifts/index.tsx +46 -7
package/dist/index.esm.js
CHANGED
|
@@ -1089,6 +1089,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
|
|
|
1089
1089
|
this.isMergeDetails = false;
|
|
1090
1090
|
this.isMergeDiscount = false;
|
|
1091
1091
|
this.isSalesDiscount = false;
|
|
1092
|
+
this.isSalesGifts = false;
|
|
1092
1093
|
this.addComparisonIndex = void 0;
|
|
1093
1094
|
this.drag = new Drag();
|
|
1094
1095
|
});
|
|
@@ -14965,6 +14966,12 @@ function useSalesDiscount() {
|
|
|
14965
14966
|
|
|
14966
14967
|
function useSalesGifts() {
|
|
14967
14968
|
var controller = Invoice.useInvoiceController();
|
|
14969
|
+
var isSalesGifts = controller.useMemo(function (s) {
|
|
14970
|
+
return s.goodsListState.isSalesGifts;
|
|
14971
|
+
}, []);
|
|
14972
|
+
var selectedGoodIndex = controller.useMemo(function (s) {
|
|
14973
|
+
return s.goodsListState.selectedGoodIndex;
|
|
14974
|
+
}, []);
|
|
14968
14975
|
var goodsList = controller.useMemo(function (s) {
|
|
14969
14976
|
return s.goodsListState.goodsList;
|
|
14970
14977
|
}, []);
|
|
@@ -14973,7 +14980,7 @@ function useSalesGifts() {
|
|
|
14973
14980
|
return e.lineAttribute === LineAttributeType$1.赠品行;
|
|
14974
14981
|
});
|
|
14975
14982
|
}, [goodsList]);
|
|
14976
|
-
var
|
|
14983
|
+
var onClickAuto = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
14977
14984
|
var _iterator, _step, g;
|
|
14978
14985
|
|
|
14979
14986
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -15027,12 +15034,105 @@ function useSalesGifts() {
|
|
|
15027
15034
|
}
|
|
15028
15035
|
}, _callee, null, [[1, 12, 15, 18]]);
|
|
15029
15036
|
})), [controller, giveaways]);
|
|
15037
|
+
var onClickManual = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
15038
|
+
var _controller$state$goo, goodsMap, selectedGoodIndex, giveaways, content, _iterator2, _step2, g;
|
|
15039
|
+
|
|
15040
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15041
|
+
while (1) {
|
|
15042
|
+
switch (_context2.prev = _context2.next) {
|
|
15043
|
+
case 0:
|
|
15044
|
+
_controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
|
|
15045
|
+
giveaways = selectedGoodIndex.map(function (e) {
|
|
15046
|
+
return goodsMap.get(e);
|
|
15047
|
+
}).filter(function (e) {
|
|
15048
|
+
return !!e;
|
|
15049
|
+
});
|
|
15050
|
+
|
|
15051
|
+
if (!(giveaways.some(function (e) {
|
|
15052
|
+
return e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行;
|
|
15053
|
+
}) === false)) {
|
|
15054
|
+
_context2.next = 5;
|
|
15055
|
+
break;
|
|
15056
|
+
}
|
|
15057
|
+
|
|
15058
|
+
content = '只能选择‘赠品行’和‘正常行’';
|
|
15059
|
+
return _context2.abrupt("return", message.error({
|
|
15060
|
+
content: content,
|
|
15061
|
+
key: content
|
|
15062
|
+
}));
|
|
15063
|
+
|
|
15064
|
+
case 5:
|
|
15065
|
+
_iterator2 = _createForOfIteratorHelper(giveaways);
|
|
15066
|
+
_context2.prev = 6;
|
|
15067
|
+
|
|
15068
|
+
_iterator2.s();
|
|
15069
|
+
|
|
15070
|
+
case 8:
|
|
15071
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
15072
|
+
_context2.next = 14;
|
|
15073
|
+
break;
|
|
15074
|
+
}
|
|
15075
|
+
|
|
15076
|
+
g = _step2.value;
|
|
15077
|
+
_context2.next = 12;
|
|
15078
|
+
return controller.addGoodDiscountV2([{
|
|
15079
|
+
$index: g.$index,
|
|
15080
|
+
discolineAmountunt: g.lineAmountIncludeTax || 0
|
|
15081
|
+
}]);
|
|
15082
|
+
|
|
15083
|
+
case 12:
|
|
15084
|
+
_context2.next = 8;
|
|
15085
|
+
break;
|
|
15086
|
+
|
|
15087
|
+
case 14:
|
|
15088
|
+
_context2.next = 19;
|
|
15089
|
+
break;
|
|
15090
|
+
|
|
15091
|
+
case 16:
|
|
15092
|
+
_context2.prev = 16;
|
|
15093
|
+
_context2.t0 = _context2["catch"](6);
|
|
15094
|
+
|
|
15095
|
+
_iterator2.e(_context2.t0);
|
|
15096
|
+
|
|
15097
|
+
case 19:
|
|
15098
|
+
_context2.prev = 19;
|
|
15099
|
+
|
|
15100
|
+
_iterator2.f();
|
|
15101
|
+
|
|
15102
|
+
return _context2.finish(19);
|
|
15103
|
+
|
|
15104
|
+
case 22:
|
|
15105
|
+
controller.state.goodsListState.selectedGoodIndex = [];
|
|
15106
|
+
|
|
15107
|
+
case 23:
|
|
15108
|
+
case "end":
|
|
15109
|
+
return _context2.stop();
|
|
15110
|
+
}
|
|
15111
|
+
}
|
|
15112
|
+
}, _callee2, null, [[6, 16, 19, 22]]);
|
|
15113
|
+
})), [controller]);
|
|
15114
|
+
var items = React.useMemo(function () {
|
|
15115
|
+
return [{
|
|
15116
|
+
key: '0',
|
|
15117
|
+
label: '自动转换',
|
|
15118
|
+
disabled: giveaways.length <= 0,
|
|
15119
|
+
onClick: onClickAuto
|
|
15120
|
+
}, {
|
|
15121
|
+
key: '1',
|
|
15122
|
+
label: '手动转换',
|
|
15123
|
+
disabled: selectedGoodIndex.length <= 0,
|
|
15124
|
+
onClick: onClickManual
|
|
15125
|
+
}];
|
|
15126
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto]);
|
|
15030
15127
|
var button = React.useMemo(function () {
|
|
15031
|
-
if (
|
|
15032
|
-
return React.createElement(
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15128
|
+
if (!isSalesGifts) return;
|
|
15129
|
+
return React.createElement(Dropdown$1, {
|
|
15130
|
+
menu: {
|
|
15131
|
+
items: items
|
|
15132
|
+
},
|
|
15133
|
+
trigger: ['click']
|
|
15134
|
+
}, React.createElement(Button, null, "\u9500\u552E\u8D60\u54C1"));
|
|
15135
|
+
}, [items, isSalesGifts]);
|
|
15036
15136
|
return {
|
|
15037
15137
|
/** 按钮 */
|
|
15038
15138
|
button: button
|
package/dist/index.js
CHANGED
|
@@ -1099,6 +1099,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
|
|
|
1099
1099
|
this.isMergeDetails = false;
|
|
1100
1100
|
this.isMergeDiscount = false;
|
|
1101
1101
|
this.isSalesDiscount = false;
|
|
1102
|
+
this.isSalesGifts = false;
|
|
1102
1103
|
this.addComparisonIndex = void 0;
|
|
1103
1104
|
this.drag = new Drag();
|
|
1104
1105
|
});
|
|
@@ -14975,6 +14976,12 @@ function useSalesDiscount() {
|
|
|
14975
14976
|
|
|
14976
14977
|
function useSalesGifts() {
|
|
14977
14978
|
var controller = Invoice.useInvoiceController();
|
|
14979
|
+
var isSalesGifts = controller.useMemo(function (s) {
|
|
14980
|
+
return s.goodsListState.isSalesGifts;
|
|
14981
|
+
}, []);
|
|
14982
|
+
var selectedGoodIndex = controller.useMemo(function (s) {
|
|
14983
|
+
return s.goodsListState.selectedGoodIndex;
|
|
14984
|
+
}, []);
|
|
14978
14985
|
var goodsList = controller.useMemo(function (s) {
|
|
14979
14986
|
return s.goodsListState.goodsList;
|
|
14980
14987
|
}, []);
|
|
@@ -14983,7 +14990,7 @@ function useSalesGifts() {
|
|
|
14983
14990
|
return e.lineAttribute === LineAttributeType$1.赠品行;
|
|
14984
14991
|
});
|
|
14985
14992
|
}, [goodsList]);
|
|
14986
|
-
var
|
|
14993
|
+
var onClickAuto = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
14987
14994
|
var _iterator, _step, g;
|
|
14988
14995
|
|
|
14989
14996
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -15037,12 +15044,105 @@ function useSalesGifts() {
|
|
|
15037
15044
|
}
|
|
15038
15045
|
}, _callee, null, [[1, 12, 15, 18]]);
|
|
15039
15046
|
})), [controller, giveaways]);
|
|
15047
|
+
var onClickManual = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
15048
|
+
var _controller$state$goo, goodsMap, selectedGoodIndex, giveaways, content, _iterator2, _step2, g;
|
|
15049
|
+
|
|
15050
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15051
|
+
while (1) {
|
|
15052
|
+
switch (_context2.prev = _context2.next) {
|
|
15053
|
+
case 0:
|
|
15054
|
+
_controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
|
|
15055
|
+
giveaways = selectedGoodIndex.map(function (e) {
|
|
15056
|
+
return goodsMap.get(e);
|
|
15057
|
+
}).filter(function (e) {
|
|
15058
|
+
return !!e;
|
|
15059
|
+
});
|
|
15060
|
+
|
|
15061
|
+
if (!(giveaways.some(function (e) {
|
|
15062
|
+
return e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行;
|
|
15063
|
+
}) === false)) {
|
|
15064
|
+
_context2.next = 5;
|
|
15065
|
+
break;
|
|
15066
|
+
}
|
|
15067
|
+
|
|
15068
|
+
content = '只能选择‘赠品行’和‘正常行’';
|
|
15069
|
+
return _context2.abrupt("return", ktsComponentsAntdX3.message.error({
|
|
15070
|
+
content: content,
|
|
15071
|
+
key: content
|
|
15072
|
+
}));
|
|
15073
|
+
|
|
15074
|
+
case 5:
|
|
15075
|
+
_iterator2 = _createForOfIteratorHelper(giveaways);
|
|
15076
|
+
_context2.prev = 6;
|
|
15077
|
+
|
|
15078
|
+
_iterator2.s();
|
|
15079
|
+
|
|
15080
|
+
case 8:
|
|
15081
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
15082
|
+
_context2.next = 14;
|
|
15083
|
+
break;
|
|
15084
|
+
}
|
|
15085
|
+
|
|
15086
|
+
g = _step2.value;
|
|
15087
|
+
_context2.next = 12;
|
|
15088
|
+
return controller.addGoodDiscountV2([{
|
|
15089
|
+
$index: g.$index,
|
|
15090
|
+
discolineAmountunt: g.lineAmountIncludeTax || 0
|
|
15091
|
+
}]);
|
|
15092
|
+
|
|
15093
|
+
case 12:
|
|
15094
|
+
_context2.next = 8;
|
|
15095
|
+
break;
|
|
15096
|
+
|
|
15097
|
+
case 14:
|
|
15098
|
+
_context2.next = 19;
|
|
15099
|
+
break;
|
|
15100
|
+
|
|
15101
|
+
case 16:
|
|
15102
|
+
_context2.prev = 16;
|
|
15103
|
+
_context2.t0 = _context2["catch"](6);
|
|
15104
|
+
|
|
15105
|
+
_iterator2.e(_context2.t0);
|
|
15106
|
+
|
|
15107
|
+
case 19:
|
|
15108
|
+
_context2.prev = 19;
|
|
15109
|
+
|
|
15110
|
+
_iterator2.f();
|
|
15111
|
+
|
|
15112
|
+
return _context2.finish(19);
|
|
15113
|
+
|
|
15114
|
+
case 22:
|
|
15115
|
+
controller.state.goodsListState.selectedGoodIndex = [];
|
|
15116
|
+
|
|
15117
|
+
case 23:
|
|
15118
|
+
case "end":
|
|
15119
|
+
return _context2.stop();
|
|
15120
|
+
}
|
|
15121
|
+
}
|
|
15122
|
+
}, _callee2, null, [[6, 16, 19, 22]]);
|
|
15123
|
+
})), [controller]);
|
|
15124
|
+
var items = React__default['default'].useMemo(function () {
|
|
15125
|
+
return [{
|
|
15126
|
+
key: '0',
|
|
15127
|
+
label: '自动转换',
|
|
15128
|
+
disabled: giveaways.length <= 0,
|
|
15129
|
+
onClick: onClickAuto
|
|
15130
|
+
}, {
|
|
15131
|
+
key: '1',
|
|
15132
|
+
label: '手动转换',
|
|
15133
|
+
disabled: selectedGoodIndex.length <= 0,
|
|
15134
|
+
onClick: onClickManual
|
|
15135
|
+
}];
|
|
15136
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto]);
|
|
15040
15137
|
var button = React__default['default'].useMemo(function () {
|
|
15041
|
-
if (
|
|
15042
|
-
return React__default['default'].createElement(
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15138
|
+
if (!isSalesGifts) return;
|
|
15139
|
+
return React__default['default'].createElement(ktsXui.Dropdown, {
|
|
15140
|
+
menu: {
|
|
15141
|
+
items: items
|
|
15142
|
+
},
|
|
15143
|
+
trigger: ['click']
|
|
15144
|
+
}, React__default['default'].createElement(ktsComponentsAntdX3.Button, null, "\u9500\u552E\u8D60\u54C1"));
|
|
15145
|
+
}, [items, isSalesGifts]);
|
|
15046
15146
|
return {
|
|
15047
15147
|
/** 按钮 */
|
|
15048
15148
|
button: button
|
package/package.json
CHANGED
|
@@ -3,32 +3,71 @@ import React from "react"
|
|
|
3
3
|
import { Button, message } from "kts-components-antd-x3"
|
|
4
4
|
import { chain, bignumber } from 'mathjs';
|
|
5
5
|
import Invoice from '../../../../../../..'
|
|
6
|
-
import { LineAttributeType } from "../../../../../../../InvoiceController";
|
|
6
|
+
import { IGood, LineAttributeType } from "../../../../../../../InvoiceController";
|
|
7
|
+
import { Dropdown, MenuProps } from "kts-xui";
|
|
7
8
|
|
|
8
9
|
/** 销售赠品 */
|
|
9
10
|
export default function useSalesGifts() {
|
|
10
11
|
|
|
11
12
|
const controller = Invoice.useInvoiceController();
|
|
12
13
|
|
|
14
|
+
const isSalesGifts = controller.useMemo(s => s.goodsListState.isSalesGifts, []);
|
|
15
|
+
|
|
16
|
+
const selectedGoodIndex = controller.useMemo(s => s.goodsListState.selectedGoodIndex, []);
|
|
17
|
+
|
|
13
18
|
const goodsList = controller.useMemo(s => s.goodsListState.goodsList, [])
|
|
14
19
|
|
|
15
20
|
const giveaways = React.useMemo(() => goodsList.filter(e => e.lineAttribute === LineAttributeType.赠品行), [goodsList])
|
|
16
21
|
|
|
17
|
-
const
|
|
22
|
+
const onClickAuto = React.useCallback(async () => {
|
|
18
23
|
for (let g of giveaways) {
|
|
19
24
|
g.lineAttribute = LineAttributeType.正常;
|
|
20
25
|
await controller.addGoodDiscountV2([{ $index: g.$index, discolineAmountunt: g.lineAmountIncludeTax || 0 }]);
|
|
21
26
|
}
|
|
22
27
|
}, [controller, giveaways])
|
|
23
28
|
|
|
29
|
+
const onClickManual = React.useCallback(async () => {
|
|
30
|
+
const { goodsMap, selectedGoodIndex } = controller.state.goodsListState;
|
|
31
|
+
const giveaways = selectedGoodIndex.map(e => goodsMap.get(e) as IGood).filter(e => !!e);
|
|
32
|
+
|
|
33
|
+
if (giveaways.some(e => e.lineAttribute === LineAttributeType.正常 || e.lineAttribute === LineAttributeType.赠品行) === false) {
|
|
34
|
+
const content = '只能选择‘赠品行’和‘正常行’';
|
|
35
|
+
return message.error({ content, key: content });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
for (let g of giveaways) {
|
|
39
|
+
await controller.addGoodDiscountV2([{ $index: g.$index, discolineAmountunt: g.lineAmountIncludeTax || 0 }]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
controller.state.goodsListState.selectedGoodIndex = [];
|
|
43
|
+
}, [controller])
|
|
44
|
+
|
|
45
|
+
const items: MenuProps['items'] = React.useMemo(() => {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
key: '0',
|
|
49
|
+
label: '自动转换',
|
|
50
|
+
disabled: giveaways.length <= 0,
|
|
51
|
+
onClick: onClickAuto,
|
|
52
|
+
}, {
|
|
53
|
+
key: '1',
|
|
54
|
+
label: '手动转换',
|
|
55
|
+
disabled: selectedGoodIndex.length <= 0,
|
|
56
|
+
onClick: onClickManual,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto])
|
|
60
|
+
|
|
24
61
|
const button = React.useMemo(() => {
|
|
25
|
-
if (
|
|
62
|
+
if (!isSalesGifts) return;
|
|
26
63
|
return (
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
64
|
+
<Dropdown menu={{ items }} trigger={['click']} >
|
|
65
|
+
<Button>
|
|
66
|
+
销售赠品
|
|
67
|
+
</Button>
|
|
68
|
+
</Dropdown>
|
|
30
69
|
)
|
|
31
|
-
}, [
|
|
70
|
+
}, [items, isSalesGifts])
|
|
32
71
|
|
|
33
72
|
return {
|
|
34
73
|
/** 按钮 */
|