kts-component-invoice-operate 3.2.66 → 3.2.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Invoice/InvoiceController/fns/mergeDetails.d.ts +1 -1
- package/dist/Invoice/InvoiceController/index.d.ts +1 -1
- package/dist/index.esm.js +148 -61
- package/dist/index.js +147 -60
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/fns/mergeDetails.ts +6 -4
- package/src/Invoice/InvoiceController/index.ts +1 -1
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemCodeInput/index.tsx +0 -2
- package/src/Invoice/ui/default/GoodsList/ui/BulkMenu/hooks/useMergeDetails/index.tsx +60 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { InvoiceControllerState } from '..';
|
|
2
|
-
export default function mergeDetails(state: InvoiceControllerState): Promise<void>;
|
|
2
|
+
export default function mergeDetails(state: InvoiceControllerState, selectedGoodIndex?: string[]): Promise<void>;
|
|
@@ -23,7 +23,7 @@ export default class InvoiceController extends InvoiceControllerForm {
|
|
|
23
23
|
/** 添加一个货物 */
|
|
24
24
|
addGood: (option?: any) => Promise<any>;
|
|
25
25
|
/** 全单合并明细 */
|
|
26
|
-
mergeDetails: (option?:
|
|
26
|
+
mergeDetails: (option?: string[] | undefined) => Promise<any>;
|
|
27
27
|
/** 全单合并折扣 */
|
|
28
28
|
mergeDiscount: (option?: any) => Promise<any>;
|
|
29
29
|
/** 给一组货物添加折扣行 */
|
package/dist/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import GreyReactBox, { decorator } from 'grey-react-box';
|
|
|
4
4
|
import { chain as chain$1, bignumber, create, all } from 'mathjs';
|
|
5
5
|
import { message, Form, Input, Icon as Icon$1, Tag as Tag$1, Select, Button, Tooltip, Switch as Switch$1, Typography, Menu, Dropdown, AutoComplete as AutoComplete$2, Spin, Checkbox, Drawer, Descriptions, Empty, Divider, Popover as Popover$1, Table as Table$1, Tree, Modal as Modal$1, Row as Row$1, Col as Col$1 } from 'kts-components-antd-x3';
|
|
6
6
|
import { v4 } from 'uuid';
|
|
7
|
-
import { message as message$1, TableManual, Switch, AutoComplete as AutoComplete$1, Popover, Row, Col, Button as Button$1, Tooltip as Tooltip$1, Input as Input$1, Select as Select$1, Spin as Spin$1, Menu as Menu$1, Form as Form$1, Drawer as Drawer$1, Space, Radio, InputNumber, Popconfirm, Modal } from 'kts-xui';
|
|
7
|
+
import { message as message$1, TableManual, Switch, AutoComplete as AutoComplete$1, Popover, Dropdown as Dropdown$1, Row, Col, Button as Button$1, Tooltip as Tooltip$1, Input as Input$1, Select as Select$1, Spin as Spin$1, Menu as Menu$1, Form as Form$1, Drawer as Drawer$1, Space, Radio, InputNumber, Popconfirm, Modal } from 'kts-xui';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { Table } from 'kts-components-antd-x4-v4';
|
|
10
10
|
import { render } from 'react-dom';
|
|
@@ -1715,90 +1715,93 @@ function getGoodsSearch(goodsList, search, isTaxIncluded) {
|
|
|
1715
1715
|
});
|
|
1716
1716
|
}
|
|
1717
1717
|
|
|
1718
|
-
function mergeDetails(_x) {
|
|
1718
|
+
function mergeDetails(_x, _x2) {
|
|
1719
1719
|
return _mergeDetails.apply(this, arguments);
|
|
1720
1720
|
}
|
|
1721
1721
|
/** 计算单价(含税) */
|
|
1722
1722
|
|
|
1723
1723
|
function _mergeDetails() {
|
|
1724
|
-
_mergeDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(state) {
|
|
1724
|
+
_mergeDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(state, selectedGoodIndex) {
|
|
1725
1725
|
var goodsList, sum, p;
|
|
1726
1726
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1727
1727
|
while (1) {
|
|
1728
1728
|
switch (_context.prev = _context.next) {
|
|
1729
1729
|
case 0:
|
|
1730
|
-
|
|
1731
|
-
|
|
1730
|
+
debugger;
|
|
1731
|
+
|
|
1732
|
+
if (!(state.goodsListState.editGood || !selectedGoodIndex || selectedGoodIndex.length < 2)) {
|
|
1733
|
+
_context.next = 3;
|
|
1732
1734
|
break;
|
|
1733
1735
|
}
|
|
1734
1736
|
|
|
1735
1737
|
return _context.abrupt("return");
|
|
1736
1738
|
|
|
1737
|
-
case
|
|
1739
|
+
case 3:
|
|
1738
1740
|
// const goodsList = state.goodsListState.selectedGoodIndex.map(e => state.goodsListState.goodsMap.get(e)).filter(e => !!e) as IGood[];
|
|
1741
|
+
// const goodsList = state.goodsListState.goodsList.filter(e => state.goodsListState.selectedGoodIndex.indexOf(e.$index) >= 0)
|
|
1739
1742
|
goodsList = state.goodsListState.goodsList.filter(function (e) {
|
|
1740
|
-
return
|
|
1743
|
+
return selectedGoodIndex.indexOf(e.$index) >= 0;
|
|
1741
1744
|
});
|
|
1742
1745
|
|
|
1743
1746
|
if (!(goodsList.length < 2)) {
|
|
1744
|
-
_context.next =
|
|
1747
|
+
_context.next = 6;
|
|
1745
1748
|
break;
|
|
1746
1749
|
}
|
|
1747
1750
|
|
|
1748
1751
|
return _context.abrupt("return");
|
|
1749
1752
|
|
|
1750
|
-
case
|
|
1751
|
-
_context.prev =
|
|
1753
|
+
case 6:
|
|
1754
|
+
_context.prev = 6;
|
|
1752
1755
|
// 创建合并后的商品对象
|
|
1753
1756
|
sum = {
|
|
1754
1757
|
$index: idGenerator(),
|
|
1755
1758
|
lineAttribute: LineAttributeType$1.正常
|
|
1756
1759
|
}; // 存在税率不一样的明细,不能合并
|
|
1757
1760
|
|
|
1758
|
-
_context.next =
|
|
1761
|
+
_context.next = 10;
|
|
1759
1762
|
return checkTaxTate(goodsList);
|
|
1760
1763
|
|
|
1761
|
-
case
|
|
1762
|
-
_context.next =
|
|
1764
|
+
case 10:
|
|
1765
|
+
_context.next = 12;
|
|
1763
1766
|
return fillingInformationGood(goodsList, sum);
|
|
1764
1767
|
|
|
1765
|
-
case
|
|
1768
|
+
case 12:
|
|
1766
1769
|
sum = _context.sent;
|
|
1767
|
-
_context.next =
|
|
1770
|
+
_context.next = 15;
|
|
1768
1771
|
return mergeQuantity(goodsList);
|
|
1769
1772
|
|
|
1770
|
-
case
|
|
1773
|
+
case 15:
|
|
1771
1774
|
sum.quantity = _context.sent;
|
|
1772
|
-
_context.next =
|
|
1775
|
+
_context.next = 18;
|
|
1773
1776
|
return mergeLineAmountExcludeTax(goodsList);
|
|
1774
1777
|
|
|
1775
|
-
case
|
|
1778
|
+
case 18:
|
|
1776
1779
|
sum.lineAmountExcludeTax = _context.sent;
|
|
1777
|
-
_context.next =
|
|
1780
|
+
_context.next = 21;
|
|
1778
1781
|
return mergeLineAmountIncludeTax(goodsList);
|
|
1779
1782
|
|
|
1780
|
-
case
|
|
1783
|
+
case 21:
|
|
1781
1784
|
sum.lineAmountIncludeTax = _context.sent;
|
|
1782
|
-
_context.next =
|
|
1785
|
+
_context.next = 24;
|
|
1783
1786
|
return calculatePriceExcludeTax(sum, state.calculatingDigits);
|
|
1784
1787
|
|
|
1785
|
-
case
|
|
1788
|
+
case 24:
|
|
1786
1789
|
sum.priceExcludeTax = _context.sent;
|
|
1787
|
-
_context.next =
|
|
1790
|
+
_context.next = 27;
|
|
1788
1791
|
return calculatePriceIncludeTax(sum, state.calculatingDigits);
|
|
1789
1792
|
|
|
1790
|
-
case
|
|
1793
|
+
case 27:
|
|
1791
1794
|
sum.priceIncludeTax = _context.sent;
|
|
1792
1795
|
// 计算税额
|
|
1793
1796
|
sum.taxAmount = chain$1(bignumber(sum.lineAmountIncludeTax)).subtract(bignumber(sum.lineAmountExcludeTax)).done().toNumber(); // 校验数据 是否数量和金额是否同号
|
|
1794
1797
|
|
|
1795
|
-
_context.next =
|
|
1798
|
+
_context.next = 31;
|
|
1796
1799
|
return checkSameNumber(sum);
|
|
1797
1800
|
|
|
1798
|
-
case
|
|
1801
|
+
case 31:
|
|
1799
1802
|
p = state.goodsListState.goodsList.indexOf(goodsList[0]);
|
|
1800
1803
|
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(function (e) {
|
|
1801
|
-
return
|
|
1804
|
+
return selectedGoodIndex.indexOf(e.$index) < 0;
|
|
1802
1805
|
});
|
|
1803
1806
|
state.goodsListState.goodsList.splice(p, 0, sum);
|
|
1804
1807
|
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(function (e) {
|
|
@@ -1809,25 +1812,25 @@ function _mergeDetails() {
|
|
|
1809
1812
|
state.goodsListState.goodsMap.set(e.$index, e);
|
|
1810
1813
|
});
|
|
1811
1814
|
state.goodsListState.selectedGoodIndex = [];
|
|
1812
|
-
_context.next =
|
|
1815
|
+
_context.next = 43;
|
|
1813
1816
|
break;
|
|
1814
1817
|
|
|
1815
|
-
case
|
|
1816
|
-
_context.prev =
|
|
1817
|
-
_context.t0 = _context["catch"](
|
|
1818
|
+
case 40:
|
|
1819
|
+
_context.prev = 40;
|
|
1820
|
+
_context.t0 = _context["catch"](6);
|
|
1818
1821
|
showError(_context.t0);
|
|
1819
1822
|
|
|
1820
|
-
case
|
|
1823
|
+
case 43:
|
|
1821
1824
|
case "end":
|
|
1822
1825
|
return _context.stop();
|
|
1823
1826
|
}
|
|
1824
1827
|
}
|
|
1825
|
-
}, _callee, null, [[
|
|
1828
|
+
}, _callee, null, [[6, 40]]);
|
|
1826
1829
|
}));
|
|
1827
1830
|
return _mergeDetails.apply(this, arguments);
|
|
1828
1831
|
}
|
|
1829
1832
|
|
|
1830
|
-
function calculatePriceIncludeTax(
|
|
1833
|
+
function calculatePriceIncludeTax(_x3, _x4) {
|
|
1831
1834
|
return _calculatePriceIncludeTax.apply(this, arguments);
|
|
1832
1835
|
}
|
|
1833
1836
|
/** 计算单价(不含税) */
|
|
@@ -1861,7 +1864,7 @@ function _calculatePriceIncludeTax() {
|
|
|
1861
1864
|
return _calculatePriceIncludeTax.apply(this, arguments);
|
|
1862
1865
|
}
|
|
1863
1866
|
|
|
1864
|
-
function calculatePriceExcludeTax(
|
|
1867
|
+
function calculatePriceExcludeTax(_x5, _x6) {
|
|
1865
1868
|
return _calculatePriceExcludeTax.apply(this, arguments);
|
|
1866
1869
|
}
|
|
1867
1870
|
/** 合并金额(含税) */
|
|
@@ -1895,7 +1898,7 @@ function _calculatePriceExcludeTax() {
|
|
|
1895
1898
|
return _calculatePriceExcludeTax.apply(this, arguments);
|
|
1896
1899
|
}
|
|
1897
1900
|
|
|
1898
|
-
function mergeLineAmountIncludeTax(
|
|
1901
|
+
function mergeLineAmountIncludeTax(_x7) {
|
|
1899
1902
|
return _mergeLineAmountIncludeTax.apply(this, arguments);
|
|
1900
1903
|
}
|
|
1901
1904
|
/** 合并金额(不含税) */
|
|
@@ -1924,7 +1927,7 @@ function _mergeLineAmountIncludeTax() {
|
|
|
1924
1927
|
return _mergeLineAmountIncludeTax.apply(this, arguments);
|
|
1925
1928
|
}
|
|
1926
1929
|
|
|
1927
|
-
function mergeLineAmountExcludeTax(
|
|
1930
|
+
function mergeLineAmountExcludeTax(_x8) {
|
|
1928
1931
|
return _mergeLineAmountExcludeTax.apply(this, arguments);
|
|
1929
1932
|
}
|
|
1930
1933
|
/** 合并数量 */
|
|
@@ -1953,7 +1956,7 @@ function _mergeLineAmountExcludeTax() {
|
|
|
1953
1956
|
return _mergeLineAmountExcludeTax.apply(this, arguments);
|
|
1954
1957
|
}
|
|
1955
1958
|
|
|
1956
|
-
function mergeQuantity(
|
|
1959
|
+
function mergeQuantity(_x9) {
|
|
1957
1960
|
return _mergeQuantity.apply(this, arguments);
|
|
1958
1961
|
}
|
|
1959
1962
|
/** 填充行明细信息 */
|
|
@@ -1982,7 +1985,7 @@ function _mergeQuantity() {
|
|
|
1982
1985
|
return _mergeQuantity.apply(this, arguments);
|
|
1983
1986
|
}
|
|
1984
1987
|
|
|
1985
|
-
function fillingInformationGood(
|
|
1988
|
+
function fillingInformationGood(_x10, _x11) {
|
|
1986
1989
|
return _fillingInformationGood.apply(this, arguments);
|
|
1987
1990
|
}
|
|
1988
1991
|
/** 存在税率不一样的明细,不能合并 */
|
|
@@ -2013,7 +2016,7 @@ function _fillingInformationGood() {
|
|
|
2013
2016
|
return _fillingInformationGood.apply(this, arguments);
|
|
2014
2017
|
}
|
|
2015
2018
|
|
|
2016
|
-
function checkTaxTate(
|
|
2019
|
+
function checkTaxTate(_x12) {
|
|
2017
2020
|
return _checkTaxTate.apply(this, arguments);
|
|
2018
2021
|
}
|
|
2019
2022
|
/** 校验数据 是否数量和金额是否同号 */
|
|
@@ -2057,7 +2060,7 @@ function _checkTaxTate() {
|
|
|
2057
2060
|
return _checkTaxTate.apply(this, arguments);
|
|
2058
2061
|
}
|
|
2059
2062
|
|
|
2060
|
-
function checkSameNumber(
|
|
2063
|
+
function checkSameNumber(_x13) {
|
|
2061
2064
|
return _checkSameNumber.apply(this, arguments);
|
|
2062
2065
|
}
|
|
2063
2066
|
/** 显示错误信息 */
|
|
@@ -10788,38 +10791,37 @@ function ItemCodeInput(props) {
|
|
|
10788
10791
|
while (1) {
|
|
10789
10792
|
switch (_context.prev = _context.next) {
|
|
10790
10793
|
case 0:
|
|
10791
|
-
|
|
10792
|
-
_context.prev = 1;
|
|
10794
|
+
_context.prev = 0;
|
|
10793
10795
|
|
|
10794
10796
|
if (!autoComplete.onItemCodeSearch) {
|
|
10795
|
-
_context.next =
|
|
10797
|
+
_context.next = 7;
|
|
10796
10798
|
break;
|
|
10797
10799
|
}
|
|
10798
10800
|
|
|
10799
10801
|
_context.t0 = setOptions;
|
|
10800
|
-
_context.next =
|
|
10802
|
+
_context.next = 5;
|
|
10801
10803
|
return autoComplete.onItemCodeSearch(searchText, editGood === null || editGood === void 0 ? void 0 : editGood.itemName);
|
|
10802
10804
|
|
|
10803
|
-
case
|
|
10805
|
+
case 5:
|
|
10804
10806
|
_context.t1 = _context.sent;
|
|
10805
10807
|
(0, _context.t0)(_context.t1);
|
|
10806
10808
|
|
|
10807
|
-
case
|
|
10808
|
-
_context.next =
|
|
10809
|
+
case 7:
|
|
10810
|
+
_context.next = 13;
|
|
10809
10811
|
break;
|
|
10810
10812
|
|
|
10811
|
-
case
|
|
10812
|
-
_context.prev =
|
|
10813
|
-
_context.t2 = _context["catch"](
|
|
10813
|
+
case 9:
|
|
10814
|
+
_context.prev = 9;
|
|
10815
|
+
_context.t2 = _context["catch"](0);
|
|
10814
10816
|
setOptions([]);
|
|
10815
10817
|
throw _context.t2;
|
|
10816
10818
|
|
|
10817
|
-
case
|
|
10819
|
+
case 13:
|
|
10818
10820
|
case "end":
|
|
10819
10821
|
return _context.stop();
|
|
10820
10822
|
}
|
|
10821
10823
|
}
|
|
10822
|
-
}, _callee, null, [[
|
|
10824
|
+
}, _callee, null, [[0, 9]]);
|
|
10823
10825
|
}));
|
|
10824
10826
|
|
|
10825
10827
|
return function (_x) {
|
|
@@ -10845,10 +10847,9 @@ function ItemCodeInput(props) {
|
|
|
10845
10847
|
return _context2.abrupt("return");
|
|
10846
10848
|
|
|
10847
10849
|
case 3:
|
|
10848
|
-
debugger;
|
|
10849
10850
|
controller.importGoodsDrawer(record);
|
|
10850
10851
|
|
|
10851
|
-
case
|
|
10852
|
+
case 4:
|
|
10852
10853
|
case "end":
|
|
10853
10854
|
return _context2.stop();
|
|
10854
10855
|
}
|
|
@@ -14540,7 +14541,7 @@ function useMergeDetails() {
|
|
|
14540
14541
|
var isMergeDetails = controller.useMemo(function (s) {
|
|
14541
14542
|
return s.goodsListState.isMergeDetails;
|
|
14542
14543
|
}, []);
|
|
14543
|
-
var
|
|
14544
|
+
var onClickManual = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
14544
14545
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14545
14546
|
while (1) {
|
|
14546
14547
|
switch (_context.prev = _context.next) {
|
|
@@ -14554,7 +14555,7 @@ function useMergeDetails() {
|
|
|
14554
14555
|
|
|
14555
14556
|
case 4:
|
|
14556
14557
|
_context.next = 6;
|
|
14557
|
-
return controller.mergeDetails();
|
|
14558
|
+
return controller.mergeDetails(controller.state.goodsListState.selectedGoodIndex);
|
|
14558
14559
|
|
|
14559
14560
|
case 6:
|
|
14560
14561
|
case "end":
|
|
@@ -14563,17 +14564,103 @@ function useMergeDetails() {
|
|
|
14563
14564
|
}
|
|
14564
14565
|
}, _callee);
|
|
14565
14566
|
})), [controller]);
|
|
14567
|
+
var onClickAuto = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
14568
|
+
var group, i, _selectedGoodIndex;
|
|
14569
|
+
|
|
14570
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
14571
|
+
while (1) {
|
|
14572
|
+
switch (_context2.prev = _context2.next) {
|
|
14573
|
+
case 0:
|
|
14574
|
+
_context2.next = 2;
|
|
14575
|
+
return controller.saveEditGood();
|
|
14576
|
+
|
|
14577
|
+
case 2:
|
|
14578
|
+
_context2.next = 4;
|
|
14579
|
+
return controller.wait();
|
|
14580
|
+
|
|
14581
|
+
case 4:
|
|
14582
|
+
group = groupBy(controller.state.goodsListState.goodsList);
|
|
14583
|
+
i = 0;
|
|
14584
|
+
|
|
14585
|
+
case 6:
|
|
14586
|
+
if (!(i < group.length)) {
|
|
14587
|
+
_context2.next = 13;
|
|
14588
|
+
break;
|
|
14589
|
+
}
|
|
14590
|
+
|
|
14591
|
+
_selectedGoodIndex = group[i].map(function (e) {
|
|
14592
|
+
return e.$index;
|
|
14593
|
+
});
|
|
14594
|
+
_context2.next = 10;
|
|
14595
|
+
return controller.mergeDetails(_selectedGoodIndex);
|
|
14596
|
+
|
|
14597
|
+
case 10:
|
|
14598
|
+
i++;
|
|
14599
|
+
_context2.next = 6;
|
|
14600
|
+
break;
|
|
14601
|
+
|
|
14602
|
+
case 13:
|
|
14603
|
+
case "end":
|
|
14604
|
+
return _context2.stop();
|
|
14605
|
+
}
|
|
14606
|
+
}
|
|
14607
|
+
}, _callee2);
|
|
14608
|
+
})), []);
|
|
14609
|
+
var items = React.useMemo(function () {
|
|
14610
|
+
return [{
|
|
14611
|
+
key: '0',
|
|
14612
|
+
label: '自动合并',
|
|
14613
|
+
onClick: onClickAuto
|
|
14614
|
+
}, {
|
|
14615
|
+
key: '1',
|
|
14616
|
+
label: '手动合并',
|
|
14617
|
+
disabled: selectedGoodIndex.length <= 1,
|
|
14618
|
+
onClick: onClickManual
|
|
14619
|
+
}];
|
|
14620
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto]);
|
|
14566
14621
|
var button = React.useMemo(function () {
|
|
14567
14622
|
if (!isMergeDetails) return React.createElement(React.Fragment, null);
|
|
14568
|
-
return React.createElement(
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14623
|
+
return React.createElement(Dropdown$1, {
|
|
14624
|
+
menu: {
|
|
14625
|
+
items: items
|
|
14626
|
+
},
|
|
14627
|
+
trigger: ['click']
|
|
14628
|
+
}, React.createElement(Button, null, "\u5408\u5E76\u660E\u7EC6"));
|
|
14572
14629
|
}, [selectedGoodIndex.length, isMergeDetails]);
|
|
14573
14630
|
return {
|
|
14574
14631
|
/** 按钮 */
|
|
14575
14632
|
button: button
|
|
14576
14633
|
};
|
|
14634
|
+
} // 根据"商品编码"" 和 "单价" 分组
|
|
14635
|
+
|
|
14636
|
+
function groupBy(arr) {
|
|
14637
|
+
var grouped = {}; // for (const item of arr) {
|
|
14638
|
+
// if (!item.itemCode) continue;
|
|
14639
|
+
// const key = `${item.itemCode}${item.priceIncludeTax}${item.priceExcludeTax}`;
|
|
14640
|
+
// if (!grouped[key]) {
|
|
14641
|
+
// grouped[key] = [];
|
|
14642
|
+
// }
|
|
14643
|
+
// grouped[key].push(item);
|
|
14644
|
+
// }
|
|
14645
|
+
|
|
14646
|
+
for (var i = 0; i < arr.length; i++) {
|
|
14647
|
+
var item = arr[i];
|
|
14648
|
+
if (!item.itemCode) continue;
|
|
14649
|
+
var key = "".concat(item.itemCode).concat(item.priceIncludeTax).concat(item.priceExcludeTax);
|
|
14650
|
+
|
|
14651
|
+
if (!grouped[key]) {
|
|
14652
|
+
grouped[key] = [];
|
|
14653
|
+
}
|
|
14654
|
+
|
|
14655
|
+
grouped[key].push(item);
|
|
14656
|
+
|
|
14657
|
+
if (item.lineAttribute === LineAttributeType$1.被折扣行) {
|
|
14658
|
+
grouped[key].push(arr[i + 1]);
|
|
14659
|
+
i++;
|
|
14660
|
+
}
|
|
14661
|
+
}
|
|
14662
|
+
|
|
14663
|
+
return Object.values(grouped);
|
|
14577
14664
|
}
|
|
14578
14665
|
|
|
14579
14666
|
/** 全单合并折扣 */
|
package/dist/index.js
CHANGED
|
@@ -1725,90 +1725,93 @@ function getGoodsSearch(goodsList, search, isTaxIncluded) {
|
|
|
1725
1725
|
});
|
|
1726
1726
|
}
|
|
1727
1727
|
|
|
1728
|
-
function mergeDetails(_x) {
|
|
1728
|
+
function mergeDetails(_x, _x2) {
|
|
1729
1729
|
return _mergeDetails.apply(this, arguments);
|
|
1730
1730
|
}
|
|
1731
1731
|
/** 计算单价(含税) */
|
|
1732
1732
|
|
|
1733
1733
|
function _mergeDetails() {
|
|
1734
|
-
_mergeDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(state) {
|
|
1734
|
+
_mergeDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(state, selectedGoodIndex) {
|
|
1735
1735
|
var goodsList, sum, p;
|
|
1736
1736
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1737
1737
|
while (1) {
|
|
1738
1738
|
switch (_context.prev = _context.next) {
|
|
1739
1739
|
case 0:
|
|
1740
|
-
|
|
1741
|
-
|
|
1740
|
+
debugger;
|
|
1741
|
+
|
|
1742
|
+
if (!(state.goodsListState.editGood || !selectedGoodIndex || selectedGoodIndex.length < 2)) {
|
|
1743
|
+
_context.next = 3;
|
|
1742
1744
|
break;
|
|
1743
1745
|
}
|
|
1744
1746
|
|
|
1745
1747
|
return _context.abrupt("return");
|
|
1746
1748
|
|
|
1747
|
-
case
|
|
1749
|
+
case 3:
|
|
1748
1750
|
// const goodsList = state.goodsListState.selectedGoodIndex.map(e => state.goodsListState.goodsMap.get(e)).filter(e => !!e) as IGood[];
|
|
1751
|
+
// const goodsList = state.goodsListState.goodsList.filter(e => state.goodsListState.selectedGoodIndex.indexOf(e.$index) >= 0)
|
|
1749
1752
|
goodsList = state.goodsListState.goodsList.filter(function (e) {
|
|
1750
|
-
return
|
|
1753
|
+
return selectedGoodIndex.indexOf(e.$index) >= 0;
|
|
1751
1754
|
});
|
|
1752
1755
|
|
|
1753
1756
|
if (!(goodsList.length < 2)) {
|
|
1754
|
-
_context.next =
|
|
1757
|
+
_context.next = 6;
|
|
1755
1758
|
break;
|
|
1756
1759
|
}
|
|
1757
1760
|
|
|
1758
1761
|
return _context.abrupt("return");
|
|
1759
1762
|
|
|
1760
|
-
case
|
|
1761
|
-
_context.prev =
|
|
1763
|
+
case 6:
|
|
1764
|
+
_context.prev = 6;
|
|
1762
1765
|
// 创建合并后的商品对象
|
|
1763
1766
|
sum = {
|
|
1764
1767
|
$index: idGenerator(),
|
|
1765
1768
|
lineAttribute: LineAttributeType$1.正常
|
|
1766
1769
|
}; // 存在税率不一样的明细,不能合并
|
|
1767
1770
|
|
|
1768
|
-
_context.next =
|
|
1771
|
+
_context.next = 10;
|
|
1769
1772
|
return checkTaxTate(goodsList);
|
|
1770
1773
|
|
|
1771
|
-
case
|
|
1772
|
-
_context.next =
|
|
1774
|
+
case 10:
|
|
1775
|
+
_context.next = 12;
|
|
1773
1776
|
return fillingInformationGood(goodsList, sum);
|
|
1774
1777
|
|
|
1775
|
-
case
|
|
1778
|
+
case 12:
|
|
1776
1779
|
sum = _context.sent;
|
|
1777
|
-
_context.next =
|
|
1780
|
+
_context.next = 15;
|
|
1778
1781
|
return mergeQuantity(goodsList);
|
|
1779
1782
|
|
|
1780
|
-
case
|
|
1783
|
+
case 15:
|
|
1781
1784
|
sum.quantity = _context.sent;
|
|
1782
|
-
_context.next =
|
|
1785
|
+
_context.next = 18;
|
|
1783
1786
|
return mergeLineAmountExcludeTax(goodsList);
|
|
1784
1787
|
|
|
1785
|
-
case
|
|
1788
|
+
case 18:
|
|
1786
1789
|
sum.lineAmountExcludeTax = _context.sent;
|
|
1787
|
-
_context.next =
|
|
1790
|
+
_context.next = 21;
|
|
1788
1791
|
return mergeLineAmountIncludeTax(goodsList);
|
|
1789
1792
|
|
|
1790
|
-
case
|
|
1793
|
+
case 21:
|
|
1791
1794
|
sum.lineAmountIncludeTax = _context.sent;
|
|
1792
|
-
_context.next =
|
|
1795
|
+
_context.next = 24;
|
|
1793
1796
|
return calculatePriceExcludeTax(sum, state.calculatingDigits);
|
|
1794
1797
|
|
|
1795
|
-
case
|
|
1798
|
+
case 24:
|
|
1796
1799
|
sum.priceExcludeTax = _context.sent;
|
|
1797
|
-
_context.next =
|
|
1800
|
+
_context.next = 27;
|
|
1798
1801
|
return calculatePriceIncludeTax(sum, state.calculatingDigits);
|
|
1799
1802
|
|
|
1800
|
-
case
|
|
1803
|
+
case 27:
|
|
1801
1804
|
sum.priceIncludeTax = _context.sent;
|
|
1802
1805
|
// 计算税额
|
|
1803
1806
|
sum.taxAmount = mathjs.chain(mathjs.bignumber(sum.lineAmountIncludeTax)).subtract(mathjs.bignumber(sum.lineAmountExcludeTax)).done().toNumber(); // 校验数据 是否数量和金额是否同号
|
|
1804
1807
|
|
|
1805
|
-
_context.next =
|
|
1808
|
+
_context.next = 31;
|
|
1806
1809
|
return checkSameNumber(sum);
|
|
1807
1810
|
|
|
1808
|
-
case
|
|
1811
|
+
case 31:
|
|
1809
1812
|
p = state.goodsListState.goodsList.indexOf(goodsList[0]);
|
|
1810
1813
|
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(function (e) {
|
|
1811
|
-
return
|
|
1814
|
+
return selectedGoodIndex.indexOf(e.$index) < 0;
|
|
1812
1815
|
});
|
|
1813
1816
|
state.goodsListState.goodsList.splice(p, 0, sum);
|
|
1814
1817
|
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(function (e) {
|
|
@@ -1819,25 +1822,25 @@ function _mergeDetails() {
|
|
|
1819
1822
|
state.goodsListState.goodsMap.set(e.$index, e);
|
|
1820
1823
|
});
|
|
1821
1824
|
state.goodsListState.selectedGoodIndex = [];
|
|
1822
|
-
_context.next =
|
|
1825
|
+
_context.next = 43;
|
|
1823
1826
|
break;
|
|
1824
1827
|
|
|
1825
|
-
case
|
|
1826
|
-
_context.prev =
|
|
1827
|
-
_context.t0 = _context["catch"](
|
|
1828
|
+
case 40:
|
|
1829
|
+
_context.prev = 40;
|
|
1830
|
+
_context.t0 = _context["catch"](6);
|
|
1828
1831
|
showError(_context.t0);
|
|
1829
1832
|
|
|
1830
|
-
case
|
|
1833
|
+
case 43:
|
|
1831
1834
|
case "end":
|
|
1832
1835
|
return _context.stop();
|
|
1833
1836
|
}
|
|
1834
1837
|
}
|
|
1835
|
-
}, _callee, null, [[
|
|
1838
|
+
}, _callee, null, [[6, 40]]);
|
|
1836
1839
|
}));
|
|
1837
1840
|
return _mergeDetails.apply(this, arguments);
|
|
1838
1841
|
}
|
|
1839
1842
|
|
|
1840
|
-
function calculatePriceIncludeTax(
|
|
1843
|
+
function calculatePriceIncludeTax(_x3, _x4) {
|
|
1841
1844
|
return _calculatePriceIncludeTax.apply(this, arguments);
|
|
1842
1845
|
}
|
|
1843
1846
|
/** 计算单价(不含税) */
|
|
@@ -1871,7 +1874,7 @@ function _calculatePriceIncludeTax() {
|
|
|
1871
1874
|
return _calculatePriceIncludeTax.apply(this, arguments);
|
|
1872
1875
|
}
|
|
1873
1876
|
|
|
1874
|
-
function calculatePriceExcludeTax(
|
|
1877
|
+
function calculatePriceExcludeTax(_x5, _x6) {
|
|
1875
1878
|
return _calculatePriceExcludeTax.apply(this, arguments);
|
|
1876
1879
|
}
|
|
1877
1880
|
/** 合并金额(含税) */
|
|
@@ -1905,7 +1908,7 @@ function _calculatePriceExcludeTax() {
|
|
|
1905
1908
|
return _calculatePriceExcludeTax.apply(this, arguments);
|
|
1906
1909
|
}
|
|
1907
1910
|
|
|
1908
|
-
function mergeLineAmountIncludeTax(
|
|
1911
|
+
function mergeLineAmountIncludeTax(_x7) {
|
|
1909
1912
|
return _mergeLineAmountIncludeTax.apply(this, arguments);
|
|
1910
1913
|
}
|
|
1911
1914
|
/** 合并金额(不含税) */
|
|
@@ -1934,7 +1937,7 @@ function _mergeLineAmountIncludeTax() {
|
|
|
1934
1937
|
return _mergeLineAmountIncludeTax.apply(this, arguments);
|
|
1935
1938
|
}
|
|
1936
1939
|
|
|
1937
|
-
function mergeLineAmountExcludeTax(
|
|
1940
|
+
function mergeLineAmountExcludeTax(_x8) {
|
|
1938
1941
|
return _mergeLineAmountExcludeTax.apply(this, arguments);
|
|
1939
1942
|
}
|
|
1940
1943
|
/** 合并数量 */
|
|
@@ -1963,7 +1966,7 @@ function _mergeLineAmountExcludeTax() {
|
|
|
1963
1966
|
return _mergeLineAmountExcludeTax.apply(this, arguments);
|
|
1964
1967
|
}
|
|
1965
1968
|
|
|
1966
|
-
function mergeQuantity(
|
|
1969
|
+
function mergeQuantity(_x9) {
|
|
1967
1970
|
return _mergeQuantity.apply(this, arguments);
|
|
1968
1971
|
}
|
|
1969
1972
|
/** 填充行明细信息 */
|
|
@@ -1992,7 +1995,7 @@ function _mergeQuantity() {
|
|
|
1992
1995
|
return _mergeQuantity.apply(this, arguments);
|
|
1993
1996
|
}
|
|
1994
1997
|
|
|
1995
|
-
function fillingInformationGood(
|
|
1998
|
+
function fillingInformationGood(_x10, _x11) {
|
|
1996
1999
|
return _fillingInformationGood.apply(this, arguments);
|
|
1997
2000
|
}
|
|
1998
2001
|
/** 存在税率不一样的明细,不能合并 */
|
|
@@ -2023,7 +2026,7 @@ function _fillingInformationGood() {
|
|
|
2023
2026
|
return _fillingInformationGood.apply(this, arguments);
|
|
2024
2027
|
}
|
|
2025
2028
|
|
|
2026
|
-
function checkTaxTate(
|
|
2029
|
+
function checkTaxTate(_x12) {
|
|
2027
2030
|
return _checkTaxTate.apply(this, arguments);
|
|
2028
2031
|
}
|
|
2029
2032
|
/** 校验数据 是否数量和金额是否同号 */
|
|
@@ -2067,7 +2070,7 @@ function _checkTaxTate() {
|
|
|
2067
2070
|
return _checkTaxTate.apply(this, arguments);
|
|
2068
2071
|
}
|
|
2069
2072
|
|
|
2070
|
-
function checkSameNumber(
|
|
2073
|
+
function checkSameNumber(_x13) {
|
|
2071
2074
|
return _checkSameNumber.apply(this, arguments);
|
|
2072
2075
|
}
|
|
2073
2076
|
/** 显示错误信息 */
|
|
@@ -10798,38 +10801,37 @@ function ItemCodeInput(props) {
|
|
|
10798
10801
|
while (1) {
|
|
10799
10802
|
switch (_context.prev = _context.next) {
|
|
10800
10803
|
case 0:
|
|
10801
|
-
|
|
10802
|
-
_context.prev = 1;
|
|
10804
|
+
_context.prev = 0;
|
|
10803
10805
|
|
|
10804
10806
|
if (!autoComplete.onItemCodeSearch) {
|
|
10805
|
-
_context.next =
|
|
10807
|
+
_context.next = 7;
|
|
10806
10808
|
break;
|
|
10807
10809
|
}
|
|
10808
10810
|
|
|
10809
10811
|
_context.t0 = setOptions;
|
|
10810
|
-
_context.next =
|
|
10812
|
+
_context.next = 5;
|
|
10811
10813
|
return autoComplete.onItemCodeSearch(searchText, editGood === null || editGood === void 0 ? void 0 : editGood.itemName);
|
|
10812
10814
|
|
|
10813
|
-
case
|
|
10815
|
+
case 5:
|
|
10814
10816
|
_context.t1 = _context.sent;
|
|
10815
10817
|
(0, _context.t0)(_context.t1);
|
|
10816
10818
|
|
|
10817
|
-
case
|
|
10818
|
-
_context.next =
|
|
10819
|
+
case 7:
|
|
10820
|
+
_context.next = 13;
|
|
10819
10821
|
break;
|
|
10820
10822
|
|
|
10821
|
-
case
|
|
10822
|
-
_context.prev =
|
|
10823
|
-
_context.t2 = _context["catch"](
|
|
10823
|
+
case 9:
|
|
10824
|
+
_context.prev = 9;
|
|
10825
|
+
_context.t2 = _context["catch"](0);
|
|
10824
10826
|
setOptions([]);
|
|
10825
10827
|
throw _context.t2;
|
|
10826
10828
|
|
|
10827
|
-
case
|
|
10829
|
+
case 13:
|
|
10828
10830
|
case "end":
|
|
10829
10831
|
return _context.stop();
|
|
10830
10832
|
}
|
|
10831
10833
|
}
|
|
10832
|
-
}, _callee, null, [[
|
|
10834
|
+
}, _callee, null, [[0, 9]]);
|
|
10833
10835
|
}));
|
|
10834
10836
|
|
|
10835
10837
|
return function (_x) {
|
|
@@ -10855,10 +10857,9 @@ function ItemCodeInput(props) {
|
|
|
10855
10857
|
return _context2.abrupt("return");
|
|
10856
10858
|
|
|
10857
10859
|
case 3:
|
|
10858
|
-
debugger;
|
|
10859
10860
|
controller.importGoodsDrawer(record);
|
|
10860
10861
|
|
|
10861
|
-
case
|
|
10862
|
+
case 4:
|
|
10862
10863
|
case "end":
|
|
10863
10864
|
return _context2.stop();
|
|
10864
10865
|
}
|
|
@@ -14550,7 +14551,7 @@ function useMergeDetails() {
|
|
|
14550
14551
|
var isMergeDetails = controller.useMemo(function (s) {
|
|
14551
14552
|
return s.goodsListState.isMergeDetails;
|
|
14552
14553
|
}, []);
|
|
14553
|
-
var
|
|
14554
|
+
var onClickManual = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
14554
14555
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14555
14556
|
while (1) {
|
|
14556
14557
|
switch (_context.prev = _context.next) {
|
|
@@ -14564,7 +14565,7 @@ function useMergeDetails() {
|
|
|
14564
14565
|
|
|
14565
14566
|
case 4:
|
|
14566
14567
|
_context.next = 6;
|
|
14567
|
-
return controller.mergeDetails();
|
|
14568
|
+
return controller.mergeDetails(controller.state.goodsListState.selectedGoodIndex);
|
|
14568
14569
|
|
|
14569
14570
|
case 6:
|
|
14570
14571
|
case "end":
|
|
@@ -14573,17 +14574,103 @@ function useMergeDetails() {
|
|
|
14573
14574
|
}
|
|
14574
14575
|
}, _callee);
|
|
14575
14576
|
})), [controller]);
|
|
14577
|
+
var onClickAuto = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
14578
|
+
var group, i, _selectedGoodIndex;
|
|
14579
|
+
|
|
14580
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
14581
|
+
while (1) {
|
|
14582
|
+
switch (_context2.prev = _context2.next) {
|
|
14583
|
+
case 0:
|
|
14584
|
+
_context2.next = 2;
|
|
14585
|
+
return controller.saveEditGood();
|
|
14586
|
+
|
|
14587
|
+
case 2:
|
|
14588
|
+
_context2.next = 4;
|
|
14589
|
+
return controller.wait();
|
|
14590
|
+
|
|
14591
|
+
case 4:
|
|
14592
|
+
group = groupBy(controller.state.goodsListState.goodsList);
|
|
14593
|
+
i = 0;
|
|
14594
|
+
|
|
14595
|
+
case 6:
|
|
14596
|
+
if (!(i < group.length)) {
|
|
14597
|
+
_context2.next = 13;
|
|
14598
|
+
break;
|
|
14599
|
+
}
|
|
14600
|
+
|
|
14601
|
+
_selectedGoodIndex = group[i].map(function (e) {
|
|
14602
|
+
return e.$index;
|
|
14603
|
+
});
|
|
14604
|
+
_context2.next = 10;
|
|
14605
|
+
return controller.mergeDetails(_selectedGoodIndex);
|
|
14606
|
+
|
|
14607
|
+
case 10:
|
|
14608
|
+
i++;
|
|
14609
|
+
_context2.next = 6;
|
|
14610
|
+
break;
|
|
14611
|
+
|
|
14612
|
+
case 13:
|
|
14613
|
+
case "end":
|
|
14614
|
+
return _context2.stop();
|
|
14615
|
+
}
|
|
14616
|
+
}
|
|
14617
|
+
}, _callee2);
|
|
14618
|
+
})), []);
|
|
14619
|
+
var items = React__default['default'].useMemo(function () {
|
|
14620
|
+
return [{
|
|
14621
|
+
key: '0',
|
|
14622
|
+
label: '自动合并',
|
|
14623
|
+
onClick: onClickAuto
|
|
14624
|
+
}, {
|
|
14625
|
+
key: '1',
|
|
14626
|
+
label: '手动合并',
|
|
14627
|
+
disabled: selectedGoodIndex.length <= 1,
|
|
14628
|
+
onClick: onClickManual
|
|
14629
|
+
}];
|
|
14630
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto]);
|
|
14576
14631
|
var button = React__default['default'].useMemo(function () {
|
|
14577
14632
|
if (!isMergeDetails) return React__default['default'].createElement(React__default['default'].Fragment, null);
|
|
14578
|
-
return React__default['default'].createElement(
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14633
|
+
return React__default['default'].createElement(ktsXui.Dropdown, {
|
|
14634
|
+
menu: {
|
|
14635
|
+
items: items
|
|
14636
|
+
},
|
|
14637
|
+
trigger: ['click']
|
|
14638
|
+
}, React__default['default'].createElement(ktsComponentsAntdX3.Button, null, "\u5408\u5E76\u660E\u7EC6"));
|
|
14582
14639
|
}, [selectedGoodIndex.length, isMergeDetails]);
|
|
14583
14640
|
return {
|
|
14584
14641
|
/** 按钮 */
|
|
14585
14642
|
button: button
|
|
14586
14643
|
};
|
|
14644
|
+
} // 根据"商品编码"" 和 "单价" 分组
|
|
14645
|
+
|
|
14646
|
+
function groupBy(arr) {
|
|
14647
|
+
var grouped = {}; // for (const item of arr) {
|
|
14648
|
+
// if (!item.itemCode) continue;
|
|
14649
|
+
// const key = `${item.itemCode}${item.priceIncludeTax}${item.priceExcludeTax}`;
|
|
14650
|
+
// if (!grouped[key]) {
|
|
14651
|
+
// grouped[key] = [];
|
|
14652
|
+
// }
|
|
14653
|
+
// grouped[key].push(item);
|
|
14654
|
+
// }
|
|
14655
|
+
|
|
14656
|
+
for (var i = 0; i < arr.length; i++) {
|
|
14657
|
+
var item = arr[i];
|
|
14658
|
+
if (!item.itemCode) continue;
|
|
14659
|
+
var key = "".concat(item.itemCode).concat(item.priceIncludeTax).concat(item.priceExcludeTax);
|
|
14660
|
+
|
|
14661
|
+
if (!grouped[key]) {
|
|
14662
|
+
grouped[key] = [];
|
|
14663
|
+
}
|
|
14664
|
+
|
|
14665
|
+
grouped[key].push(item);
|
|
14666
|
+
|
|
14667
|
+
if (item.lineAttribute === LineAttributeType$1.被折扣行) {
|
|
14668
|
+
grouped[key].push(arr[i + 1]);
|
|
14669
|
+
i++;
|
|
14670
|
+
}
|
|
14671
|
+
}
|
|
14672
|
+
|
|
14673
|
+
return Object.values(grouped);
|
|
14587
14674
|
}
|
|
14588
14675
|
|
|
14589
14676
|
/** 全单合并折扣 */
|
package/package.json
CHANGED
|
@@ -5,11 +5,13 @@ import idGenerator from '../../tools/idGenerator';
|
|
|
5
5
|
import { IGood, InvoiceControllerState, LineAttributeType } from '..';
|
|
6
6
|
import { format15 } from '../../tools/calculate';
|
|
7
7
|
|
|
8
|
-
export default async function mergeDetails(state: InvoiceControllerState) {
|
|
9
|
-
|
|
8
|
+
export default async function mergeDetails(state: InvoiceControllerState, selectedGoodIndex?: string[]) {
|
|
9
|
+
debugger;
|
|
10
|
+
if (state.goodsListState.editGood || !selectedGoodIndex || selectedGoodIndex.length < 2) return;
|
|
10
11
|
|
|
11
12
|
// const goodsList = state.goodsListState.selectedGoodIndex.map(e => state.goodsListState.goodsMap.get(e)).filter(e => !!e) as IGood[];
|
|
12
|
-
const goodsList = state.goodsListState.goodsList.filter(e => state.goodsListState.selectedGoodIndex.indexOf(e.$index) >= 0)
|
|
13
|
+
// const goodsList = state.goodsListState.goodsList.filter(e => state.goodsListState.selectedGoodIndex.indexOf(e.$index) >= 0)
|
|
14
|
+
const goodsList = state.goodsListState.goodsList.filter(e => selectedGoodIndex.indexOf(e.$index) >= 0);
|
|
13
15
|
if (goodsList.length < 2) return;
|
|
14
16
|
|
|
15
17
|
try {
|
|
@@ -44,7 +46,7 @@ export default async function mergeDetails(state: InvoiceControllerState) {
|
|
|
44
46
|
await checkSameNumber(sum);
|
|
45
47
|
|
|
46
48
|
const p = state.goodsListState.goodsList.indexOf(goodsList[0]);
|
|
47
|
-
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(e =>
|
|
49
|
+
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(e => selectedGoodIndex.indexOf(e.$index) < 0);
|
|
48
50
|
state.goodsListState.goodsList.splice(p, 0, sum);
|
|
49
51
|
state.goodsListState.goodsList = state.goodsListState.goodsList.filter(e => e.lineAmountExcludeTax !== 0);
|
|
50
52
|
state.goodsListState.goodsMap = new Map();
|
|
@@ -52,7 +52,7 @@ export default class InvoiceController extends InvoiceControllerForm {
|
|
|
52
52
|
addGood = this.pipeline(addGood);
|
|
53
53
|
|
|
54
54
|
/** 全单合并明细 */
|
|
55
|
-
mergeDetails = this.pipeline
|
|
55
|
+
mergeDetails = this.pipeline(mergeDetails);
|
|
56
56
|
|
|
57
57
|
/** 全单合并折扣 */
|
|
58
58
|
mergeDiscount = this.pipeline<any>(mergeDiscount);
|
|
@@ -21,7 +21,6 @@ export default function ItemCodeInput(props: { onChange?: (e: ChangeEvent<HTMLIn
|
|
|
21
21
|
}, [])
|
|
22
22
|
|
|
23
23
|
const onSearch = React.useCallback(async (searchText: string) => {
|
|
24
|
-
debugger;
|
|
25
24
|
try {
|
|
26
25
|
if (autoComplete.onItemCodeSearch) {
|
|
27
26
|
setOptions(await autoComplete.onItemCodeSearch(searchText, editGood?.itemName))
|
|
@@ -35,7 +34,6 @@ export default function ItemCodeInput(props: { onChange?: (e: ChangeEvent<HTMLIn
|
|
|
35
34
|
const onChangeAutoComplete = React.useCallback(async itemName => {
|
|
36
35
|
const record = options.filter(e => e.itemCode === itemName)[0] as any;
|
|
37
36
|
if (!record) return;
|
|
38
|
-
debugger;
|
|
39
37
|
controller.importGoodsDrawer(record);
|
|
40
38
|
}, [options, controller])
|
|
41
39
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import React from "react"
|
|
3
3
|
import { Button } from "kts-components-antd-x3"
|
|
4
4
|
import Invoice from '../../../../../../..'
|
|
5
|
+
import { Dropdown, MenuProps } from "kts-xui";
|
|
6
|
+
import { IGood, LineAttributeType } from "../../../../../../../InvoiceController";
|
|
5
7
|
|
|
6
8
|
/** 全单合并明细 */
|
|
7
9
|
export default function useMergeDetails() {
|
|
@@ -12,21 +14,45 @@ export default function useMergeDetails() {
|
|
|
12
14
|
|
|
13
15
|
const isMergeDetails = controller.useMemo(s => s.goodsListState.isMergeDetails, []);
|
|
14
16
|
|
|
15
|
-
const
|
|
17
|
+
const onClickManual = React.useCallback(async () => {
|
|
16
18
|
await controller.saveEditGood();
|
|
17
19
|
await controller.wait();
|
|
18
|
-
await controller.mergeDetails();
|
|
20
|
+
await controller.mergeDetails(controller.state.goodsListState.selectedGoodIndex);
|
|
19
21
|
}, [controller])
|
|
20
22
|
|
|
23
|
+
const onClickAuto = React.useCallback(async () => {
|
|
24
|
+
await controller.saveEditGood();
|
|
25
|
+
await controller.wait();
|
|
26
|
+
const group = groupBy(controller.state.goodsListState.goodsList);
|
|
27
|
+
for (let i = 0; i < group.length; i++) {
|
|
28
|
+
const selectedGoodIndex = group[i].map(e => e.$index);
|
|
29
|
+
await controller.mergeDetails(selectedGoodIndex);
|
|
30
|
+
}
|
|
31
|
+
}, [])
|
|
32
|
+
|
|
33
|
+
const items: MenuProps['items'] = React.useMemo(() => {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
key: '0',
|
|
37
|
+
label: '自动合并',
|
|
38
|
+
onClick: onClickAuto,
|
|
39
|
+
}, {
|
|
40
|
+
key: '1',
|
|
41
|
+
label: '手动合并',
|
|
42
|
+
disabled: selectedGoodIndex.length <= 1,
|
|
43
|
+
onClick: onClickManual,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
}, [selectedGoodIndex, onClickManual, onClickAuto])
|
|
47
|
+
|
|
21
48
|
const button = React.useMemo(() => {
|
|
22
49
|
if (!isMergeDetails) return <></>;
|
|
23
50
|
return (
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</Button>
|
|
51
|
+
<Dropdown menu={{ items }} trigger={['click']} >
|
|
52
|
+
<Button>
|
|
53
|
+
合并明细
|
|
54
|
+
</Button>
|
|
55
|
+
</Dropdown>
|
|
30
56
|
)
|
|
31
57
|
}, [selectedGoodIndex.length, isMergeDetails])
|
|
32
58
|
|
|
@@ -35,3 +61,29 @@ export default function useMergeDetails() {
|
|
|
35
61
|
button,
|
|
36
62
|
}
|
|
37
63
|
}
|
|
64
|
+
|
|
65
|
+
// 根据"商品编码"" 和 "单价" 分组
|
|
66
|
+
function groupBy(arr: IGood[]): IGood[][] {
|
|
67
|
+
const grouped: any = {};
|
|
68
|
+
// for (const item of arr) {
|
|
69
|
+
// if (!item.itemCode) continue;
|
|
70
|
+
// const key = `${item.itemCode}${item.priceIncludeTax}${item.priceExcludeTax}`;
|
|
71
|
+
// if (!grouped[key]) {
|
|
72
|
+
// grouped[key] = [];
|
|
73
|
+
// }
|
|
74
|
+
// grouped[key].push(item);
|
|
75
|
+
// }
|
|
76
|
+
for (let i = 0; i < arr.length; i++) {
|
|
77
|
+
const item = arr[i];
|
|
78
|
+
if (!item.itemCode) continue;
|
|
79
|
+
const key = `${item.itemCode}${item.priceIncludeTax}${item.priceExcludeTax}`;
|
|
80
|
+
if (!grouped[key]) {
|
|
81
|
+
grouped[key] = [];
|
|
82
|
+
}
|
|
83
|
+
grouped[key].push(item);
|
|
84
|
+
if (item.lineAttribute === LineAttributeType.被折扣行) {
|
|
85
|
+
grouped[key].push(arr[i + 1]); i++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return Object.values(grouped);
|
|
89
|
+
}
|