1.0.6 • Published 5 years ago

time-schedule v1.0.6

Weekly downloads
28
License
MIT
Repository
github
Last release
5 years ago

Time Schedule

React 时间日程安排控件

DEMO

antd 配合使用的DEMO

Alt Text

安装

npm i time-schedule --save-dev

使用

import 'time-schedule/lib/style/index.css';
import Schedule from 'time-schedule';

示例

<Schedule
  timelineTitle="Time/Name"
  timelineWidth={120}
  startAt="08:00"
  endAt="22:00"
  cellWidth={200}
  maxWidth={850}
  maxHeight={600}
  columns={[
    {key: 'saber', title: 'Saber'},
    {key: 'archer', title: 'Archer'}
  ]}
  dataSource={[]}
/>

有关更完整的示例,请参阅src / example

API

Schedule Props

参数说明类型默认值
classNameScheduler 组件样式类名string-
dataSource数据数组IDataSourceProps[][]
startAt开始时间,如 '9:00' (HH:mm)string'00:00'
endAt结束时间,如 '17:00' (HH:mm)string'23:50'
timelineTitle时间轴显示文字stringReactNode-
timelineWidth时间轴宽度number80
timelineInterval时间区间间隔 (m) 默认值:30(半小时)number30
timelineFormat设置时间轴时间格式。配置参考 moment.jsstring'HH:mm'
columns表格列的配置IColumnProps[][]
cellWidth单元格宽度number200
cellHeight单元格高度number30
maxWidthScheduler 组件最大宽度string | number800
maxHeightScheduler 组件最大高度string | number500
readonly是否只读状态booleanfalse
autoSize是否自动适应最大宽度宽度booleantrue

Event

参数说明参数
onSelect时间选择回调function({rowStartKey: string, rowEndKey: string, col: IColumnProps})
onScroll滚动事件function(scrollTop: number, scrollLeft: number)
selectedDataFaCC数据显示的函数子组件只有 dataSource 变化,才触发子组件更新function(data: IDataSourceProps)

IColumnProps

列描述数据对象

参数说明类型默认值
keyReact 需要的 keystring-
title列头显示内容string | ReactNode-
(other fields)冗余字段。当调用 onSelect({rowStart, rowEnd, col}) 方法, col 将会返回这些冗余字段property: string: any-

IDataSourceProps

数据源描述对象

参数说明类型默认值
colKeyIColumnProps 里的 key,用于定位数据的列项string-
rowEndKey开始时间,如 '9:00'(HH:mm)string-
rowStartKey结束时间,如 '17:00'(HH:mm)string-
dataKey设置显示区域 key 值string-
(other fields)冗余字段。当调用 selectedDataFaCC(data) 渲染, data 将会返回这些冗余字段property: string: any-