<template>
  <app-layout viewName="emeqsparemaindashboardview9" viewTitle="备件包信息" :isShowCaptionBar="false" :isShowToolbar="false" :className="{ 'view-container': true, 'default-mode-view': true, 'deportalview9': true, 'emeqspare-main-dashboard-view9': true }" layoutMode="VIEW" :isShowUserInfo="isDefaultView()" :openMode="openMode" @close-view="closeView($event)">
    <template slot="headerLeft">
      <div class="view-header-left">

        <div class="view-caption" v-if="isDefaultView()">{{$t(model.srfCaption)}}</div>
        <modal-breadcrumb v-if="isModalView()"/>
      </div>
    </template>
    <template slot="content">
      <div class="view-content-wrapper">
                    <view_dashboard 
                :viewState="viewState"  
                :viewparams="viewparams" 
                :context="JSON.parse(JSON.stringify(context))" 
                :isEnableCustomized = "false"
                name="dashboard"  
                ref='dashboard' 
                @load="dashboard_load($event)"  
                @closeview="closeView($event)">
            </view_dashboard>

      </div>
    </template>
  </app-layout>
</template>

<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { UIActionTool, Util } from '@/utils';
import { VueLifeCycleProcessing, DashboardView9Base } from '@/crm-core';
import EMEQSpareService from '@/service/emeqspare/emeqspare-service';

import PortalView9Engine from '@engine/view/portal-view9-engine';


/**
 * 备件包信息基类
 *
 * @export
 * @class EMEQSpareMainDashboardView9Base
 * @extends {DashboardView9Base}
 */
@Component({})
@VueLifeCycleProcessing
export default class EMEQSpareMainDashboardView9Base extends DashboardView9Base {

    /**
     * 实体服务对象
     *
     * @type {EMEQSpareService}
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public appEntityService: EMEQSpareService = new EMEQSpareService;


    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof EMEQSpareMainDashboardView9Base
     */    
    public counterServiceArray:Array<any> = [];
    
    /**
     * 数据变化
     *
     * @param {*} val
     * @returns {*}
     * @memberof EMEQSpareMainDashboardView9Base
     */
    @Emit() 
    public viewDatasChange(val: any):any {
        return val;
    }

	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof EMEQSpareMainDashboardView9Base
	 */
	public viewtag: string = '4903396d56ac585de8cc7ef989d2f177';

    /**
     * 父数据对象
     *
     * @protected
     * @type {*}
     * @memberof EMEQSpareMainDashboardView9Base
     */
    protected srfparentdata: any = {};

	/**
	 * 自定义视图导航上下文集合
	 *
	 * @type {*}
	 * @memberof EMEQSpareMainDashboardView9Base
	 */
    public customViewNavContexts:any ={
    };

	/**
	 * 自定义视图导航参数集合
	 *
	 * @type {*}
	 * @memberof EMEQSpareMainDashboardView9Base
	 */
    public customViewParams:any ={
    };

    /**
     * 视图模型数据
     *
     * @type {*}
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public model: any = {
        srfCaption: 'entities.emeqspare.views.maindashboardview9.caption',
        srfTitle: 'entities.emeqspare.views.maindashboardview9.title',
        srfSubTitle: 'entities.emeqspare.views.maindashboardview9.subtitle',
        dataInfo: ''
    }

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public containerModel: any = {
        view_dashboard: { name: 'dashboard', type: 'DASHBOARD' },
    };

    /**
     * 视图状态订阅对象
     *
     * @public
     * @type {Subject<{action: string, data: any}>}
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public viewState: Subject<ViewState> = new Subject();


    /**
     * 视图引擎
     *
     * @public
     * @type {Engine}
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public engine: PortalView9Engine = new PortalView9Engine();
	

    /**
     * 引擎初始化
     *
     * @public
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public engineInit(): void {
        this.engine.init({
            view: this,
            dashboard: this.$refs.dashboard,
            keyPSDEField: 'emeqspare',
            majorPSDEField: 'emeqsparename',
            isLoadDefault: true,
        });
    }

    

    /**
     * dashboard 部件 load 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public dashboard_load($event: any, $event2?: any) {
        this.engine.onCtrlEvent('dashboard', 'load', $event);
    }





    /**
     * 销毁视图回调
     *
     * @memberof EMEQSpareMainDashboardView9Base
     */
    public destroyed(){
        if(this.viewDefaultUsage){
            let localStoreLength = Object.keys(localStorage);
            if(localStoreLength.length > 0){
                localStoreLength.forEach((item:string) =>{
                if(item.startsWith(this.context.srfsessionid)){
                    localStorage.removeItem(item);
                }
                })
            }
        }
    }

}
</script>

<style lang='less'>
@import './emeqspare-main-dashboard-view9.less';
</style>