43 lines
988 B
Vue
43 lines
988 B
Vue
|
|
<template>
|
||
|
|
<uni-data-select
|
||
|
|
v-model="modelValue"
|
||
|
|
:localdata="options"
|
||
|
|
v-bind="omit($attrs,['change'])"
|
||
|
|
/>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup>
|
||
|
|
import {defineModel, defineOptions, defineProps, getCurrentInstance, ref, watch} from 'vue'
|
||
|
|
import {omit} from "radash";
|
||
|
|
import {getDicts} from "../../api/system/dict/data";
|
||
|
|
import UniDataSelect from "../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue";
|
||
|
|
|
||
|
|
defineOptions({
|
||
|
|
name: 'DictSelect',
|
||
|
|
inheritAttrs: false
|
||
|
|
})
|
||
|
|
|
||
|
|
const modelValue = defineModel()
|
||
|
|
const props = defineProps(['dict'])
|
||
|
|
const {proxy} = getCurrentInstance()
|
||
|
|
|
||
|
|
const options = ref([])
|
||
|
|
|
||
|
|
watch(() => props.dict, async () => {
|
||
|
|
if (!props.dict) return ''
|
||
|
|
const {data} = await getDicts(`${props.dict}`)
|
||
|
|
options.value = data.map(item => {
|
||
|
|
return {
|
||
|
|
value: item.dictValue,
|
||
|
|
text: item.dictLabel
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}, {
|
||
|
|
immediate: true
|
||
|
|
})
|
||
|
|
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="scss" scoped>
|
||
|
|
|
||
|
|
</style>
|