如何添加其他资源列已满

时间:2019-01-31 15:31:24

标签: typescript fullcalendar sharepoint-online fullcalendar-scheduler spfx

我希望将资源列添加到spfx fullCalendar应用。

按照文档的说明,我尝试在此处复制演示中显示的内容:

https://fullcalendar.io/docs/resourceColumns

https://fullcalendar.io/docs/resourceColumns-demo

该演示似乎使用资源列为“占用率”添加了一个附加字段

resourceColumns: [
        {
          labelText: 'Room',
          field: 'title'
        },
        {
          labelText: 'Occupancy',
          field: 'occupancy'
        }
      ],
      resources: [
        { id: 'a', title: 'Auditorium A', occupancy: 40 },
        { id: 'b', title: 'Auditorium B', occupancy: 60 },
        { id: 'c', title: 'Auditorium C', occupancy: 40 },
        { id: 'd', title: 'Auditorium D', occupancy: 40 },
      ]

我已经实现了同一段代码,但是收到错误消息。

Type '{ id: string; title: string; occupancy: number; }[]' is not assignable to type 'ResourceSourceInput'.
  Type '{ id: string; title: string; occupancy: number; }[]' is not assignable to type 'ResourceInput[]'.
    Type '{ id: string; title: string; occupancy: number; }' is not assignable to type 'ResourceInput'.
      Object literal may only specify known properties, and 'occupancy' does not exist in type 'ResourceInput'.
declare module 'fullcalendar-scheduler/src/types/input-types' {
    /// <reference types="jquery" />
    import * as moment from 'moment';
    import { BusinessHoursInput, EventOptionsBase } from 'fullcalendar';
    export interface ResourceInput {
        id?: string;
        title?: string;
        eventColor?: string;
        eventBackgroundColor?: string;
        eventBorderColor?: string;
        eventTextColor?: string;
        eventClassName?: string | string[];
        businessHours?: BusinessHoursInput;
        children?: ResourceInput[];
        parentId?: string;
        parent?: ResourceInput;
    }
    export interface ResourceComplexInput extends EventOptionsBase, JQueryAjaxSettings {
    }
    export type ResourceFunctionCallback = (resources: ResourceInput[]) => void;
    export type ResourceFunction = (callback: ResourceFunctionCallback, start: moment.Moment, end: moment.Moment, timezone: string) => void;
    export type ResourceSourceInput = ResourceInput[] | ResourceFunction | ResourceComplexInput; module 'fullcalendar/src/types/input-types' {
        interface DropInfo {
            resourceId?: string;
        }
        interface OptionsInputBase {
            schedulerLicenseKey?: string;
            resourceAreaWidth?: number;
            resourceLabelText?: string;
            resourceColumns?: any;
            resources?: ResourceSourceInput;
            refetchResourcesOnNavigate?: boolean;
            groupByResource?: boolean;
            groupByDateAndResource?: boolean;
            resourceOrder?: string;
            resourceGroupField?: string;
            resourceGroupText?: (groupValue: string) => string;
            resourcesInitiallyExpanded?: boolean;
            filterResourcesWithEvents?: boolean;
            resourceText?: (resource: ResourceInput) => string;
            resourceRender?: (resource: ResourceInput, labelTds: JQuery, bodyTds: JQuery) => void;
            eventResourceEditable?: boolean;
        }
    }

尽管我在演示中找不到任何显示此操作方式的内容,但似乎我需要添加一个用于占用的其他属性。

1 个答案:

答案 0 :(得分:0)

...添加扩展这个接口附加类型:

type Extended = ResourceInput & {occupancy: number}