CONTROL-BASE.vue.ftl 31.2 KB
Newer Older
1 2 3
<#ibizinclude>
../../@MACRO/LANG_FUN.ftl
</#ibizinclude>
4 5 6
<#ibizinclude>
../@MACRO/CONTROL/LANGBASE.vue.ftl
</#ibizinclude>
7
<template>
8 9 10 11
<#if ctrl.render??>
${ctrl.render.code}
<#else>
    <div :class='calendarClass<#if ctrl.getPSSysCss?? && ctrl.getPSSysCss()??><#assign singleCss = ctrl.getPSSysCss()> ${singleCss.getCssName()}</#if>'>
tony001's avatar
tony001 committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
    <#if ctrl.getQuickPSDEToolbar?? && ctrl.getQuickPSDEToolbar()??>
      <span class="quick-toolbar">
        <#assign quickToolbar = ctrl.getQuickPSDEToolbar()/>
        <@ibizindent blank=12>
        ${P.getCtrlCode(quickToolbar, 'CONTROL.html').code}
        </@ibizindent>
      </span>
    </#if>
    <#if ctrl.getBatchPSDEToolbar?? && ctrl.getBatchPSDEToolbar()??>
    <span v-if="selections.length > 0" class="batch-toolbar">
      <#assign batchToolbar = ctrl.getBatchPSDEToolbar()/>
      <@ibizindent blank=12>
      ${P.getCtrlCode(batchToolbar, 'CONTROL.html').code}
      </@ibizindent>
    </span>
    </#if>
tony001's avatar
tony001 committed
28
      <context-menu-container>
29
<#if ctrl.getCalendarStyle?? && ctrl.getCalendarStyle() == 'TIMELINE'>
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
        <template v-if="events.length >0">
            <el-timeline>
            <el-timeline-item
                v-for="(item, index) in events"
                :key="item.title+index"
                :color="item.color"
                :timestamp="item.start" 
                placement="top">
                <context-menu :contextMenuStyle="{width: '100%'}" :data="item" :renderContent="renderContextMenu">
                    <el-card @click.native="onEventClick(item,true,$event)" :class="item.className">
                    <#if ctrl.getPSSysCalendarItems()?? >
                    <#list ctrl.getPSSysCalendarItems() as calendarItem>
                        <div v<#if calendarItem_index != 0>-else</#if>-if="<#if calendarItem.getPSLayoutPanel()??>true<#else>false</#if> && item.itemType == '${calendarItem.getItemType()}'">
                        <#if calendarItem.getPSLayoutPanel()??>
                        <#assign panel = calendarItem.getPSLayoutPanel()>
                        <@ibizindent blank=18>
                        ${P.getCtrlCode(panel, 'CONTROL.html').code}
                        </@ibizindent>
                        </#if>
                        </div>
                    </#list>
51
                        <div v-else>
52 53 54
                            <h4>{{item.title}}</h4>
                            <p>{{$t('app.calendar.from')}} {{item.start}} {{$t('app.calendar.to')}} {{item.end}}</p>
                        </div>
Shine-zwj's avatar
Shine-zwj committed
55
                    </#if>
56 57 58 59 60 61 62 63
                    </el-card>
                </context-menu>
            </el-timeline-item>
            </el-timeline>
        </template>
        <template v-else>
            <span class="app-data-empty">{{ $t('<#if langbase??>${langbase}.nodata</#if>') }}</span>
        </template>
64
<#else>
65
        <template>
tony001's avatar
tony001 committed
66 67 68 69 70 71 72 73 74 75
        <div class="event-legends">
<#if ctrl.getPSSysCalendarItems()??>
  <#list ctrl.getPSSysCalendarItems() as calendarItem>
          <div :class="{'event-lengend':true, '${calendarItem.getItemType()}':true, 'event-disabled':!isShowlegend.${calendarItem.getItemType()}}" @click="legendTrigger('${calendarItem.getItemType()}')">
            <div class="lengend-icon" style="background:${calendarItem.getBKColor()};"></div>
            <span style="color:${calendarItem.getColor()};">${calendarItem.getName()}</span>
          </div>
  </#list>
</#if>
        </div>
76 77 78 79 80 81 82 83 84 85 86 87 88 89
        <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"
tony001's avatar
tony001 committed
90
          :eventRender="eventRender"
91 92 93 94 95 96 97
          @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>
98
        </template>
99
</#if>
tony001's avatar
tony001 committed
100
      </context-menu-container>
101
    </div>
102
</#if>
103 104 105 106 107 108
</template>
<#assign import_block>
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import timeGridPlugin from '@fullcalendar/timegrid';
import listPlugin from '@fullcalendar/list';
109 110 111
import interactionPlugin from '@fullcalendar/interaction';
import ContextMenu from '@components/context-menu/context-menu';
import UIService from '@/uiservice/ui-service';
112 113 114 115 116 117 118 119 120 121 122 123 124 125
</#assign>

<#assign component_block>
FullCalendar,
</#assign>

<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>

    /**
     * 是否默认选中第一条数据
     *
     * @type {boolean}
126
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
127
     */
128
    @Prop({ default: false }) public isSelectFirstDefault!: boolean;
129 130 131 132 133

    /**
     * 显示处理提示
     *
     * @type {boolean}
134
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
135
     */
136
    @Prop({ default: true }) public showBusyIndicator?: boolean;
137 138 139 140 141

    /**
     * 部件行为--load
     *
     * @type {string}
142
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
143
     */
144
    @Prop() public loadAction!: string;
145

tony001's avatar
tony001 committed
146 147 148 149 150 151 152
<#if view.getPSAppViewLogics?? && view.getPSAppViewLogics()??>
  <#list view.getPSAppViewLogics() as logic>
    <#if logic.getPFLogicCodeType() == 'APP_NEWDATA'>
    /**
     * 打开新建数据视图
     *
     * @type {any}
153
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
154 155 156 157 158 159 160 161
     */
    @Prop() public newdata: any;
    </#if>
    <#if logic.getPFLogicCodeType() == 'APP_OPENDATA'>
    /**
     * 打开编辑数据视图
     *
     * @type {any}
162
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
163 164 165 166 167 168
     */
    @Prop() public opendata: any;
    </#if>
  </#list>
</#if>

169 170 171
    /**
     * 日历部件样式名
     *
172
     * @public
173
     * @type {any[]}
174
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
175
     */
176
    public calendarClass: string = "calendar";
177

Shine-zwj's avatar
Shine-zwj committed
178 179 180
    /**
     * this引用
     *
181
     * @type {any}
Shine-zwj's avatar
Shine-zwj committed
182 183 184 185
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public thisRef: any = this;

186 187 188
    /**
     * 选中事件element元素
     *
189
     * @public
190
     * @type {any[]}
191
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
192
     */
193
    public selectedEventElement:any;
194 195 196 197

    /**
     * 引用插件集合
     *
198
     * @public
199
     * @type {any[]}
200
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
201
     */
202
    public calendarPlugins: any[] = [
203 204 205 206 207 208 209 210 211
        dayGridPlugin, 
        timeGridPlugin, 
        listPlugin, 
        interactionPlugin
    ];

    /**
     * 设置头部显示
     *
212
     * @public
213
     * @type {}
214
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
215
     */
216
    public header: any = {
217 218 219 220 221 222 223 224
        left: 'prev,next today gotoDate',
        center: 'title',
        right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
    };

    /**
     * 按钮文本集合
     *
225
     * @public
226
     * @type {}
227
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
228
     */
229
    public buttonText: any = {
230 231 232 233 234 235 236 237 238 239
        today: '今天',
        month: '月',
        week: '周',
        day: '天',
        list: '列'
    };

    /**
     * 自定义按钮集合
     *
240
     * @public
241
     * @type {}
242
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
243
     */
244
    public customButtons: any = {
245 246 247 248 249 250 251 252 253
        gotoDate: {
          text: "跳转",
          click: this.openDateSelect
        }
    };

    /**
     * 模态显示控制变量
     *
254
     * @public
255
     * @type boolean
256
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
257
     */
258
    public modalVisible: boolean = false;
259 260 261 262

    /**
     * 跳转日期
     *
263
     * @public
264
     * @type Date
265
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
266
     */
267
    public selectedGotoDate: Date = new Date();
268 269 270 271

    /**
     * 打开时间选择模态
     *
272
     * @public
273
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
274
     */
275
    public openDateSelect(){
276 277 278 279 280 281
        this.modalVisible = true;
    }

    /**
     * 跳转到指定时间
     *
282
     * @public
283
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
284
     */
285
    public gotoDate(){
286 287 288 289 290 291 292 293
        let appCalendar: any = this.$refs.calendar;
        let api = appCalendar.getApi();
        api.gotoDate(this.selectedGotoDate);
    }

    /**
     * 有效日期范围
     *
294
     * @public
295
     * @type {}
296
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
297
     */
298
    public validRange: any = {
299 300 301 302 303 304 305
        start:"0000-01-01",
        end:"9999-12-31"
    };

    /**
     * 默认加载日期
     *
306
     * @public
307
     * @type {}
308
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
309
     */
310
    public defaultDate: any = this.$util.dateFormat(new Date());
311 312 313 314

    /**
     * 设置按钮文本
     *
315
     * @public
316
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
317
     */
318
    public setButtonText(){
319 320 321 322 323 324 325 326 327 328 329
        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')
    }

    /**
     * 监听语言变化
     *
330
     * @public
331
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
332 333
     */
    @Watch('$i18n.locale')
334
    public onLocaleChange(newval: any, val: any) {
335 336 337 338 339 340
        this.setButtonText();
    }

    /**
     * 日程事件集合
     *
341
     * @public
342
     * @type {any[]}
343
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
344
     */
345
    public events: any[] = [];
346

347
    /**
348 349 350 351 352 353 354 355 356 357 358
     * 日历项上下文菜单集合
     *
     * @type {string[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
     public actionModel: any = {
        <#if ctrl.getPSControls()??>
            <#list ctrl.getPSControls() as childCtrl>
                <#if childCtrl.getControlType() == "CONTEXTMENU">
                    <#if childCtrl.getPSDEToolbarItems()??>
                        <#list childCtrl.getPSDEToolbarItems() as item>
359
        ${childCtrl.getOwner().getItemType()}_${item.name}: {name:'${item.name}',nodeOwner:'${childCtrl.getOwner().getItemType()}',<#if item.getPSUIAction()??><#assign uiaction=item.getPSUIAction()>type: '${uiaction.getUIActionType()}', tag: '${uiaction.getUIActionTag()}'<#if (uiaction.getActionTarget()!="")>, actiontarget: '${uiaction.getActionTarget()}'</#if><#if uiaction.getNoPrivDisplayMode(view)??>, noprivdisplaymode:${uiaction.getNoPrivDisplayMode(view)}</#if><#if uiaction.getDataAccessAction()??>, dataaccaction:'${uiaction.getDataAccessAction()}'</#if>, visabled: true, disabled: false</#if>},
360 361 362 363 364 365 366 367 368
                        </#list> 
                    </#if>
                </#if>
            </#list>
        </#if>
    }

    /**
     * 备份日历项上下文菜单
369 370 371 372
     *
     * @type {string[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
373
     public copyActionModel: any;
374

375 376 377
    /**
     * 日历样式类型
     *
378
     * @public
379
     * @type {string}
380
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
381
     */
382
    public calendarType: string = "${ctrl.getCalendarStyle()}";
383

tony001's avatar
tony001 committed
384 385 386 387 388
    /**
     * 图例显示控制
     *
     * @public
     * @type {any}
389
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
390 391 392 393 394 395 396 397 398 399 400 401 402
     */
    public isShowlegend: any = {
<#if ctrl.getPSSysCalendarItems()??>
  <#list ctrl.getPSSysCalendarItems() as calendarItem>
        ${calendarItem.getItemType()}:true,
  </#list>
</#if>
    };

    /**
     * 图例点击事件
     *
     * @public
403
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
404 405 406 407 408 409 410 411 412 413 414
     */
    legendTrigger(itemType:string){
        this.isShowlegend[itemType] = !this.isShowlegend[itemType];
        this.refresh();
    }

    /**
     * 查询参数缓存
     *
     * @public
     * @type {any}
415
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
416 417 418
     */
    public searchArgCache: any = {};

419 420 421 422 423 424 425 426
<#if ctrl.getPSSysCalendarItems()?? >
    <#assign itemPanel = false />
    <#list ctrl.getPSSysCalendarItems() as calendarItem>
        <#if calendarItem.getPSLayoutPanel()??>
        <#assign itemPanel = true />
        </#if>
    </#list>
    <#if itemPanel>
427 428 429 430 431 432 433 434
    /**
     * 面板数据变化处理事件
     * @param {any} item 当前数据
     * @param {any} $event 面板事件数据
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public onPanelDataChange(item:any,$event:any) {
Shine-zwj's avatar
Shine-zwj committed
435
        Object.assign(item, $event, {rowDataState:'update'});
436
    }
437 438
    </#if>
</#if>
439

440 441 442 443
    /**
     * 搜索获取日程事件
     *
     * @param {*} $event 日期信息
444
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
445
     */
446
    public searchEvents(fetchInfo?:any, successCallback?:any, failureCallback?:any ) {
tony001's avatar
tony001 committed
447
        // 处理请求参数
448 449 450 451 452 453 454
        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});
tony001's avatar
tony001 committed
455 456 457 458 459 460 461 462
        const parentdata: any = {};
        this.$emit('beforeload', parentdata);
        Object.assign(arg, parentdata);
        // 处理events数据
        let _this = this;
        let handleEvents = ()=>{
            if(_this.isSelectFirstDefault){
                // 模拟$event数据
463
                let tempEvent = JSON.parse(JSON.stringify(_this.events.length > 0?_this.events[0]:{}));
tony001's avatar
tony001 committed
464
                _this.onEventClick(tempEvent,true);
465 466 467
                if(_this.events.length > 0){
                    _this.events[0].className = "select-first-event";
                }
tony001's avatar
tony001 committed
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
                _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;
        }
490 491 492 493
        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) {
494
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
495 496 497 498 499
                }
                return;
            }
            // 默认选中第一项
            this.events = response.data;
tony001's avatar
tony001 committed
500
            handleEvents();
501 502 503 504
        }, (response: any) => {
            if (response && response.status === 401) {
                return;
            }
505
            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
506 507 508 509 510 511 512
        });
    }

    /**
     * 日期点击事件
     *
     * @param {*} $event 日期信息
513
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
514
     */
515
    public onDateClick($event: any) {
516 517 518 519 520 521 522 523
        let date = $event.date;
        let datestr = $event.dateStr;
    }

    /**
     * 获取编辑视图信息
     *
     * @param {*} $event 事件信息
524
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
525
     */
526
    public getEditView(deName: string) {
527 528 529 530
        let view: any = {};
        switch(deName){
<#if view.getAllRelatedPSAppViews?? && view.getAllRelatedPSAppViews()??>
  <#list view.getAllRelatedPSAppViews() as editview>
tony001's avatar
tony001 committed
531
            case "${editview.getPSAppDataEntity().getCodeName()?lower_case}": 
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
                view = {
                    viewname: '${srffilepath2(editview.getCodeName())}', 
                    height: ${editview.getHeight()?c}, 
                    width: ${editview.getWidth()?c},
                    title: this.<@getViewLanguageTitle editview />,
                    placement: '${editview.getOpenMode()}',
                    deResParameters: <#rt>
    <#if editview.isPSDEView()>
      [<#t>
      <#if editview.getPSAppDERSPathCount() gt 0>
        <#list editview.getPSAppDERSPath(editview.getPSAppDERSPathCount() - 1) as deRSPath>
        <#assign majorPSAppDataEntity = deRSPath.getMajorPSAppDataEntity()/><#t>
          { pathName: '${srfpluralize(majorPSAppDataEntity.codeName)?lower_case}', parameterName: '${majorPSAppDataEntity.getCodeName()?lower_case}' }, <#t>
        </#list>
      </#if>
      ],<#lt>
    <#else>
      [],<#lt>
    </#if>
                    parameters: <#rt>
    [<#t>
    <#if editview.isPSDEView()>
      <#assign appDataEntity = editview.getPSAppDataEntity()/>
      { pathName: '${srfpluralize(appDataEntity.codeName)?lower_case}', parameterName: '${appDataEntity.getCodeName()?lower_case}' }, <#t>
      { pathName: '${editview.getPSDEViewCodeName()?lower_case}', parameterName: '${editview.getPSDEViewCodeName()?lower_case}' } <#t>
    <#else>
      { pathName: '${editview.getCodeName()?lower_case}', parameterName: '${editview.getCodeName()?lower_case}' } <#t>
    </#if>
    ],<#lt>
                };
                break;
  </#list>
</#if>
        }
        return view;
    }

    /**
     * 日程点击事件
     *
     * @param {*} $event calendar事件对象或event数据
     * @param {*} isOriginData true:$event是原始event数据,false:是组件
     * @param {*} $event timeline事件对象
575
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
576
     */
577
    public onEventClick($event: any, isOriginData:boolean = false, $event2?: any) {
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
        // 处理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);
tony001's avatar
tony001 committed
604
        switch(event.itemType) {
605 606 607 608 609 610 611 612 613 614 615 616
<#if ctrl.getPSSysCalendarItems()??>
  <#list ctrl.getPSSysCalendarItems() as calendarItem>
    <#if calendarItem.getPSAppDataEntity()??>
      <#assign _appde = calendarItem.getPSAppDataEntity() />
            case "${calendarItem.getItemType()}":
                _context.${_appde.getCodeName()?lower_case} = event.${_appde.getCodeName()?lower_case};
                view = this.getEditView("${_appde.getCodeName()?lower_case}");
                break;
    </#if>
  </#list>
</#if>
        }
tony001's avatar
tony001 committed
617
        this.selections = [event];
618 619
        // 导航栏中不需要打开视图,只要抛出选中数据
        if(this.isSelectFirstDefault){
tony001's avatar
tony001 committed
620
            this.$emit("selectionchange",this.selections);
621 622 623
            return;
        }
        // 根据打开模式打开视图
tony001's avatar
tony001 committed
624 625 626
        if(!view.viewname){
            return;
        } else if (Object.is(view.placement, 'INDEXVIEWTAB') || Object.is(view.placement, '')) {
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
            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();
            });
        }
    }

    /**
     * 日历刷新
     *
651
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
652
     */
653
    public refresh(args?:any) {
654 655 656 657 658 659 660 661 662 663 664 665
        if(Object.is(this.calendarType,"TIMELINE")){
            this.searchEvents();
        } else {
            let calendarApi = (this.$refs.calendar as any).getApi();
            calendarApi.refetchEvents();
        }
    }

    /**
     * 日程拖动事件
     *
     * @param {*} $event 事件信息
666
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
667
     */
668
    public onEventDrop($event: any) {
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
        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) {
<#if ctrl.getPSSysCalendarItems()??>
  <#list ctrl.getPSSysCalendarItems() as calendarItem>
    <#if calendarItem.getPSAppDataEntity()??>
      <#assign _appde = calendarItem.getPSAppDataEntity() />
            case "${calendarItem.getItemType()}":
                arg.${_appde.getCodeName()?lower_case} = $event.event._def.extendedProps.${_appde.getCodeName()?lower_case};
                _context.${_appde.getCodeName()?lower_case} = $event.event._def.extendedProps.${_appde.getCodeName()?lower_case};
                break;
    </#if>
  </#list>
</#if>
        }
        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) {
695
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
696 697 698 699 700 701 702
                }
                return;
            }
        }, (response: any) => {
            if (response && response.status === 401) {
                return;
            }
703
            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.errorMessage });
704 705 706 707 708 709 710
        });
    }

    /**
     * 选中的数据
     *
     * @returns {any[]}
711
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
712 713 714
     */
    public selections: any[] = [];

715 716 717 718 719 720 721 722 723
    /**
     * 应用状态事件
     *
     * @public
     * @type {(Subscription | undefined)}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public appStateEvent: Subscription | undefined;

724 725 726 727
    /**
     * 获取多项数据
     *
     * @returns {any[]}
728
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
729 730 731 732 733 734
     */
    public getDatas(): any[] {
        return this.selections;
    }

    /**
tony001's avatar
tony001 committed
735
     * 获取单项数据
736 737
     *
     * @returns {*}
738
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
739 740 741 742 743 744 745 746 747
     */
    public getData(): any {
        return null;
    }
             
    /**
     * vue 生命周期
     *
     * @returns
748
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
749
     */
750
    public created() {
751 752 753 754 755 756 757 758 759 760 761
<#if ctrl.getCalendarStyle?? && ctrl.getCalendarStyle() == 'TIMELINE'>
        this.searchEvents();
<#else>
        this.setButtonText();
</#if>
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
762
     *  @memberof ${srfclassname('${ctrl.codeName}')}Base
763
     */    
764
    public afterCreated(){
765 766 767 768 769 770 771
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
            });
        }
772 773 774 775 776 777 778 779 780 781
        if(AppCenterService && AppCenterService.getMessageCenter()){
            this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
                if(!Object.is(name,"${ctrl.getPSAppDataEntity().getCodeName()}")){
                    return;
                }
                if(Object.is(action,'appRefresh')){
                    this.refresh();
                }
            })
        }
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

    /**
     * vue 生命周期
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public mounted(){
        this.afterMounted();
    }

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

807 808 809
    /**
     * vue 生命周期
     *
810
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
811
     */
812
    public destroyed() {
813 814 815 816 817 818
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
819
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
820
     */
821
    public afterDestroy() {
822 823 824
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
825 826 827
        if(this.appStateEvent){
            this.appStateEvent.unsubscribe();
        }
828 829 830 831 832
        <#if destroyed_block??>
        ${destroyed_block}
        </#if>       
    }

tony001's avatar
tony001 committed
833 834 835 836 837 838 839 840 841
    <#if ctrl.getQuickPSDEToolbar?? && ctrl.getQuickPSDEToolbar()??>
      <#assign quickToolbar = ctrl.getQuickPSDEToolbar()/>
      ${P.getCtrlCode(quickToolbar, 'CONTROL.vue').code}
    </#if>

    <#if ctrl.getBatchPSDEToolbar?? && ctrl.getBatchPSDEToolbar()??>
      <#assign batchToolbar = ctrl.getBatchPSDEToolbar()/>
      ${P.getCtrlCode(batchToolbar, 'CONTROL.vue').code}
    </#if>
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856

    /**
     * 计算节点右键权限
     *
     * @param {*} data 日历项数据
     * @param {*} appEntityName 应用实体名称  
     * @returns
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    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];
857
                let targetData = await service.Get(tempContext,{}, false);
858 859 860 861 862 863 864 865 866 867
                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;
            }
        }
    }

tony001's avatar
tony001 committed
868 869 870 871
    /**
     * 事件绘制回调
     *
     * @param {*} info 信息
872
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
873 874 875 876
     */
    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) => {
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892
            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 ={<#if ctrl.getPSSysCalendarItems()??><#list ctrl.getPSSysCalendarItems() as calendarItem>'${calendarItem.getItemType()}':'${calendarItem.getPSAppDataEntity().getCodeName()?lower_case}'<#if calendarItem_has_next>,</#if></#list></#if>};
            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;
                    })
tony001's avatar
tony001 committed
893
                }
894 895 896 897 898 899 900 901 902 903 904 905 906
                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);
                }
            });
tony001's avatar
tony001 committed
907 908 909 910 911 912 913 914
        });
    }

    /**
     * 绘制右键菜单
     *
     * @param {*} event
     * @returns
915
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
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
     */
    public renderContextMenu(event: any) {
        let content;
        if (event && event.itemType) {
            const data: any = JSON.parse(JSON.stringify(event));
            this.selections = [event];
            switch(event.itemType){
<#if ctrl.getPSControls()??>
<#list ctrl.getPSControls() as childCtrl>
<#if childCtrl.getControlType() == "CONTEXTMENU">
            case "${childCtrl.getOwner().getItemType()}":
                content = this.renderContextMenu${srfclassname(childCtrl.getOwner().getItemType()?lower_case)}();
                break;
</#if>
</#list>
</#if>
            }
        }
        return content;
    }
<#if ctrl.getPSControls()??>
<#list ctrl.getPSControls() as childCtrl>
<#if childCtrl.getControlType() == "CONTEXTMENU">

    /**
     * 绘制${childCtrl.getOwner().getItemType()}类型右键菜单
     *
     * @returns
944
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
945 946 947 948 949 950 951 952 953 954 955
     */
    public renderContextMenu${srfclassname(childCtrl.getOwner().getItemType()?lower_case)}() {
        return (
          <@ibizindent blank=12>
          ${P.getCtrlCode(childCtrl, 'CONTROL.html').code}
          </@ibizindent>
        );
    }
</#if>
</#list>
</#if>
tony001's avatar
tony001 committed
956

957 958 959 960 961 962 963
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>

<#ibizinclude>
../@MACRO/CONTROL/CONTROL-BASE.style.ftl
</#ibizinclude>