cnhis-design-vue 3.1.38-beta.6 → 3.1.38-beta.8
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/README.md +123 -123
- package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
- package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +1 -0
- package/es/components/bpmn-workflow/types/ModelingModule.d.ts +1 -0
- package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +1 -0
- package/es/components/fabric-chart/src/utils/index.d.ts +6823 -0
- package/es/components/form-config/index.d.ts +217 -12
- package/es/components/form-config/src/FormConfig.vue.d.ts +217 -12
- package/es/components/form-config/src/components/FormConfigCreator.vue.d.ts +108 -6
- package/es/components/form-config/src/components/FormConfigEdit.vue.d.ts +109 -6
- package/es/components/form-render/index.d.ts +108 -6
- package/es/components/form-render/src/FormRender.vue.d.ts +108 -6
- package/es/components/form-render/src/FormRender.vue.js +32 -107
- package/es/components/form-render/src/FormRenderWrapper.vue.d.ts +108 -6
- package/es/components/form-render/src/components/renderer/combination.d.ts +1 -1
- package/es/components/form-render/src/components/renderer/combination.js +9 -5
- package/es/components/form-render/src/components/renderer/formItem.d.ts +11 -3
- package/es/components/form-render/src/components/renderer/formItem.js +28 -20
- package/es/components/form-render/src/components/renderer/index.js +2 -4
- package/es/components/form-render/src/components/renderer/radio&checkbox.d.ts +186 -0
- package/es/components/form-render/src/components/renderer/radio_checkbox.js +111 -0
- package/es/components/form-render/src/hooks/useComplexOptions.d.ts +31 -0
- package/es/components/form-render/src/hooks/useComplexOptions.js +225 -0
- package/es/components/form-render/src/hooks/useFieldListAdaptor.js +10 -13
- package/es/components/form-render/src/hooks/useFormEvent.d.ts +29 -0
- package/es/components/form-render/src/hooks/useFormEvent.js +140 -0
- package/es/components/form-render/src/hooks/useFormField.d.ts +3 -2
- package/es/components/form-render/src/hooks/useFormRenderOptions.js +4 -6
- package/es/components/form-render/src/types/fieldItem.d.ts +4 -3
- package/es/components/form-render/src/types/index.d.ts +3 -1
- package/es/components/form-render/src/utils/schema.d.ts +1 -60
- package/es/components/form-render/style/index.css +1 -1
- package/es/components/index.css +1 -1
- package/es/components/scale-view/style/index.css +1 -1
- package/es/components/shortcut-setter/index.d.ts +109 -6
- package/es/components/shortcut-setter/src/ShortcutSetter.vue.d.ts +109 -6
- package/es/shared/assets/img/failure.js +1 -1
- package/es/shared/assets/img/failure.png.js +1 -1
- package/es/shared/assets/img/icon-asc.js +1 -1
- package/es/shared/assets/img/icon-desc.js +1 -1
- package/es/shared/assets/img/no-permission.js +1 -1
- package/es/shared/assets/img/no-permission.png.js +1 -1
- package/es/shared/assets/img/nodata.js +1 -1
- package/es/shared/assets/img/nodata.png.js +1 -1
- package/es/shared/assets/img/notfound.js +1 -1
- package/es/shared/assets/img/notfound.png.js +1 -1
- package/es/shared/assets/img/qr.js +1 -1
- package/es/shared/assets/img/qr.png.js +1 -1
- package/es/shared/assets/img/success.js +1 -1
- package/es/shared/assets/img/success.png.js +1 -1
- package/es/shared/assets/img/video.js +1 -1
- package/es/shared/assets/img/video.png.js +1 -1
- package/es/shared/assets/img/video_default_cover.js +1 -1
- package/es/shared/assets/img/video_default_cover.png.js +1 -1
- package/es/shared/assets/img/video_hover.js +1 -1
- package/es/shared/assets/img/video_play_hover.js +1 -1
- package/es/shared/assets/img/xb_big.js +1 -1
- package/es/shared/assets/img/xb_big.png.js +1 -1
- package/es/shared/assets/img/xb_small.js +1 -1
- package/es/shared/assets/img/xb_small.png.js +1 -1
- package/es/shared/components/VueDraggable/src/vuedraggable.d.ts +86 -0
- package/es/shared/utils/index.d.ts +1 -0
- package/es/shared/utils/index.js +6 -1
- package/es/shared/utils/tapable/index.d.ts +139 -0
- package/package.json +2 -2
- package/es/components/form-render/src/components/renderer/checkbox.d.ts +0 -90
- package/es/components/form-render/src/components/renderer/checkbox.js +0 -79
- package/es/components/form-render/src/components/renderer/radio.d.ts +0 -94
- package/es/components/form-render/src/components/renderer/radio.js +0 -101
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { AnyObject } from '../../../../../../es/shared/types';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
export declare const RADIO: import("vue").DefineComponent<{
|
|
4
|
+
value: {
|
|
5
|
+
type: (NumberConstructor | ObjectConstructor | StringConstructor)[];
|
|
6
|
+
};
|
|
7
|
+
options: {
|
|
8
|
+
type: PropType<AnyObject[]>;
|
|
9
|
+
default: () => never[];
|
|
10
|
+
};
|
|
11
|
+
autograph: {
|
|
12
|
+
type: StringConstructor;
|
|
13
|
+
};
|
|
14
|
+
lazyRequest: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
requestCache: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
wordbook: {
|
|
23
|
+
type: PropType<Partial<{
|
|
24
|
+
level_num: number;
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
render_key: string[];
|
|
28
|
+
search_key: string[];
|
|
29
|
+
primary_key: string;
|
|
30
|
+
type: string;
|
|
31
|
+
value_key: string;
|
|
32
|
+
level_key: string;
|
|
33
|
+
link_key: string;
|
|
34
|
+
link_key_split: string;
|
|
35
|
+
show_key: string[];
|
|
36
|
+
conObj: AnyObject[];
|
|
37
|
+
conObjFirstLevel: AnyObject[];
|
|
38
|
+
}>>;
|
|
39
|
+
};
|
|
40
|
+
vertical: {
|
|
41
|
+
type: BooleanConstructor;
|
|
42
|
+
default: boolean;
|
|
43
|
+
};
|
|
44
|
+
onChange: {};
|
|
45
|
+
}, () => 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<{
|
|
46
|
+
value: {
|
|
47
|
+
type: (NumberConstructor | ObjectConstructor | StringConstructor)[];
|
|
48
|
+
};
|
|
49
|
+
options: {
|
|
50
|
+
type: PropType<AnyObject[]>;
|
|
51
|
+
default: () => never[];
|
|
52
|
+
};
|
|
53
|
+
autograph: {
|
|
54
|
+
type: StringConstructor;
|
|
55
|
+
};
|
|
56
|
+
lazyRequest: {
|
|
57
|
+
type: BooleanConstructor;
|
|
58
|
+
default: boolean;
|
|
59
|
+
};
|
|
60
|
+
requestCache: {
|
|
61
|
+
type: BooleanConstructor;
|
|
62
|
+
default: boolean;
|
|
63
|
+
};
|
|
64
|
+
wordbook: {
|
|
65
|
+
type: PropType<Partial<{
|
|
66
|
+
level_num: number;
|
|
67
|
+
id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
render_key: string[];
|
|
70
|
+
search_key: string[];
|
|
71
|
+
primary_key: string;
|
|
72
|
+
type: string;
|
|
73
|
+
value_key: string;
|
|
74
|
+
level_key: string;
|
|
75
|
+
link_key: string;
|
|
76
|
+
link_key_split: string;
|
|
77
|
+
show_key: string[];
|
|
78
|
+
conObj: AnyObject[];
|
|
79
|
+
conObjFirstLevel: AnyObject[];
|
|
80
|
+
}>>;
|
|
81
|
+
};
|
|
82
|
+
vertical: {
|
|
83
|
+
type: BooleanConstructor;
|
|
84
|
+
default: boolean;
|
|
85
|
+
};
|
|
86
|
+
onChange: {};
|
|
87
|
+
}>> & {
|
|
88
|
+
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
options: AnyObject[];
|
|
91
|
+
vertical: boolean;
|
|
92
|
+
lazyRequest: boolean;
|
|
93
|
+
requestCache: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
export declare const CHECKBOX: import("vue").DefineComponent<{
|
|
96
|
+
value: {
|
|
97
|
+
type: (NumberConstructor | ObjectConstructor | StringConstructor)[];
|
|
98
|
+
};
|
|
99
|
+
options: {
|
|
100
|
+
type: PropType<AnyObject[]>;
|
|
101
|
+
default: () => never[];
|
|
102
|
+
};
|
|
103
|
+
autograph: {
|
|
104
|
+
type: StringConstructor;
|
|
105
|
+
};
|
|
106
|
+
lazyRequest: {
|
|
107
|
+
type: BooleanConstructor;
|
|
108
|
+
default: boolean;
|
|
109
|
+
};
|
|
110
|
+
requestCache: {
|
|
111
|
+
type: BooleanConstructor;
|
|
112
|
+
default: boolean;
|
|
113
|
+
};
|
|
114
|
+
wordbook: {
|
|
115
|
+
type: PropType<Partial<{
|
|
116
|
+
level_num: number;
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
render_key: string[];
|
|
120
|
+
search_key: string[];
|
|
121
|
+
primary_key: string;
|
|
122
|
+
type: string;
|
|
123
|
+
value_key: string;
|
|
124
|
+
level_key: string;
|
|
125
|
+
link_key: string;
|
|
126
|
+
link_key_split: string;
|
|
127
|
+
show_key: string[];
|
|
128
|
+
conObj: AnyObject[];
|
|
129
|
+
conObjFirstLevel: AnyObject[];
|
|
130
|
+
}>>;
|
|
131
|
+
};
|
|
132
|
+
vertical: {
|
|
133
|
+
type: BooleanConstructor;
|
|
134
|
+
default: boolean;
|
|
135
|
+
};
|
|
136
|
+
onChange: {};
|
|
137
|
+
}, () => 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<{
|
|
138
|
+
value: {
|
|
139
|
+
type: (NumberConstructor | ObjectConstructor | StringConstructor)[];
|
|
140
|
+
};
|
|
141
|
+
options: {
|
|
142
|
+
type: PropType<AnyObject[]>;
|
|
143
|
+
default: () => never[];
|
|
144
|
+
};
|
|
145
|
+
autograph: {
|
|
146
|
+
type: StringConstructor;
|
|
147
|
+
};
|
|
148
|
+
lazyRequest: {
|
|
149
|
+
type: BooleanConstructor;
|
|
150
|
+
default: boolean;
|
|
151
|
+
};
|
|
152
|
+
requestCache: {
|
|
153
|
+
type: BooleanConstructor;
|
|
154
|
+
default: boolean;
|
|
155
|
+
};
|
|
156
|
+
wordbook: {
|
|
157
|
+
type: PropType<Partial<{
|
|
158
|
+
level_num: number;
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
render_key: string[];
|
|
162
|
+
search_key: string[];
|
|
163
|
+
primary_key: string;
|
|
164
|
+
type: string;
|
|
165
|
+
value_key: string;
|
|
166
|
+
level_key: string;
|
|
167
|
+
link_key: string;
|
|
168
|
+
link_key_split: string;
|
|
169
|
+
show_key: string[];
|
|
170
|
+
conObj: AnyObject[];
|
|
171
|
+
conObjFirstLevel: AnyObject[];
|
|
172
|
+
}>>;
|
|
173
|
+
};
|
|
174
|
+
vertical: {
|
|
175
|
+
type: BooleanConstructor;
|
|
176
|
+
default: boolean;
|
|
177
|
+
};
|
|
178
|
+
onChange: {};
|
|
179
|
+
}>> & {
|
|
180
|
+
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
options: AnyObject[];
|
|
183
|
+
vertical: boolean;
|
|
184
|
+
lazyRequest: boolean;
|
|
185
|
+
requestCache: boolean;
|
|
186
|
+
}>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { defineComponent, createVNode, isVNode } from 'vue';
|
|
2
|
+
import { connect, mapProps } from '@formily/vue';
|
|
3
|
+
import { NSpace, NRadio, NRadioGroup, NCheckbox, NCheckboxGroup } from 'naive-ui';
|
|
4
|
+
import '../../../index.js';
|
|
5
|
+
import { useComplexOptions } from '../../hooks/useComplexOptions.js';
|
|
6
|
+
import '../../utils/index.js';
|
|
7
|
+
import { useAutographOptions } from '../../hooks/useFormRenderOptions.js';
|
|
8
|
+
import { useCommonInjection } from '../../hooks/useCommonInjection.js';
|
|
9
|
+
import { assignUpdateValue, createVisitedSetter } from '../../utils/schema.js';
|
|
10
|
+
import { useFormField } from '../../hooks/useFormField.js';
|
|
11
|
+
|
|
12
|
+
function _isSlot(s) {
|
|
13
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
14
|
+
}
|
|
15
|
+
function createComponent(name, Wrapper, Item) {
|
|
16
|
+
return defineComponent({
|
|
17
|
+
name,
|
|
18
|
+
props: {
|
|
19
|
+
value: {
|
|
20
|
+
type: [String, Number, Object]
|
|
21
|
+
},
|
|
22
|
+
options: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
autograph: {
|
|
27
|
+
type: String
|
|
28
|
+
},
|
|
29
|
+
lazyRequest: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
requestCache: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
wordbook: {
|
|
38
|
+
type: Object
|
|
39
|
+
},
|
|
40
|
+
vertical: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: false
|
|
43
|
+
},
|
|
44
|
+
onChange: {}
|
|
45
|
+
},
|
|
46
|
+
emits: ["update:value"],
|
|
47
|
+
setup(props, {
|
|
48
|
+
emit
|
|
49
|
+
}) {
|
|
50
|
+
const {
|
|
51
|
+
field
|
|
52
|
+
} = useFormField();
|
|
53
|
+
const {
|
|
54
|
+
renderComplexOption,
|
|
55
|
+
checkValueRef,
|
|
56
|
+
valueRef
|
|
57
|
+
} = useComplexOptions(props, emit);
|
|
58
|
+
const {
|
|
59
|
+
labelKey,
|
|
60
|
+
valueKey,
|
|
61
|
+
options
|
|
62
|
+
} = useAutographOptions(props, valueRef);
|
|
63
|
+
const {
|
|
64
|
+
injectValueBindKey,
|
|
65
|
+
injectValueValidate
|
|
66
|
+
} = useCommonInjection();
|
|
67
|
+
injectValueValidate(valueRef);
|
|
68
|
+
const key = injectValueBindKey(valueRef);
|
|
69
|
+
return () => {
|
|
70
|
+
return createVNode(Wrapper, {
|
|
71
|
+
"key": key.value,
|
|
72
|
+
"value": valueRef.value,
|
|
73
|
+
"onUpdate:value": ($event) => valueRef.value = $event,
|
|
74
|
+
"onClick": createVisitedSetter(field)
|
|
75
|
+
}, {
|
|
76
|
+
default: () => [createVNode(NSpace, {
|
|
77
|
+
"vertical": props.vertical,
|
|
78
|
+
"vertical-space": props.vertical
|
|
79
|
+
}, {
|
|
80
|
+
default: () => {
|
|
81
|
+
var _a;
|
|
82
|
+
return [(_a = options.value) == null ? void 0 : _a.map((option) => {
|
|
83
|
+
let _slot;
|
|
84
|
+
return createVNode(Item, {
|
|
85
|
+
"key": option[valueKey.value],
|
|
86
|
+
"value": option[valueKey.value],
|
|
87
|
+
"disabled": option.disabled
|
|
88
|
+
}, _isSlot(_slot = renderComplexOption({
|
|
89
|
+
value: checkValueRef.value,
|
|
90
|
+
option,
|
|
91
|
+
valueKey: valueKey.value,
|
|
92
|
+
labelKey: labelKey.value
|
|
93
|
+
})) ? _slot : {
|
|
94
|
+
default: () => [_slot]
|
|
95
|
+
});
|
|
96
|
+
})];
|
|
97
|
+
}
|
|
98
|
+
})]
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const RADIO = connect(createComponent("FormRadio", NRadioGroup, NRadio), mapProps({
|
|
105
|
+
dataSource: "options"
|
|
106
|
+
}, assignUpdateValue));
|
|
107
|
+
const CHECKBOX = connect(createComponent("FormCheckbox", NCheckboxGroup, NCheckbox), mapProps({
|
|
108
|
+
dataSource: "options"
|
|
109
|
+
}, assignUpdateValue));
|
|
110
|
+
|
|
111
|
+
export { CHECKBOX, RADIO };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AnyObject, Func } from '../../../../../es/shared/types';
|
|
2
|
+
import { Path } from '@formily/path';
|
|
3
|
+
import { FieldItem, FormOptionItem } from '../../../../../es/components/form-render';
|
|
4
|
+
declare function setSpan(uuid: string, address: Path | string, span?: number): void;
|
|
5
|
+
declare function getSpan(uuid: string, address: Path | string): number;
|
|
6
|
+
declare function deleteSpan(uuid: string, address: Path | string): void;
|
|
7
|
+
declare function clearSpan(uuid: string): void;
|
|
8
|
+
export declare function useComplexOptions(props: {
|
|
9
|
+
options: AnyObject[];
|
|
10
|
+
value: unknown;
|
|
11
|
+
}, emit: Func): {
|
|
12
|
+
renderComplexOption: ({ value, option, valueKey, labelKey }: {
|
|
13
|
+
value: unknown;
|
|
14
|
+
option: FormOptionItem;
|
|
15
|
+
valueKey: string;
|
|
16
|
+
labelKey: string;
|
|
17
|
+
}) => any[];
|
|
18
|
+
valueRef: import("vue").WritableComputedRef<unknown>;
|
|
19
|
+
hasComplexOption: import("vue").ComputedRef<boolean>;
|
|
20
|
+
checkValueRef: import("vue").Ref<any>;
|
|
21
|
+
};
|
|
22
|
+
export declare function useComplexOptionsSpan(): {
|
|
23
|
+
getSpan: typeof getSpan;
|
|
24
|
+
setSpan: typeof setSpan;
|
|
25
|
+
deleteSpan: typeof deleteSpan;
|
|
26
|
+
clearSpan: typeof clearSpan;
|
|
27
|
+
};
|
|
28
|
+
export declare function useComplexOptionsKey(): {
|
|
29
|
+
combineComplexOptionKey: (fieldList: FieldItem[], values: AnyObject) => AnyObject;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { reactive, defineComponent, inject, computed, watch, onUnmounted, onMounted, createVNode, withModifiers, ref } from 'vue';
|
|
2
|
+
import { checkInSetupEnv, jsonParse } from '../../../../shared/utils/index.js';
|
|
3
|
+
import { RecursionField } from '@formily/vue';
|
|
4
|
+
import { sumBy, property, noop, isObject, isArray, isString, cloneDeep, isNumber } from 'lodash-es';
|
|
5
|
+
import '../../index.js';
|
|
6
|
+
import { InjectionFormUUID, InjectionBusinessCollector } from '../constants/index.js';
|
|
7
|
+
import { useFormField } from './useFormField.js';
|
|
8
|
+
import { useFieldListAdaptor } from './useFieldListAdaptor.js';
|
|
9
|
+
import { createObjSchema } from '../utils/schema.js';
|
|
10
|
+
|
|
11
|
+
const spanMap = reactive(/* @__PURE__ */ new Map());
|
|
12
|
+
function setSpan(uuid, address, span = 0) {
|
|
13
|
+
spanMap.set(uuid, spanMap.get(uuid) || {});
|
|
14
|
+
const spanObj = spanMap.get(uuid);
|
|
15
|
+
spanObj[address + ""] = span;
|
|
16
|
+
}
|
|
17
|
+
function getSpan(uuid, address) {
|
|
18
|
+
const spanObj = spanMap.get(uuid);
|
|
19
|
+
if (!spanObj)
|
|
20
|
+
return 0;
|
|
21
|
+
return Object.entries(spanObj).reduce((res, [k, v]) => {
|
|
22
|
+
if (k === address + "" || k.startsWith(`${address}.`))
|
|
23
|
+
return res + v;
|
|
24
|
+
return res;
|
|
25
|
+
}, 0);
|
|
26
|
+
}
|
|
27
|
+
function deleteSpan(uuid, address) {
|
|
28
|
+
const spanObj = spanMap.get(uuid);
|
|
29
|
+
spanObj && Reflect.deleteProperty(spanObj, address + "");
|
|
30
|
+
}
|
|
31
|
+
function clearSpan(uuid) {
|
|
32
|
+
spanMap.delete(uuid);
|
|
33
|
+
}
|
|
34
|
+
const ChildSchemaField = defineComponent({
|
|
35
|
+
props: {
|
|
36
|
+
fields: {
|
|
37
|
+
type: Array,
|
|
38
|
+
default: () => []
|
|
39
|
+
},
|
|
40
|
+
name: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
setup(props) {
|
|
46
|
+
const uuid = inject(InjectionFormUUID);
|
|
47
|
+
const {
|
|
48
|
+
field
|
|
49
|
+
} = useFormField();
|
|
50
|
+
const collector = inject(InjectionBusinessCollector);
|
|
51
|
+
const {
|
|
52
|
+
schemaAdaptor
|
|
53
|
+
} = useFieldListAdaptor(collector);
|
|
54
|
+
function assignConfig(schema2) {
|
|
55
|
+
return Object.assign(schema2, {
|
|
56
|
+
["x-decorator-props"]: {
|
|
57
|
+
...schema2["x-decorator-props"],
|
|
58
|
+
labelPlacement: "left",
|
|
59
|
+
showFeedback: false,
|
|
60
|
+
showLabel: !!schema2.title
|
|
61
|
+
},
|
|
62
|
+
["x-component-props"]: {
|
|
63
|
+
...schema2["x-component-props"],
|
|
64
|
+
size: "small"
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const schema = computed(() => {
|
|
69
|
+
const schemaProperty = schemaAdaptor(props.fields);
|
|
70
|
+
Object.values(schemaProperty).forEach(assignConfig);
|
|
71
|
+
return createObjSchema(schemaProperty);
|
|
72
|
+
});
|
|
73
|
+
const column = computed(() => {
|
|
74
|
+
return sumBy(Object.values(schema.value.properties || []), property("x-decorator-props.span"));
|
|
75
|
+
});
|
|
76
|
+
const fieldKey = computed(() => `${field.value.address.toString()}.${props.name}`);
|
|
77
|
+
watch(column, (_column) => {
|
|
78
|
+
setSpan(uuid, fieldKey.value, _column);
|
|
79
|
+
}, {
|
|
80
|
+
immediate: true
|
|
81
|
+
});
|
|
82
|
+
function getRecursionField() {
|
|
83
|
+
const formModel = field.value.form;
|
|
84
|
+
return formModel.query(fieldKey.value).take();
|
|
85
|
+
}
|
|
86
|
+
onUnmounted(() => {
|
|
87
|
+
const recursionField = getRecursionField();
|
|
88
|
+
recursionField && (recursionField.display = "none");
|
|
89
|
+
deleteSpan(uuid, fieldKey.value);
|
|
90
|
+
});
|
|
91
|
+
onMounted(() => {
|
|
92
|
+
const recursionField = getRecursionField();
|
|
93
|
+
if (!recursionField)
|
|
94
|
+
return;
|
|
95
|
+
recursionField.display = "visible";
|
|
96
|
+
});
|
|
97
|
+
return () => createVNode("section", {
|
|
98
|
+
"onClick": withModifiers(noop, ["stop"]),
|
|
99
|
+
"class": "form-render__labelField",
|
|
100
|
+
"style": {
|
|
101
|
+
"--column": getSpan(uuid, fieldKey.value)
|
|
102
|
+
}
|
|
103
|
+
}, [createVNode(RecursionField, {
|
|
104
|
+
"name": props.name,
|
|
105
|
+
"schema": schema.value
|
|
106
|
+
}, null)]);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
function isComplexOption(options) {
|
|
110
|
+
return options.some((option) => {
|
|
111
|
+
return isArray(option.childrenFields) && option.childrenFields.length;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function useComplexOptions(props, emit) {
|
|
115
|
+
checkInSetupEnv();
|
|
116
|
+
const {
|
|
117
|
+
fieldKey
|
|
118
|
+
} = useFormField();
|
|
119
|
+
const hasComplexOption = computed(() => isComplexOption(props.options));
|
|
120
|
+
function dangerousTypeTransform(value) {
|
|
121
|
+
if (isNumber(value))
|
|
122
|
+
return value + "";
|
|
123
|
+
return value;
|
|
124
|
+
}
|
|
125
|
+
const checkValueRef = ref();
|
|
126
|
+
const valueRef = computed({
|
|
127
|
+
get() {
|
|
128
|
+
return dangerousTypeTransform(hasComplexOption.value ? checkValueRef.value : props.value);
|
|
129
|
+
},
|
|
130
|
+
set(value) {
|
|
131
|
+
if (!hasComplexOption.value)
|
|
132
|
+
return emit("update:value", value);
|
|
133
|
+
if (!isObject(props.value))
|
|
134
|
+
return;
|
|
135
|
+
props.value[fieldKey.value] = value;
|
|
136
|
+
checkValueRef.value = value;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
watch(checkValueRef, () => {
|
|
140
|
+
if (!hasComplexOption.value || !isObject(props.value))
|
|
141
|
+
return;
|
|
142
|
+
props.value[fieldKey.value] = checkValueRef.value;
|
|
143
|
+
});
|
|
144
|
+
watch([() => props.value, hasComplexOption], ([v, _has]) => {
|
|
145
|
+
if (!_has)
|
|
146
|
+
return;
|
|
147
|
+
if (isArray(v)) {
|
|
148
|
+
checkValueRef.value = v;
|
|
149
|
+
return emit("update:value", {
|
|
150
|
+
[fieldKey.value]: v
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (isString(v)) {
|
|
154
|
+
if (v.startsWith("{")) {
|
|
155
|
+
const result = cloneDeep(jsonParse(v));
|
|
156
|
+
checkValueRef.value = result[fieldKey.value];
|
|
157
|
+
return emit("update:value", result);
|
|
158
|
+
}
|
|
159
|
+
checkValueRef.value = v;
|
|
160
|
+
return emit("update:value", {
|
|
161
|
+
[fieldKey.value]: v
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (!isObject(v)) {
|
|
165
|
+
checkValueRef.value = void 0;
|
|
166
|
+
emit("update:value", {});
|
|
167
|
+
} else {
|
|
168
|
+
checkValueRef.value = v[fieldKey.value];
|
|
169
|
+
}
|
|
170
|
+
}, {
|
|
171
|
+
immediate: true
|
|
172
|
+
});
|
|
173
|
+
function valueMatcher(value, option, valueKey = "value") {
|
|
174
|
+
if (isArray(value) ? !value.includes(option[valueKey]) : value !== option[valueKey])
|
|
175
|
+
return;
|
|
176
|
+
return isArray(option.childrenFields) && option.childrenFields.length;
|
|
177
|
+
}
|
|
178
|
+
function renderComplexOption({
|
|
179
|
+
value,
|
|
180
|
+
option,
|
|
181
|
+
valueKey = "value",
|
|
182
|
+
labelKey = "label"
|
|
183
|
+
}) {
|
|
184
|
+
return [option[labelKey], hasComplexOption.value && valueMatcher(value, option, valueKey) ? createVNode(ChildSchemaField, {
|
|
185
|
+
"fields": option.childrenFields,
|
|
186
|
+
"name": option[valueKey]
|
|
187
|
+
}, null) : null];
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
renderComplexOption,
|
|
191
|
+
valueRef,
|
|
192
|
+
hasComplexOption,
|
|
193
|
+
checkValueRef
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function useComplexOptionsSpan() {
|
|
197
|
+
return {
|
|
198
|
+
getSpan,
|
|
199
|
+
setSpan,
|
|
200
|
+
deleteSpan,
|
|
201
|
+
clearSpan
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function useComplexOptionsKey() {
|
|
205
|
+
function combineComplexOptionKey(fieldList, values) {
|
|
206
|
+
const fieldMap = fieldList.reduce((res, field) => {
|
|
207
|
+
res[field.val_key] = field;
|
|
208
|
+
return res;
|
|
209
|
+
}, {});
|
|
210
|
+
return Object.entries(values).reduce((res, [k, v]) => {
|
|
211
|
+
const field = fieldMap[k];
|
|
212
|
+
if (isArray(field.option) && isComplexOption(field.option)) {
|
|
213
|
+
res[k] = JSON.stringify(v);
|
|
214
|
+
} else {
|
|
215
|
+
res[k] = v;
|
|
216
|
+
}
|
|
217
|
+
return res;
|
|
218
|
+
}, {});
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
combineComplexOptionKey
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export { useComplexOptions, useComplexOptionsKey, useComplexOptionsSpan };
|
|
@@ -49,7 +49,7 @@ function useFieldListAdaptor(collector) {
|
|
|
49
49
|
"x-decorator": "FORM_ITEM",
|
|
50
50
|
"x-decorator-props": {
|
|
51
51
|
fieldItem: deepOmit(item, ["reactions"]),
|
|
52
|
-
span: item.elem_width,
|
|
52
|
+
span: (item.elem_width || 3) * 2,
|
|
53
53
|
showLabel: item.hide_title !== "1",
|
|
54
54
|
remark: item.remark,
|
|
55
55
|
propertyKey: item.val_key,
|
|
@@ -77,18 +77,15 @@ function useFieldListAdaptor(collector) {
|
|
|
77
77
|
} else if (item.autograph) {
|
|
78
78
|
bindAutoGraphProps(schema, item);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
const multiple = item.multi_select === "0";
|
|
81
|
+
Object.assign(schema["x-component-props"], {
|
|
82
|
+
multiple,
|
|
83
|
+
options: item.option,
|
|
84
|
+
maxTagCount: parseNumberFromMaybeString(item.multi_select_value),
|
|
85
|
+
...pick(item, ["lazyRequest", "requestCache"])
|
|
86
|
+
});
|
|
87
|
+
multiple && (schema.type = "array");
|
|
81
88
|
return schema;
|
|
82
|
-
function bindCommonProps(schema2, item2) {
|
|
83
|
-
const multiple = item2.multi_select === "0";
|
|
84
|
-
Object.assign(schema2["x-component-props"], {
|
|
85
|
-
multiple,
|
|
86
|
-
options: item2.option,
|
|
87
|
-
maxTagCount: parseNumberFromMaybeString(item2.multi_select_value),
|
|
88
|
-
...pick(item2, ["lazyRequest", "requestCache"])
|
|
89
|
-
});
|
|
90
|
-
multiple && (schema2.type = "array");
|
|
91
|
-
}
|
|
92
89
|
};
|
|
93
90
|
const createRadioSchema = (item) => {
|
|
94
91
|
const schema = createStandardSchema(item);
|
|
@@ -255,7 +252,7 @@ function useFieldListAdaptor(collector) {
|
|
|
255
252
|
name: fieldKeyEscape(fieldList),
|
|
256
253
|
title: item.alias || item.name,
|
|
257
254
|
"x-component": "INPUT_GROUP",
|
|
258
|
-
"x-component-props": { span: item.elem_width },
|
|
255
|
+
"x-component-props": { span: (item.elem_width || 3) * 2 },
|
|
259
256
|
properties: schemaAdaptor(fieldList)
|
|
260
257
|
};
|
|
261
258
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AnyObject } from '../../../../../es/shared/types';
|
|
2
|
+
import { Form, IFieldState } from '@formily/core';
|
|
3
|
+
import { Ref } from 'vue';
|
|
4
|
+
import { FieldItem, FormItemDepsCollector, FormRenderProps } from '../../../../../es/components/form-render';
|
|
5
|
+
export declare function useFormExposeEvent({ formModel, formRenderRef, formUUID, getFieldList, formItemDepsCollector }: {
|
|
6
|
+
formModel: Form;
|
|
7
|
+
formRenderRef: Ref<HTMLElement | undefined>;
|
|
8
|
+
formUUID: string;
|
|
9
|
+
getFieldList: () => FieldItem[];
|
|
10
|
+
formItemDepsCollector: FormItemDepsCollector;
|
|
11
|
+
}): {
|
|
12
|
+
validate(path?: string): Promise<void>;
|
|
13
|
+
getFormValues(needCombineExtendKey?: boolean, needCombineOptionKey?: boolean): any;
|
|
14
|
+
setFormValues(values: AnyObject, needSplitExtendKey?: boolean): void;
|
|
15
|
+
setFieldState(path: string, handler: (field: IFieldState) => void): void;
|
|
16
|
+
resetFields(path?: string): Promise<void>;
|
|
17
|
+
queryWidget(key: string): Promise<{
|
|
18
|
+
widgetElement: HTMLInputElement | null | undefined;
|
|
19
|
+
widgetElementList: HTMLInputElement[];
|
|
20
|
+
decoratorElement: HTMLElement | null | undefined;
|
|
21
|
+
} | null>;
|
|
22
|
+
};
|
|
23
|
+
export declare function useFormDomEvent({ props, formRenderRef, formModel }: {
|
|
24
|
+
props: FormRenderProps;
|
|
25
|
+
formRenderRef: Ref<HTMLElement | undefined>;
|
|
26
|
+
formModel: Form;
|
|
27
|
+
}): {
|
|
28
|
+
onKeydown: (event: KeyboardEvent) => void;
|
|
29
|
+
};
|