<template>
|
<div>
|
<el-checkbox-group class="pam-multi-select-btn" v-model="syncMutiSelect">
|
<el-checkbox
|
v-for="(option, index) in options"
|
:key="index"
|
:label="option"
|
:name="option"
|
></el-checkbox>
|
<template v-if="nameOfSelectAll">
|
<button class="pam-selectAll-btn cursor--pointer" :class="{'selected':isSelectAll}" :model="isSelectAll" @click="selectAll">
|
<span>{{nameOfSelectAll}}</span>
|
</button>
|
</template>
|
</el-checkbox-group>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { Vue, Component, Prop, PropSync} from 'vue-property-decorator';
|
|
@Component
|
export default class MultiSelectBtn extends Vue {
|
@PropSync('mutiSelect',{type:Array,default:()=>[]}) syncMutiSelect!:string[];
|
@Prop({default:''}) nameOfSelectAll!:string;
|
@Prop({default:()=>[]}) options!:string[]|[];
|
isSelectAll=false;
|
|
updated() {
|
this.isSelectAll = this.syncMutiSelect.length === this.options.length;
|
}
|
|
selectAll():void{
|
this.isSelectAll= !this.isSelectAll;
|
this.syncMutiSelect = this.isSelectAll ? this.options:[];
|
}
|
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.pam-selectAll-btn{
|
padding: 6px 20px;
|
border: 1px $LIGHT_GREY solid;
|
background-color: $PRIMARY_WHITE;
|
border-radius: 30px;
|
font-size: 20px;
|
margin-right: 10px;
|
margin-bottom: 10px;
|
&.selected{
|
background-color:$CORAL;
|
color: $PRIMARY_WHITE;
|
}
|
}
|
</style>
|