import { CalendarControlBase } from '../../../widgets/calendar-control-base'; import { throttle, Util } from '@ibizstudio/runtime'; import { IPSSysCalendar, IPSSysCalendarItem } from '@ibizstudio/runtime'; /** * 应用日历部件基类 * * @export * @class AppCalendarBase * @extends {CalendarControlBase} */ export class AppCalendarBase extends CalendarControlBase { /** * TODO绘制日历项 * * @memberof AppCalendarBase */ renderCalendarItems() { const calendarItems: Array = (this.controlInstance as IPSSysCalendar).getPSSysCalendarItems() || []; if (calendarItems.length > 1) { return calendarItems.map((item: IPSSysCalendarItem) => { if (!item.itemType) { return null; } const itemClass = { 'event-lengend': true, [item.itemType]: true, 'event-disabled': !this.isShowlegend[item.itemType], }; return (
{ throttle(this.legendTrigger, [item.itemType as string], this); }} >
{item.name}
); }); } } /** * 绘制日历内容 * * @memberof AppCalendarBase */ renderContent() { let _this: any = this; if (this.ctrlParams) { return ( { throttle(this.onEventClick, [tempEvent, true], this); }} events={this.searchEvents} > ); }
未支持
; } /** * TODO 绘制批操作工具栏 * * @memberof AppCalendarBase */ renderBatchToolbar() {} /** * 绘制数据项面板 * * @param item 数据项 * @memberof AppCalendarBase */ renderItemPanel(item: any, calendarItem: any) { let { targetCtrlName, targetCtrlParam, targetCtrlEvent }: { targetCtrlName: string; targetCtrlParam: any; targetCtrlEvent: any } = this.computeTargetCtrlData( calendarItem.getPSLayoutPanel(), item, ); return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: item.id, on: targetCtrlEvent }); } /** * 绘制数据项 * * @param item 数据项 * @param index 下标 * @memberof AppCalendarBase */ renderTimeLineItem(item: any, index: number) { const calendarItem = (this.controlInstance as IPSSysCalendar).getPSSysCalendarItems()?.find((_item: any) => { return item?.itemType == _item.itemType; }); return ( { throttle(this.onTimeLineClick, [item], this); }} class={{ ...item.className, 'is-select': item.isSelect ? true : false }} > {calendarItem && calendarItem.getPSLayoutPanel() ? ( this.renderItemPanel(item, calendarItem) ) : (

{item.title}

{item.content}

)}
); } /** * 绘制 * * @memberof AppCalendarBase */ render() { if (!this.controlIsLoaded) { return null; } const { controlClassNames } = this.renderOptions; if (Object.is(this.controlInstance.calendarStyle, 'TIMELINE')) { if (this.events.length > 0) { return ( {this.events.map((event: any, index: number) => { return this.renderTimeLineItem(event, index); })} ); } else { return (
{this.$tl(this.controlInstance.getEmptyTextPSLanguageRes()?.lanResTag, this.$t('app.commonwords.nodata'))} {this.renderQuickToolbar()}
); } } else { return (
{this.renderCalendarItems()}
{this.renderContent()}
{this.renderBatchToolbar()}
); } } }