kts-component-invoice-operate 3.2.19 → 3.2.20

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/index.esm.js CHANGED
@@ -10220,8 +10220,8 @@ function ItemNameInput(props) {
10220
10220
 
10221
10221
  var good = options.filter(function (e) {
10222
10222
  return e.itemName === itemName;
10223
- });
10224
- (_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(good);
10223
+ })[0];
10224
+ good && ((_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(removeNullUndefined(good)));
10225
10225
  }, [options, controller]);
10226
10226
  return React.createElement("div", {
10227
10227
  className: 'kts-invoice-operate-goods-list-itemName-input'
@@ -10248,6 +10248,18 @@ function ItemNameInput(props) {
10248
10248
  })));
10249
10249
  }
10250
10250
 
10251
+ function removeNullUndefined(obj) {
10252
+ var filteredObj = {};
10253
+
10254
+ for (var key in obj) {
10255
+ if (obj[key] !== null && obj[key] !== undefined) {
10256
+ filteredObj[key] = obj[key];
10257
+ }
10258
+ }
10259
+
10260
+ return filteredObj;
10261
+ }
10262
+
10251
10263
  /** 拆分全称加简称 */
10252
10264
  var getSN = function getSN(value) {
10253
10265
  if (!value) return undefined;
package/dist/index.js CHANGED
@@ -10230,8 +10230,8 @@ function ItemNameInput(props) {
10230
10230
 
10231
10231
  var good = options.filter(function (e) {
10232
10232
  return e.itemName === itemName;
10233
- });
10234
- (_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(good);
10233
+ })[0];
10234
+ good && ((_controller$state$goo = controller.state.goodsListState.form) === null || _controller$state$goo === void 0 ? void 0 : _controller$state$goo.setFieldsValue(removeNullUndefined(good)));
10235
10235
  }, [options, controller]);
10236
10236
  return React__default['default'].createElement("div", {
10237
10237
  className: 'kts-invoice-operate-goods-list-itemName-input'
@@ -10258,6 +10258,18 @@ function ItemNameInput(props) {
10258
10258
  })));
10259
10259
  }
10260
10260
 
10261
+ function removeNullUndefined(obj) {
10262
+ var filteredObj = {};
10263
+
10264
+ for (var key in obj) {
10265
+ if (obj[key] !== null && obj[key] !== undefined) {
10266
+ filteredObj[key] = obj[key];
10267
+ }
10268
+ }
10269
+
10270
+ return filteredObj;
10271
+ }
10272
+
10261
10273
  /** 拆分全称加简称 */
10262
10274
  var getSN = function getSN(value) {
10263
10275
  if (!value) return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.19",
3
+ "version": "3.2.20",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -20,11 +20,50 @@ class MyInvoiceController extends InvoiceController {
20
20
  constructor() {
21
21
  super();
22
22
  this.state.autoComplete.onItemNameSearch = async text => {
23
- const sum: { value: string }[] = []
24
- for (let index = 0; index < 10; index++) {
25
- sum.push({ value: `xxxx${index}` })
26
- }
27
- return sum;
23
+ return [
24
+ {
25
+ "itemName": "呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵",
26
+ "taxClassificationCode": "1010112070000000000",
27
+ "itemModelName": null,
28
+ "shorthand": "蔬菜",
29
+ "taxRate": undefined
30
+ },
31
+ {
32
+ "itemName": "稻谷",
33
+ "taxClassificationCode": "1010101040000000000",
34
+ "itemModelName": null,
35
+ "shorthand": "谷物",
36
+ "taxRate": 3
37
+ },
38
+ {
39
+ "itemName": "苹果",
40
+ "taxClassificationCode": "1090111090000000000",
41
+ "itemModelName": null,
42
+ "shorthand": "小型起重设备",
43
+ "taxRate": null
44
+ },
45
+ {
46
+ "itemName": "银丝",
47
+ "taxClassificationCode": "1080411120000000000",
48
+ "itemModelName": null,
49
+ "shorthand": "金属制品",
50
+ "taxRate": 3
51
+ },
52
+ {
53
+ "itemName": "布料",
54
+ "taxClassificationCode": "1100101011100000000",
55
+ "itemModelName": null,
56
+ "shorthand": "发电",
57
+ "taxRate": 2
58
+ },
59
+ {
60
+ "itemName": "苹果",
61
+ "taxClassificationCode": "1010115010100000000",
62
+ "itemModelName": null,
63
+ "shorthand": "水果",
64
+ "taxRate": 3
65
+ }
66
+ ] as any
28
67
  }
29
68
  }
30
69
 
@@ -30,8 +30,8 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
30
30
  }, [autoComplete.onItemNameSearch])
31
31
 
32
32
  const onChangeAutoComplete = React.useCallback(itemName => {
33
- const good = options.filter(e=>e.itemName === itemName);
34
- controller.state.goodsListState.form?.setFieldsValue(good);
33
+ const good = options.filter(e=>e.itemName === itemName)[0];
34
+ good && controller.state.goodsListState.form?.setFieldsValue(removeNullUndefined(good));
35
35
  }, [options, controller])
36
36
 
37
37
  return (
@@ -43,3 +43,16 @@ export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLIn
43
43
  </div>
44
44
  )
45
45
  }
46
+
47
+
48
+ function removeNullUndefined(obj: Record<string, any>): Record<string, any> {
49
+ const filteredObj: Record<string, any> = {};
50
+
51
+ for (const key in obj) {
52
+ if (obj[key] !== null && obj[key] !== undefined) {
53
+ filteredObj[key] = obj[key];
54
+ }
55
+ }
56
+
57
+ return filteredObj;
58
+ }