kts-component-invoice-operate 3.2.97 → 3.2.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.d.ts +3 -2
- package/dist/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.d.ts +1 -1
- package/dist/index.esm.js +120 -55
- package/dist/index.js +120 -55
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/AutoComplete/index.ts +4 -1
- package/src/Invoice/_test/setDataSource/index.tsx +7 -0
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/index.tsx +1 -0
- package/src/Invoice/ui/default/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +44 -34
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import IGood from "../GoodsListState/IGood";
|
|
2
1
|
/** 自动补全 */
|
|
3
2
|
export default class AutoComplete {
|
|
4
3
|
/** 商品名称自动补全 */
|
|
5
|
-
onItemNameSearch?: (searchText: string) => Promise<
|
|
4
|
+
onItemNameSearch?: (searchText: string) => Promise<any[]>;
|
|
5
|
+
/** 购方名称智能赋码 */
|
|
6
|
+
onItemNameBlur?: (searchText: string) => Promise<any[]>;
|
|
6
7
|
/** 购方名称自动补全 */
|
|
7
8
|
onBuyerNameSearch?: (searchText: string) => Promise<any[]>;
|
|
8
9
|
/** 统一社会信用代码/纳税人识别号 */
|
package/dist/index.esm.js
CHANGED
|
@@ -1189,6 +1189,7 @@ var AutoComplete = /*#__PURE__*/_createClass(function AutoComplete() {
|
|
|
1189
1189
|
_classCallCheck(this, AutoComplete);
|
|
1190
1190
|
|
|
1191
1191
|
this.onItemNameSearch = void 0;
|
|
1192
|
+
this.onItemNameBlur = void 0;
|
|
1192
1193
|
this.onBuyerNameSearch = void 0;
|
|
1193
1194
|
this.onBuyerTaxIdSearch = void 0;
|
|
1194
1195
|
this.onItemCodeSearch = void 0;
|
|
@@ -10811,8 +10812,6 @@ var TitleText = (function (props) {
|
|
|
10811
10812
|
var css_248z$7 = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select {\n width: 100%;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select .ktsAntX-select-selector {\n height: 100%;\n}\n.has-error .kts-invoice-operate-goods-list-itemName-input {\n border: 1px solid #f5222d;\n}\n";
|
|
10812
10813
|
styleInject(css_248z$7);
|
|
10813
10814
|
|
|
10814
|
-
// import evaluate from '../../../../../../../tools/evaluate';
|
|
10815
|
-
|
|
10816
10815
|
function ItemNameInput(props) {
|
|
10817
10816
|
var controller = Invoice.useInvoiceController();
|
|
10818
10817
|
var autoComplete = controller.useMemo(function (s) {
|
|
@@ -10824,103 +10823,181 @@ function ItemNameInput(props) {
|
|
|
10824
10823
|
options = _React$useState2[0],
|
|
10825
10824
|
setOptions = _React$useState2[1];
|
|
10826
10825
|
|
|
10826
|
+
var _React$useState3 = React.useState(null),
|
|
10827
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
10828
|
+
selectLine = _React$useState4[0],
|
|
10829
|
+
setSelectLine = _React$useState4[1];
|
|
10830
|
+
|
|
10831
|
+
var _React$useState5 = React.useState(props.value),
|
|
10832
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
10833
|
+
value = _React$useState6[0],
|
|
10834
|
+
setValue = _React$useState6[1];
|
|
10835
|
+
|
|
10827
10836
|
var onChange = React.useCallback(function (e) {
|
|
10828
10837
|
var event = _objectSpread2({}, e);
|
|
10829
10838
|
|
|
10830
10839
|
props.onChange && props.onChange(event);
|
|
10831
10840
|
}, []);
|
|
10832
|
-
var
|
|
10841
|
+
var onBlur = React.useCallback( /*#__PURE__*/function () {
|
|
10833
10842
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchText) {
|
|
10834
|
-
var
|
|
10843
|
+
var taxCategoryData, params;
|
|
10835
10844
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10836
10845
|
while (1) {
|
|
10837
10846
|
switch (_context.prev = _context.next) {
|
|
10838
10847
|
case 0:
|
|
10839
10848
|
_context.prev = 0;
|
|
10840
10849
|
|
|
10841
|
-
if (!
|
|
10842
|
-
_context.next =
|
|
10850
|
+
if (!autoComplete.onItemNameBlur) {
|
|
10851
|
+
_context.next = 8;
|
|
10852
|
+
break;
|
|
10853
|
+
}
|
|
10854
|
+
|
|
10855
|
+
if (selectLine === null || selectLine === void 0 ? void 0 : selectLine.shorthand) {
|
|
10856
|
+
_context.next = 7;
|
|
10843
10857
|
break;
|
|
10844
10858
|
}
|
|
10845
10859
|
|
|
10846
|
-
_context.t0 = _toConsumableArray;
|
|
10847
10860
|
_context.next = 5;
|
|
10861
|
+
return autoComplete.onItemNameBlur(searchText);
|
|
10862
|
+
|
|
10863
|
+
case 5:
|
|
10864
|
+
taxCategoryData = _context.sent;
|
|
10865
|
+
|
|
10866
|
+
if (taxCategoryData && taxCategoryData[0]) {
|
|
10867
|
+
params = _objectSpread2(_objectSpread2({}, props.editGood), {}, {
|
|
10868
|
+
taxClassificationCode: taxCategoryData[0].taxCategoryCode,
|
|
10869
|
+
shorthand: taxCategoryData[0].shorthand
|
|
10870
|
+
});
|
|
10871
|
+
controller.importGoodsDrawer(params);
|
|
10872
|
+
}
|
|
10873
|
+
|
|
10874
|
+
case 7:
|
|
10875
|
+
setSelectLine(null);
|
|
10876
|
+
|
|
10877
|
+
case 8:
|
|
10878
|
+
_context.next = 13;
|
|
10879
|
+
break;
|
|
10880
|
+
|
|
10881
|
+
case 10:
|
|
10882
|
+
_context.prev = 10;
|
|
10883
|
+
_context.t0 = _context["catch"](0);
|
|
10884
|
+
throw _context.t0;
|
|
10885
|
+
|
|
10886
|
+
case 13:
|
|
10887
|
+
case "end":
|
|
10888
|
+
return _context.stop();
|
|
10889
|
+
}
|
|
10890
|
+
}
|
|
10891
|
+
}, _callee, null, [[0, 10]]);
|
|
10892
|
+
}));
|
|
10893
|
+
|
|
10894
|
+
return function (_x) {
|
|
10895
|
+
return _ref.apply(this, arguments);
|
|
10896
|
+
};
|
|
10897
|
+
}(), [autoComplete.onItemNameBlur, selectLine, props.editGood]);
|
|
10898
|
+
var onSearch = React.useCallback( /*#__PURE__*/function () {
|
|
10899
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(searchText) {
|
|
10900
|
+
var list;
|
|
10901
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
10902
|
+
while (1) {
|
|
10903
|
+
switch (_context2.prev = _context2.next) {
|
|
10904
|
+
case 0:
|
|
10905
|
+
_context2.prev = 0;
|
|
10906
|
+
|
|
10907
|
+
if (!(autoComplete.onItemNameSearch && searchText)) {
|
|
10908
|
+
_context2.next = 10;
|
|
10909
|
+
break;
|
|
10910
|
+
}
|
|
10911
|
+
|
|
10912
|
+
_context2.t0 = _toConsumableArray;
|
|
10913
|
+
_context2.next = 5;
|
|
10848
10914
|
return autoComplete.onItemNameSearch(searchText);
|
|
10849
10915
|
|
|
10850
10916
|
case 5:
|
|
10851
|
-
|
|
10852
|
-
list = (0,
|
|
10853
|
-
|
|
10917
|
+
_context2.t1 = _context2.sent;
|
|
10918
|
+
list = (0, _context2.t0)(_context2.t1).map(function (e) {
|
|
10919
|
+
return _objectSpread2(_objectSpread2({}, e), {}, {
|
|
10920
|
+
$index: v4()
|
|
10921
|
+
});
|
|
10922
|
+
});
|
|
10854
10923
|
setOptions(list);
|
|
10855
|
-
|
|
10924
|
+
_context2.next = 11;
|
|
10856
10925
|
break;
|
|
10857
10926
|
|
|
10858
|
-
case
|
|
10927
|
+
case 10:
|
|
10859
10928
|
setOptions([]);
|
|
10860
10929
|
|
|
10861
|
-
case
|
|
10862
|
-
|
|
10930
|
+
case 11:
|
|
10931
|
+
_context2.next = 17;
|
|
10863
10932
|
break;
|
|
10864
10933
|
|
|
10865
|
-
case
|
|
10866
|
-
|
|
10867
|
-
|
|
10934
|
+
case 13:
|
|
10935
|
+
_context2.prev = 13;
|
|
10936
|
+
_context2.t2 = _context2["catch"](0);
|
|
10868
10937
|
setOptions([]);
|
|
10869
|
-
throw
|
|
10938
|
+
throw _context2.t2;
|
|
10870
10939
|
|
|
10871
|
-
case
|
|
10940
|
+
case 17:
|
|
10872
10941
|
case "end":
|
|
10873
|
-
return
|
|
10942
|
+
return _context2.stop();
|
|
10874
10943
|
}
|
|
10875
10944
|
}
|
|
10876
|
-
},
|
|
10945
|
+
}, _callee2, null, [[0, 13]]);
|
|
10877
10946
|
}));
|
|
10878
10947
|
|
|
10879
|
-
return function (
|
|
10880
|
-
return
|
|
10948
|
+
return function (_x2) {
|
|
10949
|
+
return _ref2.apply(this, arguments);
|
|
10881
10950
|
};
|
|
10882
10951
|
}(), [autoComplete.onItemNameSearch]);
|
|
10883
10952
|
var onChangeAutoComplete = React.useCallback( /*#__PURE__*/function () {
|
|
10884
|
-
var
|
|
10953
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_, i) {
|
|
10885
10954
|
var record;
|
|
10886
|
-
return _regeneratorRuntime().wrap(function
|
|
10955
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
10887
10956
|
while (1) {
|
|
10888
|
-
switch (
|
|
10957
|
+
switch (_context3.prev = _context3.next) {
|
|
10889
10958
|
case 0:
|
|
10890
10959
|
record = options.filter(function (e) {
|
|
10891
|
-
return e
|
|
10960
|
+
return e.$index === i.value;
|
|
10892
10961
|
})[0];
|
|
10893
10962
|
|
|
10894
10963
|
if (record) {
|
|
10895
|
-
|
|
10964
|
+
_context3.next = 3;
|
|
10896
10965
|
break;
|
|
10897
10966
|
}
|
|
10898
10967
|
|
|
10899
|
-
return
|
|
10968
|
+
return _context3.abrupt("return");
|
|
10900
10969
|
|
|
10901
10970
|
case 3:
|
|
10902
|
-
|
|
10971
|
+
_context3.next = 5;
|
|
10903
10972
|
return controller.setEditGood({
|
|
10904
10973
|
itemName: record.itemName
|
|
10905
10974
|
});
|
|
10906
10975
|
|
|
10907
10976
|
case 5:
|
|
10977
|
+
_context3.next = 7;
|
|
10978
|
+
return controller.importGoodsDrawer(record);
|
|
10979
|
+
|
|
10980
|
+
case 7:
|
|
10981
|
+
setValue(record.itemName);
|
|
10982
|
+
setSelectLine(record[0]);
|
|
10908
10983
|
controller.importGoodsDrawer(record);
|
|
10909
10984
|
setOptions([]);
|
|
10910
10985
|
|
|
10911
|
-
case
|
|
10986
|
+
case 11:
|
|
10912
10987
|
case "end":
|
|
10913
|
-
return
|
|
10988
|
+
return _context3.stop();
|
|
10914
10989
|
}
|
|
10915
10990
|
}
|
|
10916
|
-
},
|
|
10991
|
+
}, _callee3);
|
|
10917
10992
|
}));
|
|
10918
10993
|
|
|
10919
|
-
return function (
|
|
10920
|
-
return
|
|
10994
|
+
return function (_x3, _x4) {
|
|
10995
|
+
return _ref3.apply(this, arguments);
|
|
10921
10996
|
};
|
|
10922
10997
|
}(), [options, controller]);
|
|
10923
|
-
|
|
10998
|
+
React.useEffect(function () {
|
|
10999
|
+
setValue(props.value);
|
|
11000
|
+
}, [props.value]);
|
|
10924
11001
|
return React.createElement("div", {
|
|
10925
11002
|
className: 'kts-invoice-operate-goods-list-itemName-input'
|
|
10926
11003
|
}, props.shorthand && React.createElement("span", {
|
|
@@ -10930,10 +11007,11 @@ function ItemNameInput(props) {
|
|
|
10930
11007
|
}
|
|
10931
11008
|
}, "*", props.shorthand, "*"), React.createElement(AutoComplete$1, {
|
|
10932
11009
|
onSearch: onSearch,
|
|
10933
|
-
value:
|
|
11010
|
+
value: value,
|
|
10934
11011
|
options: options.map(function (e) {
|
|
10935
11012
|
return {
|
|
10936
|
-
value: e
|
|
11013
|
+
value: e.$index,
|
|
11014
|
+
label: e.itemName
|
|
10937
11015
|
};
|
|
10938
11016
|
}),
|
|
10939
11017
|
onSelect: onChangeAutoComplete
|
|
@@ -10942,24 +11020,10 @@ function ItemNameInput(props) {
|
|
|
10942
11020
|
height: '100%',
|
|
10943
11021
|
border: 'none'
|
|
10944
11022
|
},
|
|
10945
|
-
onChange: onChange
|
|
11023
|
+
onChange: onChange,
|
|
11024
|
+
onBlur: onBlur
|
|
10946
11025
|
})));
|
|
10947
|
-
}
|
|
10948
|
-
// const filteredObj: Record<string, any> = {};
|
|
10949
|
-
// for (const key in obj) {
|
|
10950
|
-
// if (obj[key] !== null && obj[key] !== undefined) {
|
|
10951
|
-
// filteredObj[key] = obj[key];
|
|
10952
|
-
// }
|
|
10953
|
-
// }
|
|
10954
|
-
// return filteredObj;
|
|
10955
|
-
// }
|
|
10956
|
-
|
|
10957
|
-
/** 货物单价,不含税 */
|
|
10958
|
-
// const getPriceExcludeTax = (s: IGood, record: any, calculatingDigits?: number) => {
|
|
10959
|
-
// if ((!s.taxRate && s.taxRate !== 0) || (!record.priceIncludeTax && record.priceIncludeTax !== 0)) return;
|
|
10960
|
-
// // 单价(含税)/(1+税率) = 单价(不含税)
|
|
10961
|
-
// return format15(evaluate(`${record.priceIncludeTax} / (1+${s.taxRate}/100)`), calculatingDigits);
|
|
10962
|
-
// };
|
|
11026
|
+
}
|
|
10963
11027
|
|
|
10964
11028
|
var css_248z$8 = ".kts-invoice-operate-goods-list-itemCode-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.kts-invoice-operate-goods-list-itemCode-input .ktsAntX-select {\n width: 100%;\n}\n.kts-invoice-operate-goods-list-itemCode-input .ktsAntX-select .ktsAntX-select-selector {\n height: 100%;\n}\n.has-error .kts-invoice-operate-goods-list-itemCode-input {\n border: 1px solid #f5222d;\n}\n";
|
|
10965
11029
|
styleInject(css_248z$8);
|
|
@@ -12791,6 +12855,7 @@ var useColumns = (function (form) {
|
|
|
12791
12855
|
}()
|
|
12792
12856
|
}])
|
|
12793
12857
|
})(React.createElement(ItemNameInput, {
|
|
12858
|
+
editGood: editGood,
|
|
12794
12859
|
shorthand: editGood.shorthand,
|
|
12795
12860
|
onChange: function onChange() {
|
|
12796
12861
|
onChangeItemName(controller, form, record);
|
package/dist/index.js
CHANGED
|
@@ -1199,6 +1199,7 @@ var AutoComplete = /*#__PURE__*/_createClass(function AutoComplete() {
|
|
|
1199
1199
|
_classCallCheck(this, AutoComplete);
|
|
1200
1200
|
|
|
1201
1201
|
this.onItemNameSearch = void 0;
|
|
1202
|
+
this.onItemNameBlur = void 0;
|
|
1202
1203
|
this.onBuyerNameSearch = void 0;
|
|
1203
1204
|
this.onBuyerTaxIdSearch = void 0;
|
|
1204
1205
|
this.onItemCodeSearch = void 0;
|
|
@@ -10821,8 +10822,6 @@ var TitleText = (function (props) {
|
|
|
10821
10822
|
var css_248z$7 = ".kts-invoice-operate-goods-list-itemName-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select {\n width: 100%;\n}\n.kts-invoice-operate-goods-list-itemName-input .ktsAntX-select .ktsAntX-select-selector {\n height: 100%;\n}\n.has-error .kts-invoice-operate-goods-list-itemName-input {\n border: 1px solid #f5222d;\n}\n";
|
|
10822
10823
|
styleInject(css_248z$7);
|
|
10823
10824
|
|
|
10824
|
-
// import evaluate from '../../../../../../../tools/evaluate';
|
|
10825
|
-
|
|
10826
10825
|
function ItemNameInput(props) {
|
|
10827
10826
|
var controller = Invoice.useInvoiceController();
|
|
10828
10827
|
var autoComplete = controller.useMemo(function (s) {
|
|
@@ -10834,103 +10833,181 @@ function ItemNameInput(props) {
|
|
|
10834
10833
|
options = _React$useState2[0],
|
|
10835
10834
|
setOptions = _React$useState2[1];
|
|
10836
10835
|
|
|
10836
|
+
var _React$useState3 = React__default['default'].useState(null),
|
|
10837
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
10838
|
+
selectLine = _React$useState4[0],
|
|
10839
|
+
setSelectLine = _React$useState4[1];
|
|
10840
|
+
|
|
10841
|
+
var _React$useState5 = React__default['default'].useState(props.value),
|
|
10842
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
10843
|
+
value = _React$useState6[0],
|
|
10844
|
+
setValue = _React$useState6[1];
|
|
10845
|
+
|
|
10837
10846
|
var onChange = React__default['default'].useCallback(function (e) {
|
|
10838
10847
|
var event = _objectSpread2({}, e);
|
|
10839
10848
|
|
|
10840
10849
|
props.onChange && props.onChange(event);
|
|
10841
10850
|
}, []);
|
|
10842
|
-
var
|
|
10851
|
+
var onBlur = React__default['default'].useCallback( /*#__PURE__*/function () {
|
|
10843
10852
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchText) {
|
|
10844
|
-
var
|
|
10853
|
+
var taxCategoryData, params;
|
|
10845
10854
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
10846
10855
|
while (1) {
|
|
10847
10856
|
switch (_context.prev = _context.next) {
|
|
10848
10857
|
case 0:
|
|
10849
10858
|
_context.prev = 0;
|
|
10850
10859
|
|
|
10851
|
-
if (!
|
|
10852
|
-
_context.next =
|
|
10860
|
+
if (!autoComplete.onItemNameBlur) {
|
|
10861
|
+
_context.next = 8;
|
|
10862
|
+
break;
|
|
10863
|
+
}
|
|
10864
|
+
|
|
10865
|
+
if (selectLine === null || selectLine === void 0 ? void 0 : selectLine.shorthand) {
|
|
10866
|
+
_context.next = 7;
|
|
10853
10867
|
break;
|
|
10854
10868
|
}
|
|
10855
10869
|
|
|
10856
|
-
_context.t0 = _toConsumableArray;
|
|
10857
10870
|
_context.next = 5;
|
|
10871
|
+
return autoComplete.onItemNameBlur(searchText);
|
|
10872
|
+
|
|
10873
|
+
case 5:
|
|
10874
|
+
taxCategoryData = _context.sent;
|
|
10875
|
+
|
|
10876
|
+
if (taxCategoryData && taxCategoryData[0]) {
|
|
10877
|
+
params = _objectSpread2(_objectSpread2({}, props.editGood), {}, {
|
|
10878
|
+
taxClassificationCode: taxCategoryData[0].taxCategoryCode,
|
|
10879
|
+
shorthand: taxCategoryData[0].shorthand
|
|
10880
|
+
});
|
|
10881
|
+
controller.importGoodsDrawer(params);
|
|
10882
|
+
}
|
|
10883
|
+
|
|
10884
|
+
case 7:
|
|
10885
|
+
setSelectLine(null);
|
|
10886
|
+
|
|
10887
|
+
case 8:
|
|
10888
|
+
_context.next = 13;
|
|
10889
|
+
break;
|
|
10890
|
+
|
|
10891
|
+
case 10:
|
|
10892
|
+
_context.prev = 10;
|
|
10893
|
+
_context.t0 = _context["catch"](0);
|
|
10894
|
+
throw _context.t0;
|
|
10895
|
+
|
|
10896
|
+
case 13:
|
|
10897
|
+
case "end":
|
|
10898
|
+
return _context.stop();
|
|
10899
|
+
}
|
|
10900
|
+
}
|
|
10901
|
+
}, _callee, null, [[0, 10]]);
|
|
10902
|
+
}));
|
|
10903
|
+
|
|
10904
|
+
return function (_x) {
|
|
10905
|
+
return _ref.apply(this, arguments);
|
|
10906
|
+
};
|
|
10907
|
+
}(), [autoComplete.onItemNameBlur, selectLine, props.editGood]);
|
|
10908
|
+
var onSearch = React__default['default'].useCallback( /*#__PURE__*/function () {
|
|
10909
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(searchText) {
|
|
10910
|
+
var list;
|
|
10911
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
10912
|
+
while (1) {
|
|
10913
|
+
switch (_context2.prev = _context2.next) {
|
|
10914
|
+
case 0:
|
|
10915
|
+
_context2.prev = 0;
|
|
10916
|
+
|
|
10917
|
+
if (!(autoComplete.onItemNameSearch && searchText)) {
|
|
10918
|
+
_context2.next = 10;
|
|
10919
|
+
break;
|
|
10920
|
+
}
|
|
10921
|
+
|
|
10922
|
+
_context2.t0 = _toConsumableArray;
|
|
10923
|
+
_context2.next = 5;
|
|
10858
10924
|
return autoComplete.onItemNameSearch(searchText);
|
|
10859
10925
|
|
|
10860
10926
|
case 5:
|
|
10861
|
-
|
|
10862
|
-
list = (0,
|
|
10863
|
-
|
|
10927
|
+
_context2.t1 = _context2.sent;
|
|
10928
|
+
list = (0, _context2.t0)(_context2.t1).map(function (e) {
|
|
10929
|
+
return _objectSpread2(_objectSpread2({}, e), {}, {
|
|
10930
|
+
$index: uuid.v4()
|
|
10931
|
+
});
|
|
10932
|
+
});
|
|
10864
10933
|
setOptions(list);
|
|
10865
|
-
|
|
10934
|
+
_context2.next = 11;
|
|
10866
10935
|
break;
|
|
10867
10936
|
|
|
10868
|
-
case
|
|
10937
|
+
case 10:
|
|
10869
10938
|
setOptions([]);
|
|
10870
10939
|
|
|
10871
|
-
case
|
|
10872
|
-
|
|
10940
|
+
case 11:
|
|
10941
|
+
_context2.next = 17;
|
|
10873
10942
|
break;
|
|
10874
10943
|
|
|
10875
|
-
case
|
|
10876
|
-
|
|
10877
|
-
|
|
10944
|
+
case 13:
|
|
10945
|
+
_context2.prev = 13;
|
|
10946
|
+
_context2.t2 = _context2["catch"](0);
|
|
10878
10947
|
setOptions([]);
|
|
10879
|
-
throw
|
|
10948
|
+
throw _context2.t2;
|
|
10880
10949
|
|
|
10881
|
-
case
|
|
10950
|
+
case 17:
|
|
10882
10951
|
case "end":
|
|
10883
|
-
return
|
|
10952
|
+
return _context2.stop();
|
|
10884
10953
|
}
|
|
10885
10954
|
}
|
|
10886
|
-
},
|
|
10955
|
+
}, _callee2, null, [[0, 13]]);
|
|
10887
10956
|
}));
|
|
10888
10957
|
|
|
10889
|
-
return function (
|
|
10890
|
-
return
|
|
10958
|
+
return function (_x2) {
|
|
10959
|
+
return _ref2.apply(this, arguments);
|
|
10891
10960
|
};
|
|
10892
10961
|
}(), [autoComplete.onItemNameSearch]);
|
|
10893
10962
|
var onChangeAutoComplete = React__default['default'].useCallback( /*#__PURE__*/function () {
|
|
10894
|
-
var
|
|
10963
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_, i) {
|
|
10895
10964
|
var record;
|
|
10896
|
-
return _regeneratorRuntime().wrap(function
|
|
10965
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
10897
10966
|
while (1) {
|
|
10898
|
-
switch (
|
|
10967
|
+
switch (_context3.prev = _context3.next) {
|
|
10899
10968
|
case 0:
|
|
10900
10969
|
record = options.filter(function (e) {
|
|
10901
|
-
return e
|
|
10970
|
+
return e.$index === i.value;
|
|
10902
10971
|
})[0];
|
|
10903
10972
|
|
|
10904
10973
|
if (record) {
|
|
10905
|
-
|
|
10974
|
+
_context3.next = 3;
|
|
10906
10975
|
break;
|
|
10907
10976
|
}
|
|
10908
10977
|
|
|
10909
|
-
return
|
|
10978
|
+
return _context3.abrupt("return");
|
|
10910
10979
|
|
|
10911
10980
|
case 3:
|
|
10912
|
-
|
|
10981
|
+
_context3.next = 5;
|
|
10913
10982
|
return controller.setEditGood({
|
|
10914
10983
|
itemName: record.itemName
|
|
10915
10984
|
});
|
|
10916
10985
|
|
|
10917
10986
|
case 5:
|
|
10987
|
+
_context3.next = 7;
|
|
10988
|
+
return controller.importGoodsDrawer(record);
|
|
10989
|
+
|
|
10990
|
+
case 7:
|
|
10991
|
+
setValue(record.itemName);
|
|
10992
|
+
setSelectLine(record[0]);
|
|
10918
10993
|
controller.importGoodsDrawer(record);
|
|
10919
10994
|
setOptions([]);
|
|
10920
10995
|
|
|
10921
|
-
case
|
|
10996
|
+
case 11:
|
|
10922
10997
|
case "end":
|
|
10923
|
-
return
|
|
10998
|
+
return _context3.stop();
|
|
10924
10999
|
}
|
|
10925
11000
|
}
|
|
10926
|
-
},
|
|
11001
|
+
}, _callee3);
|
|
10927
11002
|
}));
|
|
10928
11003
|
|
|
10929
|
-
return function (
|
|
10930
|
-
return
|
|
11004
|
+
return function (_x3, _x4) {
|
|
11005
|
+
return _ref3.apply(this, arguments);
|
|
10931
11006
|
};
|
|
10932
11007
|
}(), [options, controller]);
|
|
10933
|
-
|
|
11008
|
+
React__default['default'].useEffect(function () {
|
|
11009
|
+
setValue(props.value);
|
|
11010
|
+
}, [props.value]);
|
|
10934
11011
|
return React__default['default'].createElement("div", {
|
|
10935
11012
|
className: 'kts-invoice-operate-goods-list-itemName-input'
|
|
10936
11013
|
}, props.shorthand && React__default['default'].createElement("span", {
|
|
@@ -10940,10 +11017,11 @@ function ItemNameInput(props) {
|
|
|
10940
11017
|
}
|
|
10941
11018
|
}, "*", props.shorthand, "*"), React__default['default'].createElement(ktsXui.AutoComplete, {
|
|
10942
11019
|
onSearch: onSearch,
|
|
10943
|
-
value:
|
|
11020
|
+
value: value,
|
|
10944
11021
|
options: options.map(function (e) {
|
|
10945
11022
|
return {
|
|
10946
|
-
value: e
|
|
11023
|
+
value: e.$index,
|
|
11024
|
+
label: e.itemName
|
|
10947
11025
|
};
|
|
10948
11026
|
}),
|
|
10949
11027
|
onSelect: onChangeAutoComplete
|
|
@@ -10952,24 +11030,10 @@ function ItemNameInput(props) {
|
|
|
10952
11030
|
height: '100%',
|
|
10953
11031
|
border: 'none'
|
|
10954
11032
|
},
|
|
10955
|
-
onChange: onChange
|
|
11033
|
+
onChange: onChange,
|
|
11034
|
+
onBlur: onBlur
|
|
10956
11035
|
})));
|
|
10957
|
-
}
|
|
10958
|
-
// const filteredObj: Record<string, any> = {};
|
|
10959
|
-
// for (const key in obj) {
|
|
10960
|
-
// if (obj[key] !== null && obj[key] !== undefined) {
|
|
10961
|
-
// filteredObj[key] = obj[key];
|
|
10962
|
-
// }
|
|
10963
|
-
// }
|
|
10964
|
-
// return filteredObj;
|
|
10965
|
-
// }
|
|
10966
|
-
|
|
10967
|
-
/** 货物单价,不含税 */
|
|
10968
|
-
// const getPriceExcludeTax = (s: IGood, record: any, calculatingDigits?: number) => {
|
|
10969
|
-
// if ((!s.taxRate && s.taxRate !== 0) || (!record.priceIncludeTax && record.priceIncludeTax !== 0)) return;
|
|
10970
|
-
// // 单价(含税)/(1+税率) = 单价(不含税)
|
|
10971
|
-
// return format15(evaluate(`${record.priceIncludeTax} / (1+${s.taxRate}/100)`), calculatingDigits);
|
|
10972
|
-
// };
|
|
11036
|
+
}
|
|
10973
11037
|
|
|
10974
11038
|
var css_248z$8 = ".kts-invoice-operate-goods-list-itemCode-input {\n display: flex;\n flex: 1;\n padding-left: 10px;\n height: 31px;\n}\n.kts-invoice-operate-goods-list-itemCode-input .ktsAntX-select {\n width: 100%;\n}\n.kts-invoice-operate-goods-list-itemCode-input .ktsAntX-select .ktsAntX-select-selector {\n height: 100%;\n}\n.has-error .kts-invoice-operate-goods-list-itemCode-input {\n border: 1px solid #f5222d;\n}\n";
|
|
10975
11039
|
styleInject(css_248z$8);
|
|
@@ -12801,6 +12865,7 @@ var useColumns = (function (form) {
|
|
|
12801
12865
|
}()
|
|
12802
12866
|
}])
|
|
12803
12867
|
})(React__default['default'].createElement(ItemNameInput, {
|
|
12868
|
+
editGood: editGood,
|
|
12804
12869
|
shorthand: editGood.shorthand,
|
|
12805
12870
|
onChange: function onChange() {
|
|
12806
12871
|
onChangeItemName(controller, form, record);
|
package/package.json
CHANGED
|
@@ -4,7 +4,10 @@ import IGood from "../GoodsListState/IGood";
|
|
|
4
4
|
export default class AutoComplete {
|
|
5
5
|
|
|
6
6
|
/** 商品名称自动补全 */
|
|
7
|
-
onItemNameSearch?: (searchText: string) => Promise<
|
|
7
|
+
onItemNameSearch?: (searchText: string) => Promise<any[]>;
|
|
8
|
+
|
|
9
|
+
/** 购方名称智能赋码 */
|
|
10
|
+
onItemNameBlur?: (searchText: string) => Promise<any[]>;
|
|
8
11
|
|
|
9
12
|
/** 购方名称自动补全 */
|
|
10
13
|
onBuyerNameSearch?: (searchText: string) => Promise<any[]>;
|
|
@@ -21,6 +21,13 @@ class MyInvoiceController extends InvoiceController {
|
|
|
21
21
|
super();
|
|
22
22
|
this.state.autoComplete.onItemNameSearch = async text => {
|
|
23
23
|
return [
|
|
24
|
+
{
|
|
25
|
+
"itemName": "呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵",
|
|
26
|
+
"taxClassificationCode": "1010112070000000000",
|
|
27
|
+
"itemModelName": null,
|
|
28
|
+
"shorthand": "蔬菜",
|
|
29
|
+
"taxRate": undefined
|
|
30
|
+
},
|
|
24
31
|
{
|
|
25
32
|
"itemName": "呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵",
|
|
26
33
|
"taxClassificationCode": "1010112070000000000",
|
|
@@ -1,33 +1,55 @@
|
|
|
1
1
|
|
|
2
2
|
import { Input } from 'kts-components-antd-x3';
|
|
3
|
+
import { v4 as uuid } from 'uuid';
|
|
3
4
|
import React, { ChangeEvent } from 'react';
|
|
4
5
|
import { AutoComplete } from 'kts-xui';
|
|
5
|
-
// import { countAmountIncludeTax } from '../../../../../../../tools/calculate'
|
|
6
6
|
import { IGood, Invoice } from '../../../../../../../..';
|
|
7
7
|
import './index.less';
|
|
8
|
-
// import { dutyFree, format15, updateUnitPriceExcludingTax, updateUnitPriceTax } from '../../autoFillFn';
|
|
9
|
-
// import evaluate from '../../../../../../../tools/evaluate';
|
|
10
8
|
|
|
11
|
-
export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLInputElement>) => void, value?: string, shorthand?: string }) {
|
|
9
|
+
export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLInputElement>) => void, value?: string, editGood?: any, shorthand?: string }) {
|
|
12
10
|
|
|
13
11
|
const controller = Invoice.useInvoiceController();
|
|
14
12
|
|
|
15
13
|
const autoComplete = controller.useMemo(s => s.autoComplete, [])
|
|
16
14
|
|
|
17
|
-
const [options, setOptions] = React.useState<IGood[]>([])
|
|
15
|
+
const [options, setOptions] = React.useState<IGood[]>([]);
|
|
16
|
+
|
|
17
|
+
const [selectLine, setSelectLine] = React.useState<any>(null);
|
|
18
|
+
|
|
19
|
+
const [value, setValue] = React.useState(props.value);
|
|
18
20
|
|
|
19
21
|
const onChange = React.useCallback((e: ChangeEvent<HTMLInputElement>) => {
|
|
20
22
|
const event = { ...e };
|
|
21
23
|
props.onChange && props.onChange(event);
|
|
22
24
|
}, [])
|
|
23
25
|
|
|
26
|
+
const onBlur = React.useCallback(async (searchText: any) => {
|
|
27
|
+
try {
|
|
28
|
+
if (autoComplete.onItemNameBlur) {
|
|
29
|
+
if(!selectLine?.shorthand) {
|
|
30
|
+
const taxCategoryData: any = await autoComplete.onItemNameBlur(searchText);
|
|
31
|
+
if(taxCategoryData && taxCategoryData[0]) {
|
|
32
|
+
const params = {
|
|
33
|
+
...props.editGood,
|
|
34
|
+
taxClassificationCode: taxCategoryData[0].taxCategoryCode,
|
|
35
|
+
shorthand: taxCategoryData[0].shorthand
|
|
36
|
+
}
|
|
37
|
+
controller.importGoodsDrawer(params);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
setSelectLine(null);
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}, [autoComplete.onItemNameBlur, selectLine, props.editGood])
|
|
46
|
+
|
|
24
47
|
const onSearch = React.useCallback(async (searchText: string) => {
|
|
25
48
|
try {
|
|
26
49
|
if (autoComplete.onItemNameSearch && searchText) {
|
|
27
|
-
const list = [...await autoComplete.onItemNameSearch(searchText)];
|
|
28
|
-
console.log('===> list', list);
|
|
50
|
+
const list = [...await autoComplete.onItemNameSearch(searchText)].map(e => ({ ...e, $index: uuid() }));
|
|
29
51
|
setOptions(list);
|
|
30
|
-
}else{
|
|
52
|
+
} else {
|
|
31
53
|
setOptions([]);
|
|
32
54
|
}
|
|
33
55
|
} catch (error) {
|
|
@@ -36,46 +58,34 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
|
|
|
36
58
|
}
|
|
37
59
|
}, [autoComplete.onItemNameSearch])
|
|
38
60
|
|
|
39
|
-
const onChangeAutoComplete = React.useCallback(async
|
|
40
|
-
const record = options.filter(e => e
|
|
61
|
+
const onChangeAutoComplete = React.useCallback(async (_, i) => {
|
|
62
|
+
const record = options.filter(e => e.$index === i.value)[0] as any;
|
|
41
63
|
if (!record) return;
|
|
42
64
|
|
|
43
65
|
await controller.setEditGood({ itemName: record.itemName });
|
|
44
66
|
|
|
67
|
+
await controller.importGoodsDrawer(record);
|
|
68
|
+
|
|
69
|
+
setValue(record.itemName);
|
|
70
|
+
setSelectLine(record[0]);
|
|
45
71
|
controller.importGoodsDrawer(record);
|
|
46
72
|
|
|
47
73
|
setOptions([]);
|
|
48
74
|
}, [options, controller])
|
|
49
75
|
|
|
50
|
-
|
|
76
|
+
React.useEffect(() => { setValue(props.value) }, [props.value])
|
|
51
77
|
|
|
52
78
|
return (
|
|
53
79
|
<div className='kts-invoice-operate-goods-list-itemName-input'>
|
|
54
80
|
{props.shorthand && <span style={{ alignSelf: 'center', fontSize: 12 }} >*{props.shorthand}*</span>}
|
|
55
|
-
<AutoComplete
|
|
56
|
-
|
|
81
|
+
<AutoComplete
|
|
82
|
+
onSearch={onSearch}
|
|
83
|
+
value={value}
|
|
84
|
+
options={options.map(e => ({ value: e.$index, label: e.itemName }))}
|
|
85
|
+
onSelect={onChangeAutoComplete}
|
|
86
|
+
>
|
|
87
|
+
<Input style={{ height: '100%', border: 'none' }} onChange={onChange} onBlur={onBlur} />
|
|
57
88
|
</AutoComplete>
|
|
58
89
|
</div>
|
|
59
90
|
)
|
|
60
91
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// function removeNullUndefined(obj: Record<string, any>): Record<string, any> {
|
|
64
|
-
// const filteredObj: Record<string, any> = {};
|
|
65
|
-
|
|
66
|
-
// for (const key in obj) {
|
|
67
|
-
// if (obj[key] !== null && obj[key] !== undefined) {
|
|
68
|
-
// filteredObj[key] = obj[key];
|
|
69
|
-
// }
|
|
70
|
-
// }
|
|
71
|
-
|
|
72
|
-
// return filteredObj;
|
|
73
|
-
// }
|
|
74
|
-
|
|
75
|
-
/** 货物单价,不含税 */
|
|
76
|
-
// const getPriceExcludeTax = (s: IGood, record: any, calculatingDigits?: number) => {
|
|
77
|
-
// if ((!s.taxRate && s.taxRate !== 0) || (!record.priceIncludeTax && record.priceIncludeTax !== 0)) return;
|
|
78
|
-
|
|
79
|
-
// // 单价(含税)/(1+税率) = 单价(不含税)
|
|
80
|
-
// return format15(evaluate(`${record.priceIncludeTax} / (1+${s.taxRate}/100)`), calculatingDigits);
|
|
81
|
-
// };
|