look for it on the official website, but there is no corresponding example and api
<template>
<el-select class="g-public-multi-select" v-model="selectWeekDayListProp" :disabled="disabled" @change="selectChange" multiple>
<el-option
v-for="item in weekDayAry"
:key="item.value"
:label="item | getName"
:value="item.value">
</el-option>
</el-select>
</template>
<style>
.el-select__tags {
max-width: 375px !important;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
<script>
import _const from "@/utils/constants"
export default {
name: "weekDayMultipleSelect",
props: ["selectWeekDayList", "disabled"],
data() {
return {
selectWeekDayListProp: this.selectWeekDayList,
isContainAll: true,
weekDayAry: [
{ "value": 0, "nameCn": "", "nameEn": "All" },
{ "value": 1, "nameCn": "", "nameEn": "Monday" },
{ "value": 2, "nameCn": "", "nameEn": "Tuesday" },
{ "value": 3, "nameCn": "", "nameEn": "Wednesday" },
{ "value": 4, "nameCn": "", "nameEn": "Thursday" },
{ "value": 5, "nameCn": "", "nameEn": "Friday" },
{ "value": 6, "nameCn": "", "nameEn": "Saturday" },
{ "value": 7, "nameCn": "", "nameEn": "Sunday" }
]
}
},
filters:{
getName(item) {
if (item === null) return
if (store.getters.lang === "zh") {
return item.nameCn
} else {
return item.nameEn
}
}
},
methods: {
//
selectChange() {
//
if (this.isContainAll) {
//
//
this.isContainAll = false
//
this.selectWeekDayListProp.splice(0, 1)
} else {
//
//
this.isContainAll = this.selectWeekDayListProp.some(value => value === 0)
//
if (this.isContainAll) {
// value=0
this.selectWeekDayListProp = [0]
} else {
//
if (this.selectWeekDayListProp.length === 7) {
//
this.selectWeekDayListProp = [0]
this.isContainAll = true
}
}
}
//
if (this.selectWeekDayListProp.length === 0) {
//
this.selectWeekDayListProp = [0]
this.isContainAll = true
}
this.$emit("update:selectWeekDayList", this.selectWeekDayListProp)
this.$emit("change")
}
}
}
</script>
I wrote it myself