cnhis-design-vue 3.1.32 → 3.1.33-beta.0
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/form-render/index.js +1 -1
- package/es/components/form-render/src/FormRender.vue.js +1 -0
- package/es/components/form-render/src/components/renderer/checkbox.js +1 -1
- package/es/components/form-render/src/components/renderer/index.js +0 -6
- package/es/components/form-render/src/components/renderer/radio.js +1 -1
- package/es/components/form-render/src/components/renderer/searchCascade.d.ts +1 -1
- package/es/components/form-render/src/components/renderer/searchCascade.js +3 -2
- package/es/components/form-render/src/components/renderer/select.d.ts +97 -7
- package/es/components/form-render/src/components/renderer/select.js +64 -61
- package/es/components/form-render/src/hooks/index.d.ts +1 -1
- package/es/components/form-render/src/hooks/index.js +1 -1
- package/es/components/form-render/src/hooks/useBusinessBinding.d.ts +3 -3
- package/es/components/form-render/src/hooks/useBusinessBinding.js +15 -9
- package/es/components/form-render/src/hooks/useFieldListAdaptor.js +2 -10
- package/es/components/form-render/src/hooks/useFieldNormalize.js +2 -1
- package/es/components/form-render/src/hooks/useFormRenderOptions.d.ts +41 -0
- package/es/components/form-render/src/hooks/useFormRenderOptions.js +230 -0
- package/es/components/index.d.ts +1 -0
- package/es/components/index.js +2 -1
- package/es/components/insurance-sdk/index.d.ts +1 -0
- package/es/components/insurance-sdk/index.js +1 -0
- package/es/components/insurance-sdk/src/constants/index.d.ts +161 -0
- package/es/components/insurance-sdk/src/constants/index.js +160 -0
- package/es/components/insurance-sdk/src/utils/index.d.ts +1 -0
- package/es/components/insurance-sdk/src/utils/index.js +1 -0
- package/es/components/insurance-sdk/src/utils/insurance.d.ts +260 -0
- package/es/components/insurance-sdk/src/utils/insurance.js +268 -0
- package/es/components/recommend-search/index.d.ts +1 -1
- package/es/components/recommend-search/src/RecommendSearch.vue.d.ts +1 -1
- package/es/components/recommend-search/src/components/BaseSearch.vue.js +5 -5
- package/es/components/recommend-search/src/components/RecommendInput.vue.d.ts +1 -0
- package/es/components/recommend-search/src/components/RecommendInput.vue.js +6 -0
- package/es/components/recommend-search/src/components/RecommendMenu.vue.js +12 -12
- package/es/components/recommend-search/src/components/RecommendSelect.vue.d.ts +0 -1
- package/es/components/recommend-search/src/components/RecommendSelect.vue.js +2 -11
- package/es/shared/utils/index.d.ts +1 -0
- package/es/shared/utils/index.js +11 -1
- package/package.json +2 -2
- package/es/components/form-render/src/components/renderer/labelSelect.d.ts +0 -1
- package/es/components/form-render/src/components/renderer/labelSelect.js +0 -18
- package/es/components/form-render/src/components/renderer/recommendSelect.d.ts +0 -131
- package/es/components/form-render/src/components/renderer/recommendSelect.js +0 -213
- package/es/components/form-render/src/components/renderer/search.d.ts +0 -86
- package/es/components/form-render/src/components/renderer/search.js +0 -112
- package/es/components/form-render/src/hooks/useAutographOptions.d.ts +0 -17
- package/es/components/form-render/src/hooks/useAutographOptions.js +0 -68
|
@@ -13,9 +13,9 @@ export { BusinessCollector, useBusinessBinding } from './src/hooks/useBusinessBi
|
|
|
13
13
|
export { ContextCollector, useChangeContext } from './src/hooks/useChangeContext.js';
|
|
14
14
|
export { FormItemDepsCollector, useFormItemDeps } from './src/hooks/useFormItemDeps.js';
|
|
15
15
|
export { useAnchor } from './src/hooks/useAnchor.js';
|
|
16
|
-
export { useAutographOptions } from './src/hooks/useAutographOptions.js';
|
|
17
16
|
export { useFormContext } from './src/hooks/useFormContext.js';
|
|
18
17
|
export { useCommonInjection, useSelectOptionProps } from './src/hooks/useCommonInjection.js';
|
|
18
|
+
export { useAutographOptions, useRecommendOptions, useUrlConfigOptions } from './src/hooks/useFormRenderOptions.js';
|
|
19
19
|
export { combineExtendKey, createInputSlot, createSlot, createUrlConfigParams, formRenderLog, injectOrProvide, isNestedFieldType, isNestedType, mergeDeepProperties, optionMatcherWithKeyword, parseNumberFromMaybeString, presetRequestHandler, splitExtendKey, validateMessageParser } from './src/utils/index.js';
|
|
20
20
|
export * from '@formily/core';
|
|
21
21
|
export { businessDateParser, isIdCard, isMobile, parseAge2Birthday, parseAge2FromContext, parseBirthday, parseIdCard, transformDateFormat } from './src/utils/business.js';
|
|
@@ -25,6 +25,7 @@ import '../../../shared/utils/tapable/AsyncSeriesLoopHook.js';
|
|
|
25
25
|
import '../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js';
|
|
26
26
|
import { validateMessageLocale } from './hooks/useFormValidator.js';
|
|
27
27
|
import '@vueuse/core';
|
|
28
|
+
import 'date-fns';
|
|
28
29
|
import { useAnchor } from './hooks/useAnchor.js';
|
|
29
30
|
import { useFormContext } from './hooks/useFormContext.js';
|
|
30
31
|
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.js';
|
|
@@ -4,7 +4,7 @@ import '../../../index.js';
|
|
|
4
4
|
import '../../utils/index.js';
|
|
5
5
|
import { connect, mapProps } from '@formily/vue';
|
|
6
6
|
import { NCheckboxGroup, NSpace, NCheckbox } from 'naive-ui';
|
|
7
|
-
import { useAutographOptions } from '../../hooks/
|
|
7
|
+
import { useAutographOptions } from '../../hooks/useFormRenderOptions.js';
|
|
8
8
|
import { assignUpdateValue } from '../../utils/schema.js';
|
|
9
9
|
import { useCommonInjection } from '../../hooks/useCommonInjection.js';
|
|
10
10
|
|
|
@@ -7,13 +7,10 @@ import * as input from './input.js';
|
|
|
7
7
|
import * as inputGroup from './inputGroup.js';
|
|
8
8
|
import * as inputNumber from './inputNumber.js';
|
|
9
9
|
import * as index from './jsonCombination/index.js';
|
|
10
|
-
import * as labelSelect from './labelSelect.js';
|
|
11
10
|
import * as levelSearchCascader from './levelSearchCascader.js';
|
|
12
11
|
import * as index$1 from './lineBar/index.js';
|
|
13
12
|
import * as radio from './radio.js';
|
|
14
|
-
import * as recommendSelect from './recommendSelect.js';
|
|
15
13
|
import * as remoteSearch from './remoteSearch.js';
|
|
16
|
-
import * as search from './search.js';
|
|
17
14
|
import * as searchCascade from './searchCascade.js';
|
|
18
15
|
import * as select from './select.js';
|
|
19
16
|
import * as simpleComponent from './simpleComponent.js';
|
|
@@ -32,13 +29,10 @@ const modules = Object.assign({
|
|
|
32
29
|
"./inputGroup.ts": inputGroup,
|
|
33
30
|
"./inputNumber.tsx": inputNumber,
|
|
34
31
|
"./jsonCombination/index.tsx": index,
|
|
35
|
-
"./labelSelect.tsx": labelSelect,
|
|
36
32
|
"./levelSearchCascader.tsx": levelSearchCascader,
|
|
37
33
|
"./lineBar/index.ts": index$1,
|
|
38
34
|
"./radio.tsx": radio,
|
|
39
|
-
"./recommendSelect.tsx": recommendSelect,
|
|
40
35
|
"./remoteSearch.tsx": remoteSearch,
|
|
41
|
-
"./search.tsx": search,
|
|
42
36
|
"./searchCascade.tsx": searchCascade,
|
|
43
37
|
"./select.tsx": select,
|
|
44
38
|
"./simpleComponent.tsx": simpleComponent,
|
|
@@ -4,7 +4,7 @@ import { isNumber } from 'lodash-es';
|
|
|
4
4
|
import { NRadioGroup, NSpace, NRadio } from 'naive-ui';
|
|
5
5
|
import '../../../index.js';
|
|
6
6
|
import '../../utils/index.js';
|
|
7
|
-
import { useAutographOptions } from '../../hooks/
|
|
7
|
+
import { useAutographOptions } from '../../hooks/useFormRenderOptions.js';
|
|
8
8
|
import { assignUpdateValue } from '../../utils/schema.js';
|
|
9
9
|
import { useCommonInjection } from '../../hooks/useCommonInjection.js';
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyObject, Func } from '../../../../../../es/shared/types';
|
|
2
2
|
import { UrlConfig } from '../../../../../../es/components/form-render';
|
|
3
3
|
import { PropType } from 'vue';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const SEARCH_CASCADER: import("vue").DefineComponent<{
|
|
5
5
|
options: {
|
|
6
6
|
type: PropType<AnyObject[]>;
|
|
7
7
|
default: () => never[];
|
|
@@ -19,6 +19,7 @@ import '../../../../../shared/utils/tapable/AsyncSeriesBailHook.js';
|
|
|
19
19
|
import '../../../../../shared/utils/tapable/AsyncSeriesLoopHook.js';
|
|
20
20
|
import '../../../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js';
|
|
21
21
|
import '../../hooks/useFormValidator.js';
|
|
22
|
+
import 'date-fns';
|
|
22
23
|
import '@vue/shared';
|
|
23
24
|
import { connect, mapProps } from '@formily/vue';
|
|
24
25
|
import './index.js';
|
|
@@ -242,8 +243,8 @@ const script = defineComponent({
|
|
|
242
243
|
};
|
|
243
244
|
}
|
|
244
245
|
});
|
|
245
|
-
const
|
|
246
|
+
const SEARCH_CASCADER = connect(script, mapProps({
|
|
246
247
|
dataSource: "options"
|
|
247
248
|
}, assignUpdateValue));
|
|
248
249
|
|
|
249
|
-
export {
|
|
250
|
+
export { SEARCH_CASCADER };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { AnyObject, ArrayAble, Func } from '../../../../../../es/shared/types';
|
|
2
|
+
import { RecommendItem } from '../../../../../../es/components/recommend-search/src/types';
|
|
3
|
+
import { RecommendIds } from '../../hooks';
|
|
2
4
|
import { UrlConfig } from '../../types';
|
|
3
5
|
import { PropType } from 'vue';
|
|
4
6
|
export declare const SELECT: import("vue").DefineComponent<{
|
|
@@ -17,14 +19,56 @@ export declare const SELECT: import("vue").DefineComponent<{
|
|
|
17
19
|
type: PropType<AnyObject[]>;
|
|
18
20
|
default: () => never[];
|
|
19
21
|
};
|
|
20
|
-
urlConfig: {
|
|
21
|
-
type: PropType<UrlConfig>;
|
|
22
|
-
};
|
|
23
22
|
onFocus: {
|
|
24
23
|
type: PropType<Func<any[], any>>;
|
|
25
24
|
};
|
|
26
25
|
onChange: {};
|
|
27
|
-
|
|
26
|
+
urlConfig: {
|
|
27
|
+
type: PropType<UrlConfig>;
|
|
28
|
+
};
|
|
29
|
+
autograph: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
};
|
|
32
|
+
wordbook: {
|
|
33
|
+
type: PropType<Partial<{
|
|
34
|
+
level_num: number;
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
render_key: string[];
|
|
38
|
+
search_key: string[];
|
|
39
|
+
primary_key: string;
|
|
40
|
+
type: string;
|
|
41
|
+
value_key: string;
|
|
42
|
+
level_key: string;
|
|
43
|
+
link_key: string;
|
|
44
|
+
link_key_split: string;
|
|
45
|
+
show_key: string[];
|
|
46
|
+
conObj: AnyObject[];
|
|
47
|
+
conObjFirstLevel: AnyObject[];
|
|
48
|
+
}>>;
|
|
49
|
+
};
|
|
50
|
+
recommend: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: boolean;
|
|
53
|
+
};
|
|
54
|
+
commonList: {
|
|
55
|
+
type: PropType<RecommendItem[]>;
|
|
56
|
+
};
|
|
57
|
+
recentList: {
|
|
58
|
+
type: PropType<RecommendItem[]>;
|
|
59
|
+
};
|
|
60
|
+
getRecommendInfo: {
|
|
61
|
+
type: PropType<() => RecommendIds>;
|
|
62
|
+
};
|
|
63
|
+
recommendNum: {
|
|
64
|
+
type: NumberConstructor;
|
|
65
|
+
default: number;
|
|
66
|
+
};
|
|
67
|
+
recommendCache: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
default: boolean;
|
|
70
|
+
};
|
|
71
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "postRecommend")[], "update:value" | "postRecommend", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
28
72
|
value: {
|
|
29
73
|
type: PropType<ArrayAble<string> | null>;
|
|
30
74
|
};
|
|
@@ -40,17 +84,63 @@ export declare const SELECT: import("vue").DefineComponent<{
|
|
|
40
84
|
type: PropType<AnyObject[]>;
|
|
41
85
|
default: () => never[];
|
|
42
86
|
};
|
|
43
|
-
urlConfig: {
|
|
44
|
-
type: PropType<UrlConfig>;
|
|
45
|
-
};
|
|
46
87
|
onFocus: {
|
|
47
88
|
type: PropType<Func<any[], any>>;
|
|
48
89
|
};
|
|
49
90
|
onChange: {};
|
|
91
|
+
urlConfig: {
|
|
92
|
+
type: PropType<UrlConfig>;
|
|
93
|
+
};
|
|
94
|
+
autograph: {
|
|
95
|
+
type: StringConstructor;
|
|
96
|
+
};
|
|
97
|
+
wordbook: {
|
|
98
|
+
type: PropType<Partial<{
|
|
99
|
+
level_num: number;
|
|
100
|
+
id: string;
|
|
101
|
+
name: string;
|
|
102
|
+
render_key: string[];
|
|
103
|
+
search_key: string[];
|
|
104
|
+
primary_key: string;
|
|
105
|
+
type: string;
|
|
106
|
+
value_key: string;
|
|
107
|
+
level_key: string;
|
|
108
|
+
link_key: string;
|
|
109
|
+
link_key_split: string;
|
|
110
|
+
show_key: string[];
|
|
111
|
+
conObj: AnyObject[];
|
|
112
|
+
conObjFirstLevel: AnyObject[];
|
|
113
|
+
}>>;
|
|
114
|
+
};
|
|
115
|
+
recommend: {
|
|
116
|
+
type: BooleanConstructor;
|
|
117
|
+
default: boolean;
|
|
118
|
+
};
|
|
119
|
+
commonList: {
|
|
120
|
+
type: PropType<RecommendItem[]>;
|
|
121
|
+
};
|
|
122
|
+
recentList: {
|
|
123
|
+
type: PropType<RecommendItem[]>;
|
|
124
|
+
};
|
|
125
|
+
getRecommendInfo: {
|
|
126
|
+
type: PropType<() => RecommendIds>;
|
|
127
|
+
};
|
|
128
|
+
recommendNum: {
|
|
129
|
+
type: NumberConstructor;
|
|
130
|
+
default: number;
|
|
131
|
+
};
|
|
132
|
+
recommendCache: {
|
|
133
|
+
type: BooleanConstructor;
|
|
134
|
+
default: boolean;
|
|
135
|
+
};
|
|
50
136
|
}>> & {
|
|
51
137
|
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
138
|
+
onPostRecommend?: ((...args: any[]) => any) | undefined;
|
|
52
139
|
}, {
|
|
53
140
|
options: AnyObject[];
|
|
54
141
|
lazyRequest: boolean;
|
|
55
142
|
requestCache: boolean;
|
|
143
|
+
recommend: boolean;
|
|
144
|
+
recommendCache: boolean;
|
|
145
|
+
recommendNum: number;
|
|
56
146
|
}>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent,
|
|
2
|
-
import {
|
|
3
|
-
import { isString, cloneDeep, isEqual } from 'lodash-es';
|
|
1
|
+
import { defineComponent, computed, inject, createVNode } from 'vue';
|
|
2
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
3
|
import { useCommonInjection, useSelectOptionProps } from '../../hooks/useCommonInjection.js';
|
|
5
|
-
import {
|
|
4
|
+
import { InjectionChangeContextCollector } from '../../constants/index.js';
|
|
6
5
|
import '../../../../../shared/utils/index.js';
|
|
7
6
|
import '../../../index.js';
|
|
8
|
-
import
|
|
7
|
+
import '../../utils/index.js';
|
|
9
8
|
import { useFormField } from '../../hooks/useFormField.js';
|
|
9
|
+
import '@vueuse/core';
|
|
10
10
|
import '../../../../../shared/utils/tapable/SyncHook.js';
|
|
11
11
|
import '../../../../../shared/utils/tapable/SyncBailHook.js';
|
|
12
12
|
import '../../../../../shared/utils/tapable/SyncWaterfallHook.js';
|
|
@@ -19,9 +19,11 @@ import '../../../../../shared/utils/tapable/AsyncSeriesLoopHook.js';
|
|
|
19
19
|
import '../../../../../shared/utils/tapable/AsyncSeriesWaterfallHook.js';
|
|
20
20
|
import '../../hooks/useFormValidator.js';
|
|
21
21
|
import '@formily/core';
|
|
22
|
+
import 'date-fns';
|
|
22
23
|
import '@vue/shared';
|
|
23
24
|
import { connect, mapProps } from '@formily/vue';
|
|
24
25
|
import './index.js';
|
|
26
|
+
import { useUrlConfigOptions, useAutographOptions, useRecommendOptions } from '../../hooks/useFormRenderOptions.js';
|
|
25
27
|
import { NSelect } from 'naive-ui';
|
|
26
28
|
import { visitedDecorator, assignUpdateValue, assignClearBindVisited } from '../../utils/schema.js';
|
|
27
29
|
|
|
@@ -43,82 +45,83 @@ const script = defineComponent({
|
|
|
43
45
|
type: Array,
|
|
44
46
|
default: () => []
|
|
45
47
|
},
|
|
48
|
+
onFocus: {
|
|
49
|
+
type: Function
|
|
50
|
+
},
|
|
51
|
+
onChange: {},
|
|
46
52
|
urlConfig: {
|
|
47
53
|
type: Object
|
|
48
54
|
},
|
|
49
|
-
|
|
55
|
+
autograph: {
|
|
56
|
+
type: String
|
|
57
|
+
},
|
|
58
|
+
wordbook: {
|
|
59
|
+
type: Object
|
|
60
|
+
},
|
|
61
|
+
recommend: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
commonList: {
|
|
66
|
+
type: Array
|
|
67
|
+
},
|
|
68
|
+
recentList: {
|
|
69
|
+
type: Array
|
|
70
|
+
},
|
|
71
|
+
getRecommendInfo: {
|
|
50
72
|
type: Function
|
|
51
73
|
},
|
|
52
|
-
|
|
74
|
+
recommendNum: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 10
|
|
77
|
+
},
|
|
78
|
+
recommendCache: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: false
|
|
81
|
+
}
|
|
53
82
|
},
|
|
54
|
-
emits: ["update:value"],
|
|
83
|
+
emits: ["update:value", "postRecommend"],
|
|
55
84
|
setup(props, {
|
|
56
85
|
slots,
|
|
57
86
|
emit
|
|
58
87
|
}) {
|
|
59
|
-
const valueRef =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var _a, _b;
|
|
68
|
-
return (_b = (_a = props.urlConfig) == null ? void 0 : _a.valueKey) != null ? _b : "value";
|
|
88
|
+
const valueRef = computed({
|
|
89
|
+
get() {
|
|
90
|
+
return props.value;
|
|
91
|
+
},
|
|
92
|
+
async set(value) {
|
|
93
|
+
emit("update:value", value);
|
|
94
|
+
postRecommend(value);
|
|
95
|
+
}
|
|
69
96
|
});
|
|
97
|
+
const {
|
|
98
|
+
labelKey,
|
|
99
|
+
valueKey,
|
|
100
|
+
fetchData: fetchOptions,
|
|
101
|
+
options
|
|
102
|
+
} = props.urlConfig ? useUrlConfigOptions(props, valueRef) : useAutographOptions(props, valueRef);
|
|
103
|
+
const {
|
|
104
|
+
getRecommend,
|
|
105
|
+
postRecommend,
|
|
106
|
+
sortedOptions
|
|
107
|
+
} = useRecommendOptions(props, options, emit, valueKey);
|
|
70
108
|
const {
|
|
71
109
|
field,
|
|
72
110
|
fieldKey
|
|
73
111
|
} = useFormField();
|
|
74
|
-
const asyncQueue = inject(InjectionAsyncQueue);
|
|
75
|
-
const fetchData = useDebounceFn(async function(content) {
|
|
76
|
-
lastSearch.value = content || "";
|
|
77
|
-
if (!props.urlConfig) {
|
|
78
|
-
return remoteOptions.value = null;
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
remoteOptions.value = await asyncQueue.addAsync(await createUrlConfigParams({
|
|
82
|
-
config: props.urlConfig,
|
|
83
|
-
cache: props.requestCache,
|
|
84
|
-
field: field.value
|
|
85
|
-
}));
|
|
86
|
-
} catch (e) {
|
|
87
|
-
isString(e) && formRenderLog(e);
|
|
88
|
-
}
|
|
89
|
-
}, 300);
|
|
90
|
-
const parsedOptions = computed(() => {
|
|
91
|
-
if (remoteOptions.value)
|
|
92
|
-
return optionMatcherWithKeyword(remoteOptions.value, lastSearch.value, labelKey.value);
|
|
93
|
-
if (!Array.isArray(props.options))
|
|
94
|
-
return [];
|
|
95
|
-
return optionMatcherWithKeyword(props.options, lastSearch.value, labelKey.value);
|
|
96
|
-
});
|
|
97
112
|
const changeContextCollector = inject(InjectionChangeContextCollector);
|
|
98
113
|
changeContextCollector.setContext(fieldKey.value, (v) => {
|
|
99
114
|
return {
|
|
100
115
|
currentOption: cloneDeep(getCurrentOption(v))
|
|
101
116
|
};
|
|
102
117
|
function getCurrentOption(v2) {
|
|
103
|
-
return
|
|
118
|
+
return sortedOptions.value.find((option) => option[valueKey.value] === v2);
|
|
104
119
|
}
|
|
105
120
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
remoteOptions.value = null;
|
|
111
|
-
if (!config)
|
|
112
|
-
return;
|
|
113
|
-
formItemDepsCollector.setDeps(fieldKey.value, config.dependKey || [], async () => {
|
|
114
|
-
remoteOptions.value = null;
|
|
115
|
-
valueRef.value = null;
|
|
116
|
-
!props.lazyRequest && await fetchData();
|
|
117
|
-
});
|
|
118
|
-
(valueRef.value || !props.lazyRequest) && fetchData();
|
|
119
|
-
}, {
|
|
120
|
-
immediate: true
|
|
121
|
-
});
|
|
121
|
+
async function fetchData(content = "") {
|
|
122
|
+
fetchOptions(content);
|
|
123
|
+
getRecommend();
|
|
124
|
+
}
|
|
122
125
|
const {
|
|
123
126
|
injectValueValidate,
|
|
124
127
|
injectValueWatchFromEmpty,
|
|
@@ -135,13 +138,13 @@ const script = defineComponent({
|
|
|
135
138
|
"key": key.value,
|
|
136
139
|
"remote": true,
|
|
137
140
|
"filterable": true,
|
|
138
|
-
"menu-props": menuProps,
|
|
139
|
-
"node-props": nodeProps,
|
|
140
141
|
"value": valueRef.value,
|
|
141
142
|
"onUpdate:value": ($event) => valueRef.value = $event,
|
|
143
|
+
"menu-props": menuProps,
|
|
144
|
+
"node-props": nodeProps,
|
|
142
145
|
"labelField": labelKey.value,
|
|
143
146
|
"valueField": valueKey.value,
|
|
144
|
-
"options":
|
|
147
|
+
"options": sortedOptions.value,
|
|
145
148
|
"onSearch": fetchData,
|
|
146
149
|
"onUpdate:show": (show) => show && fetchData(),
|
|
147
150
|
"onFocus": visitedDecorator(field, props.onFocus)
|
|
@@ -10,6 +10,6 @@ export * from './useBusinessBinding';
|
|
|
10
10
|
export * from './useChangeContext';
|
|
11
11
|
export * from './useFormItemDeps';
|
|
12
12
|
export * from './useAnchor';
|
|
13
|
-
export * from './useAutographOptions';
|
|
14
13
|
export * from './useFormContext';
|
|
15
14
|
export * from './useCommonInjection';
|
|
15
|
+
export * from './useFormRenderOptions';
|
|
@@ -10,6 +10,6 @@ export { BusinessCollector, useBusinessBinding } from './useBusinessBinding.js';
|
|
|
10
10
|
export { ContextCollector, useChangeContext } from './useChangeContext.js';
|
|
11
11
|
export { FormItemDepsCollector, useFormItemDeps } from './useFormItemDeps.js';
|
|
12
12
|
export { useAnchor } from './useAnchor.js';
|
|
13
|
-
export { useAutographOptions } from './useAutographOptions.js';
|
|
14
13
|
export { useFormContext } from './useFormContext.js';
|
|
15
14
|
export { useCommonInjection, useSelectOptionProps } from './useCommonInjection.js';
|
|
15
|
+
export { useAutographOptions, useRecommendOptions, useUrlConfigOptions } from './useFormRenderOptions.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Form } from '@formily/core';
|
|
2
|
-
import { FormBusinessFormatter } from '../../../../../es/components/form-render';
|
|
2
|
+
import { FieldItem, FormBusinessFormatter } from '../../../../../es/components/form-render';
|
|
3
3
|
import { FIELD_BUSINESS_TYPE } from '../constants';
|
|
4
4
|
export declare class BusinessCollector {
|
|
5
5
|
private formModel;
|
|
@@ -9,8 +9,8 @@ export declare class BusinessCollector {
|
|
|
9
9
|
private readonly fieldNameCollector;
|
|
10
10
|
constructor(formModel: Form, businessFormatter?: FormBusinessFormatter | undefined);
|
|
11
11
|
private formatter;
|
|
12
|
-
collect(type: FIELD_BUSINESS_TYPE,
|
|
13
|
-
|
|
12
|
+
collect(type: FIELD_BUSINESS_TYPE, fieldItem: FieldItem): void;
|
|
13
|
+
getField(type: FIELD_BUSINESS_TYPE): FieldItem | undefined;
|
|
14
14
|
getFieldInstanceByType(type: FIELD_BUSINESS_TYPE): import("@formily/core").GeneralField | null;
|
|
15
15
|
private getType;
|
|
16
16
|
private getValueByField;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isField } from '@formily/core';
|
|
2
2
|
import { isString } from '@vueuse/core';
|
|
3
|
+
import { format } from 'date-fns';
|
|
3
4
|
import { isFunction, isNumber } from 'lodash-es';
|
|
4
5
|
import { FIELD_BUSINESS_TYPE } from '../constants/index.js';
|
|
5
6
|
import '../utils/index.js';
|
|
@@ -18,16 +19,16 @@ class BusinessCollector {
|
|
|
18
19
|
formatter(...args) {
|
|
19
20
|
return isFunction(this.businessFormatter) ? this.businessFormatter(...args) : args[0].value;
|
|
20
21
|
}
|
|
21
|
-
collect(type,
|
|
22
|
-
this.typeCollector.set(type,
|
|
23
|
-
this.fieldNameCollector.set(
|
|
22
|
+
collect(type, fieldItem) {
|
|
23
|
+
this.typeCollector.set(type, fieldItem);
|
|
24
|
+
this.fieldNameCollector.set(fieldItem.val_key, type);
|
|
24
25
|
}
|
|
25
26
|
getField(type) {
|
|
26
27
|
return this.typeCollector.get(type);
|
|
27
28
|
}
|
|
28
29
|
getFieldInstanceByType(type) {
|
|
29
30
|
const field = this.getField(type);
|
|
30
|
-
return field ? this.formModel.query(field).take() : null;
|
|
31
|
+
return field ? this.formModel.query(field.val_key).take() : null;
|
|
31
32
|
}
|
|
32
33
|
getType(fieldName) {
|
|
33
34
|
return this.fieldNameCollector.get(fieldName);
|
|
@@ -38,16 +39,16 @@ class BusinessCollector {
|
|
|
38
39
|
}
|
|
39
40
|
getValueByType(type) {
|
|
40
41
|
const field = this.getField(type);
|
|
41
|
-
return field ? this.getValueByField(field) : null;
|
|
42
|
+
return field ? this.getValueByField(field.val_key) : null;
|
|
42
43
|
}
|
|
43
44
|
setValueByType(type, value) {
|
|
44
45
|
const field = this.getField(type);
|
|
45
|
-
field && this.formModel.setFieldState(field, (state) => {
|
|
46
|
+
field && this.formModel.setFieldState(field.val_key, (state) => {
|
|
46
47
|
if (state.value === value)
|
|
47
48
|
return;
|
|
48
49
|
const lock = this.typeLockMap.get(type);
|
|
49
50
|
this.typeLockMap.set(type, isNumber(lock) ? lock + 1 : 1);
|
|
50
|
-
state.value = this.formatter({ value, type, fieldKey: field });
|
|
51
|
+
state.value = this.formatter({ value, type, fieldKey: field.val_key });
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
registerChangeBusiness(type, handler) {
|
|
@@ -73,6 +74,11 @@ class BusinessCollector {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
function useBusinessBinding() {
|
|
77
|
+
function getBirthdayFormat() {
|
|
78
|
+
var _a;
|
|
79
|
+
const birthdayField = this.getField(FIELD_BUSINESS_TYPE.BIRTHDAY);
|
|
80
|
+
return (_a = birthdayField == null ? void 0 : birthdayField.date_format) != null ? _a : "yyyy-MM-dd HH:mm";
|
|
81
|
+
}
|
|
76
82
|
function handlerIdCardType() {
|
|
77
83
|
const idCard = this.getValueByType(FIELD_BUSINESS_TYPE.ID_CARD);
|
|
78
84
|
if (!idCard || !isString(idCard) || !isIdCard(idCard)) {
|
|
@@ -84,7 +90,7 @@ function useBusinessBinding() {
|
|
|
84
90
|
this.setValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT, ageUnit);
|
|
85
91
|
this.setValueByType(FIELD_BUSINESS_TYPE.AGE, age);
|
|
86
92
|
this.setValueByType(FIELD_BUSINESS_TYPE.SEX, info.sex);
|
|
87
|
-
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, info.birthday);
|
|
93
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, format(new Date(info.birthday), getBirthdayFormat.call(this)));
|
|
88
94
|
setSexDisabled.call(this, true);
|
|
89
95
|
function setSexDisabled(value) {
|
|
90
96
|
const sexField = this.getFieldInstanceByType(FIELD_BUSINESS_TYPE.SEX);
|
|
@@ -106,7 +112,7 @@ function useBusinessBinding() {
|
|
|
106
112
|
return;
|
|
107
113
|
if (!isString(ageUnit) || ageUnit === "")
|
|
108
114
|
return;
|
|
109
|
-
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, parseAge2Birthday(+age, ageUnit));
|
|
115
|
+
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, parseAge2Birthday(+age, ageUnit, getBirthdayFormat.call(this)));
|
|
110
116
|
}
|
|
111
117
|
function create(formModel, formatter) {
|
|
112
118
|
return new BusinessCollector(formModel, formatter).registerChangeBusiness(FIELD_BUSINESS_TYPE.ID_CARD, handlerIdCardType).registerChangeBusiness(FIELD_BUSINESS_TYPE.AGE_UNIT, handlerAgeType).registerChangeBusiness(FIELD_BUSINESS_TYPE.AGE, handlerAgeType).registerChangeBusiness(FIELD_BUSINESS_TYPE.BIRTHDAY, handlerBirthdayType);
|
|
@@ -73,7 +73,6 @@ function useFieldListAdaptor(collector) {
|
|
|
73
73
|
if (item.urlConfig) {
|
|
74
74
|
bindUrlProps(schema, item);
|
|
75
75
|
} else if (item.autograph) {
|
|
76
|
-
schema["x-component"] = "SEARCH";
|
|
77
76
|
bindAutoGraphProps(schema, item);
|
|
78
77
|
}
|
|
79
78
|
bindCommonProps(schema, item);
|
|
@@ -89,12 +88,6 @@ function useFieldListAdaptor(collector) {
|
|
|
89
88
|
multiple && (schema2.type = "array");
|
|
90
89
|
}
|
|
91
90
|
};
|
|
92
|
-
const createRecommendSelectSchema = (item) => {
|
|
93
|
-
const schema = createSelectSchema(item);
|
|
94
|
-
schema["x-component"] = "RECOMMEND_SELECT";
|
|
95
|
-
Object.assign(schema["x-component-props"], pick(item, ["commonList", "recentList"]));
|
|
96
|
-
return schema;
|
|
97
|
-
};
|
|
98
91
|
const createRadioSchema = (item) => {
|
|
99
92
|
const schema = createStandardSchema(item);
|
|
100
93
|
Object.assign(schema["x-component-props"], {
|
|
@@ -225,11 +218,10 @@ function useFieldListAdaptor(collector) {
|
|
|
225
218
|
["INPUT", createInputSchema],
|
|
226
219
|
["INPUT_NUMBER", createInputNumberSchema],
|
|
227
220
|
["SELECT", createSelectSchema],
|
|
228
|
-
["RECOMMEND_SELECT", createRecommendSelectSchema],
|
|
229
221
|
["REMOTE_SEARCH", createSelectSchema],
|
|
230
222
|
["DATE", createDateSchema],
|
|
231
223
|
["LEVEL_SEARCH_CASCADER", createLevelSearchCascadeSchema],
|
|
232
|
-
["
|
|
224
|
+
["SEARCH_CASCADER", createSearchCascadeSchema],
|
|
233
225
|
["COMBINATION", createCombinationSchema],
|
|
234
226
|
["RADIO", createRadioSchema],
|
|
235
227
|
["CHECKBOX", createRadioSchema],
|
|
@@ -268,7 +260,7 @@ function useFieldListAdaptor(collector) {
|
|
|
268
260
|
var _a;
|
|
269
261
|
cur = FieldNormalizeWaterfallHook.call(cloneDeep(cur));
|
|
270
262
|
const obj_type = (_a = cur.validate) == null ? void 0 : _a.obj_type;
|
|
271
|
-
obj_type && collector.collect(obj_type, cur
|
|
263
|
+
obj_type && collector.collect(obj_type, cloneDeep(cur));
|
|
272
264
|
if (cur.html_type === "LINEBAR") {
|
|
273
265
|
fin[createFieldName(cur)] = bindIndex(createLinebarSchema(cur), idx);
|
|
274
266
|
prevLinebar = fin[createFieldName(cur)].properties = {};
|
|
@@ -49,7 +49,8 @@ function useFieldNormalize() {
|
|
|
49
49
|
[["DATE-INPUT", "DATETIME-INPUT"], "DATE"],
|
|
50
50
|
["SWITCH_COMPONENT", "SWITCH"],
|
|
51
51
|
["SLIDER_COMPONENT", "SLIDER"],
|
|
52
|
-
["LEVEL_SEARCH_CASCADE", "LEVEL_SEARCH_CASCADER"]
|
|
52
|
+
["LEVEL_SEARCH_CASCADE", "LEVEL_SEARCH_CASCADER"],
|
|
53
|
+
["SEARCH_CASCADE", "SEARCH_CASCADER"]
|
|
53
54
|
];
|
|
54
55
|
FieldNormalizeWaterfallHook.tap("__normalize", (fieldItem) => {
|
|
55
56
|
types.some(([rule, target]) => {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AnyObject, Func } from '../../../../../es/shared/types';
|
|
2
|
+
import { Ref } from 'vue';
|
|
3
|
+
import { FormWordbook, RecommendIds, UrlConfig } from '../../../../../es/components/form-render';
|
|
4
|
+
import { RecommendItem } from '../../../../../es/components/recommend-search/src/types';
|
|
5
|
+
export declare function useRecommendOptions(props: {
|
|
6
|
+
recommend: boolean;
|
|
7
|
+
commonList?: RecommendItem[];
|
|
8
|
+
recentList?: RecommendItem[];
|
|
9
|
+
getRecommendInfo?: () => RecommendIds;
|
|
10
|
+
recommendCache: boolean;
|
|
11
|
+
recommendNum: number;
|
|
12
|
+
}, options: Ref<AnyObject[]>, emit: Func, valueKey: Ref<string>): {
|
|
13
|
+
postRecommend: (value: unknown) => Promise<void>;
|
|
14
|
+
getRecommend: () => Promise<void>;
|
|
15
|
+
sortedOptions: import("vue").ComputedRef<any[]>;
|
|
16
|
+
};
|
|
17
|
+
export declare function useUrlConfigOptions(props: {
|
|
18
|
+
urlConfig?: UrlConfig;
|
|
19
|
+
options?: AnyObject[];
|
|
20
|
+
requestCache: boolean;
|
|
21
|
+
lazyRequest: boolean;
|
|
22
|
+
}, valueRef: Ref): {
|
|
23
|
+
labelKey: import("vue").ComputedRef<string>;
|
|
24
|
+
valueKey: import("vue").ComputedRef<string>;
|
|
25
|
+
options: import("vue").ComputedRef<AnyObject[]>;
|
|
26
|
+
fetchData: (content?: string) => Promise<null | undefined>;
|
|
27
|
+
};
|
|
28
|
+
export declare function useAutographOptions(props: {
|
|
29
|
+
requestCache?: boolean;
|
|
30
|
+
wordbook?: FormWordbook;
|
|
31
|
+
autograph?: string;
|
|
32
|
+
lazyRequest?: boolean;
|
|
33
|
+
options?: AnyObject[];
|
|
34
|
+
}, valueRef: Ref): {
|
|
35
|
+
valueRef: Ref<any>;
|
|
36
|
+
options: import("vue").ComputedRef<AnyObject[]>;
|
|
37
|
+
fetchData: (content?: string) => Promise<void>;
|
|
38
|
+
labelKey: import("vue").ComputedRef<string>;
|
|
39
|
+
valueKey: import("vue").ComputedRef<string>;
|
|
40
|
+
lastSearch: Ref<string>;
|
|
41
|
+
};
|