<template>
  <app-layout viewName="emplantabexpview" viewTitle="计划" :isShowToolbar="false" :className="{ 'view-container': true, 'default-mode-view': true, 'detabexpview': true, 'emplantab-exp-view': 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_tabexppanel 
    :viewState="viewState"  
    :viewparams="viewparams" 
    :context="context" 
    name="tabexppanel"  
    ref='tabexppanel' 
    @closeview="closeView($event)">
</view_tabexppanel>

      </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, TabExpViewBase } from '@/crm-core';
import EMPlanService from '@/service/emplan/emplan-service';

import TabExpViewEngine from '@engine/view/tab-exp-view-engine';


/**
 * 计划基类
 *
 * @export
 * @class EMPLANTabExpViewBase
 * @extends {TabExpViewBase}
 */
@Component({})
@VueLifeCycleProcessing
export default class EMPLANTabExpViewBase extends TabExpViewBase {

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

    /**
     * 数据变化
     *
     * @param {*} val
     * @returns {*}
     * @memberof EMPLANTabExpViewBase
     */
    @Emit() 
    public viewDatasChange(val: any):any {
        return val;
    }

	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof EMPLANTabExpViewBase
	 */
	public viewtag: string = '7f058dd8ad37ce1cb57ea0c71b3c6fcf';

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

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

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

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

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof EMPLANTabExpViewBase
     */
    public containerModel: any = {
        view_tabexppanel: { name: 'tabexppanel', type: 'TABEXPPANEL' },
    };

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


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

    /**
     * 引擎初始化
     *
     * @public
     * @memberof EMPLANTabExpViewBase
     */
    public engineInit(): void {
        this.engine.init({
            view: this,
            keyPSDEField: 'emplan',
            majorPSDEField: 'emplanname',
            isLoadDefault: true,
        });
    }





    /**
     * 销毁视图回调
     *
     * @memberof EMPLANTabExpViewBase
     */
    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 './emplantab-exp-view.less';
</style>