kts-component-invoice-operate 3.2.191 → 3.2.193

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.
@@ -294,7 +294,7 @@ export default (form: WrappedFormUtils) => {
294
294
  })(
295
295
  <MyInput
296
296
  style={{ textAlign: 'right' }}
297
- maxLength={16}
297
+ maxLength={25}
298
298
  loading={isCipher(changeField, "quantity")}
299
299
  onChange={async () => {
300
300
  setChangeField('quantity');
@@ -338,7 +338,7 @@ export default (form: WrappedFormUtils) => {
338
338
  })(
339
339
  <MyInput
340
340
  style={{ textAlign: 'right' }}
341
- maxLength={16}
341
+ maxLength={25}
342
342
  loading={isCipher(changeField, 'priceIncludeTax')}
343
343
  onChange={() => {
344
344
  setChangeField('priceIncludeTax');
@@ -382,7 +382,7 @@ export default (form: WrappedFormUtils) => {
382
382
  })(
383
383
  <MyInput
384
384
  style={{ textAlign: 'right' }}
385
- maxLength={16}
385
+ maxLength={25}
386
386
  loading={isCipher(changeField, 'priceExcludeTax')}
387
387
  onChange={() => {
388
388
  setChangeField('priceExcludeTax');
@@ -342,6 +342,40 @@ export const onChangeTaxRate = lazyFn(
342
342
  1000,
343
343
  );
344
344
 
345
+ /** 税额 */
346
+ export const onChangeTaxAmount = lazyFn(
347
+ (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
348
+
349
+ /** 金额(不含税) */
350
+ let lineAmountExcludeTax;
351
+
352
+ form.validateFields(async (err, values) => {
353
+ err = err || {};
354
+
355
+ const record = controller.state.goodsListState.editGood;
356
+
357
+ // 校验是否有含税金额
358
+ if (err.lineAmountIncludeTax && (!record?.lineAmountIncludeTax && record?.lineAmountIncludeTax !== 0)) {
359
+ await clearCalculatingField(controller);
360
+ return;
361
+ }
362
+
363
+ // 计数不含税金额
364
+ lineAmountExcludeTax = countAmountExcludeTax(record?.lineAmountIncludeTax || 0, values.taxAmount);
365
+ form.setFieldsValue({ lineAmountExcludeTax });
366
+
367
+ const priceExcludeTax: any = countPrice(lineAmountExcludeTax || '', record?.quantity || '', controller.state.calculatingDigits);
368
+
369
+ await controller.setEditGood({ lineAmountExcludeTax, taxAmount: values.taxAmount, priceExcludeTax });
370
+ form.setFieldsValue({ priceExcludeTax });
371
+
372
+ // 清楚 计算中启动字段
373
+ await clearCalculatingField(controller);
374
+ })
375
+ },
376
+ 1000,
377
+ )
378
+
345
379
  /** 小规模纳税人 1% 和 3% 自动赋码免税 */
346
380
  export function dutyFree(controller: InvoiceController, taxRate: number, form: WrappedFormUtils<any>, record: IGood) {
347
381
 
@@ -558,7 +592,7 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
558
592
  key: '你正在编辑一个货物',
559
593
  });
560
594
 
561
- return ;
595
+ return;
562
596
  }
563
597
 
564
598
  s.goodsListState.isTaxIncluded = isTaxIncluded;
@@ -632,7 +666,7 @@ export const onChangeSwitchTax = async (controller: InvoiceController, isTaxIncl
632
666
  s.goodsListState.goodsList = newGoodsList;
633
667
  }
634
668
  }
635
- } catch(e) {
669
+ } catch (e) {
636
670
  console.error('切换税率重新计算出错', e, s.goodsListState)
637
671
  }
638
672
  })
@@ -18,6 +18,7 @@ import {
18
18
  onChangeLineAmountExcludeTax,
19
19
  onChangeTaxRate,
20
20
  onChangeItemName,
21
+ onChangeTaxAmount,
21
22
  } from './autoFillFn';
22
23
  import Drag from './ui/Drag';
23
24
  import { nonScientificNotation } from '../../../../../tools/calculate';
@@ -50,6 +51,9 @@ export default (form: WrappedFormUtils) => {
50
51
  /** 禁用字段 */
51
52
  const disableds = controller.useMemo((e) => e.stakeholder.disableds || [], []);
52
53
 
54
+ /** 启用字段 */
55
+ const enables = controller.useMemo(s => s.stakeholder.enables || [], []);
56
+
53
57
  /** 搜索条件 */
54
58
  const searchValue = controller.useMemo((e) => e.goodsListState.searchValue, []);
55
59
 
@@ -71,6 +75,8 @@ export default (form: WrappedFormUtils) => {
71
75
  /** 计算中启动字段 */
72
76
  const setChangeField = React.useCallback((value: string) => controller.run(async s => { s.calculatingField = value }), []);
73
77
 
78
+ const isEnables = React.useCallback(field => enables.indexOf(field) >= 0, [enables])
79
+
74
80
  const onNumberValueChange = React.useCallback((e) => {
75
81
  const value = e?.target?.value;
76
82
  if (value) {
@@ -256,7 +262,7 @@ export default (form: WrappedFormUtils) => {
256
262
  })(
257
263
  <MyInput
258
264
  style={{ textAlign: 'right' }}
259
- maxLength={16}
265
+ maxLength={25}
260
266
  loading={isCipher(changeField, "quantity")}
261
267
  onChange={async () => {
262
268
  setChangeField('quantity');
@@ -300,7 +306,7 @@ export default (form: WrappedFormUtils) => {
300
306
  })(
301
307
  <MyInput
302
308
  style={{ textAlign: 'right' }}
303
- maxLength={16}
309
+ maxLength={25}
304
310
  loading={isCipher(changeField, 'priceIncludeTax')}
305
311
  onChange={() => {
306
312
  setChangeField('priceIncludeTax');
@@ -344,7 +350,7 @@ export default (form: WrappedFormUtils) => {
344
350
  })(
345
351
  <MyInput
346
352
  style={{ textAlign: 'right' }}
347
- maxLength={16}
353
+ maxLength={25}
348
354
  loading={isCipher(changeField, 'priceExcludeTax')}
349
355
  onChange={() => {
350
356
  setChangeField('priceExcludeTax');
@@ -505,21 +511,28 @@ export default (form: WrappedFormUtils) => {
505
511
  if (editGood?.$index === record.$index && !disableds.includes('taxAmount')) {
506
512
  return getFieldDecorator('taxAmount', {
507
513
  initialValue: editGood.taxAmount,
508
- rules: getReplenishRules('taxAmount'),
509
- })(<MyDiv loading={isCipher(changeField, 'taxAmount')} />);
514
+ rules: [
515
+ ...getReplenishRules('taxAmount'),
516
+ { required: true, message: '税额不能为空' },
517
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '税额必须为数字' },
518
+ ],
519
+ })(
520
+ isEnables('taxAmount')
521
+ ? <MyInput
522
+ style={{ textAlign: 'right' }}
523
+ loading={isCipher(changeField, 'taxAmount')}
524
+ onChange={() => {
525
+ setChangeField('taxAmount');
526
+ onChangeTaxAmount(controller, form, record);
527
+ }}
528
+ />
529
+ : <MyDiv loading={isCipher(changeField, 'taxAmount')} />
530
+ );
510
531
  } else {
511
532
  return <span style={{ padding: '0 10px' }}>{isDutyFree(record) ? '***' : parseFloat(value).toFixed(2)}</span>;
512
533
  }
513
534
  },
514
535
  },
515
- // {
516
- // title: '操作',
517
- // key: 'operating',
518
- // align: 'right',
519
- // width: 130,
520
- // fixed: 'right',
521
- // render: (_value: string, record: IGood) => <RowMenu key={record.lineAttribute} goods={record} />,
522
- // },
523
536
  ]
524
537
  // 含税不含税
525
538
  .filter((e) => {