areaFlowTimeOps.vue 7.76 KB
<template>
    <div class="behavior-more-option behavior-test-option">
        <div class="opt-left">
            <!-- 广场 -->
            <div class="test-opt-mall">
                <el-select v-model="mallVal" class="mall-opt" filterable :placeholder="$t('pholder.shopSelect')" @change="chooseMall">
                    <el-option v-for="(item, index) in mallOpt" :label="item.name" :value="item.id" :key="item.value"></el-option>
                </el-select>
            </div>
            <!-- 监控点 -->
            <div class="test-opt-monitory">
                <el-select v-model="monitoryVal" filterable :placeholder="$t('pholder.site')" class="multipleClass mall-sel-box" multiple
                :reserve-keyword="true" collapse-tags @change="chooseMonitory">
                    <!-- <el-option value="all" label="{{$t('allPages.all')}}">
                        <span class="custom-checkbox__input">
                            <span class="custom-checkbox__inner"></span>
                        </span>
                        <span style="padding-left: 5px;">{{$t('allPages.all')}}</span>
                    </el-option> -->
                    <div :class="isSelAll ? '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, index) in monitoryOpt" :label="item.name" :value="item.id" :key="item.value">
                        <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 class="test-opt-time">
                <el-date-picker class="time-opt" v-model="dayTime" type="date" :picker-options="pickerOptions1" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
                </el-date-picker>
            </div>
        </div>
        <div class="opt-right">
            <el-button type="primary" class="primary-btn behavior-collapse-btn" size="samll"
                :disabled="!dayTime" 
                @click="clickHandle">{{$t('button.confirm')}}</el-button>
            <!-- <el-button class="reset-btn behavior-collapse-btn" size="samll" @click="resetRefresh">{{$t('button.reset')}}</el-button> -->
        </div>
    </div>
</template>

<script>
export default {
    // props: {
    //     pageSize: [Number, String]
    // },
    data() {
        return {
            pickerOptions1: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                },
            },
            mallName: '',
            mallVal: '',
            mallOpt: [],
            monitoryVal: [],
            monitoryName: '',
            monitoryOpt: [],
            cameraVal: '',
            cameraOpt: [],
            typeVal: '',
            dayTime: '',
            isSingle: false,
            isSelAll: false,
        }
    },
    created() {
    },
    watch: {
        dayTime(val) {
            this.sessionDate('dayDate', val);
        },
    },
    mounted() {
        let {dayDate} = this.createDate();
        this.dayTime = dayDate;
        this.getMallList();
    },
    methods: {
        getMallList() {
            this.mallOpt = [];
            this.mallVal = '';
            this.mallName = '';
            this.getCommonMalls().then(resolveData => {
                let {mallData,localMallId,titleName,multiMallId} = resolveData;
                this.mallOpt = mallData;
                this.mallVal =  localMallId;
                this.mallName = titleName;
                this.getZones(this.mallVal);
            },(rejectData) => {
            })
        },
        chooseMall() {
            this.mallName = this.behaviorMallChange(this.mallVal,this.mallOpt, true);
            this.getZones(this.mallVal);
        },
        getZones(mallId) {
            this.monitoryOpt = [];
            this.monitoryVal = [];
            this.monitoryName = '';
            this.isSelAll = false;
            this.$api.base.zone({
                mallId: mallId,
                status: 1,
                sortName: 'floor.name, zone.name',
                // _t: Date.parse(new Date()) / 1000
                // isMallGate: 1
            })
                .then(res => {
                    let result = res.data;
                    if (result.data.length) {
                        result.data.forEach((item, index, arr) => {
                            this.monitoryVal.push(item.id);
                            if (index == 0) {
                                // this.monitoryVal.push(item.id);
                                this.monitoryName = item.name + ' ';
                            }
                        });
                        this.monitoryOpt = result.data;
                        if(this.monitoryVal.length == this.monitoryOpt.length) {
                            this.isSelAll = true;
                        }
                        this.clickHandle();
                    }
                })
                .catch(err => { })
        },
        chooseMonitory() {
            this.isSelAll = this.isSelAll ? 
                (this.monitoryVal.length < this.monitoryOpt.length ? false: true) :
                this.monitoryVal.length < this.monitoryOpt.length ? false : true;
        },
        selAllHandle() {
            if(this.isSelAll) {
                this.isSelAll = false;
                if(this.monitoryVal.length == this.monitoryOpt.length) {
                    this.monitoryVal = [];
                }
            } else {
                this.isSelAll = true;
                if(this.monitoryVal.length == this.monitoryOpt.length) {
                    this.monitoryVal = [];
                } else {
                    this.monitoryVal = [];
                    this.monitoryOpt.forEach(item => {
                        this.monitoryVal.push(item.id);
                    })
                }
            }
        },
        clickHandle() {
            let repTit = '';
            this.monitoryName = '';
            if (this.monitoryVal.length == 1) {
                this.monitoryOpt.forEach(item => {
                    if (item.id == this.monitoryVal[0]) {
                        this.monitoryName = item.name;
                    }
                })
                repTit = this.mallName ? this.mallName + '-'  + this.monitoryName : this.monitoryName;
            }else{
                repTit = this.mallName
            }
            this.$emit('startLoading', 'areaFlowTime');
                let orgIds = '';
                this.monitoryVal.forEach((item, index, arr) => {
                    orgIds += item + ',';
                })
                orgIds = orgIds.substring(0, orgIds.length - 1);
                let params = {
                    orgIds: orgIds,
                    date: this.dayTime,
                    title: repTit + ' ' + this.dayTime + ' '
                }
                this.$emit('emitParams', params);
        },
    }
}
</script>

<style scoped>
    @media only screen and (max-width: 1680px) {
        .test-opt-monitory {
            width: 160px;
        }
    }
    @media only screen and (max-width: 1440px) {
        .test-opt-monitory {
            width: 160px;
        }
    }
    @media only screen and (max-width: 1366px) {
        .test-opt-monitory {
            width: 160px;
        }
    }
    @media only screen and (max-width: 1280px) {
        .test-opt-monitory {
            width: 160px;
        }
    }
</style>