cnhis-design-vue 3.1.16-beta.9 → 3.1.17-beta.1
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 +6 -1
- package/es/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +2 -2
- package/es/packages/big-table/src/components/edit-form/edit-date.js +13 -3
- package/es/packages/big-table/src/components/edit-form/edit-time.js +1 -0
- package/es/packages/big-table/src/components/separate.js +1 -1
- package/es/packages/big-table/src/hooks/useSeparateRow.js +7 -4
- package/es/packages/button-print/index.d.ts +4 -1
- package/es/packages/button-print/src/ButtonPrint.vue.d.ts +4 -1
- package/es/packages/button-print/src/components/IdentityVerification.js +5 -7
- package/es/packages/button-print/src/components/IdentityVerification.vue.d.ts +4 -1
- package/es/packages/fabric-chart/index.d.ts +2 -0
- package/es/packages/fabric-chart/src/FabricChart.js +21 -6
- package/es/packages/fabric-chart/src/FabricChart.vue.d.ts +2 -0
- package/es/packages/fabric-chart/src/components/PopupTip.js +2 -2
- package/es/packages/fabric-chart/src/hooks/constant.js +1 -1
- package/es/packages/fabric-chart/src/hooks/useCenter.js +30 -20
- package/es/packages/fabric-chart/src/hooks/useLeft.d.ts +3 -1
- package/es/packages/fabric-chart/src/hooks/useLeft.js +30 -12
- package/es/packages/fabric-chart/src/hooks/useOther.js +63 -13
- package/es/packages/fabric-chart/src/hooks/useRight.d.ts +1 -1
- package/es/packages/fabric-chart/src/hooks/useRight.js +11 -69
- package/es/packages/fabric-chart/src/interface.d.ts +3 -0
- package/es/packages/form-config/index.d.ts +14 -9
- package/es/packages/form-config/src/FormConfig.vue.d.ts +14 -9
- package/es/packages/form-config/src/components/FormConfigCreator.js +2 -0
- package/es/packages/form-config/src/components/FormConfigCreator.vue.d.ts +6 -4
- package/es/packages/form-config/src/components/FormConfigEdit.js +1 -0
- package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +8 -5
- package/es/packages/form-config/src/constants/index.d.ts +2 -2
- package/es/packages/form-config/src/hooks/useConfigurationField.js +9 -9
- package/es/packages/form-config/src/types/index.d.ts +1 -0
- package/es/packages/form-config/style/index.css +1 -1
- package/es/packages/form-render/index.d.ts +6 -4
- package/es/packages/form-render/index.js +1 -2
- package/es/packages/form-render/src/FormRender.js +8 -9
- package/es/packages/form-render/src/FormRender.vue.d.ts +6 -4
- package/es/packages/form-render/src/components/renderer/{combination/index.d.ts → combination.d.ts} +3 -3
- package/es/packages/form-render/src/components/renderer/combination.js +92 -0
- package/es/packages/form-render/src/components/renderer/date.js +12 -4
- package/es/packages/form-render/src/components/renderer/formItem.js +12 -5
- package/es/packages/form-render/src/components/renderer/index.d.ts +1 -0
- package/es/packages/form-render/src/components/renderer/index.js +2 -1
- package/es/packages/form-render/src/components/renderer/inputGroup.js +1 -1
- package/es/packages/form-render/src/components/renderer/{combination → jsonCombination}/hooks/useDeepValidate.d.ts +0 -0
- package/es/packages/form-render/src/components/renderer/{combination → jsonCombination}/hooks/useDeepValidate.js +0 -0
- package/es/packages/form-render/src/components/renderer/jsonCombination/index.d.ts +44 -0
- package/es/packages/form-render/src/components/renderer/{combination → jsonCombination}/index.js +29 -14
- package/es/packages/form-render/src/components/renderer/select.js +11 -8
- package/es/packages/form-render/src/constants/index.d.ts +2 -2
- package/es/packages/form-render/src/hooks/index.d.ts +1 -2
- package/es/packages/form-render/src/hooks/index.js +1 -2
- package/es/packages/form-render/src/hooks/useAnchor.d.ts +3 -3
- package/es/packages/form-render/src/hooks/useAsyncQueue.d.ts +2 -2
- package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +5 -6
- package/es/packages/form-render/src/hooks/useBusinessBinding.js +22 -20
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.d.ts +1 -1
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +11 -7
- package/es/packages/form-render/src/hooks/useFieldNormalize.d.ts +5 -0
- package/es/packages/form-render/src/hooks/useFieldNormalize.js +58 -0
- package/es/packages/form-render/src/hooks/useFieldVisitor.js +2 -5
- package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.d.ts +4 -4
- package/es/packages/form-render/src/hooks/useFormRequest.d.ts +2 -2
- package/es/packages/form-render/src/types/fieldItem.d.ts +4 -0
- package/es/packages/form-render/src/types/index.d.ts +4 -4
- package/es/packages/form-render/src/utils/dom.d.ts +2 -2
- package/es/packages/form-render/src/utils/index.js +3 -2
- package/es/packages/form-render/src/utils/schema.d.ts +62 -2
- package/es/packages/form-render/src/utils/schema.js +5 -2
- package/es/packages/form-render/style/index.css +11 -8
- package/es/packages/index.css +12 -9
- package/es/packages/index.js +1 -2
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.js +1 -0
- package/es/packages/shortcut-setter/index.d.ts +7 -4
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +7 -4
- package/es/src/types/index.d.ts +2 -2
- package/es/src/utils/index.d.ts +1 -0
- package/es/src/utils/index.js +11 -1
- package/es/src/utils/tapable/AsyncParallelBailHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncParallelBailHook.js +78 -0
- package/es/src/utils/tapable/AsyncParallelHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncParallelHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesBailHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesBailHook.js +33 -0
- package/es/src/utils/tapable/AsyncSeriesHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesLoopHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesLoopHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesWaterfallHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesWaterfallHook.js +40 -0
- package/es/src/utils/tapable/Hook.d.ts +50 -0
- package/es/src/utils/tapable/Hook.js +140 -0
- package/es/src/utils/tapable/HookCodeFactory.d.ts +58 -0
- package/es/src/utils/tapable/HookCodeFactory.js +444 -0
- package/es/src/utils/tapable/HookMap.d.ts +11 -0
- package/es/src/utils/tapable/HookMap.js +32 -0
- package/es/src/utils/tapable/MultiHook.d.ts +12 -0
- package/es/src/utils/tapable/MultiHook.js +38 -0
- package/es/src/utils/tapable/SyncBailHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncBailHook.js +40 -0
- package/es/src/utils/tapable/SyncHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncHook.js +34 -0
- package/es/src/utils/tapable/SyncLoopHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncLoopHook.js +34 -0
- package/es/src/utils/tapable/SyncWaterfallHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncWaterfallHook.js +48 -0
- package/es/src/utils/tapable/index.d.ts +139 -0
- package/es/src/utils/tapable/index.js +12 -0
- package/package.json +4 -4
- package/es/packages/form-render/src/hooks/useInitialData.d.ts +0 -5
- package/es/packages/form-render/src/hooks/useInitialData.js +0 -16
- package/es/packages/form-render/src/hooks/useTypeNormalize.d.ts +0 -4
- package/es/packages/form-render/src/hooks/useTypeNormalize.js +0 -45
|
@@ -112,7 +112,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
112
112
|
lifeCycle: {
|
|
113
113
|
type: PropType<Partial<{
|
|
114
114
|
onSetup(): void;
|
|
115
|
-
beforeRequest(fieldKey: string, params?: AnyObject | undefined): void | import("../../../../es/src/types").
|
|
115
|
+
beforeRequest(fieldKey: string, params?: AnyObject | undefined): void | import("../../../../es/src/types").UndefinedAble<AnyObject>;
|
|
116
116
|
afterRequest(fieldKey: string, payload?: any): AnyObject[];
|
|
117
117
|
}>>;
|
|
118
118
|
};
|
|
@@ -227,7 +227,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
227
227
|
lifeCycle: {
|
|
228
228
|
type: PropType<Partial<{
|
|
229
229
|
onSetup(): void;
|
|
230
|
-
beforeRequest(fieldKey: string, params?: AnyObject | undefined): void | import("../../../../es/src/types").
|
|
230
|
+
beforeRequest(fieldKey: string, params?: AnyObject | undefined): void | import("../../../../es/src/types").UndefinedAble<AnyObject>;
|
|
231
231
|
afterRequest(fieldKey: string, payload?: any): AnyObject[];
|
|
232
232
|
}>>;
|
|
233
233
|
};
|
|
@@ -236,7 +236,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
236
236
|
}>>;
|
|
237
237
|
emit: (event: "formChange", ...args: any[]) => void;
|
|
238
238
|
nuiThemeOverrides: import("naive-ui").GlobalThemeOverrides;
|
|
239
|
-
formModel: import("@formily/core").Form<
|
|
239
|
+
formModel: import("@formily/core").Form<{
|
|
240
|
+
[x: string]: any;
|
|
241
|
+
}>;
|
|
240
242
|
SchemaField: Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions>;
|
|
241
243
|
businessCollector: import("./hooks").BusinessCollector;
|
|
242
244
|
formItemDepsCollector: import("./hooks").FormItemDepsCollector;
|
|
@@ -1727,7 +1729,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1727
1729
|
lifeCycle: {
|
|
1728
1730
|
type: PropType<Partial<{
|
|
1729
1731
|
onSetup(): void;
|
|
1730
|
-
beforeRequest(fieldKey: string, params?: AnyObject | undefined): void | import("../../../../es/src/types").
|
|
1732
|
+
beforeRequest(fieldKey: string, params?: AnyObject | undefined): void | import("../../../../es/src/types").UndefinedAble<AnyObject>;
|
|
1731
1733
|
afterRequest(fieldKey: string, payload?: any): AnyObject[];
|
|
1732
1734
|
}>>;
|
|
1733
1735
|
};
|
package/es/packages/form-render/src/components/renderer/{combination/index.d.ts → combination.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldItem } from '
|
|
1
|
+
import { FieldItem } from '../../../../../../es/packages/form-render';
|
|
2
2
|
import { PropType } from 'vue';
|
|
3
3
|
export declare const COMBINATION: import("vue").DefineComponent<{
|
|
4
4
|
title: {
|
|
@@ -6,7 +6,7 @@ export declare const COMBINATION: import("vue").DefineComponent<{
|
|
|
6
6
|
default: string;
|
|
7
7
|
};
|
|
8
8
|
value: {
|
|
9
|
-
type:
|
|
9
|
+
type: ArrayConstructor;
|
|
10
10
|
};
|
|
11
11
|
maxGroupNum: {
|
|
12
12
|
type: NumberConstructor;
|
|
@@ -24,7 +24,7 @@ export declare const COMBINATION: import("vue").DefineComponent<{
|
|
|
24
24
|
default: string;
|
|
25
25
|
};
|
|
26
26
|
value: {
|
|
27
|
-
type:
|
|
27
|
+
type: ArrayConstructor;
|
|
28
28
|
};
|
|
29
29
|
maxGroupNum: {
|
|
30
30
|
type: NumberConstructor;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, inject, createVNode } from 'vue';
|
|
2
|
+
import { isNumber } from 'lodash-es';
|
|
3
|
+
import { useFieldListAdaptor } from '../../../../../packages/form-render';
|
|
4
|
+
import { useField, RecursionField, connect } from '@formily/vue';
|
|
5
|
+
import { NButton, NIcon } from 'naive-ui';
|
|
6
|
+
import { InjectionBusinessCollector } from '../../../../../packages/form-render/src/constants';
|
|
7
|
+
import { createObjSchema } from '../../../../../packages/form-render/src/utils';
|
|
8
|
+
import { AddCircleOutline, RemoveCircle } from '@vicons/ionicons5';
|
|
9
|
+
|
|
10
|
+
const script = defineComponent({
|
|
11
|
+
name: "FormCombination",
|
|
12
|
+
props: {
|
|
13
|
+
title: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: ""
|
|
16
|
+
},
|
|
17
|
+
value: {
|
|
18
|
+
type: Array
|
|
19
|
+
},
|
|
20
|
+
maxGroupNum: {
|
|
21
|
+
type: Number
|
|
22
|
+
},
|
|
23
|
+
getProperties: {
|
|
24
|
+
type: Function,
|
|
25
|
+
default: () => []
|
|
26
|
+
},
|
|
27
|
+
onInput: {},
|
|
28
|
+
onBlur: {},
|
|
29
|
+
onChange: {}
|
|
30
|
+
},
|
|
31
|
+
emits: ["update:value"],
|
|
32
|
+
setup(props) {
|
|
33
|
+
const field = useField();
|
|
34
|
+
const currentGroupNum = ref(1);
|
|
35
|
+
const maxGroupNum = computed(() => {
|
|
36
|
+
if (!isNumber(props.maxGroupNum))
|
|
37
|
+
return Infinity;
|
|
38
|
+
if (props.maxGroupNum < 1)
|
|
39
|
+
return 0;
|
|
40
|
+
return ~~props.maxGroupNum;
|
|
41
|
+
});
|
|
42
|
+
function addGroup() {
|
|
43
|
+
currentGroupNum.value++;
|
|
44
|
+
}
|
|
45
|
+
async function removeGroup(idx) {
|
|
46
|
+
currentGroupNum.value--;
|
|
47
|
+
await field.value.remove(idx);
|
|
48
|
+
}
|
|
49
|
+
const collector = inject(InjectionBusinessCollector);
|
|
50
|
+
const {
|
|
51
|
+
schemaAdaptor
|
|
52
|
+
} = useFieldListAdaptor(collector);
|
|
53
|
+
return () => {
|
|
54
|
+
return createVNode("section", {
|
|
55
|
+
"class": "form-render__combination"
|
|
56
|
+
}, [createVNode("header", {
|
|
57
|
+
"class": "form-render__combinationHeader"
|
|
58
|
+
}, [createVNode("div", {
|
|
59
|
+
"class": "form-render__combinationHeaderText"
|
|
60
|
+
}, [props.title]), createVNode(NButton, {
|
|
61
|
+
"onClick": addGroup,
|
|
62
|
+
"type": "info",
|
|
63
|
+
"text": true,
|
|
64
|
+
"disabled": currentGroupNum.value >= maxGroupNum.value
|
|
65
|
+
}, {
|
|
66
|
+
icon: () => createVNode(NIcon, {
|
|
67
|
+
"component": AddCircleOutline
|
|
68
|
+
}, null),
|
|
69
|
+
default: () => "\u65B0\u589E"
|
|
70
|
+
})]), Array.from({
|
|
71
|
+
length: currentGroupNum.value
|
|
72
|
+
}).map((_, idx) => createVNode("section", {
|
|
73
|
+
"class": "form-render__combinationContent"
|
|
74
|
+
}, [createVNode(RecursionField, {
|
|
75
|
+
"schema": createObjSchema(schemaAdaptor(props.getProperties())),
|
|
76
|
+
"name": idx
|
|
77
|
+
}, null), idx === 0 ? null : createVNode(NButton, {
|
|
78
|
+
"text": true,
|
|
79
|
+
"type": "error",
|
|
80
|
+
"class": "form-render__combinationClose",
|
|
81
|
+
"onClick": () => removeGroup(idx)
|
|
82
|
+
}, {
|
|
83
|
+
icon: () => createVNode(NIcon, {
|
|
84
|
+
"component": RemoveCircle
|
|
85
|
+
}, null)
|
|
86
|
+
})]))]);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const COMBINATION = connect(script);
|
|
91
|
+
|
|
92
|
+
export { COMBINATION };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineComponent, computed, watch, createVNode, mergeProps } from 'vue';
|
|
2
|
+
import { generateTimeFormat } from '../../../../../src/utils';
|
|
2
3
|
import { connect, mapProps } from '@formily/vue';
|
|
3
4
|
import { isObject } from '@vueuse/core';
|
|
4
5
|
import { format } from 'date-fns';
|
|
@@ -66,9 +67,7 @@ const script = defineComponent({
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
const validateConfig = computed(() => {
|
|
69
|
-
const result = {
|
|
70
|
-
valueFormat: props.valueFormat
|
|
71
|
-
};
|
|
70
|
+
const result = {};
|
|
72
71
|
if (isObject(props.validate)) {
|
|
73
72
|
const {
|
|
74
73
|
min_date,
|
|
@@ -81,6 +80,15 @@ const script = defineComponent({
|
|
|
81
80
|
}
|
|
82
81
|
return result;
|
|
83
82
|
});
|
|
83
|
+
const formatConfig = computed(() => {
|
|
84
|
+
return {
|
|
85
|
+
valueFormat: props.valueFormat,
|
|
86
|
+
format: props.valueFormat,
|
|
87
|
+
timePickerProps: {
|
|
88
|
+
format: generateTimeFormat(props.valueFormat)
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
});
|
|
84
92
|
function formatDate(value) {
|
|
85
93
|
if (!value)
|
|
86
94
|
return value;
|
|
@@ -95,7 +103,7 @@ const script = defineComponent({
|
|
|
95
103
|
get: () => formatDate(props.value),
|
|
96
104
|
set: (value) => emit("update:value", value)
|
|
97
105
|
});
|
|
98
|
-
return () => createVNode(NDatePicker, mergeProps(validateConfig.value, {
|
|
106
|
+
return () => createVNode(NDatePicker, mergeProps(validateConfig.value, formatConfig.value, {
|
|
99
107
|
"formatted-value": valueRef.value,
|
|
100
108
|
"onUpdate:formatted-value": ($event) => valueRef.value = $event
|
|
101
109
|
}), null);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineComponent, inject, computed, createVNode } from 'vue';
|
|
2
2
|
import { isVoidField } from '@formily/core';
|
|
3
|
-
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
import { useField, connect, mapProps } from '@formily/vue';
|
|
4
4
|
import { NFormItem } from 'naive-ui';
|
|
5
5
|
import AnnotationEdit from '../../../../../packages/annotation-edit';
|
|
6
|
-
import { InjectionAnnotation } from '../../../../../packages/form-render/src/constants';
|
|
6
|
+
import { InjectionAnnotation, InjectionFormUUID } from '../../../../../packages/form-render/src/constants';
|
|
7
|
+
import { elementIdEscape } from '../../../../../packages/form-render/src/utils';
|
|
7
8
|
|
|
8
9
|
const script = defineComponent({
|
|
9
10
|
props: {
|
|
@@ -38,6 +39,11 @@ const script = defineComponent({
|
|
|
38
39
|
return annotation.value && props.annotation !== false;
|
|
39
40
|
});
|
|
40
41
|
const showLabel = computed(() => props.label && props.label !== " ");
|
|
42
|
+
const field = useField();
|
|
43
|
+
const uuid = inject(InjectionFormUUID);
|
|
44
|
+
const id = computed(() => {
|
|
45
|
+
return elementIdEscape(`${uuid}-${field.value.path.toString()}`);
|
|
46
|
+
});
|
|
41
47
|
function renderLabel() {
|
|
42
48
|
return showLabel.value ? createVNode("section", {
|
|
43
49
|
"class": "form-render__formItemLabel"
|
|
@@ -47,7 +53,9 @@ const script = defineComponent({
|
|
|
47
53
|
}]
|
|
48
54
|
}, [props.label]), showAnnotation.value ? renderAnnotation() : null]) : null;
|
|
49
55
|
}
|
|
50
|
-
return () => createVNode(NFormItem,
|
|
56
|
+
return () => createVNode(NFormItem, {
|
|
57
|
+
id: id.value
|
|
58
|
+
}, {
|
|
51
59
|
...slots,
|
|
52
60
|
label: renderLabel
|
|
53
61
|
});
|
|
@@ -56,14 +64,13 @@ const script = defineComponent({
|
|
|
56
64
|
const FORM_ITEM = connect(script, mapProps({
|
|
57
65
|
title: "label"
|
|
58
66
|
}, (props, field) => {
|
|
59
|
-
var _a;
|
|
60
67
|
const feedback = !isVoidField(field) ? field.selfErrors.length ? field.selfErrors.join(",") : void 0 : void 0;
|
|
61
68
|
return {
|
|
62
69
|
...props,
|
|
63
70
|
required: isVoidField(field) ? void 0 : field.required,
|
|
64
71
|
class: "form-render__formItem",
|
|
65
72
|
style: {
|
|
66
|
-
"--form-item-column":
|
|
73
|
+
"--form-item-column": props.span
|
|
67
74
|
},
|
|
68
75
|
feedback,
|
|
69
76
|
"validation-status": feedback ? "error" : void 0
|
|
@@ -7,7 +7,8 @@ export { LINEBAR } from './linebar.js';
|
|
|
7
7
|
export { INPUT_GROUP } from './inputGroup.js';
|
|
8
8
|
export { DATE } from './date.js';
|
|
9
9
|
export { SEARCH_CASCADE } from './cascader.js';
|
|
10
|
-
export {
|
|
10
|
+
export { JSON_COMBINATION } from './jsonCombination/index.js';
|
|
11
|
+
export { COMBINATION } from './combination.js';
|
|
11
12
|
export { CHECKBOX } from './checkbox.js';
|
|
12
13
|
export { SWITCH } from './switch.js';
|
|
13
14
|
export { RADIO } from './radio.js';
|
|
@@ -2,7 +2,7 @@ import { connect, mapProps } from '@formily/vue';
|
|
|
2
2
|
import { NInputGroup } from 'naive-ui';
|
|
3
3
|
|
|
4
4
|
const INPUT_GROUP = connect(NInputGroup, mapProps((props) => {
|
|
5
|
-
return { style: { "--column": props.span
|
|
5
|
+
return { style: { "--column": props.span }, class: "form-render__inputGroup" };
|
|
6
6
|
}));
|
|
7
7
|
|
|
8
8
|
export { INPUT_GROUP };
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FieldItem } from '../../../../../../../es/packages/form-render';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
export declare const JSON_COMBINATION: import("vue").DefineComponent<{
|
|
4
|
+
title: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
value: {
|
|
9
|
+
type: (ArrayConstructor | StringConstructor)[];
|
|
10
|
+
};
|
|
11
|
+
maxGroupNum: {
|
|
12
|
+
type: NumberConstructor;
|
|
13
|
+
};
|
|
14
|
+
getProperties: {
|
|
15
|
+
type: PropType<() => FieldItem[]>;
|
|
16
|
+
default: () => never[];
|
|
17
|
+
};
|
|
18
|
+
onInput: {};
|
|
19
|
+
onBlur: {};
|
|
20
|
+
onChange: {};
|
|
21
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:value"[], "update:value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
|
+
title: {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
value: {
|
|
27
|
+
type: (ArrayConstructor | StringConstructor)[];
|
|
28
|
+
};
|
|
29
|
+
maxGroupNum: {
|
|
30
|
+
type: NumberConstructor;
|
|
31
|
+
};
|
|
32
|
+
getProperties: {
|
|
33
|
+
type: PropType<() => FieldItem[]>;
|
|
34
|
+
default: () => never[];
|
|
35
|
+
};
|
|
36
|
+
onInput: {};
|
|
37
|
+
onBlur: {};
|
|
38
|
+
onChange: {};
|
|
39
|
+
}>> & {
|
|
40
|
+
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
title: string;
|
|
43
|
+
getProperties: () => FieldItem[];
|
|
44
|
+
}>;
|
package/es/packages/form-render/src/components/renderer/{combination → jsonCombination}/index.js
RENAMED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { defineComponent, ref, computed, watch, onMounted, createVNode
|
|
1
|
+
import { defineComponent, ref, computed, watch, onMounted, createVNode } from 'vue';
|
|
2
2
|
import { isField } from '@formily/core';
|
|
3
3
|
import { Path } from '@formily/path';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { AddCircleOutline, RemoveCircle } from '@vicons/ionicons5';
|
|
5
|
+
import { isNumber, isArray, isEqual } from 'lodash-es';
|
|
6
|
+
import { useDeepValidate } from '../../../../../../packages/form-render/src/components/renderer/jsonCombination/hooks/useDeepValidate';
|
|
7
|
+
import { formRenderLog, mergeDeepProperties } from '../../../utils/index.js';
|
|
7
8
|
import { connect, mapProps } from '@formily/vue';
|
|
8
9
|
import { useDebounceFn, isObject } from '@vueuse/core';
|
|
9
|
-
import { NButton } from 'naive-ui';
|
|
10
|
+
import { NButton, NIcon } from 'naive-ui';
|
|
10
11
|
import FormRender from '../../../FormRender.js';
|
|
11
12
|
import { assignUpdateValue } from '../../../utils/schema.js';
|
|
12
13
|
|
|
13
14
|
const script = defineComponent({
|
|
14
|
-
name: "
|
|
15
|
+
name: "FormJsonCombination",
|
|
15
16
|
props: {
|
|
16
17
|
title: {
|
|
17
18
|
type: String,
|
|
18
19
|
default: ""
|
|
19
20
|
},
|
|
20
21
|
value: {
|
|
21
|
-
type: String
|
|
22
|
+
type: [String, Array]
|
|
22
23
|
},
|
|
23
24
|
maxGroupNum: {
|
|
24
25
|
type: Number
|
|
@@ -35,12 +36,18 @@ const script = defineComponent({
|
|
|
35
36
|
setup(props, {
|
|
36
37
|
emit
|
|
37
38
|
}) {
|
|
39
|
+
formRenderLog("\u5F53\u524DCOMBINATION\u63A7\u4EF6\u4E3Ajson\u6A21\u5F0F,\u63A8\u8350\u4F7F\u7528\u975Ejson\u6A21\u5F0F,FieldItem.jsonCombination=false", "warn");
|
|
38
40
|
const emitChange = useDebounceFn(function emitChange2() {
|
|
39
41
|
emit("update:value", JSON.stringify(combinationData.value));
|
|
40
42
|
}, 300);
|
|
41
43
|
const combinationData = ref([]);
|
|
42
44
|
const currentGroupNum = computed(() => combinationData.value.length);
|
|
43
45
|
function setCombinationData(data, withInitialData = false) {
|
|
46
|
+
if (isArray(data)) {
|
|
47
|
+
if (!data.length)
|
|
48
|
+
data.push({});
|
|
49
|
+
data = JSON.stringify(data);
|
|
50
|
+
}
|
|
44
51
|
const parsedData = getParsedData(data);
|
|
45
52
|
if (!needLoad(parsedData))
|
|
46
53
|
return;
|
|
@@ -66,7 +73,6 @@ const script = defineComponent({
|
|
|
66
73
|
return null;
|
|
67
74
|
return result;
|
|
68
75
|
} catch (e) {
|
|
69
|
-
formRenderLog(`invalid JSON value ${data2} in COMBINATION => ${props.title}`, "warn");
|
|
70
76
|
return null;
|
|
71
77
|
}
|
|
72
78
|
}
|
|
@@ -137,22 +143,31 @@ const script = defineComponent({
|
|
|
137
143
|
"text": true,
|
|
138
144
|
"disabled": currentGroupNum.value >= maxGroupNum.value
|
|
139
145
|
}, {
|
|
140
|
-
|
|
146
|
+
icon: () => createVNode(NIcon, {
|
|
147
|
+
"component": AddCircleOutline
|
|
148
|
+
}, null),
|
|
149
|
+
default: () => "\u65B0\u589E"
|
|
141
150
|
})]), Array.from({
|
|
142
151
|
length: currentGroupNum.value
|
|
143
152
|
}).map((_, idx) => createVNode("section", {
|
|
144
|
-
"class": "form-
|
|
153
|
+
"class": "form-render__combinationContentJson"
|
|
145
154
|
}, [createVNode(FormRenderComponent, {
|
|
146
155
|
"ref": (_ref) => setFormRenderRef(idx, _ref),
|
|
147
156
|
"fieldList": props.getProperties(),
|
|
148
157
|
"onFormChange": (payload) => onChange(idx, payload)
|
|
149
|
-
}, null), idx === 0 ? null : createVNode(
|
|
158
|
+
}, null), idx === 0 ? null : createVNode(NButton, {
|
|
159
|
+
"text": true,
|
|
150
160
|
"class": "form-render__combinationClose",
|
|
161
|
+
"type": "error",
|
|
151
162
|
"onClick": () => removeGroup(idx)
|
|
152
|
-
},
|
|
163
|
+
}, {
|
|
164
|
+
icon: () => createVNode(NIcon, {
|
|
165
|
+
"component": RemoveCircle
|
|
166
|
+
}, null)
|
|
167
|
+
})]))]);
|
|
153
168
|
};
|
|
154
169
|
}
|
|
155
170
|
});
|
|
156
|
-
const
|
|
171
|
+
const JSON_COMBINATION = connect(script, mapProps(assignUpdateValue));
|
|
157
172
|
|
|
158
|
-
export {
|
|
173
|
+
export { JSON_COMBINATION };
|
|
@@ -72,12 +72,12 @@ const script = defineComponent({
|
|
|
72
72
|
try {
|
|
73
73
|
traverseDependKey(config.dependKey, (dependKey, valueKey2, required) => {
|
|
74
74
|
const _field = field2.query(dependKey).take();
|
|
75
|
-
if (isField(_field))
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
_params[valueKey2] = _field.value;
|
|
75
|
+
if (!isField(_field))
|
|
76
|
+
return;
|
|
77
|
+
if (required && _field.value == null) {
|
|
78
|
+
throw `\u7F3A\u5C11\u5FC5\u987B\u7684\u53C2\u6570=>${dependKey}`;
|
|
80
79
|
}
|
|
80
|
+
_params[valueKey2] = _field.value;
|
|
81
81
|
});
|
|
82
82
|
} catch (e) {
|
|
83
83
|
return Promise.reject(e);
|
|
@@ -105,11 +105,14 @@ const script = defineComponent({
|
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
const changeContextCollector = inject(InjectionChangeContextCollector);
|
|
108
|
-
changeContextCollector
|
|
108
|
+
changeContextCollector.setContext(fieldKey.value, async () => {
|
|
109
109
|
await nextTick();
|
|
110
110
|
return {
|
|
111
|
-
currentOption: cloneDeep(
|
|
111
|
+
currentOption: cloneDeep(getCurrentOption())
|
|
112
112
|
};
|
|
113
|
+
function getCurrentOption() {
|
|
114
|
+
return parsedOptions.value.find((option) => option[valueKey.value] === valueRef.value);
|
|
115
|
+
}
|
|
113
116
|
});
|
|
114
117
|
const formItemDepsCollector = inject(InjectionFormItemDepsCollector);
|
|
115
118
|
watch(() => props.urlConfig, (config, oldConfig) => {
|
|
@@ -120,7 +123,7 @@ const script = defineComponent({
|
|
|
120
123
|
return;
|
|
121
124
|
formItemDepsCollector.setDeps(fieldKey.value, config.dependKey || [], async () => {
|
|
122
125
|
remoteOptions.value = null;
|
|
123
|
-
|
|
126
|
+
valueRef.value = null;
|
|
124
127
|
!props.lazyRequest && await fetchData();
|
|
125
128
|
});
|
|
126
129
|
(valueRef.value || !props.lazyRequest) && fetchData();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Nullable } from '../../../../../es/src/types';
|
|
2
2
|
import { ContextCollector } from '../../../../../es/packages/form-render/src/hooks/useChangeContext';
|
|
3
3
|
import { BusinessCollector, FormItemDepsCollector } from '../hooks';
|
|
4
4
|
import { FormAsyncQueue } from '../types';
|
|
@@ -9,7 +9,7 @@ export declare const InjectionBusinessCollector: InjectionKey<BusinessCollector>
|
|
|
9
9
|
export declare const InjectionChangeContextCollector: InjectionKey<ContextCollector>;
|
|
10
10
|
export declare const InjectionFormItemDepsCollector: InjectionKey<FormItemDepsCollector>;
|
|
11
11
|
export declare const InjectionFormUUID: InjectionKey<string>;
|
|
12
|
-
export declare const InjectionAnnotation: InjectionKey<WritableComputedRef<
|
|
12
|
+
export declare const InjectionAnnotation: InjectionKey<WritableComputedRef<Nullable<Record<string, string>>>>;
|
|
13
13
|
export declare const FormItemLineBarDepKeyPrepend = "__dep_LINEBAR_";
|
|
14
14
|
export declare enum FIELD_BUSINESS_TYPE {
|
|
15
15
|
PASSWORD = "password",
|
|
@@ -4,11 +4,10 @@ export * from './useCommonLog';
|
|
|
4
4
|
export * from './useFormField';
|
|
5
5
|
export * from './useAsyncQueue';
|
|
6
6
|
export * from './useFieldVisitor';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './useFieldNormalize';
|
|
8
8
|
export * from './useFormValidator';
|
|
9
9
|
export * from './useBusinessBinding';
|
|
10
10
|
export * from './useChangeContext';
|
|
11
11
|
export * from './useFormItemDeps';
|
|
12
|
-
export * from './useInitialData';
|
|
13
12
|
export * from './useAnchor';
|
|
14
13
|
export * from './useFormContext';
|
|
@@ -4,11 +4,10 @@ export { useCommonLog } from './useCommonLog.js';
|
|
|
4
4
|
export { useFormField } from './useFormField.js';
|
|
5
5
|
export { AsyncQueue, useAsyncQueue } from './useAsyncQueue.js';
|
|
6
6
|
export { useFieldVisitor } from './useFieldVisitor.js';
|
|
7
|
-
export {
|
|
7
|
+
export { useFieldNormalize } from './useFieldNormalize.js';
|
|
8
8
|
export { useFormValidator } 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';
|
|
12
|
-
export { useInitialData } from './useInitialData.js';
|
|
13
12
|
export { useAnchor } from './useAnchor.js';
|
|
14
13
|
export { useFormContext } from './useFormContext.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UndefinedAble } from '../../../../../es/src/types';
|
|
2
2
|
import { ISchema } from '@formily/json-schema/esm/types';
|
|
3
3
|
import { Ref } from 'vue';
|
|
4
4
|
import { FormItemDepsCollector, FormRenderProps } from '../../../../../es/packages/form-render';
|
|
5
|
-
export declare function useAnchor(props: Readonly<FormRenderProps>, scrollbarRef: Ref<
|
|
5
|
+
export declare function useAnchor(props: Readonly<FormRenderProps>, scrollbarRef: Ref<UndefinedAble<HTMLElement>>, collector: FormItemDepsCollector): {
|
|
6
6
|
currentAnchor: import("vue").WritableComputedRef<string>;
|
|
7
7
|
onScroll: () => void;
|
|
8
8
|
formHeight: import("vue").ComputedRef<string | undefined>;
|
|
@@ -11,6 +11,6 @@ export declare function useAnchor(props: Readonly<FormRenderProps>, scrollbarRef
|
|
|
11
11
|
title: string;
|
|
12
12
|
}[]>;
|
|
13
13
|
generateAnchorList: (schema: ISchema) => void;
|
|
14
|
-
scrollbarRef: Ref<
|
|
14
|
+
scrollbarRef: Ref<UndefinedAble<HTMLElement>>;
|
|
15
15
|
scrollTo: (id: string) => Promise<void>;
|
|
16
16
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AnyObject,
|
|
1
|
+
import { AnyObject, UndefinedAble } from '../../../../../es/src/types';
|
|
2
2
|
import { FormAsyncQueueItem } from '../types';
|
|
3
3
|
declare type ProcessorOption = Partial<{
|
|
4
4
|
afterRequest(key: string, payload?: unknown): AnyObject[];
|
|
5
|
-
beforeRequest(key: string, params?: unknown):
|
|
5
|
+
beforeRequest(key: string, params?: unknown): UndefinedAble<AnyObject> | void;
|
|
6
6
|
}>;
|
|
7
7
|
interface EntryCallback {
|
|
8
8
|
(err?: any, result?: any): void;
|
|
@@ -12,12 +12,11 @@ export declare class BusinessCollector {
|
|
|
12
12
|
private getField;
|
|
13
13
|
private getType;
|
|
14
14
|
private getValueByField;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
private handlerChangeMap;
|
|
15
|
+
getValueByType(type: FIELD_BUSINESS_TYPE): unknown;
|
|
16
|
+
setValueByType(type: FIELD_BUSINESS_TYPE, value: unknown, force?: boolean): void;
|
|
17
|
+
registerChangeBusiness(type: FIELD_BUSINESS_TYPE, handler: () => void): this;
|
|
18
|
+
registerBlurBusiness(type: FIELD_BUSINESS_TYPE, handler: () => void): this;
|
|
19
|
+
private changeHandlerMap;
|
|
21
20
|
private blurHandlerMap;
|
|
22
21
|
trigger(fieldName: string, triggerType?: 'change' | 'blur'): void;
|
|
23
22
|
}
|
|
@@ -10,14 +10,8 @@ class BusinessCollector {
|
|
|
10
10
|
this.businessFormatter = businessFormatter;
|
|
11
11
|
this.typeCollector = /* @__PURE__ */ new Map();
|
|
12
12
|
this.fieldNameCollector = /* @__PURE__ */ new Map();
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
[FIELD_BUSINESS_TYPE.AGE_UNIT, this.handlerAgeType.bind(this)]
|
|
16
|
-
]);
|
|
17
|
-
this.blurHandlerMap = /* @__PURE__ */ new Map([
|
|
18
|
-
[FIELD_BUSINESS_TYPE.BIRTHDAY, this.handlerBirthdayType.bind(this)],
|
|
19
|
-
[FIELD_BUSINESS_TYPE.AGE, this.handlerAgeType.bind(this)]
|
|
20
|
-
]);
|
|
13
|
+
this.changeHandlerMap = /* @__PURE__ */ new Map([]);
|
|
14
|
+
this.blurHandlerMap = /* @__PURE__ */ new Map([]);
|
|
21
15
|
}
|
|
22
16
|
formatter(...args) {
|
|
23
17
|
return isFunction(this.businessFormatter) ? this.businessFormatter(...args) : args[0].value;
|
|
@@ -48,7 +42,23 @@ class BusinessCollector {
|
|
|
48
42
|
state.value = this.formatter({ value, type, fieldKey: field });
|
|
49
43
|
});
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
registerChangeBusiness(type, handler) {
|
|
46
|
+
this.changeHandlerMap.set(type, handler);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
registerBlurBusiness(type, handler) {
|
|
50
|
+
this.blurHandlerMap.set(type, handler);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
trigger(fieldName, triggerType = "change") {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const type = this.getType(fieldName);
|
|
56
|
+
const handlerMaps = { change: this.changeHandlerMap, blur: this.blurHandlerMap };
|
|
57
|
+
type && ((_b = (_a = handlerMaps[triggerType]) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.call(this));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function useBusinessBinding() {
|
|
61
|
+
function handlerIdCardType() {
|
|
52
62
|
const idCard = this.getValueByType(FIELD_BUSINESS_TYPE.ID_CARD);
|
|
53
63
|
if (!idCard || !isString(idCard) || !isIdCard(idCard))
|
|
54
64
|
return;
|
|
@@ -59,7 +69,7 @@ class BusinessCollector {
|
|
|
59
69
|
this.setValueByType(FIELD_BUSINESS_TYPE.SEX, info.sex);
|
|
60
70
|
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, info.birthday);
|
|
61
71
|
}
|
|
62
|
-
handlerBirthdayType() {
|
|
72
|
+
function handlerBirthdayType() {
|
|
63
73
|
const birthday = this.getValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY);
|
|
64
74
|
if (!isString(birthday))
|
|
65
75
|
return;
|
|
@@ -67,7 +77,7 @@ class BusinessCollector {
|
|
|
67
77
|
this.setValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT, ageUnit);
|
|
68
78
|
this.setValueByType(FIELD_BUSINESS_TYPE.AGE, age);
|
|
69
79
|
}
|
|
70
|
-
handlerAgeType() {
|
|
80
|
+
function handlerAgeType() {
|
|
71
81
|
const age = this.getValueByType(FIELD_BUSINESS_TYPE.AGE);
|
|
72
82
|
const ageUnit = this.getValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT);
|
|
73
83
|
if (!isString(age) && !isNumber(age) || age === "")
|
|
@@ -76,16 +86,8 @@ class BusinessCollector {
|
|
|
76
86
|
return;
|
|
77
87
|
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, parseAge2Birthday(+age, ageUnit), false);
|
|
78
88
|
}
|
|
79
|
-
trigger(fieldName, triggerType = "change") {
|
|
80
|
-
var _a;
|
|
81
|
-
const type = this.getType(fieldName);
|
|
82
|
-
const handler = triggerType === "change" ? this.handlerChangeMap : triggerType === "blur" ? this.blurHandlerMap : null;
|
|
83
|
-
type && ((_a = handler == null ? void 0 : handler.get(type)) == null ? void 0 : _a());
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function useBusinessBinding() {
|
|
87
89
|
function create(formModel, formatter) {
|
|
88
|
-
return new BusinessCollector(formModel, formatter);
|
|
90
|
+
return new BusinessCollector(formModel, formatter).registerChangeBusiness(FIELD_BUSINESS_TYPE.ID_CARD, handlerIdCardType).registerChangeBusiness(FIELD_BUSINESS_TYPE.AGE_UNIT, handlerAgeType).registerBlurBusiness(FIELD_BUSINESS_TYPE.BIRTHDAY, handlerBirthdayType).registerBlurBusiness(FIELD_BUSINESS_TYPE.AGE, handlerAgeType);
|
|
89
91
|
}
|
|
90
92
|
return { create };
|
|
91
93
|
}
|
|
@@ -3,7 +3,7 @@ import { FieldItem } from '../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* @description 胶水层, 将低代码平台中的fieldList转换为JSONSchema
|
|
5
5
|
*/
|
|
6
|
-
export declare function useFieldListAdaptor(collector: BusinessCollector
|
|
6
|
+
export declare function useFieldListAdaptor(collector: BusinessCollector): {
|
|
7
7
|
schemaAdaptor: (fieldList: FieldItem[]) => Record<string, import("@formily/json-schema/esm/types").Stringify<{
|
|
8
8
|
[key: symbol]: any;
|
|
9
9
|
[key: `x-${string}`]: any;
|