mallSelector.vue 2.5 KB
<template>
    <div class="condition-item-option">
        <el-select
            v-model="mallVal"
            filterable
            :multiple="isMultiple"
            collapse-tags
            :placeholder="$t('pholder.shopSelect')"
            class="mall-sel-box"
            @change="mallChangeHandle">
            <div :class="isAllSelect ? 'sel-all-box selected' : 'sel-all-box'" @click="selAllHandle()" v-show="isMultiple">
                <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" v-show="isMultiple">
                    <span class="custom-checkbox__inner"></span>
                </span>
                <span :style="mallLabel">{{ item.name }}</span>
            </el-option>
        </el-select>
    </div>
</template>

<script>
export default {
    name: 'mallSelector',
    props: {
        isMultiple: {
            type: Boolean,
            default: false
        },
        isAllSelect: false
    },
    data() {
        return {
            mallData: [],
            radioMallVal: null,
            multiMallVal: []
        }
    },
    computed: {
        mallVal() {
            if(this.isMultiple) {
                return this.multiMallVal
            } else {
                return this.radioMallVal
            }
        }
    },
    methods: {
        getMallList() {
            this.$api.base.mall({
                accountId: this.$cookie.get('accountId'),
                status: 1,
                // _t: Date.parse(new Date()) / 1000
            }).then(res => {
                let { data } = res;
                if(data.code == 200) {
                    let localMallId = window.sessionStorage.getItem('mallId');
                        localMallId ? Number(localMallId) : false;
                    data.data.forEach((item, index) => {
                        this.multiMallVal.push(item.id);
                        if(localMallId) {
                            if(index == 0) {
                                this.radioMallVal = item.id;
                            }
                        }
                    })
                    this.mallData = data.data;
                }
            })
        },
        selAllHandle() {

        }
    }
}
</script>

<style>

</style>