UP scSelect 1.1 支持值类型为对象
This commit is contained in:
parent
c31958d0b7
commit
9ee2d62243
|
@ -1,10 +1,10 @@
|
||||||
<!--
|
<!--
|
||||||
* @Descripttion: 异步选择器
|
* @Descripttion: 异步选择器
|
||||||
* @version: 1.0
|
* @version: 1.1
|
||||||
* @Author: sakuya
|
* @Author: sakuya
|
||||||
* @Date: 2021年8月3日15:53:37
|
* @Date: 2021年8月3日15:53:37
|
||||||
* @LastEditors:
|
* @LastEditors: sakuya
|
||||||
* @LastEditTime:
|
* @LastEditTime: 2023年2月23日15:17:24
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<el-icon class="is-loading"><el-icon-loading /></el-icon>
|
<el-icon class="is-loading"><el-icon-loading /></el-icon>
|
||||||
</div>
|
</div>
|
||||||
<el-select v-bind="$attrs" :loading="loading" @visible-change="visibleChange">
|
<el-select v-bind="$attrs" :loading="loading" @visible-change="visibleChange">
|
||||||
<el-option v-for="item in options" :key="item[props.value]" :label="item[props.label]" :value="item[props.value]">
|
<el-option v-for="item in options" :key="item[props.value]" :label="item[props.label]" :value="objValueType ? item : item[props.value]">
|
||||||
<slot name="option" :data="item"></slot>
|
<slot name="option" :data="item"></slot>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
props: {
|
props: {
|
||||||
apiObj: { type: Object, default: () => {} },
|
apiObj: { type: Object, default: () => {} },
|
||||||
dic: { type: String, default: "" },
|
dic: { type: String, default: "" },
|
||||||
|
objValueType: { type: Boolean, default: false },
|
||||||
params: { type: Object, default: () => ({}) }
|
params: { type: Object, default: () => ({}) }
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
//如果有默认值就去请求接口获取options
|
//如果有默认值就去请求接口获取options
|
||||||
if(this.$attrs.modelValue && this.$attrs.modelValue.length > 0){
|
if(this.hasValue()){
|
||||||
this.initloading = true
|
this.initloading = true
|
||||||
this.getRemoteData()
|
this.getRemoteData()
|
||||||
}
|
}
|
||||||
|
@ -66,6 +67,16 @@
|
||||||
this.options = response.data
|
this.options = response.data
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.initloading = false
|
this.initloading = false
|
||||||
|
},
|
||||||
|
//判断是否有回显默认值
|
||||||
|
hasValue(){
|
||||||
|
if(Array.isArray(this.$attrs.modelValue) && this.$attrs.modelValue.length <= 0){
|
||||||
|
return false
|
||||||
|
}else if(this.$attrs.modelValue){
|
||||||
|
return true
|
||||||
|
}else{
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue