cnhis-design-vue 3.1.13-beta.0 → 3.1.13-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/fabric-chart/src/hooks/useShadow.js +1 -1
- package/es/packages/form-render/src/components/renderer/cascader.d.ts +7 -1
- package/es/packages/form-render/src/components/renderer/cascader.js +65 -53
- package/es/packages/form-render/src/components/renderer/select.d.ts +7 -5
- package/es/packages/form-render/src/components/renderer/select.js +35 -40
- package/package.json +1 -1
|
@@ -101,7 +101,7 @@ function useShadow() {
|
|
|
101
101
|
let counter = 0;
|
|
102
102
|
let xinters;
|
|
103
103
|
let p1, p2;
|
|
104
|
-
|
|
104
|
+
const pointCount = polygonPoints.length;
|
|
105
105
|
p1 = polygonPoints[0];
|
|
106
106
|
for (let i = 1; i <= pointCount; i++) {
|
|
107
107
|
p2 = polygonPoints[i % pointCount];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyObject, ArrayAble } from '../../../../../../es/src/types';
|
|
1
|
+
import { AnyObject, ArrayAble, Func } from '../../../../../../es/src/types';
|
|
2
2
|
import { FormRequestType } from '../../types';
|
|
3
3
|
import { PropType } from 'vue';
|
|
4
4
|
declare type DependKeyObj = {
|
|
@@ -24,6 +24,9 @@ export declare const SEARCH_CASCADE: import("vue").DefineComponent<{
|
|
|
24
24
|
urlConfig: {
|
|
25
25
|
type: PropType<UrlConfig>;
|
|
26
26
|
};
|
|
27
|
+
onFocus: {
|
|
28
|
+
type: PropType<Func<any[], any>>;
|
|
29
|
+
};
|
|
27
30
|
onChange: {};
|
|
28
31
|
value: {};
|
|
29
32
|
}, () => 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<{
|
|
@@ -38,6 +41,9 @@ export declare const SEARCH_CASCADE: import("vue").DefineComponent<{
|
|
|
38
41
|
urlConfig: {
|
|
39
42
|
type: PropType<UrlConfig>;
|
|
40
43
|
};
|
|
44
|
+
onFocus: {
|
|
45
|
+
type: PropType<Func<any[], any>>;
|
|
46
|
+
};
|
|
41
47
|
onChange: {};
|
|
42
48
|
value: {};
|
|
43
49
|
}>> & {
|
|
@@ -21,6 +21,9 @@ const script = defineComponent({
|
|
|
21
21
|
urlConfig: {
|
|
22
22
|
type: Object
|
|
23
23
|
},
|
|
24
|
+
onFocus: {
|
|
25
|
+
type: Function
|
|
26
|
+
},
|
|
24
27
|
onChange: {},
|
|
25
28
|
value: {}
|
|
26
29
|
},
|
|
@@ -30,15 +33,12 @@ const script = defineComponent({
|
|
|
30
33
|
emit
|
|
31
34
|
}) {
|
|
32
35
|
const _options = ref(null);
|
|
33
|
-
const {
|
|
34
|
-
title
|
|
35
|
-
} = useFormField();
|
|
36
36
|
const asyncQueue = inject(InjectAsyncQueue);
|
|
37
37
|
const {
|
|
38
|
-
field
|
|
38
|
+
field,
|
|
39
|
+
title
|
|
39
40
|
} = useFormField();
|
|
40
41
|
async function fetchData(option) {
|
|
41
|
-
var _a;
|
|
42
42
|
if (!option && _options.value)
|
|
43
43
|
return;
|
|
44
44
|
const config = props.urlConfig;
|
|
@@ -48,56 +48,63 @@ const script = defineComponent({
|
|
|
48
48
|
formRenderLog(`invalid urlConfig (${config}) in CASCADER => ${title.value}`, "warn");
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
if ((option
|
|
51
|
+
if (deepFor(option) + 1 >= props.deep)
|
|
52
52
|
return;
|
|
53
|
-
const parentDepth = (_a = option == null ? void 0 : option.depth) != null ? _a : -1;
|
|
54
|
-
const params = {
|
|
55
|
-
lvlnr: parentDepth + 1 + ""
|
|
56
|
-
};
|
|
57
|
-
if (option) {
|
|
58
|
-
if (!config.dependKey) {
|
|
59
|
-
formRenderLog(`invalid urlConfig.dependKey ${config.dependKey} in CASCADER => ${title.value}`, "warn");
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
arrayed(config.dependKey).forEach((key) => {
|
|
63
|
-
if (isString(key)) {
|
|
64
|
-
params[key] = option[valueKey.value];
|
|
65
|
-
} else if (isObject(key)) {
|
|
66
|
-
params[key.paramName] = option[key.paramValue];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
53
|
let data = await asyncQueue.addAsync({
|
|
71
|
-
...config,
|
|
72
|
-
key: title.value
|
|
73
|
-
params
|
|
54
|
+
...createRequestParams(deepFor(option), config, option),
|
|
55
|
+
key: title.value
|
|
74
56
|
});
|
|
75
57
|
if (!Array.isArray(data)) {
|
|
76
58
|
data = [];
|
|
77
59
|
}
|
|
78
60
|
if (!data.length && isObject(option)) {
|
|
79
61
|
option.isLeaf = true;
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
updateValue(null, null, getOptionChain(option));
|
|
63
|
+
show.value = false;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const result = data.map((item) => optionNormalize(item, deepFor(option)));
|
|
67
|
+
option ? option.children = result : _options.value = result;
|
|
68
|
+
function deepFor(option2) {
|
|
69
|
+
var _a;
|
|
70
|
+
return (_a = option2 == null ? void 0 : option2.depth) != null ? _a : -1;
|
|
71
|
+
}
|
|
72
|
+
function createRequestParams(deep, config2, option2) {
|
|
73
|
+
const params = {
|
|
74
|
+
lvlnr: deep + 1 + ""
|
|
75
|
+
};
|
|
76
|
+
if (option2 && config2.dependKey) {
|
|
77
|
+
arrayed(config2.dependKey).forEach((key) => {
|
|
78
|
+
if (isString(key)) {
|
|
79
|
+
params[key] = option2[valueKey.value];
|
|
80
|
+
} else if (isObject(key)) {
|
|
81
|
+
params[key.paramName] = option2[key.paramValue];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
params,
|
|
87
|
+
...config2
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function getOptionChain(option2) {
|
|
91
|
+
let currentOption = option2;
|
|
92
|
+
const result2 = [option2];
|
|
82
93
|
while (currentOption.parent) {
|
|
83
94
|
result2.unshift(currentOption.parent);
|
|
84
95
|
currentOption = currentOption.parent;
|
|
85
96
|
}
|
|
86
|
-
|
|
87
|
-
show.value = false;
|
|
88
|
-
return;
|
|
97
|
+
return result2;
|
|
89
98
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
[labelKey.value]:
|
|
93
|
-
[valueKey.value]:
|
|
94
|
-
depth:
|
|
99
|
+
function optionNormalize(data2, deep) {
|
|
100
|
+
return {
|
|
101
|
+
[labelKey.value]: data2[labelKey.value],
|
|
102
|
+
[valueKey.value]: data2[valueKey.value],
|
|
103
|
+
depth: deep + 1,
|
|
95
104
|
parent: option,
|
|
96
|
-
isLeaf:
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
}, []);
|
|
100
|
-
option ? option.children = result : _options.value = result;
|
|
105
|
+
isLeaf: deep + 2 >= props.deep
|
|
106
|
+
};
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
109
|
const renderOptions = computed(() => {
|
|
103
110
|
return _options.value || props.options || [];
|
|
@@ -134,23 +141,28 @@ const script = defineComponent({
|
|
|
134
141
|
}
|
|
135
142
|
});
|
|
136
143
|
function updateValue(_, __, options) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
emit("update:value", options.map(optionSimplify));
|
|
145
|
+
function optionSimplify(option) {
|
|
146
|
+
return {
|
|
147
|
+
...option,
|
|
148
|
+
label: option[labelKey.value],
|
|
149
|
+
children: void 0,
|
|
150
|
+
parent: void 0
|
|
151
|
+
};
|
|
152
|
+
}
|
|
144
153
|
}
|
|
145
154
|
const show = ref(false);
|
|
146
155
|
function updateShow(v) {
|
|
147
156
|
show.value = !!v;
|
|
148
157
|
v && fetchData();
|
|
149
158
|
}
|
|
150
|
-
function onFocus
|
|
151
|
-
|
|
152
|
-
field.value
|
|
153
|
-
|
|
159
|
+
function focusDecorator(onFocus) {
|
|
160
|
+
return (...args) => {
|
|
161
|
+
if (isField(field.value)) {
|
|
162
|
+
field.value.visited = true;
|
|
163
|
+
}
|
|
164
|
+
onFocus == null ? void 0 : onFocus(...args);
|
|
165
|
+
};
|
|
154
166
|
}
|
|
155
167
|
return () => {
|
|
156
168
|
return createVNode(NCascader, {
|
|
@@ -163,7 +175,7 @@ const script = defineComponent({
|
|
|
163
175
|
"options": renderOptions.value,
|
|
164
176
|
"checkStrategy": "child",
|
|
165
177
|
"onLoad": fetchData,
|
|
166
|
-
"onFocus": onFocus,
|
|
178
|
+
"onFocus": focusDecorator(props.onFocus),
|
|
167
179
|
"onUpdate:show": updateShow
|
|
168
180
|
}, slots);
|
|
169
181
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyObject } from '../../../../../../es/src/types';
|
|
1
|
+
import { AnyObject, Func } from '../../../../../../es/src/types';
|
|
2
2
|
import { FormRequestType } from '../../types';
|
|
3
3
|
import { PropType } from 'vue';
|
|
4
4
|
declare type UrlConfig = {
|
|
@@ -20,9 +20,10 @@ export declare const SELECT: import("vue").DefineComponent<{
|
|
|
20
20
|
urlConfig: {
|
|
21
21
|
type: PropType<UrlConfig>;
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
type:
|
|
23
|
+
onFocus: {
|
|
24
|
+
type: PropType<Func<any[], any>>;
|
|
25
25
|
};
|
|
26
|
+
onChange: {};
|
|
26
27
|
}, () => 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<{
|
|
27
28
|
value: {
|
|
28
29
|
type: StringConstructor;
|
|
@@ -34,9 +35,10 @@ export declare const SELECT: import("vue").DefineComponent<{
|
|
|
34
35
|
urlConfig: {
|
|
35
36
|
type: PropType<UrlConfig>;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
type:
|
|
38
|
+
onFocus: {
|
|
39
|
+
type: PropType<Func<any[], any>>;
|
|
39
40
|
};
|
|
41
|
+
onChange: {};
|
|
40
42
|
}>> & {
|
|
41
43
|
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
42
44
|
}, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, ref, inject, computed, watch, createVNode } from 'vue';
|
|
1
|
+
import { defineComponent, ref, inject, computed, watch, nextTick, createVNode } from 'vue';
|
|
2
2
|
import { isField } from '@formily/core';
|
|
3
3
|
import { cloneDeep } from 'lodash-es';
|
|
4
4
|
import { InjectAsyncQueue, InjectionFormItemDepsCollector, InjectionChangeContextCollector } from '../../constants/index.js';
|
|
@@ -21,17 +21,17 @@ const script = defineComponent({
|
|
|
21
21
|
urlConfig: {
|
|
22
22
|
type: Object
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
onFocus: {
|
|
25
25
|
type: Function
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
onChange: {}
|
|
27
28
|
},
|
|
28
29
|
emits: ["update:value"],
|
|
29
30
|
setup(props, {
|
|
30
31
|
slots,
|
|
31
32
|
emit
|
|
32
33
|
}) {
|
|
33
|
-
const
|
|
34
|
-
let cachedOptions = null;
|
|
34
|
+
const remoteOptions = ref(null);
|
|
35
35
|
const lastSearch = ref("");
|
|
36
36
|
const asyncQueue = inject(InjectAsyncQueue);
|
|
37
37
|
const {
|
|
@@ -45,54 +45,46 @@ const script = defineComponent({
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
async function fetchData(content) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} else {
|
|
52
|
-
lastSearch.value = content || "";
|
|
53
|
-
}
|
|
48
|
+
lastSearch.value = content || "";
|
|
49
|
+
if (remoteOptions.value)
|
|
50
|
+
return;
|
|
54
51
|
const config = props.urlConfig;
|
|
55
52
|
if (!config) {
|
|
56
|
-
return
|
|
53
|
+
return remoteOptions.value = null;
|
|
57
54
|
}
|
|
58
55
|
if (!isObject(config)) {
|
|
59
56
|
formRenderLog(`invalid urlConfig (${config}) in SELECT => ${title.value}`, "warn");
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
if (cachedOptions) {
|
|
63
|
-
return _options.value = filterOption(cachedOptions, content);
|
|
57
|
+
return remoteOptions.value = null;
|
|
64
58
|
}
|
|
65
59
|
try {
|
|
66
|
-
|
|
67
|
-
...config,
|
|
68
|
-
key: title.value
|
|
69
|
-
params: Object.assign({}, config.params, generateUrlParams(field.value, config.dependKey))
|
|
60
|
+
remoteOptions.value = await asyncQueue.addAsync({
|
|
61
|
+
...createParams(config, field.value),
|
|
62
|
+
key: title.value
|
|
70
63
|
});
|
|
71
|
-
_options.value = data.reduce((res, d) => {
|
|
72
|
-
var _a;
|
|
73
|
-
if (((_a = d[labelKey.value]) == null ? void 0 : _a.includes(content)) || !content) {
|
|
74
|
-
res.push(d);
|
|
75
|
-
}
|
|
76
|
-
return res;
|
|
77
|
-
}, []);
|
|
78
|
-
cachedOptions = _options.value;
|
|
79
64
|
} catch (e) {
|
|
80
|
-
|
|
65
|
+
remoteOptions.value = null;
|
|
66
|
+
}
|
|
67
|
+
function createParams(config2, field2) {
|
|
68
|
+
return {
|
|
69
|
+
...config2,
|
|
70
|
+
params: Object.assign({}, config2.params, generateUrlParams(field2, config2.dependKey))
|
|
71
|
+
};
|
|
81
72
|
}
|
|
82
73
|
}
|
|
83
74
|
const parsedOptions = computed(() => {
|
|
84
|
-
if (
|
|
85
|
-
return
|
|
75
|
+
if (remoteOptions.value)
|
|
76
|
+
return filterOption(remoteOptions.value, lastSearch.value);
|
|
86
77
|
if (!Array.isArray(props.options))
|
|
87
78
|
return [];
|
|
88
79
|
return filterOption(props.options, lastSearch.value);
|
|
89
80
|
});
|
|
90
81
|
const formItemDepsCollector = inject(InjectionFormItemDepsCollector);
|
|
91
82
|
watch(() => props.urlConfig, (config) => {
|
|
92
|
-
|
|
93
|
-
config && formItemDepsCollector.setDeps(fieldKey.value, config.dependKey || [], () => {
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
remoteOptions.value = null;
|
|
84
|
+
config && formItemDepsCollector.setDeps(fieldKey.value, config.dependKey || [], async () => {
|
|
85
|
+
remoteOptions.value = null;
|
|
86
|
+
await nextTick();
|
|
87
|
+
props.value != null && await fetchData();
|
|
96
88
|
});
|
|
97
89
|
}, {
|
|
98
90
|
immediate: true
|
|
@@ -121,10 +113,13 @@ const script = defineComponent({
|
|
|
121
113
|
var _a, _b;
|
|
122
114
|
return (_b = (_a = props.urlConfig) == null ? void 0 : _a.valueKey) != null ? _b : "value";
|
|
123
115
|
});
|
|
124
|
-
function onFocus
|
|
125
|
-
|
|
126
|
-
field.value
|
|
127
|
-
|
|
116
|
+
function focusDecorator(onFocus) {
|
|
117
|
+
return (...args) => {
|
|
118
|
+
if (isField(field.value)) {
|
|
119
|
+
field.value.visited = true;
|
|
120
|
+
}
|
|
121
|
+
return onFocus == null ? void 0 : onFocus(...args);
|
|
122
|
+
};
|
|
128
123
|
}
|
|
129
124
|
return () => createVNode(NSelect, {
|
|
130
125
|
"value": props.value,
|
|
@@ -135,7 +130,7 @@ const script = defineComponent({
|
|
|
135
130
|
"valueField": valueKey.value,
|
|
136
131
|
"onSearch": fetchData,
|
|
137
132
|
"onUpdate:show": (show) => show && fetchData(),
|
|
138
|
-
"onFocus": onFocus,
|
|
133
|
+
"onFocus": focusDecorator(props.onFocus),
|
|
139
134
|
"options": parsedOptions.value
|
|
140
135
|
}, slots);
|
|
141
136
|
}
|