forked from github/dataease
feat: 优化下拉框多选组件
This commit is contained in:
parent
5c17df3c6a
commit
a62dedb981
@ -1,6 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<el-select v-if="options!== null && options.attrs!==null" v-model="options.value" :clearable="!options.attrs.multiple" :multiple="options.attrs.multiple" :placeholder="options.attrs.placeholder" @change="changeValue">
|
<el-select
|
||||||
|
v-if="options!== null && options.attrs!==null"
|
||||||
|
ref="deSelect"
|
||||||
|
v-model="options.value"
|
||||||
|
:collapse-tags="showNumber"
|
||||||
|
:clearable="!options.attrs.multiple"
|
||||||
|
:multiple="options.attrs.multiple"
|
||||||
|
:placeholder="options.attrs.placeholder"
|
||||||
|
@change="changeValue"
|
||||||
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in options.attrs.datas"
|
v-for="item in options.attrs.datas"
|
||||||
:key="item[options.attrs.key]"
|
:key="item[options.attrs.key]"
|
||||||
@ -29,7 +38,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
options: null,
|
options: null,
|
||||||
// operator: 'eq',
|
// operator: 'eq',
|
||||||
values: null
|
values: null,
|
||||||
|
showNumber: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -59,6 +69,14 @@ export default {
|
|||||||
changeValue(value) {
|
changeValue(value) {
|
||||||
this.setCondition()
|
this.setCondition()
|
||||||
// this.inDraw && this.$emit('set-condition-value', { component: this.element, value: [value], operator: this.operator })
|
// this.inDraw && this.$emit('set-condition-value', { component: this.element, value: [value], operator: this.operator })
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const kids = this.$refs.deSelect.$refs.tags.children[0].children
|
||||||
|
let contentWidth = 0
|
||||||
|
kids.forEach(kid => {
|
||||||
|
contentWidth += kid.offsetWidth
|
||||||
|
})
|
||||||
|
this.showNumber = contentWidth > (this.$refs.deSelect.$refs.tags.clientWidth * 0.7)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
setCondition() {
|
setCondition() {
|
||||||
|
Loading…
Reference in New Issue
Block a user