order-calendar-navigation-calendar-base.vue 31.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
<template>
    <div :class='calendarClass'>
      <context-menu-container>
        <template>
        <div class="event-legends">
          <div :class="{'event-lengend':true, 'item1':true, 'event-disabled':!isShowlegend.item1}" @click="legendTrigger('item1')">
            <div class="lengend-icon" style="background:;"></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"
          :displayEventTime="displayEventTime"
          :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>
        </template>
      </context-menu-container>
    </div>
</template>
// 基于 @CONTROL/日历部件/CONTROL-BASE.vue.ftl 生成


<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,ViewTool } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import IBIZOrderEntityService from '@/service/ibizorder/ibizorder-service';
import OrderCalendarNavigationService from './order-calendar-navigation-calendar-service';
import IBIZOrderUIService from '@/uiservice/ibizorder/ibizorder-ui-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';
import UIService from '@/uiservice/ui-service';


@Component({
    components: {
      FullCalendar,

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

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

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

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

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

    /**
     * 视图操作参数(父级)
     *
     * @type {*}
     * @memberof OrderCalendarNavigationBase
     */
    @Prop() public pViewCtx!: any;

    /**
     * 视图操作参数
     *
     * @type {*}
     * @memberof OrderCalendarNavigationBase
     */
    public viewCtx: any = {};

    /**
     * 监听视图操作参数变化
     *
     * @type {*}
     * @memberof OrderCalendarNavigationBase
     */
    @Watch('pViewCtx', { immediate: true })
    public onViewCtxChange(newVal: any, oldVal: any) {
        Object.assign(this.viewCtx, newVal, { xData: this, ctrl: this });
    }

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

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



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

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

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


    /**
     * 转化数据
     *
     * @param {any} args
     * @memberof  OrderCalendarNavigationBase
     */
    public transformData(args: any) {
        let _this: any = this;
        if(_this.service && _this.service.handleRequestData instanceof Function && _this.service.handleRequestData('transform',_this.context,args)){
            return _this.service.handleRequestData('transform',_this.context,args)['data'];
        }
    }

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

    /**
     *  计数器刷新
     *
     * @memberof OrderCalendarNavigationBase
     */
    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();
                }
            })
        }
    }
    /**
     *  处理部件事件
     *
     * @memberof OrderCalendarNavigationBase
     */
    public async handleCtrlEvents(eventName: string, args: any = {}): Promise<boolean> {
        const actionData = {
            data: this.getData() || {},
            context: Util.deepCopy(this.context),
            viewparams: Util.deepCopy(this.viewparams),
            xData: this
        }
        let result: boolean = true;
        Object.assign(actionData, args);
        if ('selectionchange'.indexOf(eventName) !== -1) {
            result = await this.execute_calendarexpbar_selectionchange_ctrl_logic(actionData) && result;
        }
        if ('load'.indexOf(eventName) !== -1) {
            result = await this.execute_calendarexpbar_load_ctrl_logic(actionData) && result;
        }
        if (!result) {
            return false;
        }
        this.$emit(eventName, actionData);
        return true;
    }

    /**
     * 部件逻辑 -- calendarexpbar_selectionchange
     *
     * @param {string} eventName 部件事件名称
     * @param {any[]} data 数据
     * @param {*} event 源事件对象
     * @memberof OrderCalendarNavigationBase
     */
    public async execute_calendarexpbar_selectionchange_ctrl_logic(actionData: any): Promise<boolean> {
        console.log('暂未支持 CUSTOM 类型');
        return true;
    }
    /**
     * 部件逻辑 -- calendarexpbar_load
     *
     * @param {string} eventName 部件事件名称
     * @param {any[]} data 数据
     * @param {*} event 源事件对象
     * @memberof OrderCalendarNavigationBase
     */
    public async execute_calendarexpbar_load_ctrl_logic(actionData: any): Promise<boolean> {
        console.log('暂未支持 CUSTOM 类型');
        return true;
    }



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

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

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

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

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

    /**
     * this引用
     *
     * @type {any}
     * @memberof OrderCalendarNavigationBase
     */
    public thisRef: any = this;

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

    /**
     * 是否显示事件时也显示时间
     *
     * @public
     * @type {boolean}
     * @memberof OrderCalendarNavigationBase
     */
    public displayEventTime: boolean = true;

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

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

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

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

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

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

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

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

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

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

    /**
     * 设置按钮文本
     *
     * @public
     * @memberof OrderCalendarNavigationBase
     */
    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 OrderCalendarNavigationBase
     */
    @Watch('$i18n.locale')
    public onLocaleChange(newval: any, val: any) {
        this.setButtonText();
    }

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

    /**
     * 日历项上下文菜单集合
     *
     * @type {string[]}
     * @memberof OrderCalendarNavigationBase
     */
     public actionModel: any = {
    }

    /**
     * 备份日历项上下文菜单
     *
     * @type {string[]}
     * @memberof OrderCalendarNavigationBase
     */
     public copyActionModel: any;

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

    /**
     * 图例显示控制
     *
     * @public
     * @type {any}
     * @memberof OrderCalendarNavigationBase
     */
    public isShowlegend: any = {
        item1:true,
    };

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

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


    /**
     * 搜索获取日程事件
     *
     * @param {*} $event 日期信息
     * @memberof OrderCalendarNavigationBase
     */
    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});
        }
        const parentdata: any = {};
        this.$emit('beforeload', parentdata);
        Object.assign(arg, parentdata);
        let tempViewParams: any = parentdata.viewparams ? parentdata.viewparams : {};
        Object.assign(tempViewParams, JSON.parse(JSON.stringify(this.viewparams)));
        Object.assign(arg, { viewparams: tempViewParams });
        // 处理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;
        }
        this.handleCtrlEvents('onbeforeload', { viewparams: arg }).then((beforeLoadRes: boolean) => {
            if (!beforeLoadRes) {
                return;
            }
            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) {
                    this.handleCtrlEvents('onloaderror', { viewparams: arg }).then((loadErrorRes: boolean) => {
                        if (!loadErrorRes) {
                            return;
                        }
                        if (response.data && response.data.message) {
                            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
                        }
                    });
                    return;
                }
                this.handleCtrlEvents('onloadsuccess', { data: response.data }).then((loadSuccessRes: boolean) => {
                    if (!loadSuccessRes) {
                        return;
                    }
                    // 默认选中第一项
                    this.events = response.data;
                    handleEvents();
                })
            }, (response: any) => {
                this.handleCtrlEvents('onloaderror', { viewparams: arg }).then((loadErrorRes: boolean) => {
                    if (!loadErrorRes) {
                        return;
                    }
                    if (response && response.status === 401) {
                        return;
                    }
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
                });
            });
        })
    }

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

    /**
     * 获取编辑视图信息
     *
     * @param {*} $event 事件信息
     * @memberof OrderCalendarNavigationBase
     */
    public getEditView(deName: string) {
        let view: any = {};
        switch(deName){
            case "ibizorderdetail": 
                view = {
                    viewname: 'ibizorder-detail-sgrid-view9', 
                    height: 0, 
                    width: 0,
                    title: this.$t('entities.ibizorderdetail.views.sgridview9.title'),
                    placement: '',
                    deResParameters: [{ pathName: 'ibizorders', parameterName: 'ibizorder' }, ],
                    parameters: [{ pathName: 'ibizorderdetails', parameterName: 'ibizorderdetail' }, { pathName: 'sgridview9', parameterName: 'sgridview9' } ],
                };
                break;
            case "ibizorder": 
                view = {
                    viewname: 'ibizorder-edit-view', 
                    height: 0, 
                    width: 0,
                    title: this.$t('entities.ibizorder.views.editview.title'),
                    placement: '',
                    deResParameters: [],
                    parameters: [{ pathName: 'ibizorders', parameterName: 'ibizorder' }, { pathName: 'editview', parameterName: 'editview' } ],
                };
                break;
        }
        return view;
    }

    /**
     * 日程点击事件
     *
     * @param {*} $event calendar事件对象或event数据
     * @param {*} isOriginData true:$event是原始event数据,false:是组件
     * @param {*} $event timeline事件对象
     * @memberof OrderCalendarNavigationBase
     */
    public onEventClick($event: any, isOriginData:boolean = false, $event2?: any) {
        this.handleCtrlEvents('onselectionchange', { data: $event }).then((res: boolean) => {
            if (!res) {
                return;
            }
            // 处理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);
            let _viewparams:any = Object.assign({start:event.start,end:event.end},this.viewparams);
            switch(event.itemType) {
                case "item1":
                    _context.ibizorder = event.ibizorder;
                    view = this.getEditView("ibizorder");
                    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))] , _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)), _viewparams);
                } else if (Object.is(view.placement, 'POPUPMODAL')) {
                    container = this.$appmodal.openModal(view,  JSON.parse(JSON.stringify(_context)), _viewparams);
                } else if (view.placement.startsWith('DRAWER')) {
                    container = this.$appdrawer.openDrawer(view,  JSON.parse(JSON.stringify(_context)),  _viewparams);
                }
                container.subscribe((result: any) => {
                    if (!result || !Object.is(result.ret, 'OK')) {
                        return;
                    }
                    // 刷新日历
                    _this.refresh();
                });
            }
        })

    }

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

    /**
     * 日程拖动事件
     *
     * @param {*} $event 事件信息
     * @memberof OrderCalendarNavigationBase
     */
    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 "item1":
                arg.ibizorder = $event.event._def.extendedProps.ibizorder;
                _context.ibizorder = $event.event._def.extendedProps.ibizorder;
                break;
        }
        Object.assign(arg, { viewparams: this.viewparams} );
        this.handleCtrlEvents('onbeforedrop', { viewparams: arg }).then((beforeDropRes: boolean) => {
            if (!beforeDropRes) {
                return;
            }
            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) {
                    this.handleCtrlEvents('ondroperror', { data: response && response.data ? response.data : [] }).then((res: boolean) => {
                        if (!res) {
                            return;
                        }
                        if (response.data && response.data.message) {
                            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
                        }
                        return;
                    })
                }
                this.handleCtrlEvents('ondropsuccess', { data: response.data }).then((res: boolean) => {
                    if (!res) {
                        return;
                    }
                })
            }, (response: any) => {
                this.handleCtrlEvents('ondroperror', { data: response && response.data ? response.data : [] }).then((res: boolean) => {
                    if (!res) {
                        return;
                    }
                    if (response && response.status === 401) {
                        return;
                    }
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
                })
            })
        });
    }

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

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

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

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

    /**
     * 执行created后的逻辑
     *
     *  @memberof OrderCalendarNavigationBase
     */    
    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,"IBIZOrder")){
                    return;
                }
                if(Object.is(action,'appRefresh')){
                    this.refresh();
                }
            })
        }
    }


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

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

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

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



    /**
     * 计算节点右键权限
     *
     * @param {*} data 日历项数据
     * @param {*} appEntityName 应用实体名称  
     * @returns
     * @memberof OrderCalendarNavigationBase
     */
    public async computeNodeState(data:any,appEntityName:string) {
        let service:any = await this.appEntityService.getService(appEntityName);
        if(this.copyActionModel && Object.keys(this.copyActionModel).length > 0) {
            if(service['Get'] && service['Get'] instanceof Function){
                let tempContext:any = Util.deepCopy(this.context);
                tempContext[appEntityName] = data[appEntityName];
                let targetData = await service.Get(tempContext,{}, false);
                let uiservice:any = await new UIService().getService(appEntityName);
                let result: any[] = ViewTool.calcActionItemAuthState(targetData.data,this.copyActionModel,uiservice);
                return this.copyActionModel;
            }else{
                console.warn("获取数据异常");
                return this.copyActionModel;
            }
        }
    }

    /**
     * 事件绘制回调
     *
     * @param {*} info 信息
     * @memberof OrderCalendarNavigationBase
     */
    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) => {
            this.copyActionModel = {};
            Object.values(this.actionModel).forEach((item:any) =>{
                if(Object.is(item.nodeOwner,data.itemType)){
                    this.copyActionModel[item.name] = item;
                }
            })
            if(Object.keys(this.copyActionModel).length === 0){
                return;
            }
            let dataMapping:any ={'item1':'ibizorder'};
            this.computeNodeState(data,dataMapping[data.itemType]).then((result:any) => {
                let flag:boolean = false;
                if(Object.values(result).length>0){
                    flag =Object.values(result).some((item:any) =>{
                        return item.visabled === true;
                    })
                }
                if(flag){
                    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 OrderCalendarNavigationBase
     */
    public renderContextMenu(event: any) {
        let content;
        if (event && event.itemType) {
            const data: any = JSON.parse(JSON.stringify(event));
            this.selections = [event];
            switch(event.itemType){
            }
        }
        return content;
    }

}
</script>

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