<template>
  <Submenu :name="`${parentName}`">
<!--    <template slot="title">-->
<!--      <common-icon :type="parentItem.icon || ''"/>-->
<!--      <span>{{ showTitle(parentItem) }}</span>-->
<!--    </template>-->
    <template slot="title">
      <common-icon :style="{color:(parentItem && parentItem.searchFlag)?'orange':''}" :type="parentItem.icon || ''"/>
      <span :style="{color:(parentItem && parentItem.searchFlag)?'orange':''}">{{ showTitle(parentItem) }}</span>
    </template>
    <template v-for="item in children">
      <template v-if="item.children && item.children.length === 1">
        <side-menu-item class="a5" v-if="showChildren(item)" :key="`menu-${item.name?item.name:JSON.stringify(item)}`" :parent-item="item"></side-menu-item>
        <menu-item :class="getClass(item)" v-else :name="getNameOrHref(item, true)" :key="`menu-${item.children[0].name}`"><common-icon :type="item.children[0].icon || ''"/><span>{{ showTitle(item.children[0]) }}</span></menu-item>
      </template>
      <template v-else>
        <side-menu-item class="a5" v-if="showChildren(item)" :key="`menu-${item.name?item.name:JSON.stringify(item)}`" :parent-item="item"></side-menu-item>
        <menu-item :class="getClass(item)" v-else :name="getNameOrHref(item)" :key="`menu-${item.name?item.name:JSON.stringify(item)}`" ><common-icon  :style="{color:(item && item.searchFlag)?'orange':''}" :type="item.icon || ''"/><span :style="{color:(item && item.searchFlag)?'orange':''}">{{ showTitle(item) }}</span></menu-item>
      </template>
    </template>
  </Submenu>
</template>
<script>
import mixin from './mixin'
import itemMixin from './item-mixin'
export default {
  name: 'SideMenuItem',
  mixins: [ mixin, itemMixin ],
  methods:{
    getClass(item){
      if(item.name === this.$route.name){
        return 'a5 ivu-menu-item-active ivu-menu-item-selected'
      }else{
        return 'a6'
      }
    }
  }
}
</script>
<style scoped>
.a5{
  /*color: #fff !important;*/
  /*z-index: 2 !important;*/
  /*background: #2d8cf0 !important;*/
}

</style>
