kts-component-invoice-operate 3.2.154 → 3.2.155

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.154",
3
+ "version": "3.2.155",
4
4
  "scripts": {
5
5
  "dev": "dumi dev --max-old-space-size=6096",
6
6
  "start": "dumi dev",
@@ -55,6 +55,9 @@ export default interface IGood {
55
55
  /** 金额(不含税) */
56
56
  lineAmountExcludeTax?: number;
57
57
 
58
+ /** 税率列表 */
59
+ goodsTaxRateList?: number[] | null;
60
+
58
61
  /** 税率 */
59
62
  taxRate?: number;
60
63
 
@@ -21,6 +21,9 @@ export default class GoodsListState {
21
21
  /** 切换含税时是否重新计算 */
22
22
  isRecalculateWhenSwitchTax = false;
23
23
 
24
+ /** 是否根据税收分类编码改变商品的可选税率 */
25
+ isUpdateGoodsTaxRateList = false;
26
+
24
27
  /** 是否能添加折扣行 */
25
28
  isAddDiscount?: boolean;
26
29
 
@@ -78,4 +78,8 @@ export default class InvoiceController extends InvoiceControllerForm {
78
78
 
79
79
  /** 获取筛选后的列表 */
80
80
  getGoodsSearch = getGoodsSearch;
81
+
82
+ /** 获取货物的税率可选列表, 如果没传taxClassificationCode,返回undefined */
83
+ getGoodsTaxRateList?: (taxClassificationCode: string) => Promise<number[] | undefined | null>;
84
+
81
85
  }
@@ -53,6 +53,13 @@ export default () => {
53
53
  setDefaultValue(await getDefaultValue({ ...good }, endowcodeGoodIndex.length));
54
54
  } else {
55
55
  if (endowcodeGoodIndex.length === 1) {
56
+ if (controller.state.goodsListState.isUpdateGoodsTaxRateList && controller.getGoodsTaxRateList && good.taxClassificationCode) {
57
+ const goodsTaxRateList = await controller.getGoodsTaxRateList(good.taxClassificationCode);
58
+ good.goodsTaxRateList = goodsTaxRateList;
59
+ // if (good.taxRate !== undefined && good.taxRate !== null && !goodsTaxRateList.includes(good.taxRate)) {
60
+ // good.taxRate = undefined;
61
+ // }
62
+ }
56
63
  setDefaultValue(good);
57
64
  } else {
58
65
  setDefaultValue({ taxRate: good.taxRate } as any);
@@ -111,7 +118,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
111
118
  }, [])
112
119
 
113
120
  /** 税率列表 */
114
- const taxRateList = controller.useMemo(s => s.goodsListState.taxRateList.map((e) => ({ label: `${e}%`, value: e })), []);
121
+ const taxRateList = controller.useMemo(s => s.goodsListState.taxRateList, []);
115
122
 
116
123
  /** 免税类型 列表 */
117
124
  const taxFreeTypeList = controller.useMemo(s => s.goodsListState.endowCode.taxFreeTypeList, []);
@@ -125,6 +132,13 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
125
132
  /** 税率 */
126
133
  const [taxRate, setTaxRate] = React.useState<number>(0);
127
134
 
135
+ /** 商品可用税率 */
136
+ const [goodsTaxRateList, setGoodsTaxRateList] = React.useState<number[] | null | undefined>(defaultValue.goodsTaxRateList);
137
+
138
+ const formattedTaxRateList = React.useMemo(() => {
139
+ return (goodsTaxRateList || taxRateList).map((e) => ({ label: `${e}%`, value: e }))
140
+ }, [goodsTaxRateList, taxRateList])
141
+
128
142
  /** 税收分类编码 选择组件 */
129
143
  const ShowSearch = React.useCallback(props => {
130
144
 
@@ -342,6 +356,25 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
342
356
  }, []);
343
357
 
344
358
  const onSelect = React.useCallback((key: any, info: any) => {
359
+
360
+ // 根据税编改变税率列表
361
+ // 如果只有一个,默认选中,有多个时,置空,用户手选
362
+ if (controller.state.goodsListState.isUpdateGoodsTaxRateList) {
363
+ if (info.node.taxRateList?.length) {
364
+ setGoodsTaxRateList(info.node.taxRateList);
365
+ }
366
+ if (!readOnlyTaxRate) {
367
+ actions.setFieldState('taxRate', async s => {
368
+ if (info.node.taxRateList && info.node.taxRateList?.length === 1) {
369
+ s.value = info.node.taxRateList[0]
370
+ } else {
371
+ s.value = undefined
372
+ }
373
+ });
374
+
375
+ }
376
+ }
377
+
345
378
  // !readOnlyTaxRate && actions.setFieldState('taxRate', async s => {
346
379
  // if (info.node.taxRate || info.taxRate === 0) {
347
380
  // s.value = info.node.taxRate
@@ -437,12 +470,15 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
437
470
  good.priceExcludeTax = countPrice(good.lineAmountExcludeTax, good.quantity, controller.state.calculatingDigits) as any;
438
471
  }
439
472
 
473
+ //赋值商品的可用税率
474
+ good.goodsTaxRateList = goodsTaxRateList;
475
+
440
476
  });
441
477
 
442
478
  s.goodsListState.goodsList = s.goodsListState.goodsList.slice();
443
479
  s.goodsListState.endowCode.endowcodeGoodIndex = [];
444
480
  })();
445
- }, [controller]);
481
+ }, [controller, goodsTaxRateList]);
446
482
 
447
483
  const effects = React.useCallback(() => {
448
484
  // 税率变化
@@ -493,7 +529,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
493
529
  title="税率"
494
530
  x-component-props={{ disabled: readOnlyTaxRate }}
495
531
  default={defaultValue?.taxRate ?? 0}
496
- enum={taxRateList}
532
+ enum={formattedTaxRateList}
497
533
  x-rules={[{ message: '请选择税率', required: true }]}
498
534
  />
499
535
  {taxRate === 0 && isTaxFreeTypeNeeded &&
@@ -517,7 +517,7 @@ export default (form: WrappedFormUtils) => {
517
517
  onChangeTaxRate(controller, form, record);
518
518
  }}
519
519
  >
520
- {taxRateList.map((e, i) => {
520
+ {(record.goodsTaxRateList || taxRateList).map((e, i) => {
521
521
  return (
522
522
  <Select.Option key={i} value={e}>
523
523
  {e}%
@@ -26,8 +26,20 @@ export default () => {
26
26
  if (editGood.$index === record.$index) return;
27
27
  await controller.saveEditGood();
28
28
  await controller.wait();
29
+ if (controller.getGoodsTaxRateList && record.taxClassificationCode && !record.goodsTaxRateList ) {
30
+ record.goodsTaxRateList = await controller.getGoodsTaxRateList(record.taxClassificationCode);
31
+ // if (record.taxRate !== undefined && record.taxRate !== null && !record.goodsTaxRateList.includes(record.taxRate)) {
32
+ // record.taxRate = undefined;
33
+ // }
34
+ }
29
35
  await controller.pipeline(async s => { s.goodsListState.editGood || (await controller.setEditGood(record)) })();
30
36
  } else {
37
+ if (controller.getGoodsTaxRateList && record.taxClassificationCode && !record.goodsTaxRateList ) {
38
+ record.goodsTaxRateList = await controller.getGoodsTaxRateList(record.taxClassificationCode);
39
+ // if (record.taxRate !== undefined && record.taxRate !== null && !record.goodsTaxRateList.includes(record.taxRate)) {
40
+ // record.taxRate = undefined;
41
+ // }
42
+ }
31
43
  await controller.setEditGood(record);
32
44
  }
33
45
  },
@@ -111,7 +111,7 @@ export default () => {
111
111
  onSelect,
112
112
  selectedRowKeys,
113
113
  getCheckboxProps: (record: any) => {
114
- console.log('===> getCheckboxProps', record, record.level)
114
+ // console.log('===> getCheckboxProps', record, record.level)
115
115
  return {
116
116
  disabled: record.level > 0,
117
117
  style: record.level > 0 ? { display: 'none' } : undefined
@@ -117,7 +117,7 @@ export default function <T extends object = any>(props: TableProps<T>) {
117
117
  cont.scrollTop = 0;
118
118
  }, [props.dataSource?.length])
119
119
 
120
- console.log('===> pointer', pointer, dataSource);
120
+ // console.log('===> pointer', pointer, dataSource);
121
121
 
122
122
  return (
123
123
  <span className="kts-invoice-operate-goods-table-virtual" ref={(e) => { setSelf(e) }} >
@@ -35,6 +35,9 @@ export default (form: WrappedFormUtils) => {
35
35
  /** 组件模式 */
36
36
  const model = controller.useMemo(e => e.model, []);
37
37
 
38
+ /** 计算类型 */
39
+ const calculateType = controller.useMemo(e => e.goodsListState.calculateType, []);
40
+
38
41
  /** 是否显示我方 */
39
42
  const isMyShow = controller.useMemo(e => e.goodsListState.isMyShow, []);
40
43
 
@@ -104,7 +107,7 @@ export default (form: WrappedFormUtils) => {
104
107
  title: <TitleText required >项目名称</TitleText>,
105
108
  key: 'itemName',
106
109
  render: (_: string, record: IGood) => {
107
- if (editGood?.$index === record.$index && !disableds.includes('itemName')) {
110
+ if (editGood?.$index === record.$index && !disableds.includes('itemName') && model !== 'prefab') {
108
111
  return (
109
112
  <Form.Item>
110
113
  <div style={{ display: 'flex' }} >
@@ -165,7 +168,7 @@ export default (form: WrappedFormUtils) => {
165
168
  key: 'itemModelName',
166
169
  width: 119,
167
170
  render: (_: string, record: IGood) => {
168
- if (editGood?.$index === record.$index && !disableds.includes('itemModelName')) {
171
+ if (editGood?.$index === record.$index && !disableds.includes('itemModelName') && model !== 'prefab') {
169
172
  return (
170
173
  <Form.Item>
171
174
  {getFieldDecorator('itemModelName', {
@@ -200,7 +203,7 @@ export default (form: WrappedFormUtils) => {
200
203
  key: 'unit',
201
204
  width: 70,
202
205
  render: (_: string, record: IGood) => {
203
- if (editGood?.$index === record.$index && !disableds.includes('unit')) {
206
+ if (editGood?.$index === record.$index && !disableds.includes('unit') && model !== 'prefab') {
204
207
  return (
205
208
  <Form.Item>
206
209
  {getFieldDecorator('unit', {
@@ -231,7 +234,7 @@ export default (form: WrappedFormUtils) => {
231
234
  align: 'right',
232
235
  width: 149,
233
236
  render: (value: string, record: IGood) => {
234
- if (editGood?.$index === record.$index && !disableds.includes('quantity')) {
237
+ if (editGood?.$index === record.$index && !disableds.includes('quantity') && model !== 'prefab') {
235
238
  return (
236
239
  <Form.Item>
237
240
  {getFieldDecorator('quantity', {
@@ -275,7 +278,7 @@ export default (form: WrappedFormUtils) => {
275
278
  align: 'right',
276
279
  width: 149,
277
280
  render: (value: string, record: IGood) => {
278
- if (editGood?.$index === record.$index && !disableds.includes('priceIncludeTax')) {
281
+ if (editGood?.$index === record.$index && !disableds.includes('priceIncludeTax') && model !== 'prefab') {
279
282
  return (
280
283
  <Form.Item>
281
284
  {getFieldDecorator('priceIncludeTax', {
@@ -319,7 +322,7 @@ export default (form: WrappedFormUtils) => {
319
322
  align: 'right',
320
323
  width: 149,
321
324
  render: (value: string, record: IGood) => {
322
- if (editGood?.$index === record.$index && !disableds.includes('priceExcludeTax')) {
325
+ if (editGood?.$index === record.$index && !disableds.includes('priceExcludeTax') && model !== 'prefab') {
323
326
  return (
324
327
  <Form.Item>
325
328
  {getFieldDecorator('priceExcludeTax', {
@@ -363,7 +366,7 @@ export default (form: WrappedFormUtils) => {
363
366
  width: 119,
364
367
  align: 'right',
365
368
  render: (value: string, record: IGood) => {
366
- if (editGood?.$index === record.$index && !disableds.includes('lineAmountIncludeTax')) {
369
+ if (editGood?.$index === record.$index && !disableds.includes('lineAmountIncludeTax') && model !== 'prefab') {
367
370
  return (
368
371
  <Form.Item>
369
372
  {getFieldDecorator('lineAmountIncludeTax', {
@@ -412,7 +415,7 @@ export default (form: WrappedFormUtils) => {
412
415
  align: 'right',
413
416
  width: 119,
414
417
  render: (value: string, record: IGood) => {
415
- if (editGood?.$index === record.$index && !disableds.includes('lineAmountExcludeTax')) {
418
+ if (editGood?.$index === record.$index && !disableds.includes('lineAmountExcludeTax') && model !== 'prefab') {
416
419
  return (
417
420
  <Form.Item>
418
421
  {getFieldDecorator('lineAmountExcludeTax', {
@@ -454,7 +457,7 @@ export default (form: WrappedFormUtils) => {
454
457
  align: 'right',
455
458
  width: 70,
456
459
  render: (value: string, record: IGood) => {
457
- if (editGood?.$index === record.$index && !disableds.includes('taxRate')) {
460
+ if (editGood?.$index === record.$index && !disableds.includes('taxRate') && !(model === 'prefab' && calculateType === '3')) {
458
461
  return (
459
462
  <Form.Item>
460
463
  {getFieldDecorator('taxRate', {
@@ -476,7 +479,7 @@ export default (form: WrappedFormUtils) => {
476
479
  onChangeTaxRate(controller, form, record);
477
480
  }}
478
481
  >
479
- {taxRateList.map((e, i) => {
482
+ {(record.goodsTaxRateList || taxRateList).map((e, i) => {
480
483
  return (
481
484
  <Select.Option key={i} value={e}>
482
485
  {e}%
@@ -542,7 +545,7 @@ export default (form: WrappedFormUtils) => {
542
545
  ellipsis: true,
543
546
  };
544
547
  }) as any[];
545
- }, [isTaxIncluded, editGood, controller, taxRateList, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart]);
548
+ }, [isTaxIncluded, editGood, controller, taxRateList, changeField, deduction, isMyShow, searchValue, model, columnsReplenish, isStart, calculateType]);
546
549
 
547
550
  // React.useEffect(() => {
548
551
  // clearTimeout(t)
@@ -15,7 +15,7 @@ export default () => {
15
15
 
16
16
  const onClick = React.useCallback(
17
17
  async (record: IGood) => {
18
- if (model === 'prefab') return;
18
+ // if (model === 'prefab') return;
19
19
  if (model === 'readOnly') return;
20
20
 
21
21
  const editGood = controller.state.goodsListState.editGood;
@@ -25,8 +25,20 @@ export default () => {
25
25
  if (editGood.$index === record.$index) return;
26
26
  await controller.saveEditGood();
27
27
  await controller.wait();
28
+ if (controller.getGoodsTaxRateList && record.taxClassificationCode && !record.goodsTaxRateList ) {
29
+ record.goodsTaxRateList = await controller.getGoodsTaxRateList(record.taxClassificationCode);
30
+ // if (record.taxRate !== undefined && record.taxRate !== null && !record.goodsTaxRateList.includes(record.taxRate)) {
31
+ // record.taxRate = undefined;
32
+ // }
33
+ }
28
34
  await controller.pipeline(async s => { s.goodsListState.editGood || (await controller.setEditGood(record)) })();
29
35
  } else {
36
+ if (controller.getGoodsTaxRateList && record.taxClassificationCode && !record.goodsTaxRateList ) {
37
+ record.goodsTaxRateList = await controller.getGoodsTaxRateList(record.taxClassificationCode);
38
+ // if (record.taxRate !== undefined && record.taxRate !== null && !record.goodsTaxRateList.includes(record.taxRate)) {
39
+ // record.taxRate = undefined;
40
+ // }
41
+ }
30
42
  await controller.setEditGood(record);
31
43
  }
32
44
  },