|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
:showSearch="true"
|
|
|
|
|
@dropdown-visible-change="handleFetch"
|
|
|
|
|
@change="handleChange"
|
|
|
|
|
:optionLabelProp="props.showName ? 'showName' : 'label'"
|
|
|
|
|
>
|
|
|
|
|
<template v-for="item in Object.keys($slots)" #[item]="data">
|
|
|
|
|
<slot :name="item" v-bind="data || {}"></slot>
|
|
|
|
@ -52,13 +53,14 @@
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// api params
|
|
|
|
|
params: propTypes.any.def({}),
|
|
|
|
|
// support xxx.xxx.xx
|
|
|
|
|
resultField: propTypes.string.def(''),
|
|
|
|
|
labelField: propTypes.string.def('label'),
|
|
|
|
|
showName: propTypes.string.def(''),
|
|
|
|
|
valueField: propTypes.string.def('value'),
|
|
|
|
|
immediate: propTypes.bool.def(true),
|
|
|
|
|
alwaysLoad: propTypes.bool.def(false),
|
|
|
|
@ -83,13 +85,13 @@
|
|
|
|
|
prev.push({
|
|
|
|
|
...omit(next, [labelField, valueField]),
|
|
|
|
|
label: next[labelField],
|
|
|
|
|
showName: props.showName ? next[props.showName] : '',
|
|
|
|
|
value: numberToString ? `${value}` : value,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
return prev
|
|
|
|
|
}, [] as OptionsItem[])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
|
props.immediate && !props.alwaysLoad && fetch()
|
|
|
|
|
})
|
|
|
|
@ -158,7 +160,7 @@
|
|
|
|
|
emitData.value = args
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { state, attrs, getOptions, loading, t, handleFetch, handleChange }
|
|
|
|
|
return { state, attrs, getOptions, loading, t, handleFetch, handleChange, props }
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|