select.vue
1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<template>
<el-select v-model="selectVal" class="floor-sel-box format-sel-box" multiple collapse-tags @change="selectChange">
<div :class="isAll ? 'sel-all-box selected' : 'sel-all-box'" @click="selAllHandle()">
<span class="custom-checkbox__input">
<span class="custom-checkbox__inner"></span>
</span>
<span style="padding-left: 5px;">{{$t('allPages.all')}}</span>
</div>
<el-option v-for="item in list" :key="item.value" :label="item.label" :value="item.value">
<span class="custom-checkbox__input">
<span class="custom-checkbox__inner"></span>
</span>
<span style="padding-left: 5px;">{{ item.label }}</span>
</el-option>
</el-select>
</template>
<script>
export default {
props: {
parentList:{
type: Array,
},
typeSouce:{
type: String,
}
},
data() {
return {
list: this.parentList,
selectVal: [],
isAll: false,
}
},
components: {
},
mounted() {
},
methods: {
selAllHandle(){
if(this.isAll){
this.isAll = false
this.selectVal = [];
}else{
this.isAll = true;
this.selectVal = [];
this.list.forEach(item => {
this.selectVal.push(item.value)
})
}
let obj = {};
obj[this.typeSouce] = this.selectVal;
this.$emit("childVal",obj)
},
selectChange() {
this.isAll = this.selectVal.length >= this.list.length ? true : false;
let obj = {};
obj[this.typeSouce] = this.selectVal;
this.$emit("childVal",obj)
}
}
}
</script>
<style scoped>
.format-sel-box {
margin-left: 5px;
width: 135px;
}
</style>