kts-component-invoice-operate 3.2.60 → 3.2.62

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.
Files changed (28) hide show
  1. package/README.md +4 -1
  2. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.d.ts +2 -0
  3. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.d.ts +2 -1
  4. package/dist/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.d.ts +2 -0
  5. package/dist/Invoice/tools/coolingFn/index.d.ts +1 -1
  6. package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.d.ts +1 -1
  7. package/dist/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.d.ts +6 -0
  8. package/dist/index.esm.js +358 -118
  9. package/dist/index.js +358 -118
  10. package/package.json +1 -1
  11. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/Drag/index.ts +3 -0
  12. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/LineAttributeType/index.ts +2 -1
  13. package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/index.ts +4 -1
  14. package/src/Invoice/_test/endowCode/index.tsx +53 -2
  15. package/src/Invoice/tools/coolingFn/index.ts +1 -1
  16. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/Drag/index.tsx +24 -21
  17. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useDelItem/index.tsx +4 -0
  18. package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/RowMenu/hook/useEndowCode/index.tsx +5 -1
  19. package/src/Invoice/ui/default/GoodsList/hook/useRowSelection/index.tsx +1 -1
  20. package/src/Invoice/ui/default/GoodsList/index.tsx +7 -0
  21. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/uaeSalesDiscount/index.tsx +104 -0
  22. package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useEndowCodeButton/index.tsx +8 -1
  23. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.less +16 -1
  24. package/src/Invoice/ui/default/GoodsList/ui/TableRow/index.tsx +12 -1
  25. package/src/Invoice/ui/digtal/GoodsList/hook/useColumns/ui/Drag/index.tsx +56 -37
  26. package/src/Invoice/ui/digtal/GoodsList/ui/BulkMenu/hooks/useAddDiscountRowButton/index.tsx +0 -2
  27. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.less +16 -1
  28. package/src/Invoice/ui/digtal/GoodsList/ui/TableRow/index.tsx +14 -1
package/dist/index.js CHANGED
@@ -926,6 +926,7 @@ var LineAttributeType;
926
926
  LineAttributeType[LineAttributeType["\u6B63\u5E38"] = 0] = "\u6B63\u5E38";
927
927
  LineAttributeType[LineAttributeType["\u6298\u6263\u884C"] = 1] = "\u6298\u6263\u884C";
928
928
  LineAttributeType[LineAttributeType["\u88AB\u6298\u6263\u884C"] = 2] = "\u88AB\u6298\u6263\u884C";
929
+ LineAttributeType[LineAttributeType["\u6298\u8BA9\u884C"] = 3] = "\u6298\u8BA9\u884C";
929
930
  })(LineAttributeType || (LineAttributeType = {}));
930
931
 
931
932
  var LineAttributeType$1 = LineAttributeType;
@@ -1003,6 +1004,7 @@ var Drag = /*#__PURE__*/_createClass(function Drag() {
1003
1004
  this.isStart = false;
1004
1005
  this.current = void 0;
1005
1006
  this.container = void 0;
1007
+ this.site = void 0;
1006
1008
  });
1007
1009
 
1008
1010
  var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
@@ -1038,6 +1040,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1038
1040
  this.isVisibleDrawer = false;
1039
1041
  this.isMergeDetails = false;
1040
1042
  this.isMergeDiscount = false;
1043
+ this.isSalesDiscount = false;
1041
1044
  this.addComparisonIndex = void 0;
1042
1045
  this.drag = new Drag();
1043
1046
  });
@@ -10173,7 +10176,7 @@ function Search() {
10173
10176
  });
10174
10177
  }
10175
10178
 
10176
- var css_248z$5 = ".kts-invoice-operate-goods-list-itemName-drag-container {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n top: 0;\n z-index: 9999;\n}\n";
10179
+ var css_248z$5 = ".kts-invoice-operate-goods-list-itemName-drag-container-u {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-u::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n top: 0;\n z-index: 9999;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n bottom: 0;\n z-index: 9999;\n}\n";
10177
10180
  styleInject(css_248z$5);
10178
10181
 
10179
10182
  function TableRow(props) {
@@ -10182,9 +10185,18 @@ function TableRow(props) {
10182
10185
  var goodsMap = controller.useMemo(function (s) {
10183
10186
  return s.goodsListState.goodsMap;
10184
10187
  }, []);
10188
+ /** 当前拖动中的货品索引 */
10189
+
10185
10190
  var current = controller.useMemo(function (s) {
10186
10191
  return s.goodsListState.drag.current;
10187
10192
  }, []);
10193
+ /** 当前拖动中的货品索引 */
10194
+
10195
+ var site = controller.useMemo(function (s) {
10196
+ return s.goodsListState.drag.site;
10197
+ }, []);
10198
+ /** 准备插入的货物索引 */
10199
+
10188
10200
  var container = controller.useMemo(function (s) {
10189
10201
  return s.goodsListState.drag.container;
10190
10202
  }, []);
@@ -10218,7 +10230,7 @@ function TableRow(props) {
10218
10230
  bottom: 0
10219
10231
  }
10220
10232
  })) : React__default['default'].createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
10221
- className: classNames__default['default'](props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container' : undefined)
10233
+ className: classNames__default['default'](props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site : undefined)
10222
10234
  }));
10223
10235
  }
10224
10236
 
@@ -10248,6 +10260,10 @@ var useDelItem = (function (goods) {
10248
10260
  controller.delGood(goods.$index);
10249
10261
  }, [controller, goods.$index]);
10250
10262
 
10263
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10264
+ return undefined;
10265
+ }
10266
+
10251
10267
  if (goods.lineAttribute === LineAttributeType$1.被折扣行) {
10252
10268
  return undefined;
10253
10269
  }
@@ -10435,6 +10451,11 @@ var useEndowCode = (function (goods) {
10435
10451
  }
10436
10452
  }, _callee);
10437
10453
  })), [controller, goods]);
10454
+
10455
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10456
+ return undefined;
10457
+ }
10458
+
10438
10459
  return {
10439
10460
  key: 'endowCode',
10440
10461
  title: '赋码',
@@ -12040,64 +12061,57 @@ function Drag$1(props) {
12040
12061
  var currentGood = controller.state.goodsListState.goodsList.filter(function (e) {
12041
12062
  return e.$index === record.$index;
12042
12063
  })[0];
12043
- mounting(React__default['default'].createElement(DragDiv, _objectSpread2({}, currentGood))); // 监听移动
12044
-
12064
+ mounting(React__default['default'].createElement(DragDiv, _objectSpread2({}, currentGood)));
12045
12065
  rowList.forEach(function (e) {
12046
- e.addEventListener('mouseover', onMouseover);
12066
+ e.addEventListener('mousemove', onMousemove);
12047
12067
  });
12048
12068
 
12049
- function onMouseover(e) {
12069
+ function onMousemove(e) {
12050
12070
  controller.run( /*#__PURE__*/function () {
12051
12071
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
12052
- var _getRow, _getRow$dataset;
12072
+ var _rowDom$dataset;
12053
12073
 
12054
- var container, currentGood, row, currentIndex, containerIndex, _currentIndex, _containerIndex, t;
12074
+ var rowDom, container, row, currentGood, currentIndex, containerIndex, _currentIndex, _containerIndex, t, rect, mouseY;
12055
12075
 
12056
12076
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12057
12077
  while (1) {
12058
12078
  switch (_context2.prev = _context2.next) {
12059
12079
  case 0:
12060
- container = s.goodsListState.drag.container = (_getRow = getRow(e.target)) === null || _getRow === void 0 ? void 0 : (_getRow$dataset = _getRow.dataset) === null || _getRow$dataset === void 0 ? void 0 : _getRow$dataset.rowKey;
12080
+ rowDom = getRow(e.target);
12081
+ container = s.goodsListState.drag.container = rowDom === null || rowDom === void 0 ? void 0 : (_rowDom$dataset = rowDom.dataset) === null || _rowDom$dataset === void 0 ? void 0 : _rowDom$dataset.rowKey;
12082
+ /** 准备插入的货物 */
12061
12083
 
12062
- if (container) {
12063
- _context2.next = 3;
12084
+ row = s.goodsListState.goodsMap.get(container);
12085
+
12086
+ if (row) {
12087
+ _context2.next = 5;
12064
12088
  break;
12065
12089
  }
12066
12090
 
12067
12091
  return _context2.abrupt("return");
12068
12092
 
12069
- case 3:
12093
+ case 5:
12070
12094
  if (!(container === s.goodsListState.drag.current)) {
12071
- _context2.next = 6;
12095
+ _context2.next = 7;
12072
12096
  break;
12073
12097
  }
12074
12098
 
12075
- s.goodsListState.drag.container = undefined;
12076
- return _context2.abrupt("return");
12099
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
12077
12100
 
12078
- case 6:
12101
+ case 7:
12102
+ /** 当前拖动中的货品 */
12079
12103
  currentGood = s.goodsListState.drag.current && s.goodsListState.goodsMap.get(s.goodsListState.drag.current);
12080
12104
 
12081
12105
  if (currentGood) {
12082
- _context2.next = 9;
12106
+ _context2.next = 10;
12083
12107
  break;
12084
12108
  }
12085
12109
 
12086
12110
  return _context2.abrupt("return");
12087
12111
 
12088
- case 9:
12089
- row = s.goodsListState.goodsMap.get(container);
12090
-
12091
- if (row) {
12092
- _context2.next = 12;
12093
- break;
12094
- }
12095
-
12096
- return _context2.abrupt("return");
12097
-
12098
- case 12:
12112
+ case 10:
12099
12113
  if (!(currentGood.lineAttribute === LineAttributeType$1.折扣行)) {
12100
- _context2.next = 18;
12114
+ _context2.next = 15;
12101
12115
  break;
12102
12116
  }
12103
12117
 
@@ -12109,16 +12123,15 @@ function Drag$1(props) {
12109
12123
  }).indexOf(row.$index);
12110
12124
 
12111
12125
  if (!(currentIndex - 1 === containerIndex)) {
12112
- _context2.next = 18;
12126
+ _context2.next = 15;
12113
12127
  break;
12114
12128
  }
12115
12129
 
12116
- s.goodsListState.drag.container = undefined;
12117
- return _context2.abrupt("return");
12130
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
12118
12131
 
12119
- case 18:
12132
+ case 15:
12120
12133
  if (!(currentGood.lineAttribute === LineAttributeType$1.被折扣行)) {
12121
- _context2.next = 24;
12134
+ _context2.next = 20;
12122
12135
  break;
12123
12136
  }
12124
12137
 
@@ -12130,23 +12143,29 @@ function Drag$1(props) {
12130
12143
  }).indexOf(row.$index);
12131
12144
 
12132
12145
  if (!(_currentIndex + 1 === _containerIndex)) {
12133
- _context2.next = 24;
12146
+ _context2.next = 20;
12134
12147
  break;
12135
12148
  }
12136
12149
 
12137
- s.goodsListState.drag.container = undefined;
12138
- return _context2.abrupt("return");
12150
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
12139
12151
 
12140
- case 24:
12152
+ case 20:
12141
12153
  // 折扣行 拖动的 相当于 自己的 被折扣行
12142
12154
  if (row.lineAttribute === LineAttributeType$1.折扣行) {
12143
12155
  t = s.goodsListState.goodsList.map(function (e) {
12144
12156
  return e.$index;
12145
12157
  }).indexOf(container) - 1;
12146
12158
  s.goodsListState.drag.container = s.goodsListState.goodsList[t].$index;
12159
+ s.goodsListState.drag.site = 'u';
12160
+ } else if (row.lineAttribute === LineAttributeType$1.被折扣行) {
12161
+ s.goodsListState.drag.site = 'd';
12162
+ } else {
12163
+ rect = rowDom.getBoundingClientRect();
12164
+ mouseY = e.clientY - rect.top;
12165
+ s.goodsListState.drag.site = mouseY > 15 ? 'd' : 'u';
12147
12166
  }
12148
12167
 
12149
- case 25:
12168
+ case 21:
12150
12169
  case "end":
12151
12170
  return _context2.stop();
12152
12171
  }
@@ -12199,7 +12218,7 @@ function Drag$1(props) {
12199
12218
  }());
12200
12219
  window.removeEventListener('mouseup', onMouseup);
12201
12220
  rowList.forEach(function (e) {
12202
- e.removeEventListener('mouseover', onMouseover);
12221
+ e.removeEventListener('mousemove', onMousemove);
12203
12222
  }); // window.document.body.removeChild(rowDiv);
12204
12223
  } // 开始插入
12205
12224
 
@@ -12208,13 +12227,13 @@ function Drag$1(props) {
12208
12227
  mounting(React__default['default'].createElement(React__default['default'].Fragment, null));
12209
12228
  controller.run( /*#__PURE__*/function () {
12210
12229
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(s) {
12211
- var _s$goodsListState$dra, container, current, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
12230
+ var _s$goodsListState$dra, container, current, site, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
12212
12231
 
12213
12232
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
12214
12233
  while (1) {
12215
12234
  switch (_context4.prev = _context4.next) {
12216
12235
  case 0:
12217
- _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current;
12236
+ _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current, site = _s$goodsListState$dra.site;
12218
12237
 
12219
12238
  if (!(!container || !current)) {
12220
12239
  _context4.next = 3;
@@ -12247,9 +12266,11 @@ function Drag$1(props) {
12247
12266
  var g = s.goodsListState.goodsList.filter(function (e) {
12248
12267
  return moveGoods.indexOf(e.$index) < 0;
12249
12268
  });
12250
- var t = g.map(function (e) {
12269
+ var t = site === 'u' ? g.map(function (e) {
12270
+ return e.$index;
12271
+ }).indexOf(container) : g.map(function (e) {
12251
12272
  return e.$index;
12252
- }).indexOf(container);
12273
+ }).indexOf(container) + 1;
12253
12274
  var m = moveGoods.map(function (e) {
12254
12275
  return goodsMap.get(e);
12255
12276
  }).filter(function (e) {
@@ -13843,7 +13864,7 @@ var useRowSelection = (function () {
13843
13864
  case 0:
13844
13865
  s.goodsListState.selectedGoodIndex.forEach(function ($index) {
13845
13866
  var goods = s.goodsListState.goodsMap.get($index);
13846
- if (!goods || goods.lineAttribute === LineAttributeType$1.正常) return; // 数组位置
13867
+ if (!goods || goods.lineAttribute !== LineAttributeType$1.折扣行 && goods.lineAttribute !== LineAttributeType$1.被折扣行) return; // 数组位置
13847
13868
 
13848
13869
  var t = s.goodsListState.goodsList.indexOf(goods);
13849
13870
  goods.lineAttribute === LineAttributeType$1.折扣行 ? t-- : t++;
@@ -13900,9 +13921,9 @@ styleInject(css_248z$a);
13900
13921
  var keys$1 = {};
13901
13922
  /**
13902
13923
  * 有冷却时间的函数
13903
- * @param fn 方法
13904
13924
  * @param key 方法key
13905
13925
  * @param delayed 冷却时间
13926
+ * @param fn 方法
13906
13927
  */
13907
13928
 
13908
13929
  var coolingFn = (function () {
@@ -13978,10 +13999,25 @@ var useEndowCodeButton = (function () {
13978
13999
  return _context.abrupt("return");
13979
14000
 
13980
14001
  case 6:
14002
+ if (!(s.goodsListState.selectedGoodIndex.map(function (e) {
14003
+ return s.goodsListState.goodsMap.get(e);
14004
+ }).every(function (e) {
14005
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
14006
+ }) === false)) {
14007
+ _context.next = 9;
14008
+ break;
14009
+ }
14010
+
14011
+ coolingFn('折让行不能赋码', 3000, function () {
14012
+ ktsComponentsAntdX3.message.error('折让行不能赋码');
14013
+ });
14014
+ return _context.abrupt("return");
14015
+
14016
+ case 9:
13981
14017
  // 设置赋码
13982
14018
  s.goodsListState.endowCode.endowcodeGoodIndex = s.goodsListState.selectedGoodIndex;
13983
14019
 
13984
- case 7:
14020
+ case 10:
13985
14021
  case "end":
13986
14022
  return _context.stop();
13987
14023
  }
@@ -14597,6 +14633,184 @@ function useMergeDiscount() {
14597
14633
  };
14598
14634
  }
14599
14635
 
14636
+ /** 销售折让 */
14637
+
14638
+ function uaeSalesDiscount() {
14639
+ var controller = Invoice.useInvoiceController();
14640
+ var selectedGoodIndex = controller.useMemo(function (s) {
14641
+ return s.goodsListState.selectedGoodIndex;
14642
+ }, []);
14643
+ var goodsMap = controller.useMemo(function (s) {
14644
+ return s.goodsListState.goodsMap;
14645
+ }, []);
14646
+ var isSalesDiscount = controller.useMemo(function (s) {
14647
+ return s.goodsListState.isSalesDiscount;
14648
+ }, []);
14649
+ var onClick = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
14650
+ var selectedGood, concession, content, discountGood, totalDiscoline, discolinesSum, totalAmount, discolines, surplus, i;
14651
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
14652
+ while (1) {
14653
+ switch (_context3.prev = _context3.next) {
14654
+ case 0:
14655
+ selectedGood = selectedGoodIndex.map(function (e) {
14656
+ return goodsMap.get(e);
14657
+ });
14658
+ /** 折让行 */
14659
+
14660
+ concession = selectedGood.filter(function (e) {
14661
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折让行;
14662
+ })[0];
14663
+
14664
+ if (concession) {
14665
+ _context3.next = 6;
14666
+ break;
14667
+ }
14668
+
14669
+ content = '未选择折让行';
14670
+ ktsComponentsAntdX3.message.error({
14671
+ content: content,
14672
+ key: content
14673
+ });
14674
+ return _context3.abrupt("return");
14675
+
14676
+ case 6:
14677
+ /** 准备添加折扣的货物列表 */
14678
+ discountGood = selectedGood.filter(function (e) {
14679
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
14680
+ });
14681
+ /** 折扣总金额 */
14682
+
14683
+ totalDiscoline = mathjs.chain(mathjs.bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
14684
+ discolinesSum = mathjs.chain(mathjs.bignumber(0));
14685
+ /** 总金额 */
14686
+
14687
+ totalAmount = function () {
14688
+ var sum = 0;
14689
+ discountGood.forEach(function (e) {
14690
+ var _e$lineAmountIncludeT;
14691
+
14692
+ sum += (_e$lineAmountIncludeT = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT !== void 0 ? _e$lineAmountIncludeT : 0;
14693
+ });
14694
+ return sum;
14695
+ }(); // 每行的折扣金额
14696
+
14697
+
14698
+ discolines = discountGood.map(function (e, i) {
14699
+ var _e$lineAmountIncludeT2;
14700
+
14701
+ // 折扣金额占比
14702
+ var share = mathjs.chain(mathjs.bignumber((_e$lineAmountIncludeT2 = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT2 !== void 0 ? _e$lineAmountIncludeT2 : 0)).divide(mathjs.bignumber(totalAmount)); // 折扣金额
14703
+
14704
+ var value = totalDiscoline.multiply(share.done()).multiply(mathjs.bignumber(100)).round().divide(mathjs.bignumber(100)).done();
14705
+ discolinesSum = discolinesSum.add(value);
14706
+ return value.toNumber();
14707
+ }); // 剩余折扣金额
14708
+
14709
+ surplus = totalDiscoline.subtract(discolinesSum.done()); // 补充剩余折扣金
14710
+
14711
+ i = 0;
14712
+
14713
+ case 13:
14714
+ if (!(i < discolines.length)) {
14715
+ _context3.next = 21;
14716
+ break;
14717
+ }
14718
+
14719
+ if (!surplus.smaller(0.01).done()) {
14720
+ _context3.next = 16;
14721
+ break;
14722
+ }
14723
+
14724
+ return _context3.abrupt("break", 21);
14725
+
14726
+ case 16:
14727
+ discolines[i] = mathjs.chain(mathjs.bignumber(discolines[i])).add(mathjs.bignumber(0.01)).done().toNumber();
14728
+ surplus = surplus.subtract(mathjs.bignumber(0.01));
14729
+
14730
+ case 18:
14731
+ i++;
14732
+ _context3.next = 13;
14733
+ break;
14734
+
14735
+ case 21:
14736
+ _context3.next = 23;
14737
+ return controller.run( /*#__PURE__*/function () {
14738
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
14739
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14740
+ while (1) {
14741
+ switch (_context.prev = _context.next) {
14742
+ case 0:
14743
+ s.goodsListState.goodsList = s.goodsListState.goodsList.filter(function (e) {
14744
+ return e.$index !== concession.$index;
14745
+ });
14746
+
14747
+ case 1:
14748
+ case "end":
14749
+ return _context.stop();
14750
+ }
14751
+ }
14752
+ }, _callee);
14753
+ }));
14754
+
14755
+ return function (_x) {
14756
+ return _ref2.apply(this, arguments);
14757
+ };
14758
+ }());
14759
+
14760
+ case 23:
14761
+ _context3.next = 25;
14762
+ return controller.run( /*#__PURE__*/function () {
14763
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
14764
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14765
+ while (1) {
14766
+ switch (_context2.prev = _context2.next) {
14767
+ case 0:
14768
+ s.goodsListState.selectedGoodIndex = [];
14769
+
14770
+ case 1:
14771
+ case "end":
14772
+ return _context2.stop();
14773
+ }
14774
+ }
14775
+ }, _callee2);
14776
+ }));
14777
+
14778
+ return function (_x2) {
14779
+ return _ref3.apply(this, arguments);
14780
+ };
14781
+ }());
14782
+
14783
+ case 25:
14784
+ _context3.next = 27;
14785
+ return controller.addGoodDiscountV2(discolines.map(function (e, i) {
14786
+ var _discountGood$i;
14787
+
14788
+ return {
14789
+ $index: (_discountGood$i = discountGood[i]) === null || _discountGood$i === void 0 ? void 0 : _discountGood$i.$index,
14790
+ discolineAmountunt: e
14791
+ };
14792
+ }));
14793
+
14794
+ case 27:
14795
+ case "end":
14796
+ return _context3.stop();
14797
+ }
14798
+ }
14799
+ }, _callee3);
14800
+ })), [controller, selectedGoodIndex, goodsMap]);
14801
+ var button = React__default['default'].useMemo(function () {
14802
+ if (!isSalesDiscount) return React__default['default'].createElement(React__default['default'].Fragment, null);
14803
+ return React__default['default'].createElement(ktsComponentsAntdX3.Button, {
14804
+ onClick: onClick,
14805
+ disabled: selectedGoodIndex.length <= 1
14806
+ }, "\u9500\u552E\u6298\u8BA9");
14807
+ }, [selectedGoodIndex.length, isSalesDiscount]);
14808
+ return {
14809
+ /** 按钮 */
14810
+ button: button
14811
+ };
14812
+ }
14813
+
14600
14814
  var GoodsList = /*#__PURE__*/function (_React$Component) {
14601
14815
  _inherits(GoodsList, _React$Component);
14602
14816
 
@@ -14659,6 +14873,9 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
14659
14873
  /** 全单合并折扣 */
14660
14874
 
14661
14875
  var mergeDiscount = useMergeDiscount();
14876
+ /** 销售折让 */
14877
+
14878
+ var salesDiscount = uaeSalesDiscount();
14662
14879
  /** 清空自动赋码缓存 */
14663
14880
 
14664
14881
  React__default['default'].useEffect(function () {
@@ -14816,7 +15033,7 @@ var Main = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(function (p
14816
15033
  className: "kts-invoice-operate-goods-list-able"
14817
15034
  }, React__default['default'].createElement("div", {
14818
15035
  className: "kts-invoice-operate-goods-list-able-list"
14819
- }, 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", {
15036
+ }, 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", {
14820
15037
  className: "kts-invoice-operate-goods-list-able-extend"
14821
15038
  }, props.menuExpansion, React__default['default'].createElement(DescribeSwitch, null), React__default['default'].createElement(TaxIncludedSwitch, null))), React__default['default'].createElement("div", {
14822
15039
  className: classNames__default['default']('kts-invoice-operate-goods-list-table', {
@@ -16759,7 +16976,7 @@ function Search$1() {
16759
16976
  });
16760
16977
  }
16761
16978
 
16762
- var css_248z$l = ".kts-invoice-operate-goods-list-itemName-drag-container {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n top: 0;\n z-index: 9999;\n}\n";
16979
+ var css_248z$l = ".kts-invoice-operate-goods-list-itemName-drag-container-u {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-u::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n top: 0;\n z-index: 9999;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d {\n position: relative;\n}\n.kts-invoice-operate-goods-list-itemName-drag-container-d::after {\n content: \" \";\n width: 100%;\n height: 2px;\n background: #0074ff;\n position: absolute;\n left: 0;\n bottom: 0;\n z-index: 9999;\n}\n";
16763
16980
  styleInject(css_248z$l);
16764
16981
 
16765
16982
  function TableRow$1(props) {
@@ -16768,6 +16985,11 @@ function TableRow$1(props) {
16768
16985
  var goodsMap = controller.useMemo(function (s) {
16769
16986
  return s.goodsListState.goodsMap;
16770
16987
  }, []);
16988
+ /** 当前拖动中的货品索引 */
16989
+
16990
+ var site = controller.useMemo(function (s) {
16991
+ return s.goodsListState.drag.site;
16992
+ }, []);
16771
16993
  var current = controller.useMemo(function (s) {
16772
16994
  return s.goodsListState.drag.current;
16773
16995
  }, []);
@@ -16799,8 +17021,9 @@ function TableRow$1(props) {
16799
17021
  position: 'absolute',
16800
17022
  bottom: 0
16801
17023
  }
16802
- })) : React__default['default'].createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
16803
- className: classNames__default['default'](props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')
17024
+ })) : // <tr {...props} className={classnames(props.className, discount, (rowKey === container && current) ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')} />
17025
+ React__default['default'].createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
17026
+ className: classNames__default['default'](props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site : undefined)
16804
17027
  }));
16805
17028
  }
16806
17029
 
@@ -17995,6 +18218,12 @@ styleInject(css_248z$n);
17995
18218
 
17996
18219
  function Drag$2(props) {
17997
18220
  var record = props.record;
18221
+
18222
+ var _React$useState = React__default['default'].useState(false),
18223
+ _React$useState2 = _slicedToArray(_React$useState, 2),
18224
+ open = _React$useState2[0],
18225
+ setOpen = _React$useState2[1];
18226
+
17998
18227
  var controller = Invoice.useInvoiceController();
17999
18228
  var editGood = controller.useMemo(function (s) {
18000
18229
  return s.goodsListState.editGood;
@@ -18003,7 +18232,7 @@ function Drag$2(props) {
18003
18232
  return !!editGood;
18004
18233
  }, [editGood]);
18005
18234
  var onMouseDown = React__default['default'].useCallback(function () {
18006
- if (!controller || !record) return;
18235
+ if (!controller || !record || disabled) return;
18007
18236
  controller.run( /*#__PURE__*/function () {
18008
18237
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
18009
18238
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -18028,64 +18257,57 @@ function Drag$2(props) {
18028
18257
  var currentGood = controller.state.goodsListState.goodsList.filter(function (e) {
18029
18258
  return e.$index === record.$index;
18030
18259
  })[0];
18031
- mounting(React__default['default'].createElement(DragDiv$1, _objectSpread2({}, currentGood))); // 监听移动
18032
-
18260
+ mounting(React__default['default'].createElement(DragDiv$1, _objectSpread2({}, currentGood)));
18033
18261
  rowList.forEach(function (e) {
18034
- e.addEventListener('mouseover', onMouseover);
18262
+ e.addEventListener('mousemove', onMousemove);
18035
18263
  });
18036
18264
 
18037
- function onMouseover(e) {
18265
+ function onMousemove(e) {
18038
18266
  controller.run( /*#__PURE__*/function () {
18039
18267
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
18040
- var _getRow, _getRow$dataset;
18268
+ var _rowDom$dataset;
18041
18269
 
18042
- var container, currentGood, row, currentIndex, containerIndex, _currentIndex, _containerIndex, t;
18270
+ var rowDom, container, row, currentGood, currentIndex, containerIndex, _currentIndex, _containerIndex, t, rect, mouseY;
18043
18271
 
18044
18272
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
18045
18273
  while (1) {
18046
18274
  switch (_context2.prev = _context2.next) {
18047
18275
  case 0:
18048
- container = s.goodsListState.drag.container = (_getRow = getRow(e.target)) === null || _getRow === void 0 ? void 0 : (_getRow$dataset = _getRow.dataset) === null || _getRow$dataset === void 0 ? void 0 : _getRow$dataset.rowKey;
18276
+ rowDom = getRow(e.target);
18277
+ container = s.goodsListState.drag.container = rowDom === null || rowDom === void 0 ? void 0 : (_rowDom$dataset = rowDom.dataset) === null || _rowDom$dataset === void 0 ? void 0 : _rowDom$dataset.rowKey;
18278
+ /** 准备插入的货物 */
18279
+
18280
+ row = s.goodsListState.goodsMap.get(container);
18049
18281
 
18050
- if (container) {
18051
- _context2.next = 3;
18282
+ if (row) {
18283
+ _context2.next = 5;
18052
18284
  break;
18053
18285
  }
18054
18286
 
18055
18287
  return _context2.abrupt("return");
18056
18288
 
18057
- case 3:
18289
+ case 5:
18058
18290
  if (!(container === s.goodsListState.drag.current)) {
18059
- _context2.next = 6;
18291
+ _context2.next = 7;
18060
18292
  break;
18061
18293
  }
18062
18294
 
18063
- s.goodsListState.drag.container = undefined;
18064
- return _context2.abrupt("return");
18295
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
18065
18296
 
18066
- case 6:
18297
+ case 7:
18298
+ /** 当前拖动中的货品 */
18067
18299
  currentGood = s.goodsListState.drag.current && s.goodsListState.goodsMap.get(s.goodsListState.drag.current);
18068
18300
 
18069
18301
  if (currentGood) {
18070
- _context2.next = 9;
18302
+ _context2.next = 10;
18071
18303
  break;
18072
18304
  }
18073
18305
 
18074
18306
  return _context2.abrupt("return");
18075
18307
 
18076
- case 9:
18077
- row = s.goodsListState.goodsMap.get(container);
18078
-
18079
- if (row) {
18080
- _context2.next = 12;
18081
- break;
18082
- }
18083
-
18084
- return _context2.abrupt("return");
18085
-
18086
- case 12:
18308
+ case 10:
18087
18309
  if (!(currentGood.lineAttribute === LineAttributeType$1.折扣行)) {
18088
- _context2.next = 18;
18310
+ _context2.next = 15;
18089
18311
  break;
18090
18312
  }
18091
18313
 
@@ -18097,16 +18319,15 @@ function Drag$2(props) {
18097
18319
  }).indexOf(row.$index);
18098
18320
 
18099
18321
  if (!(currentIndex - 1 === containerIndex)) {
18100
- _context2.next = 18;
18322
+ _context2.next = 15;
18101
18323
  break;
18102
18324
  }
18103
18325
 
18104
- s.goodsListState.drag.container = undefined;
18105
- return _context2.abrupt("return");
18326
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
18106
18327
 
18107
- case 18:
18328
+ case 15:
18108
18329
  if (!(currentGood.lineAttribute === LineAttributeType$1.被折扣行)) {
18109
- _context2.next = 24;
18330
+ _context2.next = 20;
18110
18331
  break;
18111
18332
  }
18112
18333
 
@@ -18118,23 +18339,29 @@ function Drag$2(props) {
18118
18339
  }).indexOf(row.$index);
18119
18340
 
18120
18341
  if (!(_currentIndex + 1 === _containerIndex)) {
18121
- _context2.next = 24;
18342
+ _context2.next = 20;
18122
18343
  break;
18123
18344
  }
18124
18345
 
18125
- s.goodsListState.drag.container = undefined;
18126
- return _context2.abrupt("return");
18346
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
18127
18347
 
18128
- case 24:
18348
+ case 20:
18129
18349
  // 折扣行 拖动的 相当于 自己的 被折扣行
18130
18350
  if (row.lineAttribute === LineAttributeType$1.折扣行) {
18131
18351
  t = s.goodsListState.goodsList.map(function (e) {
18132
18352
  return e.$index;
18133
18353
  }).indexOf(container) - 1;
18134
18354
  s.goodsListState.drag.container = s.goodsListState.goodsList[t].$index;
18355
+ s.goodsListState.drag.site = 'u';
18356
+ } else if (row.lineAttribute === LineAttributeType$1.被折扣行) {
18357
+ s.goodsListState.drag.site = 'd';
18358
+ } else {
18359
+ rect = rowDom.getBoundingClientRect();
18360
+ mouseY = e.clientY - rect.top;
18361
+ s.goodsListState.drag.site = mouseY > 25 ? 'd' : 'u';
18135
18362
  }
18136
18363
 
18137
- case 25:
18364
+ case 21:
18138
18365
  case "end":
18139
18366
  return _context2.stop();
18140
18367
  }
@@ -18187,7 +18414,7 @@ function Drag$2(props) {
18187
18414
  }());
18188
18415
  window.removeEventListener('mouseup', onMouseup);
18189
18416
  rowList.forEach(function (e) {
18190
- e.removeEventListener('mouseover', onMouseover);
18417
+ e.removeEventListener('mousemove', onMousemove);
18191
18418
  }); // window.document.body.removeChild(rowDiv);
18192
18419
  } // 开始插入
18193
18420
 
@@ -18196,13 +18423,13 @@ function Drag$2(props) {
18196
18423
  mounting(React__default['default'].createElement(React__default['default'].Fragment, null));
18197
18424
  controller.run( /*#__PURE__*/function () {
18198
18425
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(s) {
18199
- var _s$goodsListState$dra, container, current, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
18426
+ var _s$goodsListState$dra, container, current, site, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
18200
18427
 
18201
18428
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
18202
18429
  while (1) {
18203
18430
  switch (_context4.prev = _context4.next) {
18204
18431
  case 0:
18205
- _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current;
18432
+ _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current, site = _s$goodsListState$dra.site;
18206
18433
 
18207
18434
  if (!(!container || !current)) {
18208
18435
  _context4.next = 3;
@@ -18235,9 +18462,11 @@ function Drag$2(props) {
18235
18462
  var g = s.goodsListState.goodsList.filter(function (e) {
18236
18463
  return moveGoods.indexOf(e.$index) < 0;
18237
18464
  });
18238
- var t = g.map(function (e) {
18465
+ var t = site === 'u' ? g.map(function (e) {
18466
+ return e.$index;
18467
+ }).indexOf(container) : g.map(function (e) {
18239
18468
  return e.$index;
18240
- }).indexOf(container);
18469
+ }).indexOf(container) + 1;
18241
18470
  var m = moveGoods.map(function (e) {
18242
18471
  return goodsMap.get(e);
18243
18472
  }).filter(function (e) {
@@ -18268,33 +18497,44 @@ function Drag$2(props) {
18268
18497
  };
18269
18498
  }());
18270
18499
  }
18271
- }, [controller, record]);
18272
- return React__default['default'].createElement(ktsComponentsAntdX3.Button, {
18273
- type: 'link',
18274
- style: {
18275
- padding: 0
18276
- },
18277
- disabled: disabled,
18278
- onMouseDown: onMouseDown,
18279
- onClick: function onClick(e) {
18280
- e.stopPropagation();
18281
- },
18282
- className: "kts-invoice-operate-goods-list-itemName-drag"
18283
- }, React__default['default'].createElement(Icon, {
18284
- component: SvgI001$1
18285
- }));
18500
+ }, [controller, record, disabled]);
18501
+ var renderButton = React__default['default'].useMemo(function () {
18502
+ return React__default['default'].createElement(ktsComponentsAntdX3.Button, {
18503
+ type: 'link',
18504
+ style: {
18505
+ padding: 0
18506
+ },
18507
+ onMouseDown: onMouseDown,
18508
+ onClick: function onClick(e) {
18509
+ e.stopPropagation();
18510
+ },
18511
+ className: "kts-invoice-operate-goods-list-itemName-drag",
18512
+ onMouseOver: controller.saveEditGood
18513
+ }, React__default['default'].createElement(Icon, {
18514
+ component: SvgI001$1
18515
+ }));
18516
+ }, [onMouseDown, controller]);
18517
+
18518
+ if (disabled) {
18519
+ return React__default['default'].createElement(ktsXui.Popover, {
18520
+ content: '您还有未编辑完成的商品',
18521
+ trigger: 'focus'
18522
+ }, renderButton);
18523
+ } else {
18524
+ return renderButton;
18525
+ }
18286
18526
  }
18287
18527
 
18288
18528
  function DragDiv$1(props) {
18289
- var _React$useState = React__default['default'].useState(0),
18290
- _React$useState2 = _slicedToArray(_React$useState, 2),
18291
- x = _React$useState2[0],
18292
- setX = _React$useState2[1];
18293
-
18294
- var _React$useState3 = React__default['default'].useState(-110),
18529
+ var _React$useState3 = React__default['default'].useState(0),
18295
18530
  _React$useState4 = _slicedToArray(_React$useState3, 2),
18296
- y = _React$useState4[0],
18297
- setY = _React$useState4[1];
18531
+ x = _React$useState4[0],
18532
+ setX = _React$useState4[1];
18533
+
18534
+ var _React$useState5 = React__default['default'].useState(-110),
18535
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
18536
+ y = _React$useState6[0],
18537
+ setY = _React$useState6[1];
18298
18538
 
18299
18539
  var div = React__default['default'].useMemo(function () {
18300
18540
  return window.document.querySelector("[data-row-key=\"".concat(props.$index, "\"]"));
@@ -18309,7 +18549,7 @@ function DragDiv$1(props) {
18309
18549
 
18310
18550
  React__default['default'].useEffect(function () {
18311
18551
  function onMousemove(e) {
18312
- setY(e.clientY - 25);
18552
+ setY(e.clientY - 15);
18313
18553
  }
18314
18554
  window.addEventListener('mousemove', onMousemove);
18315
18555
  return function () {