customer.vue 6.86 KB
<template>
    <div class="analysis-wrapper customer-wrapper">
        <el-container>
            <el-aside width="200px" height="100%">
                <el-menu
                   class="aside-menu-wrapper"
                   :default-active="activeIndex"
                   background-color="#fff"
                   text-color="#515a6e"
                   @select="menuSelect"
                   unique-opened>
                    <el-submenu :index="item.path" v-for="item in customerMenu" :key="item.path" style="text-align:left" v-if="permissControl(item.path) && hasChildPermission(item.children)">
                       <template slot="title">
                           <i :class="item.iconClass"></i>
                           <span>{{i18n(item.name)}}</span>
                       </template>
                       <el-menu-item-group>
                           <el-menu-item :index="child.path" v-for="(child,index) in item.children" :key="index" v-if="permissControl(child.path)">
                                <!-- <i :class="child.iconClass"></i> -->
                                <span slot="title">{{i18n(child.name)}}</span>
                            </el-menu-item>
                       </el-menu-item-group>
                   </el-submenu>
                </el-menu>
            </el-aside>
            <el-container>
                <router-view></router-view>
            </el-container>
        </el-container>
    </div>
</template>

<script>
export default {
    data() {
        return {
            activeIndex: '',
            moreOptVisible: false,
            customerMenu:[{
                path: 'humanface',
                iconClass: 'icon font_family icon-residencetime_icon custom-icon residencetime-icon',
                name: 'HumanFaceAsis',
                children: [
                    {
                        path: 'customtrack',
                        iconClass: 'icon font_family icon-customtrack_icon custom-icon customtrack-icon',
                        name: 'CustomTrack',
                    },
                    {
                        path: 'trafficdirection',
                        iconClass: 'icon font_family icon-ftmoveline_icon custom-icon ftmoveline-icon',
                        name: 'TrafficDirection',
                    },
                    {
                        path: 'moveline',
                        iconClass: 'icon font_family icon-tftrackheat_icon custom-icon tftrackheat-icon',
                        name: 'MoveLineAnalysis',
                    },
                    {
                        path: 'zonedirection',
                        iconClass: 'icon font_family icon-ftmoveline_icon custom-icon ftmoveline-icon',
                        name: 'ZoneTrafficDirection'
                    },
                    {
                        path: 'residencetime',
                        iconClass: 'icon font_family icon-residencetime_icon custom-icon residencetime-icon',
                        name: 'ResidenceTime',
                    },
                    {
                        path: 'happinessindex',
                        iconClass: 'icon font_family icon-residencetime_icon custom-icon residencetime-icon',
                        name: 'HappinessIndex',
                    },
                ]
            },{
                path: 'fisheyethermal',
                iconClass: 'icon font_family icon-areaheat_icon custom-icon areaheat-icon',
                name: 'FisheyeThermal',
                children: [
                    {
                        path: 'storeheat',
                        iconClass: 'icon font_family icon-areaheat_icon custom-icon areaheat-icon',
                        name: 'Areaheat',
                    },
                    {
                        path: 'boothheat',
                        iconClass: 'icon font_family icon-faceheat_icon custom-icon faceheat-icon',
                        name: 'Trackheat',
                    },
                ]
            }],
            menuArr: [],
        }
    },
    components: {},
    methods: {
        i18n(name){
			let languageLable = 'asis.' + name
			return this.$t(languageLable)
        },
        permissControl(path) {
            if(window._vionConfig.allMenu){
                return true
            }
            if(this.menuArr.includes(path)){
                return true
            }else{
                return false
            }
        },
        hasChildPermission(children) {
            if(window._vionConfig.allMenu){
				return true
            }
            if (!children.length) {
                return false
            }
            let hasPermission = children.map(item => {
                return this.menuArr.includes(item.path)
            }).filter(Boolean)
            return hasPermission.length > 0
        },
        menuSelect(key, path) {
            // if((window.location.href.split('/')).indexOf(key) === -1) {
            //     this.$router.push('/customer/' + key);
            // }
            this.navigateTo(this,'customer',key);
        },
        refreshSelect(path){
              this.$router.push('/customer/' + path);
        },
        refresh(){
            let name = this.$router.history.current.name;
            let path = this.$router.history.current.path;
            let newPath = path.split('/')[2];
            let obj = {
                pointheat: 'pointheat',
                flowheat: 'flowheat',
                floortrafficheat: 'floortrafficheat',
                floorheat: 'floorheat',
                trafficeline: 'trafficeline',
                // residencetime: 'residencetime',
                trafficdirection: 'trafficdirection',
                customtrack: 'customtrack',
                storeheat: 'storeheat',
                boothheat: 'boothheat',
                moveline: 'moveline',
                happinessindex: 'happinessindex',
                zonedirection: 'zonedirection'
            };
            if(obj.hasOwnProperty(newPath)){
                this.activeIndex = obj[newPath]
                this.refreshSelect(obj[newPath])
            }
        },
    },
    created() {
        if(!window._vionConfig.allMenu){
            this.menuArr = JSON.parse(window.localStorage.getItem('menuName'));
        }
    },
    mounted() {
        let firstPath,name;
        if(window._vionConfig.allMenu){
            firstPath = 'customtrack'
        }else{
            firstPath = this.menuArr[this.menuArr.indexOf('customer') + 2];
        }
        name = this.$router.history.current.name;
        // let path = this.$router.history.current.path;
        if(!name){
            this.activeIndex = firstPath;
            this.menuSelect(firstPath, [firstPath]);
        }else{
            this.refresh()
        }

    }
}
</script>

<style>
    .test-opt-time .time-opt .el-input__inner {
        height: 100% !important;
    }
    .customer-wrapper .custom-icon {
        font-size: 14px;
    }
</style>