amis2/docs/zh-CN/components/calendar.md

239 lines
9.2 KiB
Markdown
Raw Normal View History

---
title: Calendar 日历日程
description:
type: 0
group: ⚙ 组件
menuName: Calendar 日历日程
icon:
order: 36
---
## 基本用法
设置 `schedules` 属性
```schema: scope="body"
{
"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"
}
]
}
```
## 自定义颜色
```schema: scope="body"
{
"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"
}
]
}
```
## 自定义日程展示
```schema: scope="body"
{
"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}"
}
}
}
}
```
## 支持从数据源中获取日程
```schema
{
"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}"
}
]
}
```
## 放大模式
```schema: scope="body"
{
"type": "calendar",
"value": "1638288000",
"largeMode": true,
"schedules": [
{
"startTime": "2021-12-10 23:59:59",
"endTime": "2021-12-11 00:00:00",
"content": "这是一个日程1"
},
{
"startTime": "2021-12-12 00:00:00",
"endTime": "2021-12-13 00:00:01",
"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"
},
{
"startTime": "2021-12-25 12:00:00",
"endTime": "2021-12-25 15:00:00",
"content": "这是一个日程8"
}
]
}
```
## 今日高亮样式自定义
> 2.1.1 及以上版本
```schema: scope="body"
{
"type": "calendar",
"value": "NOW()",
"todayActiveStyle": {
"backgroundColor": "#ef4444 !important",
"color": "#f8f9fa",
"border": "none",
"borderRadius": "15px"
},
"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"
}
]
}
```
## Calendar 属性表
| 属性名 | 类型 | 默认值 | 说明 |
| ------------------ | ----------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| type | `string` | `"calendar"` | 指定为 calendar 渲染器 |
| schedules | `Array<{startTime: string, endTime: string, content: any, className?: string}> \| string` | | 日历中展示日程可设置静态数据或从上下文中取数据startTime 和 endTime 格式参考[文档](https://momentjs.com/docs/#/parsing/string/)className 参考[背景色](https://baidu.gitee.io/amis/zh-CN/style/background/background-color) |
| scheduleClassNames | `Array<string>` | `['bg-warning', 'bg-danger', 'bg-success', 'bg-info', 'bg-secondary']` | 日历中展示日程的颜色,参考[背景色](https://baidu.gitee.io/amis/zh-CN/style/background/background-color) |
| scheduleAction | `SchemaNode` | | 自定义日程展示 |
| largeMode | `boolean` | `false` | 放大模式 |
| todayActiveStyle | `Record<string, any>` | | 今日激活时的自定义样式 |
## 事件表
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`来获取事件产生的数据(`< 2.3.2 及以下版本 ${event.data.[事件参数名]}`详细请查看[事件动作](../../docs/concepts/event-action)
2022-05-31 15:05:54 +08:00
| 事件名称 | 事件参数 | 说明 |
| ---------- | ------------------------ | ------------------ |
| change | `value: string` 组件的值 | 时间值变化时触发 |
| click | `value: string` 组件的值 | 点击日期时触发 |
| mouseenter | `value: string` 组件的值 | 鼠标移入日期时触发 |
| mouseleave | `value: string` 组件的值 | 鼠标移出日期时触发 |
## 动作表
2022-05-31 15:05:54 +08:00
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
merge 280-6.3.0 into 280-6.4.0 (#10172) * bump: 6.4.0-280.0 * fix: 修复弹窗中关闭动作中打开弹窗后续事件动作不执行的问题 (#10044) * fix: 修复新建弹窗中弹窗列表出现重复的问题 (#10047) * fix: 修复 form 的 flush 逻辑可能会出现一直等待自己的问题 (#10059) * fix: 修复动作面板中弹窗信息显示不全的问题 (#10063) * chore: 减小 Excel 默认单元格的 padding 大小 * fix: 修复弹窗中的弹窗编辑器中出现重复的问题 (#10073) * fix: 更新 citydb closes #10046 * style(amis): 样式细节优化,避免异常溢出和换行展示 (#10072) * style(amis): 样式细节优化,避免异常溢出和换行展示 * style(amis-editor): 属性配置面板样式补充,用于避免配置面板被超长的valueLabel撑开,导致样式异常 * fix: 修复弹窗中引用弹窗自己的编辑器逻辑问题 (#10078) * 补充之前的辖区信息 * fix: 修复弹窗编辑问题 (#10083) * fix(amis): 修复InputRange不能拖拽到负值的问题 * fix(amis): 修复InputRange精度失效问题 * Update Form.tsx 修改dispatchInited方法,主要解决:当跳转到包含Form的新页面,新页面还没加载完成时,快速后退导致的报错:Uncaught (in promise) Error: [mobx-state-tree] You are trying to read or write to an object that is no longer part of a state tree. * fix: 修复弹窗编辑嵌套异常问题 (#10089) * fix:发送请求动作的sendOn配置不生效 * fix:发送请求动作的sendOn配置不生效 * fix: 修复修复内嵌弹窗中内嵌弹窗失效的问题 (#10100) * fix:刷新crud未执行切刷新service的问题 * fix: revert #9941 修复弹窗下有多个 form 时数据混乱问题 * fix: 修复弹窗修改无法删除属性的问题 * fix(amis): 修正range.test.tsx用例 * fix(editor): 修复校验规则修改后面板不更新问题 (#10113) Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> * fix: 修复 crud 中 filter 开启 submitOnChnage 后无法分页问题 (#10115) * fix(editor): 修复校验规则修改后面板不更新问题 (#10113) Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> * fix: 修复 inputArray 在编辑器中渲染错误的问题 (#10104) * fix: 修复右击菜单后报错 (#10121) * fix: 修复选项卡新增选项组件前后无插入支持 * fix: 修复crud2编辑器内设置多列右侧固定显示问题 * fix: 修复crud2组件特性动作 * fix: 修复crud2按钮列表管理编辑bug * fix: 修复each组件items数组时编辑报错 * refactor: table2刷新页面改成crud2下发 * fix: 修复选项卡新增选项组件前后无插入支持 * fix: 修复crud2编辑器内设置多列右侧固定显示问题 * fix: 修复crud2组件特性动作 * fix: 修复crud2按钮列表管理编辑bug * fix: 修复each组件items数组时编辑报错 * refactor: table2刷新页面改成crud2下发 * fix:inputTable删除行动作没有触发change事件 * fix:表单项reset支持重置为初始值 * fix(amis): 修正range.test.tsx用例 * chore: 升级amis-publish版本,支持分支版本 * chore: 升级amis-publish版本,支持分支版本 (#10150) Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> * breaking: 打印功能使用 id 而不是 testid Closes #10123 (#10126) * breaking: 打印功能使用 id 而不是 testid Closes #10123 * 修复文档错误 * 更新 snapshot * fix: 修复 inputTable 在分页情况切换数据表单项不更新的问题 (#10157) * bump: 6.4.0 * fix(amis): 修正range.test.tsx用例 * fix(amis): 注释掉range.test.tsx中的滑动change case * fix(amis): 更新range.test.tsx.snap --------- Co-authored-by: 2betop <2betop.cn@gmail.com> Co-authored-by: wuduoyi <wuduoyi@baidu.com> Co-authored-by: 刘丹 <365533093@qq.com> Co-authored-by: sidrong <529672493@qq.com> Co-authored-by: lvxiaojiao <lvxiaojiao@baidu.com> Co-authored-by: qkiroc <30946345+qkiroc@users.noreply.github.com> Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> Co-authored-by: liaoxuezhi <2698393+2betop@users.noreply.github.com> Co-authored-by: F-jianchao <161407305+F-jianchao@users.noreply.github.com> Co-authored-by: zhangtao07 <zhang.tao.1006@163.com> Co-authored-by: hsm-lv <80095014+hsm-lv@users.noreply.github.com>
2024-05-08 10:31:52 +08:00
| 动作名称 | 动作配置 | 说明 |
| -------- | ------------------------ | ------------------------------------------------ |
| clear | - | 清空 |
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
| setValue | `value: string` 更新的值 | 更新数据 |