kts-component-invoice-operate 3.1.13 → 3.1.15
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/GoodsListState/IGood/index.d.ts +2 -0
- package/dist/Invoice/InvoiceController/InvoiceControllerState/index.d.ts +1 -1
- package/dist/Invoice/tools/itemName/index.d.ts +2 -0
- package/dist/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.d.ts +2 -2
- package/dist/Invoice/ui/GoodsList/hook/useColumns/ui/ItemNameInput/index.d.ts +1 -0
- package/dist/index.esm.js +377 -339
- package/dist/index.js +377 -339
- package/package.json +1 -1
- package/src/Invoice/InvoiceController/InvoiceControllerState/GoodsListState/IGood/index.ts +3 -0
- package/src/Invoice/InvoiceController/InvoiceControllerState/index.ts +1 -1
- package/src/Invoice/InvoiceController/fns/saveEditGood.ts +1 -1
- package/src/Invoice/tools/itemName/index.ts +9 -0
- package/src/Invoice/ui/EndowCodeDrawer/index.tsx +3 -17
- package/src/Invoice/ui/GoodsList/hook/useColumns/autoFillFn/index.ts +90 -85
- package/src/Invoice/ui/GoodsList/hook/useColumns/index.tsx +6 -4
- package/src/Invoice/ui/GoodsList/hook/useColumns/ui/ItemNameInput/index.tsx +3 -18
- package/src/Invoice/ui/ImportGoodsDrawer/index.tsx +17 -19
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ export default async (state: InvoiceControllerState) => {
|
|
|
7
7
|
const editGood = state.goodsListState.editGood;
|
|
8
8
|
const form = state.goodsListState.form;
|
|
9
9
|
|
|
10
|
-
if (!editGood || !form || state.goodsListState.importGoods.isVisibleDrawer || state.
|
|
10
|
+
if (!editGood || !form || state.goodsListState.importGoods.isVisibleDrawer || state.calculatingField) return;
|
|
11
11
|
if ((await validateFields(form)).err) return;
|
|
12
12
|
|
|
13
13
|
state.goodsListState.goodsList = state.goodsListState.goodsList.map((e) =>
|
|
@@ -44,4 +44,13 @@ export const setShorthand = (name?:string, shorthand?:string) => {
|
|
|
44
44
|
if(!sn) return undefined;
|
|
45
45
|
sn.shorthand = shorthand || '';
|
|
46
46
|
return getItemName(sn);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** 组合全称加简称 */
|
|
50
|
+
export const getItemNameWithShorthand = (value: ISN) => {
|
|
51
|
+
if (value.shorthand) {
|
|
52
|
+
return `*${value.shorthand}*${value.full}`;
|
|
53
|
+
} else {
|
|
54
|
+
return value.full;
|
|
55
|
+
}
|
|
47
56
|
}
|
|
@@ -8,7 +8,6 @@ import { LineAttributeType } from '../../InvoiceController';
|
|
|
8
8
|
import IGood from '../../InvoiceController/InvoiceControllerState/GoodsListState/IGood';
|
|
9
9
|
import { countTaxAmount } from '../../tools/calculate';
|
|
10
10
|
import { bytesLnegth, cutStr } from '../../tools/strringFn';
|
|
11
|
-
import { setShorthand } from '../../tools/itemName';
|
|
12
11
|
import {
|
|
13
12
|
SchemaForm,
|
|
14
13
|
FormButtonGroup,
|
|
@@ -302,9 +301,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
|
|
|
302
301
|
endowCodeGood.forEach(good => {
|
|
303
302
|
if (!good) return;
|
|
304
303
|
|
|
305
|
-
good.
|
|
306
|
-
good.itemNameSelf = setShorthand(good.itemNameSelf, values.shorthand);
|
|
307
|
-
|
|
304
|
+
good.shorthand = values.shorthand;
|
|
308
305
|
good.taxClassificationCode = values.taxClassificationCode;
|
|
309
306
|
good.taxRate = values.taxRate;
|
|
310
307
|
good.taxFreeType = values.taxFreeType;
|
|
@@ -354,7 +351,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
|
|
|
354
351
|
}, [controller]);
|
|
355
352
|
|
|
356
353
|
return (
|
|
357
|
-
<SchemaForm actions={actions} components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.getTaxCategoryCodeTree ? ShowSearch2 : ShowSearch }} effects={effects}>
|
|
354
|
+
<SchemaForm actions={actions} previewPlaceholder=" " components={{ ...components, showSearch: !!controller.state.goodsListState.endowCode.getTaxCategoryCodeTree ? ShowSearch2 : ShowSearch }} effects={effects}>
|
|
358
355
|
<FormButtonGroup>
|
|
359
356
|
<Field
|
|
360
357
|
name="taxClassificationCode"
|
|
@@ -368,7 +365,7 @@ const DrawerBody = (props: { defaultValue: IGood }) => {
|
|
|
368
365
|
name="shorthand"
|
|
369
366
|
type="string"
|
|
370
367
|
readOnly
|
|
371
|
-
default={
|
|
368
|
+
default={defaultValue?.shorthand}
|
|
372
369
|
title="商品和服务分类简称"
|
|
373
370
|
/>
|
|
374
371
|
<Field
|
|
@@ -432,14 +429,3 @@ const components = {
|
|
|
432
429
|
string: Input,
|
|
433
430
|
number: NumberPicker,
|
|
434
431
|
};
|
|
435
|
-
|
|
436
|
-
/** 提取简称 */
|
|
437
|
-
const getShorthand = (value?: string) => {
|
|
438
|
-
if (!value) return ' ';
|
|
439
|
-
const arr = value.match(/\*[^*]+\*/);
|
|
440
|
-
if (arr) {
|
|
441
|
-
return arr[0].split('*')[1];
|
|
442
|
-
} else {
|
|
443
|
-
return ' ';
|
|
444
|
-
}
|
|
445
|
-
};
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import { WrappedFormUtils } from 'kts-components-antd-x3/lib/form/Form';
|
|
8
8
|
import InvoiceController, { IGood, LineAttributeType } from '../../../../../InvoiceController';
|
|
9
9
|
import evaluate from '../../../../../tools/evaluate';
|
|
10
|
-
import { getSN, setShorthand } from '../../../../../tools/itemName';
|
|
11
10
|
import { message } from 'kts-components-antd-x3'
|
|
12
11
|
import { format2, format15, countTaxAmount, countAmountExcludeTax, countPrice } from '../../../../../tools/calculate';
|
|
13
12
|
import moment from 'moment';
|
|
@@ -48,7 +47,7 @@ const promptErr = (err: any) => {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
/** 清除计算中启动字段 */
|
|
51
|
-
export const clearCalculatingField = async (controller: InvoiceController) => controller.run(async s => s.
|
|
50
|
+
export const clearCalculatingField = async (controller: InvoiceController) => controller.run(async s => s.calculatingField = '');
|
|
52
51
|
|
|
53
52
|
/** 数量改变了 */
|
|
54
53
|
export const onChangeQuantity = lazyFn(
|
|
@@ -91,7 +90,7 @@ export const onChangeQuantity = lazyFn(
|
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
// 更新不含税
|
|
94
|
-
updateUnitPriceExcludingTax(controller, form, record);
|
|
93
|
+
await updateUnitPriceExcludingTax(controller, form, record);
|
|
95
94
|
} else {
|
|
96
95
|
// 不含税
|
|
97
96
|
if (!err.priceExcludeTax && values.priceExcludeTax) {
|
|
@@ -107,7 +106,7 @@ export const onChangeQuantity = lazyFn(
|
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
// 更新含税
|
|
110
|
-
updateUnitPriceTax(controller, form, record);
|
|
109
|
+
await updateUnitPriceTax(controller, form, record);
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
// 清楚 计算中启动字段
|
|
@@ -152,7 +151,7 @@ export const onChangePriceIncludeTax = lazyFn(
|
|
|
152
151
|
}
|
|
153
152
|
|
|
154
153
|
// 更新不含税
|
|
155
|
-
updateUnitPriceExcludingTax(controller, form, record);
|
|
154
|
+
await updateUnitPriceExcludingTax(controller, form, record);
|
|
156
155
|
|
|
157
156
|
// 清楚 计算中启动字段
|
|
158
157
|
await clearCalculatingField(controller);
|
|
@@ -199,7 +198,7 @@ export const onChangePriceExcludeTax = lazyFn(
|
|
|
199
198
|
}
|
|
200
199
|
|
|
201
200
|
// 更新含税
|
|
202
|
-
updateUnitPriceTax(controller, form, record);
|
|
201
|
+
await updateUnitPriceTax(controller, form, record);
|
|
203
202
|
|
|
204
203
|
// 清楚 计算中启动字段
|
|
205
204
|
await clearCalculatingField(controller);
|
|
@@ -217,7 +216,7 @@ export const onChangeLineAmountIncludeTax = lazyFn(
|
|
|
217
216
|
if (promptErr(err.lineAmountIncludeTax) || !values.lineAmountIncludeTax) {
|
|
218
217
|
// 更新不含税
|
|
219
218
|
await controller.setEditGood({ lineAmountIncludeTax: undefined, lineAmountExcludeTax: undefined });
|
|
220
|
-
updateUnitPriceExcludingTax(controller, form, record);
|
|
219
|
+
await updateUnitPriceExcludingTax(controller, form, record);
|
|
221
220
|
await clearCalculatingField(controller);
|
|
222
221
|
return;
|
|
223
222
|
}
|
|
@@ -241,7 +240,7 @@ export const onChangeLineAmountIncludeTax = lazyFn(
|
|
|
241
240
|
}
|
|
242
241
|
|
|
243
242
|
// 更新不含税
|
|
244
|
-
updateUnitPriceExcludingTax(controller, form, record);
|
|
243
|
+
await updateUnitPriceExcludingTax(controller, form, record);
|
|
245
244
|
|
|
246
245
|
// 清楚 计算中启动字段
|
|
247
246
|
await clearCalculatingField(controller);
|
|
@@ -258,7 +257,7 @@ export const onChangeLineAmountExcludeTax = lazyFn(
|
|
|
258
257
|
if (promptErr(err.lineAmountExcludeTax) || !values.lineAmountExcludeTax) {
|
|
259
258
|
// 更新含税
|
|
260
259
|
await controller.setEditGood({ lineAmountIncludeTax: undefined, lineAmountExcludeTax: undefined });
|
|
261
|
-
updateUnitPriceTax(controller, form, record);
|
|
260
|
+
await updateUnitPriceTax(controller, form, record);
|
|
262
261
|
await clearCalculatingField(controller);
|
|
263
262
|
return;
|
|
264
263
|
}
|
|
@@ -281,7 +280,7 @@ export const onChangeLineAmountExcludeTax = lazyFn(
|
|
|
281
280
|
}
|
|
282
281
|
|
|
283
282
|
// 更新含税
|
|
284
|
-
updateUnitPriceTax(controller, form, record);
|
|
283
|
+
await updateUnitPriceTax(controller, form, record);
|
|
285
284
|
|
|
286
285
|
// 清楚 计算中启动字段
|
|
287
286
|
await clearCalculatingField(controller);
|
|
@@ -315,9 +314,9 @@ export const onChangeTaxRate = lazyFn(
|
|
|
315
314
|
|
|
316
315
|
// 是否含税
|
|
317
316
|
if (controller.state.goodsListState.isTaxIncluded) {
|
|
318
|
-
updateUnitPriceExcludingTax(controller, form, record);
|
|
317
|
+
await updateUnitPriceExcludingTax(controller, form, record);
|
|
319
318
|
} else {
|
|
320
|
-
updateUnitPriceTax(controller, form, record);
|
|
319
|
+
await updateUnitPriceTax(controller, form, record);
|
|
321
320
|
}
|
|
322
321
|
|
|
323
322
|
// 清楚 计算中启动字段
|
|
@@ -356,91 +355,98 @@ export function dutyFree(controller: InvoiceController, taxRate: number, form: W
|
|
|
356
355
|
}
|
|
357
356
|
|
|
358
357
|
/** 含税 => 更新(不含税) */
|
|
359
|
-
export const updateUnitPriceExcludingTax = (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
|
|
360
|
-
|
|
358
|
+
export const updateUnitPriceExcludingTax = async (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
|
|
359
|
+
return new Promise((resolve) => {
|
|
360
|
+
form.validateFields(async (err, values) => {
|
|
361
361
|
|
|
362
|
-
|
|
362
|
+
err = err || {};
|
|
363
363
|
|
|
364
|
-
|
|
365
|
-
|
|
364
|
+
/** 税额 */
|
|
365
|
+
let taxAmount;
|
|
366
366
|
|
|
367
|
-
|
|
368
|
-
|
|
367
|
+
/** 金额(不含税) */
|
|
368
|
+
let lineAmountExcludeTax;
|
|
369
369
|
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
/** 不含税单价 */
|
|
371
|
+
let priceExcludeTax;
|
|
372
372
|
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
/** 扣除额 */
|
|
374
|
+
const deduction = controller.state.goodsListState.deduction;
|
|
375
375
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
376
|
+
// 计算税额
|
|
377
|
+
if (!promptErr(err.lineAmountIncludeTax) && !promptErr(err.taxRate)) {
|
|
378
|
+
taxAmount = countTaxAmount(values.lineAmountIncludeTax, deduction, values.taxRate);
|
|
379
|
+
}
|
|
380
|
+
await controller.setEditGood({ taxAmount });
|
|
381
381
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
382
|
+
// 计算 金额(不含税)
|
|
383
|
+
if ((taxAmount || taxAmount === 0) && !promptErr(err.lineAmountIncludeTax)) {
|
|
384
|
+
lineAmountExcludeTax = countAmountExcludeTax(values.lineAmountIncludeTax, taxAmount);
|
|
385
|
+
}
|
|
386
|
+
form.setFieldsValue({ lineAmountExcludeTax });
|
|
387
|
+
await controller.setEditGood({ lineAmountExcludeTax });
|
|
388
388
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
389
|
+
// 单价(不含税)
|
|
390
|
+
if (lineAmountExcludeTax && !promptErr(err.quantity)) {
|
|
391
|
+
priceExcludeTax = countPrice(lineAmountExcludeTax, values.quantity, controller.state.calculatingDigits);
|
|
392
|
+
}
|
|
393
|
+
form.setFieldsValue({ priceExcludeTax });
|
|
394
|
+
await controller.setEditGood({ priceExcludeTax });
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
resolve(undefined)
|
|
398
|
+
})
|
|
396
399
|
};
|
|
397
400
|
|
|
398
401
|
/** 不含税 => 更新(含税) */
|
|
399
|
-
export const updateUnitPriceTax = (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
|
|
400
|
-
|
|
401
|
-
err
|
|
402
|
+
export const updateUnitPriceTax = async (controller: InvoiceController, form: WrappedFormUtils, record: IGood) => {
|
|
403
|
+
return new Promise((resolve) => {
|
|
404
|
+
form.validateFields(async (err, values) => {
|
|
405
|
+
err = err || {};
|
|
402
406
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
407
|
+
if (
|
|
408
|
+
!err.taxRat &&
|
|
409
|
+
(values.taxRate || values.taxRate === 0) &&
|
|
410
|
+
!promptErr(err.lineAmountExcludeTax) &&
|
|
411
|
+
(values.lineAmountExcludeTax || values.lineAmountExcludeTax === 0)
|
|
412
|
+
) {
|
|
409
413
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
// 单价(含税) = 金额(含税) / (數量)
|
|
417
|
-
// 是否有数量
|
|
418
|
-
if (!err.quantity && values.quantity) {
|
|
419
|
-
const priceIncludeTax = format15(evaluate(`${lineAmountIncludeTax} / ${values.quantity}`), calculatingDigits);
|
|
420
|
-
await controller.setEditGood({ priceIncludeTax });
|
|
421
|
-
}
|
|
414
|
+
const calculatingDigits = controller.state.calculatingDigits;
|
|
415
|
+
// 金额(含税)= 金额(不含税)* (1+ 税率)
|
|
416
|
+
const lineAmountExcludeTax = format2(values.lineAmountExcludeTax);
|
|
417
|
+
const lineAmountIncludeTax = format2(evaluate(`${lineAmountExcludeTax} * (1+(${values.taxRate}/100))`));
|
|
418
|
+
await controller.setEditGood({ lineAmountIncludeTax });
|
|
422
419
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
await controller.setEditGood({ taxAmount: undefined });
|
|
430
|
-
}
|
|
420
|
+
// 单价(含税) = 金额(含税) / (數量)
|
|
421
|
+
// 是否有数量
|
|
422
|
+
if (!err.quantity && values.quantity) {
|
|
423
|
+
const priceIncludeTax = format15(evaluate(`${lineAmountIncludeTax} / ${values.quantity}`), calculatingDigits);
|
|
424
|
+
await controller.setEditGood({ priceIncludeTax });
|
|
425
|
+
}
|
|
431
426
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
427
|
+
// 税额 = 金额(含税)-金额(不含税)
|
|
428
|
+
const taxAmount = evaluate(`${lineAmountIncludeTax} - ${lineAmountExcludeTax}`);
|
|
429
|
+
form.setFieldsValue({ taxAmount });
|
|
430
|
+
await controller.setEditGood({ taxAmount });
|
|
431
|
+
} else {
|
|
432
|
+
form.setFieldsValue({ taxAmount: undefined });
|
|
433
|
+
await controller.setEditGood({ taxAmount: undefined });
|
|
434
|
+
}
|
|
435
|
+
// 单价(含税) = 单价(不含税) * (1+税率)
|
|
436
|
+
// if (
|
|
437
|
+
// !err.taxRat &&
|
|
438
|
+
// (values.taxRate || values.taxRate === 0) &&
|
|
439
|
+
// !promptErr(err.priceExcludeTax) &&
|
|
440
|
+
// (values.priceExcludeTax || values.priceExcludeTax === 0)
|
|
441
|
+
// ) {
|
|
442
|
+
// const priceExcludeTax = format15(values.priceExcludeTax);
|
|
443
|
+
// const priceIncludeTax = format15(evaluate(`${priceExcludeTax} * (1+(${values.taxRate}/100))`));
|
|
444
|
+
// await controller.setEditGood({ priceIncludeTax });
|
|
445
|
+
// }
|
|
446
|
+
|
|
447
|
+
resolve(undefined)
|
|
448
|
+
});
|
|
449
|
+
})
|
|
444
450
|
};
|
|
445
451
|
|
|
446
452
|
/** 保存到编辑货物 */
|
|
@@ -501,14 +507,13 @@ export const endowCode = async (controller: InvoiceController, goods: IGood) =>
|
|
|
501
507
|
export const onChangeItemName = async (controller: InvoiceController, form: WrappedFormUtils<any>, record: IGood) => {
|
|
502
508
|
controller.run(async s => {
|
|
503
509
|
const value = form.getFieldsValue().itemName;
|
|
504
|
-
const shorthand = getSN(value)?.shorthand ?? '';
|
|
505
510
|
|
|
506
511
|
if (s.goodsListState.isMyShow) {
|
|
507
512
|
await controller.setEditGood({ itemNameSelf: value });
|
|
508
|
-
record.itemName && await controller.setEditGood({ itemName:
|
|
513
|
+
record.itemName && await controller.setEditGood({ itemName: record.itemName });
|
|
509
514
|
} else {
|
|
510
515
|
await controller.setEditGood({ itemName: value });
|
|
511
|
-
record.itemNameSelf && await controller.setEditGood({ itemNameSelf:
|
|
516
|
+
record.itemNameSelf && await controller.setEditGood({ itemNameSelf: record.itemNameSelf });
|
|
512
517
|
}
|
|
513
518
|
})
|
|
514
519
|
}
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
onChangeTaxRate,
|
|
17
17
|
onChangeItemName,
|
|
18
18
|
} from './autoFillFn';
|
|
19
|
+
import { getItemNameWithShorthand } from '../../../../tools/itemName';
|
|
19
20
|
|
|
20
21
|
export default (form: WrappedFormUtils) => {
|
|
21
22
|
const { getFieldDecorator, getFieldValue } = form;
|
|
@@ -50,10 +51,10 @@ export default (form: WrappedFormUtils) => {
|
|
|
50
51
|
const deduction = controller.useMemo((e) => e.goodsListState.deduction, []);
|
|
51
52
|
|
|
52
53
|
/** 计算中启动字段 */
|
|
53
|
-
const changeField = controller.useMemo((e) => e.
|
|
54
|
+
const changeField = controller.useMemo((e) => e.calculatingField, []);
|
|
54
55
|
|
|
55
56
|
/** 计算中启动字段 */
|
|
56
|
-
const setChangeField = React.useCallback((value: string) => controller.run(async s => { s.
|
|
57
|
+
const setChangeField = React.useCallback((value: string) => controller.run(async s => { s.calculatingField = value }), []);
|
|
57
58
|
|
|
58
59
|
const onNumberValueChange = React.useCallback((e) => {
|
|
59
60
|
const value = e?.target?.value;
|
|
@@ -106,6 +107,7 @@ export default (form: WrappedFormUtils) => {
|
|
|
106
107
|
]
|
|
107
108
|
})(
|
|
108
109
|
<ItemNameInput
|
|
110
|
+
shorthand={editGood.shorthand}
|
|
109
111
|
onChange={() => {
|
|
110
112
|
onChangeItemName(controller, form, record);
|
|
111
113
|
}}
|
|
@@ -128,8 +130,8 @@ export default (form: WrappedFormUtils) => {
|
|
|
128
130
|
} else {
|
|
129
131
|
return (
|
|
130
132
|
<MyItemNameDiv
|
|
131
|
-
valueT={formatSearch(record.itemNameSelf, searchValue)}
|
|
132
|
-
valueF={formatSearch(record.itemName, searchValue)}
|
|
133
|
+
valueT={formatSearch(getItemNameWithShorthand({shorthand: record.shorthand, full: record.itemNameSelf || ''}), searchValue)}
|
|
134
|
+
valueF={formatSearch(getItemNameWithShorthand({shorthand: record.shorthand, full: record.itemName || ''}), searchValue)}
|
|
133
135
|
isMyShow={isMyShow}
|
|
134
136
|
/>
|
|
135
137
|
)
|
|
@@ -3,32 +3,17 @@ import { Input } from 'kts-components-antd-x3';
|
|
|
3
3
|
import React, { ChangeEvent } from 'react';
|
|
4
4
|
import './index.less';
|
|
5
5
|
|
|
6
|
-
export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLInputElement>) => void, value?: string }) {
|
|
7
|
-
|
|
8
|
-
const { shorthand, fullName } = getShorthand(props.value);
|
|
6
|
+
export default function ItemNameInput(props: { onChange?: (e: ChangeEvent<HTMLInputElement>) => void, value?: string, shorthand?: string }) {
|
|
9
7
|
|
|
10
8
|
const onChange = React.useCallback((e: ChangeEvent<HTMLInputElement>) => {
|
|
11
9
|
const event = { ...e };
|
|
12
|
-
event.target.value = shorthand ? `*${shorthand}*${e.target.value}` : e.target.value
|
|
13
10
|
props.onChange && props.onChange(event);
|
|
14
11
|
}, [])
|
|
15
12
|
|
|
16
13
|
return (
|
|
17
14
|
<div className='kts-invoice-operate-goods-list-itemName-input'>
|
|
18
|
-
{shorthand && <span style={{ alignSelf: 'center', fontSize: 12 }} >*{shorthand}*</span>}
|
|
19
|
-
<Input style={{ height: '100%', border: 'none' }} value={
|
|
15
|
+
{props.shorthand && <span style={{ alignSelf: 'center', fontSize: 12 }} >*{props.shorthand}*</span>}
|
|
16
|
+
<Input style={{ height: '100%', border: 'none' }} value={props.value} onChange={onChange} />
|
|
20
17
|
</div>
|
|
21
18
|
)
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
/** 提取简称 */
|
|
25
|
-
const getShorthand = (value?: string) => {
|
|
26
|
-
if (!value) return {};
|
|
27
|
-
const arr = value.match(/\*[^*]+\*/);
|
|
28
|
-
|
|
29
|
-
const shorthand = arr ? arr[0].split('*')[1] : '';
|
|
30
|
-
const fullName = shorthand ? value.replace(`*${shorthand}*`, '') : value;
|
|
31
|
-
|
|
32
|
-
return { shorthand, fullName }
|
|
33
|
-
};
|
|
34
|
-
|
|
@@ -3,7 +3,6 @@ import { Drawer, Table } from 'kts-components-antd-x3';
|
|
|
3
3
|
import Invoice from '../../';
|
|
4
4
|
import { updateUnitPriceExcludingTax, updateUnitPriceTax, dutyFree, format15 } from '../GoodsList/hook/useColumns/autoFillFn';
|
|
5
5
|
import { countAmountIncludeTax } from '../../tools/calculate'
|
|
6
|
-
import { getSN } from '../../tools/itemName'
|
|
7
6
|
import { IGood } from '../../InvoiceController';
|
|
8
7
|
import evaluate from '../../tools/evaluate';
|
|
9
8
|
|
|
@@ -115,10 +114,9 @@ const DrawerBody = () => {
|
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
s.goodsListState.importGoods.isVisibleDrawer = false;
|
|
118
|
-
|
|
119
117
|
s.goodsListState.isTaxIncluded
|
|
120
|
-
? updateUnitPriceExcludingTax(controller, s.goodsListState.form, record)
|
|
121
|
-
: updateUnitPriceTax(controller, s.goodsListState.form, record)
|
|
118
|
+
? await updateUnitPriceExcludingTax(controller, s.goodsListState.form, record)
|
|
119
|
+
: await updateUnitPriceTax(controller, s.goodsListState.form, record)
|
|
122
120
|
})
|
|
123
121
|
}
|
|
124
122
|
};
|
|
@@ -145,31 +143,31 @@ const getPriceExcludeTax = (s: IGood, record: any, calculatingDigits?: number) =
|
|
|
145
143
|
// 获取我方名称
|
|
146
144
|
const getItemName = (record: any, editGood: IGood) => {
|
|
147
145
|
|
|
148
|
-
let shorthand;
|
|
146
|
+
// let shorthand;
|
|
149
147
|
|
|
150
|
-
shorthand = record.shorthand;
|
|
151
|
-
if (shorthand) {
|
|
152
|
-
|
|
153
|
-
}
|
|
148
|
+
// shorthand = record.shorthand;
|
|
149
|
+
// if (shorthand) {
|
|
150
|
+
// return `*${shorthand}*${record.itemName}`;
|
|
151
|
+
// }
|
|
154
152
|
|
|
155
|
-
shorthand = getSN(editGood.itemName)?.shorthand;
|
|
156
|
-
if (shorthand) {
|
|
157
|
-
|
|
158
|
-
}
|
|
153
|
+
// shorthand = getSN(editGood.itemName)?.shorthand;
|
|
154
|
+
// if (shorthand) {
|
|
155
|
+
// return `*${shorthand}*${record.itemNameSelf}`;
|
|
156
|
+
// }
|
|
159
157
|
|
|
160
158
|
return record.itemName;
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
// 获取他方名称
|
|
164
162
|
const getItemNameOther = (record: any, editGood: IGood) => {
|
|
165
|
-
if (!editGood.itemName) return editGood.itemName;
|
|
163
|
+
// if (!editGood.itemName) return editGood.itemName;
|
|
166
164
|
|
|
167
|
-
let shorthand;
|
|
165
|
+
// let shorthand;
|
|
168
166
|
|
|
169
|
-
shorthand = record.shorthand;
|
|
170
|
-
if (shorthand) {
|
|
171
|
-
|
|
172
|
-
}
|
|
167
|
+
// shorthand = record.shorthand;
|
|
168
|
+
// if (shorthand) {
|
|
169
|
+
// return `*${shorthand}*${record.itemNameSelf}`;
|
|
170
|
+
// }
|
|
173
171
|
|
|
174
172
|
return record.itemName;
|
|
175
173
|
}
|