zoneOptionContent.vue 2.69 KB
<template>
    <div class="zone-option-content">
        <span class="condition-item-text">{{$t('asisTab.storeT')}}</span>
        <div class="condition-item-option"  v-show="objectVal === 1">
            <el-select v-model="zoneVal" filterable :placeholder="$t('pholder.areaSelect')" class="shop-sel-box">
                <el-option v-for="item in zoneData" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
            </el-select>
        </div>
        <div class="condition-item-option"  v-show="objectVal === 2">
            <el-select v-model="mutiZoneVal" filterable :placeholder="$t('pholder.areaSelect')" class="shop-sel-box" multiple collapse-tags @change="zoneChangeHandle">
                <div :class="isZoneSelAll ? 'sel-all-box selected' : 'sel-all-box'" @click="selAllHandle('zone')">
                    <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 zoneData" :key="item.id" :label="item.name" :value="item.id">
                    <span class="custom-checkbox__input">
                        <span class="custom-checkbox__inner"></span>
                    </span>
                    <span style="padding-left: 5px;">{{ item.name }}</span>
                </el-option>
            </el-select>
        </div>
    </div>
</template>

<script>
import Bus from '../../views/public/eventBus'
export default {
    props: {
        objectVal: Number,
    },
    name: 'zone-option-content',
    data() {
        return {
            zoneVal: '',
            mutiZoneVal: [],
            zoneData: [],
            isZoneSelAll: false,
        }
    },
    watch: {

    },
    created() {

    },
    mounted() {

    },
    methods: {
        zoneChangeHandle() {
            this.isZoneSelAll =  this.isZoneSelAll.length >= this.zoneData.length ? true: false;
        },
        selAllHandle(selType) {
            if(this.isZoneSelAll) {
                this.isZoneSelAll = false;
                if(this.mutiZoneVal.length == this.zoneData.length) {
                    this.mutiZoneVal = [];
                }
            } else {
                this.isZoneSelAll = true;
                if(this.mutiZoneVal.length == this.zoneData.length) {
                    this.mutiZoneVal = [];
                } else {
                    this.mutiZoneVal = [];
                    this.zoneData.forEach(item => {
                        this.mutiZoneVal.push(item.id);
                    })
                }
            }
        },
    }
}
</script>

<style>

</style>