cnhis-design-vue 3.1.16-beta.1 → 3.1.16-beta.2
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/src/BigTable.vue.d.ts +1 -8
- package/es/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/packages/big-table/src/components/edit-form/edit-time.js +1 -1
- 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/form-config/index.d.ts +6 -24
- package/es/packages/form-config/src/FormConfig.vue.d.ts +6 -24
- package/es/packages/form-config/src/components/FormConfigCreator.vue.d.ts +3 -12
- package/es/packages/form-config/src/components/FormConfigEdit.js +1 -1
- package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +3 -12
- package/es/packages/form-config/src/constants/index.d.ts +47 -13
- package/es/packages/form-config/src/constants/index.js +52 -14
- 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.js +6 -43
- package/es/packages/form-config/src/hooks/usePresetRenderer.js +1 -1
- package/es/packages/form-render/index.d.ts +3 -12
- package/es/packages/form-render/src/FormRender.js +3 -4
- package/es/packages/form-render/src/FormRender.vue.d.ts +4 -13
- package/es/packages/form-render/src/components/renderer/cascader.js +1 -1
- 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/input.js +2 -1
- package/es/packages/form-render/src/components/renderer/inputNumber.js +2 -1
- package/es/packages/form-render/src/components/renderer/radio.js +1 -1
- package/es/packages/form-render/src/components/renderer/select.js +1 -1
- package/es/packages/form-render/src/components/renderer/slider.js +1 -1
- 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/useBusinessBinding.d.ts +12 -9
- package/es/packages/form-render/src/hooks/useBusinessBinding.js +58 -58
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +14 -8
- 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/types/index.d.ts +0 -8
- package/es/packages/form-render/src/utils/business.d.ts +12 -0
- package/es/packages/form-render/src/utils/business.js +65 -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 +5 -25
- package/es/packages/form-render/src/utils/index.js +5 -137
- package/es/packages/form-render/src/utils/schema.d.ts +15 -0
- package/es/packages/form-render/src/utils/schema.js +83 -0
- package/es/packages/shortcut-setter/index.d.ts +3 -12
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +3 -12
- package/package.json +1 -1
|
@@ -92,9 +92,6 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
92
92
|
type: import("vue").PropType<Record<string, import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | import("vue").FunctionalComponent<{}, {}>>>;
|
|
93
93
|
default: () => {};
|
|
94
94
|
};
|
|
95
|
-
businessFilter: {
|
|
96
|
-
type: import("vue").PropType<import("./src/types").FormBusinessFilter>;
|
|
97
|
-
};
|
|
98
95
|
scope: {
|
|
99
96
|
type: import("vue").PropType<import("../../../es/src/types").AnyObject>;
|
|
100
97
|
default: () => {};
|
|
@@ -207,9 +204,6 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
207
204
|
type: import("vue").PropType<Record<string, import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | import("vue").FunctionalComponent<{}, {}>>>;
|
|
208
205
|
default: () => {};
|
|
209
206
|
};
|
|
210
|
-
businessFilter: {
|
|
211
|
-
type: import("vue").PropType<import("./src/types").FormBusinessFilter>;
|
|
212
|
-
};
|
|
213
207
|
scope: {
|
|
214
208
|
type: import("vue").PropType<import("../../../es/src/types").AnyObject>;
|
|
215
209
|
default: () => {};
|
|
@@ -236,14 +230,14 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
236
230
|
}>>;
|
|
237
231
|
emit: (event: "formChange", ...args: any[]) => void;
|
|
238
232
|
nuiThemeOverrides: import("naive-ui").GlobalThemeOverrides;
|
|
233
|
+
formModel: import("@formily/core").Form<{
|
|
234
|
+
[x: string]: any;
|
|
235
|
+
}>;
|
|
239
236
|
SchemaField: import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>;
|
|
240
237
|
businessCollector: import("./src/hooks").BusinessCollector;
|
|
241
238
|
formItemDepsCollector: import("./src/hooks").FormItemDepsCollector;
|
|
242
239
|
changeContextCollector: import("./src/hooks").ContextCollector;
|
|
243
240
|
formUUID: string;
|
|
244
|
-
formModel: import("@formily/core").Form<{
|
|
245
|
-
[x: string]: any;
|
|
246
|
-
}>;
|
|
247
241
|
scrollbarRef: import("vue").Ref<HTMLElement | undefined>;
|
|
248
242
|
schemaAdaptor: (fieldList: import("./src/types").FieldItem[]) => Record<string, import("@formily/json-schema").Stringify<{
|
|
249
243
|
[key: symbol]: any;
|
|
@@ -1709,9 +1703,6 @@ declare const FormRender: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
1709
1703
|
type: import("vue").PropType<Record<string, import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | import("vue").FunctionalComponent<{}, {}>>>;
|
|
1710
1704
|
default: () => {};
|
|
1711
1705
|
};
|
|
1712
|
-
businessFilter: {
|
|
1713
|
-
type: import("vue").PropType<import("./src/types").FormBusinessFilter>;
|
|
1714
|
-
};
|
|
1715
1706
|
scope: {
|
|
1716
1707
|
type: import("vue").PropType<import("../../../es/src/types").AnyObject>;
|
|
1717
1708
|
default: () => {};
|
|
@@ -8,8 +8,8 @@ import { useFormRenderLifeCycle } from '../../../packages/form-render/src/hooks/
|
|
|
8
8
|
import { arrayed, queryDecorator, queryInput, getParentLinebar } from '../../../packages/form-render/src/utils';
|
|
9
9
|
import { useNuiThemeOverrides } from '../../../packages/form-table/src/hooks/useNuiThemeOverrides';
|
|
10
10
|
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.js';
|
|
11
|
-
import { useFormContext } from './hooks/useFormContext.js';
|
|
12
11
|
import { useInitialData } from './hooks/useInitialData.js';
|
|
12
|
+
import { useFormContext } from './hooks/useFormContext.js';
|
|
13
13
|
import { useFieldListAdaptor } from './hooks/useFieldListAdaptor.js';
|
|
14
14
|
import { useFieldVisitor } from './hooks/useFieldVisitor.js';
|
|
15
15
|
import { useAnchor } from './hooks/useAnchor.js';
|
|
@@ -34,7 +34,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
34
34
|
type: Object,
|
|
35
35
|
default: () => ({})
|
|
36
36
|
},
|
|
37
|
-
businessFilter: { type: Function },
|
|
38
37
|
scope: { type: Object, default: () => ({}) },
|
|
39
38
|
annotation: { type: Object },
|
|
40
39
|
consumer: { type: Boolean, default: false },
|
|
@@ -48,7 +47,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
48
47
|
const props = __props;
|
|
49
48
|
const { nuiThemeOverrides } = useNuiThemeOverrides();
|
|
50
49
|
useFormRenderLifeCycle(props).callLifeCycle("onSetup");
|
|
51
|
-
const { SchemaField, businessCollector, formItemDepsCollector, changeContextCollector, formUUID } = useFormContext(props);
|
|
52
50
|
const formModel = createForm({
|
|
53
51
|
initialValues: useInitialData().assignInitialData(props.initialData, props.fieldList),
|
|
54
52
|
effects() {
|
|
@@ -61,11 +59,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
61
59
|
value: field.value,
|
|
62
60
|
context: changeContextCollector.getContext(fieldKey)
|
|
63
61
|
});
|
|
64
|
-
businessCollector.trigger(
|
|
62
|
+
businessCollector.trigger(fieldKey);
|
|
65
63
|
formItemDepsCollector.trigger(fieldKey);
|
|
66
64
|
});
|
|
67
65
|
}
|
|
68
66
|
});
|
|
67
|
+
const { SchemaField, businessCollector, formItemDepsCollector, changeContextCollector, formUUID } = useFormContext(props, formModel);
|
|
69
68
|
const scrollbarRef = ref();
|
|
70
69
|
const { schemaAdaptor } = useFieldListAdaptor(businessCollector, formUUID);
|
|
71
70
|
const parsedSchema = computed(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import { AnyObject } from '../../../../es/src/types';
|
|
3
3
|
import { Component, FunctionalComponent, nextTick, PropType } from 'vue';
|
|
4
|
-
import { FieldItem, FieldVisitor
|
|
4
|
+
import { FieldItem, FieldVisitor } from './types';
|
|
5
5
|
declare const _default: import("vue").DefineComponent<{
|
|
6
6
|
fieldList: {
|
|
7
7
|
type: PropType<FieldItem[]>;
|
|
@@ -92,9 +92,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
92
92
|
type: PropType<Record<string, Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | FunctionalComponent<{}, {}>>>;
|
|
93
93
|
default: () => {};
|
|
94
94
|
};
|
|
95
|
-
businessFilter: {
|
|
96
|
-
type: PropType<FormBusinessFilter>;
|
|
97
|
-
};
|
|
98
95
|
scope: {
|
|
99
96
|
type: PropType<AnyObject>;
|
|
100
97
|
default: () => {};
|
|
@@ -207,9 +204,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
207
204
|
type: PropType<Record<string, Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | FunctionalComponent<{}, {}>>>;
|
|
208
205
|
default: () => {};
|
|
209
206
|
};
|
|
210
|
-
businessFilter: {
|
|
211
|
-
type: PropType<FormBusinessFilter>;
|
|
212
|
-
};
|
|
213
207
|
scope: {
|
|
214
208
|
type: PropType<AnyObject>;
|
|
215
209
|
default: () => {};
|
|
@@ -236,14 +230,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
236
230
|
}>>;
|
|
237
231
|
emit: (event: "formChange", ...args: any[]) => void;
|
|
238
232
|
nuiThemeOverrides: import("naive-ui").GlobalThemeOverrides;
|
|
233
|
+
formModel: import("@formily/core").Form<{
|
|
234
|
+
[x: string]: any;
|
|
235
|
+
}>;
|
|
239
236
|
SchemaField: Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>;
|
|
240
237
|
businessCollector: import("./hooks").BusinessCollector;
|
|
241
238
|
formItemDepsCollector: import("./hooks").FormItemDepsCollector;
|
|
242
239
|
changeContextCollector: import("./hooks").ContextCollector;
|
|
243
240
|
formUUID: string;
|
|
244
|
-
formModel: import("@formily/core").Form<{
|
|
245
|
-
[x: string]: any;
|
|
246
|
-
}>;
|
|
247
241
|
scrollbarRef: import("vue").Ref<HTMLElement | undefined>;
|
|
248
242
|
schemaAdaptor: (fieldList: FieldItem[]) => Record<string, import("@formily/vue").Stringify<{
|
|
249
243
|
[key: symbol]: any;
|
|
@@ -1709,9 +1703,6 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1709
1703
|
type: PropType<Record<string, Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | FunctionalComponent<{}, {}>>>;
|
|
1710
1704
|
default: () => {};
|
|
1711
1705
|
};
|
|
1712
|
-
businessFilter: {
|
|
1713
|
-
type: PropType<FormBusinessFilter>;
|
|
1714
|
-
};
|
|
1715
1706
|
scope: {
|
|
1716
1707
|
type: PropType<AnyObject>;
|
|
1717
1708
|
default: () => {};
|
|
@@ -3,10 +3,10 @@ import { isField } from '@formily/core';
|
|
|
3
3
|
import { isEqual } from 'lodash-es';
|
|
4
4
|
import { useCommonInjection } from '../../../../../packages/form-render/src/hooks/useCommonInjection';
|
|
5
5
|
import { InjectAsyncQueue } from '../../constants/index.js';
|
|
6
|
-
import { assignUpdateValue, traverseDependKey } from '../../utils/index.js';
|
|
7
6
|
import { connect, mapProps } from '@formily/vue';
|
|
8
7
|
import { NCascader } from 'naive-ui';
|
|
9
8
|
import { useFormField } from '../../hooks/useFormField.js';
|
|
9
|
+
import { assignUpdateValue, traverseDependKey } from '../../utils/schema.js';
|
|
10
10
|
|
|
11
11
|
const script = defineComponent({
|
|
12
12
|
name: "FormCascader",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, createVNode } from 'vue';
|
|
2
|
-
import { assignUpdateValue } from '../../utils/index.js';
|
|
3
2
|
import { connect, mapProps } from '@formily/vue';
|
|
4
3
|
import { NCheckboxGroup, NSpace, NCheckbox } from 'naive-ui';
|
|
4
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
5
5
|
|
|
6
6
|
const script = defineComponent({
|
|
7
7
|
name: "FormCheckbox",
|
|
@@ -3,11 +3,12 @@ import { isField } from '@formily/core';
|
|
|
3
3
|
import { Path } from '@formily/path';
|
|
4
4
|
import { isNumber, isEqual } from 'lodash-es';
|
|
5
5
|
import { useDeepValidate } from '../../../../../../packages/form-render/src/components/renderer/combination/hooks/useDeepValidate';
|
|
6
|
-
import {
|
|
6
|
+
import { mergeDeepProperties, formRenderLog } from '../../../utils/index.js';
|
|
7
7
|
import { connect, mapProps } from '@formily/vue';
|
|
8
8
|
import { useDebounceFn, isObject } from '@vueuse/core';
|
|
9
9
|
import { NButton } from 'naive-ui';
|
|
10
10
|
import FormRender from '../../../FormRender.js';
|
|
11
|
+
import { assignUpdateValue } from '../../../utils/schema.js';
|
|
11
12
|
|
|
12
13
|
const script = defineComponent({
|
|
13
14
|
name: "FormCombination",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, createVNode } from 'vue';
|
|
2
2
|
import { connect, mapProps } from '@formily/vue';
|
|
3
|
-
import { assignUpdateValue } from '../../utils/
|
|
3
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
4
4
|
|
|
5
5
|
const script = defineComponent({
|
|
6
6
|
props: {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineComponent, createVNode } from 'vue';
|
|
2
|
-
import { createInputSlot
|
|
2
|
+
import { createInputSlot } from '../../utils/index.js';
|
|
3
3
|
import { connect, mapProps } from '@formily/vue';
|
|
4
4
|
import { NInput } from 'naive-ui';
|
|
5
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
5
6
|
|
|
6
7
|
const script = defineComponent({
|
|
7
8
|
name: "FormInput",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { defineComponent, createVNode } from 'vue';
|
|
2
|
-
import { createInputSlot
|
|
2
|
+
import { createInputSlot } from '../../utils/index.js';
|
|
3
3
|
import { connect, mapProps } from '@formily/vue';
|
|
4
4
|
import { NInputNumber } from 'naive-ui';
|
|
5
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
5
6
|
|
|
6
7
|
const script = defineComponent({
|
|
7
8
|
props: {
|
|
@@ -2,7 +2,7 @@ import { defineComponent, computed, createVNode } from 'vue';
|
|
|
2
2
|
import { connect, mapProps } from '@formily/vue';
|
|
3
3
|
import { isNumber } from 'lodash-es';
|
|
4
4
|
import { NRadioGroup, NSpace, NRadio } from 'naive-ui';
|
|
5
|
-
import { assignUpdateValue } from '../../utils/
|
|
5
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
6
6
|
|
|
7
7
|
const script = defineComponent({
|
|
8
8
|
props: {
|
|
@@ -3,10 +3,10 @@ import { isField } from '@formily/core';
|
|
|
3
3
|
import { isEqual, cloneDeep } from 'lodash-es';
|
|
4
4
|
import { useCommonInjection } from '../../../../../packages/form-render/src/hooks/useCommonInjection';
|
|
5
5
|
import { InjectionChangeContextCollector, InjectAsyncQueue, InjectionFormItemDepsCollector } from '../../constants/index.js';
|
|
6
|
-
import { assignUpdateValue, traverseDependKey } from '../../utils/index.js';
|
|
7
6
|
import { connect, mapProps } from '@formily/vue';
|
|
8
7
|
import { NSelect } from 'naive-ui';
|
|
9
8
|
import { useFormField } from '../../hooks/useFormField.js';
|
|
9
|
+
import { assignUpdateValue, traverseDependKey } from '../../utils/schema.js';
|
|
10
10
|
|
|
11
11
|
const script = defineComponent({
|
|
12
12
|
name: "FormSelect",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { connect, mapProps } from '@formily/vue';
|
|
2
2
|
import { NSlider } from 'naive-ui';
|
|
3
|
-
import { assignUpdateValue } from '../../utils/
|
|
3
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
4
4
|
|
|
5
5
|
const SLIDER = connect(NSlider, mapProps((props, field) => {
|
|
6
6
|
const _props = assignUpdateValue(props, field);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent, computed, createVNode, createTextVNode } from 'vue';
|
|
2
2
|
import { NSwitch } from 'naive-ui';
|
|
3
|
-
import { assignUpdateValue } from '../../utils/index.js';
|
|
4
3
|
import { connect, mapProps } from '@formily/vue';
|
|
4
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
5
5
|
|
|
6
6
|
const script = defineComponent({
|
|
7
7
|
name: "FormSwitch",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { assignUpdateValue } from '../../utils/index.js';
|
|
2
1
|
import { connect, mapProps } from '@formily/vue';
|
|
3
2
|
import { NInput } from 'naive-ui';
|
|
3
|
+
import { assignUpdateValue } from '../../utils/schema.js';
|
|
4
4
|
|
|
5
5
|
const TEXTAREA = connect(NInput, mapProps((props, field) => {
|
|
6
6
|
const _props = assignUpdateValue(props, field);
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { Form } from '@formily/core';
|
|
2
|
-
import { FormBusinessFilter } from '../../../../../es/packages/form-render';
|
|
3
2
|
import { FIELD_BUSINESS_TYPE } from '../constants';
|
|
4
3
|
export declare class BusinessCollector {
|
|
4
|
+
private formModel;
|
|
5
5
|
private readonly typeCollector;
|
|
6
6
|
private readonly fieldNameCollector;
|
|
7
|
-
|
|
8
|
-
constructor(valueFilter?: FormBusinessFilter);
|
|
7
|
+
constructor(formModel: Form);
|
|
9
8
|
collect(type: FIELD_BUSINESS_TYPE, fieldName: string): void;
|
|
10
|
-
getField
|
|
11
|
-
getType
|
|
12
|
-
private
|
|
9
|
+
private getField;
|
|
10
|
+
private getType;
|
|
11
|
+
private getValueByField;
|
|
12
|
+
private getValueByType;
|
|
13
|
+
private setValueByType;
|
|
13
14
|
private handlerIdCardType;
|
|
14
15
|
private handlerBirthdayType;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
private handlerAgeType;
|
|
17
|
+
private handlerChangeMap;
|
|
18
|
+
private blurHandlerMap;
|
|
19
|
+
trigger(fieldName: string, triggerType?: 'change' | 'blur'): void;
|
|
17
20
|
}
|
|
18
21
|
export declare function useBusinessBinding(): {
|
|
19
|
-
create: (
|
|
22
|
+
create: (formModel: Form) => BusinessCollector;
|
|
20
23
|
};
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
+
import { isField } from '@formily/core';
|
|
1
2
|
import { isString } from '@vueuse/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { isNumber } from 'lodash-es';
|
|
4
|
+
import { FIELD_BUSINESS_TYPE } from '../constants/index.js';
|
|
5
|
+
import { isIdCard, parseIdCard, parseAge2FromContext, parseBirthday, parseAge2Birthday } from '../utils/business.js';
|
|
4
6
|
|
|
5
7
|
class BusinessCollector {
|
|
6
|
-
constructor(
|
|
8
|
+
constructor(formModel) {
|
|
9
|
+
this.formModel = formModel;
|
|
7
10
|
this.typeCollector = /* @__PURE__ */ new Map();
|
|
8
11
|
this.fieldNameCollector = /* @__PURE__ */ new Map();
|
|
9
|
-
this.
|
|
12
|
+
this.handlerChangeMap = /* @__PURE__ */ new Map([
|
|
10
13
|
[FIELD_BUSINESS_TYPE.ID_CARD, this.handlerIdCardType.bind(this)],
|
|
11
|
-
[FIELD_BUSINESS_TYPE.
|
|
14
|
+
[FIELD_BUSINESS_TYPE.AGE_UNIT, this.handlerAgeType.bind(this)]
|
|
15
|
+
]);
|
|
16
|
+
this.blurHandlerMap = /* @__PURE__ */ new Map([
|
|
17
|
+
[FIELD_BUSINESS_TYPE.BIRTHDAY, this.handlerBirthdayType.bind(this)],
|
|
18
|
+
[FIELD_BUSINESS_TYPE.AGE, this.handlerAgeType.bind(this)]
|
|
12
19
|
]);
|
|
13
|
-
this.valueFilter = valueFilter;
|
|
14
20
|
}
|
|
15
21
|
collect(type, fieldName) {
|
|
16
|
-
|
|
17
|
-
set.add(fieldName);
|
|
18
|
-
this.typeCollector.set(type, set);
|
|
22
|
+
this.typeCollector.set(type, fieldName);
|
|
19
23
|
this.fieldNameCollector.set(fieldName, type);
|
|
20
24
|
}
|
|
21
25
|
getField(type) {
|
|
22
|
-
return
|
|
26
|
+
return this.typeCollector.get(type);
|
|
23
27
|
}
|
|
24
28
|
getType(fieldName) {
|
|
25
29
|
return this.fieldNameCollector.get(fieldName);
|
|
26
30
|
}
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
ageFields.forEach((field) => {
|
|
42
|
-
formModel.setFieldState(field, (state) => {
|
|
43
|
-
state.value = this.valueFilter({
|
|
44
|
-
fieldKey: field,
|
|
45
|
-
value: ageUnitFields.length ? value.age : context.year,
|
|
46
|
-
context,
|
|
47
|
-
type: FIELD_BUSINESS_TYPE.AGE
|
|
48
|
-
});
|
|
49
|
-
});
|
|
31
|
+
getValueByField(fieldName) {
|
|
32
|
+
const _field = this.formModel.query(fieldName).take();
|
|
33
|
+
return isField(_field) ? _field.value : null;
|
|
34
|
+
}
|
|
35
|
+
getValueByType(type) {
|
|
36
|
+
const field = this.getField(type);
|
|
37
|
+
return field ? this.getValueByField(field) : null;
|
|
38
|
+
}
|
|
39
|
+
setValueByType(type, value, force = true) {
|
|
40
|
+
const field = this.getField(type);
|
|
41
|
+
field && this.formModel.setFieldState(field, (state) => {
|
|
42
|
+
if (!force && state.value)
|
|
43
|
+
return;
|
|
44
|
+
state.value = value;
|
|
50
45
|
});
|
|
51
46
|
}
|
|
52
|
-
handlerIdCardType(
|
|
53
|
-
|
|
47
|
+
handlerIdCardType() {
|
|
48
|
+
const idCard = this.getValueByType(FIELD_BUSINESS_TYPE.ID_CARD);
|
|
49
|
+
if (!idCard || !isString(idCard) || !isIdCard(idCard))
|
|
54
50
|
return;
|
|
55
|
-
const info = parseIdCard(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
const birthdayFields = this.getField(FIELD_BUSINESS_TYPE.BIRTHDAY);
|
|
64
|
-
birthdayFields.forEach((field) => {
|
|
65
|
-
formModel.setFieldState(field, (state) => {
|
|
66
|
-
state.value = this.valueFilter({ fieldKey: field, value: info.birthday, type: FIELD_BUSINESS_TYPE.BIRTHDAY });
|
|
67
|
-
});
|
|
68
|
-
});
|
|
51
|
+
const info = parseIdCard(idCard);
|
|
52
|
+
const { age, ageUnit } = parseAge2FromContext(info);
|
|
53
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT, ageUnit);
|
|
54
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.AGE, age);
|
|
55
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.SEX, info.sex);
|
|
56
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, info.birthday);
|
|
69
57
|
}
|
|
70
|
-
handlerBirthdayType(
|
|
71
|
-
|
|
58
|
+
handlerBirthdayType() {
|
|
59
|
+
const birthday = this.getValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY);
|
|
60
|
+
if (!isString(birthday))
|
|
72
61
|
return;
|
|
73
|
-
|
|
62
|
+
const { age, ageUnit } = parseAge2FromContext(parseBirthday(birthday));
|
|
63
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT, ageUnit);
|
|
64
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.AGE, age);
|
|
74
65
|
}
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
66
|
+
handlerAgeType() {
|
|
67
|
+
const age = this.getValueByType(FIELD_BUSINESS_TYPE.AGE);
|
|
68
|
+
const ageUnit = this.getValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT);
|
|
69
|
+
if (!isString(age) && !isNumber(age) || age === "")
|
|
70
|
+
return;
|
|
71
|
+
if (!isString(ageUnit) || ageUnit === "")
|
|
78
72
|
return;
|
|
79
|
-
this.
|
|
73
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, parseAge2Birthday(+age, ageUnit), false);
|
|
74
|
+
}
|
|
75
|
+
trigger(fieldName, triggerType = "change") {
|
|
76
|
+
var _a;
|
|
77
|
+
const type = this.getType(fieldName);
|
|
78
|
+
const handler = triggerType === "change" ? this.handlerChangeMap : triggerType === "blur" ? this.blurHandlerMap : null;
|
|
79
|
+
type && ((_a = handler == null ? void 0 : handler.get(type)) == null ? void 0 : _a());
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
function useBusinessBinding() {
|
|
83
|
-
function create(
|
|
84
|
-
return new BusinessCollector(
|
|
83
|
+
function create(formModel) {
|
|
84
|
+
return new BusinessCollector(formModel);
|
|
85
85
|
}
|
|
86
86
|
return { create };
|
|
87
87
|
}
|
|
@@ -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 } 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"
|
|
@@ -202,14 +209,13 @@ function useFieldListAdaptor(collector, uuid) {
|
|
|
202
209
|
normalize(cur);
|
|
203
210
|
const obj_type = (_a = cur.validate) == null ? void 0 : _a.obj_type;
|
|
204
211
|
obj_type && collector.collect(obj_type, cur.val_key);
|
|
205
|
-
if (
|
|
206
|
-
fin[createFieldName(cur)] = bindIndex(createLinebarSchema(cur), idx);
|
|
207
|
-
prevLinebar = fin[createFieldName(cur)].properties = {};
|
|
208
|
-
} else if (prevLinebar) {
|
|
212
|
+
if (prevLinebar) {
|
|
209
213
|
prevLinebar[createFieldName(cur)] = bindIndex(createWidgetSchema(cur), idx);
|
|
210
214
|
} else {
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
fin[createFieldName(cur)] = bindIndex(createLinebarSchema(cur), idx);
|
|
216
|
+
if (cur.html_type === "LINEBAR") {
|
|
217
|
+
prevLinebar = fin[createFieldName(cur)].properties = {};
|
|
218
|
+
}
|
|
213
219
|
}
|
|
214
220
|
return fin;
|
|
215
221
|
}, {});
|
|
@@ -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(
|
|
37
|
+
const businessCollector = useBusinessBinding().create(formModel);
|
|
38
38
|
provide(InjectionBusinessCollector, businessCollector);
|
|
39
39
|
const changeContextCollector = useChangeContext().create();
|
|
40
40
|
provide(InjectionChangeContextCollector, changeContextCollector);
|
|
@@ -2,7 +2,6 @@ import { AnyObject, WithUndefined } from '../../../../../es/src/types';
|
|
|
2
2
|
import { DataField, Field } from '@formily/core';
|
|
3
3
|
import { ISchema } from '@formily/json-schema/esm/types';
|
|
4
4
|
import { Component, FunctionalComponent } from 'vue';
|
|
5
|
-
import { FIELD_BUSINESS_TYPE } from '../../../../../es/packages/form-render/src/constants';
|
|
6
5
|
import { FieldItem } from '../types';
|
|
7
6
|
import { AsyncQueue } from '../hooks';
|
|
8
7
|
export * from './fieldItem';
|
|
@@ -45,12 +44,6 @@ export declare type FormChangePayload = {
|
|
|
45
44
|
fieldInstance: DataField;
|
|
46
45
|
context: FormChangeContext;
|
|
47
46
|
};
|
|
48
|
-
export declare type FormBusinessFilter = (payload: {
|
|
49
|
-
fieldKey: string;
|
|
50
|
-
value: unknown;
|
|
51
|
-
type: FIELD_BUSINESS_TYPE;
|
|
52
|
-
context?: any;
|
|
53
|
-
}) => unknown;
|
|
54
47
|
export declare type DependKeyType = string | Record<string, string> | Array<{
|
|
55
48
|
paramName: string;
|
|
56
49
|
paramValue?: string;
|
|
@@ -71,7 +64,6 @@ export declare type FormRenderProps = Partial<{
|
|
|
71
64
|
parallelism: number;
|
|
72
65
|
schema: ISchema;
|
|
73
66
|
components: Record<string, Component | FunctionalComponent>;
|
|
74
|
-
businessFilter: FormBusinessFilter;
|
|
75
67
|
scope: AnyObject;
|
|
76
68
|
annotation: AnyObject;
|
|
77
69
|
consumer: boolean;
|
|
@@ -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,65 @@
|
|
|
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;
|
|
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 isIdCard(idCardNo) {
|
|
30
|
+
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);
|
|
31
|
+
}
|
|
32
|
+
function isMobile(mobile) {
|
|
33
|
+
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);
|
|
34
|
+
}
|
|
35
|
+
function parseBirthday(birthday) {
|
|
36
|
+
const result = {};
|
|
37
|
+
const d = new Date();
|
|
38
|
+
const birthDate = new Date(birthday);
|
|
39
|
+
result.day = differenceInDays(d, birthDate);
|
|
40
|
+
result.month = differenceInMonths(d, birthDate);
|
|
41
|
+
result.age = result.year = differenceInYears(d, birthDate);
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
function parseAge2Birthday(age, ageUnit, formatter = "yyyy-MM-dd") {
|
|
45
|
+
var _a;
|
|
46
|
+
const result = new Date();
|
|
47
|
+
const handlerMap = {
|
|
48
|
+
[FIELD_AGE_UNIT.MINUTE]: () => decreaseDate(result, "Minute", age),
|
|
49
|
+
[FIELD_AGE_UNIT.HOUR]: () => decreaseDate(result, "Hour", age),
|
|
50
|
+
[FIELD_AGE_UNIT.DAY]: () => decreaseDate(result, "Date", age),
|
|
51
|
+
[FIELD_AGE_UNIT.WEEK]: () => decreaseDate(result, "Date", age * 7),
|
|
52
|
+
[FIELD_AGE_UNIT.MONTH]: () => decreaseDate(result, "Month", age),
|
|
53
|
+
[FIELD_AGE_UNIT.YEAR]: () => decreaseDate(result, "FullYear", age)
|
|
54
|
+
};
|
|
55
|
+
(_a = handlerMap[ageUnit]) == null ? void 0 : _a.call(handlerMap);
|
|
56
|
+
return format(result, formatter);
|
|
57
|
+
function decreaseDate(date, type, num) {
|
|
58
|
+
date[`set${type}`](date[`get${type}`]() - num);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function parseAge2FromContext(context) {
|
|
62
|
+
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 };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
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
|
+
};
|