cnhis-design-vue 3.1.12-beta.3 → 3.1.12-beta.4
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/es/packages/form-render/src/constants/index.d.ts +9 -0
- package/es/packages/form-render/src/constants/index.js +11 -1
- package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +1 -0
- package/es/packages/form-render/src/hooks/useBusinessBinding.js +23 -19
- package/es/packages/form-render/src/hooks/useTypeNormalize.js +3 -0
- package/es/packages/form-render/src/types/index.d.ts +2 -1
- package/es/packages/form-render/src/utils/index.d.ts +2 -2
- package/es/packages/form-render/src/utils/index.js +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ export declare enum FIELD_BUSINESS_TYPE {
|
|
|
13
13
|
PASSWORD = "password",
|
|
14
14
|
ID_CARD = "id_card",
|
|
15
15
|
AGE = "age",
|
|
16
|
+
AGE_UNIT = "age_unit",
|
|
16
17
|
MOBILE = "mobile",
|
|
17
18
|
TELEPHONE = "telephone",
|
|
18
19
|
EMAIL = "email",
|
|
@@ -28,3 +29,11 @@ export declare enum FIELD_SEX_VALUE {
|
|
|
28
29
|
MALE = "1",
|
|
29
30
|
FEMALE = "2"
|
|
30
31
|
}
|
|
32
|
+
export declare enum FIELD_AGE_UNIT {
|
|
33
|
+
DAY = "D",
|
|
34
|
+
MONTH = "M",
|
|
35
|
+
YEAR = "Y",
|
|
36
|
+
HOUR = "H",
|
|
37
|
+
WEEK = "W",
|
|
38
|
+
MINUTE = "N"
|
|
39
|
+
}
|
|
@@ -9,6 +9,7 @@ var FIELD_BUSINESS_TYPE = /* @__PURE__ */ ((FIELD_BUSINESS_TYPE2) => {
|
|
|
9
9
|
FIELD_BUSINESS_TYPE2["PASSWORD"] = "password";
|
|
10
10
|
FIELD_BUSINESS_TYPE2["ID_CARD"] = "id_card";
|
|
11
11
|
FIELD_BUSINESS_TYPE2["AGE"] = "age";
|
|
12
|
+
FIELD_BUSINESS_TYPE2["AGE_UNIT"] = "age_unit";
|
|
12
13
|
FIELD_BUSINESS_TYPE2["MOBILE"] = "mobile";
|
|
13
14
|
FIELD_BUSINESS_TYPE2["TELEPHONE"] = "telephone";
|
|
14
15
|
FIELD_BUSINESS_TYPE2["EMAIL"] = "email";
|
|
@@ -26,5 +27,14 @@ var FIELD_SEX_VALUE = /* @__PURE__ */ ((FIELD_SEX_VALUE2) => {
|
|
|
26
27
|
FIELD_SEX_VALUE2["FEMALE"] = "2";
|
|
27
28
|
return FIELD_SEX_VALUE2;
|
|
28
29
|
})(FIELD_SEX_VALUE || {});
|
|
30
|
+
var FIELD_AGE_UNIT = /* @__PURE__ */ ((FIELD_AGE_UNIT2) => {
|
|
31
|
+
FIELD_AGE_UNIT2["DAY"] = "D";
|
|
32
|
+
FIELD_AGE_UNIT2["MONTH"] = "M";
|
|
33
|
+
FIELD_AGE_UNIT2["YEAR"] = "Y";
|
|
34
|
+
FIELD_AGE_UNIT2["HOUR"] = "H";
|
|
35
|
+
FIELD_AGE_UNIT2["WEEK"] = "W";
|
|
36
|
+
FIELD_AGE_UNIT2["MINUTE"] = "N";
|
|
37
|
+
return FIELD_AGE_UNIT2;
|
|
38
|
+
})(FIELD_AGE_UNIT || {});
|
|
29
39
|
|
|
30
|
-
export { FIELD_BUSINESS_TYPE, FIELD_SEX_VALUE, FormItemLineBarDepKeyPrepend, InjectAsyncQueue, InjectionBusinessCollector, InjectionChangeContextCollector, InjectionFormItemDepsCollector, InjectionFormUUID, InjectionSchemaField };
|
|
40
|
+
export { FIELD_AGE_UNIT, FIELD_BUSINESS_TYPE, FIELD_SEX_VALUE, FormItemLineBarDepKeyPrepend, InjectAsyncQueue, InjectionBusinessCollector, InjectionChangeContextCollector, InjectionFormItemDepsCollector, InjectionFormUUID, InjectionSchemaField };
|
|
@@ -9,6 +9,7 @@ export declare class BusinessCollector {
|
|
|
9
9
|
collect(type: FIELD_BUSINESS_TYPE, fieldName: string): void;
|
|
10
10
|
getField(type: FIELD_BUSINESS_TYPE): string[];
|
|
11
11
|
getType(fieldName: string): FIELD_BUSINESS_TYPE | undefined;
|
|
12
|
+
private setAge;
|
|
12
13
|
private handlerIdCardType;
|
|
13
14
|
private handlerBirthdayType;
|
|
14
15
|
handlerMap: Map<FIELD_BUSINESS_TYPE, (formModel: Form, value: unknown) => void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isString } from '@vueuse/core';
|
|
2
|
-
import { FIELD_BUSINESS_TYPE } from '../constants/index.js';
|
|
2
|
+
import { FIELD_BUSINESS_TYPE, FIELD_AGE_UNIT } from '../constants/index.js';
|
|
3
3
|
import { isIdCard, parseIdCard, parseBirthday } from '../utils/index.js';
|
|
4
4
|
|
|
5
5
|
class BusinessCollector {
|
|
@@ -24,21 +24,36 @@ class BusinessCollector {
|
|
|
24
24
|
getType(fieldName) {
|
|
25
25
|
return this.fieldNameCollector.get(fieldName);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
setAge(formModel, context) {
|
|
28
|
+
const value = context.day < 30 ? { ageUnit: FIELD_AGE_UNIT.DAY, age: context.day } : context.day < 365 ? { ageUnit: FIELD_AGE_UNIT.MONTH, age: context.month } : { ageUnit: FIELD_AGE_UNIT.YEAR, age: context.year };
|
|
29
|
+
const ageUnitFields = this.getField(FIELD_BUSINESS_TYPE.AGE_UNIT);
|
|
30
|
+
ageUnitFields.forEach((field) => {
|
|
31
|
+
formModel.setFieldState(field, (state) => {
|
|
32
|
+
state.value = this.valueFilter({
|
|
33
|
+
fieldKey: field,
|
|
34
|
+
value: value.ageUnit,
|
|
35
|
+
context,
|
|
36
|
+
type: FIELD_BUSINESS_TYPE.AGE_UNIT
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
31
40
|
const ageFields = this.getField(FIELD_BUSINESS_TYPE.AGE);
|
|
32
41
|
ageFields.forEach((field) => {
|
|
33
42
|
formModel.setFieldState(field, (state) => {
|
|
34
43
|
state.value = this.valueFilter({
|
|
35
44
|
fieldKey: field,
|
|
36
|
-
value:
|
|
37
|
-
context
|
|
45
|
+
value: ageUnitFields.length ? value.age : context.year,
|
|
46
|
+
context,
|
|
38
47
|
type: FIELD_BUSINESS_TYPE.AGE
|
|
39
48
|
});
|
|
40
49
|
});
|
|
41
50
|
});
|
|
51
|
+
}
|
|
52
|
+
handlerIdCardType(formModel, value) {
|
|
53
|
+
if (!value || !isString(value) || !isIdCard(value))
|
|
54
|
+
return;
|
|
55
|
+
const info = parseIdCard(value);
|
|
56
|
+
this.setAge(formModel, info);
|
|
42
57
|
const sexFields = this.getField(FIELD_BUSINESS_TYPE.SEX);
|
|
43
58
|
sexFields.forEach((field) => {
|
|
44
59
|
formModel.setFieldState(field, (state) => {
|
|
@@ -55,18 +70,7 @@ class BusinessCollector {
|
|
|
55
70
|
handlerBirthdayType(formModel, value) {
|
|
56
71
|
if (!isString(value))
|
|
57
72
|
return;
|
|
58
|
-
|
|
59
|
-
ageFields.forEach((field) => {
|
|
60
|
-
const context = parseBirthday(value);
|
|
61
|
-
formModel.setFieldState(field, (state) => {
|
|
62
|
-
state.value = this.valueFilter({
|
|
63
|
-
fieldKey: field,
|
|
64
|
-
value: context.year,
|
|
65
|
-
context,
|
|
66
|
-
type: FIELD_BUSINESS_TYPE.AGE
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
73
|
+
this.setAge(formModel, parseBirthday(value));
|
|
70
74
|
}
|
|
71
75
|
trigger(formModel, fieldName, value) {
|
|
72
76
|
const type = this.getType(fieldName);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { FIELD_BUSINESS_TYPE } from '../../../../packages/form-render/src/constants';
|
|
2
|
+
|
|
1
3
|
function useTypeNormalize() {
|
|
2
4
|
function normalizeAgeField(item) {
|
|
3
5
|
item.html_type = "INPUT_NUMBER";
|
|
4
6
|
item.suffixConfig = [
|
|
5
7
|
{
|
|
8
|
+
validate: { obj_type: FIELD_BUSINESS_TYPE.AGE_UNIT },
|
|
6
9
|
val_key: item.val_key_unit,
|
|
7
10
|
html_type: "SELECT",
|
|
8
11
|
option: item.option
|
|
@@ -19,7 +19,8 @@ export interface FormAsyncQueueItem {
|
|
|
19
19
|
params?: AnyObject;
|
|
20
20
|
}
|
|
21
21
|
export declare type FormAsyncQueue = AsyncQueue<FormAsyncQueueItem, any, AnyObject[]>;
|
|
22
|
-
export declare type
|
|
22
|
+
export declare type AgeContext = Record<'age' | 'day' | 'month' | 'year', number>;
|
|
23
|
+
export declare type IdCardParseInfo = Record<'sex' | 'birthday', string> & AgeContext;
|
|
23
24
|
export declare type FormRenderExpose = {
|
|
24
25
|
validate(path?: string): Promise<void>;
|
|
25
26
|
getFormValues(): AnyObject;
|
|
@@ -2,7 +2,7 @@ import { AnyObject } from '../../../../../es/src/types';
|
|
|
2
2
|
import { ISchema } from '@formily/json-schema/esm/types';
|
|
3
3
|
import { GeneralField } from '@formily/core';
|
|
4
4
|
import { InjectionKey } from 'vue';
|
|
5
|
-
import { IdCardParseInfo } from '../types';
|
|
5
|
+
import { AgeContext, IdCardParseInfo } from '../types';
|
|
6
6
|
export declare function formRenderLog(message: string, type?: keyof Console): void;
|
|
7
7
|
export declare function arrayed<T>(maybeArray: T): T extends Array<any> ? T : [T];
|
|
8
8
|
export declare function assignUpdateValue(props: AnyObject, field: GeneralField): {
|
|
@@ -11,7 +11,7 @@ export declare function assignUpdateValue(props: AnyObject, field: GeneralField)
|
|
|
11
11
|
export declare function transformDateFormat(format: string): "date" | "datetime";
|
|
12
12
|
export declare function isIdCard(idCardNo: string): boolean;
|
|
13
13
|
export declare function isMobile(mobile: string): boolean;
|
|
14
|
-
export declare function parseBirthday(birthday: string):
|
|
14
|
+
export declare function parseBirthday(birthday: string): AgeContext;
|
|
15
15
|
export declare function parseIdCard(idCardNo: string): IdCardParseInfo;
|
|
16
16
|
export declare function injectOrProvide<T>(key: InjectionKey<T>, creator: () => T): T;
|
|
17
17
|
export declare function generateUrlParams(field: GeneralField, dependKeys?: string | string[]): AnyObject;
|
|
@@ -41,7 +41,7 @@ function parseBirthday(birthday) {
|
|
|
41
41
|
const birthDate = new Date(birthday);
|
|
42
42
|
result.day = differenceInDays(d, birthDate);
|
|
43
43
|
result.month = differenceInMonths(d, birthDate);
|
|
44
|
-
result.year = differenceInYears(d, birthDate);
|
|
44
|
+
result.age = result.year = differenceInYears(d, birthDate);
|
|
45
45
|
return result;
|
|
46
46
|
}
|
|
47
47
|
function parseIdCard(idCardNo) {
|