kts-component-invoice-operate 3.1.5 → 3.1.7

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.
@@ -29,8 +29,10 @@ export default class InvoiceControllerState {
29
29
  goodsListState: GoodsListState;
30
30
  /** 计算中启动字段 */
31
31
  calculating?: string;
32
- /** 数量,金额计算时保留的小数位,不传位8位 */
32
+ /** 数量,单价计算时保留的小数位,不传默认8位 */
33
33
  calculatingDigits?: number;
34
+ /** 金额整数位限制,不传默认9位 */
35
+ priceIntegerDigit?: number;
34
36
  /** 组件根结构 */
35
37
  rootElement?: HTMLDivElement | null;
36
38
  }
package/dist/index.esm.js CHANGED
@@ -936,6 +936,7 @@ var InvoiceControllerState = /*#__PURE__*/_createClass(function InvoiceControlle
936
936
  this.goodsListState = new GoodsListState();
937
937
  this.calculating = void 0;
938
938
  this.calculatingDigits = void 0;
939
+ this.priceIntegerDigit = void 0;
939
940
  this.rootElement = null;
940
941
  });
941
942
 
@@ -2220,11 +2221,12 @@ var useAddDiscount = (function (goods) {
2220
2221
  _context2.next = 7;
2221
2222
  return controller.run( /*#__PURE__*/function () {
2222
2223
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
2224
+ var _s$goodsListState$edi, _goods;
2223
2225
  var err, key;
2224
2226
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2225
2227
  while (1) switch (_context.prev = _context.next) {
2226
2228
  case 0:
2227
- if (!s.goodsListState.form) {
2229
+ if (!(s.goodsListState.form && ((_s$goodsListState$edi = s.goodsListState.editGood) === null || _s$goodsListState$edi === void 0 ? void 0 : _s$goodsListState$edi.$index) === ((_goods = goods) === null || _goods === void 0 ? void 0 : _goods.$index))) {
2228
2230
  _context.next = 11;
2229
2231
  break;
2230
2232
  }
@@ -8820,11 +8822,12 @@ var endowCode = /*#__PURE__*/function () {
8820
8822
  _context17.next = 6;
8821
8823
  return controller.pipeline( /*#__PURE__*/function () {
8822
8824
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(s) {
8825
+ var _s$goodsListState$edi;
8823
8826
  var err, key, g, i;
8824
8827
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
8825
8828
  while (1) switch (_context16.prev = _context16.next) {
8826
8829
  case 0:
8827
- if (!s.goodsListState.form) {
8830
+ if (!(s.goodsListState.form && ((_s$goodsListState$edi = s.goodsListState.editGood) === null || _s$goodsListState$edi === void 0 ? void 0 : _s$goodsListState$edi.$index) === (goods === null || goods === void 0 ? void 0 : goods.$index))) {
8828
8831
  _context16.next = 11;
8829
8832
  break;
8830
8833
  }
@@ -9190,6 +9193,10 @@ var useColumns = (function (form) {
9190
9193
  var getReplenishRules = React.useCallback(function (id) {
9191
9194
  return columnsReplenish[id] ? columnsReplenish[id].rules || [] : [];
9192
9195
  }, [columnsReplenish]);
9196
+ /** 金额整数位限制,不传默认9位 */
9197
+ var priceIntegerDigit = controller.useMemo(function (e) {
9198
+ return e.priceIntegerDigit || 9;
9199
+ }, []);
9193
9200
  /** 表头 */
9194
9201
  var columns = React.useMemo(function () {
9195
9202
  var _columnsReplenish$ite, _columnsReplenish$uni, _columnsReplenish$qua, _columnsReplenish$pri, _columnsReplenish$pri2, _columnsReplenish$tax;
@@ -9615,8 +9622,8 @@ var useColumns = (function (form) {
9615
9622
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9616
9623
  while (1) switch (_context10.prev = _context10.next) {
9617
9624
  case 0:
9618
- if ("".concat(value).split('.')[0].length > 9) {
9619
- callback('金额整数部分不能大于9位,小数点后最多2位');
9625
+ if ("".concat(value).split('.')[0].length > priceIntegerDigit) {
9626
+ callback("\u91D1\u989D\u6574\u6570\u90E8\u5206\u4E0D\u80FD\u5927\u4E8E".concat(priceIntegerDigit, "\u4F4D\uFF0C\u5C0F\u6570\u70B9\u540E\u6700\u591A2\u4F4D"));
9620
9627
  }
9621
9628
  case 1:
9622
9629
  case "end":
@@ -9692,8 +9699,8 @@ var useColumns = (function (form) {
9692
9699
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9693
9700
  while (1) switch (_context12.prev = _context12.next) {
9694
9701
  case 0:
9695
- if ("".concat(value).split('.')[0].length > 9) {
9696
- callback('金额整数部分不能大于9位,小数点后最多2位');
9702
+ if ("".concat(value).split('.')[0].length > priceIntegerDigit) {
9703
+ callback("\u91D1\u989D\u6574\u6570\u90E8\u5206\u4E0D\u80FD\u5927\u4E8E".concat(priceIntegerDigit, "\u4F4D\uFF0C\u5C0F\u6570\u70B9\u540E\u6700\u591A2\u4F4D"));
9697
9704
  }
9698
9705
  case 1:
9699
9706
  case "end":
package/dist/index.js CHANGED
@@ -946,6 +946,7 @@ var InvoiceControllerState = /*#__PURE__*/_createClass(function InvoiceControlle
946
946
  this.goodsListState = new GoodsListState();
947
947
  this.calculating = void 0;
948
948
  this.calculatingDigits = void 0;
949
+ this.priceIntegerDigit = void 0;
949
950
  this.rootElement = null;
950
951
  });
951
952
 
@@ -2230,11 +2231,12 @@ var useAddDiscount = (function (goods) {
2230
2231
  _context2.next = 7;
2231
2232
  return controller.run( /*#__PURE__*/function () {
2232
2233
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(s) {
2234
+ var _s$goodsListState$edi, _goods;
2233
2235
  var err, key;
2234
2236
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2235
2237
  while (1) switch (_context.prev = _context.next) {
2236
2238
  case 0:
2237
- if (!s.goodsListState.form) {
2239
+ if (!(s.goodsListState.form && ((_s$goodsListState$edi = s.goodsListState.editGood) === null || _s$goodsListState$edi === void 0 ? void 0 : _s$goodsListState$edi.$index) === ((_goods = goods) === null || _goods === void 0 ? void 0 : _goods.$index))) {
2238
2240
  _context.next = 11;
2239
2241
  break;
2240
2242
  }
@@ -8830,11 +8832,12 @@ var endowCode = /*#__PURE__*/function () {
8830
8832
  _context17.next = 6;
8831
8833
  return controller.pipeline( /*#__PURE__*/function () {
8832
8834
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(s) {
8835
+ var _s$goodsListState$edi;
8833
8836
  var err, key, g, i;
8834
8837
  return _regeneratorRuntime().wrap(function _callee16$(_context16) {
8835
8838
  while (1) switch (_context16.prev = _context16.next) {
8836
8839
  case 0:
8837
- if (!s.goodsListState.form) {
8840
+ if (!(s.goodsListState.form && ((_s$goodsListState$edi = s.goodsListState.editGood) === null || _s$goodsListState$edi === void 0 ? void 0 : _s$goodsListState$edi.$index) === (goods === null || goods === void 0 ? void 0 : goods.$index))) {
8838
8841
  _context16.next = 11;
8839
8842
  break;
8840
8843
  }
@@ -9200,6 +9203,10 @@ var useColumns = (function (form) {
9200
9203
  var getReplenishRules = React__default['default'].useCallback(function (id) {
9201
9204
  return columnsReplenish[id] ? columnsReplenish[id].rules || [] : [];
9202
9205
  }, [columnsReplenish]);
9206
+ /** 金额整数位限制,不传默认9位 */
9207
+ var priceIntegerDigit = controller.useMemo(function (e) {
9208
+ return e.priceIntegerDigit || 9;
9209
+ }, []);
9203
9210
  /** 表头 */
9204
9211
  var columns = React__default['default'].useMemo(function () {
9205
9212
  var _columnsReplenish$ite, _columnsReplenish$uni, _columnsReplenish$qua, _columnsReplenish$pri, _columnsReplenish$pri2, _columnsReplenish$tax;
@@ -9625,8 +9632,8 @@ var useColumns = (function (form) {
9625
9632
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9626
9633
  while (1) switch (_context10.prev = _context10.next) {
9627
9634
  case 0:
9628
- if ("".concat(value).split('.')[0].length > 9) {
9629
- callback('金额整数部分不能大于9位,小数点后最多2位');
9635
+ if ("".concat(value).split('.')[0].length > priceIntegerDigit) {
9636
+ callback("\u91D1\u989D\u6574\u6570\u90E8\u5206\u4E0D\u80FD\u5927\u4E8E".concat(priceIntegerDigit, "\u4F4D\uFF0C\u5C0F\u6570\u70B9\u540E\u6700\u591A2\u4F4D"));
9630
9637
  }
9631
9638
  case 1:
9632
9639
  case "end":
@@ -9702,8 +9709,8 @@ var useColumns = (function (form) {
9702
9709
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9703
9710
  while (1) switch (_context12.prev = _context12.next) {
9704
9711
  case 0:
9705
- if ("".concat(value).split('.')[0].length > 9) {
9706
- callback('金额整数部分不能大于9位,小数点后最多2位');
9712
+ if ("".concat(value).split('.')[0].length > priceIntegerDigit) {
9713
+ callback("\u91D1\u989D\u6574\u6570\u90E8\u5206\u4E0D\u80FD\u5927\u4E8E".concat(priceIntegerDigit, "\u4F4D\uFF0C\u5C0F\u6570\u70B9\u540E\u6700\u591A2\u4F4D"));
9707
9714
  }
9708
9715
  case 1:
9709
9716
  case "end":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -37,9 +37,12 @@ export default class InvoiceControllerState {
37
37
  /** 计算中启动字段 */
38
38
  calculating?: string;
39
39
 
40
- /** 数量,金额计算时保留的小数位,不传位8位 */
40
+ /** 数量,单价计算时保留的小数位,不传默认8位 */
41
41
  calculatingDigits?: number;
42
42
 
43
+ /** 金额整数位限制,不传默认9位 */
44
+ priceIntegerDigit?: number;
45
+
43
46
  /** 组件根结构 */
44
47
  rootElement?: HTMLDivElement | null = null;
45
48
  }
@@ -451,7 +451,7 @@ export const endowCode = async (controller: InvoiceController, goods: IGood) =>
451
451
  await controller.wait();
452
452
  await controller.saveEditGood();
453
453
  await controller.pipeline(async (s) => {
454
- if (s.goodsListState.form) {
454
+ if (s.goodsListState.form && s.goodsListState.editGood?.$index === goods?.$index) {
455
455
  const err: any = s.goodsListState.form.getFieldsError();
456
456
  for (let key in err) {
457
457
  if (!err[key]) continue;
@@ -60,6 +60,9 @@ export default (form: WrappedFormUtils) => {
60
60
  return columnsReplenish[id] ? columnsReplenish[id].rules || [] : []
61
61
  }, [columnsReplenish])
62
62
 
63
+ /** 金额整数位限制,不传默认9位 */
64
+ const priceIntegerDigit = controller.useMemo((e) => e.priceIntegerDigit || 9, []);
65
+
63
66
  /** 表头 */
64
67
  const columns = React.useMemo(() => {
65
68
  return [
@@ -339,8 +342,8 @@ export default (form: WrappedFormUtils) => {
339
342
  { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '金额必须为数字' },
340
343
  {
341
344
  validator: async (_, value, callback) => {
342
- if (`${value}`.split('.')[0].length > 9) {
343
- callback('金额整数部分不能大于9位,小数点后最多2位');
345
+ if (`${value}`.split('.')[0].length > priceIntegerDigit) {
346
+ callback(`金额整数部分不能大于${priceIntegerDigit}位,小数点后最多2位`);
344
347
  }
345
348
  }
346
349
  },
@@ -387,8 +390,8 @@ export default (form: WrappedFormUtils) => {
387
390
  { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '金额必须为数字' },
388
391
  {
389
392
  validator: async (_, value: string, callback) => {
390
- if (`${value}`.split('.')[0].length > 9) {
391
- callback('金额整数部分不能大于9位,小数点后最多2位');
393
+ if (`${value}`.split('.')[0].length > priceIntegerDigit) {
394
+ callback(`金额整数部分不能大于${priceIntegerDigit}位,小数点后最多2位`);
392
395
  }
393
396
  }
394
397
  },
@@ -21,7 +21,7 @@ export default (goods: IGood) => {
21
21
  await controller.wait();
22
22
  await controller.saveEditGood();
23
23
  await controller.run(async s => {
24
- if (s.goodsListState.form) {
24
+ if (s.goodsListState.form && s.goodsListState.editGood?.$index === goods?.$index) {
25
25
  const err: any = s.goodsListState.form.getFieldsError();
26
26
  for (let key in err) {
27
27
  if (!err[key]) continue;