kts-component-invoice-operate 3.2.69 → 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.
@@ -72,6 +72,8 @@ export default class GoodsListState {
72
72
  isMergeDiscount: boolean;
73
73
  /** 是否可以销售折让 */
74
74
  isSalesDiscount: boolean;
75
+ /** 是否可以销售赠品 */
76
+ isSalesGifts: boolean;
75
77
  /** 正在 添加商品对照 的货物 */
76
78
  addComparisonIndex?: string;
77
79
  /** 商品拖拽数据 */
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  /** 销售折让 */
3
- export default function uaeSalesDiscount(): {
3
+ export default function useSalesDiscount(): {
4
4
  /** 按钮 */
5
5
  button: JSX.Element;
6
6
  };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ /** 销售赠品 */
3
+ export default function useSalesGifts(): {
4
+ /** 按钮 */
5
+ button: JSX.Element | undefined;
6
+ };
package/dist/index.esm.js CHANGED
@@ -616,6 +616,63 @@ function _nonIterableRest() {
616
616
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
617
617
  }
618
618
 
619
+ function _createForOfIteratorHelper(o, allowArrayLike) {
620
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
621
+
622
+ if (!it) {
623
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
624
+ if (it) o = it;
625
+ var i = 0;
626
+
627
+ var F = function () {};
628
+
629
+ return {
630
+ s: F,
631
+ n: function () {
632
+ if (i >= o.length) return {
633
+ done: true
634
+ };
635
+ return {
636
+ done: false,
637
+ value: o[i++]
638
+ };
639
+ },
640
+ e: function (e) {
641
+ throw e;
642
+ },
643
+ f: F
644
+ };
645
+ }
646
+
647
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
648
+ }
649
+
650
+ var normalCompletion = true,
651
+ didErr = false,
652
+ err;
653
+ return {
654
+ s: function () {
655
+ it = it.call(o);
656
+ },
657
+ n: function () {
658
+ var step = it.next();
659
+ normalCompletion = step.done;
660
+ return step;
661
+ },
662
+ e: function (e) {
663
+ didErr = true;
664
+ err = e;
665
+ },
666
+ f: function () {
667
+ try {
668
+ if (!normalCompletion && it.return != null) it.return();
669
+ } finally {
670
+ if (didErr) throw err;
671
+ }
672
+ }
673
+ };
674
+ }
675
+
619
676
  function styleInject(css, ref) {
620
677
  if ( ref === void 0 ) ref = {};
621
678
  var insertAt = ref.insertAt;
@@ -1032,6 +1089,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1032
1089
  this.isMergeDetails = false;
1033
1090
  this.isMergeDiscount = false;
1034
1091
  this.isSalesDiscount = false;
1092
+ this.isSalesGifts = false;
1035
1093
  this.addComparisonIndex = void 0;
1036
1094
  this.drag = new Drag();
1037
1095
  });
@@ -14712,7 +14770,7 @@ function useMergeDiscount() {
14712
14770
 
14713
14771
  /** 销售折让 */
14714
14772
 
14715
- function uaeSalesDiscount() {
14773
+ function useSalesDiscount() {
14716
14774
  var controller = Invoice.useInvoiceController();
14717
14775
  var selectedGoodIndex = controller.useMemo(function (s) {
14718
14776
  return s.goodsListState.selectedGoodIndex;
@@ -14904,6 +14962,183 @@ function uaeSalesDiscount() {
14904
14962
  };
14905
14963
  }
14906
14964
 
14965
+ /** 销售赠品 */
14966
+
14967
+ function useSalesGifts() {
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
+ }, []);
14975
+ var goodsList = controller.useMemo(function (s) {
14976
+ return s.goodsListState.goodsList;
14977
+ }, []);
14978
+ var giveaways = React.useMemo(function () {
14979
+ return goodsList.filter(function (e) {
14980
+ return e.lineAttribute === LineAttributeType$1.赠品行;
14981
+ });
14982
+ }, [goodsList]);
14983
+ var onClickAuto = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14984
+ var _iterator, _step, g;
14985
+
14986
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14987
+ while (1) {
14988
+ switch (_context.prev = _context.next) {
14989
+ case 0:
14990
+ _iterator = _createForOfIteratorHelper(giveaways);
14991
+ _context.prev = 1;
14992
+
14993
+ _iterator.s();
14994
+
14995
+ case 3:
14996
+ if ((_step = _iterator.n()).done) {
14997
+ _context.next = 10;
14998
+ break;
14999
+ }
15000
+
15001
+ g = _step.value;
15002
+ g.lineAttribute = LineAttributeType$1.正常;
15003
+ _context.next = 8;
15004
+ return controller.addGoodDiscountV2([{
15005
+ $index: g.$index,
15006
+ discolineAmountunt: g.lineAmountIncludeTax || 0
15007
+ }]);
15008
+
15009
+ case 8:
15010
+ _context.next = 3;
15011
+ break;
15012
+
15013
+ case 10:
15014
+ _context.next = 15;
15015
+ break;
15016
+
15017
+ case 12:
15018
+ _context.prev = 12;
15019
+ _context.t0 = _context["catch"](1);
15020
+
15021
+ _iterator.e(_context.t0);
15022
+
15023
+ case 15:
15024
+ _context.prev = 15;
15025
+
15026
+ _iterator.f();
15027
+
15028
+ return _context.finish(15);
15029
+
15030
+ case 18:
15031
+ case "end":
15032
+ return _context.stop();
15033
+ }
15034
+ }
15035
+ }, _callee, null, [[1, 12, 15, 18]]);
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]);
15127
+ var button = React.useMemo(function () {
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]);
15136
+ return {
15137
+ /** 按钮 */
15138
+ button: button
15139
+ };
15140
+ }
15141
+
14907
15142
  var GoodsList = /*#__PURE__*/function (_React$Component) {
14908
15143
  _inherits(GoodsList, _React$Component);
14909
15144
 
@@ -14968,7 +15203,10 @@ var Main = decorator(Form.create())(function (props) {
14968
15203
  var mergeDiscount = useMergeDiscount();
14969
15204
  /** 销售折让 */
14970
15205
 
14971
- var salesDiscount = uaeSalesDiscount();
15206
+ var salesDiscount = useSalesDiscount();
15207
+ /** 销售赠品 */
15208
+
15209
+ var salesGifts = useSalesGifts();
14972
15210
  /** 清空自动赋码缓存 */
14973
15211
 
14974
15212
  React.useEffect(function () {
@@ -15126,7 +15364,7 @@ var Main = decorator(Form.create())(function (props) {
15126
15364
  className: "kts-invoice-operate-goods-list-able"
15127
15365
  }, React.createElement("div", {
15128
15366
  className: "kts-invoice-operate-goods-list-able-list"
15129
- }, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, React.createElement(Search, null)), React.createElement("div", {
15367
+ }, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, salesGifts.button, React.createElement(Search, null)), React.createElement("div", {
15130
15368
  className: "kts-invoice-operate-goods-list-able-extend"
15131
15369
  }, props.menuExpansion, React.createElement(DescribeSwitch, null), React.createElement(TaxIncludedSwitch, null))), React.createElement("div", {
15132
15370
  className: classNames('kts-invoice-operate-goods-list-table', {
package/dist/index.js CHANGED
@@ -626,6 +626,63 @@ function _nonIterableRest() {
626
626
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
627
627
  }
628
628
 
629
+ function _createForOfIteratorHelper(o, allowArrayLike) {
630
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
631
+
632
+ if (!it) {
633
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
634
+ if (it) o = it;
635
+ var i = 0;
636
+
637
+ var F = function () {};
638
+
639
+ return {
640
+ s: F,
641
+ n: function () {
642
+ if (i >= o.length) return {
643
+ done: true
644
+ };
645
+ return {
646
+ done: false,
647
+ value: o[i++]
648
+ };
649
+ },
650
+ e: function (e) {
651
+ throw e;
652
+ },
653
+ f: F
654
+ };
655
+ }
656
+
657
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
658
+ }
659
+
660
+ var normalCompletion = true,
661
+ didErr = false,
662
+ err;
663
+ return {
664
+ s: function () {
665
+ it = it.call(o);
666
+ },
667
+ n: function () {
668
+ var step = it.next();
669
+ normalCompletion = step.done;
670
+ return step;
671
+ },
672
+ e: function (e) {
673
+ didErr = true;
674
+ err = e;
675
+ },
676
+ f: function () {
677
+ try {
678
+ if (!normalCompletion && it.return != null) it.return();
679
+ } finally {
680
+ if (didErr) throw err;
681
+ }
682
+ }
683
+ };
684
+ }
685
+
629
686
  function styleInject(css, ref) {
630
687
  if ( ref === void 0 ) ref = {};
631
688
  var insertAt = ref.insertAt;
@@ -1042,6 +1099,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1042
1099
  this.isMergeDetails = false;
1043
1100
  this.isMergeDiscount = false;
1044
1101
  this.isSalesDiscount = false;
1102
+ this.isSalesGifts = false;
1045
1103
  this.addComparisonIndex = void 0;
1046
1104
  this.drag = new Drag();
1047
1105
  });
@@ -14722,7 +14780,7 @@ function useMergeDiscount() {
14722
14780
 
14723
14781
  /** 销售折让 */
14724
14782
 
14725
- function uaeSalesDiscount() {
14783
+ function useSalesDiscount() {
14726
14784
  var controller = Invoice.useInvoiceController();
14727
14785
  var selectedGoodIndex = controller.useMemo(function (s) {
14728
14786
  return s.goodsListState.selectedGoodIndex;
@@ -14914,6 +14972,183 @@ function uaeSalesDiscount() {
14914
14972
  };
14915
14973
  }
14916
14974
 
14975
+ /** 销售赠品 */
14976
+
14977
+ function useSalesGifts() {
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
+ }, []);
14985
+ var goodsList = controller.useMemo(function (s) {
14986
+ return s.goodsListState.goodsList;
14987
+ }, []);
14988
+ var giveaways = React__default['default'].useMemo(function () {
14989
+ return goodsList.filter(function (e) {
14990
+ return e.lineAttribute === LineAttributeType$1.赠品行;
14991
+ });
14992
+ }, [goodsList]);
14993
+ var onClickAuto = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
14994
+ var _iterator, _step, g;
14995
+
14996
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14997
+ while (1) {
14998
+ switch (_context.prev = _context.next) {
14999
+ case 0:
15000
+ _iterator = _createForOfIteratorHelper(giveaways);
15001
+ _context.prev = 1;
15002
+
15003
+ _iterator.s();
15004
+
15005
+ case 3:
15006
+ if ((_step = _iterator.n()).done) {
15007
+ _context.next = 10;
15008
+ break;
15009
+ }
15010
+
15011
+ g = _step.value;
15012
+ g.lineAttribute = LineAttributeType$1.正常;
15013
+ _context.next = 8;
15014
+ return controller.addGoodDiscountV2([{
15015
+ $index: g.$index,
15016
+ discolineAmountunt: g.lineAmountIncludeTax || 0
15017
+ }]);
15018
+
15019
+ case 8:
15020
+ _context.next = 3;
15021
+ break;
15022
+
15023
+ case 10:
15024
+ _context.next = 15;
15025
+ break;
15026
+
15027
+ case 12:
15028
+ _context.prev = 12;
15029
+ _context.t0 = _context["catch"](1);
15030
+
15031
+ _iterator.e(_context.t0);
15032
+
15033
+ case 15:
15034
+ _context.prev = 15;
15035
+
15036
+ _iterator.f();
15037
+
15038
+ return _context.finish(15);
15039
+
15040
+ case 18:
15041
+ case "end":
15042
+ return _context.stop();
15043
+ }
15044
+ }
15045
+ }, _callee, null, [[1, 12, 15, 18]]);
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]);
15137
+ var button = React__default['default'].useMemo(function () {
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]);
15146
+ return {
15147
+ /** 按钮 */
15148
+ button: button
15149
+ };
15150
+ }
15151
+
14917
15152
  var GoodsList = /*#__PURE__*/function (_React$Component) {
14918
15153
  _inherits(GoodsList, _React$Component);
14919
15154
 
@@ -14978,7 +15213,10 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
14978
15213
  var mergeDiscount = useMergeDiscount();
14979
15214
  /** 销售折让 */
14980
15215
 
14981
- var salesDiscount = uaeSalesDiscount();
15216
+ var salesDiscount = useSalesDiscount();
15217
+ /** 销售赠品 */
15218
+
15219
+ var salesGifts = useSalesGifts();
14982
15220
  /** 清空自动赋码缓存 */
14983
15221
 
14984
15222
  React__default['default'].useEffect(function () {
@@ -15136,7 +15374,7 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
15136
15374
  className: "kts-invoice-operate-goods-list-able"
15137
15375
  }, React__default['default'].createElement("div", {
15138
15376
  className: "kts-invoice-operate-goods-list-able-list"
15139
- }, React__default['default'].createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, React__default['default'].createElement(Search, null)), React__default['default'].createElement("div", {
15377
+ }, React__default['default'].createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, salesGifts.button, React__default['default'].createElement(Search, null)), React__default['default'].createElement("div", {
15140
15378
  className: "kts-invoice-operate-goods-list-able-extend"
15141
15379
  }, props.menuExpansion, React__default['default'].createElement(DescribeSwitch, null), React__default['default'].createElement(TaxIncludedSwitch, null))), React__default['default'].createElement("div", {
15142
15380
  className: classNames__default['default']('kts-invoice-operate-goods-list-table', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.69",
3
+ "version": "3.2.71",
4
4
  "scripts": {
5
5
  "dev": "dumi dev",
6
6
  "start": "dumi dev",
@@ -102,9 +102,12 @@ export default class GoodsListState {
102
102
  /** 是否可以销售折让 */
103
103
  isSalesDiscount = false;
104
104
 
105
+ /** 是否可以销售赠品 */
106
+ isSalesGifts = false;
107
+
105
108
  /** 正在 添加商品对照 的货物 */
106
109
  addComparisonIndex?: string;
107
110
 
108
111
  /** 商品拖拽数据 */
109
- drag = new Drag()
112
+ drag = new Drag();
110
113
  }
@@ -249,9 +249,9 @@ const lines: any[] = [
249
249
  "id": "40823568750477313",
250
250
  "itemModelName": "",
251
251
  "itemName": "打折",
252
- "lineAmountExcludeTax": -100,
253
- "lineAmountIncludeTax": -100,
254
- "lineAttribute": 3,
252
+ "lineAmountExcludeTax": 100,
253
+ "lineAmountIncludeTax": 100,
254
+ "lineAttribute": 4,
255
255
  "lineDiscountExcludeTax": null,
256
256
  "lineDiscountRate": null,
257
257
  "lineId": "1740823580142206976",
@@ -29,7 +29,8 @@ 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
31
  import useMergeDiscount from './ui/BulkMenu/hooks/useMergeDiscount';
32
- import uaeSalesDiscount from './ui/BulkMenu/hooks/uaeSalesDiscount';
32
+ import useSalesDiscount from './ui/BulkMenu/hooks/useSalesDiscount';
33
+ import useSalesGifts from './ui/BulkMenu/hooks/useSalesGifts';
33
34
 
34
35
  export interface IGoodsListProps {
35
36
  /** 扩展部分 */
@@ -93,7 +94,10 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
93
94
  const mergeDiscount = useMergeDiscount()
94
95
 
95
96
  /** 销售折让 */
96
- const salesDiscount = uaeSalesDiscount()
97
+ const salesDiscount = useSalesDiscount()
98
+
99
+ /** 销售赠品 */
100
+ const salesGifts = useSalesGifts()
97
101
 
98
102
  /** 清空自动赋码缓存 */
99
103
  React.useEffect(() => {
@@ -156,6 +160,9 @@ const Main = decorator<IGoodsListProps, FormComponentProps & IGoodsListProps>(Fo
156
160
  {/* 销售折让 */}
157
161
  {salesDiscount.button}
158
162
 
163
+ {/* 销售赠品 */}
164
+ {salesGifts.button}
165
+
159
166
  {/* 搜索 */}
160
167
  <Search />
161
168
  </div>
@@ -6,7 +6,7 @@ import Invoice from '../../../../../../..'
6
6
  import { LineAttributeType } from "../../../../../../../InvoiceController";
7
7
 
8
8
  /** 销售折让 */
9
- export default function uaeSalesDiscount() {
9
+ export default function useSalesDiscount() {
10
10
 
11
11
  const controller = Invoice.useInvoiceController();
12
12
 
@@ -0,0 +1,76 @@
1
+
2
+ import React from "react"
3
+ import { Button, message } from "kts-components-antd-x3"
4
+ import { chain, bignumber } from 'mathjs';
5
+ import Invoice from '../../../../../../..'
6
+ import { IGood, LineAttributeType } from "../../../../../../../InvoiceController";
7
+ import { Dropdown, MenuProps } from "kts-xui";
8
+
9
+ /** 销售赠品 */
10
+ export default function useSalesGifts() {
11
+
12
+ const controller = Invoice.useInvoiceController();
13
+
14
+ const isSalesGifts = controller.useMemo(s => s.goodsListState.isSalesGifts, []);
15
+
16
+ const selectedGoodIndex = controller.useMemo(s => s.goodsListState.selectedGoodIndex, []);
17
+
18
+ const goodsList = controller.useMemo(s => s.goodsListState.goodsList, [])
19
+
20
+ const giveaways = React.useMemo(() => goodsList.filter(e => e.lineAttribute === LineAttributeType.赠品行), [goodsList])
21
+
22
+ const onClickAuto = React.useCallback(async () => {
23
+ for (let g of giveaways) {
24
+ g.lineAttribute = LineAttributeType.正常;
25
+ await controller.addGoodDiscountV2([{ $index: g.$index, discolineAmountunt: g.lineAmountIncludeTax || 0 }]);
26
+ }
27
+ }, [controller, giveaways])
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
+
61
+ const button = React.useMemo(() => {
62
+ if (!isSalesGifts) return;
63
+ return (
64
+ <Dropdown menu={{ items }} trigger={['click']} >
65
+ <Button>
66
+ 销售赠品
67
+ </Button>
68
+ </Dropdown>
69
+ )
70
+ }, [items, isSalesGifts])
71
+
72
+ return {
73
+ /** 按钮 */
74
+ button,
75
+ }
76
+ }