Files
gjt_mini/components/dic-select/select-show.vue
2025-12-30 09:44:46 +08:00

70 lines
1.2 KiB
Vue

<template>
<view>
<u-picker :show="show" :loading="loading" ref="uPicker" :columns="columns" @confirm="confirm" keyName="dicName"
@cancel="show = false"></u-picker>
</view>
</template>
<script>
export default{
name:"select-show"
props: {
show: {
type: Boolean,
default: false
},
code: {
type: String,
require: true
},
placeholder: {
type: String,
default: "请选择"
}
},
mounted() {
this.getDic();
},
data() {
return {
columns: [
[
]
],
loading: false,
value:undefined,
};
},
methods: {
getDic() {
const that = this;
this.loading = true;
axios.get("/dic/queryByDicType", {
"dicType": this.code
}).then(res => {
that.columns[0]=res;
that.$refs.uPicker.setColumnValues(0, res);
that.loading = false;
}).catch(error => {
that.loading = false;
this.closeShow();
});
},
confirm(e) {
this.value = e.value[0].dicCode;
this.$emit("selectChangeValue",e.value[0].dicCode)
this.$emit("selectChange",e.value[0])
this.closeShow();
},
closeShow(){
this.$emit("closeShow",false);
}
}
}
</script>
<style>
</style>