<template>
		<div class="left-menu">
			<div class="menu-top" v-for="item in getCurSide" :key="item.name">
				<div class="first-title">{{item.name}}</div>
				<div>
					<div v-for="itemChild in item.children" :key="itemChild.name" @click="leftMenuClick(itemChild.type)" :class="activeMenu == itemChild.type?'second-title activeMenu':'second-title'">{{itemChild.name}}  {{itemChild.number?`(${itemChild.number})`:''}}</div>
				</div>
			</div>
		</div>
</template>

<script>
	export default {
		props: {
			collapsed: {
				type: Boolean,
				default: true,
			},
			dynamicTags:{
				type: Array,
				default: [],
			},
		},
		data() {
			return {
				activeMenu:'',
				getCurSide:[],
				path:''
			}
		},
		computed:{
			// getCurSide() {
			// 	return this.$store.state.global.menuTree.currentMenu || [];
			// }
		},
		methods: {
			getLeftMenu(){
				const {path}=this
				let url
        let data = {};
        let isSysOrder = path.indexOf('systemOrder') > 0;
        let statusNum = {};
				if(isSysOrder){
					url='assistant/coOrders/statusGroupCount'
				}
				this.axios({
						url: url,
						data:data,
						method: "post"
				}).then(res => {
					if(res.success){
            if (isSysOrder) {
              if(res.module){
                let _data = res.module.data;
                if(_data && _data.length){
                  for (let e of _data){
                    statusNum[e.key] = e.count;
                  }
                }
              }
            }
						// this.getCurSide=res.module.resultList
						this.activeMenu = this.$route.query.id||2
						// this.$emit('getCurrentLeft',this.activeMenu)
						this.leftMenuClick(this.activeMenu)
					}
				}).finally(()=>{
					let type2Num=Number(statusNum['PENDING'])+Number(statusNum['INTERRUPT']?statusNum['INTERRUPT']:0);
          this.getCurSide = [
            {name:'搜索',children:[{name:'全部订单',number:'',type:'1'}]},
            {name:'订单',children:[{name:'待处理订单',number:type2Num?type2Num:'0',type:'2'},{name:'仓库已接单',number:statusNum['RECEIVED']?statusNum['RECEIVED']:'0',type:'3'},{name:'缺货',number:statusNum['OUTSTOCK']?statusNum['OUTSTOCK']:'0',type:'4'},{name:'仓库已发货',number:'',type:'5'}]},
            {name:'已交运',children:[{name:'渠道已揽收',number:'',type:'6'},{name:'已妥投',number:'',type:'7'}]},
            {name:'其它',children:[{name:'退款',number:'',type:'8'},{name:'已挂起',number:'',type:'9'},{name:'废弃订单',number:'',type:'10'},{name:'拦截',number:'',type:'11'}]}
          ];
        })
			},
			leftMenuClick(value){
				this.activeMenu = value
				this.$emit('getCurrentLeft',value)
			}
		},
		mounted() {
			this.path=this.$route.path
			this.getLeftMenu()
		},
	}

</script>

<style scoped lang="less">
	// @import '../assets/css/variable.less';
	.left-menu {
		width: 160px;
		height: 438px;
		border: 1px solid #ccc;
		background: #FFFFFF;
		margin-right: 20px;
		.menu-top{
			text-align: left;
			// padding:32px 45px 0 45px;
			font-size: 16px;
			color: #333333;
			.first-title{
				height: 32px;
				line-height: 32px;
				color: #000;
				vertical-align: top;
				padding-left: 5px;
				background-color: #eee;
				border-bottom: 1px solid #dbdbdb;
				font-weight: 700;
				font-size: 13px
			}
			.second-title{
				color: #000;
				line-height: 28px;
				vertical-align: top;
				height: 28px;
				border-bottom: 1px solid #dbdbdb;
				cursor: pointer;
				padding-left: 12px;
				font-size: 13px
			}
			.activeMenu{
				color: #fff;
				background-color: #367EE2
			}
		}
	}
</style>