cnhis-design-vue 3.1.24-beta.1 → 3.1.24-beta.3
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/components/big-table/src/components/edit-form/edit-input.js +3 -1
- package/es/components/form-config/index.d.ts +1 -0
- package/es/components/form-config/src/FormConfig.vue.d.ts +1 -0
- package/es/components/form-config/src/components/FormConfigEdit.vue.d.ts +1 -0
- package/es/components/form-render/index.js +1 -1
- package/es/components/form-render/src/FormRender.js +14 -1
- package/es/components/form-render/src/components/renderer/formItem.js +10 -2
- package/es/components/form-render/src/components/renderer/index.d.ts +3 -20
- package/es/components/form-render/src/components/renderer/index.js +49 -20
- package/es/components/form-render/src/components/renderer/levelSearchCascade.js +1 -1
- package/es/components/form-render/src/components/renderer/search.js +2 -19
- package/es/components/form-render/src/components/renderer/searchCascade.js +2 -19
- package/es/components/form-render/src/components/renderer/select.js +2 -19
- package/es/components/form-render/src/hooks/index.js +1 -1
- package/es/components/form-render/src/hooks/useFieldListAdaptor.js +7 -3
- package/es/components/form-render/src/hooks/useFormContext.js +2 -2
- package/es/components/form-render/src/hooks/useFormValidator.d.ts +1 -0
- package/es/components/form-render/src/hooks/useFormValidator.js +17 -3
- package/es/components/form-render/src/types/fieldItem.d.ts +4 -0
- package/es/components/form-render/src/utils/index.d.ts +1 -0
- package/es/components/form-render/src/utils/index.js +10 -1
- package/es/components/iho-table/index.d.ts +100 -270
- package/es/components/iho-table/index.js +2 -2
- package/es/components/iho-table/src/IhoTable.vue.d.ts +100 -270
- package/es/components/iho-table/src/plugins/index.d.ts +3 -5
- package/es/components/iho-table/src/plugins/index.js +39 -15
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/editSeparate.js +4 -9
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/separateRendererPlugin/editSeparate.vue.d.ts +4 -1
- package/es/components/index.js +1 -1
- package/es/components/search-cascader/index.d.ts +2 -2
- package/es/components/search-cascader/src/SearchCascader.vue.d.ts +2 -2
- package/es/components/shortcut-setter/index.d.ts +1 -0
- package/es/components/shortcut-setter/src/ShortcutSetter.vue.d.ts +1 -0
- package/es/shared/utils/index.d.ts +1 -0
- package/es/shared/utils/index.js +19 -2
- package/package.json +2 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/index.d.ts +0 -5
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/index.js +0 -5
- package/es/components/iho-table/src/plugins/rendererPlugins/index.d.ts +0 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/index.js +0 -11
- package/es/components/iho-table/src/plugins/rendererPlugins/widgets/index.d.ts +0 -6
- package/es/components/iho-table/src/plugins/rendererPlugins/widgets/index.js +0 -6
|
@@ -970,6 +970,7 @@ declare const FormConfig: SFCWithInstall<import("vue").DefineComponent<{
|
|
|
970
970
|
} | undefined;
|
|
971
971
|
suffixConfig?: any | any[] | undefined;
|
|
972
972
|
autograph?: string | undefined;
|
|
973
|
+
defined_error_msg?: string | undefined;
|
|
973
974
|
fieldType?: import("@formily/json-schema").SchemaTypes | undefined;
|
|
974
975
|
content?: string | import("..").FormRenderer | Record<string, import("..").FormRenderer> | undefined;
|
|
975
976
|
lazyRequest?: boolean | undefined;
|
|
@@ -972,6 +972,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
972
972
|
} | undefined;
|
|
973
973
|
suffixConfig?: any | any[] | undefined;
|
|
974
974
|
autograph?: string | undefined;
|
|
975
|
+
defined_error_msg?: string | undefined;
|
|
975
976
|
fieldType?: import("@formily/json-schema").SchemaTypes | undefined;
|
|
976
977
|
content?: string | import("../..").FormRenderer | Record<string, import("../..").FormRenderer> | undefined;
|
|
977
978
|
lazyRequest?: boolean | undefined;
|
|
@@ -101,6 +101,7 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
101
101
|
} | undefined;
|
|
102
102
|
suffixConfig?: any | any[] | undefined;
|
|
103
103
|
autograph?: string | undefined;
|
|
104
|
+
defined_error_msg?: string | undefined;
|
|
104
105
|
fieldType?: import("@formily/json-schema").SchemaTypes | undefined;
|
|
105
106
|
content?: string | import("../../../../../es/components/form-render").FormRenderer | Record<string, import("../../../../../es/components/form-render").FormRenderer> | undefined;
|
|
106
107
|
lazyRequest?: boolean | undefined;
|
|
@@ -8,7 +8,7 @@ export { useFormField } from './src/hooks/useFormField.js';
|
|
|
8
8
|
export { AsyncQueue, useAsyncQueue } from './src/hooks/useAsyncQueue.js';
|
|
9
9
|
export { useFieldVisitor } from './src/hooks/useFieldVisitor.js';
|
|
10
10
|
export { useFieldNormalize } from './src/hooks/useFieldNormalize.js';
|
|
11
|
-
export { useFormValidator } from './src/hooks/useFormValidator.js';
|
|
11
|
+
export { useFormValidator, validateMessageLocale } from './src/hooks/useFormValidator.js';
|
|
12
12
|
export { BusinessCollector, useBusinessBinding } from './src/hooks/useBusinessBinding.js';
|
|
13
13
|
export { ContextCollector, useChangeContext } from './src/hooks/useChangeContext.js';
|
|
14
14
|
export { FormItemDepsCollector, useFormItemDeps } from './src/hooks/useFormItemDeps.js';
|
|
@@ -22,6 +22,7 @@ import '../../../shared/utils/tapable/AsyncSeriesHook.js';
|
|
|
22
22
|
import '../../../shared/utils/tapable/AsyncSeriesBailHook.js';
|
|
23
23
|
import '../../../shared/utils/tapable/AsyncSeriesLoopHook.js';
|
|
24
24
|
import '../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js';
|
|
25
|
+
import { validateMessageLocale } from './hooks/useFormValidator.js';
|
|
25
26
|
import '@vueuse/core';
|
|
26
27
|
import { useAnchor } from './hooks/useAnchor.js';
|
|
27
28
|
import { useFormContext } from './hooks/useFormContext.js';
|
|
@@ -62,6 +63,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
62
63
|
setup(__props, { expose, emit }) {
|
|
63
64
|
const props = __props;
|
|
64
65
|
const { nuiThemeOverrides } = useNuiThemeOverrides();
|
|
66
|
+
validateMessageLocale();
|
|
65
67
|
useFormRenderLifeCycle(props).callLifeCycle("onSetup");
|
|
66
68
|
const formModel = createForm({
|
|
67
69
|
initialValues: props.initialData,
|
|
@@ -151,7 +153,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
151
153
|
return formModel.getFormState().values;
|
|
152
154
|
},
|
|
153
155
|
setFieldState(path, handler) {
|
|
154
|
-
formModel.setFieldState(path,
|
|
156
|
+
formModel.setFieldState(path, (state) => {
|
|
157
|
+
handler(
|
|
158
|
+
new Proxy(state, {
|
|
159
|
+
get(target, key, receiver) {
|
|
160
|
+
return Reflect.get(target, key, receiver);
|
|
161
|
+
},
|
|
162
|
+
set(target, key, value, receiver) {
|
|
163
|
+
return Reflect.set(target, key, value, receiver);
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
});
|
|
155
168
|
},
|
|
156
169
|
resetFields(path = "*") {
|
|
157
170
|
formModel.reset(path);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { defineComponent, inject, computed, createVNode } from 'vue';
|
|
2
2
|
import { isVoidField } from '@formily/core';
|
|
3
3
|
import { useField, connect, mapProps } from '@formily/vue';
|
|
4
|
+
import { isString } from 'lodash-es';
|
|
4
5
|
import { NFormItem } from 'naive-ui';
|
|
5
6
|
import Annotation from '../../../../annotation-edit/index.js';
|
|
6
7
|
import { InjectionAnnotation, InjectionFormUUID } from '../../constants/index.js';
|
|
7
|
-
import '../../utils/index.js';
|
|
8
|
+
import { validateMessageParser } from '../../utils/index.js';
|
|
8
9
|
import { dotEscape } from '../../utils/schema.js';
|
|
9
10
|
|
|
10
11
|
const script = defineComponent({
|
|
@@ -65,9 +66,10 @@ const script = defineComponent({
|
|
|
65
66
|
const FORM_ITEM = connect(script, mapProps({
|
|
66
67
|
title: "label"
|
|
67
68
|
}, (props, field) => {
|
|
68
|
-
const feedback = !isVoidField(field) ? field.selfErrors.length ? field.selfErrors.
|
|
69
|
+
const feedback = !isVoidField(field) ? field.selfErrors.length ? parseFeedback(field.selfErrors, props.fieldItem) : void 0 : void 0;
|
|
69
70
|
return {
|
|
70
71
|
...props,
|
|
72
|
+
fieldItem: void 0,
|
|
71
73
|
required: isVoidField(field) ? void 0 : field.required,
|
|
72
74
|
class: "form-render__formItem",
|
|
73
75
|
style: {
|
|
@@ -77,5 +79,11 @@ const FORM_ITEM = connect(script, mapProps({
|
|
|
77
79
|
"validation-status": feedback ? "error" : void 0
|
|
78
80
|
};
|
|
79
81
|
}));
|
|
82
|
+
function parseFeedback(selfErrors, fieldItem) {
|
|
83
|
+
if (!isString(fieldItem.defined_error_msg) || !fieldItem.defined_error_msg) {
|
|
84
|
+
return selfErrors.map((message) => validateMessageParser(message, fieldItem)).join(",");
|
|
85
|
+
}
|
|
86
|
+
return validateMessageParser(fieldItem.defined_error_msg, fieldItem);
|
|
87
|
+
}
|
|
80
88
|
|
|
81
89
|
export { FORM_ITEM };
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export * from './textarea';
|
|
5
|
-
export * from './inputNumber';
|
|
6
|
-
export * from './lineBar';
|
|
7
|
-
export * from './inputGroup';
|
|
8
|
-
export * from './date';
|
|
9
|
-
export * from './levelSearchCascade';
|
|
10
|
-
export * from './jsonCombination';
|
|
11
|
-
export * from './combination';
|
|
12
|
-
export * from './checkbox';
|
|
13
|
-
export * from './switch';
|
|
14
|
-
export * from './radio';
|
|
15
|
-
export * from './labelSelect';
|
|
16
|
-
export * from './slider';
|
|
17
|
-
export * from './complex';
|
|
18
|
-
export * from './simpleComponent';
|
|
19
|
-
export * from './search';
|
|
20
|
-
export * from './searchCascade';
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
declare const exportModules: Record<string, Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>>;
|
|
3
|
+
export default exportModules;
|
|
@@ -1,20 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import * as checkbox from './checkbox.js';
|
|
2
|
+
import * as combination from './combination.js';
|
|
3
|
+
import * as complex from './complex.js';
|
|
4
|
+
import * as date from './date.js';
|
|
5
|
+
import * as formItem from './formItem.js';
|
|
6
|
+
import * as input from './input.js';
|
|
7
|
+
import * as inputGroup from './inputGroup.js';
|
|
8
|
+
import * as inputNumber from './inputNumber.js';
|
|
9
|
+
import * as index from './jsonCombination/index.js';
|
|
10
|
+
import * as labelSelect from './labelSelect.js';
|
|
11
|
+
import * as levelSearchCascade from './levelSearchCascade.js';
|
|
12
|
+
import * as index$1 from './lineBar/index.js';
|
|
13
|
+
import * as radio from './radio.js';
|
|
14
|
+
import * as search from './search.js';
|
|
15
|
+
import * as searchCascade from './searchCascade.js';
|
|
16
|
+
import * as select from './select.js';
|
|
17
|
+
import * as simpleComponent from './simpleComponent.js';
|
|
18
|
+
import * as slider from './slider.js';
|
|
19
|
+
import * as _switch from './switch.js';
|
|
20
|
+
import * as textarea from './textarea.js';
|
|
21
|
+
|
|
22
|
+
const modules = Object.assign({
|
|
23
|
+
"./checkbox.tsx": checkbox,
|
|
24
|
+
"./combination.tsx": combination,
|
|
25
|
+
"./complex.tsx": complex,
|
|
26
|
+
"./date.tsx": date,
|
|
27
|
+
"./formItem.tsx": formItem,
|
|
28
|
+
"./input.tsx": input,
|
|
29
|
+
"./inputGroup.ts": inputGroup,
|
|
30
|
+
"./inputNumber.tsx": inputNumber,
|
|
31
|
+
"./jsonCombination/index.tsx": index,
|
|
32
|
+
"./labelSelect.tsx": labelSelect,
|
|
33
|
+
"./levelSearchCascade.tsx": levelSearchCascade,
|
|
34
|
+
"./lineBar/index.ts": index$1,
|
|
35
|
+
"./radio.tsx": radio,
|
|
36
|
+
"./search.tsx": search,
|
|
37
|
+
"./searchCascade.tsx": searchCascade,
|
|
38
|
+
"./select.tsx": select,
|
|
39
|
+
"./simpleComponent.tsx": simpleComponent,
|
|
40
|
+
"./slider.tsx": slider,
|
|
41
|
+
"./switch.tsx": _switch,
|
|
42
|
+
"./textarea.tsx": textarea
|
|
43
|
+
});
|
|
44
|
+
const exportModules = Object.values(modules).reduce((result, m) => {
|
|
45
|
+
Object.assign(result, m);
|
|
46
|
+
return result;
|
|
47
|
+
}, {});
|
|
48
|
+
|
|
49
|
+
export { exportModules as default };
|
|
@@ -7,8 +7,8 @@ import { formRenderLog } from '../../utils/index.js';
|
|
|
7
7
|
import { connect, mapProps } from '@formily/vue';
|
|
8
8
|
import SearchCascader from '../../../../search-cascader/index.js';
|
|
9
9
|
import script$1 from '../../../../../shared/components/no-data/NoData.js';
|
|
10
|
-
import { useFormField } from '../../hooks/useFormField.js';
|
|
11
10
|
import { visitedDecorator, assignUpdateValue } from '../../utils/schema.js';
|
|
11
|
+
import { useFormField } from '../../hooks/useFormField.js';
|
|
12
12
|
import { useFormRequest } from '../../hooks/useFormRequest.js';
|
|
13
13
|
|
|
14
14
|
const script = defineComponent({
|
|
@@ -18,28 +18,11 @@ import '../../../../../shared/utils/tapable/AsyncSeriesHook.js';
|
|
|
18
18
|
import '../../../../../shared/utils/tapable/AsyncSeriesBailHook.js';
|
|
19
19
|
import '../../../../../shared/utils/tapable/AsyncSeriesLoopHook.js';
|
|
20
20
|
import '../../../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js';
|
|
21
|
+
import '../../hooks/useFormValidator.js';
|
|
21
22
|
import '@formily/core';
|
|
22
23
|
import '@vue/shared';
|
|
23
24
|
import { connect, mapProps } from '@formily/vue';
|
|
24
|
-
import './
|
|
25
|
-
import './select.js';
|
|
26
|
-
import './formItem.js';
|
|
27
|
-
import './textarea.js';
|
|
28
|
-
import './inputNumber.js';
|
|
29
|
-
import './lineBar/index.js';
|
|
30
|
-
import './inputGroup.js';
|
|
31
|
-
import './date.js';
|
|
32
|
-
import './levelSearchCascade.js';
|
|
33
|
-
import './jsonCombination/index.js';
|
|
34
|
-
import './combination.js';
|
|
35
|
-
import './checkbox.js';
|
|
36
|
-
import './switch.js';
|
|
37
|
-
import './radio.js';
|
|
38
|
-
import './labelSelect.js';
|
|
39
|
-
import './slider.js';
|
|
40
|
-
import './complex.js';
|
|
41
|
-
import './simpleComponent.js';
|
|
42
|
-
import './searchCascade.js';
|
|
25
|
+
import './index.js';
|
|
43
26
|
import { NSelect } from 'naive-ui';
|
|
44
27
|
import { visitedDecorator, assignUpdateValue, assignClearBindVisited } from '../../utils/schema.js';
|
|
45
28
|
|
|
@@ -18,27 +18,10 @@ import '../../../../../shared/utils/tapable/AsyncSeriesHook.js';
|
|
|
18
18
|
import '../../../../../shared/utils/tapable/AsyncSeriesBailHook.js';
|
|
19
19
|
import '../../../../../shared/utils/tapable/AsyncSeriesLoopHook.js';
|
|
20
20
|
import '../../../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js';
|
|
21
|
+
import '../../hooks/useFormValidator.js';
|
|
21
22
|
import '@vue/shared';
|
|
22
23
|
import { connect, mapProps } from '@formily/vue';
|
|
23
|
-
import './
|
|
24
|
-
import './select.js';
|
|
25
|
-
import './formItem.js';
|
|
26
|
-
import './textarea.js';
|
|
27
|
-
import './inputNumber.js';
|
|
28
|
-
import './lineBar/index.js';
|
|
29
|
-
import './inputGroup.js';
|
|
30
|
-
import './date.js';
|
|
31
|
-
import './levelSearchCascade.js';
|
|
32
|
-
import './jsonCombination/index.js';
|
|
33
|
-
import './combination.js';
|
|
34
|
-
import './checkbox.js';
|
|
35
|
-
import './switch.js';
|
|
36
|
-
import './radio.js';
|
|
37
|
-
import './labelSelect.js';
|
|
38
|
-
import './slider.js';
|
|
39
|
-
import './complex.js';
|
|
40
|
-
import './simpleComponent.js';
|
|
41
|
-
import './search.js';
|
|
24
|
+
import './index.js';
|
|
42
25
|
import { NCascader } from 'naive-ui';
|
|
43
26
|
import { assignUpdateValue, traverseDependKey } from '../../utils/schema.js';
|
|
44
27
|
|
|
@@ -18,27 +18,10 @@ import '../../../../../shared/utils/tapable/AsyncSeriesHook.js';
|
|
|
18
18
|
import '../../../../../shared/utils/tapable/AsyncSeriesBailHook.js';
|
|
19
19
|
import '../../../../../shared/utils/tapable/AsyncSeriesLoopHook.js';
|
|
20
20
|
import '../../../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js';
|
|
21
|
+
import '../../hooks/useFormValidator.js';
|
|
21
22
|
import '@vue/shared';
|
|
22
23
|
import { connect, mapProps } from '@formily/vue';
|
|
23
|
-
import './
|
|
24
|
-
import './formItem.js';
|
|
25
|
-
import './textarea.js';
|
|
26
|
-
import './inputNumber.js';
|
|
27
|
-
import './lineBar/index.js';
|
|
28
|
-
import './inputGroup.js';
|
|
29
|
-
import './date.js';
|
|
30
|
-
import './levelSearchCascade.js';
|
|
31
|
-
import './jsonCombination/index.js';
|
|
32
|
-
import './combination.js';
|
|
33
|
-
import './checkbox.js';
|
|
34
|
-
import './switch.js';
|
|
35
|
-
import './radio.js';
|
|
36
|
-
import './labelSelect.js';
|
|
37
|
-
import './slider.js';
|
|
38
|
-
import './complex.js';
|
|
39
|
-
import './simpleComponent.js';
|
|
40
|
-
import './search.js';
|
|
41
|
-
import './searchCascade.js';
|
|
24
|
+
import './index.js';
|
|
42
25
|
import { NSelect } from 'naive-ui';
|
|
43
26
|
import { traverseDependKey, visitedDecorator, assignUpdateValue, assignClearBindVisited } from '../../utils/schema.js';
|
|
44
27
|
|
|
@@ -5,7 +5,7 @@ export { useFormField } from './useFormField.js';
|
|
|
5
5
|
export { AsyncQueue, useAsyncQueue } from './useAsyncQueue.js';
|
|
6
6
|
export { useFieldVisitor } from './useFieldVisitor.js';
|
|
7
7
|
export { useFieldNormalize } from './useFieldNormalize.js';
|
|
8
|
-
export { useFormValidator } from './useFormValidator.js';
|
|
8
|
+
export { useFormValidator, validateMessageLocale } from './useFormValidator.js';
|
|
9
9
|
export { BusinessCollector, useBusinessBinding } from './useBusinessBinding.js';
|
|
10
10
|
export { ContextCollector, useChangeContext } from './useChangeContext.js';
|
|
11
11
|
export { FormItemDepsCollector, useFormItemDeps } from './useFormItemDeps.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { arrayed } from '../../../../shared/utils/index.js';
|
|
1
|
+
import { arrayed, deepOmit } from '../../../../shared/utils/index.js';
|
|
2
2
|
import { isObject } from '@vueuse/core';
|
|
3
|
-
import { cloneDeep,
|
|
3
|
+
import { cloneDeep, pick } from 'lodash-es';
|
|
4
4
|
import '../../index.js';
|
|
5
5
|
import { parseNumberFromMaybeString, formRenderLog } from '../utils/index.js';
|
|
6
6
|
import { useFieldNormalize } from './useFieldNormalize.js';
|
|
@@ -35,9 +35,13 @@ function useFieldListAdaptor(collector) {
|
|
|
35
35
|
result["x-reactions"] = item.reactions;
|
|
36
36
|
}
|
|
37
37
|
if (!item.noDecorator) {
|
|
38
|
+
if (JSON.stringify(item).includes("$deps")) {
|
|
39
|
+
console.log(item);
|
|
40
|
+
}
|
|
38
41
|
Object.assign(result, {
|
|
39
42
|
"x-decorator": "FORM_ITEM",
|
|
40
43
|
"x-decorator-props": {
|
|
44
|
+
fieldItem: deepOmit(item, ["reactions"]),
|
|
41
45
|
span: item.elem_width,
|
|
42
46
|
showLabel: item.hide_title !== "1",
|
|
43
47
|
propertyKey: item.val_key,
|
|
@@ -171,7 +175,7 @@ function useFieldListAdaptor(collector) {
|
|
|
171
175
|
const createCustomSchema = (item) => {
|
|
172
176
|
const schema = createStandardSchema(item);
|
|
173
177
|
Object.assign(schema["x-component-props"], {
|
|
174
|
-
fieldItem:
|
|
178
|
+
fieldItem: deepOmit(item, ["reactions"])
|
|
175
179
|
});
|
|
176
180
|
return schema;
|
|
177
181
|
};
|
|
@@ -4,7 +4,7 @@ import { cloneDeep } from 'lodash-es';
|
|
|
4
4
|
import { provide, computed, readonly } from 'vue';
|
|
5
5
|
import { createSchemaField } from '@formily/vue';
|
|
6
6
|
import '../../index.js';
|
|
7
|
-
import
|
|
7
|
+
import exportModules from '../components/renderer/index.js';
|
|
8
8
|
import { useFormRenderLifeCycle } from './useFormRenderLifeCycle.js';
|
|
9
9
|
import { usePresetScope } from './usePresetScope.js';
|
|
10
10
|
import { injectOrProvide, presetRequestHandler } from '../utils/index.js';
|
|
@@ -30,7 +30,7 @@ function useFormContext(props, formModel) {
|
|
|
30
30
|
const SchemaField = injectOrProvide(
|
|
31
31
|
InjectionSchemaField,
|
|
32
32
|
() => createSchemaField({
|
|
33
|
-
components: { ...
|
|
33
|
+
components: { ...exportModules, ...props.components },
|
|
34
34
|
scope: Object.assign({}, usePresetScope(), props.scope)
|
|
35
35
|
}).SchemaField
|
|
36
36
|
);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { arrayed } from '../../../../shared/utils/index.js';
|
|
2
|
-
import { isString } from 'lodash-es';
|
|
2
|
+
import { once, isString } from 'lodash-es';
|
|
3
3
|
import '../utils/index.js';
|
|
4
4
|
import { isFunction } from '@vueuse/core';
|
|
5
|
+
import { registerValidateLocale } from '@formily/core';
|
|
5
6
|
import { isIdCard } from '../utils/business.js';
|
|
6
7
|
|
|
7
8
|
function useFormValidator() {
|
|
@@ -42,7 +43,11 @@ function useFormValidator() {
|
|
|
42
43
|
};
|
|
43
44
|
function createValidatorSchema(fieldItem) {
|
|
44
45
|
const rules = [];
|
|
45
|
-
const {
|
|
46
|
+
const {
|
|
47
|
+
defined_error_msg,
|
|
48
|
+
validate: { vali_obj, max_length, min_length, message, max_value, min_value, decimal_length } = {},
|
|
49
|
+
validator
|
|
50
|
+
} = fieldItem;
|
|
46
51
|
if (validator) {
|
|
47
52
|
arrayed(validator).forEach((f) => {
|
|
48
53
|
if (!isFunction(f))
|
|
@@ -52,6 +57,8 @@ function useFormValidator() {
|
|
|
52
57
|
}
|
|
53
58
|
if (max_length)
|
|
54
59
|
rules.push({ max: max_length, message });
|
|
60
|
+
if (min_length)
|
|
61
|
+
rules.push({ min: min_length, message });
|
|
55
62
|
if (max_value)
|
|
56
63
|
rules.push({ maximum: max_value, message });
|
|
57
64
|
if (min_value)
|
|
@@ -66,5 +73,12 @@ function useFormValidator() {
|
|
|
66
73
|
}
|
|
67
74
|
return { createValidatorSchema };
|
|
68
75
|
}
|
|
76
|
+
const validateMessageLocale = once(() => {
|
|
77
|
+
registerValidateLocale({
|
|
78
|
+
"zh-CN": {
|
|
79
|
+
required: "${alias}\u4E3A\u5FC5\u586B"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
69
83
|
|
|
70
|
-
export { useFormValidator };
|
|
84
|
+
export { useFormValidator, validateMessageLocale };
|
|
@@ -16,3 +16,4 @@ export declare function presetRequestHandler(res: unknown): any;
|
|
|
16
16
|
export declare function optionMatcher(options: AnyObject[], input: Nullable<string>, key: string, matcherOption?: {
|
|
17
17
|
keyword?: string;
|
|
18
18
|
}): AnyObject[];
|
|
19
|
+
export declare function validateMessageParser(message: string, fieldItem: Omit<FieldItem, 'reactions'>): string;
|
|
@@ -124,5 +124,14 @@ function optionMatcher(options, input, key, matcherOption = {
|
|
|
124
124
|
return option[key];
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
function validateMessageParser(message, fieldItem) {
|
|
128
|
+
if (!isString(message) || !message)
|
|
129
|
+
return "";
|
|
130
|
+
return message.replace(/\$\{([^}]*)}/g, replacer);
|
|
131
|
+
function replacer(_, property) {
|
|
132
|
+
var _a;
|
|
133
|
+
return (_a = fieldItem[property.trim()]) != null ? _a : "";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
127
136
|
|
|
128
|
-
export { createInputSlot, createSlot, formRenderLog, injectOrProvide, mergeDeepProperties, optionMatcher, parseNumberFromMaybeString, presetRequestHandler };
|
|
137
|
+
export { createInputSlot, createSlot, formRenderLog, injectOrProvide, mergeDeepProperties, optionMatcher, parseNumberFromMaybeString, presetRequestHandler, validateMessageParser };
|