<template>
    <div :class='calendarClass'>
      <span class="quick-toolbar">
                    <div class='toolbar-container'>
                <tooltip :transfer="true" :max-width="600">
                        <i-button v-show="calendarviewcalendar_quicktoolbarModels.tbitem3.visabled" :disabled="calendarviewcalendar_quicktoolbarModels.tbitem3.disabled" class='' @click="calendar_quicktoolbar_click({ tag: 'tbitem3' }, $event)">
                            <i class='fa fa-file-text-o'></i>
                            <span class='caption'>{{$t('entities.emwo.calendarviewcalendar_quicktoolbar_toolbar.tbitem3.caption')}}</span>
                        </i-button>
                    <div slot='content'>{{$t('entities.emwo.calendarviewcalendar_quicktoolbar_toolbar.tbitem3.tip')}}</div>
                </tooltip>
                <tooltip :transfer="true" :max-width="600">
                        <i-button v-show="calendarviewcalendar_quicktoolbarModels.tbitem4.visabled" :disabled="calendarviewcalendar_quicktoolbarModels.tbitem4.disabled" class='' @click="calendar_quicktoolbar_click({ tag: 'tbitem4' }, $event)">
                            <i class='fa fa-edit'></i>
                            <span class='caption'>{{$t('entities.emwo.calendarviewcalendar_quicktoolbar_toolbar.tbitem4.caption')}}</span>
                        </i-button>
                    <div slot='content'>{{$t('entities.emwo.calendarviewcalendar_quicktoolbar_toolbar.tbitem4.tip')}}</div>
                </tooltip>
                <span class='seperator'>|</span>    <tooltip :transfer="true" :max-width="600">
                        <i-button v-show="calendarviewcalendar_quicktoolbarModels.tbitem8.visabled" :disabled="calendarviewcalendar_quicktoolbarModels.tbitem8.disabled" class='' @click="calendar_quicktoolbar_click({ tag: 'tbitem8' }, $event)">
                            <i class='fa fa-remove'></i>
                            <span class='caption'>{{$t('entities.emwo.calendarviewcalendar_quicktoolbar_toolbar.tbitem8.caption')}}</span>
                        </i-button>
                    <div slot='content'>{{$t('entities.emwo.calendarviewcalendar_quicktoolbar_toolbar.tbitem8.tip')}}</div>
                </tooltip>
            </div>
      </span>
    <span v-if="selections.length > 0" class="batch-toolbar">
                  <div class='toolbar-container'>
                <tooltip :transfer="true" :max-width="600">
                        <i-button v-show="calendarviewcalendar_batchtoolbarModels.deuiaction2.visabled" :disabled="calendarviewcalendar_batchtoolbarModels.deuiaction2.disabled" class='' @click="calendar_batchtoolbar_click({ tag: 'deuiaction2' }, $event)">
                            <i class='fa fa-remove'></i>
                            <span class='caption'>{{$t('entities.emwo.calendarviewcalendar_batchtoolbar_toolbar.deuiaction2.caption')}}</span>
                        </i-button>
                    <div slot='content'>{{$t('entities.emwo.calendarviewcalendar_batchtoolbar_toolbar.deuiaction2.tip')}}</div>
                </tooltip>
            </div>
    </span>
      <context-menu-container>
        <div class="event-legends">
          <div :class="{'event-lengend':true, 'EMWO_INNER':true, 'event-disabled':!isShowlegend.EMWO_INNER}" @click="legendTrigger('EMWO_INNER')">
            <div class="lengend-icon" style="background:rgba(0, 72, 255, 1);"></div>
            <span style="color:;">内部工单</span>
          </div>
          <div :class="{'event-lengend':true, 'EMWO_OSC':true, 'event-disabled':!isShowlegend.EMWO_OSC}" @click="legendTrigger('EMWO_OSC')">
            <div class="lengend-icon" style="background:rgba(255, 106, 0, 1);"></div>
            <span style="color:;">外委工单</span>
          </div>
          <div :class="{'event-lengend':true, 'EMWO_DP':true, 'event-disabled':!isShowlegend.EMWO_DP}" @click="legendTrigger('EMWO_DP')">
            <div class="lengend-icon" style="background:rgba(149, 117, 205, 1);"></div>
            <span style="color:;">点检工单</span>
          </div>
          <div :class="{'event-lengend':true, 'EMWO_EN':true, 'event-disabled':!isShowlegend.EMWO_EN}" @click="legendTrigger('EMWO_EN')">
            <div class="lengend-icon" style="background:rgba(0, 204, 255, 1);"></div>
            <span style="color:;">能耗工单</span>
          </div>
        </div>
        <FullCalendar
          ref="calendar"
          :locale="$i18n.locale"
          height="parent"
          :firstDay="1"
          :eventLimit="true"
          :editable="!isSelectFirstDefault && true"
          :buttonText="buttonText" 
          :header="header"
          :plugins="calendarPlugins"
          :events="searchEvents"
          :customButtons="customButtons"
          :validRange="validRange"
          :defaultDate="defaultDate"
          :eventRender="eventRender"
          @dateClick="onDateClick"
          @eventClick="onEventClick"
          @eventDrop="onEventDrop"
          defaultView="dayGridMonth"/>
          <modal v-model="modalVisible" width="250px" :title="$t('app.calendar.dateSelectModalTitle')" class-name='date-select-modal' @on-ok="gotoDate">
            <el-date-picker style="width: 200px;" v-model="selectedGotoDate" type="date"></el-date-picker>
          </modal>
      </context-menu-container>
    </div>
</template>


<script lang='tsx'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import EMWOService from '@/service/emwo/emwo-service';
import WoCalendarService from './wo-calendar-calendar-service';

import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import timeGridPlugin from '@fullcalendar/timegrid';
import listPlugin from '@fullcalendar/list';
import interactionPlugin from '@fullcalendar/interaction'
import ContextMenu from '@components/context-menu/context-menu'


@Component({
    components: {
      FullCalendar,

    }
})
export default class WoCalendarBase extends Vue implements ControlInterface {

    /**
     * 名称
     *
     * @type {string}
     * @memberof WoCalendarBase
     */
    @Prop() public name?: string;

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
     * @memberof WoCalendarBase
     */
    @Prop() public viewState!: Subject<ViewState>;

    /**
     * 应用上下文
     *
     * @type {*}
     * @memberof WoCalendarBase
     */
    @Prop() public context: any;

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof WoCalendarBase
     */
    @Prop() public viewparams: any;

    /**
     * 视图状态事件
     *
     * @public
     * @type {(Subscription | undefined)}
     * @memberof WoCalendarBase
     */
    public viewStateEvent: Subscription | undefined;

    /**
     * 获取部件类型
     *
     * @returns {string}
     * @memberof WoCalendarBase
     */
    public getControlType(): string {
        return 'CALENDAR'
    }



    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof WoCalendarBase
     */    
    public counterServiceArray:Array<any> = [];

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

    /**
     * 实体服务对象
     *
     * @type {EMWOService}
     * @memberof WoCalendarBase
     */
    public appEntityService: EMWOService = new EMWOService({ $store: this.$store });

    /**
     * calendar_quicktoolbar 部件 click 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof WoCalendarBase
     */
    public calendar_quicktoolbar_click($event: any, $event2?: any) {
        if (Object.is($event.tag, 'tbitem3')) {
            this.calendar_quicktoolbar_tbitem3_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem4')) {
            this.calendar_quicktoolbar_tbitem4_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem5')) {
            this.calendar_quicktoolbar_tbitem5_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem24')) {
            this.calendar_quicktoolbar_tbitem24_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem25')) {
            this.calendar_quicktoolbar_tbitem25_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem8')) {
            this.calendar_quicktoolbar_tbitem8_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem13')) {
            this.calendar_quicktoolbar_tbitem13_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem11')) {
            this.calendar_quicktoolbar_tbitem11_click(null, 'calendar_quicktoolbar', $event2);
        }
        if (Object.is($event.tag, 'tbitem19')) {
            this.calendar_quicktoolbar_tbitem19_click(null, 'calendar_quicktoolbar', $event2);
        }
    }

    /**
     * cm 部件 click 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof WoCalendarBase
     */
    public cm_click($event: any, $event2?: any) {
        if (Object.is($event.tag, 'deuiaction1')) {
            this.cm_deuiaction1_click(null, 'cm', $event2);
        }
        if (Object.is($event.tag, 'deuiaction2')) {
            this.cm_deuiaction2_click(null, 'cm', $event2);
        }
    }

    /**
     * calendar_batchtoolbar 部件 click 事件
     *
     * @param {*} [args={}]
     * @param {*} $event
     * @memberof WoCalendarBase
     */
    public calendar_batchtoolbar_click($event: any, $event2?: any) {
        if (Object.is($event.tag, 'deuiaction1')) {
            this.calendar_batchtoolbar_deuiaction1_click(null, 'calendar_batchtoolbar', $event2);
        }
        if (Object.is($event.tag, 'deuiaction2')) {
            this.calendar_batchtoolbar_deuiaction2_click(null, 'calendar_batchtoolbar', $event2);
        }
    }
    

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem3_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.New(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem4_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.Edit(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem5_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.View(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem24_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.ToggleRowEdit(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem25_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.NewRow(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem8_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.Remove(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem13_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.ExportExcel(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem11_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.Print(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_quicktoolbar_tbitem19_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.ToggleFilter(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_batchtoolbar_deuiaction1_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.View(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public calendar_batchtoolbar_deuiaction2_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.Remove(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public cm_deuiaction1_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.View(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public cm_deuiaction2_click(params: any = {}, tag?: any, $event?: any) {
        // 参数
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        this.Remove(datas, contextJO,paramJO,  $event, xData,this,"EMWO");
    }

    /**
     * 新建
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public New(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
         const _this: any = this;
        if (_this.newdata && _this.newdata instanceof Function) {
            const data: any = {};
            _this.newdata([{ ...data }],[{ ...data }], params, $event, xData);
        } else {
            _this.$Notice.error({ title: '错误', desc: 'newdata 视图处理逻辑不存在，请添加!' });
        }
    }
    /**
     * 编辑
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public Edit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        if (args.length === 0) {
            return;
        }
        const _this: any = this;
        if (_this.opendata && _this.opendata instanceof Function) {
            const data: any = { };
            if (args.length > 0) {
                Object.assign(data, { emwo: args[0].emwo })
            }
            _this.opendata([{ ...data }], params, $event, xData);
        } else {
            _this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在，请添加!' });
        }
    }
    /**
     * 查看
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public View(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        if (args.length === 0) {
            return;
        }
        const _this: any = this;
        if (_this.opendata && _this.opendata instanceof Function) {
            const data: any = { };
            if (args.length > 0) {
                Object.assign(data, { emwo: args[0].emwo })
            }
            _this.opendata([{ ...data }], params, $event, xData);
        } else {
            _this.$Notice.error({ title: '错误', desc: 'opendata 视图处理逻辑不存在，请添加!' });
        }
    }
    /**
     * 行编辑
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public ToggleRowEdit(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        xData.actualIsOpenEdit = !xData.actualIsOpenEdit;
    }
    /**
     * 新建行
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public NewRow(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        const _this: any = this;
        const data: any = {};
        if (_this.newRow && _this.newRow instanceof Function) {
            _this.newRow([{ ...data }], params, $event, xData);
        } else if(xData.newRow && xData.newRow instanceof Function) {
            xData.newRow([{ ...data }], params, $event, xData);
        }else{
            _this.$Notice.error({ title: '错误', desc: 'newRow 视图处理逻辑不存在，请添加!' });
        }
    }
    /**
     * 删除
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public Remove(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        const _this: any = this;
        if (!xData || !(xData.remove instanceof Function)) {
            return ;
        }
        xData.remove(args);
    }

    /**
     * 导出
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public ExportExcel(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        const _this: any = this;
        if (!xData || !(xData.exportExcel instanceof Function) || !$event) {
            return ;
        }
        xData.exportExcel($event.exportparms);
    }
    /**
     * 打印
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public Print(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        let _this:any = this;
        if (!xData || !(xData.print instanceof Function) || !$event) {
            return ;
        }
        xData.print();
    }
    /**
     * 过滤
     *
     * @param {any[]} args 当前数据
     * @param {any} contextJO 行为附加上下文
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @memberof EMWOCalendarViewBase
     */
    public ToggleFilter(args: any[],contextJO?:any, params?: any, $event?: any, xData?: any,actionContext?:any,srfParentDeName?:string) {
        const _this: any = this;
        if (_this.hasOwnProperty('isExpandSearchForm')) {
            _this.isExpandSearchForm = !_this.isExpandSearchForm;
        }
    }

    /**
     * 关闭视图
     *
     * @param {any} args
     * @memberof WoCalendarBase
     */
    public closeView(args: any): void {
        let _this: any = this;
        _this.$emit('closeview', [args]);
    }

    /**
     *  计数器刷新
     *
     * @memberof WoCalendarBase
     */
    public counterRefresh(){
        const _this:any =this;
        if(_this.counterServiceArray && _this.counterServiceArray.length >0){
            _this.counterServiceArray.forEach((item:any) =>{
                if(item.refreshData && item.refreshData instanceof Function){
                    item.refreshData();
                }
            })
        }
    }


    /**
     * 是否默认选中第一条数据
     *
     * @type {boolean}
     * @memberof WoCalendarBase
     */
    @Prop({ default: false }) public isSelectFirstDefault!: boolean;

    /**
     * 显示处理提示
     *
     * @type {boolean}
     * @memberof WoCalendarBase
     */
    @Prop({ default: true }) public showBusyIndicator?: boolean;

    /**
     * 部件行为--load
     *
     * @type {string}
     * @memberof WoCalendarBase
     */
    @Prop() public loadAction!: string;

    /**
     * 打开新建数据视图
     *
     * @type {any}
     * @memberof WoCalendarBase
     */
    @Prop() public newdata: any;
    /**
     * 打开编辑数据视图
     *
     * @type {any}
     * @memberof WoCalendarBase
     */
    @Prop() public opendata: any;

    /**
     * 日历部件样式名
     *
     * @public
     * @type {any[]}
     * @memberof WoCalendarBase
     */
    public calendarClass: string = "calendar";

    /**
     * 选中事件element元素
     *
     * @public
     * @type {any[]}
     * @memberof WoCalendarBase
     */
    public selectedEventElement:any;

    /**
     * 引用插件集合
     *
     * @public
     * @type {any[]}
     * @memberof WoCalendarBase
     */
    public calendarPlugins: any[] = [
        dayGridPlugin, 
        timeGridPlugin, 
        listPlugin, 
        interactionPlugin
    ];

    /**
     * 设置头部显示
     *
     * @public
     * @type {}
     * @memberof WoCalendarBase
     */
    public header: any = {
        left: 'prev,next today gotoDate',
        center: 'title',
        right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
    };

    /**
     * 按钮文本集合
     *
     * @public
     * @type {}
     * @memberof WoCalendarBase
     */
    public buttonText: any = {
        today: '今天',
        month: '月',
        week: '周',
        day: '天',
        list: '列'
    };

    /**
     * 自定义按钮集合
     *
     * @public
     * @type {}
     * @memberof WoCalendarBase
     */
    public customButtons: any = {
        gotoDate: {
          text: "跳转",
          click: this.openDateSelect
        }
    };

    /**
     * 模态显示控制变量
     *
     * @public
     * @type boolean
     * @memberof WoCalendarBase
     */
    public modalVisible: boolean = false;

    /**
     * 跳转日期
     *
     * @public
     * @type Date
     * @memberof WoCalendarBase
     */
    public selectedGotoDate: Date = new Date();

    /**
     * 打开时间选择模态
     *
     * @public
     * @memberof WoCalendarBase
     */
    public openDateSelect(){
        this.modalVisible = true;
    }

    /**
     * 跳转到指定时间
     *
     * @public
     * @memberof WoCalendarBase
     */
    public gotoDate(){
        let appCalendar: any = this.$refs.calendar;
        let api = appCalendar.getApi();
        api.gotoDate(this.selectedGotoDate);
    }

    /**
     * 有效日期范围
     *
     * @public
     * @type {}
     * @memberof WoCalendarBase
     */
    public validRange: any = {
        start:"0000-01-01",
        end:"9999-12-31"
    };

    /**
     * 默认加载日期
     *
     * @public
     * @type {}
     * @memberof WoCalendarBase
     */
    public defaultDate: any = this.$util.dateFormat(new Date());

    /**
     * 设置按钮文本
     *
     * @public
     * @memberof WoCalendarBase
     */
    public setButtonText(){
        this.buttonText.today = this.$t('app.calendar.today'),
        this.buttonText.month = this.$t('app.calendar.month'),
        this.buttonText.week = this.$t('app.calendar.week'),
        this.buttonText.day = this.$t('app.calendar.day'),
        this.buttonText.list = this.$t('app.calendar.list')
        this.customButtons.gotoDate.text = this.$t('app.calendar.gotoDate')
    }

    /**
     * 监听语言变化
     *
     * @public
     * @memberof WoCalendarBase
     */
    @Watch('$i18n.locale')
    public onLocaleChange(newval: any, val: any) {
        this.setButtonText();
    }

    /**
     * 日程事件集合
     *
     * @public
     * @type {any[]}
     * @memberof WoCalendarBase
     */
    public events: any[] = [];

    /**
     * 日历样式类型
     *
     * @public
     * @type {string}
     * @memberof WoCalendarBase
     */
    public calendarType: string = "MONTH";

    /**
     * 图例显示控制
     *
     * @public
     * @type {any}
     * @memberof WoCalendarBase
     */
    public isShowlegend: any = {
        EMWO_INNER:true,
        EMWO_OSC:true,
        EMWO_DP:true,
        EMWO_EN:true,
    };

    /**
     * 图例点击事件
     *
     * @public
     * @memberof WoCalendarBase
     */
    legendTrigger(itemType:string){
        this.isShowlegend[itemType] = !this.isShowlegend[itemType];
        this.refresh();
    }

    /**
     * 查询参数缓存
     *
     * @public
     * @type {any}
     * @memberof WoCalendarBase
     */
    public searchArgCache: any = {};

    /**
     * 搜索获取日程事件
     *
     * @param {*} $event 日期信息
     * @memberof WoCalendarBase
     */
    public searchEvents(fetchInfo?:any, successCallback?:any, failureCallback?:any ) {
        // 处理请求参数
        let start = (fetchInfo && fetchInfo.start) ? this.$util.dateFormat(fetchInfo.start) : null;
        let end = (fetchInfo && fetchInfo.end) ? this.$util.dateFormat(fetchInfo.end) : null;
        let arg = { start: start, end: end };
        if(fetchInfo && fetchInfo.query){
            Object.assign(arg,{query : fetchInfo.query});
        }
        Object.assign(arg,{viewparams:this.viewparams});
        const parentdata: any = {};
        this.$emit('beforeload', parentdata);
        Object.assign(arg, parentdata);
        // 处理events数据
        let _this = this;
        let handleEvents = ()=>{
            if(_this.isSelectFirstDefault){
                // 模拟$event数据
                let tempEvent = JSON.parse(JSON.stringify(_this.events.length > 0?_this.events[0]:{}));
                _this.onEventClick(tempEvent,true);
                if(_this.events.length > 0){
                    _this.events[0].className = "select-first-event";
                }
                _this.calendarClass = "calendar select-first-calendar";
            }
            let filterEvents = this.events.filter((event:any)=>{
                return _this.isShowlegend[event.itemType];
            });

            if(successCallback){
                successCallback(filterEvents);
            }
            // 刷新日历的大小（仅fullcalendar组件使用）
            if(!Object.is(_this.calendarType,"TIMELINE")){
                let appCalendar: any = _this.$refs.calendar;
                let api = appCalendar.getApi();
                api.updateSize();
            }
        }
        if(JSON.stringify(arg) === JSON.stringify(this.searchArgCache)){
            handleEvents();
            return;
        }else{
            this.searchArgCache = arg;
        }
        const post: Promise<any> = this.service.search(this.loadAction, JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
        post.then((response: any) => {
            if (!response || response.status !== 200) {
                if (response.errorMessage) {
                    this.$Notice.error({ title: '错误', desc: response.errorMessage });
                }
                return;
            }
            // 默认选中第一项
            this.events = response.data;
            handleEvents();
        }, (response: any) => {
            if (response && response.status === 401) {
                return;
            }
            this.$Notice.error({ title: '错误', desc: response.errorMessage });
        });
    }

    /**
     * 日期点击事件
     *
     * @param {*} $event 日期信息
     * @memberof WoCalendarBase
     */
    public onDateClick($event: any) {
        let date = $event.date;
        let datestr = $event.dateStr;
    }

    /**
     * 获取编辑视图信息
     *
     * @param {*} $event 事件信息
     * @memberof WoCalendarBase
     */
    public getEditView(deName: string) {
        let view: any = {};
        switch(deName){
        }
        return view;
    }

    /**
     * 日程点击事件
     *
     * @param {*} $event calendar事件对象或event数据
     * @param {*} isOriginData true：$event是原始event数据，false：是组件
     * @param {*} $event timeline事件对象
     * @memberof WoCalendarBase
     */
    public onEventClick($event: any, isOriginData:boolean = false, $event2?: any) {
        // 处理event数据
        let event: any = {};
        if(isOriginData){
            event = JSON.parse(JSON.stringify($event));
        }else{
            event = Object.assign({title: $event.event.title, start: $event.event.start, end: $event.event.end}, $event.event.extendedProps);
        }
        // 点击选中样式
        let JSelement:any = null;
        if(!isOriginData && $event.el){
            JSelement = $event.el;
        }else if(isOriginData && $event2 && $event2.currentTarget){
            JSelement = $event2.currentTarget;
        }
        if(JSelement){
            this.calendarClass = "calendar";
            if(this.selectedEventElement){
                this.selectedEventElement.classList.remove("selected-event");
            }
            this.selectedEventElement = JSelement;
            this.selectedEventElement.classList.add("selected-event");
        }
        // 处理上下文数据
        let _this = this;
        let view: any = {};
        let _context: any = Object.assign({},this.context);
        switch(event.itemType) {
            case "EMWO_INNER":
                _context.emwo_inner = event.emwo_inner;
                view = this.getEditView("emwo_inner");
                break;
            case "EMWO_OSC":
                _context.emwo_osc = event.emwo_osc;
                view = this.getEditView("emwo_osc");
                break;
            case "EMWO_DP":
                _context.emwo_dp = event.emwo_dp;
                view = this.getEditView("emwo_dp");
                break;
            case "EMWO_EN":
                _context.emwo_en = event.emwo_en;
                view = this.getEditView("emwo_en");
                break;
        }
        this.selections = [event];
        // 导航栏中不需要打开视图，只要抛出选中数据
        if(this.isSelectFirstDefault){
            this.$emit("selectionchange",this.selections);
            return;
        }
        // 根据打开模式打开视图
        if(!view.viewname){
            return;
        } else if (Object.is(view.placement, 'INDEXVIEWTAB') || Object.is(view.placement, '')) {
            const routePath = this.$viewTool.buildUpRoutePath(this.$route, this.context, view.deResParameters, view.parameters, [JSON.parse(JSON.stringify(_context))] , JSON.parse(JSON.stringify(this.viewparams)));
            this.$router.push(routePath);
        } else {
            let container: Subject<any> = new Subject();
            if (Object.is(view.placement, 'POPOVER')) {
                container = this.$apppopover.openPop(isOriginData ? $event2 : $event.jsEvent, view,JSON.parse(JSON.stringify(_context)),  JSON.parse(JSON.stringify(this.viewparams)));
            } else if (Object.is(view.placement, 'POPUPMODAL')) {
                container = this.$appmodal.openModal(view,  JSON.parse(JSON.stringify(_context)),  JSON.parse(JSON.stringify(this.viewparams)));
            } else if (view.placement.startsWith('DRAWER')) {
                container = this.$appdrawer.openDrawer(view,  JSON.parse(JSON.stringify(_context)),  JSON.parse(JSON.stringify(this.viewparams)));
            }
            container.subscribe((result: any) => {
                if (!result || !Object.is(result.ret, 'OK')) {
                    return;
                }
                // 刷新日历
                _this.refresh();
            });
        }
    }

    /**
     * 日历刷新
     *
     * @memberof WoCalendarBase
     */
    public refresh() {
        if(Object.is(this.calendarType,"TIMELINE")){
            this.searchEvents();
        } else {
            let calendarApi = (this.$refs.calendar as any).getApi();
            calendarApi.refetchEvents();
        }
    }

    /**
     * 日程拖动事件
     *
     * @param {*} $event 事件信息
     * @memberof WoCalendarBase
     */
    public onEventDrop($event: any) {
        if(this.isSelectFirstDefault){
          return;
        }
        let arg: any = {};
        let _context: any = Object.assign({},this.context);
        arg.start = this.$util.dateFormat($event.event.start);
        arg.end = this.$util.dateFormat($event.event.end);
        let itemType = $event.event._def.extendedProps.itemType;
        switch(itemType) {
            case "EMWO_INNER":
                arg.emwo_inner = $event.event._def.extendedProps.emwo_inner;
                _context.emwo_inner = $event.event._def.extendedProps.emwo_inner;
                break;
            case "EMWO_OSC":
                arg.emwo_osc = $event.event._def.extendedProps.emwo_osc;
                _context.emwo_osc = $event.event._def.extendedProps.emwo_osc;
                break;
            case "EMWO_DP":
                arg.emwo_dp = $event.event._def.extendedProps.emwo_dp;
                _context.emwo_dp = $event.event._def.extendedProps.emwo_dp;
                break;
            case "EMWO_EN":
                arg.emwo_en = $event.event._def.extendedProps.emwo_en;
                _context.emwo_en = $event.event._def.extendedProps.emwo_en;
                break;
        }
        Object.assign(arg,{viewparams:this.viewparams});
        const post: Promise<any> = this.service.update(itemType, JSON.parse(JSON.stringify(_context)), arg, this.showBusyIndicator);
        post.then((response: any) => {
            if (!response || response.status !== 200) {
                if (response.errorMessage) {
                    this.$Notice.error({ title: '错误', desc: response.errorMessage });
                }
                return;
            }
        }, (response: any) => {
            if (response && response.status === 401) {
                return;
            }
            this.$Notice.error({ title: '错误', desc: response.errorMessage });
        });
    }

    /**
     * 选中的数据
     *
     * @returns {any[]}
     * @memberof WoCalendarBase
     */
    public selections: any[] = [];

    /**
     * 应用状态事件
     *
     * @public
     * @type {(Subscription | undefined)}
     * @memberof WoCalendarBase
     */
    public appStateEvent: Subscription | undefined;

    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof WoCalendarBase
     */
    public getDatas(): any[] {
        return this.selections;
    }

    /**
     * 获取单项数据
     *
     * @returns {*}
     * @memberof WoCalendarBase
     */
    public getData(): any {
        return null;
    }
             
    /**
     * vue 生命周期
     *
     * @returns
     * @memberof WoCalendarBase
     */
    public created() {
        this.setButtonText();
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof WoCalendarBase
     */    
    public afterCreated(){
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
            });
        }
        if(AppCenterService && AppCenterService.getMessageCenter()){
            this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
                if(!Object.is(name,"EMWO")){
                    return;
                }
                if(Object.is(action,'appRefresh')){
                    this.refresh();
                }
            })
        }
    }


    /**
     * vue 生命周期
     *
     * @memberof WoCalendarBase
     */
    public mounted(){
        this.afterMounted();
    }

    /**
     * 执行mounted后的逻辑
     *
     * @memberof WoCalendarBase
     */
    public afterMounted(){
        let appCalendar: any = this.$refs.calendar;
        if(appCalendar){
            let api = appCalendar.getApi();
            api.updateSize()
        }
    }

    /**
     * vue 生命周期
     *
     * @memberof WoCalendarBase
     */
    public destroyed() {
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof WoCalendarBase
     */
    public afterDestroy() {
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        if(this.appStateEvent){
            this.appStateEvent.unsubscribe();
        }
    }

          /**
     * 工具栏模型
     *
     * @type {*}
     * @memberof EMWOCalendarView
     */
    public calendarviewcalendar_quicktoolbarModels: any = {
        tbitem3: { name: 'tbitem3', caption: '新建','isShowCaption':true,'isShowIcon':true, tooltip: '新建', iconcls: 'fa fa-file-text-o', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'New', target: '' }, class: '' },

        tbitem4: { name: 'tbitem4', caption: '编辑','isShowCaption':true,'isShowIcon':true, tooltip: '编辑', iconcls: 'fa fa-edit', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'Edit', target: 'SINGLEKEY' }, class: '' },

        tbitem7: {  name: 'tbitem7', type: 'SEPERATOR', visabled: true, dataaccaction: '', uiaction: { }, class: '' },
        tbitem8: { name: 'tbitem8', caption: '删除','isShowCaption':true,'isShowIcon':true, tooltip: '删除', iconcls: 'fa fa-remove', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'Remove', target: 'MULTIKEY' }, class: '' },

    };


          /**
     * 工具栏模型
     *
     * @type {*}
     * @memberof EMWOCalendarView
     */
    public calendarviewcalendar_batchtoolbarModels: any = {
        deuiaction2: { name: 'deuiaction2', caption: '删除','isShowCaption':true,'isShowIcon':true, tooltip: '删除', iconcls: 'fa fa-remove', icon: '', disabled: false, type: 'DEUIACTION', visabled: true, dataaccaction: '', uiaction: { tag: 'Remove', target: 'MULTIKEY' }, class: '' },

    };

    
    /**
     * 事件绘制回调
     *
     * @param {*} info 信息
     * @memberof WoCalendarBase
     */
    public eventRender(info?:any,) {
        let data = Object.assign({title: info.event.title, start: info.event.start, end: info.event.end}, info.event.extendedProps);
        info.el.addEventListener('contextmenu', (event: MouseEvent) => {
            event.preventDefault();
            let props = { data: data, renderContent: this.renderContextMenu };
            let component = ContextMenu;
            const vm:any = new Vue({
                render(h) {
                    return h(component, { props });
                }
            }).$mount();
            document.body.appendChild(vm.$el);
            const comp: any = vm.$children[0];
            comp.showContextMenu(event.clientX, event.clientY);
        });
    }

    /**
     * 绘制右键菜单
     *
     * @param {*} event
     * @returns
     * @memberof WoCalendarBase
     */
    public renderContextMenu(event: any) {
        let content;
        if (event && event.itemType) {
            const data: any = JSON.parse(JSON.stringify(event));
            this.selections = [event];
            switch(event.itemType){
            case "EMWO_INNER":
                content = this.renderContextMenuEmwo_inner();
                break;
            }
        }
        return content;
    }

    /**
     * 绘制EMWO_INNER类型右键菜单
     *
     * @returns
     * @memberof WoCalendarBase
     */
    public renderContextMenuEmwo_inner() {
        return (
                      <dropdown class="tree-right-menu" trigger="custom" visible={true} on-on-click={($event: any) => this.cm_click({tag: $event})}>
                <dropdown-menu slot="list">
                            <dropdown-item name="deuiaction2">
                        <i class='fa fa-remove'></i>
                        删除
                    </dropdown-item>
                </dropdown-menu>
            </dropdown>
        );
    }

}
</script>

<style lang='less'>
@import './wo-calendar-calendar.less';
</style>