<template>
<div class='view-container decalendarview emwocalendar-view'>
    <app-studioaction :viewTitle="$t(model.srfTitle)" viewName="emwocalendarview"></app-studioaction>
    <card class='view-card view-no-caption  view-no-toolbar'  :bordered="false" :dis-hover="true" >
    

        <div class='content-container'>

<view_calendar 
    :viewState="viewState"  
    :viewparams="viewparams" 
    :context="context" 
    :showBusyIndicator="true"
    @beforeload="onBeforeLoad($event)" 
    :newdata="newdata"
    :opendata="opendata"
    name="calendar"  
    ref='calendar' 
    @closeview="closeView($event)">
</view_calendar>

        </div>
    </card>
</div>
</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, ListView9Base } from '@/crm-core';
import EMWOService from '@/service/emwo/emwo-service';


import CodeListService from "@service/app/codelist-service";


/**
 * 工单日历视图基类
 *
 * @export
 * @class EMWOCalendarViewBase
 * @extends {ListView9Base}
 */
@Component({})
@VueLifeCycleProcessing
export default class EMWOCalendarViewBase extends ListView9Base {

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


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

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

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

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

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

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

    /**
     * 容器模型
     *
     * @type {*}
     * @memberof EMWOCalendarViewBase
     */
    public containerModel: any = {
        view_calendar: { name: 'calendar', type: 'CALENDAR' },
    };

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



	

    /**
     * 引擎初始化
     *
     * @public
     * @memberof EMWOCalendarViewBase
     */
    public engineInit(): void {
    }

    


    /**
     * 打开新建数据视图
     *
     * @param {any[]} args
     * @param {*} [params]
     * @param {*} [fullargs]
     * @param {*} [$event]
     * @param {*} [xData]
     * @memberof EMWOCalendarView
     */
    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 EMWOCalendarView
     */
    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 EMWOCalendarViewBase
     */
    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 EMWOCalendarViewBase
     */
    public query: string = '';

    /**
     * 是否展开搜索表单
     *
     * @type {boolean}
     * @memberof EMWOCalendarViewBase
     */
    public isExpandSearchForm: boolean = false;

    /**
     * 快速搜索
     *
     * @param {*} $event
     * @memberof EMWOCalendarViewBase
     */
    public onSearch($event: any): void {
        const refs: any = this.$refs;
        if (refs.calendar) {
            refs.calendar.refresh();
        }
    }

    /**
     * calendar 的 beforeload 事件
     *
     * @param {*} arg
     * @memberof EMWOCalendarViewBase
     */
    public onBeforeLoad(arg: any){
        let _this:any = this;
        if (_this.viewparams && Object.keys(_this.viewparams).length > 0) {
            Object.assign(arg, _this.viewparams);
        }
        if (_this.$refs.searchform && _this.isExpandSearchForm) {
            Object.assign(arg, _this.$refs.searchform.getData());
        }
        if (_this && !_this.isExpandSearchForm) {
            Object.assign(arg, { query: _this.query });
        }
        // 快速分组和快速搜索栏
        let otherQueryParam:any = {};
        if(_this && (_this.quickGroupData as any)){
            Object.assign(otherQueryParam,_this.quickGroupData);
        }
        if(_this && _this.quickFormData){
            Object.assign(otherQueryParam,_this.quickFormData);
        }
        Object.assign(arg,{viewparams:otherQueryParam});
    }

    /**
     * searchform 部件 search 事件
     *
     * @param {*} $event
     * @memberof EMWOCalendarViewBase
     */
    public searchform_search($event: any) {
        this.onSearch($event);
    }

    /**
     * searchform 部件 load 事件
     *
     * @param {*} $event
     * @memberof EMWOCalendarViewBase
     */
    public searchform_load($event: any) {
        this.onSearch($event);
    }



}
</script>

<style lang='less'>
@import './emwocalendar-view.less';
</style>