88 lines
1.6 KiB
Vue
88 lines
1.6 KiB
Vue
<template>
|
|
<view>
|
|
<u--input :value="select" disabled disabledColor="#ffffff" :placeholder="placeholder" border="none"></u--input>
|
|
|
|
|
|
<u-picker :show="show" :loading="loading" ref="uPicker" :columns="columns" @confirm="confirm" keyName="dicName"
|
|
@cancel="show = false"></u-picker>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from "@/utils/request";
|
|
export default {
|
|
name: "dic-select",
|
|
props: {
|
|
show: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
code: {
|
|
type: String,
|
|
require: true
|
|
},
|
|
|
|
placeholder: {
|
|
type: String,
|
|
default: "请选择"
|
|
}
|
|
},
|
|
computed: {
|
|
select() {
|
|
if (this.value == undefined || this.value == "") {
|
|
return '';
|
|
}
|
|
for (var i = 0; i < (this.columns[0] || []).length; i++) {
|
|
const item=this.columns[0][i]
|
|
if(item.dicCode==this.value){
|
|
return item.dicName;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
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> |