Commit 5d51d48787f7b96637bc6abe5175578e0263092a
1 parent
b45f8c50
feat(api-select): added numberToString prop #200
Showing
2 changed files
with
16 additions
and
2 deletions
CHANGELOG.zh_CN.md
src/components/Form/src/components/ApiSelect.vue
... | ... | @@ -36,6 +36,7 @@ |
36 | 36 | }, |
37 | 37 | props: { |
38 | 38 | value: propTypes.string, |
39 | + numberToString: propTypes.bool, | |
39 | 40 | api: { |
40 | 41 | type: Function as PropType<(arg?: Recordable) => Promise<OptionsItem[]>>, |
41 | 42 | default: null, |
... | ... | @@ -61,13 +62,14 @@ |
61 | 62 | const [state] = useRuleFormItem(props); |
62 | 63 | |
63 | 64 | const getOptions = computed(() => { |
64 | - const { labelField, valueField } = props; | |
65 | + const { labelField, valueField, numberToString } = props; | |
65 | 66 | |
66 | 67 | return unref(options).reduce((prev, next: Recordable) => { |
67 | 68 | if (next) { |
69 | + const value = next[valueField]; | |
68 | 70 | prev.push({ |
69 | 71 | label: next[labelField], |
70 | - value: next[valueField], | |
72 | + value: numberToString ? `${value}` : value, | |
71 | 73 | }); |
72 | 74 | } |
73 | 75 | return prev; | ... | ... |