kts-component-invoice-operate 3.2.263 → 3.2.264
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 +126 -30
- package/dist/index.js +126 -30
- package/package.json +1 -1
- package/src/Invoice/ui/digtal/Stakeholder/index.tsx +100 -14
package/dist/index.esm.js
CHANGED
|
@@ -19711,6 +19711,24 @@ var formatCompanyName = function formatCompanyName(e) {
|
|
|
19711
19711
|
if (value) {
|
|
19712
19712
|
return value.replace('(', '(').replace(')', ')').replace(' ', '');
|
|
19713
19713
|
}
|
|
19714
|
+
}; // 参与自然人联动的字段
|
|
19715
|
+
|
|
19716
|
+
|
|
19717
|
+
var GROUP_FIELDS = ['certificateType', 'certificateNumber', 'nationality']; // 各字段为空时的提示
|
|
19718
|
+
|
|
19719
|
+
var EMPTY_MSG = {
|
|
19720
|
+
certificateType: '请选择证件类型',
|
|
19721
|
+
certificateNumber: '请输入证件号码',
|
|
19722
|
+
nationality: '请选择国籍'
|
|
19723
|
+
};
|
|
19724
|
+
var NO_ERROR = {
|
|
19725
|
+
certificateType: '',
|
|
19726
|
+
certificateNumber: '',
|
|
19727
|
+
nationality: ''
|
|
19728
|
+
};
|
|
19729
|
+
|
|
19730
|
+
var isEmpty = function isEmpty(v) {
|
|
19731
|
+
return v === undefined || v === null || typeof v === 'string' && v.trim() === '';
|
|
19714
19732
|
};
|
|
19715
19733
|
/** 干系人 */
|
|
19716
19734
|
|
|
@@ -19749,6 +19767,11 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
|
|
|
19749
19767
|
nationInfo = _React$useState10[0],
|
|
19750
19768
|
setNation = _React$useState10[1];
|
|
19751
19769
|
|
|
19770
|
+
var _React$useState11 = React.useState(NO_ERROR),
|
|
19771
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
19772
|
+
errors = _React$useState12[0],
|
|
19773
|
+
setErrors = _React$useState12[1];
|
|
19774
|
+
|
|
19752
19775
|
var getFieldDecorator = form.getFieldDecorator;
|
|
19753
19776
|
var controller = Invoice.useInvoiceController();
|
|
19754
19777
|
var model = controller.useMemo(function (s) {
|
|
@@ -19806,6 +19829,74 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
|
|
|
19806
19829
|
React.useEffect(function () {
|
|
19807
19830
|
setExpand(typeof props.isExpand === 'boolean' ? props.isExpand : true);
|
|
19808
19831
|
}, [props.isExpand]);
|
|
19832
|
+
/**
|
|
19833
|
+
* 生成校验器:三个字段要么全空,要么全不空
|
|
19834
|
+
* @param {string} field 当前被校验的字段名
|
|
19835
|
+
*/
|
|
19836
|
+
|
|
19837
|
+
var createGroupValidator = function createGroupValidator(field) {
|
|
19838
|
+
return function (rule, value, callback) {
|
|
19839
|
+
var getFieldValue = form.getFieldValue; // 实时读取三个字段的当前值
|
|
19840
|
+
|
|
19841
|
+
var values = GROUP_FIELDS.map(function (name) {
|
|
19842
|
+
return getFieldValue(name);
|
|
19843
|
+
});
|
|
19844
|
+
var filledCount = values.filter(function (v) {
|
|
19845
|
+
return !isEmpty(v);
|
|
19846
|
+
}).length; // 情况一:全空 —— 通过
|
|
19847
|
+
|
|
19848
|
+
if (filledCount === 0) {
|
|
19849
|
+
return callback();
|
|
19850
|
+
} // 情况二:全不空 —— 通过
|
|
19851
|
+
|
|
19852
|
+
|
|
19853
|
+
if (filledCount === GROUP_FIELDS.length) {
|
|
19854
|
+
return callback();
|
|
19855
|
+
} // 情况三:部分填写 —— 为空的字段报错
|
|
19856
|
+
|
|
19857
|
+
|
|
19858
|
+
if (isEmpty(value)) {
|
|
19859
|
+
return Promise.reject(EMPTY_MSG[field]);
|
|
19860
|
+
}
|
|
19861
|
+
|
|
19862
|
+
callback();
|
|
19863
|
+
};
|
|
19864
|
+
};
|
|
19865
|
+
/** 根据三个字段当前值计算错误 */
|
|
19866
|
+
|
|
19867
|
+
|
|
19868
|
+
var calcErrors = function calcErrors() {
|
|
19869
|
+
var getFieldValue = form.getFieldValue;
|
|
19870
|
+
var values = GROUP_FIELDS.map(function (f) {
|
|
19871
|
+
return getFieldValue(f);
|
|
19872
|
+
});
|
|
19873
|
+
var filledCount = values.filter(function (v) {
|
|
19874
|
+
return !isEmpty(v);
|
|
19875
|
+
}).length;
|
|
19876
|
+
|
|
19877
|
+
var errors = _objectSpread2({}, NO_ERROR); // 全空 / 全不空:不报错
|
|
19878
|
+
// 部分填写:为空的字段报错
|
|
19879
|
+
|
|
19880
|
+
|
|
19881
|
+
if (filledCount > 0 && filledCount < GROUP_FIELDS.length) {
|
|
19882
|
+
GROUP_FIELDS.forEach(function (f) {
|
|
19883
|
+
if (isEmpty(getFieldValue(f))) {
|
|
19884
|
+
errors[f] = EMPTY_MSG[f];
|
|
19885
|
+
}
|
|
19886
|
+
});
|
|
19887
|
+
}
|
|
19888
|
+
|
|
19889
|
+
return errors;
|
|
19890
|
+
};
|
|
19891
|
+
/** 任一字段变化时,主动触发另外两个字段的校验,形成联动 */
|
|
19892
|
+
|
|
19893
|
+
|
|
19894
|
+
var handleGroupChange = React.useCallback(function () {
|
|
19895
|
+
setTimeout(function () {
|
|
19896
|
+
form.validateFields(GROUP_FIELDS, {}, function () {});
|
|
19897
|
+
setErrors(calcErrors());
|
|
19898
|
+
}, 0);
|
|
19899
|
+
}, [form]);
|
|
19809
19900
|
var onChangeType = React.useCallback(function (value) {
|
|
19810
19901
|
var buyerTaxId = form === null || form === void 0 ? void 0 : form.getFieldValue("buyerTaxId");
|
|
19811
19902
|
var certificateNumber = form === null || form === void 0 ? void 0 : form.getFieldValue("certificateNumber");
|
|
@@ -19880,13 +19971,15 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
|
|
|
19880
19971
|
nationality: "158"
|
|
19881
19972
|
});
|
|
19882
19973
|
}
|
|
19974
|
+
|
|
19975
|
+
handleGroupChange();
|
|
19883
19976
|
}, [form]);
|
|
19884
19977
|
/** 校验证件号码*/
|
|
19885
19978
|
|
|
19886
19979
|
var validateIDCode = useCallback(function (_, value) {
|
|
19887
19980
|
if (!value) {
|
|
19888
|
-
setStatus('
|
|
19889
|
-
setInfo('
|
|
19981
|
+
setStatus('');
|
|
19982
|
+
setInfo('');
|
|
19890
19983
|
return Promise.resolve();
|
|
19891
19984
|
}
|
|
19892
19985
|
|
|
@@ -19984,8 +20077,8 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
|
|
|
19984
20077
|
}, [form]);
|
|
19985
20078
|
var validateNationality = useCallback(function (_, value) {
|
|
19986
20079
|
if (!value) {
|
|
19987
|
-
setNationStatue('
|
|
19988
|
-
setNation('
|
|
20080
|
+
setNationStatue('');
|
|
20081
|
+
setNation('');
|
|
19989
20082
|
return Promise.resolve();
|
|
19990
20083
|
}
|
|
19991
20084
|
|
|
@@ -20373,49 +20466,50 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
|
|
|
20373
20466
|
span: 6
|
|
20374
20467
|
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
20375
20468
|
label: "\u8BC1\u4EF6\u7C7B\u578B",
|
|
20376
|
-
colon: false
|
|
20469
|
+
colon: false,
|
|
20470
|
+
validateStatus: errors.certificateType ? 'error' : "",
|
|
20471
|
+
help: errors.certificateType
|
|
20377
20472
|
}, getFieldDecorator('certificateType', {
|
|
20378
20473
|
rules: [{
|
|
20379
|
-
|
|
20380
|
-
message: '证件类型必填'
|
|
20474
|
+
validator: createGroupValidator('certificateType')
|
|
20381
20475
|
}]
|
|
20382
20476
|
})( /*#__PURE__*/React.createElement(CardSelect, {
|
|
20383
20477
|
onChange: onChangeType,
|
|
20384
20478
|
readOnly: isReadOnly('certificateType'),
|
|
20385
|
-
placeholder: "\
|
|
20386
|
-
autoComplete: "off"
|
|
20479
|
+
placeholder: "\u8BF7\u9009\u62E9",
|
|
20480
|
+
autoComplete: "off",
|
|
20481
|
+
allowClear: true
|
|
20387
20482
|
})))), /*#__PURE__*/React.createElement(Col, {
|
|
20388
20483
|
span: 7
|
|
20389
20484
|
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
20390
20485
|
label: "\u8BC1\u4EF6\u53F7\u7801",
|
|
20391
20486
|
colon: false,
|
|
20392
|
-
validateStatus: validateStatus,
|
|
20393
|
-
help: errorInfo
|
|
20487
|
+
validateStatus: validateStatus || (errors.certificateNumber ? 'error' : ""),
|
|
20488
|
+
help: errorInfo || errors.certificateNumber
|
|
20394
20489
|
}, getFieldDecorator('certificateNumber', {
|
|
20395
20490
|
rules: [{
|
|
20396
|
-
required: true,
|
|
20397
|
-
message: '证件号码必填'
|
|
20398
|
-
}, {
|
|
20399
20491
|
max: 30,
|
|
20400
20492
|
message: "\u5185\u5BB9\u8D85\u957F"
|
|
20493
|
+
}, {
|
|
20494
|
+
validator: createGroupValidator('certificateNumber')
|
|
20401
20495
|
}, {
|
|
20402
20496
|
validator: validateIDCode
|
|
20403
20497
|
}]
|
|
20404
20498
|
})( /*#__PURE__*/React.createElement(MyInput$1, {
|
|
20405
20499
|
readOnly: isReadOnly('certificateNumber'),
|
|
20406
|
-
placeholder: "\
|
|
20407
|
-
autoComplete: "off"
|
|
20500
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
|
20501
|
+
autoComplete: "off",
|
|
20502
|
+
onChange: handleGroupChange
|
|
20408
20503
|
})))), /*#__PURE__*/React.createElement(Col, {
|
|
20409
20504
|
span: 6
|
|
20410
20505
|
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
20411
20506
|
label: "\u56FD\u7C4D(\u6216\u5730\u533A)",
|
|
20412
20507
|
colon: false,
|
|
20413
|
-
validateStatus: nation,
|
|
20414
|
-
help: nationInfo
|
|
20508
|
+
validateStatus: nation || (errors.nationality ? 'error' : ""),
|
|
20509
|
+
help: nationInfo || errors.nationality
|
|
20415
20510
|
}, getFieldDecorator('nationality', {
|
|
20416
20511
|
rules: [{
|
|
20417
|
-
|
|
20418
|
-
message: '国籍必填'
|
|
20512
|
+
validator: createGroupValidator('nationality')
|
|
20419
20513
|
}, {
|
|
20420
20514
|
validator: validateNationality
|
|
20421
20515
|
}]
|
|
@@ -20432,18 +20526,20 @@ var Stakeholder$1 = decorator(Form.create())(function (props) {
|
|
|
20432
20526
|
return false;
|
|
20433
20527
|
},
|
|
20434
20528
|
readOnly: isReadOnly('nationality'),
|
|
20435
|
-
placeholder: "\
|
|
20436
|
-
autoComplete: "off"
|
|
20529
|
+
placeholder: "\u8BF7\u9009\u62E9",
|
|
20530
|
+
autoComplete: "off",
|
|
20531
|
+
onChange: handleGroupChange,
|
|
20532
|
+
allowClear: true
|
|
20437
20533
|
}))))))));
|
|
20438
20534
|
});
|
|
20439
20535
|
|
|
20440
20536
|
function NaturalPersonFlag(props) {
|
|
20441
20537
|
var controller = Invoice.useInvoiceController();
|
|
20442
20538
|
|
|
20443
|
-
var _React$
|
|
20444
|
-
_React$
|
|
20445
|
-
value = _React$
|
|
20446
|
-
setValue = _React$
|
|
20539
|
+
var _React$useState13 = React.useState(props.value || 'COMPANY'),
|
|
20540
|
+
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
20541
|
+
value = _React$useState14[0],
|
|
20542
|
+
setValue = _React$useState14[1];
|
|
20447
20543
|
|
|
20448
20544
|
var onChange = React.useCallback(function (e) {
|
|
20449
20545
|
if (props.readOnly) return;
|
|
@@ -20492,10 +20588,10 @@ function BuyerNameInput$1(props) {
|
|
|
20492
20588
|
return s.autoComplete;
|
|
20493
20589
|
}, []);
|
|
20494
20590
|
|
|
20495
|
-
var _React$
|
|
20496
|
-
_React$
|
|
20497
|
-
options = _React$
|
|
20498
|
-
setOptions = _React$
|
|
20591
|
+
var _React$useState15 = React.useState([]),
|
|
20592
|
+
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
20593
|
+
options = _React$useState16[0],
|
|
20594
|
+
setOptions = _React$useState16[1];
|
|
20499
20595
|
|
|
20500
20596
|
var onChangeAutoComplete = React.useCallback(function (value) {
|
|
20501
20597
|
var record = options.filter(function (e) {
|
package/dist/index.js
CHANGED
|
@@ -19721,6 +19721,24 @@ var formatCompanyName = function formatCompanyName(e) {
|
|
|
19721
19721
|
if (value) {
|
|
19722
19722
|
return value.replace('(', '(').replace(')', ')').replace(' ', '');
|
|
19723
19723
|
}
|
|
19724
|
+
}; // 参与自然人联动的字段
|
|
19725
|
+
|
|
19726
|
+
|
|
19727
|
+
var GROUP_FIELDS = ['certificateType', 'certificateNumber', 'nationality']; // 各字段为空时的提示
|
|
19728
|
+
|
|
19729
|
+
var EMPTY_MSG = {
|
|
19730
|
+
certificateType: '请选择证件类型',
|
|
19731
|
+
certificateNumber: '请输入证件号码',
|
|
19732
|
+
nationality: '请选择国籍'
|
|
19733
|
+
};
|
|
19734
|
+
var NO_ERROR = {
|
|
19735
|
+
certificateType: '',
|
|
19736
|
+
certificateNumber: '',
|
|
19737
|
+
nationality: ''
|
|
19738
|
+
};
|
|
19739
|
+
|
|
19740
|
+
var isEmpty = function isEmpty(v) {
|
|
19741
|
+
return v === undefined || v === null || typeof v === 'string' && v.trim() === '';
|
|
19724
19742
|
};
|
|
19725
19743
|
/** 干系人 */
|
|
19726
19744
|
|
|
@@ -19759,6 +19777,11 @@ var Stakeholder$1 = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(fu
|
|
|
19759
19777
|
nationInfo = _React$useState10[0],
|
|
19760
19778
|
setNation = _React$useState10[1];
|
|
19761
19779
|
|
|
19780
|
+
var _React$useState11 = React__default['default'].useState(NO_ERROR),
|
|
19781
|
+
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
19782
|
+
errors = _React$useState12[0],
|
|
19783
|
+
setErrors = _React$useState12[1];
|
|
19784
|
+
|
|
19762
19785
|
var getFieldDecorator = form.getFieldDecorator;
|
|
19763
19786
|
var controller = Invoice.useInvoiceController();
|
|
19764
19787
|
var model = controller.useMemo(function (s) {
|
|
@@ -19816,6 +19839,74 @@ var Stakeholder$1 = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(fu
|
|
|
19816
19839
|
React__default['default'].useEffect(function () {
|
|
19817
19840
|
setExpand(typeof props.isExpand === 'boolean' ? props.isExpand : true);
|
|
19818
19841
|
}, [props.isExpand]);
|
|
19842
|
+
/**
|
|
19843
|
+
* 生成校验器:三个字段要么全空,要么全不空
|
|
19844
|
+
* @param {string} field 当前被校验的字段名
|
|
19845
|
+
*/
|
|
19846
|
+
|
|
19847
|
+
var createGroupValidator = function createGroupValidator(field) {
|
|
19848
|
+
return function (rule, value, callback) {
|
|
19849
|
+
var getFieldValue = form.getFieldValue; // 实时读取三个字段的当前值
|
|
19850
|
+
|
|
19851
|
+
var values = GROUP_FIELDS.map(function (name) {
|
|
19852
|
+
return getFieldValue(name);
|
|
19853
|
+
});
|
|
19854
|
+
var filledCount = values.filter(function (v) {
|
|
19855
|
+
return !isEmpty(v);
|
|
19856
|
+
}).length; // 情况一:全空 —— 通过
|
|
19857
|
+
|
|
19858
|
+
if (filledCount === 0) {
|
|
19859
|
+
return callback();
|
|
19860
|
+
} // 情况二:全不空 —— 通过
|
|
19861
|
+
|
|
19862
|
+
|
|
19863
|
+
if (filledCount === GROUP_FIELDS.length) {
|
|
19864
|
+
return callback();
|
|
19865
|
+
} // 情况三:部分填写 —— 为空的字段报错
|
|
19866
|
+
|
|
19867
|
+
|
|
19868
|
+
if (isEmpty(value)) {
|
|
19869
|
+
return Promise.reject(EMPTY_MSG[field]);
|
|
19870
|
+
}
|
|
19871
|
+
|
|
19872
|
+
callback();
|
|
19873
|
+
};
|
|
19874
|
+
};
|
|
19875
|
+
/** 根据三个字段当前值计算错误 */
|
|
19876
|
+
|
|
19877
|
+
|
|
19878
|
+
var calcErrors = function calcErrors() {
|
|
19879
|
+
var getFieldValue = form.getFieldValue;
|
|
19880
|
+
var values = GROUP_FIELDS.map(function (f) {
|
|
19881
|
+
return getFieldValue(f);
|
|
19882
|
+
});
|
|
19883
|
+
var filledCount = values.filter(function (v) {
|
|
19884
|
+
return !isEmpty(v);
|
|
19885
|
+
}).length;
|
|
19886
|
+
|
|
19887
|
+
var errors = _objectSpread2({}, NO_ERROR); // 全空 / 全不空:不报错
|
|
19888
|
+
// 部分填写:为空的字段报错
|
|
19889
|
+
|
|
19890
|
+
|
|
19891
|
+
if (filledCount > 0 && filledCount < GROUP_FIELDS.length) {
|
|
19892
|
+
GROUP_FIELDS.forEach(function (f) {
|
|
19893
|
+
if (isEmpty(getFieldValue(f))) {
|
|
19894
|
+
errors[f] = EMPTY_MSG[f];
|
|
19895
|
+
}
|
|
19896
|
+
});
|
|
19897
|
+
}
|
|
19898
|
+
|
|
19899
|
+
return errors;
|
|
19900
|
+
};
|
|
19901
|
+
/** 任一字段变化时,主动触发另外两个字段的校验,形成联动 */
|
|
19902
|
+
|
|
19903
|
+
|
|
19904
|
+
var handleGroupChange = React__default['default'].useCallback(function () {
|
|
19905
|
+
setTimeout(function () {
|
|
19906
|
+
form.validateFields(GROUP_FIELDS, {}, function () {});
|
|
19907
|
+
setErrors(calcErrors());
|
|
19908
|
+
}, 0);
|
|
19909
|
+
}, [form]);
|
|
19819
19910
|
var onChangeType = React__default['default'].useCallback(function (value) {
|
|
19820
19911
|
var buyerTaxId = form === null || form === void 0 ? void 0 : form.getFieldValue("buyerTaxId");
|
|
19821
19912
|
var certificateNumber = form === null || form === void 0 ? void 0 : form.getFieldValue("certificateNumber");
|
|
@@ -19890,13 +19981,15 @@ var Stakeholder$1 = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(fu
|
|
|
19890
19981
|
nationality: "158"
|
|
19891
19982
|
});
|
|
19892
19983
|
}
|
|
19984
|
+
|
|
19985
|
+
handleGroupChange();
|
|
19893
19986
|
}, [form]);
|
|
19894
19987
|
/** 校验证件号码*/
|
|
19895
19988
|
|
|
19896
19989
|
var validateIDCode = React.useCallback(function (_, value) {
|
|
19897
19990
|
if (!value) {
|
|
19898
|
-
setStatus('
|
|
19899
|
-
setInfo('
|
|
19991
|
+
setStatus('');
|
|
19992
|
+
setInfo('');
|
|
19900
19993
|
return Promise.resolve();
|
|
19901
19994
|
}
|
|
19902
19995
|
|
|
@@ -19994,8 +20087,8 @@ var Stakeholder$1 = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(fu
|
|
|
19994
20087
|
}, [form]);
|
|
19995
20088
|
var validateNationality = React.useCallback(function (_, value) {
|
|
19996
20089
|
if (!value) {
|
|
19997
|
-
setNationStatue('
|
|
19998
|
-
setNation('
|
|
20090
|
+
setNationStatue('');
|
|
20091
|
+
setNation('');
|
|
19999
20092
|
return Promise.resolve();
|
|
20000
20093
|
}
|
|
20001
20094
|
|
|
@@ -20383,49 +20476,50 @@ var Stakeholder$1 = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(fu
|
|
|
20383
20476
|
span: 6
|
|
20384
20477
|
}, /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, {
|
|
20385
20478
|
label: "\u8BC1\u4EF6\u7C7B\u578B",
|
|
20386
|
-
colon: false
|
|
20479
|
+
colon: false,
|
|
20480
|
+
validateStatus: errors.certificateType ? 'error' : "",
|
|
20481
|
+
help: errors.certificateType
|
|
20387
20482
|
}, getFieldDecorator('certificateType', {
|
|
20388
20483
|
rules: [{
|
|
20389
|
-
|
|
20390
|
-
message: '证件类型必填'
|
|
20484
|
+
validator: createGroupValidator('certificateType')
|
|
20391
20485
|
}]
|
|
20392
20486
|
})( /*#__PURE__*/React__default['default'].createElement(CardSelect, {
|
|
20393
20487
|
onChange: onChangeType,
|
|
20394
20488
|
readOnly: isReadOnly('certificateType'),
|
|
20395
|
-
placeholder: "\
|
|
20396
|
-
autoComplete: "off"
|
|
20489
|
+
placeholder: "\u8BF7\u9009\u62E9",
|
|
20490
|
+
autoComplete: "off",
|
|
20491
|
+
allowClear: true
|
|
20397
20492
|
})))), /*#__PURE__*/React__default['default'].createElement(ktsXui.Col, {
|
|
20398
20493
|
span: 7
|
|
20399
20494
|
}, /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, {
|
|
20400
20495
|
label: "\u8BC1\u4EF6\u53F7\u7801",
|
|
20401
20496
|
colon: false,
|
|
20402
|
-
validateStatus: validateStatus,
|
|
20403
|
-
help: errorInfo
|
|
20497
|
+
validateStatus: validateStatus || (errors.certificateNumber ? 'error' : ""),
|
|
20498
|
+
help: errorInfo || errors.certificateNumber
|
|
20404
20499
|
}, getFieldDecorator('certificateNumber', {
|
|
20405
20500
|
rules: [{
|
|
20406
|
-
required: true,
|
|
20407
|
-
message: '证件号码必填'
|
|
20408
|
-
}, {
|
|
20409
20501
|
max: 30,
|
|
20410
20502
|
message: "\u5185\u5BB9\u8D85\u957F"
|
|
20503
|
+
}, {
|
|
20504
|
+
validator: createGroupValidator('certificateNumber')
|
|
20411
20505
|
}, {
|
|
20412
20506
|
validator: validateIDCode
|
|
20413
20507
|
}]
|
|
20414
20508
|
})( /*#__PURE__*/React__default['default'].createElement(MyInput$1, {
|
|
20415
20509
|
readOnly: isReadOnly('certificateNumber'),
|
|
20416
|
-
placeholder: "\
|
|
20417
|
-
autoComplete: "off"
|
|
20510
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
|
20511
|
+
autoComplete: "off",
|
|
20512
|
+
onChange: handleGroupChange
|
|
20418
20513
|
})))), /*#__PURE__*/React__default['default'].createElement(ktsXui.Col, {
|
|
20419
20514
|
span: 6
|
|
20420
20515
|
}, /*#__PURE__*/React__default['default'].createElement(ktsComponentsAntdX3.Form.Item, {
|
|
20421
20516
|
label: "\u56FD\u7C4D(\u6216\u5730\u533A)",
|
|
20422
20517
|
colon: false,
|
|
20423
|
-
validateStatus: nation,
|
|
20424
|
-
help: nationInfo
|
|
20518
|
+
validateStatus: nation || (errors.nationality ? 'error' : ""),
|
|
20519
|
+
help: nationInfo || errors.nationality
|
|
20425
20520
|
}, getFieldDecorator('nationality', {
|
|
20426
20521
|
rules: [{
|
|
20427
|
-
|
|
20428
|
-
message: '国籍必填'
|
|
20522
|
+
validator: createGroupValidator('nationality')
|
|
20429
20523
|
}, {
|
|
20430
20524
|
validator: validateNationality
|
|
20431
20525
|
}]
|
|
@@ -20442,18 +20536,20 @@ var Stakeholder$1 = GreyReactBox.decorator(ktsComponentsAntdX3.Form.create())(fu
|
|
|
20442
20536
|
return false;
|
|
20443
20537
|
},
|
|
20444
20538
|
readOnly: isReadOnly('nationality'),
|
|
20445
|
-
placeholder: "\
|
|
20446
|
-
autoComplete: "off"
|
|
20539
|
+
placeholder: "\u8BF7\u9009\u62E9",
|
|
20540
|
+
autoComplete: "off",
|
|
20541
|
+
onChange: handleGroupChange,
|
|
20542
|
+
allowClear: true
|
|
20447
20543
|
}))))))));
|
|
20448
20544
|
});
|
|
20449
20545
|
|
|
20450
20546
|
function NaturalPersonFlag(props) {
|
|
20451
20547
|
var controller = Invoice.useInvoiceController();
|
|
20452
20548
|
|
|
20453
|
-
var _React$
|
|
20454
|
-
_React$
|
|
20455
|
-
value = _React$
|
|
20456
|
-
setValue = _React$
|
|
20549
|
+
var _React$useState13 = React__default['default'].useState(props.value || 'COMPANY'),
|
|
20550
|
+
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
20551
|
+
value = _React$useState14[0],
|
|
20552
|
+
setValue = _React$useState14[1];
|
|
20457
20553
|
|
|
20458
20554
|
var onChange = React__default['default'].useCallback(function (e) {
|
|
20459
20555
|
if (props.readOnly) return;
|
|
@@ -20502,10 +20598,10 @@ function BuyerNameInput$1(props) {
|
|
|
20502
20598
|
return s.autoComplete;
|
|
20503
20599
|
}, []);
|
|
20504
20600
|
|
|
20505
|
-
var _React$
|
|
20506
|
-
_React$
|
|
20507
|
-
options = _React$
|
|
20508
|
-
setOptions = _React$
|
|
20601
|
+
var _React$useState15 = React__default['default'].useState([]),
|
|
20602
|
+
_React$useState16 = _slicedToArray(_React$useState15, 2),
|
|
20603
|
+
options = _React$useState16[0],
|
|
20604
|
+
setOptions = _React$useState16[1];
|
|
20509
20605
|
|
|
20510
20606
|
var onChangeAutoComplete = React__default['default'].useCallback(function (value) {
|
|
20511
20607
|
var record = options.filter(function (e) {
|
package/package.json
CHANGED
|
@@ -51,6 +51,24 @@ const formatCompanyName = (e: any) => {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// 参与自然人联动的字段
|
|
55
|
+
const GROUP_FIELDS = ['certificateType', 'certificateNumber', 'nationality'];
|
|
56
|
+
|
|
57
|
+
// 各字段为空时的提示
|
|
58
|
+
const EMPTY_MSG: any = {
|
|
59
|
+
certificateType: '请选择证件类型',
|
|
60
|
+
certificateNumber: '请输入证件号码',
|
|
61
|
+
nationality: '请选择国籍',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const NO_ERROR = {
|
|
65
|
+
certificateType: '',
|
|
66
|
+
certificateNumber: '',
|
|
67
|
+
nationality: '',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const isEmpty = (v: any) =>
|
|
71
|
+
v === undefined || v === null || (typeof v === 'string' && v.trim() === '');
|
|
54
72
|
export interface IStakeholder {
|
|
55
73
|
|
|
56
74
|
/** 是否显示导入按钮 */
|
|
@@ -96,6 +114,7 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
96
114
|
const [errorInfo, setInfo] = React.useState('');
|
|
97
115
|
const [nation, setNationStatue] = React.useState<any>('');
|
|
98
116
|
const [nationInfo, setNation] = React.useState('');
|
|
117
|
+
const [errors, setErrors] = React.useState<any>(NO_ERROR);
|
|
99
118
|
|
|
100
119
|
const { getFieldDecorator } = form;
|
|
101
120
|
|
|
@@ -149,6 +168,62 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
149
168
|
setExpand(typeof props.isExpand === 'boolean' ? props.isExpand : true);
|
|
150
169
|
}, [props.isExpand])
|
|
151
170
|
|
|
171
|
+
/**
|
|
172
|
+
* 生成校验器:三个字段要么全空,要么全不空
|
|
173
|
+
* @param {string} field 当前被校验的字段名
|
|
174
|
+
*/
|
|
175
|
+
const createGroupValidator = (field: any) => (rule: any, value: any, callback: any) => {
|
|
176
|
+
const { getFieldValue } = form;
|
|
177
|
+
|
|
178
|
+
// 实时读取三个字段的当前值
|
|
179
|
+
const values = GROUP_FIELDS.map(name => getFieldValue(name));
|
|
180
|
+
const filledCount = values.filter(v => !isEmpty(v)).length;
|
|
181
|
+
|
|
182
|
+
// 情况一:全空 —— 通过
|
|
183
|
+
if (filledCount === 0) {
|
|
184
|
+
return callback();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// 情况二:全不空 —— 通过
|
|
188
|
+
if (filledCount === GROUP_FIELDS.length) {
|
|
189
|
+
return callback();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 情况三:部分填写 —— 为空的字段报错
|
|
193
|
+
if (isEmpty(value)) {
|
|
194
|
+
return Promise.reject(EMPTY_MSG[field]);
|
|
195
|
+
}
|
|
196
|
+
callback();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/** 根据三个字段当前值计算错误 */
|
|
200
|
+
const calcErrors = () => {
|
|
201
|
+
const { getFieldValue } = form;
|
|
202
|
+
const values = GROUP_FIELDS.map(f => getFieldValue(f));
|
|
203
|
+
const filledCount = values.filter(v => !isEmpty(v)).length;
|
|
204
|
+
|
|
205
|
+
const errors:any = { ...NO_ERROR };
|
|
206
|
+
|
|
207
|
+
// 全空 / 全不空:不报错
|
|
208
|
+
// 部分填写:为空的字段报错
|
|
209
|
+
if (filledCount > 0 && filledCount < GROUP_FIELDS.length) {
|
|
210
|
+
GROUP_FIELDS.forEach(f => {
|
|
211
|
+
if (isEmpty(getFieldValue(f))) {
|
|
212
|
+
errors[f] = EMPTY_MSG[f];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return errors;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/** 任一字段变化时,主动触发另外两个字段的校验,形成联动 */
|
|
220
|
+
const handleGroupChange = React.useCallback(() => {
|
|
221
|
+
setTimeout(() => {
|
|
222
|
+
form.validateFields(GROUP_FIELDS, { }, () => { });
|
|
223
|
+
setErrors(calcErrors())
|
|
224
|
+
}, 0);
|
|
225
|
+
}, [form]);
|
|
226
|
+
|
|
152
227
|
const onChangeType = React.useCallback(
|
|
153
228
|
(value: string) => {
|
|
154
229
|
const buyerTaxId = form?.getFieldValue("buyerTaxId");
|
|
@@ -223,15 +298,17 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
223
298
|
// 当“自然人证件类型”选择“238:中华人民共和国台湾居民居住证”时,校验是否为“ 158:中国台湾”
|
|
224
299
|
form?.setFieldsValue({ nationality: "158" });
|
|
225
300
|
}
|
|
301
|
+
handleGroupChange()
|
|
226
302
|
},
|
|
227
303
|
[form]
|
|
228
304
|
);
|
|
305
|
+
|
|
229
306
|
/** 校验证件号码*/
|
|
230
307
|
const validateIDCode = useCallback(
|
|
231
308
|
(_: any, value: string) => {
|
|
232
309
|
if (!value) {
|
|
233
|
-
setStatus('
|
|
234
|
-
setInfo('
|
|
310
|
+
setStatus('');
|
|
311
|
+
setInfo('')
|
|
235
312
|
return Promise.resolve();
|
|
236
313
|
}
|
|
237
314
|
|
|
@@ -339,8 +416,8 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
339
416
|
const validateNationality = useCallback(
|
|
340
417
|
(_: any, value: string) => {
|
|
341
418
|
if (!value) {
|
|
342
|
-
setNationStatue('
|
|
343
|
-
setNation('
|
|
419
|
+
setNationStatue('');
|
|
420
|
+
setNation('');
|
|
344
421
|
return Promise.resolve();
|
|
345
422
|
}
|
|
346
423
|
const idtype = form?.getFieldValue("certificateType");
|
|
@@ -400,6 +477,7 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
400
477
|
setNationStatue('');
|
|
401
478
|
setNation('');
|
|
402
479
|
return Promise.resolve();
|
|
480
|
+
|
|
403
481
|
},
|
|
404
482
|
[form]
|
|
405
483
|
);
|
|
@@ -626,25 +704,33 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
626
704
|
|
|
627
705
|
</Form.Item>
|
|
628
706
|
</Col>
|
|
629
|
-
{/* <label
|
|
707
|
+
{/* <label>自然人购买方补充信息</label> */}
|
|
630
708
|
<Col span={6} >
|
|
631
|
-
<Form.Item label='证件类型' colon={false} >
|
|
709
|
+
<Form.Item label='证件类型' colon={false} validateStatus={ errors.certificateType ? 'error' : "" } help={errors.certificateType}>
|
|
632
710
|
{getFieldDecorator('certificateType', {
|
|
633
|
-
rules: [
|
|
634
|
-
|
|
711
|
+
rules: [
|
|
712
|
+
{ validator: createGroupValidator('certificateType') }
|
|
713
|
+
]
|
|
714
|
+
})(<CardSelect onChange={onChangeType} readOnly={isReadOnly('certificateType')} placeholder="请选择" autoComplete="off" allowClear={true} />)}
|
|
635
715
|
</Form.Item>
|
|
636
716
|
</Col>
|
|
637
717
|
<Col span={7} >
|
|
638
|
-
<Form.Item label='证件号码' colon={false} validateStatus={validateStatus} help={errorInfo}>
|
|
718
|
+
<Form.Item label='证件号码' colon={false} validateStatus={validateStatus || (errors.certificateNumber ? 'error' : "") } help={errorInfo || errors.certificateNumber}>
|
|
639
719
|
{getFieldDecorator('certificateNumber', {
|
|
640
|
-
rules: [
|
|
641
|
-
|
|
720
|
+
rules: [
|
|
721
|
+
{ max: 30, message: `内容超长` },
|
|
722
|
+
{ validator: createGroupValidator('certificateNumber') },
|
|
723
|
+
{ validator: validateIDCode },]
|
|
724
|
+
})(<MyInput readOnly={isReadOnly('certificateNumber')} placeholder="请输入" autoComplete="off" onChange={handleGroupChange} />)}
|
|
642
725
|
</Form.Item>
|
|
643
726
|
</Col>
|
|
644
727
|
<Col span={6} >
|
|
645
|
-
<Form.Item label='国籍(或地区)' colon={false} validateStatus={nation} help={nationInfo}>
|
|
728
|
+
<Form.Item label='国籍(或地区)' colon={false} validateStatus={nation || (errors.nationality ? 'error' : "")} help={nationInfo || errors.nationality}>
|
|
646
729
|
{getFieldDecorator('nationality', {
|
|
647
|
-
rules: [
|
|
730
|
+
rules: [
|
|
731
|
+
{ validator: createGroupValidator('nationality') },
|
|
732
|
+
{ validator: validateNationality },
|
|
733
|
+
]
|
|
648
734
|
})(<NationalSelect showSearch={true}
|
|
649
735
|
optionFilterProp="children"
|
|
650
736
|
filterOption={(input: any, option: any) => {
|
|
@@ -652,7 +738,7 @@ export default decorator<IStakeholder, IStakeholder & FormComponentProps>(Form.c
|
|
|
652
738
|
return option.label?.indexOf(input) >= 0;
|
|
653
739
|
}
|
|
654
740
|
return false;
|
|
655
|
-
}} readOnly={isReadOnly('nationality')} placeholder="
|
|
741
|
+
}} readOnly={isReadOnly('nationality')} placeholder="请选择" autoComplete="off" onChange={handleGroupChange} allowClear={true} />)}
|
|
656
742
|
</Form.Item>
|
|
657
743
|
</Col>
|
|
658
744
|
</Row>
|