cnhis-design-vue 3.1.16-beta.1 → 3.1.16-beta.12
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/big-table/index.d.ts +652 -430
- package/es/packages/big-table/src/BigTable.vue.d.ts +655 -457
- package/es/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +106 -112
- package/es/packages/big-table/src/bigTableProps.d.ts +4 -0
- package/es/packages/big-table/src/bigTableProps.js +2 -1
- package/es/packages/big-table/src/bigTableState.d.ts +2 -0
- package/es/packages/big-table/src/bigTableState.js +3 -1
- package/es/packages/big-table/src/components/edit-form/edit-time.js +1 -1
- package/es/packages/big-table/src/hooks/index.d.ts +9 -0
- package/es/packages/big-table/src/hooks/index.js +9 -0
- package/es/packages/big-table/src/hooks/useAnchor.d.ts +7 -0
- package/es/packages/big-table/src/hooks/useAnchor.js +49 -0
- package/es/packages/big-table/src/hooks/useColumnConfigAdaptor.js +24 -8
- package/es/packages/big-table/src/hooks/useEdit.js +1 -1
- package/es/packages/big-table/src/hooks/useEvent.d.ts +1 -1
- package/es/packages/big-table/src/hooks/useEvent.js +3 -2
- package/es/packages/big-table/style/index.css +1 -2
- package/es/packages/button-print/index.d.ts +7 -4
- package/es/packages/button-print/src/ButtonPrint.vue.d.ts +7 -4
- package/es/packages/button-print/src/ButtonPrint.vue_vue_type_script_setup_true_lang.js +5 -16
- package/es/packages/button-print/src/components/IdentityVerification.js +5 -7
- package/es/packages/button-print/src/components/IdentityVerification.vue.d.ts +6 -3
- package/es/packages/drag-layout/index.d.ts +2 -2
- package/es/packages/drag-layout/src/DragLayout.vue.d.ts +2 -2
- package/es/packages/fabric-chart/src/FabricChart.js +3 -2
- package/es/packages/fabric-chart/src/hooks/constant.js +5 -5
- package/es/packages/fabric-chart/src/hooks/useCenter.js +20 -23
- package/es/packages/fabric-chart/src/hooks/useDraw.js +11 -4
- package/es/packages/fabric-chart/src/hooks/useEvent.js +11 -3
- package/es/packages/fabric-chart/src/hooks/useLeft.js +8 -4
- package/es/packages/fabric-chart/src/hooks/useOther.js +63 -13
- package/es/packages/fabric-chart/src/hooks/useTop.js +5 -8
- package/es/packages/field-set/index.d.ts +1 -1
- package/es/packages/field-set/src/FieldSet.vue.d.ts +1 -1
- package/es/packages/form-config/index.d.ts +110 -3367
- package/es/packages/form-config/src/FormConfig.js +42 -34
- package/es/packages/form-config/src/FormConfig.vue.d.ts +147 -3404
- package/es/packages/form-config/src/components/FormConfigCreator.js +13 -11
- package/es/packages/form-config/src/components/FormConfigCreator.vue.d.ts +23 -22
- package/es/packages/form-config/src/components/FormConfigEdit.js +2 -2
- package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +75 -49
- package/es/packages/form-config/src/constants/index.d.ts +58 -24
- package/es/packages/form-config/src/constants/index.js +52 -23
- package/es/packages/form-config/src/hooks/index.d.ts +1 -0
- package/es/packages/form-config/src/hooks/index.js +1 -0
- package/es/packages/form-config/src/hooks/useConfigurationField.d.ts +2 -1
- package/es/packages/form-config/src/hooks/useConfigurationField.js +29 -80
- package/es/packages/form-config/src/hooks/usePresetRenderer.d.ts +2 -3
- package/es/packages/form-config/src/hooks/usePresetRenderer.js +16 -19
- package/es/packages/form-config/src/hooks/useSortable.js +1 -1
- package/es/packages/form-config/src/types/index.d.ts +22 -4
- package/es/packages/form-config/src/utils/index.d.ts +2 -0
- package/es/packages/form-config/src/utils/index.js +15 -0
- package/es/packages/form-config/style/index.css +27 -3
- package/es/packages/form-render/index.d.ts +13 -15
- package/es/packages/form-render/src/FormRender.js +11 -8
- package/es/packages/form-render/src/FormRender.vue.d.ts +14 -16
- package/es/packages/form-render/src/components/renderer/cascader.d.ts +2 -14
- package/es/packages/form-render/src/components/renderer/cascader.js +3 -3
- package/es/packages/form-render/src/components/renderer/checkbox.js +1 -1
- package/es/packages/form-render/src/components/renderer/combination/index.js +2 -1
- package/es/packages/form-render/src/components/renderer/complex.js +1 -1
- package/es/packages/form-render/src/components/renderer/date.d.ts +20 -4
- package/es/packages/form-render/src/components/renderer/date.js +36 -20
- package/es/packages/form-render/src/components/renderer/input.js +2 -1
- package/es/packages/form-render/src/components/renderer/inputNumber.js +2 -1
- package/es/packages/form-render/src/components/renderer/linebar.js +1 -4
- package/es/packages/form-render/src/components/renderer/radio.js +1 -1
- package/es/packages/form-render/src/components/renderer/select.d.ts +1 -10
- package/es/packages/form-render/src/components/renderer/select.js +26 -17
- package/es/packages/form-render/src/components/renderer/slider.d.ts +8 -344
- package/es/packages/form-render/src/components/renderer/slider.js +24 -2
- package/es/packages/form-render/src/components/renderer/switch.js +1 -1
- package/es/packages/form-render/src/components/renderer/textarea.js +1 -1
- package/es/packages/form-render/src/hooks/useAnchor.js +7 -4
- package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +15 -9
- package/es/packages/form-render/src/hooks/useBusinessBinding.js +62 -58
- package/es/packages/form-render/src/hooks/useChangeContext.d.ts +4 -2
- package/es/packages/form-render/src/hooks/useChangeContext.js +4 -7
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +17 -7
- package/es/packages/form-render/src/hooks/useFormContext.d.ts +2 -1
- package/es/packages/form-render/src/hooks/useFormContext.js +2 -2
- package/es/packages/form-render/src/hooks/useFormValidator.js +13 -3
- package/es/packages/form-render/src/hooks/useInitialData.d.ts +1 -1
- package/es/packages/form-render/src/hooks/useInitialData.js +9 -4
- package/es/packages/form-render/src/hooks/useTypeNormalize.js +3 -2
- package/es/packages/form-render/src/types/fieldItem.d.ts +11 -12
- package/es/packages/form-render/src/types/index.d.ts +7 -8
- package/es/packages/form-render/src/utils/business.d.ts +12 -0
- package/es/packages/form-render/src/utils/business.js +78 -0
- package/es/packages/form-render/src/utils/dom.d.ts +6 -0
- package/es/packages/form-render/src/utils/dom.js +14 -0
- package/es/packages/form-render/src/utils/index.d.ts +6 -26
- package/es/packages/form-render/src/utils/index.js +9 -138
- package/es/packages/form-render/src/utils/schema.d.ts +16 -0
- package/es/packages/form-render/src/utils/schema.js +94 -0
- package/es/packages/index.css +28 -5
- package/es/packages/scale-view/src/hooks/use-component.d.ts +7 -7
- package/es/packages/select-label/index.d.ts +10 -10
- package/es/packages/select-label/src/LabelFormContent.vue.d.ts +3 -3
- package/es/packages/select-label/src/SelectLabel.vue.d.ts +7 -7
- package/es/packages/shortcut-setter/index.d.ts +18 -20
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +18 -20
- package/es/packages/time-line/index.d.ts +2 -2
- package/es/packages/time-line/src/TimeLine.vue.d.ts +2 -2
- package/global.d.ts +8 -8
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { isObject } from '@vueuse/core';
|
|
2
2
|
import { pick } from 'lodash-es';
|
|
3
3
|
import { useFormValidator, useTypeNormalize } from '../../../../packages/form-render';
|
|
4
|
-
import {
|
|
4
|
+
import { arrayed, parseNumberFromMaybeString, formRenderLog } from '../utils/index.js';
|
|
5
|
+
import { fieldKeyEscape, createLinebarId, elementIdEscape } from '../utils/schema.js';
|
|
6
|
+
import { transformDateFormat } from '../utils/business.js';
|
|
5
7
|
|
|
6
8
|
function useFieldListAdaptor(collector, uuid) {
|
|
7
9
|
const { createValidatorSchema } = useFormValidator();
|
|
@@ -15,7 +17,12 @@ function useFieldListAdaptor(collector, uuid) {
|
|
|
15
17
|
"x-component-props": {
|
|
16
18
|
placeholder: item.placeholder,
|
|
17
19
|
clearable: item.is_empty === "0",
|
|
18
|
-
...item.componentProps || {}
|
|
20
|
+
...item.componentProps || {},
|
|
21
|
+
onBlur(...args) {
|
|
22
|
+
var _a2;
|
|
23
|
+
collector.trigger(item.val_key, "blur");
|
|
24
|
+
(_a2 = item.componentProps) == null ? void 0 : _a2.onBlur(...args);
|
|
25
|
+
}
|
|
19
26
|
},
|
|
20
27
|
"x-display": item.is_show === "0" ? "hidden" : "visible",
|
|
21
28
|
"x-pattern": item.is_edit === "0" ? "disabled" : "editable"
|
|
@@ -121,9 +128,9 @@ function useFieldListAdaptor(collector, uuid) {
|
|
|
121
128
|
const createSliderSchema = (item) => {
|
|
122
129
|
const schema = createStandardSchema(item);
|
|
123
130
|
Object.assign(schema["x-component-props"], {
|
|
124
|
-
step:
|
|
125
|
-
max:
|
|
126
|
-
min:
|
|
131
|
+
step: parseNumberFromMaybeString(item.step_length),
|
|
132
|
+
max: parseNumberFromMaybeString(item.max_length),
|
|
133
|
+
min: parseNumberFromMaybeString(item.min_length),
|
|
127
134
|
option: item.option
|
|
128
135
|
});
|
|
129
136
|
return schema;
|
|
@@ -145,13 +152,16 @@ function useFieldListAdaptor(collector, uuid) {
|
|
|
145
152
|
line: item.__line,
|
|
146
153
|
disabled: item.is_not_fold === "1",
|
|
147
154
|
id: createLinebarId(item.val_key),
|
|
148
|
-
show:
|
|
155
|
+
show: item.is_show !== "0"
|
|
149
156
|
}
|
|
150
157
|
};
|
|
151
158
|
};
|
|
152
159
|
const createComplexSchema = (item) => {
|
|
153
160
|
const schema = createStandardSchema(item);
|
|
154
|
-
|
|
161
|
+
if (Array.isArray(item.properties)) {
|
|
162
|
+
formRenderLog("COMPLEX\u63A7\u4EF6\u7684properties\u5C5E\u6027\u5DF2\u7ECF\u5E9F\u5F03, \u8BF7\u4F7F\u7528children\u4F5C\u4E3A\u66FF\u4EE3, \u5728\u4E4B\u540E\u7684\u7248\u672C\u4E2Dproperties\u5C5E\u6027\u5C06\u4E0D\u518D\u652F\u6301", "warn");
|
|
163
|
+
}
|
|
164
|
+
const properties = Array.isArray(item.properties || item.children) ? schemaAdaptor(item.properties || item.children) : {};
|
|
155
165
|
schema.type = item.fieldType || "void";
|
|
156
166
|
schema.properties = properties;
|
|
157
167
|
Object.assign(schema["x-decorator-props"], { showFeedback: false });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Form } from '@formily/core';
|
|
1
2
|
import { ShallowReactive } from 'vue';
|
|
2
3
|
import { FormRenderProps } from '../../../../../es/packages/form-render';
|
|
3
|
-
export declare function useFormContext(props: ShallowReactive<FormRenderProps
|
|
4
|
+
export declare function useFormContext(props: ShallowReactive<FormRenderProps>, formModel: Form): {
|
|
4
5
|
asyncQueue: import("../../../../../es/packages/form-render").FormAsyncQueue;
|
|
5
6
|
SchemaField: import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>;
|
|
6
7
|
businessCollector: import("../../../../../es/packages/form-render").BusinessCollector;
|
|
@@ -9,7 +9,7 @@ import { usePresetScope } from '../../../../packages/form-render/src/hooks/usePr
|
|
|
9
9
|
import { injectOrProvide, uuidGenerator } from '../../../../packages/form-render/src/utils';
|
|
10
10
|
import { InjectAsyncQueue, InjectionSchemaField, InjectionBusinessCollector, InjectionChangeContextCollector, InjectionFormItemDepsCollector, InjectionFormUUID, InjectionAnnotation } from '../../../../packages/form-render/src/constants';
|
|
11
11
|
|
|
12
|
-
function useFormContext(props) {
|
|
12
|
+
function useFormContext(props, formModel) {
|
|
13
13
|
const { callLifeCycle } = useFormRenderLifeCycle(props);
|
|
14
14
|
const asyncQueue = injectOrProvide(InjectAsyncQueue, () => useAsyncQueue().create(props.parallelism, {
|
|
15
15
|
beforeRequest(...args) {
|
|
@@ -34,7 +34,7 @@ function useFormContext(props) {
|
|
|
34
34
|
},
|
|
35
35
|
scope: Object.assign({}, usePresetScope(), props.scope)
|
|
36
36
|
}).SchemaField);
|
|
37
|
-
const businessCollector = useBusinessBinding().create(props.
|
|
37
|
+
const businessCollector = useBusinessBinding().create(formModel, props.businessFormatter);
|
|
38
38
|
provide(InjectionBusinessCollector, businessCollector);
|
|
39
39
|
const changeContextCollector = useChangeContext().create();
|
|
40
40
|
provide(InjectionChangeContextCollector, changeContextCollector);
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
+
import { isString } from 'lodash-es';
|
|
1
2
|
import { arrayed } from '../utils/index.js';
|
|
2
3
|
import { isFunction } from '@vueuse/core';
|
|
4
|
+
import { isIdCard } from '../utils/business.js';
|
|
3
5
|
|
|
4
6
|
function useFormValidator() {
|
|
5
7
|
const validateMap = /* @__PURE__ */ new Map([
|
|
6
8
|
["mobile", ({ validate }) => ({ format: "phone", message: validate == null ? void 0 : validate.message })],
|
|
7
9
|
["integer", ({ validate }) => ({ format: "integer", message: validate == null ? void 0 : validate.message })],
|
|
8
10
|
["number", ({ validate }) => ({ format: "number", message: validate == null ? void 0 : validate.message })],
|
|
9
|
-
[
|
|
11
|
+
[
|
|
12
|
+
"id_card",
|
|
13
|
+
({ validate }) => ({
|
|
14
|
+
validator(value) {
|
|
15
|
+
var _a;
|
|
16
|
+
if (!isString(value) || !isIdCard(value))
|
|
17
|
+
return (_a = validate == null ? void 0 : validate.message) != null ? _a : "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u5408\u6CD5\u7684\u8EAB\u4EFD\u8BC1\u683C\u5F0F";
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
],
|
|
10
21
|
[
|
|
11
22
|
"regular",
|
|
12
|
-
(
|
|
13
|
-
const { validate, regular_expression, regular_error_tip } = field;
|
|
23
|
+
({ validate, regular_expression, regular_error_tip }) => {
|
|
14
24
|
const pattern = regular_expression || (validate == null ? void 0 : validate.regular_expression) || "";
|
|
15
25
|
const message = regular_error_tip || (validate == null ? void 0 : validate.regular_error_tip) || (validate == null ? void 0 : validate.message) || "\u683C\u5F0F\u9519\u8BEF";
|
|
16
26
|
return { pattern, message };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnyObject } from '../../../../../es/src/types';
|
|
2
2
|
import { FieldItem } from '../types';
|
|
3
3
|
export declare function useInitialData(): {
|
|
4
|
-
assignInitialData: (initialData?: AnyObject, fieldList?: FieldItem[]) =>
|
|
4
|
+
assignInitialData: (initialData?: AnyObject, fieldList?: FieldItem[]) => any;
|
|
5
5
|
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { Path } from '@formily/path';
|
|
2
|
+
import { mergeWith } from 'lodash-es';
|
|
3
|
+
import { traverseFieldList } from '../../../../packages/form-render/src/utils';
|
|
4
|
+
|
|
1
5
|
function useInitialData() {
|
|
2
6
|
function assignInitialData(initialData, fieldList) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
+
const defaultVal = {};
|
|
8
|
+
fieldList && traverseFieldList(fieldList, (field) => {
|
|
9
|
+
field.default_val != void 0 && Path.setIn(defaultVal, field.val_key, field.default_val);
|
|
10
|
+
});
|
|
11
|
+
return mergeWith({}, initialData, defaultVal);
|
|
7
12
|
}
|
|
8
13
|
return { assignInitialData };
|
|
9
14
|
}
|
|
@@ -8,7 +8,8 @@ function useTypeNormalize() {
|
|
|
8
8
|
validate: { obj_type: FIELD_BUSINESS_TYPE.AGE_UNIT },
|
|
9
9
|
val_key: item.val_key_unit,
|
|
10
10
|
html_type: "SELECT",
|
|
11
|
-
option: item.option
|
|
11
|
+
option: item.option,
|
|
12
|
+
urlConfig: item.urlConfig
|
|
12
13
|
}
|
|
13
14
|
];
|
|
14
15
|
}
|
|
@@ -24,7 +25,7 @@ function useTypeNormalize() {
|
|
|
24
25
|
];
|
|
25
26
|
function normalize(item) {
|
|
26
27
|
const type = item.html_type;
|
|
27
|
-
if (["
|
|
28
|
+
if (["CHECKBOX_BLOCK", "RADIO_BLOCK"].includes(type)) {
|
|
28
29
|
item.__vertical = true;
|
|
29
30
|
}
|
|
30
31
|
if (["LINE_BREAKS"].includes(type)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyObject, ArrayAble } from '../../../../../es/src/types';
|
|
2
2
|
import { SchemaTypes } from '@formily/vue';
|
|
3
3
|
import { CSSProperties, VNode } from 'vue';
|
|
4
|
-
import { DependKeyType, FormCommonState } from '../../../../../es/packages/form-render';
|
|
4
|
+
import { DependKeyType, FormCommonState, FormRequestType } from '../../../../../es/packages/form-render';
|
|
5
5
|
declare type FieldBusinessType = 'password' | 'id_card' | 'age' | 'age_unit' | 'mobile' | 'telephone' | 'email' | 'sex' | 'birthday' | 'bank_card' | 'website' | 'gestational_weeks' | 'gestational_stage' | 'customer_name';
|
|
6
6
|
export declare type ValidateItem = Partial<{
|
|
7
7
|
/**
|
|
@@ -36,6 +36,15 @@ interface FormRendererPayload {
|
|
|
36
36
|
export interface FormRenderer {
|
|
37
37
|
(payload: FormRendererPayload): ArrayAble<VNode> | any;
|
|
38
38
|
}
|
|
39
|
+
export declare type UrlConfig = {
|
|
40
|
+
url: string;
|
|
41
|
+
} & Partial<{
|
|
42
|
+
method?: FormRequestType;
|
|
43
|
+
nameKey?: string;
|
|
44
|
+
valueKey?: string;
|
|
45
|
+
params?: AnyObject;
|
|
46
|
+
dependKey?: DependKeyType;
|
|
47
|
+
}>;
|
|
39
48
|
interface SwitchProperty {
|
|
40
49
|
value?: any;
|
|
41
50
|
describe?: string;
|
|
@@ -141,17 +150,7 @@ export declare type FieldItem = {
|
|
|
141
150
|
* slider控件间距
|
|
142
151
|
*/
|
|
143
152
|
step_length: string | number;
|
|
144
|
-
urlConfig:
|
|
145
|
-
url: string;
|
|
146
|
-
method: 'post' | 'get' | 'put' | 'patch' | 'delete';
|
|
147
|
-
/**
|
|
148
|
-
* 请求参数依赖关系
|
|
149
|
-
*/
|
|
150
|
-
dependKey: DependKeyType;
|
|
151
|
-
params: AnyObject;
|
|
152
|
-
nameKey: string;
|
|
153
|
-
valueKey: string;
|
|
154
|
-
}>;
|
|
153
|
+
urlConfig: UrlConfig;
|
|
155
154
|
/**
|
|
156
155
|
* 控件组
|
|
157
156
|
*/
|
|
@@ -25,7 +25,7 @@ export declare type FormAsyncQueue = AsyncQueue<FormAsyncQueueItem, any, AnyObje
|
|
|
25
25
|
export declare type AgeContext = Record<'age' | 'day' | 'month' | 'year', number>;
|
|
26
26
|
export declare type IdCardParseInfo = Record<'sex' | 'birthday', string> & AgeContext;
|
|
27
27
|
export declare type FormRenderExpose = {
|
|
28
|
-
validate(path?: string): Promise<
|
|
28
|
+
validate(path?: string): Promise<unknown>;
|
|
29
29
|
getFormValues(): AnyObject;
|
|
30
30
|
setFieldState(path: string, setter: (field: Field) => void): void;
|
|
31
31
|
resetFields(path?: string): void;
|
|
@@ -45,12 +45,6 @@ export declare type FormChangePayload = {
|
|
|
45
45
|
fieldInstance: DataField;
|
|
46
46
|
context: FormChangeContext;
|
|
47
47
|
};
|
|
48
|
-
export declare type FormBusinessFilter = (payload: {
|
|
49
|
-
fieldKey: string;
|
|
50
|
-
value: unknown;
|
|
51
|
-
type: FIELD_BUSINESS_TYPE;
|
|
52
|
-
context?: any;
|
|
53
|
-
}) => unknown;
|
|
54
48
|
export declare type DependKeyType = string | Record<string, string> | Array<{
|
|
55
49
|
paramName: string;
|
|
56
50
|
paramValue?: string;
|
|
@@ -71,10 +65,15 @@ export declare type FormRenderProps = Partial<{
|
|
|
71
65
|
parallelism: number;
|
|
72
66
|
schema: ISchema;
|
|
73
67
|
components: Record<string, Component | FunctionalComponent>;
|
|
74
|
-
businessFilter: FormBusinessFilter;
|
|
75
68
|
scope: AnyObject;
|
|
76
69
|
annotation: AnyObject;
|
|
77
70
|
consumer: boolean;
|
|
78
71
|
uuid: string;
|
|
79
72
|
lifeCycle: FormRenderLifeCycle;
|
|
73
|
+
businessFormatter: FormBusinessFormatter;
|
|
80
74
|
}>;
|
|
75
|
+
export declare type FormBusinessFormatter = (payload: {
|
|
76
|
+
fieldKey: string;
|
|
77
|
+
value: unknown;
|
|
78
|
+
type: FIELD_BUSINESS_TYPE;
|
|
79
|
+
}) => unknown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AgeContext, IdCardParseInfo } from '../../../../../es/packages/form-render';
|
|
2
|
+
import { FIELD_AGE_UNIT } from '../../../../../es/packages/form-render/src/constants';
|
|
3
|
+
export declare function parseIdCard(idCardNo: string): IdCardParseInfo;
|
|
4
|
+
export declare function transformDateFormat(format?: string): "date" | "datetime" | "month";
|
|
5
|
+
export declare function isIdCard(idCardNo: string): boolean;
|
|
6
|
+
export declare function isMobile(mobile: string): boolean;
|
|
7
|
+
export declare function parseBirthday(birthday: string): AgeContext;
|
|
8
|
+
export declare function parseAge2Birthday(age: number, ageUnit: string, formatter?: string): string;
|
|
9
|
+
export declare function parseAge2FromContext(context: AgeContext): {
|
|
10
|
+
ageUnit: FIELD_AGE_UNIT;
|
|
11
|
+
age: number;
|
|
12
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { differenceInDays, differenceInMonths, differenceInYears, format } from 'date-fns';
|
|
2
|
+
import { FIELD_AGE_UNIT, FIELD_SEX_VALUE } from '../../../../packages/form-render/src/constants';
|
|
3
|
+
|
|
4
|
+
function parseIdCard(idCardNo) {
|
|
5
|
+
const parseInner = (certificateNo, idxSexStart, birthYearSpan) => {
|
|
6
|
+
const res = {};
|
|
7
|
+
const idxSex = 1 - certificateNo.substr(idxSexStart, 1) % 2;
|
|
8
|
+
res.sex = idxSex === 1 ? FIELD_SEX_VALUE.FEMALE : FIELD_SEX_VALUE.MALE;
|
|
9
|
+
const year = (birthYearSpan == 2 ? "19" : "") + certificateNo.substr(6, birthYearSpan);
|
|
10
|
+
const month = certificateNo.substr(6 + birthYearSpan, 2);
|
|
11
|
+
const day = certificateNo.substr(8 + birthYearSpan, 2);
|
|
12
|
+
res.birthday = year + "-" + month + "-" + day + " 00:00:00";
|
|
13
|
+
const d = new Date();
|
|
14
|
+
const monthFloor = d.getMonth() + 1 < parseInt(month, 10) || d.getMonth() + 1 == parseInt(month, 10) && d.getDate() < parseInt(day, 10) ? 1 : 0;
|
|
15
|
+
Object.assign(res, parseBirthday(res.birthday));
|
|
16
|
+
res.age = res.year = d.getFullYear() - parseInt(year, 10) - monthFloor;
|
|
17
|
+
return res;
|
|
18
|
+
};
|
|
19
|
+
return parseInner(idCardNo, idCardNo.length == 15 ? 14 : 16, idCardNo.length == 15 ? 2 : 4);
|
|
20
|
+
}
|
|
21
|
+
function isMonthType(format2) {
|
|
22
|
+
return format2 && format2.replace(/yyyy-MM/gi, "YYYY-MM") === "YYYY-MM";
|
|
23
|
+
}
|
|
24
|
+
function transformDateFormat(format2 = "") {
|
|
25
|
+
if (isMonthType(format2))
|
|
26
|
+
return "month";
|
|
27
|
+
return format2.includes("HH") ? "datetime" : "date";
|
|
28
|
+
}
|
|
29
|
+
function validIdCard(cardNo) {
|
|
30
|
+
if (!cardNo || cardNo.length !== 18) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const w = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
|
|
34
|
+
const v = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
|
|
35
|
+
let sum = 0;
|
|
36
|
+
for (let i = 0; i < 17; i++) {
|
|
37
|
+
sum += +cardNo[i] * w[i];
|
|
38
|
+
}
|
|
39
|
+
return cardNo.charAt(17).toUpperCase() === v[sum % 11];
|
|
40
|
+
}
|
|
41
|
+
const idcardMatcher = /^\d{6}(((19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}(\d|x|X))|(\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}))$/;
|
|
42
|
+
function isIdCard(idCardNo) {
|
|
43
|
+
return idcardMatcher.test(idCardNo) && validIdCard(idCardNo);
|
|
44
|
+
}
|
|
45
|
+
function isMobile(mobile) {
|
|
46
|
+
return /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(mobile);
|
|
47
|
+
}
|
|
48
|
+
function parseBirthday(birthday) {
|
|
49
|
+
const result = {};
|
|
50
|
+
const d = new Date();
|
|
51
|
+
const birthDate = new Date(birthday);
|
|
52
|
+
result.day = differenceInDays(d, birthDate);
|
|
53
|
+
result.month = differenceInMonths(d, birthDate);
|
|
54
|
+
result.age = result.year = differenceInYears(d, birthDate);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
function parseAge2Birthday(age, ageUnit, formatter = "yyyy-MM-dd") {
|
|
58
|
+
var _a;
|
|
59
|
+
const result = new Date();
|
|
60
|
+
const handlerMap = {
|
|
61
|
+
[FIELD_AGE_UNIT.MINUTE]: () => decreaseDate(result, "Minute", age),
|
|
62
|
+
[FIELD_AGE_UNIT.HOUR]: () => decreaseDate(result, "Hour", age),
|
|
63
|
+
[FIELD_AGE_UNIT.DAY]: () => decreaseDate(result, "Date", age),
|
|
64
|
+
[FIELD_AGE_UNIT.WEEK]: () => decreaseDate(result, "Date", age * 7),
|
|
65
|
+
[FIELD_AGE_UNIT.MONTH]: () => decreaseDate(result, "Month", age),
|
|
66
|
+
[FIELD_AGE_UNIT.YEAR]: () => decreaseDate(result, "FullYear", age)
|
|
67
|
+
};
|
|
68
|
+
(_a = handlerMap[ageUnit]) == null ? void 0 : _a.call(handlerMap);
|
|
69
|
+
return format(result, formatter);
|
|
70
|
+
function decreaseDate(date, type, num) {
|
|
71
|
+
date[`set${type}`](date[`get${type}`]() - num);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function parseAge2FromContext(context) {
|
|
75
|
+
return 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 };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { isIdCard, isMobile, parseAge2Birthday, parseAge2FromContext, parseBirthday, parseIdCard, transformDateFormat };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WithNull } from '../../../../../es/src/types';
|
|
2
|
+
export declare function queryDecorator(key: string, wrapperElement: HTMLElement, formUUID: string): HTMLElement | null;
|
|
3
|
+
export declare function queryInput(decoratorElement?: WithNull<HTMLElement>): {
|
|
4
|
+
widgetElement: HTMLInputElement | null | undefined;
|
|
5
|
+
widgetElementList: HTMLInputElement[];
|
|
6
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { elementIdEscape } from '../../../../packages/form-render/src/utils/schema';
|
|
2
|
+
|
|
3
|
+
function queryDecorator(key, wrapperElement, formUUID) {
|
|
4
|
+
return wrapperElement.querySelector(elementIdEscape(`#${formUUID}-${key}`));
|
|
5
|
+
}
|
|
6
|
+
function queryInput(decoratorElement) {
|
|
7
|
+
var _a;
|
|
8
|
+
return {
|
|
9
|
+
widgetElement: decoratorElement == null ? void 0 : decoratorElement.querySelector("input"),
|
|
10
|
+
widgetElementList: Array.from((_a = decoratorElement == null ? void 0 : decoratorElement.querySelectorAll("input")) != null ? _a : [])
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { queryDecorator, queryInput };
|
|
@@ -1,36 +1,16 @@
|
|
|
1
|
-
import { AnyObject, ArrayAble
|
|
2
|
-
import { ISchema } from '@formily/json-schema/esm/types';
|
|
3
|
-
import { GeneralField } from '@formily/core';
|
|
1
|
+
import { AnyObject, ArrayAble } from '../../../../../es/src/types';
|
|
4
2
|
import { FunctionalComponent, InjectionKey, VNode } from 'vue';
|
|
5
|
-
import {
|
|
3
|
+
import { FieldItem } from '../types';
|
|
4
|
+
export * from './business';
|
|
5
|
+
export * from './dom';
|
|
6
|
+
export * from './schema';
|
|
6
7
|
export declare function formRenderLog(message: string, type?: keyof Console): void;
|
|
7
8
|
export declare function arrayed<T>(maybeArray: T): T extends Array<any> ? T : [T];
|
|
8
|
-
export declare function assignUpdateValue(props: AnyObject, field: GeneralField): {
|
|
9
|
-
[x: string]: any;
|
|
10
|
-
};
|
|
11
|
-
export declare function transformDateFormat(format?: string): "date" | "datetime" | "month";
|
|
12
|
-
export declare function isIdCard(idCardNo: string): boolean;
|
|
13
|
-
export declare function isMobile(mobile: string): boolean;
|
|
14
|
-
export declare function parseBirthday(birthday: string): AgeContext;
|
|
15
9
|
export declare function mergeDeepProperties(target: AnyObject, fieldList: FieldItem[], traverseProperties?: string[], property?: string, targetProperty?: string): AnyObject;
|
|
16
|
-
export declare function parseIdCard(idCardNo: string): IdCardParseInfo;
|
|
17
10
|
export declare function injectOrProvide<T>(key: InjectionKey<T>, creator: () => T): T;
|
|
18
|
-
export declare function parseNumberFromMaybeString(value:
|
|
19
|
-
export declare function traverseDependKey(dependKeys: DependKeyType, handler: {
|
|
20
|
-
(dependKey: string, valueKey: string, required?: boolean): void;
|
|
21
|
-
}): void;
|
|
22
|
-
export declare function traverseSchema(schema: ISchema, handler: (_s: ISchema) => void): void;
|
|
11
|
+
export declare function parseNumberFromMaybeString<T>(value: T): T extends number | string ? number : T;
|
|
23
12
|
export declare function uuidGenerator(): string;
|
|
24
13
|
export declare function createSlot(renderer: unknown, props: AnyObject): Record<string, () => ArrayAble<VNode>> | {
|
|
25
14
|
default(): any;
|
|
26
15
|
};
|
|
27
|
-
export declare function queryDecorator(key: string, wrapperElement: HTMLElement, formUUID: string): HTMLElement | null;
|
|
28
|
-
export declare function queryInput(decoratorElement?: WithNull<HTMLElement>): {
|
|
29
|
-
widgetElement: HTMLInputElement | null | undefined;
|
|
30
|
-
widgetElementList: HTMLInputElement[];
|
|
31
|
-
};
|
|
32
|
-
export declare function getParentLinebar(key: string, fieldList: FieldItem[]): WithNull<string>;
|
|
33
|
-
export declare function elementIdEscape(id: string): string;
|
|
34
|
-
export declare function createLinebarId(id: string): string;
|
|
35
|
-
export declare function fieldKeyEscape(fieldList: FieldItem[]): string;
|
|
36
16
|
export declare function createInputSlot(props: AnyObject): import("vue").ComputedRef<Record<string, FunctionalComponent<{}, {}>>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { inject, provide, computed, createVNode, Fragment } from 'vue';
|
|
2
2
|
import { isObject } from '@vue/shared';
|
|
3
|
-
import { isNumber, isString,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { isNumber, isString, isFunction } from 'lodash-es';
|
|
4
|
+
export { isIdCard, isMobile, parseAge2Birthday, parseAge2FromContext, parseBirthday, parseIdCard, transformDateFormat } from './business.js';
|
|
5
|
+
export { queryDecorator, queryInput } from './dom.js';
|
|
6
|
+
export { assignUpdateValue, createLinebarId, elementIdEscape, fieldKeyEscape, getParentLinebar, traverseDependKey, traverseFieldList, traverseSchema } from './schema.js';
|
|
7
7
|
|
|
8
8
|
function formRenderLog(message, type = "log") {
|
|
9
9
|
console[type](`[FormRender]: ${message}`);
|
|
@@ -13,42 +13,6 @@ function arrayed(maybeArray) {
|
|
|
13
13
|
return maybeArray;
|
|
14
14
|
return [maybeArray];
|
|
15
15
|
}
|
|
16
|
-
function assignUpdateValue(props, field) {
|
|
17
|
-
const _props = {
|
|
18
|
-
...props
|
|
19
|
-
};
|
|
20
|
-
if (isField(field)) {
|
|
21
|
-
Object.assign(_props, {
|
|
22
|
-
"onUpdate:value"(value) {
|
|
23
|
-
field.setValue(value);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return _props;
|
|
28
|
-
}
|
|
29
|
-
function isMonthType(format) {
|
|
30
|
-
return format && format.replace(/yyyy-MM/gi, "YYYY-MM") === "YYYY-MM";
|
|
31
|
-
}
|
|
32
|
-
function transformDateFormat(format = "") {
|
|
33
|
-
if (isMonthType(format))
|
|
34
|
-
return "month";
|
|
35
|
-
return format.includes("HH") ? "datetime" : "date";
|
|
36
|
-
}
|
|
37
|
-
function isIdCard(idCardNo) {
|
|
38
|
-
return /^\d{6}(((19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}(\d|x|X))|(\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}))$/.test(idCardNo);
|
|
39
|
-
}
|
|
40
|
-
function isMobile(mobile) {
|
|
41
|
-
return /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(mobile);
|
|
42
|
-
}
|
|
43
|
-
function parseBirthday(birthday) {
|
|
44
|
-
const result = {};
|
|
45
|
-
const d = new Date();
|
|
46
|
-
const birthDate = new Date(birthday);
|
|
47
|
-
result.day = differenceInDays(d, birthDate);
|
|
48
|
-
result.month = differenceInMonths(d, birthDate);
|
|
49
|
-
result.age = result.year = differenceInYears(d, birthDate);
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
16
|
function mergeDeepProperties(target, fieldList, traverseProperties = ["children", "properties", "suffixConfig"], property = "val_key", targetProperty = "default_val") {
|
|
53
17
|
function traverse(_target, _fieldList) {
|
|
54
18
|
_fieldList.forEach((field) => {
|
|
@@ -76,23 +40,6 @@ function mergeDeepProperties(target, fieldList, traverseProperties = ["children"
|
|
|
76
40
|
return field[targetProperty];
|
|
77
41
|
}
|
|
78
42
|
}
|
|
79
|
-
function parseIdCard(idCardNo) {
|
|
80
|
-
const parseInner = (certificateNo, idxSexStart, birthYearSpan) => {
|
|
81
|
-
const res = {};
|
|
82
|
-
const idxSex = 1 - certificateNo.substr(idxSexStart, 1) % 2;
|
|
83
|
-
res.sex = idxSex === 1 ? FIELD_SEX_VALUE.FEMALE : FIELD_SEX_VALUE.MALE;
|
|
84
|
-
const year = (birthYearSpan == 2 ? "19" : "") + certificateNo.substr(6, birthYearSpan);
|
|
85
|
-
const month = certificateNo.substr(6 + birthYearSpan, 2);
|
|
86
|
-
const day = certificateNo.substr(8 + birthYearSpan, 2);
|
|
87
|
-
res.birthday = year + "-" + month + "-" + day;
|
|
88
|
-
const d = new Date();
|
|
89
|
-
const monthFloor = d.getMonth() + 1 < parseInt(month, 10) || d.getMonth() + 1 == parseInt(month, 10) && d.getDate() < parseInt(day, 10) ? 1 : 0;
|
|
90
|
-
Object.assign(res, parseBirthday(res.birthday));
|
|
91
|
-
res.age = res.year = d.getFullYear() - parseInt(year, 10) - monthFloor;
|
|
92
|
-
return res;
|
|
93
|
-
};
|
|
94
|
-
return parseInner(idCardNo, idCardNo.length == 15 ? 14 : 16, idCardNo.length == 15 ? 2 : 4);
|
|
95
|
-
}
|
|
96
43
|
function injectOrProvide(key, creator) {
|
|
97
44
|
let injected = inject(key, null);
|
|
98
45
|
if (!injected) {
|
|
@@ -108,54 +55,14 @@ function parseNumberFromMaybeString(value) {
|
|
|
108
55
|
return +value;
|
|
109
56
|
return value;
|
|
110
57
|
}
|
|
111
|
-
function traverseDependKey(dependKeys, handler) {
|
|
112
|
-
if (!dependKeys)
|
|
113
|
-
return;
|
|
114
|
-
createDependKeyMap().forEach((valueKey, dependKey) => {
|
|
115
|
-
if (isString(valueKey))
|
|
116
|
-
return handler(dependKey, valueKey);
|
|
117
|
-
handler(dependKey, valueKey.key, valueKey.required);
|
|
118
|
-
});
|
|
119
|
-
Object.entries(createDependKeyMap()).forEach(([dependKey, valueKey]) => {
|
|
120
|
-
handler(dependKey, valueKey);
|
|
121
|
-
});
|
|
122
|
-
function createDependKeyMap() {
|
|
123
|
-
const result = /* @__PURE__ */ new Map();
|
|
124
|
-
if (isArray(dependKeys)) {
|
|
125
|
-
dependKeys.forEach((k) => {
|
|
126
|
-
var _a;
|
|
127
|
-
if (isObject(k)) {
|
|
128
|
-
result.set(k.paramName, {
|
|
129
|
-
key: (_a = k.paramName) != null ? _a : k.paramValue,
|
|
130
|
-
required: k.required
|
|
131
|
-
});
|
|
132
|
-
} else {
|
|
133
|
-
result.set(k, k);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
} else if (isObject(dependKeys)) {
|
|
137
|
-
Object.entries(dependKeys).forEach(([k, v]) => {
|
|
138
|
-
result.set(k, v);
|
|
139
|
-
});
|
|
140
|
-
} else if (isString(dependKeys)) {
|
|
141
|
-
result.set(dependKeys, dependKeys);
|
|
142
|
-
}
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function traverseSchema(schema, handler) {
|
|
147
|
-
handler(schema);
|
|
148
|
-
if (isObject(schema.properties)) {
|
|
149
|
-
Object.values(schema.properties).forEach((_s) => {
|
|
150
|
-
traverseSchema(_s, handler);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
58
|
function uuidGenerator() {
|
|
155
|
-
|
|
59
|
+
if (window.isSecureContext && window.crypto)
|
|
60
|
+
return `key${window.crypto.randomUUID()}`;
|
|
61
|
+
const uuid = "xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
156
62
|
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
157
63
|
return v.toString(16);
|
|
158
64
|
});
|
|
65
|
+
return `key${uuid}`;
|
|
159
66
|
}
|
|
160
67
|
function createSlot(renderer, props) {
|
|
161
68
|
if (isObject(renderer) && !isFunction(renderer)) {
|
|
@@ -171,42 +78,6 @@ function createSlot(renderer, props) {
|
|
|
171
78
|
}
|
|
172
79
|
};
|
|
173
80
|
}
|
|
174
|
-
function queryDecorator(key, wrapperElement, formUUID) {
|
|
175
|
-
return wrapperElement.querySelector(elementIdEscape(`#${formUUID}-${key}`));
|
|
176
|
-
}
|
|
177
|
-
function queryInput(decoratorElement) {
|
|
178
|
-
var _a;
|
|
179
|
-
return {
|
|
180
|
-
widgetElement: decoratorElement == null ? void 0 : decoratorElement.querySelector("input"),
|
|
181
|
-
widgetElementList: Array.from((_a = decoratorElement == null ? void 0 : decoratorElement.querySelectorAll("input")) != null ? _a : [])
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function getParentLinebar(key, fieldList) {
|
|
185
|
-
let result = null;
|
|
186
|
-
for (const fieldItem of fieldList) {
|
|
187
|
-
if (fieldItem.val_key === key) {
|
|
188
|
-
if (isLinebar(fieldItem))
|
|
189
|
-
result = null;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
if (isLinebar(fieldItem)) {
|
|
193
|
-
result = fieldItem.val_key;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return result;
|
|
197
|
-
function isLinebar(field) {
|
|
198
|
-
return field.html_type === "LINEBAR";
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
function elementIdEscape(id) {
|
|
202
|
-
return id.replace(".", "-");
|
|
203
|
-
}
|
|
204
|
-
function createLinebarId(id) {
|
|
205
|
-
return elementIdEscape(`id-${id}`);
|
|
206
|
-
}
|
|
207
|
-
function fieldKeyEscape(fieldList) {
|
|
208
|
-
return fieldList.map((f) => f.val_key).join("-").replace(/[.]/g, "_");
|
|
209
|
-
}
|
|
210
81
|
function createInputSlot(props) {
|
|
211
82
|
return computed(() => {
|
|
212
83
|
const res = {};
|
|
@@ -220,4 +91,4 @@ function createInputSlot(props) {
|
|
|
220
91
|
});
|
|
221
92
|
}
|
|
222
93
|
|
|
223
|
-
export { arrayed,
|
|
94
|
+
export { arrayed, createInputSlot, createSlot, formRenderLog, injectOrProvide, mergeDeepProperties, parseNumberFromMaybeString, uuidGenerator };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AnyObject, WithNull } from '../../../../../es/src/types';
|
|
2
|
+
import { GeneralField } from '@formily/core';
|
|
3
|
+
import { ISchema } from '@formily/json-schema/esm/types';
|
|
4
|
+
import { DependKeyType, FieldItem } from '../../../../../es/packages/form-render';
|
|
5
|
+
export declare function traverseSchema(schema: ISchema, handler: (_s: ISchema) => void): void;
|
|
6
|
+
export declare function fieldKeyEscape(fieldList: FieldItem[]): string;
|
|
7
|
+
export declare function elementIdEscape(id: string): string;
|
|
8
|
+
export declare function createLinebarId(id: string): string;
|
|
9
|
+
export declare function traverseDependKey(dependKeys: DependKeyType, handler: {
|
|
10
|
+
(dependKey: string, valueKey: string, required?: boolean): void;
|
|
11
|
+
}): void;
|
|
12
|
+
export declare function getParentLinebar(key: string, fieldList: FieldItem[]): WithNull<string>;
|
|
13
|
+
export declare function assignUpdateValue(props: AnyObject, field: GeneralField): {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
};
|
|
16
|
+
export declare function traverseFieldList(fieldList: FieldItem[], handler: (field: FieldItem) => void): void;
|