<script lang='tsx'>
import { Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { AppMenusCtrlBase } from '@/crm-core';
import AppIndexViewService from './app-index-view-appmenu-service';

import AppIndexViewModel from './app-index-view-appmenu-model';


/**
 * 应用首页视图默认菜单基类
 *
 * @export
 * @class AppIndexViewBase
 * @extends {AppMenusCtrlBase}
 */
export default class AppIndexViewBase extends AppMenusCtrlBase {

    /**
     * 建构部件服务对象
     *
     * @type {AppIndexViewService}
     * @memberof AppIndexView
     */
    public service: AppIndexViewService = new AppIndexViewService({ $store: this.$store });

    /**
     * 菜单对齐方向
     *
     * @type {CrmIndexService}
     * @memberof CrmIndex
     */
    protected menuAlign: string = '';

    /**
     * 菜单模型
     *
     * @protected
     * @type {AppIndexViewModel}
     * @memberof AppIndexView
     */
    protected menuModel: AppIndexViewModel = new AppIndexViewModel();

    /**
     * 触发方式，默认click
     *
     * @type {string}
     * @memberof AppIndexView
     */
    @Provide()
    public trigger: string = 'click';

    /**
     * 菜单点击
     *
     * @protected
     * @param {*} item 菜单数据
     * @memberof AppIndexView
     */
    protected click(item: any) {
        if (item) {
            switch (item.appfunctag) {
                case '_2': 
                    this.click_2(item);
                    return;
                default:
                    console.warn('未指定应用功能');
            }
        }
    }
    
    /**
     * 班级
     *
     * @param {*} [item={}]
     * @memberof AppIndexView
     */
    public click_2(item: any = {}) {
        const viewparam: any = {};
        Object.assign(viewparam, {});
        const deResParameters: any[] = [];
        const parameters: any[] = [
            { pathName: 'classes', parameterName: 'class' },
            { pathName: 'usr2editview', parameterName: 'usr2editview' },
        ];
        const path: string = this.$viewTool.buildUpRoutePath(this.$route, {}, deResParameters, parameters, [], viewparam);
        if(Object.is(this.$route.fullPath,path)){
            return;
        }
        this.$nextTick(function(){
            this.$router.push(path);
        })
    }

    public render(): any {
        return (
            <div class="app-app-menu">
                <app-menus menuAlign={this.menuAlign} menus={this.menus} on-menu-click={(item: any) => this.click(item)}/>
            </div>
        );
    }
    
}
</script>

<style lang='less'>
@import './app-index-view-appmenu.less';
</style>