kts-component-invoice-operate 3.2.70 → 3.2.71-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/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/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 +124 -8
- package/dist/index.js +124 -8
- package/package.json +1 -1
- package/src/Invoice/Invoice-digtal/_test/readOnly/index.tsx +4 -3
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +3 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/Stakeholder/index.ts +3 -0
- package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useSalesGifts/index.tsx +46 -7
- package/src/Invoice/ui/digtal/Sign/index.tsx +11 -1
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
|
});
|
|
@@ -1151,6 +1152,7 @@ var Stakeholder = /*#__PURE__*/_createClass(function Stakeholder() {
|
|
|
1151
1152
|
_classCallCheck(this, Stakeholder);
|
|
1152
1153
|
|
|
1153
1154
|
this.disableds = void 0;
|
|
1155
|
+
this.enables = void 0;
|
|
1154
1156
|
this.rulesMap = void 0;
|
|
1155
1157
|
});
|
|
1156
1158
|
|
|
@@ -14965,6 +14967,12 @@ function useSalesDiscount() {
|
|
|
14965
14967
|
|
|
14966
14968
|
function useSalesGifts() {
|
|
14967
14969
|
var controller = Invoice.useInvoiceController();
|
|
14970
|
+
var isSalesGifts = controller.useMemo(function (s) {
|
|
14971
|
+
return s.goodsListState.isSalesGifts;
|
|
14972
|
+
}, []);
|
|
14973
|
+
var selectedGoodIndex = controller.useMemo(function (s) {
|
|
14974
|
+
return s.goodsListState.selectedGoodIndex;
|
|
14975
|
+
}, []);
|
|
14968
14976
|
var goodsList = controller.useMemo(function (s) {
|
|
14969
14977
|
return s.goodsListState.goodsList;
|
|
14970
14978
|
}, []);
|
|
@@ -14973,7 +14981,7 @@ function useSalesGifts() {
|
|
|
14973
14981
|
return e.lineAttribute === LineAttributeType$1.赠品行;
|
|
14974
14982
|
});
|
|
14975
14983
|
}, [goodsList]);
|
|
14976
|
-
var
|
|
14984
|
+
var onClickAuto = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
14977
14985
|
var _iterator, _step, g;
|
|
14978
14986
|
|
|
14979
14987
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -15027,12 +15035,105 @@ function useSalesGifts() {
|
|
|
15027
15035
|
}
|
|
15028
15036
|
}, _callee, null, [[1, 12, 15, 18]]);
|
|
15029
15037
|
})), [controller, giveaways]);
|
|
15038
|
+
var onClickManual = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
15039
|
+
var _controller$state$goo, goodsMap, selectedGoodIndex, giveaways, content, _iterator2, _step2, g;
|
|
15040
|
+
|
|
15041
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15042
|
+
while (1) {
|
|
15043
|
+
switch (_context2.prev = _context2.next) {
|
|
15044
|
+
case 0:
|
|
15045
|
+
_controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
|
|
15046
|
+
giveaways = selectedGoodIndex.map(function (e) {
|
|
15047
|
+
return goodsMap.get(e);
|
|
15048
|
+
}).filter(function (e) {
|
|
15049
|
+
return !!e;
|
|
15050
|
+
});
|
|
15051
|
+
|
|
15052
|
+
if (!(giveaways.some(function (e) {
|
|
15053
|
+
return e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行;
|
|
15054
|
+
}) === false)) {
|
|
15055
|
+
_context2.next = 5;
|
|
15056
|
+
break;
|
|
15057
|
+
}
|
|
15058
|
+
|
|
15059
|
+
content = '只能选择‘赠品行’和‘正常行’';
|
|
15060
|
+
return _context2.abrupt("return", message.error({
|
|
15061
|
+
content: content,
|
|
15062
|
+
key: content
|
|
15063
|
+
}));
|
|
15064
|
+
|
|
15065
|
+
case 5:
|
|
15066
|
+
_iterator2 = _createForOfIteratorHelper(giveaways);
|
|
15067
|
+
_context2.prev = 6;
|
|
15068
|
+
|
|
15069
|
+
_iterator2.s();
|
|
15070
|
+
|
|
15071
|
+
case 8:
|
|
15072
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
15073
|
+
_context2.next = 14;
|
|
15074
|
+
break;
|
|
15075
|
+
}
|
|
15076
|
+
|
|
15077
|
+
g = _step2.value;
|
|
15078
|
+
_context2.next = 12;
|
|
15079
|
+
return controller.addGoodDiscountV2([{
|
|
15080
|
+
$index: g.$index,
|
|
15081
|
+
discolineAmountunt: g.lineAmountIncludeTax || 0
|
|
15082
|
+
}]);
|
|
15083
|
+
|
|
15084
|
+
case 12:
|
|
15085
|
+
_context2.next = 8;
|
|
15086
|
+
break;
|
|
15087
|
+
|
|
15088
|
+
case 14:
|
|
15089
|
+
_context2.next = 19;
|
|
15090
|
+
break;
|
|
15091
|
+
|
|
15092
|
+
case 16:
|
|
15093
|
+
_context2.prev = 16;
|
|
15094
|
+
_context2.t0 = _context2["catch"](6);
|
|
15095
|
+
|
|
15096
|
+
_iterator2.e(_context2.t0);
|
|
15097
|
+
|
|
15098
|
+
case 19:
|
|
15099
|
+
_context2.prev = 19;
|
|
15100
|
+
|
|
15101
|
+
_iterator2.f();
|
|
15102
|
+
|
|
15103
|
+
return _context2.finish(19);
|
|
15104
|
+
|
|
15105
|
+
case 22:
|
|
15106
|
+
controller.state.goodsListState.selectedGoodIndex = [];
|
|
15107
|
+
|
|
15108
|
+
case 23:
|
|
15109
|
+
case "end":
|
|
15110
|
+
return _context2.stop();
|
|
15111
|
+
}
|
|
15112
|
+
}
|
|
15113
|
+
}, _callee2, null, [[6, 16, 19, 22]]);
|
|
15114
|
+
})), [controller]);
|
|
15115
|
+
var items = React.useMemo(function () {
|
|
15116
|
+
return [{
|
|
15117
|
+
key: '0',
|
|
15118
|
+
label: '自动转换',
|
|
15119
|
+
disabled: giveaways.length <= 0,
|
|
15120
|
+
onClick: onClickAuto
|
|
15121
|
+
}, {
|
|
15122
|
+
key: '1',
|
|
15123
|
+
label: '手动转换',
|
|
15124
|
+
disabled: selectedGoodIndex.length <= 0,
|
|
15125
|
+
onClick: onClickManual
|
|
15126
|
+
}];
|
|
15127
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto]);
|
|
15030
15128
|
var button = React.useMemo(function () {
|
|
15031
|
-
if (
|
|
15032
|
-
return React.createElement(
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
|
|
15129
|
+
if (!isSalesGifts) return;
|
|
15130
|
+
return React.createElement(Dropdown$1, {
|
|
15131
|
+
menu: {
|
|
15132
|
+
items: items
|
|
15133
|
+
},
|
|
15134
|
+
trigger: ['click']
|
|
15135
|
+
}, React.createElement(Button, null, "\u9500\u552E\u8D60\u54C1"));
|
|
15136
|
+
}, [items, isSalesGifts]);
|
|
15036
15137
|
return {
|
|
15037
15138
|
/** 按钮 */
|
|
15038
15139
|
button: button
|
|
@@ -16543,15 +16644,25 @@ var SignDigtal = decorator(Form.create())(function (props) {
|
|
|
16543
16644
|
var model = controller.useMemo(function (s) {
|
|
16544
16645
|
return s.model;
|
|
16545
16646
|
}, []);
|
|
16647
|
+
/** 禁用字段 */
|
|
16648
|
+
|
|
16546
16649
|
var disableds = controller.useMemo(function (s) {
|
|
16547
16650
|
return s.stakeholder.disableds || [];
|
|
16548
16651
|
}, []);
|
|
16652
|
+
/** 启用字段 */
|
|
16653
|
+
|
|
16654
|
+
var enables = controller.useMemo(function (s) {
|
|
16655
|
+
return s.stakeholder.enables || [];
|
|
16656
|
+
}, []);
|
|
16549
16657
|
var readOnly = React.useMemo(function () {
|
|
16550
16658
|
return model === 'readOnly';
|
|
16551
16659
|
}, [model]);
|
|
16552
16660
|
var isReadOnly = React.useCallback(function (field) {
|
|
16553
16661
|
return disableds.indexOf(field) >= 0;
|
|
16554
|
-
}, [disableds]);
|
|
16662
|
+
}, [disableds]);
|
|
16663
|
+
var isEnables = React.useCallback(function (field) {
|
|
16664
|
+
return enables.indexOf(field) >= 0;
|
|
16665
|
+
}, [enables]); // 注册 form
|
|
16555
16666
|
|
|
16556
16667
|
controller.useForm('sign', form);
|
|
16557
16668
|
|
|
@@ -16562,7 +16673,12 @@ var SignDigtal = decorator(Form.create())(function (props) {
|
|
|
16562
16673
|
className: 'sign-digtal-readOnly-cont'
|
|
16563
16674
|
}, React.createElement("div", null, React.createElement("span", null, "\u5907"), React.createElement("span", null, "\u6CE8")), React.createElement("div", null, getFieldDecorator('remarks', {
|
|
16564
16675
|
initialValue: props.defaultRemark
|
|
16565
|
-
})(React.createElement(
|
|
16676
|
+
})(isEnables('remarks') ? React.createElement(Input$1.TextArea, {
|
|
16677
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
|
16678
|
+
style: {
|
|
16679
|
+
height: '100%'
|
|
16680
|
+
}
|
|
16681
|
+
}) : React.createElement(MyDiv$1, null)))), React.createElement(Form, {
|
|
16566
16682
|
layout: 'inline',
|
|
16567
16683
|
className: 'digtal-readOnly-form'
|
|
16568
16684
|
}, React.createElement(Form.Item, {
|
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
|
});
|
|
@@ -1161,6 +1162,7 @@ var Stakeholder = /*#__PURE__*/_createClass(function Stakeholder() {
|
|
|
1161
1162
|
_classCallCheck(this, Stakeholder);
|
|
1162
1163
|
|
|
1163
1164
|
this.disableds = void 0;
|
|
1165
|
+
this.enables = void 0;
|
|
1164
1166
|
this.rulesMap = void 0;
|
|
1165
1167
|
});
|
|
1166
1168
|
|
|
@@ -14975,6 +14977,12 @@ function useSalesDiscount() {
|
|
|
14975
14977
|
|
|
14976
14978
|
function useSalesGifts() {
|
|
14977
14979
|
var controller = Invoice.useInvoiceController();
|
|
14980
|
+
var isSalesGifts = controller.useMemo(function (s) {
|
|
14981
|
+
return s.goodsListState.isSalesGifts;
|
|
14982
|
+
}, []);
|
|
14983
|
+
var selectedGoodIndex = controller.useMemo(function (s) {
|
|
14984
|
+
return s.goodsListState.selectedGoodIndex;
|
|
14985
|
+
}, []);
|
|
14978
14986
|
var goodsList = controller.useMemo(function (s) {
|
|
14979
14987
|
return s.goodsListState.goodsList;
|
|
14980
14988
|
}, []);
|
|
@@ -14983,7 +14991,7 @@ function useSalesGifts() {
|
|
|
14983
14991
|
return e.lineAttribute === LineAttributeType$1.赠品行;
|
|
14984
14992
|
});
|
|
14985
14993
|
}, [goodsList]);
|
|
14986
|
-
var
|
|
14994
|
+
var onClickAuto = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
14987
14995
|
var _iterator, _step, g;
|
|
14988
14996
|
|
|
14989
14997
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -15037,12 +15045,105 @@ function useSalesGifts() {
|
|
|
15037
15045
|
}
|
|
15038
15046
|
}, _callee, null, [[1, 12, 15, 18]]);
|
|
15039
15047
|
})), [controller, giveaways]);
|
|
15048
|
+
var onClickManual = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
15049
|
+
var _controller$state$goo, goodsMap, selectedGoodIndex, giveaways, content, _iterator2, _step2, g;
|
|
15050
|
+
|
|
15051
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
15052
|
+
while (1) {
|
|
15053
|
+
switch (_context2.prev = _context2.next) {
|
|
15054
|
+
case 0:
|
|
15055
|
+
_controller$state$goo = controller.state.goodsListState, goodsMap = _controller$state$goo.goodsMap, selectedGoodIndex = _controller$state$goo.selectedGoodIndex;
|
|
15056
|
+
giveaways = selectedGoodIndex.map(function (e) {
|
|
15057
|
+
return goodsMap.get(e);
|
|
15058
|
+
}).filter(function (e) {
|
|
15059
|
+
return !!e;
|
|
15060
|
+
});
|
|
15061
|
+
|
|
15062
|
+
if (!(giveaways.some(function (e) {
|
|
15063
|
+
return e.lineAttribute === LineAttributeType$1.正常 || e.lineAttribute === LineAttributeType$1.赠品行;
|
|
15064
|
+
}) === false)) {
|
|
15065
|
+
_context2.next = 5;
|
|
15066
|
+
break;
|
|
15067
|
+
}
|
|
15068
|
+
|
|
15069
|
+
content = '只能选择‘赠品行’和‘正常行’';
|
|
15070
|
+
return _context2.abrupt("return", ktsComponentsAntdX3.message.error({
|
|
15071
|
+
content: content,
|
|
15072
|
+
key: content
|
|
15073
|
+
}));
|
|
15074
|
+
|
|
15075
|
+
case 5:
|
|
15076
|
+
_iterator2 = _createForOfIteratorHelper(giveaways);
|
|
15077
|
+
_context2.prev = 6;
|
|
15078
|
+
|
|
15079
|
+
_iterator2.s();
|
|
15080
|
+
|
|
15081
|
+
case 8:
|
|
15082
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
15083
|
+
_context2.next = 14;
|
|
15084
|
+
break;
|
|
15085
|
+
}
|
|
15086
|
+
|
|
15087
|
+
g = _step2.value;
|
|
15088
|
+
_context2.next = 12;
|
|
15089
|
+
return controller.addGoodDiscountV2([{
|
|
15090
|
+
$index: g.$index,
|
|
15091
|
+
discolineAmountunt: g.lineAmountIncludeTax || 0
|
|
15092
|
+
}]);
|
|
15093
|
+
|
|
15094
|
+
case 12:
|
|
15095
|
+
_context2.next = 8;
|
|
15096
|
+
break;
|
|
15097
|
+
|
|
15098
|
+
case 14:
|
|
15099
|
+
_context2.next = 19;
|
|
15100
|
+
break;
|
|
15101
|
+
|
|
15102
|
+
case 16:
|
|
15103
|
+
_context2.prev = 16;
|
|
15104
|
+
_context2.t0 = _context2["catch"](6);
|
|
15105
|
+
|
|
15106
|
+
_iterator2.e(_context2.t0);
|
|
15107
|
+
|
|
15108
|
+
case 19:
|
|
15109
|
+
_context2.prev = 19;
|
|
15110
|
+
|
|
15111
|
+
_iterator2.f();
|
|
15112
|
+
|
|
15113
|
+
return _context2.finish(19);
|
|
15114
|
+
|
|
15115
|
+
case 22:
|
|
15116
|
+
controller.state.goodsListState.selectedGoodIndex = [];
|
|
15117
|
+
|
|
15118
|
+
case 23:
|
|
15119
|
+
case "end":
|
|
15120
|
+
return _context2.stop();
|
|
15121
|
+
}
|
|
15122
|
+
}
|
|
15123
|
+
}, _callee2, null, [[6, 16, 19, 22]]);
|
|
15124
|
+
})), [controller]);
|
|
15125
|
+
var items = React__default['default'].useMemo(function () {
|
|
15126
|
+
return [{
|
|
15127
|
+
key: '0',
|
|
15128
|
+
label: '自动转换',
|
|
15129
|
+
disabled: giveaways.length <= 0,
|
|
15130
|
+
onClick: onClickAuto
|
|
15131
|
+
}, {
|
|
15132
|
+
key: '1',
|
|
15133
|
+
label: '手动转换',
|
|
15134
|
+
disabled: selectedGoodIndex.length <= 0,
|
|
15135
|
+
onClick: onClickManual
|
|
15136
|
+
}];
|
|
15137
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto]);
|
|
15040
15138
|
var button = React__default['default'].useMemo(function () {
|
|
15041
|
-
if (
|
|
15042
|
-
return React__default['default'].createElement(
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15139
|
+
if (!isSalesGifts) return;
|
|
15140
|
+
return React__default['default'].createElement(ktsXui.Dropdown, {
|
|
15141
|
+
menu: {
|
|
15142
|
+
items: items
|
|
15143
|
+
},
|
|
15144
|
+
trigger: ['click']
|
|
15145
|
+
}, React__default['default'].createElement(ktsComponentsAntdX3.Button, null, "\u9500\u552E\u8D60\u54C1"));
|
|
15146
|
+
}, [items, isSalesGifts]);
|
|
15046
15147
|
return {
|
|
15047
15148
|
/** 按钮 */
|
|
15048
15149
|
button: button
|
|
@@ -16553,15 +16654,25 @@ var SignDigtal = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(funct
|
|
|
16553
16654
|
var model = controller.useMemo(function (s) {
|
|
16554
16655
|
return s.model;
|
|
16555
16656
|
}, []);
|
|
16657
|
+
/** 禁用字段 */
|
|
16658
|
+
|
|
16556
16659
|
var disableds = controller.useMemo(function (s) {
|
|
16557
16660
|
return s.stakeholder.disableds || [];
|
|
16558
16661
|
}, []);
|
|
16662
|
+
/** 启用字段 */
|
|
16663
|
+
|
|
16664
|
+
var enables = controller.useMemo(function (s) {
|
|
16665
|
+
return s.stakeholder.enables || [];
|
|
16666
|
+
}, []);
|
|
16559
16667
|
var readOnly = React__default['default'].useMemo(function () {
|
|
16560
16668
|
return model === 'readOnly';
|
|
16561
16669
|
}, [model]);
|
|
16562
16670
|
var isReadOnly = React__default['default'].useCallback(function (field) {
|
|
16563
16671
|
return disableds.indexOf(field) >= 0;
|
|
16564
|
-
}, [disableds]);
|
|
16672
|
+
}, [disableds]);
|
|
16673
|
+
var isEnables = React__default['default'].useCallback(function (field) {
|
|
16674
|
+
return enables.indexOf(field) >= 0;
|
|
16675
|
+
}, [enables]); // 注册 form
|
|
16565
16676
|
|
|
16566
16677
|
controller.useForm('sign', form);
|
|
16567
16678
|
|
|
@@ -16572,7 +16683,12 @@ var SignDigtal = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(funct
|
|
|
16572
16683
|
className: 'sign-digtal-readOnly-cont'
|
|
16573
16684
|
}, React__default['default'].createElement("div", null, React__default['default'].createElement("span", null, "\u5907"), React__default['default'].createElement("span", null, "\u6CE8")), React__default['default'].createElement("div", null, getFieldDecorator('remarks', {
|
|
16574
16685
|
initialValue: props.defaultRemark
|
|
16575
|
-
})(
|
|
16686
|
+
})(isEnables('remarks') ? React__default['default'].createElement(ktsXui.Input.TextArea, {
|
|
16687
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
|
16688
|
+
style: {
|
|
16689
|
+
height: '100%'
|
|
16690
|
+
}
|
|
16691
|
+
}) : React__default['default'].createElement(MyDiv$1, null)))), React__default['default'].createElement(ktsComponentsAntdX3.Form, {
|
|
16576
16692
|
layout: 'inline',
|
|
16577
16693
|
className: 'digtal-readOnly-form'
|
|
16578
16694
|
}, React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, {
|
package/package.json
CHANGED
|
@@ -9,10 +9,11 @@ export default () => {
|
|
|
9
9
|
React.useEffect(() => {
|
|
10
10
|
(async () => {
|
|
11
11
|
await controller.run(async s => { s.model = 'readOnly' }); // 设置只读
|
|
12
|
+
await controller.run(async s => { s.stakeholder.enables = ['remarks'] });
|
|
12
13
|
await controller.formList.get('invoiceHeader')?.setFieldsValue({
|
|
13
14
|
no: '2029292029201920291029',
|
|
14
15
|
invoicingDate: '2023年7月6日',
|
|
15
|
-
tag:'成品油',
|
|
16
|
+
tag: '成品油',
|
|
16
17
|
})
|
|
17
18
|
await controller.formList.get('stakeholder')?.setFieldsValue({
|
|
18
19
|
buyerName: '国能供应链内蒙古有限公司',
|
|
@@ -30,8 +31,8 @@ export default () => {
|
|
|
30
31
|
sellerAccount: '9550880218186900195',
|
|
31
32
|
})
|
|
32
33
|
await controller.formList.get('sign')?.setFieldsValue({
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
remarks: '备注',
|
|
35
|
+
drawer: '张自豪',
|
|
35
36
|
})
|
|
36
37
|
})()
|
|
37
38
|
}, [controller])
|
|
@@ -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
|
/** 按钮 */
|
|
@@ -27,12 +27,18 @@ export default decorator<IBuyerProps, IBuyerProps & FormComponentProps>(Form.cre
|
|
|
27
27
|
|
|
28
28
|
const model = controller.useMemo(s => s.model, []);
|
|
29
29
|
|
|
30
|
+
/** 禁用字段 */
|
|
30
31
|
const disableds = controller.useMemo(s => s.stakeholder.disableds || [], []);
|
|
31
32
|
|
|
33
|
+
/** 启用字段 */
|
|
34
|
+
const enables = controller.useMemo(s => s.stakeholder.enables || [], []);
|
|
35
|
+
|
|
32
36
|
const readOnly = React.useMemo(() => model === 'readOnly', [model]);
|
|
33
37
|
|
|
34
38
|
const isReadOnly = React.useCallback(field => disableds.indexOf(field) >= 0, [disableds])
|
|
35
39
|
|
|
40
|
+
const isEnables = React.useCallback(field => enables.indexOf(field) >= 0, [enables])
|
|
41
|
+
|
|
36
42
|
// 注册 form
|
|
37
43
|
controller.useForm('sign', form);
|
|
38
44
|
|
|
@@ -47,7 +53,11 @@ export default decorator<IBuyerProps, IBuyerProps & FormComponentProps>(Form.cre
|
|
|
47
53
|
<div>
|
|
48
54
|
{getFieldDecorator('remarks', {
|
|
49
55
|
initialValue: props.defaultRemark
|
|
50
|
-
})(
|
|
56
|
+
})(
|
|
57
|
+
isEnables('remarks')
|
|
58
|
+
? <Input.TextArea placeholder='请输入' style={{ height: '100%' }} />
|
|
59
|
+
: <MyDiv />
|
|
60
|
+
)}
|
|
51
61
|
</div>
|
|
52
62
|
</div>
|
|
53
63
|
<Form layout='inline' className='digtal-readOnly-form' >
|