UP scSelect 1.1 支持值类型为对象

This commit is contained in:
sc 2023-02-24 09:45:09 +08:00
parent c31958d0b7
commit 9ee2d62243
1 changed files with 16 additions and 5 deletions

View File

@ -1,10 +1,10 @@
<!--
* @Descripttion: 异步选择器
* @version: 1.0
* @version: 1.1
* @Author: sakuya
* @Date: 2021年8月3日15:53:37
* @LastEditors:
* @LastEditTime:
* @LastEditors: sakuya
* @LastEditTime: 2023年2月23日15:17:24
-->
<template>
@ -13,7 +13,7 @@
<el-icon class="is-loading"><el-icon-loading /></el-icon>
</div>
<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>
</el-option>
</el-select>
@ -27,6 +27,7 @@
props: {
apiObj: { type: Object, default: () => {} },
dic: { type: String, default: "" },
objValueType: { type: Boolean, default: false },
params: { type: Object, default: () => ({}) }
},
data() {
@ -40,7 +41,7 @@
},
created() {
//options
if(this.$attrs.modelValue && this.$attrs.modelValue.length > 0){
if(this.hasValue()){
this.initloading = true
this.getRemoteData()
}
@ -66,6 +67,16 @@
this.options = response.data
this.loading = 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
}
}
}
}