mallOptionContent.vue 3.04 KB
<template>
    <div class="mall-option-content">
        <span class="condition-item-text">{{$t('asisTab.mallT')}}</span>
        <div class="condition-item-option" v-show="objectVal === 1">
            <el-select v-model="mallVal" filterable :placeholder="$t('pholder.shopSelect')" class="mall-sel-box" @change="mallChange">
                <el-option v-for="item in mallData" :key="item.id" :label="item.name" :value="item.id"></el-option>
            </el-select>
        </div>
        <div class="condition-item-option" v-show="objectVal === 2">
            <!-- @visible-change="visibleHandle" @focus="mallFocus" -->
            <el-select v-model="mutiMallVal" filterable :placeholder="$t('pholder.shopSelect')" class="mall-sel-box" multiple collapse-tags @change="mallChangeHandle">
                <!-- v-show="isFocus"  -->
                <div :class="isMallSelAll ? 'sel-all-box selected' : 'sel-all-box'" @click="selAllHandle('mall')">
                    <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 mallData" :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,
        mallData: Array
    },
    name: 'mall-option-content',
    data() {
        return {
            mallVal: '',
            mutiMallVal: [],
            isMallSelAll: false,
        }
    },
    watch: {
        mallData(val) {
            this.mallVal = val[0].id;
            this.mutiMallVal = [this.mallVal];
        },
        mallVal(val) {
            Bus.$emit('mallVal',val)
        }
    },
    created() {

    },
    mounted() {

    },
    methods: {
        mallChange() {
            this.mutiMallVal = [this.mallVal];
        },
        mallChangeHandle() {
            this.mutiMallVal.length >= this.mallData.length ? true: false
        },
        selAllHandle(selType) {
            if(this.isMallSelAll) {
                this.isMallSelAll = false;
                if(this.mutiMallVal.length == this.mallData.length) {
                    this.mutiMallVal = [];
                }
            } else {
                this.isMallSelAll = true;
                if(this.mutiMallVal.length == this.mallData.length) {
                    this.mutiMallVal = [];
                } else {
                    this.mutiMallVal = [];
                    this.mallData.forEach(item => {
                        this.mutiMallVal.push(item.id);
                    })
                }
            }
        },
    }
}
</script>

<style>

</style>