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.esm.js CHANGED
@@ -916,6 +916,7 @@ var LineAttributeType;
916
916
  LineAttributeType[LineAttributeType["\u6B63\u5E38"] = 0] = "\u6B63\u5E38";
917
917
  LineAttributeType[LineAttributeType["\u6298\u6263\u884C"] = 1] = "\u6298\u6263\u884C";
918
918
  LineAttributeType[LineAttributeType["\u88AB\u6298\u6263\u884C"] = 2] = "\u88AB\u6298\u6263\u884C";
919
+ LineAttributeType[LineAttributeType["\u6298\u8BA9\u884C"] = 3] = "\u6298\u8BA9\u884C";
919
920
  })(LineAttributeType || (LineAttributeType = {}));
920
921
 
921
922
  var LineAttributeType$1 = LineAttributeType;
@@ -993,6 +994,7 @@ var Drag = /*#__PURE__*/_createClass(function Drag() {
993
994
  this.isStart = false;
994
995
  this.current = void 0;
995
996
  this.container = void 0;
997
+ this.site = void 0;
996
998
  });
997
999
 
998
1000
  var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
@@ -1028,6 +1030,7 @@ var GoodsListState = /*#__PURE__*/_createClass(function GoodsListState() {
1028
1030
  this.isVisibleDrawer = false;
1029
1031
  this.isMergeDetails = false;
1030
1032
  this.isMergeDiscount = false;
1033
+ this.isSalesDiscount = false;
1031
1034
  this.addComparisonIndex = void 0;
1032
1035
  this.drag = new Drag();
1033
1036
  });
@@ -10163,7 +10166,7 @@ function Search() {
10163
10166
  });
10164
10167
  }
10165
10168
 
10166
- 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";
10169
+ 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";
10167
10170
  styleInject(css_248z$5);
10168
10171
 
10169
10172
  function TableRow(props) {
@@ -10172,9 +10175,18 @@ function TableRow(props) {
10172
10175
  var goodsMap = controller.useMemo(function (s) {
10173
10176
  return s.goodsListState.goodsMap;
10174
10177
  }, []);
10178
+ /** 当前拖动中的货品索引 */
10179
+
10175
10180
  var current = controller.useMemo(function (s) {
10176
10181
  return s.goodsListState.drag.current;
10177
10182
  }, []);
10183
+ /** 当前拖动中的货品索引 */
10184
+
10185
+ var site = controller.useMemo(function (s) {
10186
+ return s.goodsListState.drag.site;
10187
+ }, []);
10188
+ /** 准备插入的货物索引 */
10189
+
10178
10190
  var container = controller.useMemo(function (s) {
10179
10191
  return s.goodsListState.drag.container;
10180
10192
  }, []);
@@ -10208,7 +10220,7 @@ function TableRow(props) {
10208
10220
  bottom: 0
10209
10221
  }
10210
10222
  })) : React.createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
10211
- className: classNames(props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container' : undefined)
10223
+ className: classNames(props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site : undefined)
10212
10224
  }));
10213
10225
  }
10214
10226
 
@@ -10238,6 +10250,10 @@ var useDelItem = (function (goods) {
10238
10250
  controller.delGood(goods.$index);
10239
10251
  }, [controller, goods.$index]);
10240
10252
 
10253
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10254
+ return undefined;
10255
+ }
10256
+
10241
10257
  if (goods.lineAttribute === LineAttributeType$1.被折扣行) {
10242
10258
  return undefined;
10243
10259
  }
@@ -10425,6 +10441,11 @@ var useEndowCode = (function (goods) {
10425
10441
  }
10426
10442
  }, _callee);
10427
10443
  })), [controller, goods]);
10444
+
10445
+ if (goods.lineAttribute === LineAttributeType$1.折让行) {
10446
+ return undefined;
10447
+ }
10448
+
10428
10449
  return {
10429
10450
  key: 'endowCode',
10430
10451
  title: '赋码',
@@ -12030,64 +12051,57 @@ function Drag$1(props) {
12030
12051
  var currentGood = controller.state.goodsListState.goodsList.filter(function (e) {
12031
12052
  return e.$index === record.$index;
12032
12053
  })[0];
12033
- mounting(React.createElement(DragDiv, _objectSpread2({}, currentGood))); // 监听移动
12034
-
12054
+ mounting(React.createElement(DragDiv, _objectSpread2({}, currentGood)));
12035
12055
  rowList.forEach(function (e) {
12036
- e.addEventListener('mouseover', onMouseover);
12056
+ e.addEventListener('mousemove', onMousemove);
12037
12057
  });
12038
12058
 
12039
- function onMouseover(e) {
12059
+ function onMousemove(e) {
12040
12060
  controller.run( /*#__PURE__*/function () {
12041
12061
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
12042
- var _getRow, _getRow$dataset;
12062
+ var _rowDom$dataset;
12043
12063
 
12044
- var container, currentGood, row, currentIndex, containerIndex, _currentIndex, _containerIndex, t;
12064
+ var rowDom, container, row, currentGood, currentIndex, containerIndex, _currentIndex, _containerIndex, t, rect, mouseY;
12045
12065
 
12046
12066
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12047
12067
  while (1) {
12048
12068
  switch (_context2.prev = _context2.next) {
12049
12069
  case 0:
12050
- 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;
12070
+ rowDom = getRow(e.target);
12071
+ 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;
12072
+ /** 准备插入的货物 */
12051
12073
 
12052
- if (container) {
12053
- _context2.next = 3;
12074
+ row = s.goodsListState.goodsMap.get(container);
12075
+
12076
+ if (row) {
12077
+ _context2.next = 5;
12054
12078
  break;
12055
12079
  }
12056
12080
 
12057
12081
  return _context2.abrupt("return");
12058
12082
 
12059
- case 3:
12083
+ case 5:
12060
12084
  if (!(container === s.goodsListState.drag.current)) {
12061
- _context2.next = 6;
12085
+ _context2.next = 7;
12062
12086
  break;
12063
12087
  }
12064
12088
 
12065
- s.goodsListState.drag.container = undefined;
12066
- return _context2.abrupt("return");
12089
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
12067
12090
 
12068
- case 6:
12091
+ case 7:
12092
+ /** 当前拖动中的货品 */
12069
12093
  currentGood = s.goodsListState.drag.current && s.goodsListState.goodsMap.get(s.goodsListState.drag.current);
12070
12094
 
12071
12095
  if (currentGood) {
12072
- _context2.next = 9;
12096
+ _context2.next = 10;
12073
12097
  break;
12074
12098
  }
12075
12099
 
12076
12100
  return _context2.abrupt("return");
12077
12101
 
12078
- case 9:
12079
- row = s.goodsListState.goodsMap.get(container);
12080
-
12081
- if (row) {
12082
- _context2.next = 12;
12083
- break;
12084
- }
12085
-
12086
- return _context2.abrupt("return");
12087
-
12088
- case 12:
12102
+ case 10:
12089
12103
  if (!(currentGood.lineAttribute === LineAttributeType$1.折扣行)) {
12090
- _context2.next = 18;
12104
+ _context2.next = 15;
12091
12105
  break;
12092
12106
  }
12093
12107
 
@@ -12099,16 +12113,15 @@ function Drag$1(props) {
12099
12113
  }).indexOf(row.$index);
12100
12114
 
12101
12115
  if (!(currentIndex - 1 === containerIndex)) {
12102
- _context2.next = 18;
12116
+ _context2.next = 15;
12103
12117
  break;
12104
12118
  }
12105
12119
 
12106
- s.goodsListState.drag.container = undefined;
12107
- return _context2.abrupt("return");
12120
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
12108
12121
 
12109
- case 18:
12122
+ case 15:
12110
12123
  if (!(currentGood.lineAttribute === LineAttributeType$1.被折扣行)) {
12111
- _context2.next = 24;
12124
+ _context2.next = 20;
12112
12125
  break;
12113
12126
  }
12114
12127
 
@@ -12120,23 +12133,29 @@ function Drag$1(props) {
12120
12133
  }).indexOf(row.$index);
12121
12134
 
12122
12135
  if (!(_currentIndex + 1 === _containerIndex)) {
12123
- _context2.next = 24;
12136
+ _context2.next = 20;
12124
12137
  break;
12125
12138
  }
12126
12139
 
12127
- s.goodsListState.drag.container = undefined;
12128
- return _context2.abrupt("return");
12140
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
12129
12141
 
12130
- case 24:
12142
+ case 20:
12131
12143
  // 折扣行 拖动的 相当于 自己的 被折扣行
12132
12144
  if (row.lineAttribute === LineAttributeType$1.折扣行) {
12133
12145
  t = s.goodsListState.goodsList.map(function (e) {
12134
12146
  return e.$index;
12135
12147
  }).indexOf(container) - 1;
12136
12148
  s.goodsListState.drag.container = s.goodsListState.goodsList[t].$index;
12149
+ s.goodsListState.drag.site = 'u';
12150
+ } else if (row.lineAttribute === LineAttributeType$1.被折扣行) {
12151
+ s.goodsListState.drag.site = 'd';
12152
+ } else {
12153
+ rect = rowDom.getBoundingClientRect();
12154
+ mouseY = e.clientY - rect.top;
12155
+ s.goodsListState.drag.site = mouseY > 15 ? 'd' : 'u';
12137
12156
  }
12138
12157
 
12139
- case 25:
12158
+ case 21:
12140
12159
  case "end":
12141
12160
  return _context2.stop();
12142
12161
  }
@@ -12189,7 +12208,7 @@ function Drag$1(props) {
12189
12208
  }());
12190
12209
  window.removeEventListener('mouseup', onMouseup);
12191
12210
  rowList.forEach(function (e) {
12192
- e.removeEventListener('mouseover', onMouseover);
12211
+ e.removeEventListener('mousemove', onMousemove);
12193
12212
  }); // window.document.body.removeChild(rowDiv);
12194
12213
  } // 开始插入
12195
12214
 
@@ -12198,13 +12217,13 @@ function Drag$1(props) {
12198
12217
  mounting(React.createElement(React.Fragment, null));
12199
12218
  controller.run( /*#__PURE__*/function () {
12200
12219
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(s) {
12201
- var _s$goodsListState$dra, container, current, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
12220
+ var _s$goodsListState$dra, container, current, site, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
12202
12221
 
12203
12222
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
12204
12223
  while (1) {
12205
12224
  switch (_context4.prev = _context4.next) {
12206
12225
  case 0:
12207
- _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current;
12226
+ _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current, site = _s$goodsListState$dra.site;
12208
12227
 
12209
12228
  if (!(!container || !current)) {
12210
12229
  _context4.next = 3;
@@ -12237,9 +12256,11 @@ function Drag$1(props) {
12237
12256
  var g = s.goodsListState.goodsList.filter(function (e) {
12238
12257
  return moveGoods.indexOf(e.$index) < 0;
12239
12258
  });
12240
- var t = g.map(function (e) {
12259
+ var t = site === 'u' ? g.map(function (e) {
12260
+ return e.$index;
12261
+ }).indexOf(container) : g.map(function (e) {
12241
12262
  return e.$index;
12242
- }).indexOf(container);
12263
+ }).indexOf(container) + 1;
12243
12264
  var m = moveGoods.map(function (e) {
12244
12265
  return goodsMap.get(e);
12245
12266
  }).filter(function (e) {
@@ -13833,7 +13854,7 @@ var useRowSelection = (function () {
13833
13854
  case 0:
13834
13855
  s.goodsListState.selectedGoodIndex.forEach(function ($index) {
13835
13856
  var goods = s.goodsListState.goodsMap.get($index);
13836
- if (!goods || goods.lineAttribute === LineAttributeType$1.正常) return; // 数组位置
13857
+ if (!goods || goods.lineAttribute !== LineAttributeType$1.折扣行 && goods.lineAttribute !== LineAttributeType$1.被折扣行) return; // 数组位置
13837
13858
 
13838
13859
  var t = s.goodsListState.goodsList.indexOf(goods);
13839
13860
  goods.lineAttribute === LineAttributeType$1.折扣行 ? t-- : t++;
@@ -13890,9 +13911,9 @@ styleInject(css_248z$a);
13890
13911
  var keys$1 = {};
13891
13912
  /**
13892
13913
  * 有冷却时间的函数
13893
- * @param fn 方法
13894
13914
  * @param key 方法key
13895
13915
  * @param delayed 冷却时间
13916
+ * @param fn 方法
13896
13917
  */
13897
13918
 
13898
13919
  var coolingFn = (function () {
@@ -13968,10 +13989,25 @@ var useEndowCodeButton = (function () {
13968
13989
  return _context.abrupt("return");
13969
13990
 
13970
13991
  case 6:
13992
+ if (!(s.goodsListState.selectedGoodIndex.map(function (e) {
13993
+ return s.goodsListState.goodsMap.get(e);
13994
+ }).every(function (e) {
13995
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
13996
+ }) === false)) {
13997
+ _context.next = 9;
13998
+ break;
13999
+ }
14000
+
14001
+ coolingFn('折让行不能赋码', 3000, function () {
14002
+ message.error('折让行不能赋码');
14003
+ });
14004
+ return _context.abrupt("return");
14005
+
14006
+ case 9:
13971
14007
  // 设置赋码
13972
14008
  s.goodsListState.endowCode.endowcodeGoodIndex = s.goodsListState.selectedGoodIndex;
13973
14009
 
13974
- case 7:
14010
+ case 10:
13975
14011
  case "end":
13976
14012
  return _context.stop();
13977
14013
  }
@@ -14587,6 +14623,184 @@ function useMergeDiscount() {
14587
14623
  };
14588
14624
  }
14589
14625
 
14626
+ /** 销售折让 */
14627
+
14628
+ function uaeSalesDiscount() {
14629
+ var controller = Invoice.useInvoiceController();
14630
+ var selectedGoodIndex = controller.useMemo(function (s) {
14631
+ return s.goodsListState.selectedGoodIndex;
14632
+ }, []);
14633
+ var goodsMap = controller.useMemo(function (s) {
14634
+ return s.goodsListState.goodsMap;
14635
+ }, []);
14636
+ var isSalesDiscount = controller.useMemo(function (s) {
14637
+ return s.goodsListState.isSalesDiscount;
14638
+ }, []);
14639
+ var onClick = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
14640
+ var selectedGood, concession, content, discountGood, totalDiscoline, discolinesSum, totalAmount, discolines, surplus, i;
14641
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
14642
+ while (1) {
14643
+ switch (_context3.prev = _context3.next) {
14644
+ case 0:
14645
+ selectedGood = selectedGoodIndex.map(function (e) {
14646
+ return goodsMap.get(e);
14647
+ });
14648
+ /** 折让行 */
14649
+
14650
+ concession = selectedGood.filter(function (e) {
14651
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) === LineAttributeType$1.折让行;
14652
+ })[0];
14653
+
14654
+ if (concession) {
14655
+ _context3.next = 6;
14656
+ break;
14657
+ }
14658
+
14659
+ content = '未选择折让行';
14660
+ message.error({
14661
+ content: content,
14662
+ key: content
14663
+ });
14664
+ return _context3.abrupt("return");
14665
+
14666
+ case 6:
14667
+ /** 准备添加折扣的货物列表 */
14668
+ discountGood = selectedGood.filter(function (e) {
14669
+ return (e === null || e === void 0 ? void 0 : e.lineAttribute) !== LineAttributeType$1.折让行;
14670
+ });
14671
+ /** 折扣总金额 */
14672
+
14673
+ totalDiscoline = chain$1(bignumber(-1 * (concession.lineAmountIncludeTax || 0)));
14674
+ discolinesSum = chain$1(bignumber(0));
14675
+ /** 总金额 */
14676
+
14677
+ totalAmount = function () {
14678
+ var sum = 0;
14679
+ discountGood.forEach(function (e) {
14680
+ var _e$lineAmountIncludeT;
14681
+
14682
+ sum += (_e$lineAmountIncludeT = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT !== void 0 ? _e$lineAmountIncludeT : 0;
14683
+ });
14684
+ return sum;
14685
+ }(); // 每行的折扣金额
14686
+
14687
+
14688
+ discolines = discountGood.map(function (e, i) {
14689
+ var _e$lineAmountIncludeT2;
14690
+
14691
+ // 折扣金额占比
14692
+ var share = chain$1(bignumber((_e$lineAmountIncludeT2 = e === null || e === void 0 ? void 0 : e.lineAmountIncludeTax) !== null && _e$lineAmountIncludeT2 !== void 0 ? _e$lineAmountIncludeT2 : 0)).divide(bignumber(totalAmount)); // 折扣金额
14693
+
14694
+ var value = totalDiscoline.multiply(share.done()).multiply(bignumber(100)).round().divide(bignumber(100)).done();
14695
+ discolinesSum = discolinesSum.add(value);
14696
+ return value.toNumber();
14697
+ }); // 剩余折扣金额
14698
+
14699
+ surplus = totalDiscoline.subtract(discolinesSum.done()); // 补充剩余折扣金
14700
+
14701
+ i = 0;
14702
+
14703
+ case 13:
14704
+ if (!(i < discolines.length)) {
14705
+ _context3.next = 21;
14706
+ break;
14707
+ }
14708
+
14709
+ if (!surplus.smaller(0.01).done()) {
14710
+ _context3.next = 16;
14711
+ break;
14712
+ }
14713
+
14714
+ return _context3.abrupt("break", 21);
14715
+
14716
+ case 16:
14717
+ discolines[i] = chain$1(bignumber(discolines[i])).add(bignumber(0.01)).done().toNumber();
14718
+ surplus = surplus.subtract(bignumber(0.01));
14719
+
14720
+ case 18:
14721
+ i++;
14722
+ _context3.next = 13;
14723
+ break;
14724
+
14725
+ case 21:
14726
+ _context3.next = 23;
14727
+ return controller.run( /*#__PURE__*/function () {
14728
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
14729
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14730
+ while (1) {
14731
+ switch (_context.prev = _context.next) {
14732
+ case 0:
14733
+ s.goodsListState.goodsList = s.goodsListState.goodsList.filter(function (e) {
14734
+ return e.$index !== concession.$index;
14735
+ });
14736
+
14737
+ case 1:
14738
+ case "end":
14739
+ return _context.stop();
14740
+ }
14741
+ }
14742
+ }, _callee);
14743
+ }));
14744
+
14745
+ return function (_x) {
14746
+ return _ref2.apply(this, arguments);
14747
+ };
14748
+ }());
14749
+
14750
+ case 23:
14751
+ _context3.next = 25;
14752
+ return controller.run( /*#__PURE__*/function () {
14753
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
14754
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
14755
+ while (1) {
14756
+ switch (_context2.prev = _context2.next) {
14757
+ case 0:
14758
+ s.goodsListState.selectedGoodIndex = [];
14759
+
14760
+ case 1:
14761
+ case "end":
14762
+ return _context2.stop();
14763
+ }
14764
+ }
14765
+ }, _callee2);
14766
+ }));
14767
+
14768
+ return function (_x2) {
14769
+ return _ref3.apply(this, arguments);
14770
+ };
14771
+ }());
14772
+
14773
+ case 25:
14774
+ _context3.next = 27;
14775
+ return controller.addGoodDiscountV2(discolines.map(function (e, i) {
14776
+ var _discountGood$i;
14777
+
14778
+ return {
14779
+ $index: (_discountGood$i = discountGood[i]) === null || _discountGood$i === void 0 ? void 0 : _discountGood$i.$index,
14780
+ discolineAmountunt: e
14781
+ };
14782
+ }));
14783
+
14784
+ case 27:
14785
+ case "end":
14786
+ return _context3.stop();
14787
+ }
14788
+ }
14789
+ }, _callee3);
14790
+ })), [controller, selectedGoodIndex, goodsMap]);
14791
+ var button = React.useMemo(function () {
14792
+ if (!isSalesDiscount) return React.createElement(React.Fragment, null);
14793
+ return React.createElement(Button, {
14794
+ onClick: onClick,
14795
+ disabled: selectedGoodIndex.length <= 1
14796
+ }, "\u9500\u552E\u6298\u8BA9");
14797
+ }, [selectedGoodIndex.length, isSalesDiscount]);
14798
+ return {
14799
+ /** 按钮 */
14800
+ button: button
14801
+ };
14802
+ }
14803
+
14590
14804
  var GoodsList = /*#__PURE__*/function (_React$Component) {
14591
14805
  _inherits(GoodsList, _React$Component);
14592
14806
 
@@ -14649,6 +14863,9 @@ var Main = decorator(Form.create())(function (props) {
14649
14863
  /** 全单合并折扣 */
14650
14864
 
14651
14865
  var mergeDiscount = useMergeDiscount();
14866
+ /** 销售折让 */
14867
+
14868
+ var salesDiscount = uaeSalesDiscount();
14652
14869
  /** 清空自动赋码缓存 */
14653
14870
 
14654
14871
  React.useEffect(function () {
@@ -14806,7 +15023,7 @@ var Main = decorator(Form.create())(function (props) {
14806
15023
  className: "kts-invoice-operate-goods-list-able"
14807
15024
  }, React.createElement("div", {
14808
15025
  className: "kts-invoice-operate-goods-list-able-list"
14809
- }, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, React.createElement(Search, null)), React.createElement("div", {
15026
+ }, React.createElement(AddRowButton, null), endowCodeButton.button, delRowButton.button, mergeDetails.button, mergeDiscount.button, addDiscountRowButton.drawer, salesDiscount.button, React.createElement(Search, null)), React.createElement("div", {
14810
15027
  className: "kts-invoice-operate-goods-list-able-extend"
14811
15028
  }, props.menuExpansion, React.createElement(DescribeSwitch, null), React.createElement(TaxIncludedSwitch, null))), React.createElement("div", {
14812
15029
  className: classNames('kts-invoice-operate-goods-list-table', {
@@ -16749,7 +16966,7 @@ function Search$1() {
16749
16966
  });
16750
16967
  }
16751
16968
 
16752
- 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";
16969
+ 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";
16753
16970
  styleInject(css_248z$l);
16754
16971
 
16755
16972
  function TableRow$1(props) {
@@ -16758,6 +16975,11 @@ function TableRow$1(props) {
16758
16975
  var goodsMap = controller.useMemo(function (s) {
16759
16976
  return s.goodsListState.goodsMap;
16760
16977
  }, []);
16978
+ /** 当前拖动中的货品索引 */
16979
+
16980
+ var site = controller.useMemo(function (s) {
16981
+ return s.goodsListState.drag.site;
16982
+ }, []);
16761
16983
  var current = controller.useMemo(function (s) {
16762
16984
  return s.goodsListState.drag.current;
16763
16985
  }, []);
@@ -16789,8 +17011,9 @@ function TableRow$1(props) {
16789
17011
  position: 'absolute',
16790
17012
  bottom: 0
16791
17013
  }
16792
- })) : React.createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
16793
- className: classNames(props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')
17014
+ })) : // <tr {...props} className={classnames(props.className, discount, (rowKey === container && current) ? 'kts-invoice-operate-goods-list-itemName-drag-container' : '')} />
17015
+ React.createElement("tr", _objectSpread2(_objectSpread2({}, props), {}, {
17016
+ className: classNames(props.className, discount, rowKey === container && current ? 'kts-invoice-operate-goods-list-itemName-drag-container-' + site : undefined)
16794
17017
  }));
16795
17018
  }
16796
17019
 
@@ -17985,6 +18208,12 @@ styleInject(css_248z$n);
17985
18208
 
17986
18209
  function Drag$2(props) {
17987
18210
  var record = props.record;
18211
+
18212
+ var _React$useState = React.useState(false),
18213
+ _React$useState2 = _slicedToArray(_React$useState, 2),
18214
+ open = _React$useState2[0],
18215
+ setOpen = _React$useState2[1];
18216
+
17988
18217
  var controller = Invoice.useInvoiceController();
17989
18218
  var editGood = controller.useMemo(function (s) {
17990
18219
  return s.goodsListState.editGood;
@@ -17993,7 +18222,7 @@ function Drag$2(props) {
17993
18222
  return !!editGood;
17994
18223
  }, [editGood]);
17995
18224
  var onMouseDown = React.useCallback(function () {
17996
- if (!controller || !record) return;
18225
+ if (!controller || !record || disabled) return;
17997
18226
  controller.run( /*#__PURE__*/function () {
17998
18227
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
17999
18228
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -18018,64 +18247,57 @@ function Drag$2(props) {
18018
18247
  var currentGood = controller.state.goodsListState.goodsList.filter(function (e) {
18019
18248
  return e.$index === record.$index;
18020
18249
  })[0];
18021
- mounting(React.createElement(DragDiv$1, _objectSpread2({}, currentGood))); // 监听移动
18022
-
18250
+ mounting(React.createElement(DragDiv$1, _objectSpread2({}, currentGood)));
18023
18251
  rowList.forEach(function (e) {
18024
- e.addEventListener('mouseover', onMouseover);
18252
+ e.addEventListener('mousemove', onMousemove);
18025
18253
  });
18026
18254
 
18027
- function onMouseover(e) {
18255
+ function onMousemove(e) {
18028
18256
  controller.run( /*#__PURE__*/function () {
18029
18257
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(s) {
18030
- var _getRow, _getRow$dataset;
18258
+ var _rowDom$dataset;
18031
18259
 
18032
- var container, currentGood, row, currentIndex, containerIndex, _currentIndex, _containerIndex, t;
18260
+ var rowDom, container, row, currentGood, currentIndex, containerIndex, _currentIndex, _containerIndex, t, rect, mouseY;
18033
18261
 
18034
18262
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
18035
18263
  while (1) {
18036
18264
  switch (_context2.prev = _context2.next) {
18037
18265
  case 0:
18038
- 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;
18266
+ rowDom = getRow(e.target);
18267
+ 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;
18268
+ /** 准备插入的货物 */
18269
+
18270
+ row = s.goodsListState.goodsMap.get(container);
18039
18271
 
18040
- if (container) {
18041
- _context2.next = 3;
18272
+ if (row) {
18273
+ _context2.next = 5;
18042
18274
  break;
18043
18275
  }
18044
18276
 
18045
18277
  return _context2.abrupt("return");
18046
18278
 
18047
- case 3:
18279
+ case 5:
18048
18280
  if (!(container === s.goodsListState.drag.current)) {
18049
- _context2.next = 6;
18281
+ _context2.next = 7;
18050
18282
  break;
18051
18283
  }
18052
18284
 
18053
- s.goodsListState.drag.container = undefined;
18054
- return _context2.abrupt("return");
18285
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
18055
18286
 
18056
- case 6:
18287
+ case 7:
18288
+ /** 当前拖动中的货品 */
18057
18289
  currentGood = s.goodsListState.drag.current && s.goodsListState.goodsMap.get(s.goodsListState.drag.current);
18058
18290
 
18059
18291
  if (currentGood) {
18060
- _context2.next = 9;
18292
+ _context2.next = 10;
18061
18293
  break;
18062
18294
  }
18063
18295
 
18064
18296
  return _context2.abrupt("return");
18065
18297
 
18066
- case 9:
18067
- row = s.goodsListState.goodsMap.get(container);
18068
-
18069
- if (row) {
18070
- _context2.next = 12;
18071
- break;
18072
- }
18073
-
18074
- return _context2.abrupt("return");
18075
-
18076
- case 12:
18298
+ case 10:
18077
18299
  if (!(currentGood.lineAttribute === LineAttributeType$1.折扣行)) {
18078
- _context2.next = 18;
18300
+ _context2.next = 15;
18079
18301
  break;
18080
18302
  }
18081
18303
 
@@ -18087,16 +18309,15 @@ function Drag$2(props) {
18087
18309
  }).indexOf(row.$index);
18088
18310
 
18089
18311
  if (!(currentIndex - 1 === containerIndex)) {
18090
- _context2.next = 18;
18312
+ _context2.next = 15;
18091
18313
  break;
18092
18314
  }
18093
18315
 
18094
- s.goodsListState.drag.container = undefined;
18095
- return _context2.abrupt("return");
18316
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
18096
18317
 
18097
- case 18:
18318
+ case 15:
18098
18319
  if (!(currentGood.lineAttribute === LineAttributeType$1.被折扣行)) {
18099
- _context2.next = 24;
18320
+ _context2.next = 20;
18100
18321
  break;
18101
18322
  }
18102
18323
 
@@ -18108,23 +18329,29 @@ function Drag$2(props) {
18108
18329
  }).indexOf(row.$index);
18109
18330
 
18110
18331
  if (!(_currentIndex + 1 === _containerIndex)) {
18111
- _context2.next = 24;
18332
+ _context2.next = 20;
18112
18333
  break;
18113
18334
  }
18114
18335
 
18115
- s.goodsListState.drag.container = undefined;
18116
- return _context2.abrupt("return");
18336
+ return _context2.abrupt("return", s.goodsListState.drag.container = undefined);
18117
18337
 
18118
- case 24:
18338
+ case 20:
18119
18339
  // 折扣行 拖动的 相当于 自己的 被折扣行
18120
18340
  if (row.lineAttribute === LineAttributeType$1.折扣行) {
18121
18341
  t = s.goodsListState.goodsList.map(function (e) {
18122
18342
  return e.$index;
18123
18343
  }).indexOf(container) - 1;
18124
18344
  s.goodsListState.drag.container = s.goodsListState.goodsList[t].$index;
18345
+ s.goodsListState.drag.site = 'u';
18346
+ } else if (row.lineAttribute === LineAttributeType$1.被折扣行) {
18347
+ s.goodsListState.drag.site = 'd';
18348
+ } else {
18349
+ rect = rowDom.getBoundingClientRect();
18350
+ mouseY = e.clientY - rect.top;
18351
+ s.goodsListState.drag.site = mouseY > 25 ? 'd' : 'u';
18125
18352
  }
18126
18353
 
18127
- case 25:
18354
+ case 21:
18128
18355
  case "end":
18129
18356
  return _context2.stop();
18130
18357
  }
@@ -18177,7 +18404,7 @@ function Drag$2(props) {
18177
18404
  }());
18178
18405
  window.removeEventListener('mouseup', onMouseup);
18179
18406
  rowList.forEach(function (e) {
18180
- e.removeEventListener('mouseover', onMouseover);
18407
+ e.removeEventListener('mousemove', onMousemove);
18181
18408
  }); // window.document.body.removeChild(rowDiv);
18182
18409
  } // 开始插入
18183
18410
 
@@ -18186,13 +18413,13 @@ function Drag$2(props) {
18186
18413
  mounting(React.createElement(React.Fragment, null));
18187
18414
  controller.run( /*#__PURE__*/function () {
18188
18415
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(s) {
18189
- var _s$goodsListState$dra, container, current, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
18416
+ var _s$goodsListState$dra, container, current, site, goodsList, goodsMap, _currentGood, currentIndex, moveGoods;
18190
18417
 
18191
18418
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
18192
18419
  while (1) {
18193
18420
  switch (_context4.prev = _context4.next) {
18194
18421
  case 0:
18195
- _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current;
18422
+ _s$goodsListState$dra = s.goodsListState.drag, container = _s$goodsListState$dra.container, current = _s$goodsListState$dra.current, site = _s$goodsListState$dra.site;
18196
18423
 
18197
18424
  if (!(!container || !current)) {
18198
18425
  _context4.next = 3;
@@ -18225,9 +18452,11 @@ function Drag$2(props) {
18225
18452
  var g = s.goodsListState.goodsList.filter(function (e) {
18226
18453
  return moveGoods.indexOf(e.$index) < 0;
18227
18454
  });
18228
- var t = g.map(function (e) {
18455
+ var t = site === 'u' ? g.map(function (e) {
18456
+ return e.$index;
18457
+ }).indexOf(container) : g.map(function (e) {
18229
18458
  return e.$index;
18230
- }).indexOf(container);
18459
+ }).indexOf(container) + 1;
18231
18460
  var m = moveGoods.map(function (e) {
18232
18461
  return goodsMap.get(e);
18233
18462
  }).filter(function (e) {
@@ -18258,33 +18487,44 @@ function Drag$2(props) {
18258
18487
  };
18259
18488
  }());
18260
18489
  }
18261
- }, [controller, record]);
18262
- return React.createElement(Button, {
18263
- type: 'link',
18264
- style: {
18265
- padding: 0
18266
- },
18267
- disabled: disabled,
18268
- onMouseDown: onMouseDown,
18269
- onClick: function onClick(e) {
18270
- e.stopPropagation();
18271
- },
18272
- className: "kts-invoice-operate-goods-list-itemName-drag"
18273
- }, React.createElement(Icon, {
18274
- component: SvgI001$1
18275
- }));
18490
+ }, [controller, record, disabled]);
18491
+ var renderButton = React.useMemo(function () {
18492
+ return React.createElement(Button, {
18493
+ type: 'link',
18494
+ style: {
18495
+ padding: 0
18496
+ },
18497
+ onMouseDown: onMouseDown,
18498
+ onClick: function onClick(e) {
18499
+ e.stopPropagation();
18500
+ },
18501
+ className: "kts-invoice-operate-goods-list-itemName-drag",
18502
+ onMouseOver: controller.saveEditGood
18503
+ }, React.createElement(Icon, {
18504
+ component: SvgI001$1
18505
+ }));
18506
+ }, [onMouseDown, controller]);
18507
+
18508
+ if (disabled) {
18509
+ return React.createElement(Popover, {
18510
+ content: '您还有未编辑完成的商品',
18511
+ trigger: 'focus'
18512
+ }, renderButton);
18513
+ } else {
18514
+ return renderButton;
18515
+ }
18276
18516
  }
18277
18517
 
18278
18518
  function DragDiv$1(props) {
18279
- var _React$useState = React.useState(0),
18280
- _React$useState2 = _slicedToArray(_React$useState, 2),
18281
- x = _React$useState2[0],
18282
- setX = _React$useState2[1];
18283
-
18284
- var _React$useState3 = React.useState(-110),
18519
+ var _React$useState3 = React.useState(0),
18285
18520
  _React$useState4 = _slicedToArray(_React$useState3, 2),
18286
- y = _React$useState4[0],
18287
- setY = _React$useState4[1];
18521
+ x = _React$useState4[0],
18522
+ setX = _React$useState4[1];
18523
+
18524
+ var _React$useState5 = React.useState(-110),
18525
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
18526
+ y = _React$useState6[0],
18527
+ setY = _React$useState6[1];
18288
18528
 
18289
18529
  var div = React.useMemo(function () {
18290
18530
  return window.document.querySelector("[data-row-key=\"".concat(props.$index, "\"]"));
@@ -18299,7 +18539,7 @@ function DragDiv$1(props) {
18299
18539
 
18300
18540
  React.useEffect(function () {
18301
18541
  function onMousemove(e) {
18302
- setY(e.clientY - 25);
18542
+ setY(e.clientY - 15);
18303
18543
  }
18304
18544
  window.addEventListener('mousemove', onMousemove);
18305
18545
  return function () {