<template>
  <app-layout viewName="emeqaheqcalendarexpview" viewTitle="设备活动日历导航视图" :isShowCaptionBar="false" :isShowToolbar="false" :className="{ 'view-container': true, 'default-mode-view': true, 'decalendarexpview': true, 'emeqaheq-calendar-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_calendarexpbar 
    :viewState="viewState"  
    :viewparams="viewparams" 
    :context="context" 
    :showBusyIndicator="true" 
    :viewUID="viewUID"
    :newdata="newdata"
    :opendata="opendata"
    name="calendarexpbar"  
    ref='calendarexpbar' 
    @selectionchange="calendarexpbar_selectionchange($event)"  
    @activated="calendarexpbar_activated($event)"  
    @load="calendarexpbar_load($event)"  
    @closeview="closeView($event)">
</view_calendarexpbar>

      </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, CalendarExpViewBase } from '@/crm-core';
import EMEQAHService from '@/service/emeqah/emeqah-service';

import CalendarExpViewEngine from '@engine/view/calendar-exp-view-engine';


/**
 * 设备活动日历导航视图基类
 *
 * @export
 * @class EMEQAHEqCalendarExpViewBase
 * @extends {CalendarExpViewBase}
 */
@Component({})
@VueLifeCycleProcessing
export default class EMEQAHEqCalendarExpViewBase extends CalendarExpViewBase {

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


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

	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof EMEQAHEqCalendarExpViewBase
	 */
	public viewtag: string = 'af462b2dc25c02bbb2147e2b870dcf21';

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

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

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

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

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof EMEQAHEqCalendarExpViewBase
     */
    public containerModel: any = {
        view_searchform: { name: 'searchform', type: 'SEARCHFORM' },
        view_calendarexpbar: { name: 'calendarexpbar', type: 'CALENDAREXPBAR' },
    };

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


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

    /**
     * 引擎初始化
     *
     * @public
     * @memberof EMEQAHEqCalendarExpViewBase
     */
    public engineInit(): void {
        this.engine.init({
            view: this,
            calendarexpbar: this.$refs.calendarexpbar,
            keyPSDEField: 'emeqah',
            majorPSDEField: 'emeqahname',
            isLoadDefault: true,
        });
    }

    

    /**
     * calendarexpbar 部件 selectionchange 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EMEQAHEqCalendarExpViewBase
     */
    public calendarexpbar_selectionchange($event: any, $event2?: any) {
        this.engine.onCtrlEvent('calendarexpbar', 'selectionchange', $event);
    }


    /**
     * calendarexpbar 部件 activated 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof EMEQAHEqCalendarExpViewBase
     */
    public calendarexpbar_activated($event: any, $event2?: any) {
        this.engine.onCtrlEvent('calendarexpbar', 'activated', $event);
    }


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



    /**
     * 打开新建数据视图
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [fullargs]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof EMEQAHEqCalendarExpView
     */
    public newdata(args: any[],fullargs?:any[], params?: any, $event?: any, xData?: any) {
        let localContext:any = null;
        let localViewParam:any =null;
        this.$Notice.warning({ title: '错误', desc: '向导添加未实现' });
    }


    /**
     * 打开编辑数据视图
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [fullargs]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof EMEQAHEqCalendarExpView
     */
    public opendata(args: any[],fullargs?:any[],params?: any, $event?: any, xData?: any) {
        let localContext:any = null;
        let localViewParam:any =null;
    this.$Notice.warning({ title: '错误', desc: '未指定关系视图' });
    }




    /**
     * 销毁视图回调
     *
     * @memberof EMEQAHEqCalendarExpViewBase
     */
    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);
                }
                })
            }
        }
    }

    /**
     * 视图唯一标识
     *
     * @type {string}
     * @memberof EMEQAHEqCalendarExpViewBase
     */
    public viewUID: string = 'eam-core-emeqaheq-calendar-exp-view';

}
</script>

<style lang='less'>
@import './emeqaheq-calendar-exp-view.less';
</style>