mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-14 00:41:26 +08:00
8.3 KiB
8.3 KiB
title | description | type | group | menuName | icon | order |
---|---|---|---|---|---|---|
Calendar 日历日程 | 0 | ⚙ 组件 | Calendar 日历日程 | 36 |
基本用法
设置 schedules
属性
{
"type": "calendar",
"value": "1638288000",
"schedules": [
{
"startTime": "2021-12-11 05:14:00",
"endTime": "2021-12-11 06:14:00",
"content": "这是一个日程1"
},
{
"startTime": "2021-12-21 05:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程2"
}
]
}
自定义颜色
{
"type": "calendar",
"value": "1638288000",
"schedules": [
{
"startTime": "2021-12-11 05:14:00",
"endTime": "2021-12-11 06:14:00",
"content": "这是一个日程1",
"className": "bg-success"
},
{
"startTime": "2021-12-21 05:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程2",
"className": "bg-info"
}
]
}
{
"type": "calendar",
"value": "1638288000",
"scheduleClassNames": ["bg-success", "bg-info"],
"schedules": [
{
"startTime": "2021-12-11 05:14:00",
"endTime": "2021-12-11 06:14:00",
"content": "这是一个日程1"
},
{
"startTime": "2021-12-21 05:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程2"
}
]
}
自定义日程展示
{
"type": "calendar",
"value": "1638288000",
"schedules": [
{
"startTime": "2021-12-11 05:14:00",
"endTime": "2021-12-11 06:14:00",
"content": "这是一个日程1"
},
{
"startTime": "2021-12-21 05:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程2"
}
],
"scheduleAction": {
"actionType": "drawer",
"drawer": {
"title": "日程",
"body": {
"type": "table",
"columns": [
{
"name": "time",
"label": "时间"
},
{
"name": "content",
"label": "内容"
}
],
"data": "${scheduleData}"
}
}
}
}
支持从数据源中获取日程
{
"type": "page",
"data": {
"schedules": [
{
"startTime": "2021-12-11 05:14:00",
"endTime": "2021-12-11 06:14:00",
"content": "这是一个日程1"
},
{
"startTime": "2021-12-21 05:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程2"
}
]
},
"body": [
{
"type": "calendar",
"value": "1638288000",
"schedules": "${schedules}"
}
]
}
放大模式
{
"type": "calendar",
"value": "1638288000",
"largeMode": true,
"schedules": [
{
"startTime": "2021-12-11 05:14:00",
"endTime": "2021-12-11 06:14:00",
"content": "这是一个日程1"
},
{
"startTime": "2021-12-12 02:14:00",
"endTime": "2021-12-13 05:14:00",
"content": "这是一个日程2"
},
{
"startTime": "2021-12-20 05:14:00",
"endTime": "2021-12-21 05:14:00",
"content": "这是一个日程3"
},
{
"startTime": "2021-12-21 05:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程4"
},
{
"startTime": "2021-12-22 02:14:00",
"endTime": "2021-12-23 05:14:00",
"content": "这是一个日程5"
},
{
"startTime": "2021-12-22 02:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程6"
},
{
"startTime": "2021-12-22 02:14:00",
"endTime": "2021-12-22 05:14:00",
"content": "这是一个日程7"
}
]
}
Calendar 属性表
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
type | string |
"calendar" |
指定为 calendar 渲染器 |
schedules | Array<{startTime: string, endTime: string, content: any, className?: string}> | string |
日历中展示日程,可设置静态数据或从上下文中取数据,startTime 和 endTime 格式参考文档,className 参考背景色 | |
scheduleClassNames | Array<string> |
['bg-warning', 'bg-danger', 'bg-success', 'bg-info', 'bg-secondary'] |
日历中展示日程的颜色,参考背景色 |
scheduleAction | SchemaNode |
自定义日程展示 | |
largeMode | boolean |
false |
放大模式 |
事件表
当前组件会对外派发以下事件,可以通过onEvent
来监听这些事件,并通过actions
来配置执行的动作,在actions
中可以通过event.data.xxx
事件参数变量来获取事件产生的数据,详细请查看事件动作。
事件名称 | 事件参数 | 说明 |
---|---|---|
change | event.data.value: string 时间值 |
时间值变化时触发 |
动作表
当前组件对外暴露以下特性动作,其他组件可以通过指定actionType: 动作名称
、componentId: 该组件id
来触发这些动作,动作配置可以通过args: {动作配置项名称: xxx}
来配置具体的参数,详细请查看事件动作。
动作名称 | 动作配置 | 说明 |
---|---|---|
clear | - | 清空 |
reset | - | 将值重置为resetValue ,若没有配置resetValue ,则清空 |
setValue | value: string 更新的值 |
更新数据 |