kts-component-invoice-operate 3.2.194 → 3.2.196

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
@@ -22166,12 +22166,32 @@ var useColumns$1 = (function (form) {
22166
22166
  align: 'right',
22167
22167
  width: 119,
22168
22168
  render: function render(value, record) {
22169
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && !disableds.includes('taxAmount')) {
22170
- return getFieldDecorator('taxAmount', {
22169
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && !disableds.includes('taxAmount') && model !== 'prefab') {
22170
+ return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('taxAmount', {
22171
22171
  initialValue: editGood.taxAmount,
22172
22172
  rules: [].concat(_toConsumableArray(getReplenishRules('taxAmount')), [{
22173
22173
  required: true,
22174
22174
  message: '税额不能为空'
22175
+ }, {
22176
+ validator: function validator(rule, value, callback) {
22177
+ //含税金额
22178
+ var lineAmountIncludeTax = (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax) || 0; //不含税金额
22179
+
22180
+ var lineAmountExcludeTax = lineAmountIncludeTax - value;
22181
+ var taxRate = editGood === null || editGood === void 0 ? void 0 : editGood.taxRate;
22182
+
22183
+ if (lineAmountExcludeTax && taxRate && lineAmountIncludeTax) {
22184
+ var total = lineAmountExcludeTax * taxRate / 100;
22185
+
22186
+ if (Number(Math.abs(total - Number(value)).toFixed(2)) <= 0.01) {
22187
+ callback();
22188
+ } else {
22189
+ callback('税额填写错误,请重新输入');
22190
+ }
22191
+ } else {
22192
+ callback();
22193
+ }
22194
+ }
22175
22195
  }, {
22176
22196
  pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/,
22177
22197
  message: '税额必须为数字'
@@ -22187,7 +22207,7 @@ var useColumns$1 = (function (form) {
22187
22207
  }
22188
22208
  }) : /*#__PURE__*/React.createElement(MyDiv$2, {
22189
22209
  loading: isCipher$1(changeField, 'taxAmount')
22190
- }));
22210
+ })));
22191
22211
  } else {
22192
22212
  return /*#__PURE__*/React.createElement("span", {
22193
22213
  style: {
package/dist/index.js CHANGED
@@ -22176,12 +22176,32 @@ var useColumns$1 = (function (form) {
22176
22176
  align: 'right',
22177
22177
  width: 119,
22178
22178
  render: function render(value, record) {
22179
- if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && !disableds.includes('taxAmount')) {
22180
- return getFieldDecorator('taxAmount', {
22179
+ if ((editGood === null || editGood === void 0 ? void 0 : editGood.$index) === record.$index && !disableds.includes('taxAmount') && model !== 'prefab') {
22180
+ return /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, null, getFieldDecorator('taxAmount', {
22181
22181
  initialValue: editGood.taxAmount,
22182
22182
  rules: [].concat(_toConsumableArray(getReplenishRules('taxAmount')), [{
22183
22183
  required: true,
22184
22184
  message: '税额不能为空'
22185
+ }, {
22186
+ validator: function validator(rule, value, callback) {
22187
+ //含税金额
22188
+ var lineAmountIncludeTax = (editGood === null || editGood === void 0 ? void 0 : editGood.lineAmountIncludeTax) || 0; //不含税金额
22189
+
22190
+ var lineAmountExcludeTax = lineAmountIncludeTax - value;
22191
+ var taxRate = editGood === null || editGood === void 0 ? void 0 : editGood.taxRate;
22192
+
22193
+ if (lineAmountExcludeTax && taxRate && lineAmountIncludeTax) {
22194
+ var total = lineAmountExcludeTax * taxRate / 100;
22195
+
22196
+ if (Number(Math.abs(total - Number(value)).toFixed(2)) <= 0.01) {
22197
+ callback();
22198
+ } else {
22199
+ callback('税额填写错误,请重新输入');
22200
+ }
22201
+ } else {
22202
+ callback();
22203
+ }
22204
+ }
22185
22205
  }, {
22186
22206
  pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/,
22187
22207
  message: '税额必须为数字'
@@ -22197,7 +22217,7 @@ var useColumns$1 = (function (form) {
22197
22217
  }
22198
22218
  }) : /*#__PURE__*/React__default['default'].createElement(MyDiv$2, {
22199
22219
  loading: isCipher$1(changeField, 'taxAmount')
22200
- }));
22220
+ })));
22201
22221
  } else {
22202
22222
  return /*#__PURE__*/React__default['default'].createElement("span", {
22203
22223
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kts-component-invoice-operate",
3
- "version": "3.2.194",
3
+ "version": "3.2.196",
4
4
  "scripts": {
5
5
  "dev": "dumi dev --max-old-space-size=6096",
6
6
  "start": "dumi dev",
@@ -1,7 +1,7 @@
1
1
  # 数电
2
2
 
3
- <!-- ## 简单用法
4
- <code src="./_test/easiest/index.tsx"></code> -->
3
+ ## 简单用法
4
+ <code src="./_test/easiest/index.tsx"></code>
5
5
 
6
6
  ## 建筑服务
7
7
  <code src="./_test/architecture/index.tsx"></code>
@@ -365,7 +365,7 @@ export const onChangeTaxAmount = lazyFn(
365
365
  form.setFieldsValue({ lineAmountExcludeTax });
366
366
 
367
367
  const priceExcludeTax: any = countPrice(lineAmountExcludeTax || '', record?.quantity || '', controller.state.calculatingDigits);
368
-
368
+
369
369
  await controller.setEditGood({ lineAmountExcludeTax, taxAmount: values.taxAmount, priceExcludeTax });
370
370
  form.setFieldsValue({ priceExcludeTax });
371
371
 
@@ -508,26 +508,52 @@ export default (form: WrappedFormUtils) => {
508
508
  align: 'right',
509
509
  width: 119,
510
510
  render: (value: string, record: IGood) => {
511
- if (editGood?.$index === record.$index && !disableds.includes('taxAmount')) {
512
- return getFieldDecorator('taxAmount', {
513
- initialValue: editGood.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
- );
511
+ if (editGood?.$index === record.$index && !disableds.includes('taxAmount')&& model !== 'prefab') {
512
+ return (
513
+ <Form.Item>
514
+ {getFieldDecorator('taxAmount', {
515
+ initialValue: editGood.taxAmount,
516
+ rules: [
517
+ ...getReplenishRules('taxAmount'),
518
+ { required: true, message: '税额不能为空' },
519
+ {
520
+ validator: (rule, value, callback) => {
521
+ //含税金额
522
+ const lineAmountIncludeTax = editGood?.lineAmountIncludeTax || 0;
523
+ //不含税金额
524
+ const lineAmountExcludeTax = lineAmountIncludeTax - value;
525
+ const taxRate = editGood?.taxRate;
526
+ if (lineAmountExcludeTax && taxRate && lineAmountIncludeTax) {
527
+ const total = lineAmountExcludeTax * taxRate / 100;
528
+ if (Number(Math.abs(total - Number(value)).toFixed(2)) <= 0.01) {
529
+ callback();
530
+ } else {
531
+ callback('税额填写错误,请重新输入')
532
+ }
533
+
534
+ } else {
535
+ callback();
536
+ }
537
+
538
+ }
539
+ },
540
+
541
+ { pattern: /^[+-]?(0|([1-9]\d*))(\.\d+)?$/, message: '税额必须为数字' },
542
+ ],
543
+ })(
544
+ isEnables('taxAmount')
545
+ ? <MyInput
546
+ style={{ textAlign: 'right' }}
547
+ loading={isCipher(changeField, 'taxAmount')}
548
+ onChange={() => {
549
+ setChangeField('taxAmount');
550
+ onChangeTaxAmount(controller, form, record);
551
+ }}
552
+ />
553
+ : <MyDiv loading={isCipher(changeField, 'taxAmount')} />
554
+ )}
555
+ </Form.Item>
556
+ )
531
557
  } else {
532
558
  return <span style={{ padding: '0 10px' }}>{isDutyFree(record) ? '***' : parseFloat(value).toFixed(2)}</span>;
533
559
  }