vendor: amis 6.13.0 base (fork root)
This commit is contained in:
1131
docs/zh-CN/components/action.md
Executable file
1131
docs/zh-CN/components/action.md
Executable file
File diff suppressed because it is too large
Load Diff
283
docs/zh-CN/components/alert.md
Executable file
283
docs/zh-CN/components/alert.md
Executable file
@@ -0,0 +1,283 @@
|
||||
---
|
||||
title: Alert 提示
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Alert 提示
|
||||
icon:
|
||||
order: 27
|
||||
---
|
||||
|
||||
用来做文字特殊提示,分为四类:提示类、成功类、警告类和危险类。
|
||||
|
||||
## 基本使用
|
||||
|
||||
`level`属性支持 4 种预设样式:`info`, `success`, `warning`, `danger`。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "提示类文案",
|
||||
"level": "info",
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "提示类标题",
|
||||
"body": "提示类文案",
|
||||
"level": "info",
|
||||
"className": "mb-3"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "成功类文案",
|
||||
"level": "success",
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "成功类标题",
|
||||
"body": "成功类文案",
|
||||
"level": "success",
|
||||
"className": "mb-3"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "警告类文案",
|
||||
"level": "warning",
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "警告类标题",
|
||||
"body": "警告类文案",
|
||||
"level": "warning",
|
||||
"className": "mb-3"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "危险类文案",
|
||||
"level": "danger",
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "危险类标题",
|
||||
"body": "危险类文案",
|
||||
"level": "danger",
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
## 图标
|
||||
|
||||
配置`"showIcon": true`后展示图标让信息更加醒目。可以通过`icon`属性自定义设置 icon 内容,如果`icon`属性为空,则根据`level`值添加默认 icon。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "提示类文案",
|
||||
"level": "info",
|
||||
"showIcon": true,
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "提示类标题",
|
||||
"body": "提示类文案",
|
||||
"level": "info",
|
||||
"showIcon": true,
|
||||
"className": "mb-3"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "成功类文案",
|
||||
"level": "success",
|
||||
"showIcon": true,
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "成功类标题",
|
||||
"body": "成功类文案",
|
||||
"level": "success",
|
||||
"showIcon": true,
|
||||
"className": "mb-3"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "警告类文案",
|
||||
"level": "warning",
|
||||
"showIcon": true,
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "警告类标题",
|
||||
"body": "警告类文案",
|
||||
"level": "warning",
|
||||
"showIcon": true,
|
||||
"className": "mb-3"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "危险类文案",
|
||||
"level": "danger",
|
||||
"showIcon": true,
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "危险类标题",
|
||||
"body": "危险类文案",
|
||||
"level": "danger",
|
||||
"showIcon": true,
|
||||
"className": "mb-3"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "自定义ICON文案",
|
||||
"showIcon": true,
|
||||
"icon": "info-circle",
|
||||
"className": "mb-1"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "自定义ICON标题",
|
||||
"body": "自定义ICON文案",
|
||||
"showIcon": true,
|
||||
"icon": "fa fa-list"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## level 支持表达式
|
||||
|
||||
> 1.6.4 及以上版本
|
||||
|
||||
修改下面例子的 status 值为 2 就能看到变化
|
||||
|
||||
```schema:
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"status": 1
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "alert",
|
||||
"level": "${IFS(status===1, 'danger', status===2, 'warning')}",
|
||||
"body": "这是内容区"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
同时 icon 和 showIcon 也都支持表达式
|
||||
|
||||
## 显示关闭按钮
|
||||
|
||||
配置`"showCloseButton": true`实现显示关闭按钮。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "显示关闭按钮的提示",
|
||||
"level": "info",
|
||||
"showCloseButton": true,
|
||||
"showIcon": true,
|
||||
"className": "mb-2"
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"title": "可关闭提示",
|
||||
"body": "显示关闭按钮的提示",
|
||||
"level": "success",
|
||||
"showCloseButton": true,
|
||||
"showIcon": true
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 操作区域
|
||||
|
||||
> `3.6.0`及以上版本
|
||||
|
||||
配置`actions`属性,可以添加操作区域。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "alert",
|
||||
"level": "success",
|
||||
"className": "mb-3",
|
||||
"showIcon": true,
|
||||
"showCloseButton": true,
|
||||
"title": "标题",
|
||||
"body": "创建成功",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "查看详情",
|
||||
"size": "xs",
|
||||
"level": "link",
|
||||
"style": {
|
||||
"position": "relative",
|
||||
"top": "25px",
|
||||
"left": "30px"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "alert",
|
||||
"level": "info",
|
||||
"showIcon": true,
|
||||
"showCloseButton": true,
|
||||
"body": "创建成功",
|
||||
"actions": {
|
||||
"type": "flex",
|
||||
"justify": "flex-start",
|
||||
"alignItems": "flex-start",
|
||||
"direction": "column",
|
||||
"style": {"padding": "6px"},
|
||||
"items": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "详情",
|
||||
"size": "xs",
|
||||
"level": "primary",
|
||||
"style": {
|
||||
"marginBottom": "5px"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "关闭",
|
||||
"size": "xs",
|
||||
"level": "danger"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| -------------------- | ----------------------------------------- | --------- | -------------------------------------------------------- | --- |
|
||||
| type | `string` | `"alert"` | 指定为 alert 渲染器 |
|
||||
| title | `string` | | alert标题 |
|
||||
| className | `string` | | 外层 Dom 的类名 |
|
||||
| level | `string` | `info` | 级别,可以是:`info`、`success`、`warning` 或者 `danger` |
|
||||
| body | [`SchemaNode[] \| SchemaNode`](../../docs/types/schemanode) | | 显示内容 |
|
||||
| showCloseButton | `boolean` | `false` | 是否显示关闭按钮 |
|
||||
| closeButtonClassName | `string` | | 关闭按钮的 CSS 类名 |
|
||||
| showIcon | `boolean` | `false` | 是否显示 icon |
|
||||
| icon | `string` | | 自定义 icon |
|
||||
| iconClassName | `string` | | icon 的 CSS 类名 |
|
||||
| actions | [`SchemaNode[] \| SchemaNode`](../../docs/types/schemanode) | | 操作区域 | `3.6.0` |
|
||||
87
docs/zh-CN/components/amis.md
Normal file
87
docs/zh-CN/components/amis.md
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
title: AMIS 渲染器
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: AMIS 渲染器
|
||||
icon:
|
||||
order: 28
|
||||
---
|
||||
|
||||
用于渲染数据中的 amis 配置
|
||||
|
||||
## 基本使用
|
||||
|
||||
只需要设置 schema 或 name,值可以是 JSON 对象或字符串的 JSON
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "amis",
|
||||
"schema": {
|
||||
"type": "tpl",
|
||||
"tpl": "amis render"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 通过 name 绑定动态数据
|
||||
|
||||
可以用在表单或 CRUD 中,下面示例演示了编辑后实时渲染的效果,因为使用了相同 的 name
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"title": "实时测试 amis 渲染效果",
|
||||
"body": [
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"name": "amis",
|
||||
"language": "json",
|
||||
"value": {
|
||||
"label": "弹框",
|
||||
"type": "button",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "弹框",
|
||||
"body": "这是个简单的弹框。"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "amis",
|
||||
"name": "amis"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 向下传递 props
|
||||
|
||||
通过设置 props 向下传递,这个 props 会作为默认值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "amis",
|
||||
"props": {
|
||||
"tpl": "amis render"
|
||||
},
|
||||
"value": {
|
||||
"type": "tpl"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------ | -------- | -------- | ------------------ |
|
||||
| type | `string` | `"amis"` | 指定为 amis 渲染器 |
|
||||
| name | `string` | | 绑定上下文变量名 |
|
||||
| props | `object` | | 向下传递的 props |
|
||||
493
docs/zh-CN/components/anchor-nav.md
Normal file
493
docs/zh-CN/components/anchor-nav.md
Normal file
@@ -0,0 +1,493 @@
|
||||
---
|
||||
title: AnchorNav 锚点导航
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: AnchorNav
|
||||
icon:
|
||||
order: 68
|
||||
---
|
||||
|
||||
锚点导航容器组件。
|
||||
|
||||
## 基本用法
|
||||
|
||||
`6.1.0`及以上版本垂直方向支持配置子节点
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "anchor-nav",
|
||||
"links": [
|
||||
{
|
||||
"title": "基本信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "基本信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
{
|
||||
"name": "email",
|
||||
"type": "input-email",
|
||||
"label": "邮箱:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "工作信息",
|
||||
"children": [
|
||||
{
|
||||
"title": "工作信息-1",
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "workInfo1-1",
|
||||
"label": "工作信息1-1:"
|
||||
},
|
||||
{
|
||||
"name": "workInfo1-2",
|
||||
"type": "input-text",
|
||||
"label": "工作信息1-2"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "工作信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "cname",
|
||||
"label": "公司名称:"
|
||||
},
|
||||
{
|
||||
"name": "caddress",
|
||||
"type": "input-text",
|
||||
"label": "公司地址:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "兴趣爱好",
|
||||
"children": [
|
||||
{
|
||||
"title": "兴趣爱好1-1",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "兴趣爱好1-1",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "interest1-1",
|
||||
"label": "interest1-1"
|
||||
},
|
||||
{
|
||||
"name": "interest1-2",
|
||||
"type": "input-text",
|
||||
"label": "interest1-2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "兴趣爱好",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "interest1",
|
||||
"label": "兴趣爱好1:"
|
||||
},
|
||||
{
|
||||
"name": "interest2",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好2:"
|
||||
},
|
||||
{
|
||||
"name": "interest3",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好3:"
|
||||
},
|
||||
{
|
||||
"name": "interest4",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好4:"
|
||||
},
|
||||
{
|
||||
"name": "interest5",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好5:"
|
||||
},
|
||||
{
|
||||
"name": "interest6",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好6:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
默认想要显示多少锚点导航配置多少个 `links` 成员即可。
|
||||
|
||||
## 水平导航
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "anchor-nav",
|
||||
"direction": "horizontal",
|
||||
"links": [
|
||||
{
|
||||
"title": "基本信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "基本信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
{
|
||||
"name": "email",
|
||||
"type": "input-email",
|
||||
"label": "邮箱:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "工作信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "工作信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "cname",
|
||||
"label": "公司名称:"
|
||||
},
|
||||
{
|
||||
"name": "caddress",
|
||||
"type": "input-text",
|
||||
"label": "公司地址:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "兴趣爱好",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "兴趣爱好",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "interest1",
|
||||
"label": "兴趣爱好1:"
|
||||
},
|
||||
{
|
||||
"name": "interest2",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好2:"
|
||||
},
|
||||
{
|
||||
"name": "interest3",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好3:"
|
||||
},
|
||||
{
|
||||
"name": "interest4",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好4:"
|
||||
},
|
||||
{
|
||||
"name": "interest5",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好5:"
|
||||
},
|
||||
{
|
||||
"name": "interest6",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好6:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 默认定位到某个区域
|
||||
|
||||
主要配置`active`属性来实现该效果,共有下面两种方法:
|
||||
|
||||
#### 配置 href 值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "anchor-nav",
|
||||
"active": "work",
|
||||
"links": [
|
||||
{
|
||||
"title": "基本信息",
|
||||
"href": "base",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "基本信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
{
|
||||
"name": "email",
|
||||
"type": "input-email",
|
||||
"label": "邮箱:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "工作信息",
|
||||
"href": "work",
|
||||
"children": [
|
||||
{
|
||||
"title": "工作信息-1",
|
||||
"href": "work-1",
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "workInfo1-1",
|
||||
"label": "工作信息1-1:"
|
||||
},
|
||||
{
|
||||
"name": "workInfo1-2",
|
||||
"type": "input-text",
|
||||
"label": "工作信息1-2"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "工作信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "cname",
|
||||
"label": "公司名称:"
|
||||
},
|
||||
{
|
||||
"name": "caddress",
|
||||
"type": "input-text",
|
||||
"label": "公司地址:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "兴趣爱好",
|
||||
"href": "interest",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "兴趣爱好",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "interest1",
|
||||
"label": "兴趣爱好1:"
|
||||
},
|
||||
{
|
||||
"name": "interest2",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好2:"
|
||||
},
|
||||
{
|
||||
"name": "interest3",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好3:"
|
||||
},
|
||||
{
|
||||
"name": "interest4",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好4:"
|
||||
},
|
||||
{
|
||||
"name": "interest5",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好5:"
|
||||
},
|
||||
{
|
||||
"name": "interest6",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好6:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### 配置索引值
|
||||
|
||||
单个`link`上不要配置`href`属性,配置需要展示的`link`索引值,`0`代表第一个。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "anchor-nav",
|
||||
"active": 1,
|
||||
"links": [
|
||||
{
|
||||
"title": "基本信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "基本信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
{
|
||||
"name": "email",
|
||||
"type": "input-email",
|
||||
"label": "邮箱:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "工作信息",
|
||||
"children": [
|
||||
{
|
||||
"title": "工作信息-1",
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "workInfo1-1",
|
||||
"label": "工作信息1-1:"
|
||||
},
|
||||
{
|
||||
"name": "workInfo1-2",
|
||||
"type": "input-text",
|
||||
"label": "工作信息1-2"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "工作信息",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "cname",
|
||||
"label": "公司名称:"
|
||||
},
|
||||
{
|
||||
"name": "caddress",
|
||||
"type": "input-text",
|
||||
"label": "公司地址:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "兴趣爱好",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"title": "兴趣爱好",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "interest1",
|
||||
"label": "兴趣爱好1:"
|
||||
},
|
||||
{
|
||||
"name": "interest2",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好2:"
|
||||
},
|
||||
{
|
||||
"name": "interest3",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好3:"
|
||||
},
|
||||
{
|
||||
"name": "interest4",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好4:"
|
||||
},
|
||||
{
|
||||
"name": "interest5",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好5:"
|
||||
},
|
||||
{
|
||||
"name": "interest6",
|
||||
"type": "input-text",
|
||||
"label": "兴趣爱好6:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------------ | --------------------------------- | ----------------------------------- | -------------------------------------------------------------------------- |
|
||||
| type | `string` | `"anchor-nav"` | 指定为 AnchorNav 渲染器 |
|
||||
| className | `string` | | 外层 Dom 的类名 |
|
||||
| linkClassName | `string` | | 导航 Dom 的类名 |
|
||||
| sectionClassName | `string` | | 锚点区域 Dom 的类名 |
|
||||
| links | `Array` | | links 内容 |
|
||||
| direction | `string` | `"vertical"` | 可以配置导航水平展示还是垂直展示。对应的配置项分别是:vertical、horizontal |
|
||||
| active | `string` | | 需要定位的区域 |
|
||||
| links[x].title | `string` | | 区域 标题 |
|
||||
| links[x].href | `string` | | 区域 标识 |
|
||||
| links[x].body | [SchemaNode](../types/schemanode) | | 区域 内容区,`6.1.0`及以上版本垂直方向支持配置子节点 |
|
||||
| links[x].className | `string` | `"bg-white b-l b-r b-b wrapper-md"` | 区域成员 样式 |
|
||||
87
docs/zh-CN/components/app.md
Normal file
87
docs/zh-CN/components/app.md
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
title: App 多页应用
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: App 多页应用
|
||||
icon:
|
||||
order: 99
|
||||
---
|
||||
|
||||
用于实现多页应用,适合于全屏模式,如果只是局部渲染请不要使用。
|
||||
|
||||
## 基本用法
|
||||
|
||||
类型定义为 `app`,通过 pages 定义页面,支持层级,支持内嵌 schema,或者 通过 schemaApi 远程拉取页面,完整用法请参考 [amis-admin](https://github.com/aisuda/amis-admin) 项目里的代码示例,需要修改 `env`:
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "app",
|
||||
"brandName": "应用名称",
|
||||
"pages": [
|
||||
{
|
||||
"label": "分组1",
|
||||
"children": [
|
||||
{
|
||||
"label": "父页面",
|
||||
"url": "/parent",
|
||||
"children": [
|
||||
{
|
||||
"label": "子页面",
|
||||
"url": "pageA",
|
||||
"schema": {
|
||||
"type": "page",
|
||||
"title": "Page A"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## 属性说明
|
||||
|
||||
- `type` 请配置成 `app`
|
||||
- `api` 页面配置接口,如果你想远程拉取页面配置请配置。返回配置路径 `json>data>pages`,具体格式请参考 `pages` 属性。
|
||||
- `brandName` 应用名称。
|
||||
- `logo` 支持图片地址,或者 svg。
|
||||
- `className` css 类名。
|
||||
- `header` 顶部区域。
|
||||
- `asideBefore` 页面菜单上前面区域。
|
||||
- `asideAfter` 页面菜单下前面区域。
|
||||
- `footer` 页面。
|
||||
- `pages` `Array<页面配置>`具体的页面配置。
|
||||
通常为数组,数组第一层为分组,一般只需要配置 label 集合,如果你不想分组,直接不配置,真正的页面请在第二层开始配置,即第一层的 children 中。
|
||||
|
||||
具体的页面配置也支持属性结构,每层有以下配置。
|
||||
|
||||
- `label` 菜单名称。
|
||||
- `icon` 菜单图标,比如:fa fa-file.
|
||||
- `url` 页面路由路径,当路由命中该路径时,启用当前页面。当路径不是 `/` 打头时,会连接父级路径。比如:父级的路径为 `folder`,而此时配置 `pageA`, 那么当页面地址为 `/folder/pageA` 时才会命中此页面。当路径是 `/` 开头如: `/crud/list` 时,则不会拼接父级路径。另外还支持 `/crud/view/:id` 这类带参数的路由,页面中可以通过 `${params.id}` 取到此值。
|
||||
- `schema` 页面的配置,具体配置请前往 [Page 页面说明](./page)
|
||||
- `schemaApi` 如果想通过接口拉取,请配置。返回路径为 `json>data`。schema 和 schemaApi 只能二选一。
|
||||
- `link` 如果想配置个外部链接菜单,只需要配置 link 即可。
|
||||
- `redirect` 跳转,当命中当前页面时,跳转到目标页面。
|
||||
- `rewrite` 改成渲染其他路径的页面,这个方式页面地址不会发生修改。
|
||||
- `isDefaultPage` 当你需要自定义 404 页面的时候有用,不要出现多个这样的页面,因为只有第一个才会有用。
|
||||
- `visible` 有些页面可能不想出现在菜单中,可以配置成 `false`,另外带参数的路由无需配置,直接就是不可见的。
|
||||
- `className` 菜单类名。
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | -------- | --------------------------------------------------- |
|
||||
| init | - | 组件实例被创建并插入 DOM 中时触发。2.4.1 及以上版本 |
|
||||
|
||||
## 动作表
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------------------------- | ---------------- |
|
||||
| reload | - | 刷新(重新加载) |
|
||||
| setValue | `value: object` 更新的数据 | 更新数据 |
|
||||
31
docs/zh-CN/components/audio.md
Executable file
31
docs/zh-CN/components/audio.md
Executable file
@@ -0,0 +1,31 @@
|
||||
---
|
||||
title: Audio 音频
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Audio 音频
|
||||
icon:
|
||||
order: 28
|
||||
---
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "audio",
|
||||
"src": "https://amis.bj.bcebos.com/amis/2019-7/1562137295708/chicane-poppiholla-original-radio-edit%20(1).mp3"
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------- | --------- | ------------------------------------------------ | --------------------------------------- |
|
||||
| type | `string` | `"audio"` | 指定为 audio 渲染器 |
|
||||
| className | `string` | | 外层 Dom 的类名 |
|
||||
| inline | `boolean` | true | 是否是内联模式 |
|
||||
| src | `string` | | 音频地址 |
|
||||
| loop | `boolean` | false | 是否循环播放 |
|
||||
| autoPlay | `boolean` | false | 是否自动播放 |
|
||||
| rates | `array` | `[]` | 可配置音频播放倍速如:`[1.0, 1.5, 2.0]` |
|
||||
| controls | `array` | `['rates', 'play', 'time', 'process', 'volume']` | 内部模块定制化 |
|
||||
342
docs/zh-CN/components/avatar.md
Normal file
342
docs/zh-CN/components/avatar.md
Normal file
@@ -0,0 +1,342 @@
|
||||
---
|
||||
title: Avatar 头像
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Avatar 头像
|
||||
icon:
|
||||
order: 27
|
||||
---
|
||||
|
||||
用来显示用户头像
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"src": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
}
|
||||
```
|
||||
|
||||
## 文字
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"text": "AM"
|
||||
}
|
||||
```
|
||||
|
||||
## 图标
|
||||
|
||||
通过 icon 设置图标
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"icon": "fa fa-user"
|
||||
}
|
||||
```
|
||||
|
||||
> 如果同时存在 src、text 和 icon,会优先用 src、接着 text、最后 icon
|
||||
|
||||
## 动态图片或文字
|
||||
|
||||
src、text 都支持变量,可以从上下文中动态获取图片或文字,下面的例子中:
|
||||
|
||||
- 第一个获取到了,显示正常
|
||||
- 第二个没获取到,因此降级为显示 icon
|
||||
- 第三个图片没获取到,由于 text 优先级比 icon 高,所以显示 text
|
||||
|
||||
```schema
|
||||
{
|
||||
"data": {
|
||||
"myAvatar": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
},
|
||||
"type": "page",
|
||||
"body": [
|
||||
{
|
||||
"type": "avatar",
|
||||
"icon": "fa fa-user",
|
||||
"src": "$myAvatar"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"icon": "fa fa-user",
|
||||
"src": "$other"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"src": "$other",
|
||||
"icon": "fa fa-user",
|
||||
"text": "avatar"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 方形和圆角形
|
||||
|
||||
可以通过 shape 改成方形或圆角形
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"shape": "square",
|
||||
"text": "AM"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"shape": "rounded",
|
||||
"text": "AM",
|
||||
"style": {
|
||||
"marginLeft": "10px"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
## 大小
|
||||
|
||||
通过 size 可以控制头像的大小
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"size": 'large',
|
||||
"icon": "fa fa-user"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"size": 'default',
|
||||
"icon": "fa fa-user"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"size": 'small',
|
||||
"icon": "fa fa-user"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"size": 60,
|
||||
"src": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"src": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"size": 20,
|
||||
"src": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
},
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
## 控制字符类型距离左右两侧边界单位像素
|
||||
|
||||
通过 gap 可以控制字符类型距离左右两侧边界单位像素
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"text": 'ejson',
|
||||
"gap": 2
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"text": "ejson",
|
||||
"gap": 7
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
## 图片拉伸方式
|
||||
|
||||
通过 `fit` 可以控制图片拉伸方式,默认是 `'cover'`
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"fit": "cover",
|
||||
"src": "https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"fit": "fill",
|
||||
"src": "https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"fit": "contain",
|
||||
"src": "https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"fit": "none",
|
||||
"src": "https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"fit": "scale-down",
|
||||
"src": "https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 控制图片是否允许拖动
|
||||
|
||||
通过 draggable 可以控制图片是否允许拖动
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"fit": "cover",
|
||||
"src": "https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg",
|
||||
"draggable": false
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"fit": "cover",
|
||||
"src": "https://suda.cdn.bcebos.com/images/amis/plumeria.jpeg",
|
||||
"draggable": true
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 图片加载失败后,通过 onError 控制是否进行 text、icon 置换
|
||||
|
||||
> 如果同时存在 text 和 icon,会优先用 text、接着 icon
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"src": "empty",
|
||||
"text": "avatar",
|
||||
"onError": "return true;"
|
||||
},
|
||||
```
|
||||
|
||||
## 样式
|
||||
|
||||
可以通过 style 来控制背景及文字颜色
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"text": "AM",
|
||||
"style": {
|
||||
"background": "#DB3E35",
|
||||
"color": "#FFFFFF"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------- | ------------------------------------------------------------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| className | `string` | | 外层 dom 的类名 |
|
||||
| style | `object` | | 外层 dom 的样式 |
|
||||
| fit | `'contain'` \| `'cover'` \| `'fill'` \| `'none'` \| `'scale-down'` | `'cover'` | 具体细节可以参考 MDN [文档](https://developer.mozilla.org/zh-CN/docs/Web/CSS/object-fit) |
|
||||
| src | `string` | | 图片地址 |
|
||||
| defaultAvatar | `string` | | 占位图 |
|
||||
| text | `string` | | 文字 |
|
||||
| icon | `string` | `'fa fa-user'` | 图标 |
|
||||
| shape | `'circle'` \| `'square'` \| `'rounded'` | `'circle'` | 形状,有三种 `'circle'` (圆形)、`'square'`(正方形)、`'rounded'`(圆角) |
|
||||
| size | `number` \| `'default'` \| `'normal'` \| `'small'` | `'default'` | `'default' \| 'normal' \| 'small'`三种字符串类型代表不同大小(分别是 48、40、32),也可以直接数字表示 |
|
||||
| gap | `number` | 4 | 控制字符类型距离左右两侧边界单位像素 |
|
||||
| alt | `number` | | 图像无法显示时的替代文本 |
|
||||
| draggable | `boolean` | | 图片是否允许拖动 |
|
||||
| crossOrigin | `'anonymous'` \| `'use-credentials'` \| `''` | | 图片的 `CORS` 属性设置 |
|
||||
| onError | `string` | | 图片加载失败的字符串,这个字符串是一个 New Function 内部执行的字符串,参数是 event(使用 event.nativeEvent 获取原生 dom 事件),这个字符串需要返回 boolean 值。设置 `"return ture;"` 会在图片加载失败后,使用 `text` 或者 `icon` 代表的信息来进行替换。目前图片加载失败默认是不进行置换。注意:图片加载失败,不包括$获取数据为空情况 |
|
||||
|
||||
## 事件表
|
||||
|
||||
> 6.1.0 及以上版本
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| ---------- | -------- | -------------- |
|
||||
| click | - | 点击时触发 |
|
||||
| mouseenter | - | 鼠标移入时触发 |
|
||||
| mouseleave | - | 鼠标移出时触发 |
|
||||
|
||||
### click
|
||||
|
||||
鼠标点击。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.context.nativeEvent.type}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### mouseenter
|
||||
|
||||
鼠标移入。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"onEvent": {
|
||||
"mouseenter": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.context.nativeEvent.type}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### mouseleave
|
||||
|
||||
鼠标移出。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "avatar",
|
||||
"onEvent": {
|
||||
"mouseleave": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.context.nativeEvent.type}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
370
docs/zh-CN/components/badge.md
Normal file
370
docs/zh-CN/components/badge.md
Normal file
@@ -0,0 +1,370 @@
|
||||
---
|
||||
title: Badge 角标
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Badge
|
||||
icon:
|
||||
order: 30
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
部分组件可以设置 `badge` 属性来显示角标。
|
||||
|
||||
> 1.2.2 及之前版本只支持头像组件
|
||||
>
|
||||
> 1.2.3 开始支持按钮、链接、模板组件。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "action",
|
||||
"label": "按钮",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 15
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"href": "https://www.baidu.com",
|
||||
"body": "百度一下,你就知道",
|
||||
"badge": {
|
||||
"position": "top-right"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "Hello ${text}",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "icon",
|
||||
"icon": "cloud",
|
||||
"className": "text-info text-xl",
|
||||
"badge": {
|
||||
"position": "top-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "action",
|
||||
"label": "按钮",
|
||||
"badge": {
|
||||
"mode": "ribbon",
|
||||
"text": "HOT"
|
||||
}
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
## 显示文字或数值
|
||||
|
||||
设置 `mode` 为 `text`,通过 `text` 属性来显示文字或数字,数值为零的时候将不显示。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": "new"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 显示位置
|
||||
|
||||
通过 `position` 来控制角标显示位置,默认 `top-right`,还可以设置为 `top-left`、`bottom-left`、`bottom-right`。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"position": "top-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"position": "bottom-left"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"position": "bottom-right"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
通过 `offset` 来控制角标显示位置,offset 相对于 position 位置进行水平、垂直偏移。offset 在 mode=ribbon 下设置无效。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"offset": [10, 10]
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 动态数字
|
||||
|
||||
`text` 可以取上下文变量。
|
||||
|
||||
```schema
|
||||
{
|
||||
"data": {
|
||||
"myData": 10
|
||||
},
|
||||
"type": "page",
|
||||
"body": [
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"visibleOn": "this.myData > 1",
|
||||
"text": "${myData}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置封顶值
|
||||
|
||||
通过 `overflowCount` 可以设置封顶值。超过 overflowCount 的会显示为 ${overflowCount}+,默认的 overflowCount 为 99
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": [
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10,
|
||||
"overflowCount": 9
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动态控制是否显示角标
|
||||
|
||||
角标可以直接写表达式来判断是否显示
|
||||
|
||||
```schema
|
||||
{
|
||||
"data": {
|
||||
"myData": 10
|
||||
},
|
||||
"type": "page",
|
||||
"body": [
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": "this.myData > 1"
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": "this.myData > 10"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
还可以通过 `visibleOn` 表达式来动态控制,这样还能设置其他属性
|
||||
|
||||
```schema
|
||||
{
|
||||
"data": {
|
||||
"myData": 10
|
||||
},
|
||||
"type": "page",
|
||||
"body": [
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"visibleOn": "this.myData > 1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"visibleOn": "this.myData > 10"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置大小
|
||||
|
||||
通过 `size` 来控制大小
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10,
|
||||
"size": 20
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10,
|
||||
"size": 12
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"size": 12
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"size": 4
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 设置角标级别
|
||||
|
||||
通过 `level` 来设置角标级别,改变角标背景颜色
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10,
|
||||
"size": 20,
|
||||
"level": "success"
|
||||
}
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
## 是否显示动画
|
||||
|
||||
在默认点状态下,可以通过设置 `animation` 属性来控制是否显示动画
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"animation": true
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 自定义样式
|
||||
|
||||
通过 `style` 来控制展现样式,比如背景及文字的颜色
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "avatar",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10,
|
||||
"style": {
|
||||
"background": "#46C93A"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "avatar",
|
||||
"className": "m-l",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 10,
|
||||
"style": {
|
||||
"background": "#1A5CFF"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------- | ------------------------------------------- | --------- | ---------------------------------------------------------------------- |
|
||||
| mode | `string` | dot | 角标类型,可以是 dot/text/ribbon |
|
||||
| text | `string`\|`number` | | 角标文案,支持字符串和数字,在 mode='dot'下设置无效 |
|
||||
| size | `number` | | 角标大小 |
|
||||
| level | `string` | | 角标级别, 可以是 info/success/warning/danger, 设置之后角标背景颜色不同 |
|
||||
| overflowCount | `number` | 99 | 设置封顶的数字值 |
|
||||
| position | `string` | top-right | 角标位置, 可以是 top-right/top-left/bottom-right/bottom-left |
|
||||
| offset | `number[top, left]` | [0, 0] | 角标位置,offset 相对于 position 位置进行水平、垂直偏移 |
|
||||
| className | `string` | | 外层 dom 的类名 |
|
||||
| animation | `boolean` | | 角标是否显示动画 |
|
||||
| style | `object` | | 角标的自定义样式 |
|
||||
| visibleOn | [表达式](../../../docs/concepts/expression) | | 控制角标的显示隐藏 |
|
||||
43
docs/zh-CN/components/barcode.md
Normal file
43
docs/zh-CN/components/barcode.md
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: BarCode 条形码
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: BarCode 条形码
|
||||
icon:
|
||||
order: 62
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "barcode",
|
||||
"value": "amis"
|
||||
}
|
||||
```
|
||||
|
||||
## 条形码配置
|
||||
|
||||
通过 options 属性配置,具体请参考[这里](https://github.com/lindell/JsBarcode/wiki/Options),比如
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "barcode",
|
||||
"value": "123",
|
||||
"options": {
|
||||
"format": "pharmacode",
|
||||
"lineColor": "#0aa",
|
||||
"width": "4",
|
||||
"height": "40",
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------- | -------- | ------ | ------------------------------ |
|
||||
| className | `string` | | 外层 CSS 类名 |
|
||||
| value | `string` | | 显示的颜色值 |
|
||||
| name | `string` | | 在其他组件中,时,用作变量映射 |
|
||||
163
docs/zh-CN/components/breadcrumb.md
Normal file
163
docs/zh-CN/components/breadcrumb.md
Normal file
@@ -0,0 +1,163 @@
|
||||
---
|
||||
title: Breadcrumb 面包屑
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Breadcrumb
|
||||
icon:
|
||||
order: 30
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "breadcrumb",
|
||||
"items": [
|
||||
{
|
||||
"label": "首页",
|
||||
"href": "https://baidu.gitee.com/",
|
||||
"icon": "fa fa-home"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "上级页面"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "当前页面"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动态数据
|
||||
|
||||
可以配置 source 来获取上下文中的动态数据,结合 [service](service) 来实现动态生成。
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"breadcrumb": [
|
||||
{
|
||||
"label": "首页",
|
||||
"href": "https://baidu.gitee.com/"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "上级页面"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "当前页面"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": {
|
||||
"type": "breadcrumb",
|
||||
"source": "${breadcrumb}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 分隔符
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "breadcrumb",
|
||||
"separator": ">",
|
||||
"separatorClassName": "text-black",
|
||||
"items": [
|
||||
{
|
||||
"href": "https://baidu.gitee.com/",
|
||||
"icon": "fa fa-home"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "上级页面"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "当前页面"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 下拉菜单
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "breadcrumb",
|
||||
"separator": ">",
|
||||
"separatorClassName": "text-black",
|
||||
"items": [
|
||||
{
|
||||
"label": "首页",
|
||||
"href": "https://baidu.gitee.com/",
|
||||
"icon": "fa fa-home"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "上级页面",
|
||||
"dropdown": [
|
||||
{
|
||||
"label": "选项一",
|
||||
"href": "https://baidu.gitee.com/",
|
||||
},
|
||||
{
|
||||
"label": "选项二"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "当前页面"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 最大展示长度
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "breadcrumb",
|
||||
"separator": ">",
|
||||
"separatorClassName": "text-black",
|
||||
"labelMaxLength": 16,
|
||||
"tooltipPosition": "top",
|
||||
"items": [
|
||||
{
|
||||
"href": "https://baidu.gitee.com/",
|
||||
"icon": "fa fa-home"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "上级页面上级页面上级页面上级页面上级页面"
|
||||
},
|
||||
|
||||
{
|
||||
"label": "当前页面"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------------ | -------------------------------- | ------------- | ---------------------------------------------------- |
|
||||
| className | `string` | | 外层类名 |
|
||||
| itemClassName | `string` | | 导航项类名 |
|
||||
| separatorClassName | `string` | | 分割符类名 |
|
||||
| dropdownClassName | `string` | | 下拉菜单类名 |
|
||||
| dropdownItemClassName | `string` | | 下拉菜单项类名 |
|
||||
| separator | `string` | | 分隔符 |
|
||||
| labelMaxLength | `number` | 16 | 最大展示长度 |
|
||||
| tooltipPosition | `top \| bottom \| left \| right` | `top` | 浮窗提示位置 |
|
||||
| source | `string` | | 动态数据 |
|
||||
| items[].label | `string` | | 文本 |
|
||||
| items[].href | `string` | | 链接 |
|
||||
| items[].icon | `string` | | [图标](icon) |
|
||||
| items[].dropdown | `dropdown[]` | | 下拉菜单,dropdown[]的每个对象都包含label、href、icon属性 |
|
||||
137
docs/zh-CN/components/button-group.md
Executable file
137
docs/zh-CN/components/button-group.md
Executable file
@@ -0,0 +1,137 @@
|
||||
---
|
||||
title: ButtonGroup 按钮组
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: ButtonGroup
|
||||
icon:
|
||||
order: 30
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button-group",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "Button",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"confirmMode": false,
|
||||
"title": "提示",
|
||||
"body": "对,你刚点击了!"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "url",
|
||||
"url": "https://www.baidu.com",
|
||||
"blank": true,
|
||||
"label": "百度一下"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "button",
|
||||
"label": "普通按钮"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 垂直模式
|
||||
|
||||
配置`"vertical": true`,实现垂直模式
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "button-group",
|
||||
"vertical": true,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 平铺模式
|
||||
|
||||
配置 `"tiled": true` 实现平铺模式
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "button-group",
|
||||
"tiled": true,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 按钮主题样式
|
||||
|
||||
配置 `btnLevel` 统一设置按钮主题样式,注意 `buttons ` 或 `options` 中的`level`属性优先级高于`btnLevel`。配置 `btnActiveLevel` 为按钮设置激活态时的主题样式。
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "button-group",
|
||||
"btnLevel": "light",
|
||||
"btnActiveLevel": "warning",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3",
|
||||
"level": "primary"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| -------------- | ------------------------------------------------------------------------------------------------------------------- | ---------------- | -------------------------- |
|
||||
| type | `string` | `"button-group"` | 指定为 button-group 渲染器 |
|
||||
| vertical | `boolean` | `false` | 是否使用垂直模式 |
|
||||
| tiled | `boolean` | `false` | 是否使用平铺模式 |
|
||||
| btnLevel | `'link' \| 'primary' \| 'secondary' \| 'info'\|'success' \| 'warning' \| 'danger' \| 'light'\| 'dark' \| 'default'` | `"default"` | 按钮样式 |
|
||||
| btnActiveLevel | `'link' \| 'primary' \| 'secondary' \| 'info'\|'success' \| 'warning' \| 'danger' \| 'light'\| 'dark' \| 'default'` | `"default"` | 选中按钮样式 |
|
||||
| buttons | `Array<Action>` | | [按钮](./action) |
|
||||
| className | `string` | | 外层 Dom 的类名 |
|
||||
43
docs/zh-CN/components/button.md
Executable file
43
docs/zh-CN/components/button.md
Executable file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
title: Button 按钮
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Button 按钮
|
||||
icon:
|
||||
order: 29
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"label": "弹个框",
|
||||
"type": "button",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "弹框",
|
||||
"body": "这是个简单的弹框。"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`button` 实际上是 `action` 的别名,更多用法见 [action](./action)
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------- | ----------------------------------------------------- |
|
||||
| className | `string` | | 指定添加 button 类名 |
|
||||
| url | `string` | | 点击跳转的地址,指定此属性 button 的行为和 a 链接一致 |
|
||||
| size | `'xs' \| 'sm' \| 'md' \| 'lg' ` | | 设置按钮大小 |
|
||||
| actionType | `'button' \| 'reset' \| 'submit'\| 'clear'\| 'url'` | button | 设置按钮类型 |
|
||||
| level | `'link' \| 'primary' \| 'enhance' \| 'secondary' \| 'info'\|'success' \| 'warning' \| 'danger' \| 'light'\| 'dark' \| 'default'` | default | 设置按钮样式 |
|
||||
| tooltip | `'string' \| 'TooltipObject'` | | 气泡提示内容 |
|
||||
| tooltipPlacement | `'top' \| 'right' \| 'bottom' \| 'left' ` | top | 气泡框位置器 |
|
||||
| tooltipTrigger | `'hover' \| 'focus'` | | 触发 tooltip |
|
||||
| disabled | `'boolean'` | false | 按钮失效状态 |
|
||||
| disabledTip | `'string' \| 'TooltipObject'` | | 按钮失效状态下的提示 |
|
||||
| block | `'boolean'` | false | 将按钮宽度调整为其父宽度的选项 |
|
||||
| loading | `'boolean'` | false | 显示按钮 loading 效果 |
|
||||
| loadingOn | `'string'` | | 显示按钮 loading 表达式 |
|
||||
238
docs/zh-CN/components/calendar.md
Normal file
238
docs/zh-CN/components/calendar.md
Normal file
@@ -0,0 +1,238 @@
|
||||
---
|
||||
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)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| ---------- | ------------------------ | ------------------ |
|
||||
| change | `value: string` 组件的值 | 时间值变化时触发 |
|
||||
| click | `value: string` 组件的值 | 点击日期时触发 |
|
||||
| mouseenter | `value: string` 组件的值 | 鼠标移入日期时触发 |
|
||||
| mouseleave | `value: string` 组件的值 | 鼠标移出日期时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的值 | 更新数据 |
|
||||
739
docs/zh-CN/components/card.md
Executable file
739
docs/zh-CN/components/card.md
Executable file
@@ -0,0 +1,739 @@
|
||||
---
|
||||
title: Card 卡片
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Card 卡片
|
||||
icon:
|
||||
order: 31
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"header": {
|
||||
"title": "标题",
|
||||
"subTitle": "副标题",
|
||||
"description": "这是一段描述",
|
||||
"avatarClassName": "pull-left thumb-md avatar b-3x m-r",
|
||||
"avatar": "data:image/svg+xml,%3C%3Fxml version='1.0' standalone='no'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg t='1631083237695' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2420' xmlns:xlink='http://www.w3.org/1999/xlink' width='1024' height='1024'%3E%3Cdefs%3E%3Cstyle type='text/css'%3E%3C/style%3E%3C/defs%3E%3Cpath d='M959.872 128c0.032 0.032 0.096 0.064 0.128 0.128v767.776c-0.032 0.032-0.064 0.096-0.128 0.128H64.096c-0.032-0.032-0.096-0.064-0.128-0.128V128.128c0.032-0.032 0.064-0.096 0.128-0.128h895.776zM960 64H64C28.8 64 0 92.8 0 128v768c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64V128c0-35.2-28.8-64-64-64z' p-id='2421' fill='%23bfbfbf'%3E%3C/path%3E%3Cpath d='M832 288c0 53.024-42.976 96-96 96s-96-42.976-96-96 42.976-96 96-96 96 42.976 96 96zM896 832H128V704l224-384 256 320h64l224-192z' p-id='2422' fill='%23bfbfbf'%3E%3C/path%3E%3C/svg%3E"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "Trident",
|
||||
"inline": false,
|
||||
"label": "Engine"
|
||||
},
|
||||
{
|
||||
"name": "static",
|
||||
"type": "static",
|
||||
"label": "Browser",
|
||||
"value": "Internet Explorer 5.0"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "version",
|
||||
"label": "Version",
|
||||
"size": "sm"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "编辑",
|
||||
"actionType": "dialog",
|
||||
"icon": "fa fa-pencil",
|
||||
"dialog": {
|
||||
"title": "编辑",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "删除",
|
||||
"icon": "fa fa-trash",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "提示",
|
||||
"body": "你删掉了该卡片"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 打开链接
|
||||
|
||||
> 1.4.0 及以上版本
|
||||
|
||||
通过 `href` 属性可以设置点击卡片打开外部链接
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"href": "https://github.com/baidu/amis",
|
||||
"header": {
|
||||
"title": "标题",
|
||||
"subTitle": "副标题",
|
||||
"description": "这是一段描述",
|
||||
"avatarClassName": "pull-left thumb-md avatar b-3x m-r",
|
||||
"avatar": "data:image/svg+xml,%3C%3Fxml version='1.0' standalone='no'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg t='1631083237695' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2420' xmlns:xlink='http://www.w3.org/1999/xlink' width='1024' height='1024'%3E%3Cdefs%3E%3Cstyle type='text/css'%3E%3C/style%3E%3C/defs%3E%3Cpath d='M959.872 128c0.032 0.032 0.096 0.064 0.128 0.128v767.776c-0.032 0.032-0.064 0.096-0.128 0.128H64.096c-0.032-0.032-0.096-0.064-0.128-0.128V128.128c0.032-0.032 0.064-0.096 0.128-0.128h895.776zM960 64H64C28.8 64 0 92.8 0 128v768c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64V128c0-35.2-28.8-64-64-64z' p-id='2421' fill='%23bfbfbf'%3E%3C/path%3E%3Cpath d='M832 288c0 53.024-42.976 96-96 96s-96-42.976-96-96 42.976-96 96-96 96 42.976 96 96zM896 832H128V704l224-384 256 320h64l224-192z' p-id='2422' fill='%23bfbfbf'%3E%3C/path%3E%3C/svg%3E"
|
||||
},
|
||||
"useCardLabel": false,
|
||||
"body": [
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "Trident",
|
||||
"inline": false,
|
||||
"label": "Engine"
|
||||
},
|
||||
{
|
||||
"name": "static",
|
||||
"type": "static",
|
||||
"label": "Browser",
|
||||
"value": "Internet Explorer 5.0",
|
||||
"mode": "horizontal"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "version",
|
||||
"label": "Version",
|
||||
"size": "sm",
|
||||
"mode": "horizontal"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "编辑",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "编辑",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "删除",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "提示",
|
||||
"body": "你删掉了该卡片"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置头像文本
|
||||
|
||||
如果没有 avatar,还可以通过 `avatarText` 设置头像文本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"href": "https://github.com/baidu/amis",
|
||||
"header": {
|
||||
"title": "标题",
|
||||
"subTitle": "副标题",
|
||||
"description": "这是一段描述",
|
||||
"avatarText": "AMIS"
|
||||
},
|
||||
"body": "这里是内容"
|
||||
}
|
||||
```
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
可以设置文本背景色,它会根据数据分配一个颜色,主要配合 `cards` 使用
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"items": [
|
||||
{
|
||||
"engine": "Trident",
|
||||
"browser": "Internet Explorer 4.0"
|
||||
},
|
||||
{
|
||||
"engine": "Chrome",
|
||||
"browser": "Chrome 44"
|
||||
},
|
||||
{
|
||||
"engine": "Gecko",
|
||||
"browser": "Firefox 1.0"
|
||||
},
|
||||
{
|
||||
"engine": "Presto",
|
||||
"browser": "Opera 10"
|
||||
},
|
||||
{
|
||||
"engine": "Webkie",
|
||||
"browser": "Safari 12"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": {
|
||||
"type": "cards",
|
||||
"source": "$items",
|
||||
"card": {
|
||||
"header": {
|
||||
"avatarText": "${engine|substring:0:2|upperCase}",
|
||||
"avatarTextBackground": ["#FFB900", "#D83B01", "#B50E0E", "#E81123", "#B4009E", "#5C2D91", "#0078D7", "#00B4FF", "#008272"]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"label": "Browser",
|
||||
"name": "browser"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 点击卡片的行为
|
||||
|
||||
> 1.4.0 及以上版本
|
||||
|
||||
通过设置 `itemAction` 可以设置整个卡片的点击行为
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"itemAction": {
|
||||
"type": "button",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "详情",
|
||||
"body": "当前描述"
|
||||
}
|
||||
},
|
||||
"header": {
|
||||
"title": "标题",
|
||||
"subTitle": "副标题",
|
||||
"description": "这是一段描述",
|
||||
"avatarClassName": "pull-left thumb-md avatar b-3x m-r",
|
||||
"avatar": "data:image/svg+xml,%3C%3Fxml version='1.0' standalone='no'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg t='1631083237695' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2420' xmlns:xlink='http://www.w3.org/1999/xlink' width='1024' height='1024'%3E%3Cdefs%3E%3Cstyle type='text/css'%3E%3C/style%3E%3C/defs%3E%3Cpath d='M959.872 128c0.032 0.032 0.096 0.064 0.128 0.128v767.776c-0.032 0.032-0.064 0.096-0.128 0.128H64.096c-0.032-0.032-0.096-0.064-0.128-0.128V128.128c0.032-0.032 0.064-0.096 0.128-0.128h895.776zM960 64H64C28.8 64 0 92.8 0 128v768c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64V128c0-35.2-28.8-64-64-64z' p-id='2421' fill='%23bfbfbf'%3E%3C/path%3E%3Cpath d='M832 288c0 53.024-42.976 96-96 96s-96-42.976-96-96 42.976-96 96-96 96 42.976 96 96zM896 832H128V704l224-384 256 320h64l224-192z' p-id='2422' fill='%23bfbfbf'%3E%3C/path%3E%3C/svg%3E"
|
||||
},
|
||||
"body": "这里是内容"
|
||||
}
|
||||
```
|
||||
|
||||
注意它和前面的 `href` 配置冲突,如果设置了 `href` 这个将不会生效
|
||||
|
||||
## 设置多媒体卡片
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
通过设置 `media` 可以设置为多媒体卡片, 通过 `mediaPosition` 可以设置多媒体位置
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"header": {
|
||||
"title": "标题"
|
||||
},
|
||||
"media": {
|
||||
"type": "image",
|
||||
"className": "w-36 h-24",
|
||||
"url": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"position": "left"
|
||||
},
|
||||
"body": "这里是内容",
|
||||
"secondary": "次要说明",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "操作",
|
||||
"actionType": "dialog",
|
||||
"className": "mr-4",
|
||||
"dialog": {
|
||||
"title": "操作",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "操作",
|
||||
"actionType": "dialog",
|
||||
"className": "mr-2.5",
|
||||
"dialog": {
|
||||
"title": "操作",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "dropdown-button",
|
||||
"level": "link",
|
||||
"icon": "fa fa-ellipsis-h",
|
||||
"className": "pr-1 flex",
|
||||
"hideCaret": true,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "编辑",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "编辑",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "删除",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "提示",
|
||||
"body": "你删掉了该卡片"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"toolbar": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "标签",
|
||||
"className": "label label-warning"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置标签卡片
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"header": {
|
||||
"title": "标题"
|
||||
},
|
||||
"body": "这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容这里是内容",
|
||||
"secondary": "次要说明",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "操作",
|
||||
"actionType": "dialog",
|
||||
"className": "mr-4",
|
||||
"dialog": {
|
||||
"title": "操作",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "操作",
|
||||
"actionType": "dialog",
|
||||
"className": "mr-2.5",
|
||||
"dialog": {
|
||||
"title": "操作",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "dropdown-button",
|
||||
"level": "link",
|
||||
"icon": "fa fa-ellipsis-h",
|
||||
"className": "pr-1 flex",
|
||||
"hideCaret": true,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "编辑",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "编辑",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "删除",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "提示",
|
||||
"body": "你删掉了该卡片"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"toolbar": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "标签",
|
||||
"className": "label label-warning"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置按钮卡片
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
按钮卡片一般以卡片形式展示当前卡片的执行语义,例如:创建卡片、添加卡片等场景。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"className": "hover:shadow",
|
||||
"body": {
|
||||
"type": "wrapper",
|
||||
"className": "h-32 flex items-center justify-center",
|
||||
"body": [
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"className": "text-center",
|
||||
"body": {
|
||||
"type": "icon",
|
||||
"icon": "plus",
|
||||
"className": "text-2xl",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"body": "点击会有弹框"
|
||||
}
|
||||
]
|
||||
},
|
||||
"itemAction": {
|
||||
"type": "button",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "详情",
|
||||
"body": "当前描述"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 设置文本卡片
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"header": {
|
||||
"className": "items-center",
|
||||
"title": "卡片标题"
|
||||
},
|
||||
"body": {
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"body": {
|
||||
"type": "tabs",
|
||||
"tabs": [
|
||||
{
|
||||
"title": "标签1",
|
||||
"className": "p-0",
|
||||
"tab": [
|
||||
{
|
||||
"type": "card",
|
||||
"className": "border-0",
|
||||
"header": {
|
||||
"className": "p-0 pb-2",
|
||||
"title": "内容标题"
|
||||
},
|
||||
"body": "卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容",
|
||||
"bodyClassName": "p-0"
|
||||
},
|
||||
{
|
||||
"type": "card",
|
||||
"className": "border-0",
|
||||
"header": {
|
||||
"className": "p-0 pb-2",
|
||||
"title": "内容标题"
|
||||
},
|
||||
"body": "卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容",
|
||||
"bodyClassName": "p-0"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "标签2",
|
||||
"className": "p-0",
|
||||
"tab": "卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容卡片内容"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"toolbar": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "操作",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "操作",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置单元格卡片
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"body": [
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"body": {
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"style": {
|
||||
"display": "flex",
|
||||
"align-items": "center",
|
||||
"justify-content": "space-between",
|
||||
"margin-bottom": "4px"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"style": {
|
||||
"flex": "1",
|
||||
"overflow": "hidden",
|
||||
"white-space": "nowrap",
|
||||
"text-overflow": "ellipsis"
|
||||
},
|
||||
"body": "单元格"
|
||||
},
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"style": {
|
||||
"color": "#999"
|
||||
},
|
||||
"body": "内容"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"body": [
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"style": {
|
||||
"display": "flex",
|
||||
"alignItems": "center",
|
||||
"justifyContent": "space-between",
|
||||
"marginBottom": "4px"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"style": {
|
||||
"flex": "1",
|
||||
"overflow": "hidden",
|
||||
"whiteSpace": "nowrap",
|
||||
"textOverflow": "ellipsis"
|
||||
},
|
||||
"body": "单元格"
|
||||
},
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"style": {
|
||||
"color": "#999"
|
||||
},
|
||||
"body": "内容"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "wrapper",
|
||||
"size": "none",
|
||||
"style": {
|
||||
"color": "#999",
|
||||
"fontSize": "12px"
|
||||
},
|
||||
"body": "描述信息"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配置工具栏
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "card",
|
||||
"header": {
|
||||
"title": "标题",
|
||||
"subTitle": "副标题",
|
||||
"description": "这是一段描述",
|
||||
"avatarClassName": "pull-left thumb-md avatar b-3x m-r",
|
||||
"avatar": "data:image/svg+xml,%3C%3Fxml version='1.0' standalone='no'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg t='1631083237695' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2420' xmlns:xlink='http://www.w3.org/1999/xlink' width='1024' height='1024'%3E%3Cdefs%3E%3Cstyle type='text/css'%3E%3C/style%3E%3C/defs%3E%3Cpath d='M959.872 128c0.032 0.032 0.096 0.064 0.128 0.128v767.776c-0.032 0.032-0.064 0.096-0.128 0.128H64.096c-0.032-0.032-0.096-0.064-0.128-0.128V128.128c0.032-0.032 0.064-0.096 0.128-0.128h895.776zM960 64H64C28.8 64 0 92.8 0 128v768c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64V128c0-35.2-28.8-64-64-64z' p-id='2421' fill='%23bfbfbf'%3E%3C/path%3E%3Cpath d='M832 288c0 53.024-42.976 96-96 96s-96-42.976-96-96 42.976-96 96-96 96 42.976 96 96zM896 832H128V704l224-384 256 320h64l224-192z' p-id='2422' fill='%23bfbfbf'%3E%3C/path%3E%3C/svg%3E"
|
||||
},
|
||||
"body": "这里是内容",
|
||||
"toolbar": [
|
||||
{
|
||||
"type": "button",
|
||||
"icon": "fa fa-eye",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "查看",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "static",
|
||||
"name": "engine",
|
||||
"label": "Engine"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static",
|
||||
"name": "browser",
|
||||
"label": "Browser"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static",
|
||||
"name": "platform",
|
||||
"label": "Platform(s)"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static",
|
||||
"name": "version",
|
||||
"label": "Engine version"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static",
|
||||
"name": "grade",
|
||||
"label": "CSS grade"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "html",
|
||||
"html": "<p>添加其他 <span>Html 片段</span> 需要支持变量替换(todo).</p>"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "dropdown-button",
|
||||
"level": "link",
|
||||
"icon": "fa fa-ellipsis-h",
|
||||
"hideCaret": true,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "编辑",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "编辑",
|
||||
"body": "你正在编辑该卡片"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "删除",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "提示",
|
||||
"body": "你删掉了该卡片"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------------------------- | ------------------------------------ | ----------------------------------- | ------------------------------------------------- |
|
||||
| type | `string` | `"card"` | 指定为 Card 渲染器 |
|
||||
| className | `string` | | 外层 Dom 的类名 |
|
||||
| href | [模板](../../docs/concepts/template) | | 外部链接 |
|
||||
| header | `Object` | | Card 头部内容设置 |
|
||||
| header.className | `string` | | 头部类名 |
|
||||
| header.title | [模板](../../docs/concepts/template) | | 标题 |
|
||||
| header.titleClassName | `string` | | 标题类名 |
|
||||
| header.subTitle | [模板](../../docs/concepts/template) | | 副标题 |
|
||||
| header.subTitleClassName | `string` | | 副标题类名 |
|
||||
| header.subTitlePlaceholder | `string` | | 副标题占位 |
|
||||
| header.description | [模板](../../docs/concepts/template) | | 描述 |
|
||||
| header.descriptionClassName | `string` | | 描述类名 |
|
||||
| header.descriptionPlaceholder | `string` | | 描述占位 |
|
||||
| header.avatar | [模板](../../docs/concepts/template) | | 图片 |
|
||||
| header.avatarClassName | `string` | `"pull-left thumb avatar b-3x m-r"` | 图片包括层类名 |
|
||||
| header.imageClassName | `string` | | 图片类名 |
|
||||
| header.avatarText | [模板](../../docs/concepts/template) | | 如果不配置图片,则会在图片处显示该文本 |
|
||||
| header.avatarTextBackground | `Array` | | 设置文本背景色,它会根据数据分配一个颜色 |
|
||||
| header.avatarTextClassName | `string` | | 图片文本类名 |
|
||||
| header.highlight | `boolean` | `false` | 是否显示激活样式 |
|
||||
| header.highlightClassName | `string` | | 激活样式类名 |
|
||||
| header.href | [模板](../../docs/concepts/template) | | 点击卡片跳转的链接地址 |
|
||||
| header.blank | `boolean` | `true` | 是否新窗口打开 |
|
||||
| body | `Array` | | 内容容器,主要用来放置非表单项组件 |
|
||||
| bodyClassName | `string` | | 内容区域类名 |
|
||||
| actions | Array<[Action](./action)> | | 配置按钮集合 |
|
||||
| actionsCount | `number` | `4` | 按钮集合每行个数 |
|
||||
| itemAction | [Action](./action) | | 点击卡片的行为 |
|
||||
| media | `Object` | | Card 多媒体部内容设置 |
|
||||
| media.type | `'image'\|'video'` | | 多媒体类型 |
|
||||
| media.url | `string` | | 图片/视频链接 |
|
||||
| media.position | `'left'\|'right'\|'top'\|'bottom'` | `'left'` | 多媒体位置 |
|
||||
| media.className | `string` | `"w-44 h-28"` | 多媒体类名 |
|
||||
| media.isLive | `boolean` | `false` | 视频是否为直播 |
|
||||
| media.autoPlay | `boolean` | `false` | 视频是否自动播放 |
|
||||
| media.poster | `string` | `false` | 视频封面 |
|
||||
| secondary | [模板](../../docs/concepts/template) | | 次要说明 |
|
||||
| toolbar | Array<[Action](./action)> | | 工具栏按钮 |
|
||||
| dragging | `boolean` | `false` | 是否显示拖拽图标 |
|
||||
| selectable | `boolean` | `false` | 卡片是否可选 |
|
||||
| checkable | `boolean` | `true` | 卡片选择按钮是否禁用 |
|
||||
| selected | `boolean` | `false` | 卡片选择按钮是否选中 |
|
||||
| hideCheckToggler | `boolean` | `false` | 卡片选择按钮是否隐藏 |
|
||||
| multiple | `boolean` | `false` | 卡片是否为多选 |
|
||||
| useCardLabel | `boolean` | `true` | 卡片内容区的表单项 label 是否使用 Card 内部的样式 |
|
||||
1129
docs/zh-CN/components/cards.md
Executable file
1129
docs/zh-CN/components/cards.md
Executable file
File diff suppressed because it is too large
Load Diff
345
docs/zh-CN/components/carousel.md
Executable file
345
docs/zh-CN/components/carousel.md
Executable file
@@ -0,0 +1,345 @@
|
||||
---
|
||||
title: Carousel 轮播图
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Carousel 幻灯片
|
||||
icon:
|
||||
order: 33
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "carousel",
|
||||
"auto": false,
|
||||
"thumbMode": "cover",
|
||||
"animation": "slide",
|
||||
"height": 300,
|
||||
"options": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png"
|
||||
},
|
||||
{
|
||||
"html": "<div style=\"width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;\">carousel data</div>"
|
||||
},
|
||||
{
|
||||
"thumbMode": "contain",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动态列表
|
||||
|
||||
轮播图组件目前没有获取数据的配置,因此需要依赖 `service` 来获取数据。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "service",
|
||||
"api": "/api/mock2/options/carousel",
|
||||
"body": {
|
||||
"type": "carousel",
|
||||
"name": "imageList"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
目前数据关联是通过 name 的方式,因此 api 返回应该是类似这样的:
|
||||
|
||||
```
|
||||
{
|
||||
status: 0,
|
||||
msg: '',
|
||||
data: {
|
||||
imageList: [{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png"
|
||||
}]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
其中的 `imageList` 要和配置的 `name` 值对应。
|
||||
|
||||
## 点击图片打开外部链接
|
||||
|
||||
> 1.3.3 及以上版本
|
||||
|
||||
需要放回的字段中除了前面的 image,还有 href 属性
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"imageList": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png",
|
||||
"href": "https://github.com/baidu/amis"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": {
|
||||
"type": "carousel",
|
||||
"name": "imageList"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义轮播图的展现
|
||||
|
||||
通过配置 `itemSchema` 可以自定义轮播图的展现,比如图片默认背景配置是 contain,可以改成 cover:
|
||||
|
||||
```
|
||||
itemSchema: {
|
||||
type: 'tpl',
|
||||
tpl: '<div style="background-image: url("${image}"); background-size: cover; background-repeat: no-repeat; background-position: center center;" class="image ${imageClassName}"></div>'
|
||||
}
|
||||
```
|
||||
|
||||
## 多图展示
|
||||
|
||||
> `2.8.1` 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "carousel",
|
||||
"auto": false,
|
||||
"thumbMode": "cover",
|
||||
"animation": "slide",
|
||||
"multiple": {count: 3},
|
||||
"interval": 1000,
|
||||
"duration": 5000,
|
||||
"height": 300,
|
||||
"options": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80"
|
||||
},
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80"
|
||||
},
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80"
|
||||
},
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693379/8f2e79f82be0.jpeg@s_0,w_216,l_1,f_jpg,q_80"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ---------------------------- | ----------------------------------------------------- | ---------------------- | ------------------------------------------------------- | ------- |
|
||||
| type | `string` | `"carousel"` | 指定为 Carousel 渲染器 |
|
||||
| className | `string` | `"panel-default"` | 外层 Dom 的类名 |
|
||||
| options | `array` | `[]` | 轮播面板数据 |
|
||||
| options.image | `string` | | 图片链接 |
|
||||
| options.href | `string` | | 图片打开网址的链接 |
|
||||
| options.imageClassName | `string` | | 图片类名 |
|
||||
| options.title | `string` | | 图片标题 |
|
||||
| options.titleClassName | `string` | | 图片标题类名 |
|
||||
| options.description | `string` | | 图片描述 |
|
||||
| options.descriptionClassName | `string` | | 图片描述类名 |
|
||||
| options.html | `string` | | HTML 自定义,同[Tpl](./tpl)一致 |
|
||||
| itemSchema | `object` | | 自定义`schema`来展示数据 |
|
||||
| auto | `boolean` | `true` | 是否自动轮播 |
|
||||
| interval | `string` | `5s` | 切换动画间隔 |
|
||||
| duration | `number` | `500` | 切换动画时长(ms) |
|
||||
| width | `string` | `auto` | 宽度 |
|
||||
| height | `string` | `200px` | 高度 |
|
||||
| controls | `array` | `['dots', 'arrows']` | 显示左右箭头、底部圆点索引 |
|
||||
| controlsTheme | `string` | `light` | 左右箭头、底部圆点索引颜色,默认`light`,另有`dark`模式 |
|
||||
| animation | `string` | fade | 切换动画效果,默认`fade`,另有`slide`模式,`marquee`跑马灯模式 |
|
||||
| thumbMode | `string` | `"cover" \| "contain"` | 图片默认缩放模式 |
|
||||
| multiple | `object` | `{count: 1}` | 多图展示,count 表示展示的数量 | `2.8.1` |
|
||||
| alwaysShowArrow | `boolean` | `false` | 是否一直显示箭头,为 false 时鼠标 hover 才会显示 | `2.8.1` |
|
||||
| icons | {prev: `SchemaCollection`; next: `SchemaCollection`;} | | 自定义箭头图标 | `2.8.1` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | -------------------------------------------------------------------------------- | ---------------- |
|
||||
| change | `activeIndex: number` 激活图片的索引 <br /> `prevIndex: number` 上一张图片的索引 | 轮播图切换时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "carousel",
|
||||
"auto": false,
|
||||
"thumbMode": "cover",
|
||||
"animation": "slide",
|
||||
"height": 300,
|
||||
"options": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png"
|
||||
},
|
||||
{
|
||||
"html": "<div style=\"width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;\">carousel data</div>"
|
||||
},
|
||||
{
|
||||
"thumbMode": "contain",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "滚动至${activeIndex}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| ---------- | ------------------------------------ | ---------- |
|
||||
| next | - | 下一张 |
|
||||
| prev | - | 上一张 |
|
||||
| goto-image | `activeIndex: number` 切换图片的索引 | 切换轮播图 |
|
||||
|
||||
### next
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "action",
|
||||
"label": "下一张",
|
||||
"className": "mr-3 mb-3",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "next",
|
||||
"componentId": "carousel_001"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "carousel",
|
||||
"id": "carousel_001",
|
||||
"auto": false,
|
||||
"thumbMode": "cover",
|
||||
"animation": "slide",
|
||||
"height": 300,
|
||||
"options": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png"
|
||||
},
|
||||
{
|
||||
"html": "<div style=\"width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;\">carousel data</div>"
|
||||
},
|
||||
{
|
||||
"thumbMode": "contain",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### prev
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "action",
|
||||
"label": "上一张",
|
||||
"className": "mr-3 mb-3",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "prev",
|
||||
"componentId": "carousel_002"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "carousel",
|
||||
"id": "carousel_002",
|
||||
"auto": false,
|
||||
"thumbMode": "cover",
|
||||
"animation": "slide",
|
||||
"height": 300,
|
||||
"options": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png"
|
||||
},
|
||||
{
|
||||
"html": "<div style=\"width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;\">carousel data</div>"
|
||||
},
|
||||
{
|
||||
"thumbMode": "contain",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### goto-image
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "action",
|
||||
"label": "滚动到第三张",
|
||||
"className": "mr-3 mb-3",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "goto-image",
|
||||
"componentId": "carousel_003",
|
||||
"args": {
|
||||
"activeIndex": "${index}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "carousel",
|
||||
"id": "carousel_003",
|
||||
"auto": false,
|
||||
"thumbMode": "cover",
|
||||
"animation": "slide",
|
||||
"height": 300,
|
||||
"options": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2019-12/1577157239810/da6376bf988c.png"
|
||||
},
|
||||
{
|
||||
"html": "<div style=\"width: 100%; height: 300px; background: #e3e3e3; text-align: center; line-height: 300px;\">carousel data</div>"
|
||||
},
|
||||
{
|
||||
"thumbMode": "contain",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
1557
docs/zh-CN/components/chart.md
Executable file
1557
docs/zh-CN/components/chart.md
Executable file
File diff suppressed because it is too large
Load Diff
144
docs/zh-CN/components/code.md
Normal file
144
docs/zh-CN/components/code.md
Normal file
@@ -0,0 +1,144 @@
|
||||
---
|
||||
title: Code 代码高亮
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Code
|
||||
icon:
|
||||
order: 38
|
||||
---
|
||||
|
||||
使用代码高亮的方式来显示一段代码。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "code",
|
||||
"language": "html",
|
||||
"value": "<div>html</div>"
|
||||
}
|
||||
```
|
||||
|
||||
## 语言设置
|
||||
|
||||
默认语言是 html,可以通过 language 指定以下语言:
|
||||
|
||||
`bat`、 `c`、 `coffeescript`、 `cpp`、 `csharp`、 `css`、 `dockerfile`、 `fsharp`、 `go`、 `handlebars`、 `html`、 `ini`、 `java`、 `javascript`、 `json`、 `less`、 `lua`、 `markdown`、 `msdax`、 `objective-c`、 `php`、 `plaintext`、 `postiats`、 `powershell`、 `pug`、 `python`、 `r`、 `razor`、 `ruby`、 `sb`、 `scss`、`shell`、 `sol`、 `sql`、 `swift`、 `typescript`、 `vb`、 `xml`、 `yaml`
|
||||
|
||||
```schema
|
||||
{
|
||||
"body": {
|
||||
"type": "code",
|
||||
"language": "javascript",
|
||||
"value": "(function () {\n let amis = amisRequire('amis/embed');\n let amisJSON = {\n type: 'page',\n title: '表单页面',\n body: {\n type: 'form',\n mode: 'horizontal',\n api: '/saveForm',\n body: [\n {\n label: 'Name',\n type: 'input-text',\n name: 'name'\n },\n {\n label: 'Email',\n type: 'input-email',\n name: 'email'\n }\n ]\n }\n };\n let amisScoped = amis.embed('#root', amisJSON);\n})();"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
language 支持从上下文获取数据
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"lang": "javascript"
|
||||
},
|
||||
"body": {
|
||||
"type": "code",
|
||||
"language": "${lang}",
|
||||
"value": "function amis() {\n console.log('amis');\n}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 动态数据
|
||||
|
||||
可以使用 name 来从上下文来获取数据,比如
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"sourcecode": "<div>html</div>"
|
||||
},
|
||||
"body": {
|
||||
"type": "code",
|
||||
"language": "html",
|
||||
"name": "sourcecode"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
因此它还能放在表单、crud 中实现代码的展现。
|
||||
|
||||
## 主题及 tab 大小
|
||||
|
||||
通过 `editorTheme` 设置主题,`tagSize` 设置 tab 宽度
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "code",
|
||||
"language": "javascript",
|
||||
"tagSize": 4,
|
||||
"value": "function amis() {\n\tconsole.log('amis');\n}"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## 超出换行
|
||||
|
||||
> 1.5.1 及以上版本
|
||||
|
||||
通过 `wordWrap` 设置是否折行,默认是折行
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "code",
|
||||
"language": "typescript",
|
||||
"tagSize": 4,
|
||||
"wordWrap": false,
|
||||
"value": "function amis() {\n\tconsole.log('amis')\tconsole.log('amis')\tconsole.log('amis')\tconsole.log('amis')\tconsole.log('amis')\tconsole.log('amis');\n}"
|
||||
}
|
||||
```
|
||||
|
||||
## 最大高度
|
||||
|
||||
通过配置 `maxHeight` 可以实现最大高度,超出滚动
|
||||
|
||||
```schema
|
||||
{
|
||||
"body": {
|
||||
"type": "code",
|
||||
"language": "javascript",
|
||||
"className": "b-a",
|
||||
"maxHeight": 200,
|
||||
"value": "(function () {\n let amis = amisRequire('amis/embed');\n let amisJSON = {\n type: 'page',\n title: '表单页面',\n body: {\n type: 'form',\n mode: 'horizontal',\n api: '/saveForm',\n body: [\n {\n label: 'Name',\n type: 'input-text',\n name: 'name'\n },\n {\n label: 'Email',\n type: 'input-email',\n name: 'email'\n }\n ]\n }\n };\n let amisScoped = amis.embed('#root', amisJSON);\n})();"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义语言高亮
|
||||
|
||||
还可以通过 `customLang` 参数来自定义高亮,详情参考[示例](../../../examples/code)。
|
||||
|
||||
`customLang` 中主要是 `tokens` 设置,这里是语言词法配置,它有 4 个配置项:
|
||||
|
||||
- `name`:词法名称
|
||||
- `regex`:词法的正则匹配,注意因为是在字符串中,这里正则中如果遇到 `\` 需要写成 `\\`
|
||||
- `regexFlags`: 可选,正则的标志参数
|
||||
- `color`:颜色
|
||||
- `fontStyle`: 可选,字体样式,比如 `bold` 代表加粗
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------- | ------------------ | ------ | ---------------------------------- |
|
||||
| className | `string` | | 外层 CSS 类名 |
|
||||
| value | `string` | | 显示的颜色值 |
|
||||
| name | `string` | | 在其他组件中,时,用作变量映射 |
|
||||
| language | `string` | | 所使用的高亮语言,默认是 plaintext |
|
||||
| tabSize | `number` | 4 | 默认 tab 大小 |
|
||||
| editorTheme | `string` | 'vs' | 主题,还有 'vs-dark' |
|
||||
| wordWrap | `string` | `true` | 是否折行 |
|
||||
| maxHeight | `string`\|`number` | | 最大高度 |
|
||||
403
docs/zh-CN/components/collapse.md
Normal file
403
docs/zh-CN/components/collapse.md
Normal file
@@ -0,0 +1,403 @@
|
||||
---
|
||||
title: Collapse 折叠器
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Collapse 折叠器
|
||||
icon:
|
||||
order: 36
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"activeKey": ["1"],
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": "这里是内容1"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "3",
|
||||
"header": "标题3",
|
||||
"body": "这里是内容3"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 手风琴模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"activeKey": ["1"],
|
||||
"accordion": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": "这里是内容1"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "3",
|
||||
"header": "标题3",
|
||||
"body": "这里是内容3"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义图标
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"activeKey": ["1"],
|
||||
"expandIcon": {
|
||||
"type": "icon",
|
||||
"icon": "caret-right"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": "这里是内容1"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "3",
|
||||
"header": "标题3",
|
||||
"body": "这里是内容3"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置图标位置
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"expandIconPosition": "right",
|
||||
"activeKey": ["1"],
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": "这里是内容1"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "3",
|
||||
"header": "标题3",
|
||||
"body": "这里是内容3"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 面板嵌套
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"activeKey": ["1"],
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": {
|
||||
"type": "collapse-group",
|
||||
"activeKey": ["1"],
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "嵌套面板标题",
|
||||
"body": "嵌套面板内容"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 折叠面板禁用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"activeKey": ["1"],
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": "这里是内容1"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"disabled": true,
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 折叠面板图标隐藏
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": "这里是内容1"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"showArrow": false,
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 类FieldSet样式
|
||||
|
||||
当Collapse组件作为Form组件的子元素时,`enableFieldSetStyle`属性可以控制Collapse组件样式风格,开启后转换为类似[FieldSet组件](./form/fieldset)的样式,默认开启。
|
||||
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "enableFieldSetStyle",
|
||||
"label": "切换展示方式",
|
||||
"mode": "horizontal",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"activeKey": ["1"],
|
||||
"enableFieldSetStyle": "${enableFieldSetStyle}",
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"header": "标题1",
|
||||
"body": "这里是内容1"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": "这里是内容2"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "3",
|
||||
"header": "标题3",
|
||||
"body": "这里是内容3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## CollapseGroup 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------ | ------------------------------------------------------ | ------------------ | ----------------------------------- | --- |
|
||||
| type | `string` | `"collapse-group"` | 指定为 collapse-group 渲染器 |
|
||||
| activeKey | `Array<string \| number \| never> \| string \| number` | - | 初始化激活面板的 key |
|
||||
| accordion | `boolean` | `false` | 手风琴模式 |
|
||||
| expandIcon | `SchemaNode` | - | 自定义切换图标 |
|
||||
| expandIconPosition | `string` | `"left"` | 设置图标位置,可选值`left \| right` |
|
||||
| enableFieldSetStyle | `boolean` | `true` | 当Collapse作为Form组件的子元素时,开启该属性后组件样式设置为FieldSet组件的样式,默认开启 | `3.5.0` |
|
||||
|
||||
|
||||
## CollapseGroup 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过 onEvent 来监听这些事件,并通过 actions 来配置执行的动作,在 actions 中可以通过${事件参数名}或${event.data.[事件参数名]}来获取事件产生的数据,详细查看事件动作。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
|
||||
| change | `activeKeys: Array<string \| number>` 当前展开的索引列表 <br /> `collapseId: string \| number` 折叠器索引 <br/> `collapsed: boolean` 折叠器状态 | 折叠面板折叠状态改变时触发 |
|
||||
|
||||
### change
|
||||
|
||||
折叠面板折叠状态改变时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse-group",
|
||||
"activeKey": [
|
||||
"1"
|
||||
],
|
||||
"body": [
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "1",
|
||||
"active": true,
|
||||
"header": "标题1",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "这里是内容1",
|
||||
"wrapperComponent": "",
|
||||
"inline": false,
|
||||
"id": "u:757ad799da08"
|
||||
}
|
||||
],
|
||||
"id": "u:b1b68dfbb08d"
|
||||
},
|
||||
{
|
||||
"type": "collapse",
|
||||
"key": "2",
|
||||
"header": "标题2",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "这里是内容1",
|
||||
"wrapperComponent": "",
|
||||
"inline": false,
|
||||
"id": "u:92caa03f227e"
|
||||
}
|
||||
],
|
||||
"id": "u:621a22c8b18c"
|
||||
}
|
||||
],
|
||||
"id": "u:23e4c5ec9c89",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"weight": 0,
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"position": "top-right",
|
||||
"closeButton": true,
|
||||
"showIcon": true,
|
||||
"title": "折叠状态改变",
|
||||
"msg": "activeKeys: ${event.data.activeKeys | json}, collapseId: ${event.data.collapseId}, collapsed: ${event.data.collapsed}",
|
||||
"className": "theme-toast-action-scope"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Collapse 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| --------- | ---------------------- | ------------ | ---------------------- | --- |
|
||||
| type | `string` | `"collapse"` | 指定为 collapse 渲染器 |
|
||||
| disabled | `boolean` | `false` | 禁用 |
|
||||
| collapsed | `boolean` | `true` | 初始状态是否折叠 |
|
||||
| key | `string \| number` | - | 标识 |
|
||||
| header | `string \| SchemaNode` | - | 标题 |
|
||||
| body | `string \| SchemaNode` | - | 内容 |
|
||||
| showArrow | `boolean` | `true` | 是否展示图标 |
|
||||
|
||||
## Collapse 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过 onEvent 来监听这些事件,并通过 actions 来配置执行的动作,在 actions 中可以通过${事件参数名}或${event.data.[事件参数名]}来获取事件产生的数据,详细查看事件动作。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------- | ------------------------ |
|
||||
| change | `collapsed: boolean` 折叠器状态 | 折叠器折叠状态改变时触发 |
|
||||
|
||||
### change
|
||||
|
||||
折叠面板折叠状态改变时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "collapse",
|
||||
"header": "标题",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "内容",
|
||||
"wrapperComponent": "",
|
||||
"inline": false,
|
||||
"id": "u:6588c12ee3b0"
|
||||
}
|
||||
],
|
||||
"id": "u:62aa2f0c7fd9",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"weight": 0,
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"position": "top-right",
|
||||
"closeButton": true,
|
||||
"showIcon": true,
|
||||
"title": "collapsedChange",
|
||||
"msg": "collapsed: ${event.data.collapsed}",
|
||||
"className": "theme-toast-action-scope"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
95
docs/zh-CN/components/color.md
Executable file
95
docs/zh-CN/components/color.md
Executable file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: Color 颜色
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Color
|
||||
icon:
|
||||
order: 37
|
||||
---
|
||||
|
||||
用于展示颜色
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "color",
|
||||
"value": "#108cee"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 用作 Field 时
|
||||
|
||||
当用在 Table 的列配置 Column、List 的内容、Card 卡片的内容和表单的 Static-XXX 中时,可以设置`name`属性,映射同名变量
|
||||
|
||||
### Table 中的列类型
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "table",
|
||||
"data": {
|
||||
"items": [
|
||||
{
|
||||
"id": "1",
|
||||
"color": "#108cee"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"color": "#f38900"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"color": "#04c1ba"
|
||||
}
|
||||
]
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"label": "Id"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "color",
|
||||
"label": "颜色",
|
||||
"type": "color"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
List 的内容、Card 卡片的内容配置同上
|
||||
|
||||
### Form 中静态展示
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"data": {
|
||||
"color": "#108cee"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "static-color",
|
||||
"name": "color",
|
||||
"label": "颜色"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | |
|
||||
| ------------------------ | --------- | ------ | -------------------------------------------------------------------------------------- | ------- |
|
||||
| type | `string` | | 如果在 Table、Card 和 List 中,为`"color"`;在 Form 中用作静态展示,为`"static-color"` |
|
||||
| className | `string` | | 外层 CSS 类名 |
|
||||
| value | `string` | | 显示的颜色值 |
|
||||
| name | `string` | | 在其他组件中,时,用作变量映射 |
|
||||
| defaultColor | `string` | | 默认颜色值 |
|
||||
| showValue | `boolean` | `true` | 是否显示右边的颜色值 |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.2` |
|
||||
143
docs/zh-CN/components/container.md
Executable file
143
docs/zh-CN/components/container.md
Executable file
@@ -0,0 +1,143 @@
|
||||
---
|
||||
title: Container 容器
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Container 容器
|
||||
icon:
|
||||
order: 38
|
||||
---
|
||||
|
||||
Container 是一种容器组件,它可以渲染其他 amis 组件。
|
||||
|
||||
注意 Container 组件因为历史原因多了一层 div,推荐使用 [wrapper](wrapper) 来作为容器。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "container",
|
||||
"body": "这里是容器内容区"
|
||||
}
|
||||
```
|
||||
|
||||
### style
|
||||
|
||||
container 可以通过 style 来设置样式,比如背景色或背景图,注意这里的属性是使用驼峰写法,是 `backgroundColor` 而不是 `background-color`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "container",
|
||||
"style": {
|
||||
"backgroundColor": "#C4C4C4"
|
||||
},
|
||||
"body": "这里是容器内容区"
|
||||
}
|
||||
```
|
||||
|
||||
### wrapperComponent
|
||||
|
||||
修改标签名可以让容器使用其它标签渲染,比如 `pre`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "container",
|
||||
"wrapperComponent": "pre",
|
||||
"body": "var a = 1;"
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------------- | ----------------------------------------- | ------------- | ----------------------- |
|
||||
| type | `string` | `"container"` | 指定为 container 渲染器 |
|
||||
| className | `string` | | 外层 Dom 的类名 |
|
||||
| bodyClassName | `string` | | 容器内容区的类名 |
|
||||
| wrapperComponent | `string` | `"div"` | 容器标签名 |
|
||||
| style | `Object` | | 自定义样式 |
|
||||
| body | [SchemaNode](../../docs/types/schemanode) | | 容器内容 |
|
||||
|
||||
## 事件表
|
||||
|
||||
> 3.3.0 及以上版本
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| ---------- | -------- | -------------- |
|
||||
| click | - | 点击时触发 |
|
||||
| mouseenter | - | 鼠标移入时触发 |
|
||||
| mouseleave | - | 鼠标移出时触发 |
|
||||
|
||||
### click
|
||||
|
||||
鼠标点击。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "container",
|
||||
"body": "这里是容器内容区",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.context.nativeEvent.type}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### mouseenter
|
||||
|
||||
鼠标移入。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "container",
|
||||
"body": "这里是容器内容区",
|
||||
"onEvent": {
|
||||
"mouseenter": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.context.nativeEvent.type}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### mouseleave
|
||||
|
||||
鼠标移出。可以尝试通过`${event.context.nativeEvent}`获取鼠标事件对象。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "container",
|
||||
"body": "这里是容器内容区",
|
||||
"onEvent": {
|
||||
"mouseleave": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.context.nativeEvent.type}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
6455
docs/zh-CN/components/crud.md
Executable file
6455
docs/zh-CN/components/crud.md
Executable file
File diff suppressed because it is too large
Load Diff
189
docs/zh-CN/components/custom.md
Normal file
189
docs/zh-CN/components/custom.md
Normal file
@@ -0,0 +1,189 @@
|
||||
---
|
||||
title: Custom 自定义组件
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Custom 自定义组件
|
||||
icon:
|
||||
order: 26
|
||||
---
|
||||
|
||||
用于实现自定义组件,它解决了之前 JS SDK 和可视化编辑器中难以支持自定义组件的问题。
|
||||
|
||||
## 基本用法
|
||||
|
||||
设置 type 类型为 custom
|
||||
|
||||
### onMount
|
||||
|
||||
这是节点在初始化的时候执行的函数,它接收三个参数:
|
||||
|
||||
- dom,组件加载之后的 dom 节点
|
||||
- data,组件初始值,需要设置 name
|
||||
- onChange,修改这个组件对应 name 的值
|
||||
- props,后面会单独介绍
|
||||
|
||||
比如在这样的 form 组件中:
|
||||
|
||||
```javascript
|
||||
{
|
||||
type: 'page',
|
||||
title: '表单页面',
|
||||
body: {
|
||||
type: 'form',
|
||||
title: 'custom 组件',
|
||||
body: [
|
||||
{
|
||||
type: 'custom',
|
||||
name: 'myName',
|
||||
label: '自定义组件',
|
||||
onMount: (dom, value, onChange, props) => {
|
||||
const button = document.createElement('button');
|
||||
button.innerText = '点击修改';
|
||||
button.onclick = event => {
|
||||
// 这个 onChange 方法只有放在表单项中才能调用,第二个参数是表单项名称
|
||||
onChange('new', 'myName');
|
||||
event.preventDefault();
|
||||
};
|
||||
dom.appendChild(button);
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
点击按钮之后,执行 `onChange` 函数,就会将 `myName` 这个参数的值改成 `new`,点击表单提交的时候,就会有一个 `myName=new` 的表单数据。
|
||||
|
||||
### onUpdate
|
||||
|
||||
onUpdate 是在数据变更的时候调用,注意这个数据变更会包含表单内的所有其他组件。
|
||||
|
||||
```javascript
|
||||
{
|
||||
type: 'page',
|
||||
title: '表单页面',
|
||||
body: {
|
||||
type: 'form',
|
||||
title: 'custom 组件',
|
||||
body: [
|
||||
{
|
||||
name: 'email',
|
||||
label: '邮箱',
|
||||
type: 'input-text'
|
||||
},
|
||||
{
|
||||
name: 'username',
|
||||
label: '用户名',
|
||||
type: 'input-text'
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
label: '自定义组件',
|
||||
onUpdate: (dom, data, prevData, props) => {
|
||||
console.log('data', data, prevData)
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
这个例子中,无论是邮箱还是用户名修改,都会触发 onUpdata 函数,其中 `data` 是当前值,`prevData` 是之前的值:
|
||||
|
||||
1. 如果修改 email,则 data 将会是 `{email: 'xxx'}`,prevData 是 `{}`
|
||||
2. 如果再次修改 email,则 data 将会是 `{email: 'xxx1'}`,prevData 是 `{email: 'xxx '}`
|
||||
3. 如果修改 username,则 data 将会是 `{email: 'xxx1', username: 'yyy'}`,prevData 是 `{email: 'xxx1'}`
|
||||
|
||||
### onUnmount
|
||||
|
||||
onUnmount 是在组件销毁的时候执行,可以在这里做资源清理,这个函数只有一个 props 参数。
|
||||
|
||||
### Vue.js
|
||||
|
||||
因为 onMount 拿到的 dom 就是标准的 dom,所以可以执行任意 JavaScript 代码,包括 jQuery 等,下面的例子演示了如何使用 vue 2.0 实现自定义组件:
|
||||
|
||||
```javascript
|
||||
{
|
||||
type: 'page',
|
||||
title: '表单页面',
|
||||
body: {
|
||||
type: 'form',
|
||||
title: 'custom 组件',
|
||||
body: [
|
||||
{
|
||||
type: 'custom',
|
||||
name: 'my-custom',
|
||||
html: `
|
||||
<ol>
|
||||
<li v-for="todo in todos">
|
||||
{{ todo.text }}
|
||||
</li>
|
||||
</ol>
|
||||
`,
|
||||
label: '自定义组件',
|
||||
onMount: (dom, data, onChange, props) => {
|
||||
const app = new Vue({
|
||||
el: dom,
|
||||
data: {
|
||||
todos: [
|
||||
{ text: 'hello' },
|
||||
{ text: 'world' },
|
||||
{ text: 'vue' }
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
【温馨提示】
|
||||
custom 组件中使用 vue2 语法,请先引入vue.js(umd 或 global 模块,比如:https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js) 。
|
||||
同理,使用 vue3 语法请先引入 vue3 对应的 umd 或 global 模块,比如:https://unpkg.com/vue@3/dist/vue.global.js 。
|
||||
|
||||
### props
|
||||
|
||||
前面可以看到所有函数最后都有一个 props 参数,在这个参数里能拿到 amis 内部属性和方法,比如弹框
|
||||
|
||||
```javascript
|
||||
onMount: (dom, data, onChange, props) => {
|
||||
const button = document.createElement('button');
|
||||
button.innerText = '点击修改姓名';
|
||||
button.onclick = event => {
|
||||
onChange('new name', 'name');
|
||||
props.onAction(
|
||||
event,
|
||||
{
|
||||
type: 'action',
|
||||
label: '弹个框',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '弹框',
|
||||
body: 'Hello World!'
|
||||
}
|
||||
},
|
||||
{} // 这是 data
|
||||
);
|
||||
event.preventDefault();
|
||||
};
|
||||
dom.appendChild(button);
|
||||
};
|
||||
```
|
||||
|
||||
或者执行 `props.env.notify('success', '执行成功')` 来在右上角弹出提示等。
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------- | --------- | -------- | --------------------------------------------- |
|
||||
| type | 'custom' | | |
|
||||
| id | `string` | | 节点 id |
|
||||
| name | `string` | | 节点 名称 |
|
||||
| className | `string` | | 节点 class |
|
||||
| inline | `boolean` | false | 默认使用 div 标签,如果 true 就使用 span 标签 |
|
||||
| html | `string` | | 初始化节点 html |
|
||||
| onMount | `string` | Function | 节点初始化之后调的用函数 |
|
||||
| onUpdate | `string` | Function | 数据有更新的时候调用的函数 |
|
||||
| onUnmount | `string` | Function | 节点销毁的时候调用的函数 |
|
||||
193
docs/zh-CN/components/date.md
Executable file
193
docs/zh-CN/components/date.md
Executable file
@@ -0,0 +1,193 @@
|
||||
---
|
||||
title: Date 日期时间
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Date
|
||||
icon:
|
||||
order: 39
|
||||
---
|
||||
|
||||
用于展示日期
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "date",
|
||||
"value": "1591326307"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 用作 Field 时
|
||||
|
||||
当用在 Table 的列配置 Column、List 的内容、Card 卡片的内容和表单的 Static-XXX 中时,可以设置`name`属性,映射同名变量
|
||||
|
||||
### Table 中的列类型
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "table",
|
||||
"data": {
|
||||
"items": [
|
||||
{
|
||||
"id": "1",
|
||||
"date": "1591326307"
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"date": "1591321307"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"date": "1591322307"
|
||||
}
|
||||
]
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"label": "Id"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"type": "date"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
List 的内容、Card 卡片的内容配置同上
|
||||
|
||||
### Form 中静态展示
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"data": {
|
||||
"now": "1591322307"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "static-date",
|
||||
"name": "now",
|
||||
"label": "日期",
|
||||
"format": "YYYY年MM月DD日 HH时mm分ss秒"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配置展示格式
|
||||
|
||||
例如你想将某一个时间值,以 `xxxx年xx月xx日 xx时xx分xx秒` 这样的格式输出,那么查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY年MM月DD日 HH时mm分ss秒`,即:
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"now": 1586865590
|
||||
},
|
||||
"body": {
|
||||
"type": "date",
|
||||
"value": "1586865590",
|
||||
"format": "YYYY年MM月DD日 HH时mm分ss秒"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 配置数据格式
|
||||
|
||||
如果你的数据值默认不是`X`格式(时间戳秒格式),那么需要配置 `valueFormat` 参数用于解析当前时间值,比如毫秒是配置 `"valueFormat": "x"`。
|
||||
|
||||
除此之外还支持各种自定义日期格式,例如下面`value`值为:`"2020/4/14 19:59:50"`,查阅 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知,需要配置数据格式为 `"YYYY/MM/DD HH:mm:ss"`,然后我们配置输出格式`format`,输出指定格式日期:
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "date",
|
||||
"value": "2020/4/14 19:59:50",
|
||||
"valueFormat": "YYYY/MM/DD HH:mm:ss",
|
||||
"format": "YYYY年MM月DD日 HH时mm分ss秒"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 转成相对当前时间的描述
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "date",
|
||||
"fromNow": true,
|
||||
"value": "1591326307"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 设置展示时区
|
||||
|
||||
通过配置 `displayTimeZone` 参数,可以设置展示时区,默认展示当前时区。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "crud",
|
||||
"api": {
|
||||
"method": "get",
|
||||
"url": "/whatever/api",
|
||||
"mockResponse": {
|
||||
"status": 200,
|
||||
"data": [
|
||||
{
|
||||
"date": "2023-10-27 15:00:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"type": "date",
|
||||
"label": "Asia/Shanghai",
|
||||
"name": "date",
|
||||
"displayTimeZone": "Asia/Shanghai",
|
||||
"format": "YYYY-MM-DD HH:mm:ss"
|
||||
},
|
||||
{
|
||||
"type": "date",
|
||||
"label": "America/Los_Angeles",
|
||||
"name": "date",
|
||||
"displayTimeZone": "America/Los_Angeles",
|
||||
"format": "YYYY-MM-DD HH:mm:ss"
|
||||
},
|
||||
{
|
||||
"type": "date",
|
||||
"name": "date",
|
||||
"label": "Asia/Tokyo",
|
||||
"displayTimeZone": "Asia/Tokyo",
|
||||
"format": "YYYY-MM-DD HH:mm:ss"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| --------------- | --------- | ------------ | ------------------------------------------------------------------------------------------------------ | ----------------------- |
|
||||
| type | `string` | | 如果在 Table、Card 和 List 中,为`"date"`;在 Form 中用作静态展示,为`"static-date"` |
|
||||
| className | `string` | | 外层 CSS 类名 |
|
||||
| value | `string` | | 显示的日期数值 |
|
||||
| name | `string` | | 在其他组件中,时,用作变量映射 |
|
||||
| placeholder | `string` | `-` | 占位内容 |
|
||||
| displayFormat | `string` | `YYYY-MM-DD` | 展示格式, 更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 版本号 3.4.0 及以上支持 |
|
||||
| valueFormat | `string` | `X` | 数据格式,默认为时间戳。更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) |
|
||||
| fromNow | `boolean` | `false` | 是否显示相对当前的时间描述,比如: 11 小时前、3 天前、1 年前等,fromNow 为 true 时,format 不生效。 |
|
||||
| updateFrequency | `number` | `60000` | 更新频率, 默认为 1 分钟 |
|
||||
| displayTimeZone | `string` | | 设置日期展示时区,可设置清单参考:https://gist.github.com/diogocapela/12c6617fc87607d11fd62d2a4f42b02a |
|
||||
1287
docs/zh-CN/components/dialog.md
Executable file
1287
docs/zh-CN/components/dialog.md
Executable file
File diff suppressed because it is too large
Load Diff
71
docs/zh-CN/components/divider.md
Executable file
71
docs/zh-CN/components/divider.md
Executable file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: Divider 分割线
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Divider 分割线
|
||||
icon:
|
||||
order: 42
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "divider"
|
||||
}
|
||||
```
|
||||
|
||||
## 不同样式
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "divider",
|
||||
"lineStyle": "solid"
|
||||
},
|
||||
{
|
||||
"type": "divider",
|
||||
"lineStyle": "dashed"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 带标题的分割线
|
||||
|
||||
> `3.5.0`及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "divider",
|
||||
"title": "Text",
|
||||
"titlePosition": "left"
|
||||
},
|
||||
{
|
||||
"type": "divider",
|
||||
"title": "Text",
|
||||
"titlePosition": "center"
|
||||
},
|
||||
{
|
||||
"type": "divider",
|
||||
"title": "Text",
|
||||
"titlePosition": "right"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| --------- | -------- | ------------ | --------------------------------------- |---------- |
|
||||
| type | `string` | | `"divider"` 指定为 分割线 渲染器 |
|
||||
| className | `string` | | 外层 Dom 的类名 |
|
||||
| lineStyle | `string` | `solid` | 分割线的样式,支持`dashed`和`solid` |
|
||||
| direction | `string` | `horizontal` | 分割线的方向,支持`horizontal`和`vertical` | `3.5.0` |
|
||||
| color | `string` | | 分割线的颜色 | `3.5.0` |
|
||||
| rotate | `number` | | 分割线的旋转角度 | `3.5.0` |
|
||||
| title | [SchemaNode](../../docs/types/schemanode) | | 分割线的标题 | `3.5.0` |
|
||||
| titleClassName | `string` | | 分割线的标题类名 | `3.5.0` |
|
||||
| titlePosition | `string` | `center`| 分割线的标题位置,支持`left`、`center`和`right` | `3.5.0` |
|
||||
|
||||
851
docs/zh-CN/components/drawer.md
Executable file
851
docs/zh-CN/components/drawer.md
Executable file
@@ -0,0 +1,851 @@
|
||||
---
|
||||
title: Drawer 抽屉
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Drawer 抽屉
|
||||
icon:
|
||||
order: 43
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"label": "弹出",
|
||||
"type": "button",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "抽屉标题",
|
||||
"body": "这是一个抽屉"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 多级弹框
|
||||
|
||||
可以嵌套使用。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "多级抽屉",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "提示",
|
||||
"body": "这是个简单的抽屉",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "confirm",
|
||||
"label": "确认",
|
||||
"primary": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "drawer",
|
||||
"label": "再弹一个",
|
||||
"drawer": {
|
||||
"title": "抽屉中的抽屉",
|
||||
"body": "如果你想,可以继续弹下去",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "drawer",
|
||||
"label": "来吧",
|
||||
"level": "info",
|
||||
"drawer": {
|
||||
"title": "抽屉中的抽屉",
|
||||
"body": "如果你想,可以无限弹下去",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "confirm",
|
||||
"label": "不弹了",
|
||||
"primary": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 指定弹出方向
|
||||
|
||||
通过配置 `position`,可以指定抽屉弹出的方向,可选 `left`、`right`、`top` 和 `bottom`。默认为 `right`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "左侧弹出",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"position": "left",
|
||||
"title": "提示",
|
||||
"body": "这是一个从左侧弹出的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "右侧弹出",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"position": "right",
|
||||
"title": "提示",
|
||||
"body": "这是一个从右侧弹出的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "顶部弹出",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"position": "top",
|
||||
"title": "提示",
|
||||
"body": "这是一个从顶部弹出的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "底部弹出",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"position": "bottom",
|
||||
"title": "提示",
|
||||
"body": "这是一个从底部弹出的抽屉"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 抽屉尺寸
|
||||
|
||||
通过设置 `size` 来控制抽屉的大小,可选值:`xs`、`sm`、`md`、`lg` 和 `xl`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "极小框",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"size": "xs",
|
||||
"title": "提示",
|
||||
"body": "这是一个极小的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "小框",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"size": "sm",
|
||||
"title": "提示",
|
||||
"body": "这是一个小抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "中框",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"size": "md",
|
||||
"title": "提示",
|
||||
"body": "这是一个标准的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "大框",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"size": "lg",
|
||||
"title": "提示",
|
||||
"body": "这是一个大抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "超大框",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"size": "xl",
|
||||
"title": "提示",
|
||||
"body": "这是一个超大的抽屉"
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义抽屉尺寸
|
||||
|
||||
通过设置 `width`(`position` 为 `left` 或 `right` 时生效)和 `height`(`position` 为 `top` 或 `bottom` 时生效)来控制抽屉的尺寸。
|
||||
|
||||
值如果是数字类型,单位默认使用 `px`, 如果是字符串类型,可以使用自定义 css 宽度变量,如:`%`、`vw`、`px` 等。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "自定义宽度",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"position": "right",
|
||||
"width": 300,
|
||||
"title": "提示",
|
||||
"body": "这是一个自定义 300px 宽度的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "自定义高度",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"position": "bottom",
|
||||
"height": 300,
|
||||
"title": "提示",
|
||||
"body": "这是一个自定义 300px 高度的抽屉"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 可拖拽抽屉大小
|
||||
|
||||
配置 `"resizable": true`,可以拖拽调整 `drawer` 大小。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "可拖拽调整大小",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"resizable": true,
|
||||
"title": "提示",
|
||||
"body": "这是一个可拖拽的抽屉"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 是否展示关闭按钮
|
||||
|
||||
配置 `"showCloseButton": false`,可以隐藏关闭按钮。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "无关闭按钮",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "提示",
|
||||
"body": "这是一个没有关闭按钮的抽屉",
|
||||
"showCloseButton": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 蒙层显示
|
||||
|
||||
通过配置 `overlay`,来控制是否显示蒙层。默认为 `true`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "默认",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"overlay": true,
|
||||
"title": "提示",
|
||||
"body": "这是一个有蒙层的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "不显示",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"overlay": false,
|
||||
"title": "提示",
|
||||
"body": "这是一个没有蒙层的抽屉"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 关闭方式
|
||||
|
||||
通过配置 `closeOnOutside`,即可在点击抽屉外部时,直接关闭抽屉。
|
||||
|
||||
同时可以配置 `closeOnEsc`,让抽屉支持 <kbd>Esc</kbd> 键关闭。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "点击抽屉外自动关闭(有蒙层)",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"closeOnOutside": true,
|
||||
"title": "提示",
|
||||
"body": "这是一个简单的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "点击抽屉外自动关闭(无蒙层)",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"overlay": false,
|
||||
"closeOnOutside": true,
|
||||
"title": "提示",
|
||||
"body": "这是一个简单的抽屉"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按键关闭",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"closeOnEsc": true,
|
||||
"title": "提示",
|
||||
"body": "试试按下 Esc"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作后关闭抽屉
|
||||
|
||||
在抽屉中配置行为按钮,可以在按钮上配置 `"close": true`,在行为完成后,关闭当前抽屉。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "打开",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "提示",
|
||||
"body": [
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "默认的 ajax 请求",
|
||||
"actionType": "ajax",
|
||||
"api": "/api/mock2/form/saveForm?waitSeconds=1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "ajax 请求成功后关闭抽屉",
|
||||
"actionType": "ajax",
|
||||
"api": "/api/mock2/form/saveForm?waitSeconds=1",
|
||||
"close": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
以上例子是关闭当前抽屉,如果希望关闭上层抽屉,则需要给目标抽屉设置 `name` 属性,然后配置按钮 `close` 属性为目标 `name` 属性如:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "多级抽屉",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "提示",
|
||||
"body": "这是个简单的抽屉",
|
||||
"name": "drawer_1",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "confirm",
|
||||
"label": "确认",
|
||||
"primary": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "drawer",
|
||||
"label": "再弹一个",
|
||||
"drawer": {
|
||||
"title": "抽屉中的抽屉",
|
||||
"body": "关闭当前抽屉时,将外层抽屉一并关闭",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "关闭所有",
|
||||
"level": "info",
|
||||
"close": "drawer_1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> 3.3.0 及以上版本
|
||||
|
||||
如果是表单,可以在表单上配置 `close: false`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "弹个框",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名"
|
||||
}
|
||||
],
|
||||
"close": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 配置抽屉的按钮
|
||||
|
||||
默认抽屉会自动生成两个按钮,一个取消,一个确认。如果通过 `actions` 来自定义配置,则以配置的为准。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "无按钮",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "提示",
|
||||
"body": "这是一个没有按钮的抽屉",
|
||||
"actions": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "一个按钮",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "提示",
|
||||
"body": "只有一个 OK 的抽屉",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "confirm",
|
||||
"label": "OK",
|
||||
"primary": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------------- | ----------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------- |
|
||||
| type | `string` | | `"drawer"` 指定为 Drawer 渲染器 |
|
||||
| title | [SchemaNode](../../docs/types/schemanode) | | 弹出层标题 |
|
||||
| body | [SchemaNode](../../docs/types/schemanode) | | 往 Drawer 内容区加内容 |
|
||||
| size | `string` | | 指定 Drawer 大小,支持: `xs`、`sm`、`md`、`lg`、`xl` |
|
||||
| position | `string` | `right` | 指定 Drawer 方向,支持: `left`、`right`、`top`、`bottom` |
|
||||
| className | `string` | | Drawer 最外层容器的样式类名 |
|
||||
| headerClassName | `string` | | Drawer 头部 区域的样式类名 |
|
||||
| bodyClassName | `string` | `modal-body` | Drawer body 区域的样式类名 |
|
||||
| footerClassName | `string` | | Drawer 页脚 区域的样式类名 |
|
||||
| showCloseButton | `boolean` | `true` | 是否展示关闭按钮,当值为 `false` 时,默认开启 closeOnOutside |
|
||||
| closeOnEsc | `boolean` | `false` | 是否支持按 <kbd>Esc</kbd> 关闭 Drawer |
|
||||
| closeOnOutside | `boolean` | `false` | 点击内容区外是否关闭 Drawer |
|
||||
| overlay | `boolean` | `true` | 是否显示蒙层 |
|
||||
| resizable | `boolean` | `false` | 是否可通过拖拽改变 Drawer 大小 |
|
||||
| width | `string \| number` | `500px` | 容器的宽度,在 `position` 为 `left` 或 `right` 时生效 |
|
||||
| height | `string \| number` | `500px` | 容器的高度,在 `position` 为 `top` 或 `bottom` 时生效 |
|
||||
| actions | Array<[Action](./action)> | 【确认】和【取消】 | 可以不设置,默认只有两个按钮。 |
|
||||
| data | `object` | | 支持 [数据映射](../../docs/concepts/data-mapping),如果不设定将默认将触发按钮的上下文中继承数据。 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过 `onEvent` 来监听这些事件,并通过 `actions` 来配置执行的动作,在 `actions` 中可以通过 `${事件参数名}` 或 `${event.data.[事件参数名]}` 来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------------------------------------------------ | ------------------ |
|
||||
| confirm | `event.data: object` 抽屉数据<br/>`[name]: any` 当前数据域中指定字段的值 | 点击确认提交时触发 |
|
||||
| cancel | `event.data: object` 抽屉数据<br/>`[name]: any` 当前数据域中指定字段的值 | 点击取消时触发 |
|
||||
|
||||
### confirm
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"label": "打开",
|
||||
"type": "button",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "标题",
|
||||
"body": "这是一个抽屉",
|
||||
"onEvent": {
|
||||
"confirm": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "confirm"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### cancel
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"label": "打开",
|
||||
"type": "button",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "标题",
|
||||
"body": "这是一个抽屉",
|
||||
"onEvent": {
|
||||
"cancel": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "cancel"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定 `actionType: 动作名称`、`componentId: 该组件id` 来触发这些动作,动作配置可以通过 `args: {动作配置项名称: xxx}` 来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------------------------- | ------------ |
|
||||
| confirm | - | 确认(提交) |
|
||||
| cancel | - | 取消(关闭) |
|
||||
| setValue | `value: object` 更新的数据 | 更新数据 |
|
||||
|
||||
### confirm 动作
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "弹个表单",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "在抽屉中的表单",
|
||||
"id": "drawer_confirm",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm?waitSeconds=2",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "username",
|
||||
"required": true,
|
||||
"placeholder": "请输入用户名",
|
||||
"label": "用户名"
|
||||
},
|
||||
{
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码",
|
||||
"required": true,
|
||||
"placeholder": "请输入密码"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"name": "rememberMe",
|
||||
"label": "记住登录"
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "触发确认",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "confirm",
|
||||
"componentId": "drawer_confirm"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### cancel 动作
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "弹个表单",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "在抽屉中的表单",
|
||||
"id": "drawer_cancel",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm?waitSeconds=2",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "username",
|
||||
"required": true,
|
||||
"placeholder": "请输入用户名",
|
||||
"label": "用户名"
|
||||
},
|
||||
{
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码",
|
||||
"required": true,
|
||||
"placeholder": "请输入密码"
|
||||
},
|
||||
{
|
||||
"type": "checkbox",
|
||||
"name": "rememberMe",
|
||||
"label": "记住登录"
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "触发取消",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "cancel",
|
||||
"componentId": "drawer_cancel"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### setValue 动作
|
||||
|
||||
通过 `setValue` 更新指定抽屉的数据。
|
||||
|
||||
#### 合并数据
|
||||
|
||||
默认 `setValue` 会将新数据与目标组件数据进行合并。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "弹个表单",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "在抽屉中的表单",
|
||||
"id": "drawer_setvalue",
|
||||
"data": {
|
||||
"username": "amis",
|
||||
"password": "amis@baidu.com"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "初始化时,抽屉的数据 data 为 {username: 'amis', password: 'fex'},表单内或者表单外都可以读取这些数据,当点击【更新抽屉数据】按钮后,抽屉的数据被更新为 {username: 'aisuda', password: 'aisuda@baidu.com'}"
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"label": "表单外的密码",
|
||||
"name": "password"
|
||||
},
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm?waitSeconds=2",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "username",
|
||||
"required": true,
|
||||
"placeholder": "请输入用户名",
|
||||
"label": "用户名"
|
||||
},
|
||||
{
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码",
|
||||
"required": true,
|
||||
"placeholder": "请输入密码"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "更新抽屉数据",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "drawer_setvalue",
|
||||
"args": {
|
||||
"value": {
|
||||
"username": "aisuda",
|
||||
"password": "aisuda@baidu.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 覆盖数据
|
||||
|
||||
可以通过 `"dataMergeMode": "override"` 来覆盖目标组件数据。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "button",
|
||||
"label": "弹个表单",
|
||||
"actionType": "drawer",
|
||||
"drawer": {
|
||||
"title": "在抽屉中的表单",
|
||||
"id": "drawer_setvalue2",
|
||||
"data": {
|
||||
"username": "amis",
|
||||
"password": "amis@baidu.com"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "alert",
|
||||
"body": "初始化时,抽屉的数据 data 为 {username: 'amis', password: 'fex'},表单内或者表单外都可以读取这些数据,当点击【更新抽屉数据】按钮后,抽屉的数据被更新为 {username: 'aisuda'},即 password 将被删除"
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"label": "表单外的密码",
|
||||
"name": "password"
|
||||
},
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm?waitSeconds=2",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "username",
|
||||
"required": true,
|
||||
"placeholder": "请输入用户名",
|
||||
"label": "用户名"
|
||||
},
|
||||
{
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码",
|
||||
"required": true,
|
||||
"placeholder": "请输入密码"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "更新抽屉数据",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "drawer_setvalue2",
|
||||
"args": {
|
||||
"value": {
|
||||
"username": "aisuda"
|
||||
}
|
||||
},
|
||||
"dataMergeMode": "override"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
358
docs/zh-CN/components/dropdown-button.md
Executable file
358
docs/zh-CN/components/dropdown-button.md
Executable file
@@ -0,0 +1,358 @@
|
||||
---
|
||||
title: DropDownButton 下拉菜单
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: DropDownButton
|
||||
icon:
|
||||
order: 44
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉菜单",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 分组展示模式
|
||||
|
||||
配置`children`可以实现分组展示,分组标题支持配置`icon`。
|
||||
|
||||
> 1.5.7 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉菜单",
|
||||
"buttons": [
|
||||
{
|
||||
"label": "RD",
|
||||
"icon": "fa fa-user",
|
||||
"children": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "前端FE"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "后端RD"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "QA",
|
||||
"icon": "fa fa-user",
|
||||
"children": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "测试QA",
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "交付测试DQA",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "Manager",
|
||||
"icon": "fa fa-user",
|
||||
"children": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "项目经理PM"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "项目管理中心PMO",
|
||||
"visible": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 关闭下拉菜单
|
||||
|
||||
配置`"closeOnClick": true`可以实现点击按钮后自动关闭下拉菜单。
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉菜单",
|
||||
"closeOnClick": true,
|
||||
"closeOnOutside": true,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 触发方式
|
||||
|
||||
> 1.4.0 及以上版本
|
||||
|
||||
默认是点击鼠标触发,可以通过 `"trigger": "hover"` 配置为鼠标移上去后触发
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉菜单",
|
||||
"trigger": "hover",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 设置图标
|
||||
|
||||
通过 `icon` 可以设置左侧图标
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉菜单",
|
||||
"trigger": "hover",
|
||||
"icon": "fa fa-home",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 只显示图标
|
||||
|
||||
可以设置 `level` 及 `hideCaret` 来只显示图标,并配合 `tooltip` 来显示提示文字
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "dropdown-button",
|
||||
"level": "link",
|
||||
"icon": "fa fa-ellipsis-h",
|
||||
"hideCaret": true,
|
||||
"tooltip": "提示",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 设置右侧图标
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
通过 `rightIcon` 设置右侧图标,同时通过 `hideCaret` 隐藏右侧下拉图标
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉菜单",
|
||||
"trigger": "hover",
|
||||
"rightIcon": "fa fa-ellipsis-v",
|
||||
"hideCaret": true,
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮3"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------------- | ----------------------- | ----------------- | ----------------------------------------- |
|
||||
| type | `string` | `dropdown-button` | 类型 |
|
||||
| label | `string` | | 按钮文本 |
|
||||
| className | `string` | | 外层 CSS 类名 |
|
||||
| btnClassName | `string` | | 按钮 CSS 类名 |
|
||||
| menuClassName | `string` | | 下拉菜单 CSS 类名 |
|
||||
| block | `boolean` | | 块状样式 |
|
||||
| size | `string` | | 尺寸,支持`'xs'`、`'sm'`、`'md'` 、`'lg'` |
|
||||
| align | `string` | | 位置,可选`'left'`或`'right'` |
|
||||
| buttons | `Array<DropdownButton>` | | 配置下拉按钮 |
|
||||
| iconOnly | `boolean` | | 只显示 icon |
|
||||
| defaultIsOpened | `boolean` | | 默认是否打开 |
|
||||
| closeOnOutside | `boolean` | `true` | 点击外侧区域是否收起 |
|
||||
| closeOnClick | `boolean` | `false` | 点击按钮后自动关闭下拉菜单 |
|
||||
| trigger | `click` 或 `hover` | `click` | 触发方式 |
|
||||
| hideCaret | `boolean` | false | 隐藏下拉图标 |
|
||||
| popOverContainerSelector | `string` | | 弹出的下拉按钮放在哪个节点下 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| ---------- | ---------------------------- | --------------------------------------- |
|
||||
| mouseenter | items: Array<DropdownButton> | 触发方式为 hover 模式下,鼠标移入时触发 |
|
||||
| mouseleave | items: Array<DropdownButton> | 触发方式为 hover 模式下,鼠标移出时触发 |
|
||||
|
||||
### mouseenter
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉按钮",
|
||||
"trigger": "hover",
|
||||
"onEvent": {
|
||||
"mouseenter": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "mouseenter ${event.data.items.length}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### mouseleave
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "dropdown-button",
|
||||
"label": "下拉按钮",
|
||||
"trigger": "hover",
|
||||
"onEvent": {
|
||||
"mouseleave": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "mouseleave ${event.data.items.length}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
暂无
|
||||
225
docs/zh-CN/components/each.md
Executable file
225
docs/zh-CN/components/each.md
Executable file
@@ -0,0 +1,225 @@
|
||||
---
|
||||
title: Each 循环渲染器
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Each 循环渲染器
|
||||
icon:
|
||||
order: 45
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
通过 name 属性指定要循环的数组,items 属性指定循环的内容。
|
||||
|
||||
```schema: scope="page"
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"arr": ["A", "B", "C"]
|
||||
},
|
||||
"body": {
|
||||
"type": "each",
|
||||
"name": "arr",
|
||||
"items": {
|
||||
"type": "tpl",
|
||||
"tpl": "<span class='label label-default m-l-sm'>${item}</span> "
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 如果是对象数组
|
||||
|
||||
如果数组中的数据是对象,可以直接使用内部变量 xxx 来获取,或者通过 `item.xxxx`。另外能用 index 来获取数组索引。
|
||||
|
||||
> 如果成员对象本身也有名字为 index 的字段就会覆盖到,获取不到索引了,请查看「循环嵌套」的章节解决
|
||||
|
||||
```schema:height="160" scope="page"
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"arr": [{"name": "a"}, {"name": "b"}, {"name": "c"}]
|
||||
},
|
||||
"body": {
|
||||
"type": "each",
|
||||
"name": "arr",
|
||||
"items": {
|
||||
"type": "tpl",
|
||||
"tpl": "<span class='label label-default m-l-sm'>${name}:${index}</span> "
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 循环嵌套
|
||||
|
||||
如果存在嵌套使用,通过默认的 `item` 或者 `index` 始终是拿的最里面那层的信息,想要获取上层 each 的信息,则需要自定义 `itemKeyName` 和 `indexKeyName` 来指定字段名。
|
||||
|
||||
```schema:height="160" scope="page"
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"arr": [{"name": "a", "subList": ["a1", "a2"]}, {"name": "b", "subList": ["b1", "b2"]}, {"name": "c", "subList": ["c1", "c2"]}]
|
||||
},
|
||||
"body": {
|
||||
"type": "each",
|
||||
"name": "arr",
|
||||
"itemKeyName": "itemOutter",
|
||||
"indexKeyName": "indexOutter",
|
||||
"items": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"inline": false,
|
||||
"tpl": "<span class='label label-default m-l-sm'>${name}:${index}</span> "
|
||||
},
|
||||
|
||||
{
|
||||
"type": "each",
|
||||
"name": "subList",
|
||||
"items": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "<span class='label label-default m-l-sm'>${itemOutter.name}-${item}:${indexOutter}-${index}</span> "
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 用作 Field 时
|
||||
|
||||
当用在 Table 的列配置 Column、List 的内容、Card 卡片的内容和表单的 Static-XXX 中时,可以设置`name`属性,映射同名变量,然后用可以通过 `item` 变量获取单项值
|
||||
|
||||
### Table 中的列类型
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "table",
|
||||
"data": {
|
||||
"items": [
|
||||
{
|
||||
"id": "1",
|
||||
"each": ["A1", "B1", "C1"]
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"each": ["A2", "B2", "C2"]
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"each": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"label": "Id"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "each",
|
||||
"label": "循环",
|
||||
"type": "each",
|
||||
"placeholder": "暂无内容",
|
||||
"items": {
|
||||
"type": "tpl",
|
||||
"tpl": "<span class='label label-info m-l-sm'>${item}</span>"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
List 的内容、Card 卡片的内容配置同上
|
||||
|
||||
### Form 中静态展示
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"data": {
|
||||
"each": ["A", "B", "C"]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "each",
|
||||
"label": "静态展示each",
|
||||
"name": "each",
|
||||
"items": {
|
||||
"type": "tpl",
|
||||
"tpl": "<span class='label label-info m-l-sm'>${item}</span>"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 使用数据映射
|
||||
|
||||
```schema: scope="page"
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"arr": ["A", "B", "C"]
|
||||
},
|
||||
"body": {
|
||||
"type": "each",
|
||||
"source": "${arr}",
|
||||
"items": {
|
||||
"type": "tpl",
|
||||
"tpl": "<span class='label label-default m-l-sm'>${item}</span> "
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`name` 的优先级会比 `source` 更高
|
||||
|
||||
## 动态表单项
|
||||
|
||||
> 3.5.0 版本开始支持
|
||||
|
||||
表单项支持通过表达式配置动态表单项,可结合 `each` 组件一起使用。
|
||||
|
||||
```schema: scope="page"
|
||||
{
|
||||
"type": "page",
|
||||
"data": {
|
||||
"arr": ["A", "B", "C"]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
type: "form",
|
||||
debug: true,
|
||||
body: [
|
||||
{
|
||||
"type": "each",
|
||||
"source": "${arr}",
|
||||
"items": {
|
||||
"type": "input-text",
|
||||
"label": "Input${item}",
|
||||
"name": "text${index}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------ | -------- | -------- | -------------------------------------------------------------------- |
|
||||
| type | `string` | `"each"` | 指定为 Each 组件 |
|
||||
| value | `array` | `[]` | 用于循环的值 |
|
||||
| name | `string` | | 获取数据域中变量 |
|
||||
| source | `string` | | 获取数据域中变量, 支持 [数据映射](../../docs/concepts/data-mapping) |
|
||||
| items | `object` | | 使用`value`中的数据,循环输出渲染器。 |
|
||||
| placeholder | `string` | | 当 `value` 值不存在或为空数组时的占位文本 |
|
||||
| itemKeyName | `string` | `item` | 获取循环当前数组成员 |
|
||||
| indexKeyName | `string` | `index` | 获取循环当前索引 |
|
||||
521
docs/zh-CN/components/flex.md
Normal file
521
docs/zh-CN/components/flex.md
Normal file
@@ -0,0 +1,521 @@
|
||||
---
|
||||
title: Flex 布局
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: Flex 布局
|
||||
icon:
|
||||
order: 47
|
||||
---
|
||||
|
||||
Flex 布局是基于 CSS Flex 实现的布局效果,它比 Grid 和 HBox 对子节点位置的可控性更强,比用 CSS 类的方式更易用,并且默认使用水平垂直居中的对齐。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "flex",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 50,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 50,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 50,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
其中 `items` 里的每一个都可以是其他 amis 类型。
|
||||
|
||||
## 子节点水平分布
|
||||
|
||||
> 严格来说并不一定是水平,因为还能通过 direction 修改方向,不过这里为了简化就这么称呼了
|
||||
|
||||
可以通过 justify 控制水平分布方式,默认是 `center` 居中,其他几种的示例如下:
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": [
|
||||
"center",
|
||||
{
|
||||
"type": "flex",
|
||||
"justify": "center",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
"flex-start",
|
||||
{
|
||||
"type": "flex",
|
||||
"justify": "flex-start",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
"flex-end",
|
||||
{
|
||||
"type": "flex",
|
||||
"justify": "flex-end",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
"space-around",
|
||||
{
|
||||
"type": "flex",
|
||||
"justify": "space-around",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
"space-between",
|
||||
{
|
||||
"type": "flex",
|
||||
"justify": "space-between",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
"space-evenly",
|
||||
{
|
||||
"type": "flex",
|
||||
"justify": "space-evenly",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 垂直方向位置
|
||||
|
||||
可以通过设置 `alignItems` 改变在子节点在垂直方向的位置,默认是 `center` 居中,其他几个常见设置请参考:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"body": [
|
||||
"center",
|
||||
{
|
||||
"type": "flex",
|
||||
"alignItems": "center",
|
||||
"style": {
|
||||
"height": 60,
|
||||
"backgroundColor": "#fff"
|
||||
},
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
"flex-start",
|
||||
{
|
||||
"type": "flex",
|
||||
"alignItems": "flex-start",
|
||||
"style": {
|
||||
"height": 60,
|
||||
"backgroundColor": "#fff"
|
||||
},
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
"flex-end",
|
||||
{
|
||||
"type": "flex",
|
||||
"alignItems": "flex-end",
|
||||
"style": {
|
||||
"height": 60,
|
||||
"backgroundColor": "#fff"
|
||||
},
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 布局方向
|
||||
|
||||
默认是行的方式,可以通过 "direction": "column" 改成列的方式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"body": [
|
||||
"direction: row",
|
||||
{
|
||||
"type": "flex",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
},
|
||||
"direction: column",
|
||||
{
|
||||
"type": "flex",
|
||||
"direction": "column",
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 30,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 移动端支持
|
||||
|
||||
有时候希望在移动端有不同展现,比如将 `direction` 改成 `column`:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "flex",
|
||||
"mobile": {
|
||||
"direction": "column"
|
||||
},
|
||||
"items": [{
|
||||
"style": {
|
||||
"backgroundColor": "#1A5CFF",
|
||||
"width": 100,
|
||||
"height": 50,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#46C93A",
|
||||
"width": 100,
|
||||
"height": 50,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}, {
|
||||
"style": {
|
||||
"backgroundColor": "#FF4757",
|
||||
"width": 100,
|
||||
"height": 50,
|
||||
"margin": 5
|
||||
},
|
||||
"type": "tpl",
|
||||
"tpl": ""
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
其他关于移动端定制的细节请参考[这里](../docs/extend/mobile)。
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------- | -------------------------------------- | ------ | --------------------------------------------------------------------------------------------------- |
|
||||
| type | `string` | `flex` | 指定为 Flex 渲染器 |
|
||||
| className | `string` | | css 类名 |
|
||||
| justify | `string` | | "start", "flex-start", "center", "end", "flex-end", "space-around", "space-between", "space-evenly" |
|
||||
| alignItems | `string` | | "stretch", "start", "flex-start", "flex-end", "end", "center", "baseline" |
|
||||
| style | `object` | | 自定义样式 |
|
||||
| items[] | [SchemaNode](../docs/types/schemanode) | |
|
||||
451
docs/zh-CN/components/form/button-group-select.md
Executable file
451
docs/zh-CN/components/form/button-group-select.md
Executable file
@@ -0,0 +1,451 @@
|
||||
---
|
||||
title: Button-Group-Select 按钮点选
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Button-Group-Select
|
||||
icon:
|
||||
order: 6
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
按钮集合当 select 点选用。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 垂直模式
|
||||
|
||||
配置`"vertical": true`,实现垂直模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"vertical": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 平铺模式
|
||||
|
||||
配置 `"tiled": true` 实现平铺模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"tiled": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 按钮主题样式
|
||||
|
||||
配置 `btnLevel` 统一设置按钮主题样式,注意 `buttons ` 或 `options` 中的`level`属性优先级高于`btnLevel`。配置 `btnActiveLevel` 为按钮设置激活态时的主题样式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"btnLevel": "light",
|
||||
"btnActiveLevel": "warning",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c",
|
||||
"level": "primary"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 支持角标
|
||||
|
||||
按钮可支持角标,在 options 中配置
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b",
|
||||
"badge": {
|
||||
"mode": "text",
|
||||
"text": 15
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c",
|
||||
"badge": {
|
||||
"mode": "ribbon",
|
||||
"text": "HOT"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| -------------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------- | ------- |
|
||||
| type | `string` | `"button-group-select"` | 指定为 button-group-select 渲染器 |
|
||||
| vertical | `boolean` | `false` | 是否使用垂直模式 |
|
||||
| tiled | `boolean` | `false` | 是否使用平铺模式 |
|
||||
| btnLevel | `'link' \| 'primary' \| 'secondary' \| 'info'\|'success' \| 'warning' \| 'danger' \| 'light'\| 'dark' \| 'default'` | `"default"` | 按钮样式 |
|
||||
| btnActiveLevel | `'link' \| 'primary' \| 'secondary' \| 'info'\|'success' \| 'warning' \| 'danger' \| 'light'\| 'dark' \| 'default'` | `"default"` | 选中按钮样式 |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./options#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| option.badge | `object` | | [角标](../badge#属性表) | `2.8.1` |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| multiple | `boolean` | `false` | [多选](./options#%E5%A4%9A%E9%80%89-multiple) |
|
||||
| labelField | `boolean` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `boolean` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
| autoFill | `object` | | [自动填充](./options#%E8%87%AA%E5%8A%A8%E5%A1%AB%E5%85%85-autofill) |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | ---------------- |
|
||||
| change | `[name]: string` 组件的值 | 选中值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
|
||||
| setValue | `value: string` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "clear_type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
],
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"data": {
|
||||
"abc": {
|
||||
"type": "c"
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "reset_type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
],
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "reload_type",
|
||||
"source": "/api/mock2/form/getOptions?waitSeconds=1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "button-group-select",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "setvalue_type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
],
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_type",
|
||||
"args": {
|
||||
"value": "c"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
59
docs/zh-CN/components/form/button-toolbar.md
Executable file
59
docs/zh-CN/components/form/button-toolbar.md
Executable file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: Button-Toolbar 按钮工具栏
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Button-Toolbar
|
||||
icon:
|
||||
order: 5
|
||||
---
|
||||
|
||||
默认按钮会独占一行,如果想让多个按钮并排方式,可以使用 `button-toolbar` 组件包裹起来,另外还有能用 [button-group](./button-group) 来在展现上更紧凑。
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "test",
|
||||
"label": "Text"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "button-toolbar",
|
||||
"label": "按钮组",
|
||||
"buttons": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "按钮",
|
||||
"actionType": "dialog",
|
||||
"dialog": {
|
||||
"title": "提示",
|
||||
"body": "对,你刚点击了!"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "提交"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "reset",
|
||||
"label": "重置"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------- | --------------------------- | ------------------ | ------------------------- |
|
||||
| type | `string` | `"button-toolbar"` | 指定为 ButtonToolbar 组件 |
|
||||
| buttons | Array<[行为按钮](./action)> | | 按钮组 |
|
||||
246
docs/zh-CN/components/form/chain-select.md
Executable file
246
docs/zh-CN/components/form/chain-select.md
Executable file
@@ -0,0 +1,246 @@
|
||||
---
|
||||
title: Chained-Select 链式下拉框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Chained-Select
|
||||
icon:
|
||||
order: 7
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
用于实现无限级别下拉,只支持单选,且必须和 `source` 搭配,通过 API 拉取数据,只要 API 有返回结果,就能一直无限级别下拉。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "select3",
|
||||
"type": "chained-select",
|
||||
"label": "链式下拉",
|
||||
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
|
||||
"value": "a,b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> `source`接口中配置的参数`waitSeconds=1`和`maxLevel=4`是测试接口所需参数,实际使用自己接口时不需要添加这两个参数
|
||||
|
||||
## 暴露参数
|
||||
|
||||
为了帮助后端接口获取当前选择器状态,chained-select 会默认给 source 接口的数据域中,添加若干个参数:
|
||||
|
||||
- `value`: 选中的表单项值;
|
||||
- `level`: 当前拉取数据时的层级,
|
||||
- `parentId`: 上一级选项的值,数据格式基于配置的`joinValues`和`extractValue`属性
|
||||
- `parent`: 上一级选项的完整的数据格式
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------ | ----------------------------------------- | --------- | ------------------------------------------------------------------------------------------- |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./options#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| autoComplete | `string`或 [API](../../../docs/types/api) | | [自动选中](./options#%E8%87%AA%E5%8A%A8%E8%A1%A5%E5%85%A8-autocomplete) |
|
||||
| delimiter | `string` | `,` | [拼接符](./options#%E6%8B%BC%E6%8E%A5%E7%AC%A6-delimiter) |
|
||||
| labelField | `boolean` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `boolean` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | ---------------- |
|
||||
| change | `[name]: string` 组件的值 | 选中值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "select3",
|
||||
"type": "chained-select",
|
||||
"label": "链式下拉",
|
||||
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
|
||||
"value": "a,b",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
|
||||
| setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "type",
|
||||
"id": "clear_type",
|
||||
"type": "chained-select",
|
||||
"label": "链式下拉",
|
||||
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
|
||||
"value": "a,b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "type",
|
||||
"id": "reset_type",
|
||||
"type": "chained-select",
|
||||
"label": "链式下拉",
|
||||
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
|
||||
"value": "a,b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "type",
|
||||
"id": "reload_type",
|
||||
"type": "chained-select",
|
||||
"label": "链式下拉",
|
||||
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
|
||||
"value": "a,b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "type",
|
||||
"id": "setvalue_type",
|
||||
"type": "chained-select",
|
||||
"label": "链式下拉",
|
||||
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
|
||||
"value": "a,b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_type",
|
||||
"args": {
|
||||
"value": "c"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
57
docs/zh-CN/components/form/chart-radios.md
Normal file
57
docs/zh-CN/components/form/chart-radios.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
title: ChartRadios 图表单选框
|
||||
description:
|
||||
type: 0
|
||||
group: ⚙ 组件
|
||||
menuName: ChartRadios 图表单选框
|
||||
icon:
|
||||
order: 34
|
||||
---
|
||||
|
||||
图表点选功能,用来做多个图表联动。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "chart-radios",
|
||||
name: 'main',
|
||||
chartValueField: 'num',
|
||||
"options": [
|
||||
{
|
||||
"label": "A",
|
||||
"num": 100,
|
||||
value: 'a'
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"num": 120,
|
||||
value: 'b'
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"num": 30,
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
"label": "D",
|
||||
"num": 40,
|
||||
value: 'd'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 ## 二级标题 |
|
||||
| ---------------------- | --------- | --------- | -------------------------- |
|
||||
| config | `object` | | echart 图表配置 |
|
||||
| showTooltipOnHighlight | `boolean` | `false` | 高亮的时候是否显示 tooltip |
|
||||
| chartValueField | `string` | `"value"` | 图表数值字段名 |
|
||||
254
docs/zh-CN/components/form/checkbox.md
Executable file
254
docs/zh-CN/components/form/checkbox.md
Executable file
@@ -0,0 +1,254 @@
|
||||
---
|
||||
title: Checkbox 勾选框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Checkbox
|
||||
icon:
|
||||
order: 8
|
||||
---
|
||||
|
||||
用于实现勾选,功能和 [Switch](./switch) 类似,只是展现上不同。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkbox",
|
||||
"type": "checkbox",
|
||||
"label": "勾选框",
|
||||
"option": "选项说明"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配置真假值
|
||||
|
||||
默认情况:
|
||||
|
||||
- 勾选框勾选时,表单项值为:true
|
||||
- 勾选框取消勾选时,表单项值为:false
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkbox",
|
||||
"type": "checkbox",
|
||||
"label": "勾选框",
|
||||
"option": "选项说明"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果你想调整这个值,可以配置`trueValue`和`falseValue`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkbox",
|
||||
"type": "checkbox",
|
||||
"label": "勾选框",
|
||||
"option": "选项说明",
|
||||
"trueValue": 1,
|
||||
"falseValue": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
勾选上例中的勾选框,观察数据域变化,会发现勾选后值为`1`,而取消勾选后为`0`
|
||||
|
||||
## 按钮模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkbox",
|
||||
"type": "checkbox",
|
||||
"label": "勾选框",
|
||||
"trueValue": true,
|
||||
"falseValue": false,
|
||||
"optionType": "button",
|
||||
"option": "选项说明"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------- | ------------------------- | --------- | ---------------- |
|
||||
| option | `string` | | 选项说明 |
|
||||
| trueValue | `string|number|boolean` | `true` | 标识真值 |
|
||||
| falseValue | `string|number|boolean` | `false` | 标识假值 |
|
||||
| optionType | `default|button` | `default` | 设置 option 类型 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | -------------------------- | ------------------ |
|
||||
| change | `[name]: boolean` 组件的值 | 选中状态变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkbox",
|
||||
"type": "checkbox",
|
||||
"label": "勾选框",
|
||||
"option": "选项说明",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkbox",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "clear_type",
|
||||
"option": "选项说明",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkbox",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "reset_type",
|
||||
"option": "选项说明",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkbox",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "setvalue_type",
|
||||
"option": "选项说明",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_type",
|
||||
"args": {
|
||||
"value": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
864
docs/zh-CN/components/form/checkboxes.md
Executable file
864
docs/zh-CN/components/form/checkboxes.md
Executable file
@@ -0,0 +1,864 @@
|
||||
---
|
||||
title: Checkboxes 复选框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Checkboxes
|
||||
icon:
|
||||
order: 9
|
||||
---
|
||||
|
||||
用于实现多选。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 结果是数组模式
|
||||
|
||||
默认是拼接成字符串,如果希望结果是数组,可以设置 `"joinValues": false`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"joinValues": false,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果只想提取 value,需要加上 `"extractValue": true`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"joinValues": false,
|
||||
"extractValue": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示全选
|
||||
|
||||
通过 `checkAll` 属性配置全选
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"checkAll": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 按钮模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"optionType": "button",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 按列显示
|
||||
|
||||
设置 `"inline": false`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"inline": false,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 展示多行
|
||||
|
||||
可以配置`columnsCount`属性调整展示列的个数
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes1",
|
||||
"type": "checkboxes",
|
||||
"label": "默认的复选框",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"name": "checkboxes2",
|
||||
"type": "checkboxes",
|
||||
"label": "显示两列的复选框",
|
||||
"columnsCount": 2,
|
||||
"inline": false,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> 1.8.0 及以上版本
|
||||
|
||||
`columnsCount` 还有一种数组形式,可以手动控制每行显示的列数
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes1",
|
||||
"type": "checkboxes",
|
||||
"label": "默认的复选框",
|
||||
"columnsCount": [1, 2, 3],
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
},
|
||||
{
|
||||
"label": "OptionE",
|
||||
"value": "e"
|
||||
},
|
||||
{
|
||||
"label": "OptionF",
|
||||
"value": "f"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 分组显示
|
||||
|
||||
`"inline": false` 下,选项中配置 `children` 字段可以实现分组展示效果。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"mode": "horizontal",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkboxes",
|
||||
"name": "checkboxes",
|
||||
"label": "城市选择",
|
||||
"inline": false,
|
||||
"checkAll": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "A类型",
|
||||
"children": [
|
||||
{
|
||||
"label": "选项 A-1",
|
||||
"value": "a-1"
|
||||
},
|
||||
{
|
||||
"label": "选项 A-2",
|
||||
"value": "a-2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "B类型",
|
||||
"children": [
|
||||
{
|
||||
"label": "选项 B-1",
|
||||
"value": "b-1"
|
||||
},
|
||||
{
|
||||
"label": "选项 B-2",
|
||||
"value": "b-2"
|
||||
},
|
||||
{
|
||||
"label": "选项 B-3",
|
||||
"value": "b-3"
|
||||
},
|
||||
{
|
||||
"label": "选项 B-4",
|
||||
"value": "b-4"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义选项渲染
|
||||
|
||||
> 2.0.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"menuTpl": "<span class='label label-${klass}'>${label}</span>",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a",
|
||||
"klass": "success"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b",
|
||||
"klass": "danger"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c",
|
||||
"klass": "warning"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d",
|
||||
"klass": "info"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------------- | ----------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------- |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| delimiter | `string` | `,` | [拼接符](./options#%E6%8B%BC%E6%8E%A5%E7%AC%A6-delimiter) |
|
||||
| labelField | `string` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `string` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
| columnsCount | `number` | `1` | 选项按几列显示,默认为一列 |
|
||||
| menuTpl | `string` | | 支持自定义选项渲染 |
|
||||
| checkAll | `boolean` | `false` | 是否支持全选 |
|
||||
| inline | `boolean` | `true` | 是否显示为一行 |
|
||||
| defaultCheckAll | `boolean` | `false` | 默认是否全选 |
|
||||
| creatable | `boolean` | `false` | [新增选项](./options#%E5%89%8D%E7%AB%AF%E6%96%B0%E5%A2%9E-creatable) |
|
||||
| createBtnLabel | `string` | `"新增选项"` | [新增选项](./options#%E6%96%B0%E5%A2%9E%E9%80%89%E9%A1%B9) |
|
||||
| addControls | Array<[表单项](./formitem)> | | [自定义新增表单项](./options#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%96%B0%E5%A2%9E%E8%A1%A8%E5%8D%95%E9%A1%B9-addcontrols) |
|
||||
| addApi | [API](../../docs/types/api) | | [配置新增选项接口](./options#%E9%85%8D%E7%BD%AE%E6%96%B0%E5%A2%9E%E6%8E%A5%E5%8F%A3-addapi) |
|
||||
| editable | `boolean` | `false` | [编辑选项](./options#%E5%89%8D%E7%AB%AF%E7%BC%96%E8%BE%91-editable) |
|
||||
| editControls | Array<[表单项](./formitem)> | | [自定义编辑表单项](./options#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BC%96%E8%BE%91%E8%A1%A8%E5%8D%95%E9%A1%B9-editcontrols) |
|
||||
| editApi | [API](../../docs/types/api) | | [配置编辑选项接口](./options#%E9%85%8D%E7%BD%AE%E7%BC%96%E8%BE%91%E6%8E%A5%E5%8F%A3-editapi) |
|
||||
| removable | `boolean` | `false` | [删除选项](./options#%E5%88%A0%E9%99%A4%E9%80%89%E9%A1%B9) |
|
||||
| deleteApi | [API](../../docs/types/api) | | [配置删除选项接口](./options#%E9%85%8D%E7%BD%AE%E5%88%A0%E9%99%A4%E6%8E%A5%E5%8F%A3-deleteapi) |
|
||||
| optionType | `default` \| `button` | `default` | 按钮模式 |
|
||||
| itemClassName | `string` | | 选项样式类名 |
|
||||
| labelClassName | `string` | | 选项标签样式类名 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------------------------------- | ----------------------------------------------------------------------------------------- | ------------------ |
|
||||
| change | `[name]: string` 选中值 | 选中值变化时触发 |
|
||||
| addConfirm (3.6.4 及以上版本) | `[name]: string` 组件的值<br/>`item: object` 新增的节点信息<br/>`items: object[]`选项集合 | 新增节点提交时触发 |
|
||||
| editConfirm (3.6.4 及以上版本) | `[name]: object` 组件的值<br/>`item: object` 编辑的节点信息<br/>`items: object[]`选项集合 | 编辑节点提交时触发 |
|
||||
| deleteConfirm (3.6.4 及以上版本) | `[name]: string` 组件的值<br/>`item: object` 删除的节点信息<br/>`items: object[]`选项集合 | 删除节点提交时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### addConfirm
|
||||
|
||||
配置 `creatable`后,可监听确认新增操作。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"creatable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"addConfirm": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.item|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### editConfirm
|
||||
|
||||
配置 `editable`后,可监听确认编辑操作。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"editable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"editConfirm": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.item|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### deleteConfirm
|
||||
|
||||
配置 `removable`后,可监听确认删除操作。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "checkboxes",
|
||||
"type": "checkboxes",
|
||||
"label": "复选框",
|
||||
"removable": true,
|
||||
"labelField": "label2",
|
||||
"valueField": "value2",
|
||||
"options": [
|
||||
{
|
||||
"label2": "OptionA",
|
||||
"value2": "a"
|
||||
},
|
||||
{
|
||||
"label2": "OptionB",
|
||||
"value2": "b"
|
||||
},
|
||||
{
|
||||
"label2": "OptionC",
|
||||
"value2": "c"
|
||||
},
|
||||
{
|
||||
"label2": "OptionD",
|
||||
"value2": "d"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"deleteConfirm": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.item|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
|
||||
| setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkboxes",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "clear_type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
],
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkboxes",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "reset_type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
],
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkboxes",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "reload_type",
|
||||
"source": "/api/mock2/form/getOptions?waitSeconds=1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "checkboxes",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "setvalue_type",
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "Option C",
|
||||
"value": "c"
|
||||
}
|
||||
],
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_type",
|
||||
"args": {
|
||||
"value": "c"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
2010
docs/zh-CN/components/form/combo.md
Executable file
2010
docs/zh-CN/components/form/combo.md
Executable file
File diff suppressed because it is too large
Load Diff
1477
docs/zh-CN/components/form/condition-builder.md
Normal file
1477
docs/zh-CN/components/form/condition-builder.md
Normal file
File diff suppressed because it is too large
Load Diff
78
docs/zh-CN/components/form/control.md
Normal file
78
docs/zh-CN/components/form/control.md
Normal file
@@ -0,0 +1,78 @@
|
||||
---
|
||||
title: Control 表单项包裹
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Control
|
||||
icon:
|
||||
order: 24
|
||||
---
|
||||
|
||||
展示类的组件,如果直接放在表单项里面,不会有 `label` 和 `description` 之类的信息展示。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"mode": "horizontal",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"label": "文本输入"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "image",
|
||||
"src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "qr-code",
|
||||
"codeSize": 128,
|
||||
"backgroundColor": "#108cee",
|
||||
"foregroundColor": "#000",
|
||||
"value": "https://www.baidu.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果想像文本输入框一样,可以配置 `label` 和 `description`,则可以通过这个组件包裹一下。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"mode": "horizontal",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"label": "文本输入"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "control",
|
||||
"label": "图片",
|
||||
body: [
|
||||
{
|
||||
"type": "image",
|
||||
"src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
"type": "control",
|
||||
"label": "二维码",
|
||||
"description": "还可以来点描述",
|
||||
body: [
|
||||
{
|
||||
"type": "qr-code",
|
||||
"codeSize": 128,
|
||||
"backgroundColor": "#108cee",
|
||||
"foregroundColor": "#000",
|
||||
"value": "https://www.baidu.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
245
docs/zh-CN/components/form/diff-editor.md
Executable file
245
docs/zh-CN/components/form/diff-editor.md
Executable file
@@ -0,0 +1,245 @@
|
||||
---
|
||||
title: DiffEditor 对比编辑器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: DiffEditor 对比编辑器
|
||||
icon:
|
||||
order: 17
|
||||
---
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "diff-editor",
|
||||
"name": "diff",
|
||||
"label": "Diff-Editor",
|
||||
"diffValue": "hello world",
|
||||
"value": "hello"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 禁用编辑器
|
||||
|
||||
左侧编辑器始终不可编辑,右侧编辑器可以通过设置`disabled`或`disabledOn`,控制是否禁用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "diff-editor",
|
||||
"name": "diff",
|
||||
"label": "Diff-Editor",
|
||||
"diffValue": "hello world",
|
||||
"value": "hello",
|
||||
"disabledOn": "this.isDisabled"
|
||||
},
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "isDisabled",
|
||||
"label": "是否禁用"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## diff 数据域中的两个变量
|
||||
|
||||
如下例,左侧编辑器中的值,通过`"diffValue": "${value1}"`获取,右侧编辑器的值,通过设置`"name": "value2"`,自动映射数据域中`value2`的值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"data": {
|
||||
"value1": "hello world",
|
||||
"value2": "hello wrold"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "diff-editor",
|
||||
"name": "value2",
|
||||
"label": "Diff-Editor",
|
||||
"diffValue": "${value1}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------- | ------------- | ------------ | ------------------------------------------------------------------------------------------- |
|
||||
| language | `string` | `javascript` | 编辑器高亮的语言,可选 [支持的语言](./editor#%E6%94%AF%E6%8C%81%E7%9A%84%E8%AF%AD%E8%A8%80) |
|
||||
| diffValue | [Tpl](../tpl) | | 左侧值 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | ------------------------ |
|
||||
| change | `[name]: string` 组件的值 | 代码变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 右侧输入框获取焦点时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 右侧输入框失去焦点时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| focus | - | 获取焦点,焦点落在右侧编辑面板 |
|
||||
| setValue | `value: string` 更新的右侧编辑面板中的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "diff-editor",
|
||||
"name": "diff",
|
||||
"id": "clear_text",
|
||||
"label": "Diff-Editor",
|
||||
"diffValue": "hello world",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"id": "reset_text",
|
||||
"type": "diff-editor",
|
||||
"name": "diff",
|
||||
"label": "Diff-Editor",
|
||||
"diffValue": "hello world",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### focus
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"id": "focus_text",
|
||||
"type": "diff-editor",
|
||||
"name": "diff",
|
||||
"label": "Diff-Editor",
|
||||
"diffValue": "hello world",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "聚焦",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "focus",
|
||||
"componentId": "focus_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"id": "setvalue_text",
|
||||
"type": "diff-editor",
|
||||
"name": "diff",
|
||||
"label": "Diff-Editor",
|
||||
"diffValue": "hello world",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "amis go go go!"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
322
docs/zh-CN/components/form/editor.md
Executable file
322
docs/zh-CN/components/form/editor.md
Executable file
@@ -0,0 +1,322 @@
|
||||
---
|
||||
title: Editor 编辑器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Editor
|
||||
icon:
|
||||
order: 19
|
||||
---
|
||||
|
||||
用于实现代码编辑,如果要实现富文本编辑请使用 [Rich-Text](./input-rich-text)。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"name": "editor",
|
||||
"label": "编辑器",
|
||||
placeholder: "function() {\n console.log('hello world')\n}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 支持的语言
|
||||
|
||||
可以设置`language`配置高亮的语言,支持的语言有:
|
||||
|
||||
`bat`、 `c`、 `coffeescript`、 `cpp`、 `csharp`、 `css`、 `dockerfile`、 `fsharp`、 `go`、 `handlebars`、 `html`、 `ini`、 `java`、 `javascript`、 `json`、 `less`、 `lua`、 `markdown`、 `msdax`、 `objective-c`、 `php`、 `plaintext`、 `postiats`、 `powershell`、 `pug`、 `python`、 `r`、 `razor`、 `ruby`、 `sb`、 `scss`、`shell`、 `sol`、 `sql`、 `swift`、 `typescript`、 `vb`、 `xml`、 `yaml`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"name": "editor",
|
||||
"label": "JSON编辑器",
|
||||
"language": "json"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> 因为性能原因,上面的例子不支持实时修改 language 生效
|
||||
|
||||
当然你也可以使用`xxx-editor`这种形式,例如`"type": "json-editor"`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "json-editor",
|
||||
"name": "editor",
|
||||
"label": "JSON编辑器"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 只读模式
|
||||
|
||||
使用 `disabled: true`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "json-editor",
|
||||
"name": "editor",
|
||||
"disabled": true,
|
||||
"label": "JSON编辑器"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 全屏模式
|
||||
|
||||
设置`allowFullscreen`属性为`true`,显示编辑器的全屏模式开关,开关开启后编辑器进入全屏模式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"name": "editor",
|
||||
"label": "支持全屏模式的编辑器",
|
||||
"allowFullscreen": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 编辑器展现控制
|
||||
|
||||
通过 `options` 来控制编辑器展现,比如下面的配置可以关闭行号
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"name": "editor",
|
||||
"label": "编辑器",
|
||||
"options": {
|
||||
"lineNumbers": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 编辑器自定义开发
|
||||
|
||||
amis 的编辑器是基于 monaco 开发的,如果想进行深度定制,比如自动完成功能,可以通过自定义 `editorDidMount` 属性来获取到 monaco 实例,它有两种写法,一种是在 JS 中直接用函数,示例如下:
|
||||
|
||||
```javascript
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"name": "editor",
|
||||
"label": "编辑器",
|
||||
"language": "myLan",
|
||||
"editorDidMount": (editor, monaco) => {
|
||||
// editor 是 monaco 实例,monaco 是全局的名称空间
|
||||
const dispose = monaco.languages.registerCompletionItemProvider('myLan', {
|
||||
/// 其他细节参考 monaco 手册
|
||||
});
|
||||
|
||||
// 如果返回一个函数,这个函数会在编辑器组件卸载的时候调用,主要用于清理资源
|
||||
return dispose;
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------------- | --------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| language | `string` | `javascript` | 编辑器高亮的语言,支持通过 `${xxx}` 变量获取 |
|
||||
| size | `string` | `md` | 编辑器高度,取值可以是 `md`、`lg`、`xl`、`xxl` |
|
||||
| allowFullscreen | `boolean` | `false` | 是否显示全屏模式开关 |
|
||||
| options | `object` | | monaco 编辑器的其它配置,比如是否显示行号等,请参考[这里](https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IEditorOptions.html),不过无法设置 readOnly,只读模式需要使用 `disabled: true` |
|
||||
| placeholder | `string` | | 占位描述,没有值的时候展示 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------- |
|
||||
| change | `[name]: string` 组件的值 | 代码变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| focus | - | 获取焦点 |
|
||||
| setValue | `value: string` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"name": "editor",
|
||||
"label": "编辑器",
|
||||
"id": "clear_text",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"id": "reset_text",
|
||||
"name": "editor",
|
||||
"label": "编辑器",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### focus
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"id": "focus_text",
|
||||
"name": "editor",
|
||||
"label": "编辑器",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "聚焦",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "focus",
|
||||
"componentId": "focus_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "editor",
|
||||
"id": "setvalue_text",
|
||||
"name": "editor",
|
||||
"label": "编辑器",
|
||||
"value": "hello"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "amis go go go!"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
245
docs/zh-CN/components/form/fieldset.md
Executable file
245
docs/zh-CN/components/form/fieldset.md
Executable file
@@ -0,0 +1,245 @@
|
||||
---
|
||||
title: FieldSet 表单项集合
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: FieldSet
|
||||
icon:
|
||||
order: 20
|
||||
---
|
||||
|
||||
FieldSet 是用于分组展示表单项的一种容器型组件,可以折叠。
|
||||
|
||||
## 基本用法
|
||||
|
||||
可以通过配置标题`title`和表单项数组`body`,实现多个表单项分组展示
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "fieldSet",
|
||||
"title": "基本配置",
|
||||
"body": [
|
||||
{
|
||||
"name": "text1",
|
||||
"type": "input-text",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "text2",
|
||||
"type": "input-text",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 展示模式
|
||||
|
||||
可以通过设置`mode`调整展示模式,用法同 [Form 展示模式](./index#%E8%A1%A8%E5%8D%95%E5%B1%95%E7%A4%BA)
|
||||
|
||||
下面`group`我们配置了`"mode": "horizontal"`,观察显示情况
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text",
|
||||
"label": "文本"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "fieldSet",
|
||||
"title": "基本配置",
|
||||
"mode": "horizontal",
|
||||
"body": [
|
||||
{
|
||||
"name": "text1",
|
||||
"type": "input-text",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "text2",
|
||||
"type": "input-text",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 可折叠
|
||||
|
||||
配置`"collapsable": true`可以实现点击标题折叠显隐表单项。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "fieldSet",
|
||||
"title": "基本配置",
|
||||
"collapsable": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text1",
|
||||
"type": "input-text",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "text2",
|
||||
"type": "input-text",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 默认是否折叠
|
||||
|
||||
默认是展开的,如果想默认折叠,那么配置`"collapsed": true`默认折叠。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "fieldSet",
|
||||
"title": "基本配置",
|
||||
"collapsable": true,
|
||||
"collapsed": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text1",
|
||||
"type": "input-text",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "text2",
|
||||
"type": "input-text",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 标题放底部
|
||||
|
||||
fieldSet 的另一种标题展现样式,不同的是展开的时候收起文本是在下方的,如果组件比较多的时候更容易收起。
|
||||
|
||||
设置 `"titlePosition": "bottom"`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "fieldSet",
|
||||
"title": "展开更多设置",
|
||||
"collapseTitle": "收起设置",
|
||||
"titlePosition": "bottom",
|
||||
"collapsable": true,
|
||||
"collapsed": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text1",
|
||||
"type": "input-text",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "text2",
|
||||
"type": "input-text",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 嵌套使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "fieldSet",
|
||||
"title": "基本配置",
|
||||
"collapsable": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text1",
|
||||
"type": "input-text",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "text2",
|
||||
"type": "input-text",
|
||||
"label": "文本2"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "fieldSet",
|
||||
"title": "基本配置",
|
||||
"collapsable": true,
|
||||
"collapsed": true,
|
||||
size: 'base',
|
||||
"body": [
|
||||
{
|
||||
"name": "text1",
|
||||
"type": "input-text",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "text2",
|
||||
"type": "input-text",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------------- | -------------------------------------------- | ------- | -------------------------------------------------------------------------- |
|
||||
| className | `string` | | CSS 类名 |
|
||||
| headingClassName | `string` | | 标题 CSS 类名 |
|
||||
| bodyClassName | `string` | | 内容区域 CSS 类名 |
|
||||
| title | [SchemaNode](../../../docs/types/schemanode) | | 标题 |
|
||||
| body | Array<[表单项](./formitem)> | | 表单项集合 |
|
||||
| mode | `string` | | 展示默认,同 [Form](./index#%E8%A1%A8%E5%8D%95%E5%B1%95%E7%A4%BA) 中的模式 |
|
||||
| collapsable | `boolean` | `false` | 是否可折叠 |
|
||||
| collapsed | `booelan` | `false` | 默认是否折叠 |
|
||||
| collapseTitle | [SchemaNode](../../../docs/types/schemanode) | `收起` | 收起的标题 |
|
||||
| size | string | `` | 大小,支持 xs、sm、base、md、lg |
|
||||
1864
docs/zh-CN/components/form/formitem.md
Executable file
1864
docs/zh-CN/components/form/formitem.md
Executable file
File diff suppressed because it is too large
Load Diff
255
docs/zh-CN/components/form/formula.md
Executable file
255
docs/zh-CN/components/form/formula.md
Executable file
@@ -0,0 +1,255 @@
|
||||
---
|
||||
title: Formula 公式
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Formula
|
||||
icon:
|
||||
order: 22
|
||||
---
|
||||
|
||||
可以设置公式,将公式结果设置到指定表单项上。
|
||||
|
||||
> 该表单项是隐藏的
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "a",
|
||||
"label": "A"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "b",
|
||||
"label": "B"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "sum",
|
||||
"label": "和",
|
||||
"disabled": true,
|
||||
"description": "自动计算 A + B"
|
||||
},
|
||||
{
|
||||
"type": "formula",
|
||||
"name": "sum",
|
||||
"value": 0,
|
||||
"formula": "a + b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动应用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "a",
|
||||
"label": "A"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "b",
|
||||
"label": "B"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "sum",
|
||||
"label": "和",
|
||||
"disabled": true,
|
||||
"description": "自动计算 A + B"
|
||||
},
|
||||
{
|
||||
"type": "formula",
|
||||
"name": "sum",
|
||||
"value": 0,
|
||||
"formula": "a + b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 手动应用
|
||||
|
||||
配置`"autoSet": false`,然后按钮上配置`target`,配置值为`formula`的`id`值,就可以实现手动触发公式应用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "a",
|
||||
"label": "A"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "b",
|
||||
"label": "B"
|
||||
},
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "sum",
|
||||
"label": "和",
|
||||
"disabled": true,
|
||||
"columnClassName": "col-sm-11"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "计算",
|
||||
"columnClassName": "col-sm-1 v-bottom",
|
||||
"target": "theFormula"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "formula",
|
||||
"name": "sum",
|
||||
"id": "theFormula",
|
||||
"value": 0,
|
||||
"formula": "a + b",
|
||||
"initSet": false,
|
||||
"autoSet": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> 为什么设置`id`而不是设置`name`?
|
||||
>
|
||||
> 因为`name`值已经用来设置目标变量名了,这个表单项肯定已经存在了,所以不是唯一了,不能够被按钮指定。
|
||||
|
||||
## 条件应用
|
||||
|
||||
可以配置`condition`用来指定作用条件,有两种写法:
|
||||
|
||||
- 用 tpl 语法,把关联的字段写上如: `${xxx} ${yyy}` 意思是当 xxx 和 yyy 的取值结果变化了就再应用一次公式结果。
|
||||
- 自己写判断如: `this.xxx == "a" && this.xxx !== this.__prev.xxx` 当 xxx 变化了,且新的值是字符 "a" 时应用,可以写更加复杂的判断。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "radios",
|
||||
"name": "radios",
|
||||
"label": "radios",
|
||||
"options": [
|
||||
{
|
||||
"label": "a",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "b",
|
||||
"value": "b"
|
||||
}
|
||||
],
|
||||
"description": "radios 变化会自动清空 B"
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "b",
|
||||
"label": "B"
|
||||
},
|
||||
{
|
||||
"type": "formula",
|
||||
"name": "b",
|
||||
"value": "some string",
|
||||
"formula": "''",
|
||||
"condition": "${radios}",
|
||||
"initSet": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 使用新表达式语法
|
||||
|
||||
> 1.5.0 及以上版本
|
||||
|
||||
通过新的[表达式](../../../docs/concepts/expression)语法,可以调用其中的函数,比如
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "static",
|
||||
"value": "这个表单没有内容,通过上面的 debug 可以看到输出当前日期"
|
||||
},
|
||||
{
|
||||
"type": "formula",
|
||||
"name": "date",
|
||||
"formula": "${DATETOSTR(NOW(), 'YYYY-MM-DD')}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
这种写法默认会解决浮点数计算问题(需要更新到 amis 1.6.4 及以上版本),比如
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "a",
|
||||
"value": 0.1,
|
||||
"label": "A"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "b",
|
||||
"value": 0.2,
|
||||
"label": "B"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "sum",
|
||||
"label": "直接相加",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "formula",
|
||||
"name": "sum",
|
||||
"formula": "a + b"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "sum-new",
|
||||
"label": "使用新表达式",
|
||||
"disabled": true
|
||||
},
|
||||
{
|
||||
"type": "formula",
|
||||
"name": "sum-new",
|
||||
"formula": "${a + b}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------- | ------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------- |
|
||||
| name | `string` | | 需要应用的表单项`name`值,公式结果将作用到此处指定的变量中去。 |
|
||||
| formula | [表达式](../../../docs/concepts/expression) | | 应用的公式 |
|
||||
| condition | [表达式](../../../docs/concepts/expression) | | 公式作用条件 |
|
||||
| initSet | `boolean` | `true` | 初始化时是否设置 |
|
||||
| autoSet | `boolean` | `true` | 观察公式结果,如果计算结果有变化,则自动应用到变量上 |
|
||||
| id | `string` | | 定义个名字,当某个按钮的目标指定为此值后,会触发一次公式应用。这个机制可以在 `autoSet` 为 false 时用来手动触发 |
|
||||
232
docs/zh-CN/components/form/group.md
Executable file
232
docs/zh-CN/components/form/group.md
Executable file
@@ -0,0 +1,232 @@
|
||||
---
|
||||
title: Group 表单项组
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Group
|
||||
icon:
|
||||
order: 24
|
||||
---
|
||||
|
||||
表单项,默认都是一行显示一个,Group 组件用于在一行展示多个表单项,会自动根据表单项数量均分宽度。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text1",
|
||||
"label": "文本1"
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text2",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text3",
|
||||
"label": "文本3"
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text4",
|
||||
"label": "文本4"
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text5",
|
||||
"label": "文本5"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 展示
|
||||
|
||||
可以给`group`组件设置`mode`调整展示模式,用法同 [Form 展示](./index#%E8%A1%A8%E5%8D%95%E5%B1%95%E7%A4%BA)
|
||||
|
||||
下面`group`我们配置了`"mode": "horizontal"`,观察显示情况
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text",
|
||||
"label": "文本"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "group",
|
||||
"mode": "horizontal",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text1",
|
||||
"label": "文本1"
|
||||
},
|
||||
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text2",
|
||||
"label": "文本2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
当表单在水平模式下时,如果`group`内表单项设置`"label": false`,会导致布局错乱,如下
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"mode": "horizontal",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text",
|
||||
"label": "文本"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text1",
|
||||
"label": false
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text2",
|
||||
"label": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
这时可以给`group`配置`label`属性,保持和其他表单项布局统一
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"mode": "horizontal",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text",
|
||||
"label": "文本"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "group",
|
||||
"label": "文本组",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text1",
|
||||
"label": false
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text2",
|
||||
"label": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 宽度占比
|
||||
|
||||
在表单项内部可以通过 `columnRatio` 来控制宽度,整体是 12 等分
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text1",
|
||||
"label": "text1",
|
||||
"columnRatio": 8
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text2",
|
||||
"label": "text2",
|
||||
"columnRatio": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text1",
|
||||
"label": "text1",
|
||||
"columnRatio": 6
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text2",
|
||||
"label": "text2",
|
||||
"columnRatio": 4
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text3",
|
||||
"label": "text3"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------- | --------------------------- | -------------- | -------------------------------------------------------------------------- |
|
||||
| className | `string` | | CSS 类名 |
|
||||
| label | `string` | | group 的标签 |
|
||||
| body | Array<[表单项](./formitem)> | | 表单项集合 |
|
||||
| mode | `string` | | 展示默认,同 [Form](./index#%E8%A1%A8%E5%8D%95%E5%B1%95%E7%A4%BA) 中的模式 |
|
||||
| gap | `string` | | 表单项之间的间距,可选:`xs`、`sm`、`normal` |
|
||||
| direction | `string` | `"horizontal"` | 可以配置水平展示还是垂直展示。对应的配置项分别是:`vertical`、`horizontal` |
|
||||
38
docs/zh-CN/components/form/hidden.md
Executable file
38
docs/zh-CN/components/form/hidden.md
Executable file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: Hidden 隐藏字段
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Hidden 隐藏字段
|
||||
icon:
|
||||
order: 26
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
默认表单提交,在没有 [自定义 API 请求数据](../../../docs/types/api#%E9%85%8D%E7%BD%AE%E8%AF%B7%E6%B1%82%E6%95%B0%E6%8D%AE) 的情况下,只会发送 `body` 里面的这些成员,对于隐藏的字段同时又希望提交表单的时候带过去,可以使用 `hidden` 组件
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "hidden",
|
||||
"name": "id",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "name",
|
||||
"label": "姓名:"
|
||||
},
|
||||
{
|
||||
"name": "email",
|
||||
"type": "input-email",
|
||||
"label": "邮箱:"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
2599
docs/zh-CN/components/form/index.md
Executable file
2599
docs/zh-CN/components/form/index.md
Executable file
File diff suppressed because it is too large
Load Diff
75
docs/zh-CN/components/form/input-array.md
Executable file
75
docs/zh-CN/components/form/input-array.md
Executable file
@@ -0,0 +1,75 @@
|
||||
---
|
||||
title: InputArray 数组输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputArray 数组输入框
|
||||
icon:
|
||||
order: 3
|
||||
---
|
||||
|
||||
InputArray 是一种简化的 [Combo](./combo),用于输入多个某种类型的[表单项](./formitem),提交的时将以数组的形式提交。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="form2"
|
||||
[
|
||||
{
|
||||
"name": "array",
|
||||
"label": "颜色集合",
|
||||
"type": "input-array",
|
||||
"value": ["red"],
|
||||
"inline": true,
|
||||
"items": {
|
||||
"type": "input-color",
|
||||
"clearable": false
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 新增成员默认值
|
||||
|
||||
部分情况下,期望新增元素时使用默认值,这时可以通过设置`scaffold`属性配置新增成员的默认值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"debugConfig": {
|
||||
"levelExpand": 2
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"name": "array",
|
||||
"label": "整数集合",
|
||||
"mode": "horizontal",
|
||||
"type": "input-array",
|
||||
"value": [123, 456],
|
||||
"scaffold": 0,
|
||||
"inline": true,
|
||||
"items": {
|
||||
"type": "input-number",
|
||||
"clearable": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------- | ------------------------------------------- | --------- | ------------------------------------------------------------------------ |
|
||||
| type | `string` | `"input-array"` | 指明为`array`组件 |
|
||||
| items | [`SchemaNode`](../../docs/types/schemanode) | | 配置单项表单类型 |
|
||||
| addable | `boolean` | | 是否可新增。 |
|
||||
| removable | `boolean` | | 是否可删除 |
|
||||
| draggable | `boolean` | `false` | 是否可以拖动排序, 需要注意的是当启用拖动排序的时候,会多一个\$id 字段 |
|
||||
| draggableTip | `string` | | 可拖拽的提示文字,默认为:`"可通过拖动每行中的【交换】按钮进行顺序调整"` |
|
||||
| addButtonText | `string` | `"新增"` | 新增按钮文字 |
|
||||
| minLength | `number` | | 限制最小长度 |
|
||||
| maxLength | `number` | | 限制最大长度 |
|
||||
| scaffold | `any` | | 新增成员时的默认值,一般根据`items`的数据类型指定需要的默认值 |
|
||||
253
docs/zh-CN/components/form/input-city.md
Executable file
253
docs/zh-CN/components/form/input-city.md
Executable file
@@ -0,0 +1,253 @@
|
||||
---
|
||||
title: InputCity 城市选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputCity
|
||||
icon:
|
||||
order: 10
|
||||
---
|
||||
|
||||
城市选择器,方便输入城市,可以理解为自动配置了国内城市选项的 Select,支持到县级别。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"searchable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
观察数据域中表单项的值,存储的是位置邮编。
|
||||
|
||||
## 配置选择级别
|
||||
|
||||
可以通过设置 `allowDistrict` 和 `allowCity` 设置用户选择级别,例如只选择省份:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"allowDistrict": false,
|
||||
"allowCity": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 获取更多选项信息
|
||||
|
||||
表单项值默认格式是编码(即 `code`),如果你想要详细点的信息,可以把 `extractValue` 设置成 `false`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"extractValue": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配置下拉框样式
|
||||
|
||||
可以通过 `itemClassName` 指定下拉框样式,如配置最小宽度
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"itemClassName": "min-w-xs",
|
||||
"searchable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------- | --------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| allowCity | `boolean` | `true` | 允许选择城市 |
|
||||
| allowDistrict | `boolean` | `true` | 允许选择区域 |
|
||||
| searchable | `boolean` | `false` | 是否出搜索框 |
|
||||
| extractValue | `boolean` | `true` | 默认 `true` 是否抽取值,如果设置成 `false` 值格式会变成对象,包含 `code`、`province`、`city` 和 `district` 文字信息。 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ----------------------------------- | ---------------- |
|
||||
| change | `[name]: number \| string` 组件的值 | 选中值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string \| number` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"id": "clear_text",
|
||||
"value": "110000"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"id": "reset_text",
|
||||
"value": "110000"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "city",
|
||||
"type": "input-city",
|
||||
"label": "城市",
|
||||
"id": "setvalue_text",
|
||||
"value": "110000"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "110100"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
115
docs/zh-CN/components/form/input-color.md
Executable file
115
docs/zh-CN/components/form/input-color.md
Executable file
@@ -0,0 +1,115 @@
|
||||
---
|
||||
title: InputColor 颜色选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputColor
|
||||
icon:
|
||||
order: 11
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-color",
|
||||
"name": "color",
|
||||
"label": "普通色盘"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 选择器预设颜色值
|
||||
|
||||
颜色选择器底部预设有会写可选的颜色值,默认为:
|
||||
|
||||
```
|
||||
['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF']
|
||||
```
|
||||
|
||||
你可以配置`presetColors`数组进行自定义。颜色支持两种格式`string` 和 `{color: string; title: string}`,并支持两种格式混合使用。`string`格式支持所有合法的 CSS 颜色码,`object`类型下的`color`属性为 CSS 颜色码,`title`属性为颜色名称,鼠标悬浮于色块时会显示对应颜色名称。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-color",
|
||||
"name": "color",
|
||||
"label": "自定义预设色盘",
|
||||
"presetColors": [
|
||||
{"color": "#d4380d", "title": "熔岩红"},
|
||||
{"color": "#ffa940", "title": "金桔橙"},
|
||||
{"color": "#ffec3d", "title": "土豪金"},
|
||||
{"color": "#73d13d", "title": "苹果绿"},
|
||||
{"color": "#73E3EC", "title": "蒂芙尼青"},
|
||||
{"color": "#2f54eb", "title": "冰川蓝"},
|
||||
{"color": "#9254de", "title": "薰衣草紫"},
|
||||
{"color": "#ffc0cb", "title": "樱花粉"},
|
||||
"rgb(212, 56, 13)", "rgba(255, 169, 64, 1.0)", "hsl(54,100%,62%)", "hsla(98, 62%, 53%, 1.0)", "#73E3EC", "#2f54eb", "#9254de", "pink"
|
||||
]
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## rgba
|
||||
|
||||
将 `format` 设置为 rgba 就能改变颜色透明度。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-color",
|
||||
"name": "color",
|
||||
"label": "带透明度调节的色盘",
|
||||
"format": "rgba"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## hexa (8 digits HEX)
|
||||
|
||||
将 `format` 设置为 hexa 支持 8位 HEX,参考 `https://drafts.csswg.org/css-color/`。
|
||||
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-color",
|
||||
"name": "color",
|
||||
"label": "带透明度调节的色盘, 8 digits HEX",
|
||||
"value": "#73E3EC88",
|
||||
"format": "hexa"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------------- | --------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
||||
| format | `string` | `hex` | 请选择 `hex`、`hexa`、`hls`、`rgb`或者`rgba`。 |
|
||||
| presetColors | `Array<string>` | [选择器预设颜色值](./input-color#%E9%80%89%E6%8B%A9%E5%99%A8%E9%A2%84%E8%AE%BE%E9%A2%9C%E8%89%B2%E5%80%BC) | 选择器底部的默认颜色,数组内为空则不显示默认颜色 |
|
||||
| allowCustomColor | `boolean` | `true` | 为`false`时只能选择颜色,使用 `presetColors` 设定颜色选择范围 |
|
||||
| clearable | `boolean` | `"label"` | 是否显示清除按钮 |
|
||||
| resetValue | `string` | `""` | 清除后,表单项值调整成该值 |
|
||||
477
docs/zh-CN/components/form/input-date-range.md
Executable file
477
docs/zh-CN/components/form/input-date-range.md
Executable file
@@ -0,0 +1,477 @@
|
||||
---
|
||||
title: InputDateRange 日期范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputDateRange
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "select",
|
||||
"label": "日期范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 默认值
|
||||
|
||||
通过 value 设置默认值,除了实际值,比如
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期范围",
|
||||
"value": "1659283200,1661961599"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
还可以是相对值,比如最近一周内
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期范围",
|
||||
"value": "today,+1weeks"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
支持的相对值关键字有:
|
||||
|
||||
- today: 当前日期
|
||||
- day 或 days: 天
|
||||
- week 或 weeks: 周
|
||||
- month 或 months: 月
|
||||
- year 或 years: 年
|
||||
|
||||
或者用公式来配置复杂情况, 比如本周一到周日
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期范围",
|
||||
"value": "${DATETOSTR(DATEMODIFY(STARTOF(NOW(), 'week'), 1, 'day'), 'X') + ',' + DATETOSTR(DATEMODIFY(ENDOF(NOW(), 'week'), '1', 'day'), 'X')}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> 因为默认周日是第一天,所以需要往后加一天
|
||||
|
||||
再看个上月第一天到上月最后一天的例子
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期范围",
|
||||
"value": "${DATETOSTR(STARTOF(DATEMODIFY(NOW(), -1, 'month'), 'month'), 'X') + ',' + DATETOSTR(ENDOF(DATEMODIFY(NOW(), -1, 'month'), 'month'), 'X')}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 快捷键
|
||||
|
||||
`shortcuts`属性支持自定义快捷选择日期范围快捷键
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "select",
|
||||
"label": "日期范围",
|
||||
"shortcuts": [
|
||||
"7daysago",
|
||||
"15dayslater",
|
||||
"2weeksago",
|
||||
"1weekslater",
|
||||
"thismonth",
|
||||
"2monthsago",
|
||||
"3monthslater"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
支持的快捷键有
|
||||
|
||||
- `today`: 今天
|
||||
- `yesterday`: 昨天
|
||||
- `tomorrow`: 明天
|
||||
- `prevweek`: 上周
|
||||
- `thisweek`: 这个周
|
||||
- `thismonth`: 本月
|
||||
- `prevmonth`: 上个月
|
||||
- `prevquarter`: 上个季度
|
||||
- `thisquarter`: 这个季度
|
||||
- `thisyear`: 今年
|
||||
- `lastYear`: 去年
|
||||
- `{n}daysago` : 最近 n 天,例如:`7daysago`,下面用法相同
|
||||
- `{n}dayslater`: n 天以内
|
||||
- `{n}weeksago`: 最近 n 周
|
||||
- `{n}weekslater`: n 周以内
|
||||
- `{n}monthsago`: 最近 n 月
|
||||
- `{n}monthslater`: n 月以内
|
||||
- `{n}quartersago`: 最近 n 季度
|
||||
- `{n}quarterslater`: n 季度以内
|
||||
- `{n}yearsago`: 最近 n 年
|
||||
- `{n}yearslater`: n 年以内
|
||||
|
||||
快捷键也支持使用表达式的写法,可以使用这种方式自定义快捷键
|
||||
|
||||
> 3.1.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "select",
|
||||
"label": "日期范围",
|
||||
"shortcuts": [
|
||||
{
|
||||
"label": "1天前",
|
||||
"startDate": "${DATEMODIFY(NOW(), -1, 'day')}",
|
||||
"endDate": "${NOW()}"
|
||||
},
|
||||
{
|
||||
"label": "1个月前",
|
||||
"startDate": "${DATEMODIFY(NOW(), -1, 'months')}",
|
||||
"endDate": "${NOW()}"
|
||||
},
|
||||
{
|
||||
"label": "本季度",
|
||||
"startDate": "${STARTOF(NOW(), 'quarter')}",
|
||||
"endDate": "${ENDOF(NOW(), 'quarter')}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期范围",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 存成两个字段
|
||||
|
||||
默认日期范围存储一个字段,用 `delimiter` 分割,如果配置 `extraName` 则会存两个字段。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "begin",
|
||||
"extraName": "end",
|
||||
"label": "日期范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 数据处理函数
|
||||
|
||||
> `3.5.0`及以上版本
|
||||
|
||||
默认情况下,日期范围选择器组件的绑定值的开始时间为所选时间当天的 0 点(使用`moment().startOf('day')`处理),结束时间为所选时间当天的 23 时 59 分 59 秒 999 毫秒(使用`moment().endOf('day')`处理)。如果设置了`timeFormat`(时间格式),则会基于`timeFormat`配置决定**最小时间单位**,举例:
|
||||
|
||||
- 不设置`timeFormat`(时间格式),默认按照天(day)级处理:
|
||||
|
||||
```typescript
|
||||
moment().startOf('day'); // 2008-08-08 00:00:00.000
|
||||
moment().endOf('day'); // 2008-08-08 23:59:59.999
|
||||
```
|
||||
|
||||
- `timeFormat`(时间格式)为 `"HH:mm:ss"`,则会按照秒(second)级处理:
|
||||
|
||||
```typescript
|
||||
moment().startOf('second'); // 2008-08-08 08:08:08.000
|
||||
moment().endOf('second'); // 2008-08-08 08:08:08.999
|
||||
```
|
||||
|
||||
- `timeFormat`(时间格式)为 `"HH:mm"`,则会按照分钟(minute)级处理:
|
||||
|
||||
```typescript
|
||||
moment().startOf('minute'); // 2008-08-08 08:08:00.000
|
||||
moment().endOf('minute'); // 2008-08-08 08:08:59.999
|
||||
```
|
||||
|
||||
- `timeFormat`(时间格式)为 `"HH"`,则会按照小时(hour)级处理:
|
||||
|
||||
```typescript
|
||||
moment().startOf('hour'); // 2008-08-08 08:00:00.000
|
||||
moment().endOf('hour'); // 2008-08-08 08:59:59.999
|
||||
```
|
||||
|
||||
部分情况下,即使配置`timeFormat`也无法满足需求,此时可以使用`transform`函数对时间值做进一步处理, 函数签名如下:
|
||||
|
||||
```typescript
|
||||
interface TransFormFunc {
|
||||
(
|
||||
/* 当前值,Moment对象 */
|
||||
value: moment.Moment,
|
||||
config: {
|
||||
/* 操作类型,start:起始时间;end:结束时间 */
|
||||
type: 'start' | 'end';
|
||||
/* 初始值,最近一次选择的时间值 */
|
||||
originValue: moment.Moment;
|
||||
/* 时间格式 */
|
||||
timeFormat: string;
|
||||
},
|
||||
/* 当前组件的属性 */
|
||||
props: any,
|
||||
/* 当前组件数据域 */
|
||||
data: any,
|
||||
/* moment函数 */
|
||||
moment: moment
|
||||
): moment.Moment;
|
||||
}
|
||||
```
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "range1",
|
||||
"label": "日期范围(默认)",
|
||||
"valueFormat": "YYYY-MM-DDTHH:mm:ss[Z]"
|
||||
},
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "range2",
|
||||
"label": "日期范围(使用transform函数)",
|
||||
"valueFormat": "YYYY-MM-DDTHH:mm:ss[Z]",
|
||||
"transform": "const now = moment(); if (config.type === 'end') {value.set({hours: now.hours(), minutes: now.minutes(), seconds: now.seconds(), milliseconds: now.milliseconds()})}; return value;"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上面的示例使用 `transform` 函数,将结束时间的值设置为当前时间
|
||||
|
||||
```typescript
|
||||
function transform(value, config, props, data) {
|
||||
const now = moment();
|
||||
|
||||
if (config.type === 'end') {
|
||||
value.set({
|
||||
hours: now.hours(),
|
||||
minutes: now.minutes(),
|
||||
seconds: now.seconds(),
|
||||
milliseconds: now.milliseconds()
|
||||
});
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------- | ----------------------- |
|
||||
| valueFormat | `string` | `X` | [日期选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 |
|
||||
| displayFormat | `string` | `YYYY-MM-DD` | [日期选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 |
|
||||
| placeholder | `string` | `"请选择日期范围"` | 占位文本 |
|
||||
| shortcuts | `string \| string[] \| Array<{label: string; startDate: string; endDate: string}>` | `"yesterday,7daysago,prevweek,thismonth,prevmonth,prevquarter"` | 日期范围快捷键 | `3.1.0`版本后支持表达式 |
|
||||
| minDate | `string` | | 限制最小日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| minDuration | `string` | | 限制最小跨度,如: 2days |
|
||||
| maxDuration | `string` | | 限制最大跨度,如:1year |
|
||||
| utc | `boolean` | `false` | [保存 UTC 值](./date#utc) |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| embed | `boolean` | `false` | 是否内联模式 |
|
||||
| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` |
|
||||
| extraName | `string` | | 是否存成两个字段 | `3.3.0` |
|
||||
| transform | `string` | | 日期数据处理函数,用来处理选择日期之后的的值,返回值为 `Moment`对象 | `3.5.0` |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | ----------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,,依赖格式`format`,例如:'1650556800,1652889599' |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"id": "clear_text",
|
||||
"value": "1714060800,1714319999"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"id": "reset_text",
|
||||
"value": "1714060800,1714319999"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date-range",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"id": "setvalue_text",
|
||||
"value": "1714060800,1714319999"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "1714060800,1714492799"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
552
docs/zh-CN/components/form/input-date.md
Executable file
552
docs/zh-CN/components/form/input-date.md
Executable file
@@ -0,0 +1,552 @@
|
||||
---
|
||||
title: InputDate 日期
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Date
|
||||
icon:
|
||||
order: 13
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示格式
|
||||
|
||||
选中任意日期,可以看到默认显示日期的格式是像`2020-04-14`这样的格式,如果你想要自定义显示格式,那么可以配置`inputFormat`。
|
||||
|
||||
例如你想显示`2020年04月14日`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY年MM月DD日`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"inputFormat": "YYYY年MM月DD日"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
选中任意日期,观察显示格式
|
||||
|
||||
## 值格式
|
||||
|
||||
选中任意日期,可以看到默认表单项的值格式是像`1591862818`这样的时间戳格式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
|
||||
|
||||
例如你调整值为`2020-04-14`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY-MM-DD`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"format": "YYYY-MM-DD"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
选中任意日期,观察数据域中表单项值的变化
|
||||
|
||||
## 默认值
|
||||
|
||||
可以设置`value`属性,设置日期选择器的默认值
|
||||
|
||||
### 基本配置
|
||||
|
||||
配置符合当前 [值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) 的默认值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"value": "1591862818"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 相对值
|
||||
|
||||
`value` 还支持类似像`"+1days"`这样的相对值,更加便捷的配置默认值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"value": "+1days"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中配置了`"value": "+1days"`,默认就会选中明天。
|
||||
|
||||
支持的相对值关键字有:
|
||||
|
||||
- `today`: 当前日期
|
||||
- `day`或`days`: 天
|
||||
- `week`或`weeks`: 周
|
||||
- `month`或`months`: 月
|
||||
- `year`或`years`: 年
|
||||
|
||||
### 通过公式配置默认值
|
||||
|
||||
> 1.7.0 及以上版本
|
||||
|
||||
可以通过日期公式来动态计算。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"value": "${DATEMODIFY(NOW(), 2, 'days')}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 限制范围
|
||||
|
||||
可以通过配置`maxDate`和`minDate`显示可选范围
|
||||
|
||||
### 固定时间值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "1591862818",
|
||||
"description": "限制可选最小日期是 <code>2020-06-11 16:06:58</code>"
|
||||
},
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "end",
|
||||
"label": "结束时间",
|
||||
"maxDate": "1591862818",
|
||||
"description": "限制可选最大日期是 <code>2020-06-11 16:06:58</code>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 支持相对值
|
||||
|
||||
范围限制也支持设置 [相对值](./input-date#%E7%9B%B8%E5%AF%B9%E5%80%BC)。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "-1days",
|
||||
"description": "限制可选最小日期是昨天"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 支持模板
|
||||
|
||||
也支持通过[模板](./template),设置自定义值。
|
||||
|
||||
来一个常见例子,配置两个选择`开始时间`和`结束时间`的时间选择器,需要满足:`开始时间`不能大于`结束时间`,`结束时间`也不能小于`开始时间`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "start",
|
||||
"label": "开始日期",
|
||||
"maxDate": "$end"
|
||||
},
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "end",
|
||||
"label": "结束日期",
|
||||
"minDate": "$start"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 通过 js 来控制
|
||||
|
||||
> 3.3.0 及以上版本
|
||||
|
||||
可以通过 `disabledDate` 字符函数来控制,比如不允许选择周一、周六、周日
|
||||
|
||||
函数签名: `(currentDate: moment.Moment, props: any) => boolean`
|
||||
示例: `"return currentDate.day() == 1 || currentDate.day() == 0 || currentDate.day() == 6"`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"description": "限制不能选周一、周六、周日",
|
||||
"disabledDate": "return currentDate.day() == 1 || currentDate.day() == 0 || currentDate.day() == 6"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 快捷键
|
||||
|
||||
你也可以配置`shortcuts`属性支持快捷选择日期
|
||||
|
||||
> 注:移动端 picker 的形式不支持快捷键
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"shortcuts": ["yesterday", "today", "tomorrow"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中我们配置了`"shortcuts": ["yesterday" ,"today", "tomorrow"]`,选择器顶部有将会显示快捷键`昨天`,`今天`和`明天`
|
||||
|
||||
支持的快捷键有
|
||||
|
||||
- `today`: 今天
|
||||
- `yesterday`: 昨天
|
||||
- `thisweek`: 本周一
|
||||
- `thismonth`: 本月初
|
||||
- `prevmonth`: 上个月初
|
||||
- `prevquarter`: 上个季节初
|
||||
- `thisquarter`: 本季度初
|
||||
- `tomorrow`: 明天
|
||||
- `endofthisweek`: 本周日
|
||||
- `endofthismonth`:本月底
|
||||
- `endoflastmonth`:上月底
|
||||
- `{n}daysago` : n 天前,例如:`2daysago`,下面用法相同
|
||||
- `{n}dayslater`: n 天后
|
||||
- `{n}weeksago`: n 周前
|
||||
- `{n}weekslater`: n 周后
|
||||
- `{n}monthsago`: n 月前
|
||||
- `{n}monthslater`: n 月后
|
||||
- `{n}quartersago`: n 季度前
|
||||
- `{n}quarterslater`: n 季度后
|
||||
|
||||
快捷键也支持使用表达式的写法,可以使用这种方式自定义快捷键
|
||||
|
||||
> 3.1.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"shortcuts": [
|
||||
{
|
||||
"label": "前天",
|
||||
"date": "${STARTOF(DATEMODIFY(NOW(), -2, 'day'))}"
|
||||
},
|
||||
"yesterday",
|
||||
"today"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## UTC
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "普通日期",
|
||||
"format": "YYYY-MM-DD"
|
||||
},
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date-utc",
|
||||
"label": "UTC日期",
|
||||
"utc": true,
|
||||
"format": "YYYY-MM-DD"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "static-date",
|
||||
"name": "date",
|
||||
"label": "当前值"
|
||||
},
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 原生日期组件
|
||||
|
||||
原生数字日期将直接使用浏览器的实现,最终展现效果和浏览器有关,而且只支持 `min`、`max`、`step` 这几个属性设置。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "native-date",
|
||||
"name": "date",
|
||||
"label": "日期"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | -------------------------------------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------- |
|
||||
| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) |
|
||||
| valueFormat | `string` | `X` | 日期选择器值格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 |
|
||||
| displayFormat | `string` | `YYYY-MM-DD` | 日期选择器显示格式,即时间戳格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 |
|
||||
| closeOnSelect | `boolean` | `false` | 点选日期后,是否马上关闭选择框 |
|
||||
| placeholder | `string` | `"请选择日期"` | 占位文本 |
|
||||
| shortcuts | `string \| string[] \| Array<{"label": string; date: string}>` | | 日期快捷键,字符串格式为预设值,对象格式支持写表达式 | `3.1.0`版本后支持表达式 |
|
||||
| minDate | `string` | | 限制最小日期 |
|
||||
| maxDate | `string` | | 限制最大日期 |
|
||||
| utc | `boolean` | `false` | 保存 utc 值 |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| embed | `boolean` | `false` | 是否内联模式 |
|
||||
| disabledDate | `string` | | 用字符函数来控制哪些天不可以被点选 |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"id": "clear_text",
|
||||
"value": "1714060800"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"id": "reset_text",
|
||||
"value": "1714060800"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-date",
|
||||
"name": "date",
|
||||
"label": "日期",
|
||||
"id": "setvalue_text",
|
||||
"value": "1714060800"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "1714233600"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
163
docs/zh-CN/components/form/input-datetime-range.md
Executable file
163
docs/zh-CN/components/form/input-datetime-range.md
Executable file
@@ -0,0 +1,163 @@
|
||||
---
|
||||
title: InputDatetimeRange 日期时间范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputDatetimeRange
|
||||
icon:
|
||||
order: 16
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime-range",
|
||||
"name": "select",
|
||||
"label": "日期时间范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 时间显示到秒
|
||||
|
||||
通过 `"timeFormat": "HH:mm:ss"` 设置时间输入框显示秒
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime-range",
|
||||
"name": "select",
|
||||
"timeFormat": "HH:mm:ss",
|
||||
"label": "日期时间范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 快捷键
|
||||
|
||||
`shortcuts`属性支持自定义日期时间范围快捷键
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime-range",
|
||||
"name": "select",
|
||||
"label": "日期范围",
|
||||
"shortcuts": "today,yesterday,1dayago,7daysago"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
快捷键也支持使用表达式的写法,可以使用这种方式自定义快捷键
|
||||
|
||||
> 3.1.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime-range",
|
||||
"name": "select",
|
||||
"label": "日期范围",
|
||||
"inputFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"timeFormat": "HH:mm:ss",
|
||||
"format": "x",
|
||||
"shortcuts": [
|
||||
{
|
||||
"label": "1天前",
|
||||
"startDate": "${DATEMODIFY(NOW(), -1, 'day')}",
|
||||
"endDate": "${NOW()}"
|
||||
},
|
||||
{
|
||||
"label": "1个月前",
|
||||
"startDate": "${DATEMODIFY(NOW(), -1, 'months')}",
|
||||
"endDate": "${NOW()}"
|
||||
},
|
||||
{
|
||||
"label": "本季度",
|
||||
"startDate": "${STARTOF(NOW(), 'quarter')}",
|
||||
"endDate": "${ENDOF(NOW(), 'quarter')}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 存成两个字段
|
||||
|
||||
默认日期范围存储一个字段,用 `delimiter` 分割,如果配置 `extraName` 则会存两个字段。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime-range",
|
||||
"name": "begin",
|
||||
"extraName": "end",
|
||||
"label": "日期范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | ---------------------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | ----------------------- |
|
||||
| valueFormat | `string` | `X` | [日期时间选择器值格式](./input-datetime#%E5%80%BC%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 |
|
||||
| displayFormat | `string` | `YYYY-MM-DD` | [日期时间选择器显示格式](./input-datetime#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | 3.4.0 版本后支持 |
|
||||
| placeholder | `string` | `"请选择日期范围"` | 占位文本 |
|
||||
| shortcuts | `string \| string[] \| Array<{label: string; startDate: string; endDate: string}>` | `"yesterday,7daysago,prevweek,thismonth,prevmonth,prevquarter"` | 日期范围快捷键,详情参考[快捷键](./input-date-range#快捷键) | `3.1.0`版本后支持表达式 |
|
||||
| minDate | `string` | | 限制最小日期时间,用法同 [限制范围](./input-datetime#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| maxDate | `string` | | 限制最大日期时间,用法同 [限制范围](./input-datetime#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| utc | `boolean` | `false` | [保存 UTC 值](./input-datetime#utc) |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` |
|
||||
| extraName | `string` | | 是否存成两个字段 | `3.3.0` |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | -------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1650556800,1652889599' |
|
||||
451
docs/zh-CN/components/form/input-datetime.md
Executable file
451
docs/zh-CN/components/form/input-datetime.md
Executable file
@@ -0,0 +1,451 @@
|
||||
---
|
||||
title: InputDatetime 日期时间
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputDatetime
|
||||
icon:
|
||||
order: 14
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示格式
|
||||
|
||||
选中任意日期时间,可以看到默认显示日期的格式是像`2020-04-14 12:20:10`这样的格式,如果你想要自定义显示格式,那么可以配置`inputFormat`。
|
||||
|
||||
例如你想显示`2020年04月14日 12时20分10秒`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY年MM月DD日 HH时mm分ss秒`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"inputFormat": "YYYY年MM月DD日 HH时mm分ss秒"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
选中任意日期时间,观察显示格式
|
||||
|
||||
## 值格式
|
||||
|
||||
选中任意日期时间,可以看到默认表单项的值格式是像`1591862818`这样的时间戳格式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果你想要其他格式的日期值,那么可以配置`format`参数用于调整表单项的值格式。
|
||||
|
||||
例如你调整值为`2020-04-14 12:20:10`这样的格式,查找 [moment 文档](https://momentjs.com/docs/#/displaying/format/) 可知配置格式应为 `YYYY-MM-DD HH:mm:ss`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"format": "YYYY-MM-DD HH:mm:ss"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
选中任意日期时间,观察数据域中表单项值的变化
|
||||
|
||||
## 默认值
|
||||
|
||||
可以设置`value`属性,设置日期选择器的默认值
|
||||
|
||||
### 基本配置
|
||||
|
||||
配置符合当前 [值格式](./datetime#%E5%80%BC%E6%A0%BC%E5%BC%8F) 的默认值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"value": "1591862818"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 相对值
|
||||
|
||||
`value` 还支持类似像`"+1hours"`这样的相对值,更加便捷的配置默认值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期",
|
||||
"value": "+1hours"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中配置了`"value": "+1hours"`,默认就会选中一小时后的时间。
|
||||
|
||||
支持的相对值关键字除了 [Date](./input-date#%E7%9B%B8%E5%AF%B9%E5%80%BC) 中的以外,还支持:
|
||||
|
||||
- `now`: 当前时间
|
||||
- `minute`或`minutes`或`min`或`mins`: 分钟
|
||||
- `hour`或`hours`: 小时
|
||||
|
||||
## 限制范围
|
||||
|
||||
### 控制时间范围
|
||||
|
||||
通过 `timeConstraints` 属性可以控制时间输入范围
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"timeConstraints": {
|
||||
"hours": {
|
||||
"min": 12,
|
||||
"max": 18
|
||||
},
|
||||
"minutes": {
|
||||
"step": 15
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
可以通过配置`maxDate`和`minDate`显示可选范围
|
||||
|
||||
### 固定时间值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "1591862818",
|
||||
"description": "限制可选最小日期是 <code>2020-06-11 16:06:58</code>"
|
||||
},
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "end",
|
||||
"label": "结束时间",
|
||||
"maxDate": "1591862818",
|
||||
"description": "限制可选最大日期是 <code>2020-06-11 16:06:58</code>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 支持相对值
|
||||
|
||||
范围限制也支持设置 [相对值](./input-date#%E7%9B%B8%E5%AF%B9%E5%80%BC)。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"minDate": "-1days",
|
||||
"description": "限制可选最小日期是昨天"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 支持模板
|
||||
|
||||
也支持通过[模板](./template),设置自定义值。
|
||||
|
||||
来一个常见例子,配置两个选择`开始时间`和`结束时间`的时间选择器,需要满足:`开始时间`不能小于`结束时间`,`结束时间`也不能大于`开始时间`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"maxDate": "$end"
|
||||
},
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "end",
|
||||
"label": "结束时间",
|
||||
"minDate": "$start"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 通过 js 来控制
|
||||
|
||||
> 3.3.0 及以上版本
|
||||
|
||||
可以通过 `disabledDate` 字符函数来控制,比如不允许选择周一、周六、周日
|
||||
|
||||
函数签名: `(currentDate: moment.Moment, props: any) => boolean`
|
||||
示例: `"return currentDate.day() == 1 || currentDate.day() == 0 || currentDate.day() == 6"`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "start",
|
||||
"label": "开始时间",
|
||||
"description": "限制不能选周一、周六、周日",
|
||||
"disabledDate": "return currentDate.day() == 1 || currentDate.day() == 0 || currentDate.day() == 6"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 快捷键
|
||||
|
||||
你也可以配置`shortcuts`属性支持快捷选择日期
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期",
|
||||
"shortcuts": ["yesterday" ,"today", "tomorrow"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中我们配置了`"shortcuts": ["yesterday" ,"today", "tomorrow"]`,选择器顶部有将会显示快捷键`昨天`,`今天`和`明天`
|
||||
|
||||
除了支持 的快捷键有
|
||||
|
||||
支持的快捷键除了 [Date](./date#%E5%BF%AB%E6%8D%B7%E9%94%AE) 中的以外,还支持:
|
||||
|
||||
- `now`: 现在
|
||||
- `{n}hoursago` : n 小时前,例如:`2hoursago`,下面用法相同
|
||||
- `{n}hourslater` : n 小时后,例如:`2hourslater`,下面用法相同
|
||||
|
||||
快捷键也支持使用表达式的写法,可以使用这种方式自定义快捷键
|
||||
|
||||
> 3.1.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期",
|
||||
"shortcuts": [
|
||||
{
|
||||
"label": "前天",
|
||||
"date": "${STARTOF(DATEMODIFY(NOW(), -2, 'day'))}"
|
||||
},
|
||||
"yesterday",
|
||||
"today"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## UTC
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "普通日期时间",
|
||||
"format": "YYYY-MM-DD HH:mm:ss"
|
||||
},
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime-utc",
|
||||
"label": "UTC日期时间",
|
||||
"utc": true,
|
||||
"format": "YYYY-MM-DD HH:mm:ss"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "static-date",
|
||||
"name": "date",
|
||||
"format": "LLL",
|
||||
"label": "当前值"
|
||||
},
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "date",
|
||||
"label": "日期时间",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 确认模式
|
||||
|
||||
> `3.6.0`及以上版本
|
||||
|
||||
设置`"closeOnSelect": false`,点选日期时间后,不会自动关闭浮层,需要点击底部工具栏的确认才会关闭。点击**取消按钮**或者**浮层外部区域**也会关闭浮层,并将值重置为初始状态。
|
||||
|
||||
> 注意:该特性仅对`input-datetime`有效,其他日期时间组件无效。开启内嵌模式后,该特性无效。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-datetime",
|
||||
"name": "datetime",
|
||||
"label": "日期时间",
|
||||
"shortcuts": ["yesterday", "today", "tomorrow"],
|
||||
"closeOnSelect": false,
|
||||
"valueFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"displayFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"clearable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | -------------------------------------------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------- |
|
||||
| value | `string` | | [默认值](./datetime#%E9%BB%98%E8%AE%A4%E5%80%BC) |
|
||||
| valueFormat | `string` | `X` | 日期时间选择器值格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 |
|
||||
| displayFormat | `string` | `YYYY-MM-DD HH:mm:ss` | 日期时间选择器显示格式,即时间戳格式,更多格式类型请参考 [文档](https://momentjs.com/docs/#/displaying/format/) | 3.4.0 版本后支持 |
|
||||
| placeholder | `string` | `"请选择日期以及时间"` | 占位文本 |
|
||||
| shortcuts | `string \| string[] \| Array<{"label": string; date: string}>` | | 日期时间快捷键 | `3.1.0`版本后支持表达式 |
|
||||
| minDate | `string` | | 限制最小日期时间 |
|
||||
| maxDate | `string` | | 限制最大日期时间 |
|
||||
| utc | `boolean` | `false` | 保存 utc 值 |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| embed | `boolean` | `false` | 是否内联 |
|
||||
| timeConstraints | `object` | `true` | 请参考 [input-time](./input-time#控制输入范围) 里的说明 |
|
||||
| isEndDate | `boolean` | `false` | 如果配置为 true,会自动默认为 23:59:59 秒 |
|
||||
| disabledDate | `string` | | 用字符函数来控制哪些天不可以被点选 |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0`版本后支持 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1650556800' |
|
||||
438
docs/zh-CN/components/form/input-excel.md
Normal file
438
docs/zh-CN/components/form/input-excel.md
Normal file
@@ -0,0 +1,438 @@
|
||||
---
|
||||
title: InputExcel 解析 Excel
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputExcel
|
||||
icon:
|
||||
order: 14
|
||||
---
|
||||
|
||||
这个组件是通过前端对 Excel 进行解析,将结果作为表单项,使用它有两个好处:
|
||||
|
||||
1. 节省后端开发成本,无需再次解析 Excel
|
||||
2. 可以前端实时预览效果,比如配合 input-table 组件进行二次修改
|
||||
|
||||
> 2.10.0 以上版本支持 xls 文件格式,2.9.0 及以下版本只支持 xlsx
|
||||
|
||||
## 基本使用
|
||||
|
||||
默认情况下只解析第一个 sheet 的内容,下面的例子中,选择上传文件后,就能知道最终会解析成什么数据
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"label": "上传 Excel"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
默认模式是解析成对象数组,将第一行作为对象里的键,可以上传一个类似这样的 Excel 内容试试
|
||||
|
||||
```
|
||||
|名称|网址|
|
||||
|amis|https://baidu.gitee.io/amis|
|
||||
|百度|https://www.baidu.com|
|
||||
```
|
||||
|
||||
解析后的的数据格式将会是
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"名称": "amis",
|
||||
"网址": "https://baidu.gitee.io/amis"
|
||||
},
|
||||
{
|
||||
"名称": "百度",
|
||||
"网址": "https://www.baidu.com"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
可以配合 `input-table` 来实现上传后二次编辑
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"label": "上传 Excel",
|
||||
"placeholder": "请拖拽Excel文件到当前区域"
|
||||
},
|
||||
{
|
||||
"type": "input-table",
|
||||
"name": "excel",
|
||||
"visibleOn": "data.excel",
|
||||
"columns": [
|
||||
{
|
||||
"name": "名称",
|
||||
"label": "名称",
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "网址",
|
||||
"label": "网址",
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
需要保证 `input-table` 的 `name` 和 `input-excel` 一致,同时 `columns` 中的 `name` 也需要和 Excel 的列名一致。
|
||||
|
||||
## 二维数组模式
|
||||
|
||||
除了默认配置的对象数组格式,还可以使用二维数组方式,方法是设置 `"parseMode": "array"`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"parseMode": "array",
|
||||
"label": "上传 Excel"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果是前面的例子,解析结果将会是
|
||||
|
||||
```json
|
||||
[
|
||||
["名称", "网址"],
|
||||
["amis", "https://baidu.gitee.io/amis"],
|
||||
["百度", "https://www.baidu.com"]
|
||||
]
|
||||
```
|
||||
|
||||
## 解析多个 sheet
|
||||
|
||||
默认配置只解析第一个 sheet,如果要解析多个 sheet,可以通过 `"allSheets": true` 开启多个 sheet 的读取,这时的数据会增加一个层级。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"allSheets": true,
|
||||
"label": "上传 Excel"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果按之前的例子,结果将会是
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"sheetName": "Sheet1",
|
||||
"data": [
|
||||
{
|
||||
"名称": "amis",
|
||||
"网址": "https://baidu.gitee.io/amis"
|
||||
},
|
||||
{
|
||||
"名称": "百度",
|
||||
"网址": "https://www.baidu.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
## 解析多个文件
|
||||
可以配置"multiple": true,来开启多文件解析功能,通过"maxLength": 5,来限制最多上传5个文件。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"allSheets": true,
|
||||
"label": "上传 Excel",
|
||||
"multiple": true,
|
||||
"maxLength": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 解析图片
|
||||
|
||||
> 2.6.0 及以上版本
|
||||
|
||||
通过配置 `parseImage` 来支持解析 excel 里的图片
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"parseImage": true,
|
||||
"label": "上传 Excel"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
默认情况下解析结果是 data URI 格式,如果不想要这个前缀可以通过 `"imageDataURI": false` 关闭
|
||||
|
||||
## 富文本模式
|
||||
|
||||
默认情况下 Excel 内容将会解析为纯文本,如果要使用富文本格式,可以通过 `plainText` 属性控制
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"plainText": false,
|
||||
"label": "上传 Excel"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
开启这个模式后,对于富文本的内容会解析成对象的形式,有以下几种
|
||||
|
||||
- 富文本,内容放在 richText 属性下
|
||||
|
||||
```
|
||||
{
|
||||
"richText": [
|
||||
{text: 'This is '},
|
||||
{font: {italic: true}, text: 'italic'}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- 出错
|
||||
|
||||
```
|
||||
{ error: '#N/A' }
|
||||
```
|
||||
|
||||
- 公式
|
||||
|
||||
```
|
||||
{ formula: 'A1+A2', result: 7 };
|
||||
```
|
||||
|
||||
- 超链接
|
||||
|
||||
```
|
||||
{
|
||||
text: 'www.mylink.com',
|
||||
hyperlink: 'http://www.mylink.com',
|
||||
tooltip: 'www.mylink.com'
|
||||
}
|
||||
```
|
||||
|
||||
## 解析文件名称
|
||||
|
||||
> `3.5.0`及以上版本
|
||||
|
||||
文件解析成功后,可以使用`autoFill`属性,在当前组件所在的数据域中填充值,`input-excel`组件特有的保留字段请查看下方定义,`InputExcelData`中的字段可以用变量获取。通常可以利用这个属性为`input-excel`所在的表单追加文件名称。
|
||||
|
||||
```typescript
|
||||
interface InputExcelData {
|
||||
/* 文件名称 */
|
||||
filename: string;
|
||||
}
|
||||
```
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"label": "上传 Excel",
|
||||
"autoFill": {
|
||||
"operator": "amis",
|
||||
"time": "${DATETOSTR(NOW(), 'YYYY-MM-DD HH:mm:ss')}",
|
||||
"fileName": "${filename}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
|--------------|--------------------------|-----------------------|--------------|----------|
|
||||
| allSheets | `boolean` | false | 是否解析所有 sheet |
|
||||
| parseMode | `'array'` 或 `'object'` | 'object' | 解析模式 |
|
||||
| includeEmpty | `boolean` | true | 是否包含空值 |
|
||||
| plainText | `boolean` | true | 是否解析为纯文本 |
|
||||
| placeholder | `string` | `"拖拽 Excel 到这,或点击上传"` | 占位文本提示 | `2.8.1` |
|
||||
| autoFill | `Record<string, string>` | | 自动填充 | `3.5.0` |
|
||||
| multiple | `boolean` | | 解析多个文件 | `6.13.0` |
|
||||
| maxLength | `number` | | 解析文件最大数 | `6.13.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------------------------------ | ------------------------ |
|
||||
| change | `[name]: Array<object>` 组件的值(excel 解析后的数据) | excel 上传解析完成后触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: Array<object>` 更新的 excel 解析后数据 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"label": "上传 Excel",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"label": "上传 Excel",
|
||||
"id": "reset_text",
|
||||
"value": [
|
||||
{
|
||||
"ID": "1",
|
||||
"NAME": "amis"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-excel",
|
||||
"name": "excel",
|
||||
"label": "上传 Excel",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": [
|
||||
{
|
||||
"ID": "1",
|
||||
"NAME": "amis"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
538
docs/zh-CN/components/form/input-file.md
Executable file
538
docs/zh-CN/components/form/input-file.md
Executable file
@@ -0,0 +1,538 @@
|
||||
---
|
||||
title: InputFile 文件上传
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputFile
|
||||
icon:
|
||||
order: 21
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
用来负责文件上传,文件上传成功后会返回文件地址,这个文件地址会作为这个表单项的值,整个表单提交的时候,其实提交的是文件地址,文件上传已经在这个控件中完成了。
|
||||
|
||||
> 如果希望文件内容伴随表单一起提交,可以配置 `asBlob` 或者 `asBase64`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
"receiver": "/api/upload/file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 接口说明
|
||||
|
||||
这是单文件上传模式,通过配置 `receiver` 来接管文件上传。
|
||||
|
||||
接口发送方式是 POST, 数据体为 form-data 格式。对应的文件字段名为 `file`。这个可以通过 `fileField` 来配置。要求返回的数据格式如下。
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"value": "xxxx"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- value:必须返回该字段用作回显,一般是文件资源地址
|
||||
|
||||
> 注意这只是单文件上传部分,如果允许上传的文件比较大,建议用分块上传,请阅读下面的分块上传部分。
|
||||
|
||||
## 限制文件类型
|
||||
|
||||
可以配置`accept`来限制可选择的文件类型,格式是文件后缀名`.xxx`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "限制只能上传csv文件",
|
||||
"accept": ".csv",
|
||||
"receiver": "/api/upload/file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
想要限制多个类型,则用逗号分隔,例如:`.csv,.md`
|
||||
|
||||
## 限制文件大小
|
||||
|
||||
可以配置`maxSize`来限制文件大小
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "不能上传超过 1M 的文件",
|
||||
"maxSize": 1048576,
|
||||
"receiver": "/api/upload/file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 手动上传
|
||||
|
||||
默认`"autoUpload": true`,即添加文件后自动上传。可以设置`"autoUpload": false`关闭自动上传,此时通过点击上传按钮上传。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"data": {
|
||||
"file": {
|
||||
"id":"2ba48d02d348",
|
||||
"value":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"url":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"filename":"file(single).md",
|
||||
"name":"file(single).md",
|
||||
"state":"uploaded"
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"id":"2ba48d02d349",
|
||||
"value":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"url":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"filename":"file1.md",
|
||||
"name":"file1.md",
|
||||
"state":"uploaded"
|
||||
},
|
||||
{
|
||||
"id":"14723e0bc640",
|
||||
"value":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"url":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"filename":"file2.md",
|
||||
"name":"file2.md",
|
||||
"state":"uploaded"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "files",
|
||||
"label": "File(多选)",
|
||||
"mode": "horizontal",
|
||||
"labelAlign": "left",
|
||||
"accept": "*",
|
||||
"receiver": "/api/upload/file",
|
||||
"multiple": true,
|
||||
"autoUpload": false,
|
||||
"joinValues": false,
|
||||
"onEvent": {
|
||||
"success": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "「${event.data.path}」上传成功"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File(单选)",
|
||||
"mode": "horizontal",
|
||||
"labelAlign": "left",
|
||||
"accept": "*",
|
||||
"receiver": "/api/upload/file",
|
||||
"multiple": false,
|
||||
"autoUpload": false,
|
||||
"joinValues": false,
|
||||
"onEvent": {
|
||||
"success": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "「${event.data.path}」上传成功"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 作为表单项上传
|
||||
|
||||
如果不希望 InputFile 组件在提交 Form 之前上传,可以配置 `asBlob` 或者 `asBase64`,采用这种方式后,组件不再自己上传了,而是直接把文件数据作为表单项的值,文件内容会在 Form 表单提交的接口里面一起带上。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
"asBlob": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中,选择任意文件,然后观察数据域变化;点击提交,amis 自动会调整接口数据格式为`FormData`
|
||||
|
||||
## 分块上传
|
||||
|
||||
如果文件过大,则可能需要使用分块上传,默认大于 5M(chunkSize 配置决定) 的文件是会自动开启,可以通过 `useChunk` 配置成 false 关闭。
|
||||
|
||||
分块上传需要配置三个接口来完成分别是:
|
||||
|
||||
- `startChunkApi` 用来做分块前的准备工作
|
||||
- `chunkApi` 用来接收每个分块上传
|
||||
- `finishChunkApi` 用来收尾分块上传
|
||||
|
||||
还可以通过 `concurrency` 控制并行数量,默认是 3
|
||||
|
||||
### startChunkApi
|
||||
|
||||
用来做分块前的准备工作,一个文件只会调用一次。如果出错了,后续的分块上传就会中断。
|
||||
|
||||
发送说明:默认是 post,发送的数据中会包含 `filename` 字段,记录文件名,默认的数据体格式为 json。可以额外配置参数,请参考 API 的配置说明。
|
||||
|
||||
要求返回的数据中必须包含:
|
||||
|
||||
- `uploadId` 这次上传的唯一 ID。
|
||||
- `key` 有点类似 `uploadId`,可有可无,爱速搭中用来记录后端文件存储路径。
|
||||
|
||||
其他属性返回目前是没有任何作用的。
|
||||
|
||||
如:
|
||||
|
||||
```
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"key": "images/JSSDK_page-xxxx.zip",
|
||||
"uploadId": "036f64cd5dd95750d4bcb33556b629c6"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### chunkApi
|
||||
|
||||
用来接收每个分块上传,大文件会根据 chunkSize 分割成多块,然后每块上传都会调用这个接口。
|
||||
|
||||
发送说明:默认为 post,发送体格式为 form-data。包含以下信息:
|
||||
|
||||
- `uploadId` startChunkApi 返回的
|
||||
- `key` startChunkApi 返回的
|
||||
- `partNumber` 分块序号,从 1 开始。
|
||||
- `partSize` 分块大小
|
||||
- `file` 文件体
|
||||
|
||||
要求返回的数据中必须包含:
|
||||
|
||||
- `eTag` 通常为文件的内容戳。
|
||||
|
||||
如:
|
||||
|
||||
```
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"eTag": "016bd9b68ddd5cd7318875da3ea28207"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### finishChunkApi
|
||||
|
||||
等所有分块上传完后,将上传文件收集到的 `eTag` 信息合并一起,再次请求后端完成文件上传。
|
||||
|
||||
发送说明:默认为 post,数据体默认为 json,包含以下信息
|
||||
|
||||
- `filename` 文件名
|
||||
- `key` startChunkApi 返回的
|
||||
- `uploadId` startChunkApi 返回的
|
||||
- `partList` 数组,每个成员为 `{partNumber: xxx, eTag: "xxxxx"}` 即分块编号和分块 `eTag` 信息。
|
||||
|
||||
数据返回,类似单文件上传一样,必须有 `value` 属性,可选返回 `url` 用来决定文件的下载地址。如:
|
||||
|
||||
```
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"value": "https://xxxx.cdn.bcebos.com/images/JSSDK_page-xxxxx.zip"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 自动填充
|
||||
|
||||
上传成功后,可以通过配置 `autoFill` 将上传接口返回的值填充到某个表单项中(在非表单下暂不支持):
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
"receiver": "/api/upload/file",
|
||||
"autoFill": {
|
||||
"myUrl": "${url}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "myUrl",
|
||||
"label": "url"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中,file 组件上传后,接口返回格式例如如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"value": "xxxxxxx",
|
||||
"filename": "xxxx.csv",
|
||||
"url": "http://xxxx.xxx.xxx"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
然后 file 上配置:
|
||||
|
||||
```json
|
||||
"autoFill": {
|
||||
"myUrl": "${url}"
|
||||
}
|
||||
```
|
||||
|
||||
这样上传成功后,会把接口中的 `url` 变量,赋值给 `myUrl` 变量
|
||||
|
||||
**多选模式**
|
||||
|
||||
当表单项为多选模式时,不能再直接取选项中的值了,而是通过 `items` 变量来取,通过它可以获取当前选中的选项集合。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"multiple": true,
|
||||
"receiver": "/api/upload/file",
|
||||
"autoFill": {
|
||||
"myUrl": "${items|pick:url}",
|
||||
"lastUrl": "${items|last|pick:url}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 拖拽上传
|
||||
|
||||
把文件拖入指定区域,完成上传,同样支持点击上传。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
"receiver": "/api/upload/file",
|
||||
"drag": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 上传文件列表
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"data": {
|
||||
"files": [
|
||||
{
|
||||
"id":"2ba48d02d349",
|
||||
"value":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"url":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"filename":"file1.md",
|
||||
"name":"file1.md",
|
||||
"state":"uploaded"
|
||||
},
|
||||
{
|
||||
"id":"14723e0bc640",
|
||||
"value":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"url":"http://amis.bj.bcebos.com/amis/2017-11/1510713111265/fis3-react.md",
|
||||
"filename":"file2.md",
|
||||
"name":"file2.md",
|
||||
"state":"uploaded"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "files",
|
||||
"label": false,
|
||||
"mode": "horizontal",
|
||||
"accept": "*",
|
||||
"receiver": "/api/mock2/upload/random",
|
||||
"multiple": true,
|
||||
"joinValues": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------------ | ------------------------------ | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| receiver | [API](../../../docs/types/api) | | 上传文件接口 |
|
||||
| accept | `string` | `text/plain` | 默认只支持纯文本,要支持其他类型,请配置此属性为文件后缀`.xxx` |
|
||||
| capture | `string` | `undefined` | 用于控制 input[type=file] 标签的 capture 属性,在移动端可控制输入来源 |
|
||||
| asBase64 | `boolean` | `false` | 将文件以`base64`的形式,赋值给当前组件 |
|
||||
| asBlob | `boolean` | `false` | 将文件以二进制的形式,赋值给当前组件 |
|
||||
| maxSize | `number` | | 默认没有限制,当设置后,文件大小大于此值将不允许上传。单位为`B` |
|
||||
| maxLength | `number` | | 默认没有限制,当设置后,一次只允许上传指定数量文件。 |
|
||||
| multiple | `boolean` | `false` | 是否多选。 |
|
||||
| drag | `boolean` | `false` | 是否为拖拽上传 |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
| delimiter | `string` | `,` | [拼接符](./options#%E6%8B%BC%E6%8E%A5%E7%AC%A6-delimiter) |
|
||||
| autoUpload | `boolean` | `true` | 否选择完就自动开始上传 |
|
||||
| hideUploadButton | `boolean` | `false` | 隐藏上传按钮 |
|
||||
| stateTextMap | object | `{ init: '', pending: '等待上传', uploading: '上传中', error: '上传出错', uploaded: '已上传', ready: '' }` | 上传状态文案 |
|
||||
| fileField | `string` | `file` | 如果你不想自己存储,则可以忽略此属性。 |
|
||||
| nameField | `string` | `name` | 接口返回哪个字段用来标识文件名 |
|
||||
| valueField | `string` | `value` | 文件的值用那个字段来标识。 |
|
||||
| urlField | `string` | `url` | 文件下载地址的字段名。 |
|
||||
| btnLabel | `string` | | 上传按钮的文字 |
|
||||
| downloadUrl | `boolean`或`string` | `""` 1.1.6 版本开始支持 `post:http://xxx.com/${value}` 这种写法 | 默认显示文件路径的时候会支持直接下载,可以支持加前缀如:`http://xx.dom/filename=` ,如果不希望这样,可以把当前配置项设置为 `false`。 |
|
||||
| useChunk | `boolean`或`"auto"` | `"auto"` | amis 所在服务器,限制了文件上传大小不得超出 10M,所以 amis 在用户选择大文件的时候,自动会改成分块上传模式。 |
|
||||
| chunkSize | `number` | `5 * 1024 * 1024` | 分块大小 |
|
||||
| startChunkApi | [API](../../../docs/types/api) | | startChunkApi |
|
||||
| chunkApi | [API](../../../docs/types/api) | | chunkApi |
|
||||
| finishChunkApi | [API](../../../docs/types/api) | | finishChunkApi |
|
||||
| concurrency | `number` | | 分块上传时并行个数 |
|
||||
| documentation | `string` | | 文档内容 |
|
||||
| documentLink | `string` | | 文档链接 |
|
||||
| initAutoFill | `boolean` | `true` | 初表单反显时是否执行 |
|
||||
| invalidTypeMessage | `string` | | 校验格式失败后的提示信息 可以用{{}}获取内部变量值,如{{accept}} |
|
||||
| invalidSizeMessage | `string` | | 校验文件大小失败时显示的文字信息 可以用{{}}获取内部变量值,如{{maxSize}} |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`file`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
|
||||
| change | `[name]: FileValue` \| `Array<FileValue>` 组件的值 | 上传文件值变化时触发(上传失败同样会触发) |
|
||||
| remove | `item: FileValue` 被移除的文件<br/>`[name]: FileValue` \| `Array<FileValue>` 组件的值 | 移除文件时触发 |
|
||||
| success | `item: FileValue` 上传的文件<br/>`result: any` 远程上传请求成功后接口返回的结果数据<br/>`[name]: FileValue` \| `Array<FileValue>` 组件的值 | 上传成功时触发 |
|
||||
| fail | `item: FileValue` 上传的文件 <br /> `error: object` 远程上传请求失败后返回的错误信息<br/>`[name]: FileValue` \| `Array<FileValue>` 组件的值 | 上传文件失败时触发 |
|
||||
|
||||
### FileValue 属性表
|
||||
|
||||
| 属性名 | 类型 | 说明 |
|
||||
| ------ | -------- | -------------------------------------------------- |
|
||||
| name | `string` | 文件名称 |
|
||||
| value | `string` | 上传成功后返回的 url |
|
||||
| state | `string` | 文件当前状态,值可为 `pending` `uploaded` `invalid` |
|
||||
| error | `string` | 错误信息 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------- | ---- |
|
||||
| clear | - | 清空 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-file",
|
||||
"name": "file",
|
||||
"label": "File",
|
||||
"accept": "*",
|
||||
"receiver": "/api/upload/file",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
545
docs/zh-CN/components/form/input-formula.md
Normal file
545
docs/zh-CN/components/form/input-formula.md
Normal file
@@ -0,0 +1,545 @@
|
||||
---
|
||||
title: InputFormula 公式编辑器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputFormula
|
||||
icon:
|
||||
order: 21
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
用来输入公式。还是 beta 版本,整体待优化。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-formula",
|
||||
"name": "formula",
|
||||
"label": "公式",
|
||||
"evalMode": true,
|
||||
"value": "SUM(1 , user.id)",
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "人员对象",
|
||||
"value": "user",
|
||||
"children": [
|
||||
{
|
||||
"label": "ID",
|
||||
"value": "user.id"
|
||||
},
|
||||
{
|
||||
"label": "用户名",
|
||||
"value": "user.name"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "长文本测试分类长文本测试分类长文本测试分类长文本测试分类",
|
||||
"children": [
|
||||
{
|
||||
"label": "这是一段测试长文本这是一段测试长文本这是一段测试长文本",
|
||||
"value": "longtext",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 展示模式
|
||||
|
||||
设置`"inputMode": "button"`可以切换编辑器的展示模式为按钮模式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-formula",
|
||||
"name": "formula",
|
||||
"label": "公式",
|
||||
"variableMode": "tree",
|
||||
"evalMode": true,
|
||||
"value": "SUM(1 , 2)",
|
||||
"inputMode": "button",
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
设置`"inputMode": "input-group"`可以切换编辑器的展示模式为输入框组合模式,1.10.0 及以上版本。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-formula",
|
||||
"name": "formula",
|
||||
"label": "公式",
|
||||
"variableMode": "tree",
|
||||
"evalMode": true,
|
||||
"value": "SUM(1 , 2)",
|
||||
"inputMode": "input-group",
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 变量展示模式
|
||||
|
||||
设置不同`variableMode`字段切换变量展示模式,树形结构:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-formula",
|
||||
"name": "formula",
|
||||
"label": "公式",
|
||||
"variableMode": "tree",
|
||||
"evalMode": true,
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Tab 结构:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-formula",
|
||||
"name": "formula",
|
||||
"label": "公式",
|
||||
"variableMode": "tabs",
|
||||
"evalMode": false,
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 模板模式
|
||||
|
||||
当配置 `evalMode` 为 false 时则为模板模式,意思是说默认不当做表达式,只有 `${`和`}`包裹的部分才是表达式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-formula",
|
||||
"name": "formula",
|
||||
"label": "公式",
|
||||
"evalMode": false,
|
||||
"value": "my name is \\${name}",
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 混合模式
|
||||
|
||||
混合模式的意思是支持输入文本和输入公式两种格式的值,当输入公式时值会自动用 `${` 和 `}` 包裹,如果不是这种格式则认为是输入普通的字符串。通过 `mixedMode` 为 true 启用这种模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-formula",
|
||||
"name": "value",
|
||||
"label": "混合模式",
|
||||
"mixedMode": true,
|
||||
"value": "\\${SUM(1, 2)}",
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------ | -------------- | ------------------------------------------------------------------------------ |
|
||||
| title | `string` | `'公式编辑器'` | 弹框标题 |
|
||||
| header | `string` | - | 编辑器 header 标题,如果不设置,默认使用表单项`label`字段 |
|
||||
| evalMode | `boolean` | `true` | 表达式模式 或者 模板模式,模板模式则需要将表达式写在 `${` 和 `}` 中间。 |
|
||||
| variables | `{label: string; value: string; children?: any[]; tag?: string}[]` | `[]` | 可用变量 |
|
||||
| variableMode | `string` | `list` | 可配置成 `tabs` 或者 `tree` 默认为列表,支持分组。 |
|
||||
| functions | `Object[]` | - | 可以不设置,默认就是 amis-formula 里面定义的函数,如果扩充了新的函数则需要指定 |
|
||||
| inputMode | `'button' \| 'input-button' \| 'input-group'` | - | 控件的展示模式 |
|
||||
| icon | `string` | - | 按钮图标,例如`fa fa-list` |
|
||||
| btnLabel | `string` | `'公示编辑'` | 按钮文本,`inputMode`为`button`时生效 |
|
||||
| level | `'info' \| 'success' \| 'warning' \| 'danger' \| 'link' \| 'primary' \| 'dark' \| 'light'` | `default` | 按钮样式 |
|
||||
| allowInput | `boolean` | - | 输入框是否可输入 |
|
||||
| btnSize | `'xs' \| 'sm' \| 'md' \| 'lg'` | - | 按钮大小 |
|
||||
| borderMode | `'full' \| 'half' \| 'none'` | - | 输入框边框模式 |
|
||||
| placeholder | `string` | `'暂无数据'` | 输入框占位符 |
|
||||
| className | `string` | - | 控件外层 CSS 样式类名 |
|
||||
| variableClassName | `string` | - | 变量面板 CSS 样式类名 |
|
||||
| functionClassName | `string` | - | 函数面板 CSS 样式类名 |
|
||||
151
docs/zh-CN/components/form/input-group.md
Executable file
151
docs/zh-CN/components/form/input-group.md
Executable file
@@ -0,0 +1,151 @@
|
||||
---
|
||||
title: Input-Group 输入框组合
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Input-Group
|
||||
icon:
|
||||
order: 28
|
||||
---
|
||||
|
||||
**输入框组合选择器** 可用于输入框与其他组件进行组合。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-group",
|
||||
"name": "input-group",
|
||||
"label": "input 组合",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"placeholder": "搜索作业ID/名称",
|
||||
"inputClassName": "b-r-none p-r-none",
|
||||
"name": "input-group"
|
||||
},
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "搜索",
|
||||
"level": "primary"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "input-group",
|
||||
"label": "各种组合",
|
||||
"body": [
|
||||
{
|
||||
"type": "select",
|
||||
"name": "memoryUnits",
|
||||
"options": [
|
||||
{
|
||||
"label": "Gi",
|
||||
"value": "Gi"
|
||||
},
|
||||
{
|
||||
"label": "Mi",
|
||||
"value": "Mi"
|
||||
},
|
||||
{
|
||||
"label": "Ki",
|
||||
"value": "Ki"
|
||||
}
|
||||
],
|
||||
"value": "Gi"
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "memory"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"name": "memoryUnits2",
|
||||
"options": [
|
||||
{
|
||||
"label": "Gi",
|
||||
"value": "Gi"
|
||||
},
|
||||
{
|
||||
"label": "Mi",
|
||||
"value": "Mi"
|
||||
},
|
||||
{
|
||||
"label": "Ki",
|
||||
"value": "Ki"
|
||||
}
|
||||
],
|
||||
"value": "Gi"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "Go"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## 校验
|
||||
|
||||
input-group 配置校验方法较为特殊,需要配置下面步骤:
|
||||
|
||||
1. input-group 上配置任意`name`值 (必填, 否则表单内存在多个输入组合时无法定位)
|
||||
2. input-group 的 body 内配置的表单项上配置校验规则
|
||||
3. 如果 input-group 的子元素配置了`label`, 则会在校验失败时作为标识符展示, 否则仅使用索引值作为标识符
|
||||
4. 单个子元素多条校验信息会使用`; `分隔
|
||||
5. 可以使用`"errorMode": "full" | "partial"`设置错误提示风格, `full`整体飘红, `partial`仅错误元素飘红, 默认为`"full"`
|
||||
|
||||
> 细粒度错误提示需`2.7.1`及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-group",
|
||||
"name": "input-group",
|
||||
"label": "输入组合校验",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"placeholder": "请输入长度不超过6的数字类型",
|
||||
"name": "group-input1",
|
||||
"label": "子元素一",
|
||||
"validations": {
|
||||
"isNumeric": true,
|
||||
"maxLength": 6
|
||||
},
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"placeholder": "请输入长度不少于5的文本",
|
||||
"name": "group-input2",
|
||||
"required": true,
|
||||
"validations": {
|
||||
"minLength": 5
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ---------------- | ----------------------------------------- | -------- | ----------------------------------------------------- | ------- |
|
||||
| className | `string` | | CSS 类名 | |
|
||||
| body | Array<[表单项](./formitem)> | | 表单项集合 | |
|
||||
| validationConfig | `Record<'errorMode' \| 'delimiter', any>` | - | 校验相关配置, 具体配置属性如下 | `2.8.0` |
|
||||
| +errorMode | `"full" \| "partial"` | `"full"` | 错误提示风格, `full`整体飘红, `partial`仅错误元素飘红 | `2.8.0` |
|
||||
| +delimiter | `string` | `"; "` | 单个子元素多条校验信息的分隔符 | `2.8.0` |
|
||||
770
docs/zh-CN/components/form/input-image.md
Executable file
770
docs/zh-CN/components/form/input-image.md
Executable file
@@ -0,0 +1,770 @@
|
||||
---
|
||||
title: InputImage 图片
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputImage
|
||||
icon:
|
||||
order: 27
|
||||
---
|
||||
|
||||
图片格式输入,需要实现接收器,提交时将以 url 的方式提交,如果需要以表单方式提交请使用 [InputFile](input-file#作为表单项上传)。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "image",
|
||||
"receiver": "/api/upload/file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
默认情况下,选中文件后,就会自动调用 `receiver` 配置里的接口进行上传,比如 node 版本的示例如下:
|
||||
|
||||
```javascript
|
||||
const express = require('express');
|
||||
const multer = require('multer');
|
||||
const upload = multer({dest: 'uploads/'});
|
||||
const app = express();
|
||||
|
||||
app.use(express.static('public'));
|
||||
|
||||
// 默认情况下是 file 字段名作为文件参数,也可以通过 fileField 配置来改成别的名字
|
||||
app.post('/uploader', upload.single('file'), function (req, res, next) {
|
||||
res.json({
|
||||
status: 0,
|
||||
data: {
|
||||
value: '/' + req.file.path
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 配合上面的返回值,将 uploads 目录可读,这样返回的文件才能正常显示
|
||||
app.get('uploads', express.static('uploads'));
|
||||
|
||||
app.listen(8080, function () {});
|
||||
```
|
||||
|
||||
这个接口需要返回图片地址,比如下面的格式
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"value": "https:/xxx.yy/zz.png"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
点击表单提交的时候,实际提交的就是这个返回的图片地址,比如上面的例子是 `image`,则会提交
|
||||
|
||||
```
|
||||
{
|
||||
"image": "https:/xxx.yy/zz.png"
|
||||
}
|
||||
```
|
||||
|
||||
## 限制文件类型
|
||||
|
||||
可以配置`accept`来限制可选择的文件类型,格式是文件后缀名`.xxx`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "限制只能上传jpg图片",
|
||||
"accept": ".jpg",
|
||||
"receiver": "/api/upload/file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
想要限制多个类型,则用逗号分隔,例如:`.jpg,.png`
|
||||
|
||||
## 限制文件宽度
|
||||
|
||||
配置 `limit`,更多属性请参考后面的属性说明。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "限制只能上传宽度大于 1000 的图片",
|
||||
"accept": ".jpg",
|
||||
"limit": {
|
||||
"minWidth": 1000
|
||||
},
|
||||
"receiver": "/api/upload/file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 限制文件大小
|
||||
|
||||
配置 `maxSize`,限制文件大小,单位为 `B`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "上传文件不能大于 1K",
|
||||
"accept": ".jpg",
|
||||
"maxSize": 1024,
|
||||
"receiver": "/api/upload/file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 支持裁剪
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "上传后裁剪",
|
||||
"receiver": "/api/upload/file",
|
||||
"crop": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
设置裁剪比例等配置,具体细节可以参考[这里](https://github.com/fengyuanchen/cropperjs#options)。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "上传后裁剪",
|
||||
"receiver": "/api/upload/file",
|
||||
"crop": {
|
||||
"aspectRatio": 1.7777
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
默认情况下裁剪结果是 `png` 格式,如果要支持其它格式,请设置 `cropFormat`,比如下面设置为 `jpeg` 格式,同时设置质量为 `0.9`
|
||||
|
||||
> 1.4.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "上传后裁剪",
|
||||
"receiver": "/api/upload/file",
|
||||
"crop": true,
|
||||
"cropFormat": "image/jpeg",
|
||||
"cropQuality": 0.9
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 手动上传
|
||||
|
||||
默认`"autoUpload": true`,即添加文件后自动上传。可以设置`"autoUpload": false`关闭自动上传,此时通过点击底部上传按钮上传。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"data": {
|
||||
"file": {
|
||||
"id":"2ba48d02d348",
|
||||
"value":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"url":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"filename":"file(single).md",
|
||||
"name":"file(single).md",
|
||||
"state":"uploaded"
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"id":"2ba48d02d349",
|
||||
"value":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"url":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"preview": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"filename":"file1.md",
|
||||
"name":"file1.md",
|
||||
"state":"uploaded"
|
||||
},
|
||||
{
|
||||
"id": "14723e0bc640",
|
||||
"value": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"url": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"preview": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"filename":"file2.md",
|
||||
"name":"file2.md",
|
||||
"state":"uploaded"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "files",
|
||||
"label": "File(多选)",
|
||||
"mode": "horizontal",
|
||||
"labelAlign": "left",
|
||||
"accept": "image/jpeg, image/jpg, image/png, image/gif",
|
||||
"receiver": "/api/upload/file",
|
||||
"multiple": true,
|
||||
"autoUpload": false,
|
||||
"joinValues": false,
|
||||
"onEvent": {
|
||||
"success": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "「${event.data.path}」上传成功"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "file",
|
||||
"label": "File(单选)",
|
||||
"mode": "horizontal",
|
||||
"labelAlign": "left",
|
||||
"accept": "image/jpeg, image/jpg, image/png, image/gif",
|
||||
"receiver": "/api/upload/file",
|
||||
"multiple": false,
|
||||
"autoUpload": false,
|
||||
"joinValues": false,
|
||||
"onEvent": {
|
||||
"success": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "「${event.data.path}」上传成功"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 隐藏上传按钮
|
||||
|
||||
设置 `"hideUploadButton": true` 隐藏手动上传的按钮。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"data": {
|
||||
"file": {
|
||||
"id":"2ba48d02d348",
|
||||
"value":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"url":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"filename":"file(single).md",
|
||||
"name":"file(single).md",
|
||||
"state":"uploaded"
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"id":"2ba48d02d349",
|
||||
"value":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"url":"https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"preview": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"filename":"file1.md",
|
||||
"name":"file1.md",
|
||||
"state":"uploaded"
|
||||
},
|
||||
{
|
||||
"id": "14723e0bc640",
|
||||
"value": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"url": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"preview": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"filename":"file2.md",
|
||||
"name":"file2.md",
|
||||
"state":"uploaded"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "files",
|
||||
"label": "File(多选)",
|
||||
"mode": "horizontal",
|
||||
"labelAlign": "left",
|
||||
"accept": "image/jpeg, image/jpg, image/png, image/gif",
|
||||
"receiver": "/api/upload/file",
|
||||
"multiple": true,
|
||||
"autoUpload": false,
|
||||
"joinValues": false,
|
||||
"hideUploadButton": true,
|
||||
"onEvent": {
|
||||
"success": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "「${event.data.path}」上传成功"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "file",
|
||||
"label": "File(单选)",
|
||||
"mode": "horizontal",
|
||||
"labelAlign": "left",
|
||||
"accept": "image/jpeg, image/jpg, image/png, image/gif",
|
||||
"receiver": "/api/upload/file",
|
||||
"multiple": false,
|
||||
"autoUpload": false,
|
||||
"joinValues": false,
|
||||
"hideUploadButton": true,
|
||||
"onEvent": {
|
||||
"success": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "「${event.data.path}」上传成功"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果浏览器支持,还能设置为 `image/webp`
|
||||
|
||||
## 自动填充
|
||||
|
||||
上传成功后,可以通过配置 `autoFill` 将上传接口返回的值填充到某个表单项中:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "image",
|
||||
"receiver": "/api/upload/file",
|
||||
"autoFill": {
|
||||
"myUrl": "${url}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"name": "myUrl",
|
||||
"label": "url"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中,image 组件上传后,接口返回格式例如如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"value": "xxxxxxx",
|
||||
"filename": "xxxx.jpg",
|
||||
"url": "http://xxxx.xxx.xxx"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
然后 image 上配置:
|
||||
|
||||
```json
|
||||
"autoFill": {
|
||||
"myUrl": "${url}"
|
||||
}
|
||||
```
|
||||
|
||||
这样上传成功后,会把接口中的 `url` 变量,赋值给 `myUrl` 变量,这个里支持表达式,比如在前面加上域名
|
||||
|
||||
```json
|
||||
"autoFill": {
|
||||
"myUrl": "https://cdn.com/${filename}"
|
||||
}
|
||||
```
|
||||
|
||||
### 多选模式
|
||||
|
||||
当表单项为多选模式时,不能再直接取选项中的值了,而是通过 `items` 变量来取,通过它可以获取当前选中的选项集合。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "image",
|
||||
"multiple": true,
|
||||
"receiver": "/api/upload/file",
|
||||
"autoFill": {
|
||||
"myUrl": "${items|pick:url}",
|
||||
"lastUrl": "${items|last|pick:url}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "tpl",
|
||||
"label": false,
|
||||
"inline": false,
|
||||
"tpl": "<strong>myUrl集合</strong>"
|
||||
},
|
||||
{
|
||||
"type": "each",
|
||||
"name": "myUrl",
|
||||
"className": "mb-1",
|
||||
"items": {
|
||||
"type": "tpl",
|
||||
"tpl": "<span class='label label-info m-l-sm inline-block mb-1'>${item}</span>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "tpl",
|
||||
"label": false,
|
||||
"inline": false,
|
||||
"tpl": "<strong>lastUrl</strong>"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"name": "lastUrl",
|
||||
"label": "lastUrl",
|
||||
"inline": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 其他表单项填充
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"title": "表单",
|
||||
"body": [
|
||||
{
|
||||
"type": "select",
|
||||
"label": "选项",
|
||||
"name": "imageUrl",
|
||||
"delimiter": "|",
|
||||
"autoFill": {
|
||||
"inputImage": "${value}"
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"label": "imageURL",
|
||||
"value": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80"
|
||||
},
|
||||
{
|
||||
"label": "空链接",
|
||||
"value": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "input-image",
|
||||
"label": "图片上传",
|
||||
"name": "inputImage",
|
||||
"imageClassName": "r w-full"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### initAutoFill 初始化时自动同步
|
||||
|
||||
当表单反显时,可通过`initAutoFill`控制`autoFill`在数据反显时是否执行。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
type: 'crud',
|
||||
api: '/api/mock2/crud/list',
|
||||
perPage: 3,
|
||||
columns: [
|
||||
{
|
||||
type: 'operation',
|
||||
label: '操作',
|
||||
buttons: [
|
||||
{
|
||||
type: 'button',
|
||||
label: '修改',
|
||||
level: 'link',
|
||||
size: 'xs',
|
||||
actionType: 'dialog',
|
||||
dialog: {
|
||||
title: '修改',
|
||||
size: 'lg',
|
||||
body: {
|
||||
"type": "form",
|
||||
"horizontal": {
|
||||
"left": 3,
|
||||
"right": 9
|
||||
},
|
||||
"api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "image",
|
||||
"receiver": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/upload/file",
|
||||
"autoFill": {
|
||||
"text": "${url}"
|
||||
},
|
||||
"initAutoFill": true
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "text",
|
||||
"label": "文本",
|
||||
},
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "carousel",
|
||||
"label": "image",
|
||||
"receiver": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/upload/file",
|
||||
"autoFill": {
|
||||
"id": "${url}"
|
||||
},
|
||||
"initAutoFill": false
|
||||
},
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "id",
|
||||
"label": "ID",
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'id',
|
||||
label: 'ID',
|
||||
type: 'text'
|
||||
},
|
||||
{
|
||||
name: 'text',
|
||||
label: '文本',
|
||||
type: 'text'
|
||||
},
|
||||
{
|
||||
type: 'image',
|
||||
label: '图片',
|
||||
name: 'image',
|
||||
enlargeAble: true,
|
||||
title: '233',
|
||||
thumbMode: 'cover'
|
||||
},
|
||||
{
|
||||
name: 'carousel',
|
||||
label: '轮播图',
|
||||
type: 'carousel',
|
||||
width: '300'
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 拖拽排序
|
||||
|
||||
可配置 `draggable` 为 `true` 启动拖拽排序。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"title": "表单",
|
||||
data: {
|
||||
image: [
|
||||
'http://www.sortablejs.com/assets/img/npm.png',
|
||||
'http://www.sortablejs.com/assets/img/bower.png',
|
||||
'http://www.sortablejs.com/assets/img/js.png'
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
'Images: <br />${image|split|join:"<br />"}',
|
||||
{
|
||||
type: 'input-image',
|
||||
name: 'image',
|
||||
multiple: true,
|
||||
draggable: true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
|--------------------|-------------------------------------------------------|------------------------|-----------------------------------------------------------------------------------|
|
||||
| receiver | [API](../../../docs/types/api) | | 上传文件接口 |
|
||||
| accept | `string` | `.jpeg,.jpg,.png,.gif` | 支持的图片类型格式,请配置此属性为图片后缀,例如`.jpg,.png` |
|
||||
| capture | `string` | `undefined` | 用于控制 input[type=file] 标签的 capture 属性,在移动端可控制输入来源 |
|
||||
| maxSize | `number` | | 默认没有限制,当设置后,文件大小大于此值将不允许上传。单位为`B` |
|
||||
| maxLength | `number` | | 默认没有限制,当设置后,一次只允许上传指定数量文件。 |
|
||||
| multiple | `boolean` | `false` | 是否多选。 |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
| delimiter | `string` | `,` | [拼接符](./options#%E6%8B%BC%E6%8E%A5%E7%AC%A6-delimiter) |
|
||||
| autoUpload | `boolean` | `true` | 否选择完就自动开始上传 |
|
||||
| hideUploadButton | `boolean` | `false` | 隐藏上传按钮 |
|
||||
| fileField | `string` | `file` | 如果你不想自己存储,则可以忽略此属性。 |
|
||||
| crop | `boolean`或`{"aspectRatio":""}` | | 用来设置是否支持裁剪。 |
|
||||
| crop.aspectRatio | `number` | | 裁剪比例。浮点型,默认 `1` 即 `1:1`,如果要设置 `16:9` 请设置 `1.7777777777777777` 即 `16 / 9`。。 |
|
||||
| crop.rotatable | `boolean` | `false` | 裁剪时是否可旋转 |
|
||||
| crop.scalable | `boolean` | `false` | 裁剪时是否可缩放 |
|
||||
| crop.viewMode | `number` | `1` | 裁剪时的查看模式,0 是无限制 |
|
||||
| cropFormat | `string` | `image/png` | 裁剪文件格式 |
|
||||
| cropQuality | `number` | `1` | 裁剪文件格式的质量,用于 jpeg/webp,取值在 0 和 1 之间 |
|
||||
| limit | Limit | | 限制图片大小,超出不让上传。 |
|
||||
| frameImage | `string` | | 默认占位图地址 |
|
||||
| fixedSize | `boolean` | | 是否开启固定尺寸,若开启,需同时设置 fixedSizeClassName |
|
||||
| fixedSizeClassName | `string` | | 开启固定尺寸时,根据此值控制展示尺寸。例如`h-30`,即图片框高为 h-30,AMIS 将自动缩放比率设置默认图所占位置的宽度,最终上传图片根据此尺寸对应缩放。 |
|
||||
| initAutoFill | `boolean` | `false` | 表单反显时是否执行 autoFill |
|
||||
| uploadBtnText | `string` \| [SchemaNode](../../docs/types/schemanode) | | 上传按钮文案。支持 tpl、schema 形式配置。 |
|
||||
| dropCrop | `boolean` | `true` | 图片上传后是否进入裁剪模式 |
|
||||
| initCrop | `boolean` | `false` | 图片选择器初始化后是否立即进入裁剪模式 |
|
||||
| draggable | `boolean` | false | 开启后支持拖拽排序改变图片值顺序 |
|
||||
| draggableTip | `string` | '拖拽排序' | 拖拽提示文案 |
|
||||
| showErrorModal | `boolean` | `true` | 校验失败后是否弹窗提醒 |
|
||||
| invalidTypeMessage | `string` | '文件格式不正确' | 校验格式失败后的提示信息 | |
|
||||
| invalidSizeMessage | `string` | '文件大小超出限制' | 校验文件大小失败时显示的文字信息 | |
|
||||
|
||||
### Limit 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------- | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| width | `number` | | 限制图片宽度。 |
|
||||
| height | `number` | | 限制图片高度。 |
|
||||
| minWidth | `number` | | 限制图片最小宽度。 |
|
||||
| minHeight | `number` | | 限制图片最小高度。 |
|
||||
| maxWidth | `number` | | 限制图片最大宽度。 |
|
||||
| maxHeight | `number` | | 限制图片最大高度。 |
|
||||
| aspectRatio | `number` | | 限制图片宽高比,格式为浮点型数字,默认 `1` 即 `1:1`,如果要设置 `16:9` 请设置 `1.7777777777777777` 即 `16 / 9`。 如果不想限制比率,请设置空字符串。 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`file`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
|
||||
| change | `[name]: FileValue` \| `Array<FileValue>` 组件的值 | 上传文件值变化时触发(上传失败同样会触发) |
|
||||
| remove | `item: FileValue` 被移除的文件<br/>`[name]: FileValue` \| `Array<FileValue>` 组件的值 | 移除文件时触发 |
|
||||
| success | `item: FileValue` 上传的文件<br/>`result: any` 远程上传请求成功后接口返回的结果数据<br/>`id: string` id<br />`[name]: FileValue` 组件的值 | 上传成功时触发 |
|
||||
| fail | `item: FileValue` 上传的文件 <br /> `error: object` 远程上传请求失败后返回的错误信息<br/>`[name]: FileValue` \| `Array<FileValue>` 组件的值 | 上传文件失败时触发 |
|
||||
|
||||
### FileValue 属性表
|
||||
|
||||
| 属性名 | 类型 | 说明 |
|
||||
| ------ | -------- | -------------------------------------------------- |
|
||||
| name | `string` | 图片名称 |
|
||||
| value | `string` | 上传成功后返回的 url |
|
||||
| state | `string` | 文件当前状态,值可为 `pending` `uploaded` `invalid` |
|
||||
| error | `string` | 错误信息 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------- | ---- |
|
||||
| clear | - | 清空 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-image",
|
||||
"name": "image",
|
||||
"label": "Image",
|
||||
"receiver": "/api/upload/file",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
229
docs/zh-CN/components/form/input-kv.md
Normal file
229
docs/zh-CN/components/form/input-kv.md
Normal file
@@ -0,0 +1,229 @@
|
||||
---
|
||||
title: InputKV 键值对
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputKV
|
||||
icon:
|
||||
order: 14
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
`input-kv` 是用来支持对象形式的数据编辑,比如类似这样的数据:
|
||||
|
||||
```json
|
||||
{
|
||||
"css": {
|
||||
"width": 1,
|
||||
"height": 2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`css` 中的 key 是不确定的,没法用 combo 来实现,这时可以使用 `input-kv`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kv",
|
||||
"name": "kv"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
最终发送的数据将会是
|
||||
|
||||
## 自定义 value 的格式
|
||||
|
||||
key 只能是字符串,因此输入格式是 `input-text`,但 value 格式可通过 `valueType` 自定义。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kv",
|
||||
"name": "kv",
|
||||
"valueType": "input-number"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义 value 的默认值
|
||||
|
||||
通过 `defaultValue` 设置默认值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kv",
|
||||
"name": "css",
|
||||
"defaultValue": "1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义 value 的 schema
|
||||
|
||||
> 3.1.0 及以上版本
|
||||
|
||||
默认创建的 value schema 是
|
||||
|
||||
```json
|
||||
{
|
||||
"placeholder": "Value",
|
||||
"type": "input-text",
|
||||
"name": "value"
|
||||
}
|
||||
```
|
||||
|
||||
前面的配置可以改其中的 type 或 placeholder,而这个新的 `valueSchema` 配置就能做到替换所有配置,比如
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kv",
|
||||
"name": "css",
|
||||
"valueSchema": {
|
||||
"type": "select",
|
||||
"options": [
|
||||
{
|
||||
"label": "A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义 key schema
|
||||
|
||||
> 3.1.0 及以上版本
|
||||
|
||||
和前面的 value schema 类似,还可以自定义 key 的 schema
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kv",
|
||||
"name": "css",
|
||||
"keySchema": {
|
||||
"type": "select",
|
||||
"options": [
|
||||
{
|
||||
"label": "A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 关闭可拖拽排序
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kv",
|
||||
"name": "css",
|
||||
"draggable": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义提示信息
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kv",
|
||||
"name": "css",
|
||||
"keyPlaceholder": "属性",
|
||||
"valuePlaceholder": "值"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------------- | --------- | -------------- | ---------------------------- |
|
||||
| valueType | `type` | `"input-text"` | 值类型 |
|
||||
| keyPlaceholder | `string` | | key 的提示信息的 |
|
||||
| valuePlaceholder | `string` | | value 的提示信息的 |
|
||||
| draggable | `boolean` | true | 是否可拖拽排序 |
|
||||
| defaultValue | | `''` | 默认值 |
|
||||
| autoParseJSON | `boolean` | `true` | 是否自动转换 json 对象字符串 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------------------------------------------------------------ | ---------------- |
|
||||
| add | `[name]: string \| string[]` 组件的值 | 添加组合项时触发 |
|
||||
| delete | `key: number` 移除项的索引<br />`item: string` 移除项<br />`[name]: object` 组件的值 | 删除组合项时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: object` 更新的值 | 更新数据 |
|
||||
320
docs/zh-CN/components/form/input-kvs.md
Normal file
320
docs/zh-CN/components/form/input-kvs.md
Normal file
@@ -0,0 +1,320 @@
|
||||
---
|
||||
title: InputKVS 键值对象
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputKVS
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
|
||||
> 2.1.0 及以上版本
|
||||
|
||||
这个组件的功能和 `input-kv` 类似,`input-kv` 的 value 值只支持一个对象,`input-kvs` 的最大不同就是 value 支持对象和数组,可以用来支持深层结构编辑
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"name": "field",
|
||||
"addButtonText": "新增字段",
|
||||
"keyItem": {
|
||||
"label": "字段名"
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "primary",
|
||||
"label": "是否是主键"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"name": "type",
|
||||
"label": "字段类型",
|
||||
"options": [
|
||||
"text",
|
||||
"int",
|
||||
"float"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
其中 `keyItem` 可以用来修改 key 值控件,比如可以改成下拉框
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"name": "field",
|
||||
"addButtonText": "新增字段",
|
||||
"keyItem": {
|
||||
"label": "字段名",
|
||||
"type": "select",
|
||||
"options": [
|
||||
"id",
|
||||
"title",
|
||||
"content"
|
||||
]
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "primary",
|
||||
"label": "是否是主键"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"name": "type",
|
||||
"label": "字段类型",
|
||||
"options": [
|
||||
"text",
|
||||
"int",
|
||||
"float"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
而 `valueItems` 是用来控制值的控件,这里的配置和 combo 的 items 一样,唯一限制是不允许有 `"name": "_key"` 值的情况,因为这个值被当成对象 key 了。
|
||||
|
||||
## 水平模式
|
||||
|
||||
通过 `"mode": "horizontal"` 设置,需要分别在 `keyItem` 和 `valueItems` 里设置
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"name": "field",
|
||||
"addButtonText": "新增字段",
|
||||
"keyItem": {
|
||||
"label": "字段名",
|
||||
"mode": "horizontal"
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "primary",
|
||||
"mode": "horizontal",
|
||||
"label": "是否是主键"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"name": "type",
|
||||
"label": "字段类型",
|
||||
"mode": "horizontal",
|
||||
"options": [
|
||||
"text",
|
||||
"int",
|
||||
"float"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 嵌套的场景
|
||||
|
||||
`valueItems` 可以进一步嵌套,比如里面又嵌一个 `input-kvs` 实现深层结构编辑
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"name": "dataModel",
|
||||
"addButtonText": "新增表",
|
||||
"keyItem": {
|
||||
"label": "表名",
|
||||
"mode": "horizontal",
|
||||
"type": "select",
|
||||
"options": [
|
||||
"table1",
|
||||
"table2",
|
||||
"table3"
|
||||
]
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"addButtonText": "新增字段",
|
||||
"name": "column",
|
||||
"keyItem": {
|
||||
"label": "字段名",
|
||||
"mode": "horizontal",
|
||||
"type": "select",
|
||||
"options": [
|
||||
"id",
|
||||
"title",
|
||||
"content"
|
||||
]
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "primary",
|
||||
"mode": "horizontal",
|
||||
"label": "是否是主键"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"name": "type",
|
||||
"label": "字段类型",
|
||||
"mode": "horizontal",
|
||||
"options": [
|
||||
"text",
|
||||
"int",
|
||||
"float"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
前面的嵌套会多一个层级,如果想去掉这个层级 `column`,可以将 `"name": "column"` 改成 `"name": "_value"`,这时值就会直接放入
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"name": "dataModel",
|
||||
"addButtonText": "新增表",
|
||||
"keyItem": {
|
||||
"label": "表名",
|
||||
"mode": "horizontal",
|
||||
"type": "select",
|
||||
"options": [
|
||||
"table1",
|
||||
"table2",
|
||||
"table3"
|
||||
]
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"addButtonText": "新增字段",
|
||||
"name": "_value",
|
||||
"keyItem": {
|
||||
"label": "字段名",
|
||||
"mode": "horizontal",
|
||||
"type": "select",
|
||||
"options": [
|
||||
"id",
|
||||
"title",
|
||||
"content"
|
||||
]
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "primary",
|
||||
"mode": "horizontal",
|
||||
"label": "是否是主键"
|
||||
},
|
||||
{
|
||||
"type": "select",
|
||||
"name": "type",
|
||||
"label": "字段类型",
|
||||
"mode": "horizontal",
|
||||
"options": [
|
||||
"text",
|
||||
"int",
|
||||
"float"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
除了前面的对象,值也可以是数组,需要配置一下 `valueIsArray`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-kvs",
|
||||
"name": "dataModel",
|
||||
"addButtonText": "新增表",
|
||||
"valueIsArray": true,
|
||||
"keyItem": {
|
||||
"label": "表名",
|
||||
"mode": "horizontal",
|
||||
"type": "select",
|
||||
"options": [
|
||||
"table1",
|
||||
"table2",
|
||||
"table3"
|
||||
]
|
||||
},
|
||||
"valueItems": [
|
||||
{
|
||||
type: 'checkboxes',
|
||||
name: '_value',
|
||||
joinValues: false,
|
||||
extractValue: true,
|
||||
options: [
|
||||
{
|
||||
label: '查询',
|
||||
value: 'select'
|
||||
},
|
||||
{
|
||||
label: '写入',
|
||||
value: 'insert'
|
||||
},
|
||||
{
|
||||
label: '更新',
|
||||
value: 'update'
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
value: 'delete'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
106
docs/zh-CN/components/form/input-month-range.md
Normal file
106
docs/zh-CN/components/form/input-month-range.md
Normal file
@@ -0,0 +1,106 @@
|
||||
---
|
||||
title: InputMonthRange 月份范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputMonthRange
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month-range",
|
||||
"name": "a",
|
||||
"label": "月份范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month-range",
|
||||
"name": "a",
|
||||
"label": "月份范围",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 存成两个字段
|
||||
|
||||
默认月份范围存储一个字段,用 `delimiter` 分割,如果配置 `extraName` 则会存两个字段。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month-range",
|
||||
"name": "begin",
|
||||
"extraName": "end",
|
||||
"label": "月份范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | --------- | ------------------ | ---------------------------------------------------------------------------------- | ------- |
|
||||
| format | `string` | `X` | [日期选择器值格式](./input-date#%E5%80%BC%E6%A0%BC%E5%BC%8F) |
|
||||
| inputFormat | `string` | `YYYY-DD` | [日期选择器显示格式](./input-date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) |
|
||||
| placeholder | `string` | `"请选择月份范围"` | 占位文本 |
|
||||
| minDate | `string` | | 限制最小日期,用法同 [限制范围](./input-date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./input-date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| minDuration | `string` | | 限制最小跨度,如: 2days |
|
||||
| maxDuration | `string` | | 限制最大跨度,如:1year |
|
||||
| utc | `boolean` | `false` | [保存 UTC 值](./input-date#utc) |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| embed | `boolean` | `false` | 是否内联模式 |
|
||||
| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` |
|
||||
| extraName | `string` | | 是否存成两个字段 | `3.3.0` |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | -------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1646064000,1651334399' |
|
||||
178
docs/zh-CN/components/form/input-month.md
Executable file
178
docs/zh-CN/components/form/input-month.md
Executable file
@@ -0,0 +1,178 @@
|
||||
---
|
||||
title: InputMonth 月份
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputMonth 月份
|
||||
icon:
|
||||
order: 81
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "时间"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示格式
|
||||
|
||||
选中月份,可以看到默认显示月份的格式是像`01`这样的格式,如果你想要自定义显示格式,那么可以配置`displayFormat`。
|
||||
|
||||
例如你想显示`01月`这样的格式,查找 moment 文档可知配置格式应为 `MM月`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"displayFormat": "MM月"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
调整月份,观察显示格式
|
||||
|
||||
## 值格式
|
||||
|
||||
选中任意月份,可以看到默认表单项的值格式是像`1582992000`这样的时间戳格式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果你想要其他格式的月份值,那么可以配置`valueFormat`参数用于调整表单项的值格式。
|
||||
|
||||
例如你调整值为`01`这样的格式,查找 moment 文档可知配置格式应为 `MM`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"valueFormat": "MM"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
调整月份,观察数据域中表单项值的变化
|
||||
|
||||
## 默认值
|
||||
|
||||
可以设置`value`属性,设置月份选择器的默认值
|
||||
|
||||
### 基本配置
|
||||
|
||||
配置符合当前 [值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) 的默认值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"value": "1582992000"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 相对值
|
||||
|
||||
`value` 还支持类似像`"+1hours"`这样的相对值,更加便捷的配置默认值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-month",
|
||||
"name": "month",
|
||||
"label": "月份",
|
||||
"value": "+1month"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中配置了`"value": "+1month"`,默认就会选中一个月后。
|
||||
|
||||
支持的相对值关键字有:
|
||||
|
||||
- `now`: 当前时间
|
||||
- `hour`或`hours`: 时
|
||||
- `minute`或`minutes`: 分
|
||||
- `second`或`seconds`: 秒
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | --------- | -------------- | ----------------------------------------------------------------------------------- | ------- |
|
||||
| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) |
|
||||
| valueFormat | `string` | `X` | 月份选择器值格式,更多格式类型请参考 [moment](http://momentjs.com/) | `3.4.0` |
|
||||
| displayFormat | `string` | `YYYY-MM` | 月份选择器显示格式,即时间戳格式,更多格式类型请参考 [moment](http://momentjs.com/) | `3.4.0` |
|
||||
| placeholder | `string` | `"请选择月份"` | 占位文本 |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------- | --------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`valueFormat`,例如:'1646064000' |
|
||||
417
docs/zh-CN/components/form/input-number.md
Executable file
417
docs/zh-CN/components/form/input-number.md
Executable file
@@ -0,0 +1,417 @@
|
||||
---
|
||||
title: InputNumber 数字输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputNumber
|
||||
icon:
|
||||
order: 32
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置精度
|
||||
|
||||
`precision` 设置数字的显示精度,一般需要配合 `step` 属性使用,以实现细粒度调整。注意带有单位的输入不支持配置精度属性。若设置了 `step` 值,则会基于 `step` 和 `precision` 的值,选择更高的精度。若输入的内容不满足精度要求,组件会按照精度自动处理,遵循四舍五入规则。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"data": {
|
||||
"number2": 3.1234
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number1",
|
||||
"label": "数字",
|
||||
"precision": 2,
|
||||
"step": 0.01,
|
||||
"value": 2.98786
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number2",
|
||||
"label": "数字2",
|
||||
"precision": 3,
|
||||
"step": 0.001
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number3",
|
||||
"label": "数字3",
|
||||
"step": 0.001,
|
||||
"description": "不设置precision,仅设置step, 实际精度为3"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 重置值
|
||||
|
||||
清空/重置组件输入后,组件绑定的值将被设置为 `resetValue`,默认为 `""`。若 `resetValue` 为合法数字时,会根据 `min`、`max` 和 `precision` 属性,将组件值设置为满足条件的值。若 `resetValue` 为非数字,则组件清空/重置后设置为该值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number1",
|
||||
"label": "数字resetValue为0",
|
||||
"resetValue": 0,
|
||||
"value": 1234
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number2",
|
||||
"label": "数字带有min",
|
||||
"min": 100,
|
||||
"resetValue": 0,
|
||||
"value": 1234,
|
||||
"description": "清空输入后组件值变为100,因为设置了最小值min为100"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number3",
|
||||
"label": "数字带有max和precision",
|
||||
"max": 100.5,
|
||||
"precision": 2,
|
||||
"resetValue": 1000,
|
||||
"value": 1234,
|
||||
"description": "清空输入后组件值变为100.5,因为设置了最大值max为100.5"
|
||||
},
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number4",
|
||||
"label": "数字未设置resetValue",
|
||||
"resetValue": "string",
|
||||
"value": 1234,
|
||||
"description": "清空输入后组件值变为\"string\",因为resetValue不是一个合法的数字"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 前后缀、千分分隔
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字",
|
||||
"value": 111111,
|
||||
"prefix": "$",
|
||||
"suffix": "%",
|
||||
"kilobitSeparator": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 带单位数字
|
||||
|
||||
> 1.4.0 及以上版本
|
||||
|
||||
可以通过 `unitOptions` 设置数字的单位选项,和前面的前后缀不同,它的输出结果也将会是字符串,包含单位,默认取选项的第一个。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字",
|
||||
"unitOptions": ["px", "%", "em"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 加强版输入框
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字",
|
||||
"displayMode": "enhance"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 是否是大数
|
||||
|
||||
> 2.3.0 及以上版本
|
||||
|
||||
默认情况下使用 JavaScript 原生数字类型,但如果要支持输入超过 JavaScript 支持范围的整数或浮点数,可以通过 `"big": true` 开启大数支持,开启之后输入输出都将是字符串。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字",
|
||||
"big": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内容清空时删除字段
|
||||
|
||||
> 2.8.0 及以上版本
|
||||
|
||||
如果设置了 `"clearValueOnEmpty": true`,当输入框的值清空时,会从数据域中删除该表单项对应的值。比较常见的用法是在 `combo`、`input-array` 等组件中避免 `input-number` 清空后提交空字符串。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"debugConfig": {
|
||||
"levelExpand": 2
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "group",
|
||||
"body": [
|
||||
{
|
||||
"name": "numberClear",
|
||||
"type": "input-number",
|
||||
"label": "清空",
|
||||
"value": 123,
|
||||
"clearValueOnEmpty": true
|
||||
},
|
||||
{
|
||||
"name": "numberNotClear",
|
||||
"type": "input-number",
|
||||
"label": "不清空",
|
||||
"value": 456
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "combo",
|
||||
"name": "user",
|
||||
"label": "用户",
|
||||
"items": [
|
||||
{
|
||||
"name": "text",
|
||||
"label": "名字",
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "gender",
|
||||
"label": "性别",
|
||||
"type": "select",
|
||||
"options": ["男", "女"]
|
||||
},
|
||||
{
|
||||
"name": "age",
|
||||
"label": "年龄",
|
||||
"type": "input-number",
|
||||
"clearValueOnEmpty": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 原生数字组件
|
||||
|
||||
原生数字组件将直接使用浏览器的实现,最终展现效果和浏览器有关,并且只支持 `min`、`max` 和 `step` 这几个属性设置,这个功能主要是给移动端浏览器使用的,PC 下不建议使用。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "native-number",
|
||||
"name": "number",
|
||||
"label": "数字"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ----------------- | --------------------------------------- | -------- | ------------------------------------------- | ------- |
|
||||
| min | [模板](../../../docs/concepts/template) | | 最小值 |
|
||||
| max | [模板](../../../docs/concepts/template) | | 最大值 |
|
||||
| step | `number` | | 步长 |
|
||||
| precision | `number` | | 精度,即小数点后几位,支持 0 和正整数 |
|
||||
| showSteps | `boolean` | `true` | 是否显示上下点击按钮 |
|
||||
| readOnly | `boolean` | `false` | 只读 |
|
||||
| prefix | `string` | | 前缀 |
|
||||
| suffix | `string` | | 后缀 |
|
||||
| unitOptions | `string[]` | | 单位选项 | `1.4.0` |
|
||||
| kilobitSeparator | `boolean` | `false` | 千分分隔 |
|
||||
| keyboard | `boolean` | `true` | 键盘事件(方向上下) |
|
||||
| big | `boolean` | `false` | 是否使用大数 | `2.3.0` |
|
||||
| displayMode | `"base" \| "enhance"` | `"base"` | 样式类型 |
|
||||
| borderMode | `"full" \| "half" \| "none"` | `"full"` | 边框模式,全边框,还是半边框,或者没边框 |
|
||||
| resetValue | `number \| string` | `""` | 清空输入内容时,组件值将设置为 `resetValue` |
|
||||
| clearValueOnEmpty | `boolean` | `false` | 内容为空时从数据域中删除该表单项对应的值 | `2.8.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过 `onEvent` 来监听这些事件,并通过 `actions` 来配置执行的动作,在 `actions` 中可以通过 `${事件参数名}` 或 `${event.data.[事件参数名]}` 来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]` 表示当前组件绑定的名称,即 `name` 属性,如果没有配置 `name` 属性,则通过 `value` 取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | ---------------- |
|
||||
| change | `[name]: number` 组件的值 | 输入值变化时触发 |
|
||||
| blur | `[name]: number` 组件的值 | - |
|
||||
| focus | `[name]: number` 组件的值 | - |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定 `actionType: 动作名称`、`componentId: 该组件id` 来触发这些动作,动作配置可以通过 `args: {动作配置项名称: xxx}` 来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------------------------- | -------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为 `resetValue`,若没有配置 `resetValue`,则清空 |
|
||||
| setValue | `value: number` 更新的数值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字",
|
||||
"id": "clear_text",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字",
|
||||
"id": "reset_text",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "number",
|
||||
"label": "数字",
|
||||
"id": "setvalue_text",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
60
docs/zh-CN/components/form/input-password.md
Normal file
60
docs/zh-CN/components/form/input-password.md
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
title: InputPassword 密码输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputPassword
|
||||
icon:
|
||||
order: 35
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配置密码显/隐藏
|
||||
|
||||
`revealPassword`属性可以设置是否展示密码显/隐按钮,默认为`true`。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码",
|
||||
"revealPassword": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
请参考[输入框](./input-text)
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| -------------- | --------- | ------ | --------------------- |
|
||||
| revealPassword | `boolean` | `true` | 是否展示密码显/隐按钮 |
|
||||
|
||||
## 事件表
|
||||
|
||||
请参考[输入框](./input-text)
|
||||
|
||||
## 动作表
|
||||
|
||||
请参考[输入框](./input-text)
|
||||
105
docs/zh-CN/components/form/input-quarter-range.md
Normal file
105
docs/zh-CN/components/form/input-quarter-range.md
Normal file
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: InputQuarterRange 季度范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputQuarterRange
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-quarter-range",
|
||||
"name": "quarter-range",
|
||||
"label": "季度范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-quarter-range",
|
||||
"name": "quarter-range",
|
||||
"label": "季度范围",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 存成两个字段
|
||||
|
||||
默认季度范围存储一个字段,用 `delimiter` 分割,如果配置 `extraName` 则会存两个字段。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-quarter-range",
|
||||
"name": "begin",
|
||||
"extraName": "end",
|
||||
"label": "季度范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | --------- | ------------------ | ---------------------------------------------------------------------------------- | ------- |
|
||||
| valueFormat | `string` | `X` | [日期选择器值格式](./input-date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` |
|
||||
| displayFormat | `string` | `YYYY-DD` | [日期选择器显示格式](./input-date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` |
|
||||
| placeholder | `string` | `"请选择季度范围"` | 占位文本 |
|
||||
| minDate | `string` | | 限制最小日期,用法同 [限制范围](./input-date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./input-date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| minDuration | `string` | | 限制最小跨度,如: 2quarter |
|
||||
| maxDuration | `string` | | 限制最大跨度,如:4quarter |
|
||||
| utc | `boolean` | `false` | [保存 UTC 值](./input-date#utc) |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| embed | `boolean` | `false` | 是否内联模式 |
|
||||
| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` |
|
||||
| extraName | `string` | | 是否存成两个字段 | `3.3.0` |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | -------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1640966400,1664553600' |
|
||||
49
docs/zh-CN/components/form/input-quarter.md
Normal file
49
docs/zh-CN/components/form/input-quarter.md
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: InputQuarter 季度
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputQuarter 季度
|
||||
icon:
|
||||
order: 62
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-quarter",
|
||||
"name": "quarter",
|
||||
"label": "季度"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
更多用法和配置可以参考 [InputDate 日期](input-date),quarter 就是 date 的特定配置,所以 date 的所有配置都能使用。
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1640966400' |
|
||||
541
docs/zh-CN/components/form/input-range.md
Executable file
541
docs/zh-CN/components/form/input-range.md
Executable file
@@ -0,0 +1,541 @@
|
||||
---
|
||||
title: InputRange 滑块
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputRange 范围
|
||||
icon:
|
||||
order: 38
|
||||
---
|
||||
|
||||
可以用于选择单个数值或数值范围。
|
||||
|
||||
## 基本用法
|
||||
|
||||
默认是单个数值,结果是个整数。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": '滑块',
|
||||
"name": 'range',
|
||||
"value": 20
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 选择范围
|
||||
|
||||
对于范围的渲染,结果将是个字符串,两个数值通过分隔符来隔开。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range",
|
||||
"multiple": true,
|
||||
"joinValues": false,
|
||||
"value": {
|
||||
"min": 10,
|
||||
"max": 50
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 控制调整的粒度
|
||||
|
||||
使用 `step` 可以控制调整粒度,默认是 1。`3.3.0`版本后支持使用变量。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"step": 0.01,
|
||||
"label": "range"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 禁用
|
||||
|
||||
使用`disabled`禁用滑块。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": '滑块',
|
||||
"name": 'range',
|
||||
"value": 10,
|
||||
"disabled": true,
|
||||
"showInput": true,
|
||||
"clearable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示步长
|
||||
|
||||
开启`showSteps`可显示每个`step`长度
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": '滑块',
|
||||
"name": 'range',
|
||||
"max": 10,
|
||||
"showSteps": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 分割块数
|
||||
|
||||
通过`parts`可对整个滑动条平均分为`parts`块。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": '滑块',
|
||||
"name": 'range',
|
||||
"showSteps": true,
|
||||
"parts": 20
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 刻度标记
|
||||
|
||||
通过`marks`可对刻度进行自定义。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": '滑块',
|
||||
"name": 'range',
|
||||
"parts": 5,
|
||||
"marks": {
|
||||
'0': '0',
|
||||
'20%': '20Mbps',
|
||||
'40%': '40Mbps',
|
||||
'60%': '60Mbps',
|
||||
'80%': '80Mbps',
|
||||
'100': '100'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 输入框
|
||||
|
||||
通过开启`showInput`会展示输入框,输入框数据于滑块数据同步。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range",
|
||||
"value": 20,
|
||||
"showInput": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range",
|
||||
"multiple": true,
|
||||
"value": [10, 20],
|
||||
"showInput": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 清除输入
|
||||
|
||||
在打开`showInput`输入框的前提下,开启`clearable`可对数据进行清除。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range",
|
||||
"value": 20,
|
||||
"showInput": true,
|
||||
"clearable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示单位
|
||||
|
||||
在打开`showInput`输入框且设置了`unit`单位的前提下,开启`showInputUnit`可在 input 框中显示已配置的单位。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range",
|
||||
"value": 20,
|
||||
"unit": "个",
|
||||
"showInput": true,
|
||||
"showInputUnit": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示标签
|
||||
|
||||
标签默认在 hover 和拖拽过程中展示,通过`tooltipVisible`或者`tipFormatter`可指定标签是否展示。标签默认展示在滑块上方,通过`tooltipPlacement`可指定标签展示的位置。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"name": "range",
|
||||
"label": "range",
|
||||
"value": 20,
|
||||
"tooltipVisible": true,
|
||||
"tooltipPlacement": "right"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 存成两个字段
|
||||
|
||||
默认滑块多选存储一个字段,用 `delimiter` 分割,如果配置 `extraName` 则会存两个字段。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"multiple": true,
|
||||
"name": "begin",
|
||||
"extraName": "end",
|
||||
"label": "range"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
|
||||
| className | `string` | | css 类名 |
|
||||
| value | `number` or `string` or `{min: number, max: number}` or `[number, number]` | | |
|
||||
| min | `number \| string` | `0` | 最小值,支持变量 | `3.3.0`后支持变量 |
|
||||
| max | `number \| string` | `100` | 最大, 支持变量值 | `3.3.0`后支持变量 |
|
||||
| disabled | `boolean` | `false` | 是否禁用 |
|
||||
| step | `number \| string` | `1` | 步长,支持变量 | `3.3.0`后支持变量 |
|
||||
| showSteps | `boolean` | `false` | 是否显示步长 |
|
||||
| parts | `number` or `number[]` | `1` | 分割的块数<br/>主持数组传入分块的节点 |
|
||||
| marks | <code>{ [number | string]: string | number | SchemaObject }</code> or <code>{ [number | string]: { style: CSSProperties, label: string } }</code> | | 刻度标记<br/>- 支持自定义样式<br/>- 设置百分比 |
|
||||
| tooltipVisible | `boolean` | `false` | 是否显示滑块标签 |
|
||||
| tooltipPlacement | `auto` or `bottom` or `left` or `right` | `top` | 滑块标签的位置,默认`auto`,方向自适应<br/>前置条件:tooltipVisible 不为 false 时有效 |
|
||||
| tipFormatter | `function` | | 控制滑块标签显隐函数<br/>前置条件:tooltipVisible 不为 false 时有效 |
|
||||
| multiple | `boolean` | `false` | 支持选择范围 |
|
||||
| joinValues | `boolean` | `true` | 默认为 `true`,选择的 `value` 会通过 `delimiter` 连接起来,否则直接将以`{min: 1, max: 100}`的形式提交<br/>前置条件:开启`multiple`时有效 |
|
||||
| delimiter | `string` | `,` | 分隔符 |
|
||||
| unit | `string` | | 单位 |
|
||||
| clearable | `boolean` | `false` | 是否可清除<br/>前置条件:开启`showInput`时有效 |
|
||||
| showInput | `boolean` | `false` | 是否显示输入框 |
|
||||
| showInputUnit | `boolean` | `false` | 是否显示输入框单位<br/>前置条件:开启`showInput`且配置了`unit`单位时有效 | `6.0.0`后支持变量 |
|
||||
| onChange | `function` | | 当 组件 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入 |
|
||||
| onAfterChange | `function` | | 与 `onmouseup` 触发时机一致,把当前值作为参数传入 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ---------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| change | `[name]: number \| string \|{min: number, max: number}` 组件的值 | 当值变化时触发的事件 |
|
||||
| blur | `[name]: number \| string \|{min: number, max: number}` 组件的值 | 当设置 showInput 为 true 时,输入框失去焦点时触发 |
|
||||
| focus | `[name]: number \| string \|{min: number, max: number}` 组件的值 | 当设置 showInput 为 true 时,输入框获取焦点时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": "滑块",
|
||||
"name": "range",
|
||||
"value": 20,
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### blur
|
||||
|
||||
当设置 `showInput` 为 true 时,输入框失去焦点时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": "滑块",
|
||||
"name": "range",
|
||||
"value": 20,
|
||||
"showInput": true,
|
||||
"onEvent": {
|
||||
"blur": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### focus
|
||||
|
||||
当设置 `showInput` 为 true 时,输入框获取焦点时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": "滑块",
|
||||
"name": "range",
|
||||
"value": 20,
|
||||
"showInput": true,
|
||||
"onEvent": {
|
||||
"focus": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------------------------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清除输入框 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: number \| string \| {min: number, max: number}` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": "滑块",
|
||||
"name": "range",
|
||||
"value": 20,
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": "滑块",
|
||||
"name": "range",
|
||||
"value": 20,
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-range",
|
||||
"label": "滑块",
|
||||
"name": "range",
|
||||
"value": 20,
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": 30
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
288
docs/zh-CN/components/form/input-rating.md
Executable file
288
docs/zh-CN/components/form/input-rating.md
Executable file
@@ -0,0 +1,288 @@
|
||||
---
|
||||
title: InputRating 评分
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputRating 评分
|
||||
icon:
|
||||
order: 37
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
默认颜色
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
自定义颜色。支持各种颜色形式,如 CSS 预定义颜色,十六进制颜色,RGB 颜色,HSL 颜色。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3,
|
||||
"colors": {
|
||||
"1": "gray",
|
||||
"2": "#678f8d",
|
||||
"3": "rgb(119, 168, 141)",
|
||||
"4": "hsl(147, 22%, 56%)",
|
||||
"5": "#ff6670"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 半星
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3.5,
|
||||
"half": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 带有文字
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3,
|
||||
"texts": {
|
||||
"1": "很差",
|
||||
"2": "较差",
|
||||
"3": "一般",
|
||||
"4": "较好",
|
||||
"5": "很好"
|
||||
},
|
||||
"textClassName": "okde"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义字符
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3,
|
||||
"char": "好"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 只读
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3.6,
|
||||
"half": true,
|
||||
"readOnly": true,
|
||||
"texts": {
|
||||
"5": "3.6"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------- | ------------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
||||
| value | `number` | - | 当前值 |
|
||||
| half | `boolean` | `false` | 是否使用半星选择 |
|
||||
| count | `number` | `5` | 总星数 |
|
||||
| readOnly | `boolean` | `false` | 只读 |
|
||||
| allowClear | `boolean` | `true` | 是否允许再次点击后清除 |
|
||||
| colors | `string` / `object` | `{'2': '#abadb1', '3': '#787b81', '5': '#ffa900' }` | 星星被选中的颜色。 若传入字符串,则只有一种颜色。若传入对象,可自定义分段,键名为分段的界限值,键值为对应的类名 |
|
||||
| inactiveColor | `string` | `#e7e7e8` | 未被选中的星星的颜色 |
|
||||
| texts | `object` | - | 星星被选中时的提示文字。可自定义分段,键名为分段的界限值,键值为对应的类名 |
|
||||
| textPosition | `right` / `left` | `right` | 文字的位置 |
|
||||
| char | `string` | `★` | 自定义字符 |
|
||||
| className | `string` | - | 自定义样式类名 |
|
||||
| charClassName | `string` | - | 自定义字符类名 |
|
||||
| textClassName | `string` | - | 自定义文字类名 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------- |
|
||||
| change | `[name]: number` 组件的值 | 分值变化时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: number` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3.5,
|
||||
"half": true,
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3.5,
|
||||
"half": true,
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rating",
|
||||
"name": "rating",
|
||||
"label": "评分",
|
||||
"count": 5,
|
||||
"value": 3.5,
|
||||
"half": true,
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": 4
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
34
docs/zh-CN/components/form/input-repeat.md
Executable file
34
docs/zh-CN/components/form/input-repeat.md
Executable file
@@ -0,0 +1,34 @@
|
||||
---
|
||||
title: InputRepeat 重复频率选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputRepeat 重复频率
|
||||
icon:
|
||||
order: 39
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-repeat",
|
||||
"name": "repeat",
|
||||
"label": "重复频率"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------- | -------- | ----------------------------- | ------------------------------------------------------------------------ |
|
||||
| options | `string` | `hourly,daily,weekly,monthly` | 可用配置 `secondly,minutely,hourly,daily,weekdays,weekly,monthly,yearly` |
|
||||
| placeholder | `string` | `不重复` | 当不指定值时的说明。 |
|
||||
260
docs/zh-CN/components/form/input-rich-text.md
Executable file
260
docs/zh-CN/components/form/input-rich-text.md
Executable file
@@ -0,0 +1,260 @@
|
||||
---
|
||||
title: InputRichText 富文本编辑器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputRichText
|
||||
icon:
|
||||
order: 47
|
||||
---
|
||||
|
||||
目前富文本编辑器基于两个库:[froala](https://froala.com/) 和 [tinymce](https://github.com/tinymce/tinymce),默认使用 tinymce。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"name": "rich",
|
||||
"label": "Rich Text"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 图片上传
|
||||
|
||||
通过设置 `receiver` 来支持文件上传,如果是 tinymce,它会将图片放在 `file` 字段中
|
||||
|
||||
> 1.6.1 及以上版本可以通过 fileField 字段修改
|
||||
|
||||
它的返回值类似如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"link": "https://xxx.png"
|
||||
}
|
||||
```
|
||||
|
||||
也可以是
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"data": {
|
||||
"link": "https://xxx.png"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
下面是个示例,但不会真正上传,每次都返回同一张图片
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"receiver": "/api/mock2/sample/mirror?json={%22link%22:%22/amis/static/logo_c812f54.png%22}",
|
||||
"name": "rich",
|
||||
"label": "Rich Text"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## tinymce 自定义配置
|
||||
|
||||
可以设置 options 属性来自定义编辑器的展现,详细配置项请参考[官方文档](https://www.tiny.cloud/docs/tinymce/6/basic-setup/)。
|
||||
|
||||
> amis 2.1.0 版本升级到了 tinymce 6,导致 plugins 的写法有变化
|
||||
|
||||
注意在下面的编辑器里修改 JSON 配置后不会实时生效。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"name": "rich",
|
||||
"options": {
|
||||
"menubar": false,
|
||||
"height": 200,
|
||||
"plugins": [
|
||||
"advlist", "autolink", "link", "image", "lists", "charmap", "preview", "anchor", "pagebreak", "searchreplace", "wordcount", "visualblocks", "visualchars", "code", "fullscreen", "insertdatetime", "media", "nonbreaking", "table", "emoticons", "template", "help"
|
||||
],
|
||||
"toolbar": "undo redo | formatselect | bold italic backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 关于 tinymce 粘贴 word 的问题
|
||||
|
||||
因为 amis 中使用的是开源版本 tinymce,没有商业版本功能,导致比如从 Word 中粘贴表格会看不到边框,解决方法是自己
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"name": "rich",
|
||||
"options": {
|
||||
"content_css": "/xxx.css"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
比如下面的示例
|
||||
|
||||
```css
|
||||
.mce-item-table th {
|
||||
font-weight: bold;
|
||||
}
|
||||
.mce-item-table th,
|
||||
.mce-item-table td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
.mce-item-table tr {
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
```
|
||||
|
||||
但最终页面渲染的时候,这个 class 没有了,得改成 table
|
||||
|
||||
```css
|
||||
table th {
|
||||
font-weight: bold;
|
||||
}
|
||||
table th,
|
||||
table td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
table tr {
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
```
|
||||
|
||||
## 图片保存为 base64
|
||||
|
||||
当使用 tinymce 编辑器的时候,如果配置文件接收器为空,当选择图片的时候,会自动转成 base64 格式存储
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"name": "rich",
|
||||
"label": "Rich Text",
|
||||
"receiver": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 扩充 tinymce 插件
|
||||
|
||||
需要在调用 amis 的时候,通过 `env.loadTinymcePlugin` 来加载自定义插件,可以查考: [examples/components/SchemaRender.jsx](https://github.com/baidu/amis/blob/master/examples/components/SchemaRender.jsx) 文件中的示例。
|
||||
|
||||
```schema
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"name": "rich",
|
||||
"label": "Rich Text",
|
||||
"options": {
|
||||
"menubar": false,
|
||||
"height": 200,
|
||||
"plugins": [
|
||||
|
||||
"example"
|
||||
],
|
||||
"toolbar": "undo redo | example"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 使用 froala 编辑器
|
||||
|
||||
只需要加一行 `"vendor": "froala"` 配置就行,froala 是付费产品,需要设置 [richTextToken](../../start/getting-started#richtexttoken-string) 才能去掉水印。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-rich-text",
|
||||
"vendor": "froala",
|
||||
"name": "rich",
|
||||
"label": "Rich Text"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### froala buttons 配置项
|
||||
|
||||
froala 可以通过设置 buttons 参数来控制显示哪些按钮,默认是这些:
|
||||
|
||||
```json
|
||||
[
|
||||
"undo",
|
||||
"redo",
|
||||
"paragraphFormat",
|
||||
"textColor",
|
||||
"backgroundColor",
|
||||
"bold",
|
||||
"underline",
|
||||
"strikeThrough",
|
||||
"formatOL",
|
||||
"formatUL",
|
||||
"align",
|
||||
"quote",
|
||||
"insertLink",
|
||||
"insertImage",
|
||||
"insertEmotion",
|
||||
"insertTable",
|
||||
"html"
|
||||
]
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------- | ------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| saveAsUbb | `boolean` | | 是否保存为 ubb 格式 |
|
||||
| receiver | [API](../../../docs/types/api) | | 默认的图片保存 API |
|
||||
| videoReceiver | [API](../../../docs/types/api) | | 默认的视频保存 API `仅支持 froala 编辑器` |
|
||||
| fileField | string | | 上传文件时的字段名 |
|
||||
| size | `string` | | 框的大小,可设置为 `md` 或者 `lg` |
|
||||
| options | `object` | | 需要参考 [tinymce](https://www.tiny.cloud/docs/configure/integration-and-setup/) 或 [froala](https://www.froala.com/wysiwyg-editor/docs/options) 的文档 |
|
||||
| buttons | `Array<string>` | | froala 专用,配置显示的按钮,tinymce 可以通过前面的 options 设置 [toolbar](https://www.tiny.cloud/docs/demo/custom-toolbar-button/) 字符串 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
> | 事件名称 | 事件参数 | 说明 |
|
||||
> | -------- | ------------------------------------- | ------------------------------------------- |
|
||||
> | change | `[value]: object` 富文本组件的值<br/> | 富文本值改变时触发 |
|
||||
122
docs/zh-CN/components/form/input-signature.md
Normal file
122
docs/zh-CN/components/form/input-signature.md
Normal file
@@ -0,0 +1,122 @@
|
||||
---
|
||||
title: inputSignature 签名面板
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: inputSignature
|
||||
icon:
|
||||
order: 62
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "input-signature",
|
||||
"label": "手写签名",
|
||||
"height": 200
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义按钮名称
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "input-signature",
|
||||
"height": 160,
|
||||
"confirmBtnLabel": "确定",
|
||||
"undoBtnLabel": "上一步",
|
||||
"clearBtnLabel": "重置"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义颜色
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "input-signature",
|
||||
"label": "手写签名",
|
||||
"height": 200,
|
||||
"color": "#ff0000",
|
||||
"bgColor": "#fff"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配合图片组件实现实时预览
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "input-signature",
|
||||
"label": "手写签名",
|
||||
"height": 200
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"name": "signature"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
在内嵌模式下,组件会以按钮的形式展示,点击按钮后弹出一个容器,用户可以在容器中完成签名。更适合在移动端使用。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "input-signature",
|
||||
"label": "手写签名",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------------- | ------------------------------ | ---------- | ------------------------------------ |
|
||||
| width | `number` | | 组件宽度,最小 300 |
|
||||
| height | `number` | | 组件高度,最小 160 |
|
||||
| color | `string` | `#000` | 手写字体颜色 |
|
||||
| bgColor | `string` | `#EFEFEF` | 面板背景颜色 |
|
||||
| clearBtnLabel | `string` | `清空` | 清空按钮名称 |
|
||||
| undoBtnLabel | `string` | `撤销` | 撤销按钮名称 |
|
||||
| confirmBtnLabel | `string` | `确认` | 确认按钮名称 |
|
||||
| embed | `boolean` | | 是否内嵌 |
|
||||
| embedConfirmLabel | `string` | `确认` | 内嵌容器确认按钮名称 |
|
||||
| ebmedCancelLabel | `string` | `取消` | 内嵌容器取消按钮名称 |
|
||||
| embedBtnIcon | `string` | | 内嵌按钮图标 |
|
||||
| embedBtnLabel | `string` | `点击签名` | 内嵌按钮文案 |
|
||||
| uploadApi | [API](../../../docs/types/api) | | 上传签名图片接口,仅在内嵌模式下生效 |
|
||||
183
docs/zh-CN/components/form/input-sub-form.md
Executable file
183
docs/zh-CN/components/form/input-sub-form.md
Executable file
@@ -0,0 +1,183 @@
|
||||
---
|
||||
title: InputSubForm 子表单
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputSubForm 子表单
|
||||
icon:
|
||||
order: 50
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-sub-form",
|
||||
"name": "form",
|
||||
"label": "子Form",
|
||||
"btnLabel": "设置子表单",
|
||||
"form": {
|
||||
"title": "配置子表单",
|
||||
"body": [
|
||||
{
|
||||
"name": "a",
|
||||
"label": "A",
|
||||
"type": "input-text"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "b",
|
||||
"label": "B",
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 多选模式
|
||||
|
||||
可以配置`"multiple": true`,实现多选模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-sub-form",
|
||||
"name": "form2",
|
||||
"label": "多选",
|
||||
"multiple": true,
|
||||
"maxLength": 3,
|
||||
"form": {
|
||||
"title": "配置子表单",
|
||||
"body": [
|
||||
{
|
||||
"name": "a",
|
||||
"label": "A",
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"label": "B",
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置按钮名称
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-sub-form",
|
||||
"name": "form2",
|
||||
"label": "多选",
|
||||
"multiple": true,
|
||||
"btnLabel": "设置${title}",
|
||||
"form": {
|
||||
"title": "配置子表单",
|
||||
"body": [
|
||||
{
|
||||
"name": "title",
|
||||
"label": "标题",
|
||||
"required": true,
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"label": "其他",
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 支持拖拽
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-sub-form",
|
||||
"name": "form2",
|
||||
"label": "多选",
|
||||
"multiple": true,
|
||||
"btnLabel": "设置${title}",
|
||||
"draggable": true,
|
||||
"addable": false,
|
||||
"removable": false,
|
||||
"value": [
|
||||
{
|
||||
"title": "a"
|
||||
},
|
||||
{
|
||||
"title": "b"
|
||||
},
|
||||
{
|
||||
"title": "c"
|
||||
},
|
||||
{
|
||||
"title": "d"
|
||||
}
|
||||
],
|
||||
"form": {
|
||||
"title": "配置子表单",
|
||||
"body": [
|
||||
{
|
||||
"name": "title",
|
||||
"label": "标题",
|
||||
"required": true,
|
||||
"type": "input-text"
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"label": "其他",
|
||||
"type": "input-text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------------ | --------------- | -------- | ------------------------------------------------------ |
|
||||
| multiple | `boolean` | `false` | 是否为多选模式 |
|
||||
| labelField | `string` | | 当值中存在这个字段,则按钮名称将使用此字段的值来展示。 |
|
||||
| btnLabel | `string` | `"设置"` | 按钮默认名称 |
|
||||
| minLength | `number` | `0` | 限制最小个数。 |
|
||||
| maxLength | `number` | `0` | 限制最大个数。 |
|
||||
| draggable | `boolean` | | 是否可拖拽排序 |
|
||||
| addable | `boolean` | | 是否可新增 |
|
||||
| removable | `boolean` | | 是否可删除 |
|
||||
| addButtonClassName | `string` | `` | 新增按钮 CSS 类名 |
|
||||
| itemClassName | `string` | `` | 值元素 CSS 类名 |
|
||||
| itemsClassName | `string` | `` | 值包裹元素 CSS 类名 |
|
||||
| form | [Form](./index) | | 子表单配置,同 [Form](./index) |
|
||||
| addButtonText | `string` | `` | 自定义新增一项的文本 |
|
||||
| showErrorMsg | `boolean` | `true` | 是否在左下角显示报错信息 |
|
||||
2871
docs/zh-CN/components/form/input-table.md
Executable file
2871
docs/zh-CN/components/form/input-table.md
Executable file
File diff suppressed because it is too large
Load Diff
441
docs/zh-CN/components/form/input-tag.md
Executable file
441
docs/zh-CN/components/form/input-tag.md
Executable file
@@ -0,0 +1,441 @@
|
||||
---
|
||||
title: InputTag 标签选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputTag 标签选择器
|
||||
icon:
|
||||
order: 55
|
||||
---
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"options": [
|
||||
"Aaron Rodgers",
|
||||
"Tom Brady",
|
||||
"Charlse Woodson",
|
||||
"Aaron Jones"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 限制标签最大展示数量
|
||||
|
||||
> 1.10.0 及以上版本
|
||||
|
||||
`maxTagCount`可以限制标签的最大展示数量,超出数量的部分会收纳到 Popover 中,可以通过`overflowTagPopover`配置 Popover 相关的[属性](../tooltip#属性表),注意该属性仅在多选模式开启后生效。
|
||||
|
||||
> 6.13.0 版本开始,可摆放个数会根据所剩空间尽可能多的摆放,但是摆放个数不会超出设定的值,所以可以将这个值稍微设置大点。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"maxTagCount": 100,
|
||||
"overflowTagPopover": {
|
||||
"title": "水果"
|
||||
},
|
||||
"value": "Pineapple,Kiwifruit,Banana,Blueberry,Carambola,Coconut,Lemon,Grape,Pomegranate,Mango,Papaya,Mangosteen,Durian,Longan,Litchi,Loquat,Persimmon,Pomelo,Orange,Tangerine,Kumquat,Plum,Apricot,Peach,Pear,Apple,Strawberry",
|
||||
"options": [
|
||||
{"label": "苹果", "value": "Apple"},
|
||||
{"label": "香蕉", "value": "Banana"},
|
||||
{"label": "黑莓", "value": "Blackberry"},
|
||||
{"label": "蓝莓", "value": "Blueberry"},
|
||||
{"label": "樱桃", "value": "Cherry"},
|
||||
{"label": "杨桃", "value": "Carambola"},
|
||||
{"label": "椰子", "value": "Coconut"},
|
||||
{"label": "猕猴桃", "value": "Kiwifruit"},
|
||||
{"label": "柠檬", "value": "Lemon"},
|
||||
{"label": "菠萝", "value": "Pineapple"},
|
||||
{"label": "葡萄", "value": "Grape"},
|
||||
{"label": "石榴", "value": "Pomegranate"},
|
||||
{"label": "芒果", "value": "Mango"},
|
||||
{"label": "木瓜", "value": "Papaya"},
|
||||
{"label": "山竹", "value": "Mangosteen"},
|
||||
{"label": "榴莲", "value": "Durian"},
|
||||
{"label": "龙眼", "value": "Longan"},
|
||||
{"label": "荔枝", "value": "Litchi"},
|
||||
{"label": "枇杷", "value": "Loquat"},
|
||||
{"label": "柿子", "value": "Persimmon"},
|
||||
{"label": "柚子", "value": "Pomelo"},
|
||||
{"label": "橙子", "value": "Orange"},
|
||||
{"label": "橘子", "value": "Tangerine"},
|
||||
{"label": "金桔", "value": "Kumquat"},
|
||||
{"label": "李子", "value": "Plum"},
|
||||
{"label": "杏子", "value": "Apricot"},
|
||||
{"label": "桃子", "value": "Peach"},
|
||||
{"label": "梨子", "value": "Pear"},
|
||||
{"label": "草莓", "value": "Strawberry"}
|
||||
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 批量输入
|
||||
|
||||
> 2.0.0 及以上版本
|
||||
|
||||
可以设置`"enableBatchAdd": true`开启批量输入模式,默认的分隔符为`"-"`,可以使用`"separator"`属性自定义分隔符,注意避免和`"delimiter"`属性冲突。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"enableBatchAdd": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 数量&文本长度限制
|
||||
|
||||
> 2.0.0 及以上版本
|
||||
|
||||
可以设置`max`限制输入的标签数量,设置`maxTagLength`限制单个标签的最大文本长度。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"options": ["abc", "def", "xyz"],
|
||||
"enableBatchAdd": true,
|
||||
"max": 5,
|
||||
"maxTagLength": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------------ | ----------------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./options#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| optionsTip | `Array<object>`或`Array<string>` | `"最近您使用的标签"` | 选项提示 |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| delimiter | `string` | `false` | [拼接符](./options#%E6%8B%BC%E6%8E%A5%E7%AC%A6-delimiter) |
|
||||
| labelField | `string` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `string` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
| clearable | `boolean` | `false` | 在有值的时候是否显示一个删除图标在右侧。 |
|
||||
| resetValue | `string` | `""` | 删除后设置此配置项给定的值。 |
|
||||
| max | `number` | | 允许添加的标签的最大数量 |
|
||||
| maxTagLength | `number` | | 单个标签的最大文本长度 |
|
||||
| maxTagCount | `number` | | 标签的最大展示数量,超出数量后以收纳浮层的方式展示,仅在多选模式开启后生效 |
|
||||
| overflowTagPopover | `TooltipObject` | `{"placement": "top", "trigger": "hover", "showArrow": false, "offset": [0, -10]}` | 收纳浮层的配置属性,详细配置参考[Tooltip](../tooltip#属性表) |
|
||||
| enableBatchAdd | `boolean` | `false` | 是否开启批量添加模式 |
|
||||
| separator | `string` | `"-"` | 开启批量添加后,输入多个标签的分隔符,支持传入多个符号,默认为"-" |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ----------------------------------------------------------------------------------------------------------------- | -------------------- |
|
||||
| change | `[name]: string` 组件的值(多个以逗号分割)<br/>`selectedItems: Option[]` 选中的项<br/>`items: Option[]` 所有选项 | 选中值变化时触发 |
|
||||
| blur | `[name]: string` 组件的值<br/>`selectedItems: Option[]` 选中的项<br/>`items: Option[]` 所有选项 | 输入框失去焦点时触发 |
|
||||
| focus | `[name]: string` 组件的值<br/>`selectedItems: Option[]` 选中的项<br/>`items: Option[]` 所有选项 | 输入框获取焦点时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"options": [
|
||||
"Aaron Rodgers",
|
||||
"Tom Brady",
|
||||
"Charlse Woodson",
|
||||
"Aaron Jones"
|
||||
],
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### blur
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"options": [
|
||||
"Aaron Rodgers",
|
||||
"Tom Brady",
|
||||
"Charlse Woodson",
|
||||
"Aaron Jones"
|
||||
],
|
||||
"onEvent": {
|
||||
"blur": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### focus
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"options": [
|
||||
"Aaron Rodgers",
|
||||
"Tom Brady",
|
||||
"Charlse Woodson",
|
||||
"Aaron Jones"
|
||||
],
|
||||
"onEvent": {
|
||||
"focus": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
|
||||
| setValue | `value: string` 更新的值 | 更新数据,多个值用`,`分隔 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"options": [
|
||||
"Aaron Rodgers",
|
||||
"Tom Brady",
|
||||
"Charlse Woodson",
|
||||
"Aaron Jones"
|
||||
],
|
||||
"value": "Charlse Woodson",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"options": [
|
||||
"Aaron Rodgers",
|
||||
"Tom Brady",
|
||||
"Charlse Woodson",
|
||||
"Aaron Jones"
|
||||
],
|
||||
"value": "Charlse Woodson",
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"id": "reload_type",
|
||||
"source": "/api/mock2/form/getOptions?waitSeconds=1",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-tag",
|
||||
"name": "tag",
|
||||
"label": "标签",
|
||||
"placeholder": "请选择标签",
|
||||
"options": [
|
||||
"Aaron Rodgers",
|
||||
"Tom Brady",
|
||||
"Charlse Woodson",
|
||||
"Aaron Jones"
|
||||
],
|
||||
"value": "Charlse Woodson",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "Tom Brady"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
798
docs/zh-CN/components/form/input-text.md
Executable file
798
docs/zh-CN/components/form/input-text.md
Executable file
@@ -0,0 +1,798 @@
|
||||
---
|
||||
title: InputText 输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputText 输入框
|
||||
icon:
|
||||
order: 56
|
||||
---
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 不同边框风格
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "text-half-border",
|
||||
"type": "input-text",
|
||||
"label": "半边框",
|
||||
"borderMode": "half",
|
||||
"inputControlClassName": "bg-gray-100"
|
||||
},
|
||||
{
|
||||
"name": "text-no-border",
|
||||
"type": "input-text",
|
||||
"label": "无边框",
|
||||
"borderMode": "none",
|
||||
"nativeInputClassName": "focus:text-indigo-700"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 不同类型
|
||||
|
||||
配置`type`可以支持不同格式的文本输入框
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "input-url",
|
||||
"name": "url",
|
||||
"label": "链接"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "input-email",
|
||||
"name": "email",
|
||||
"label": "邮箱"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "input-password",
|
||||
"name": "password",
|
||||
"label": "密码"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 附加组件
|
||||
|
||||
可以配置`addOn`,附带附加组件,比如 button,还能设置 icon。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"addOn": {
|
||||
"type": "button",
|
||||
"icon": "https://suda.cdn.bcebos.com/images%2F2021-01%2Fsearch.svg",
|
||||
"label": "搜索"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 可清除
|
||||
|
||||
通过 `"clearable": true` 可以设置文本可清除
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"clearable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 选择器模式
|
||||
|
||||
配置`options`即可支持选择器模式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"options": [
|
||||
{
|
||||
"label": "aa",
|
||||
"value": "aa"
|
||||
},
|
||||
{
|
||||
"label": "bb",
|
||||
"value": "bb"
|
||||
},
|
||||
{
|
||||
"label": "cc",
|
||||
"value": "cc"
|
||||
},
|
||||
{
|
||||
"label": "dd",
|
||||
"value": "dd"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
选择器模式下,支持部分选择器组件支持的配置项,具体请查看下面的属性表。如:source 和 autoComplete 都支持
|
||||
|
||||
## 限制只能选择预设
|
||||
|
||||
配置 options 并且配置 creatable: false
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"creatable": false,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 多选模式
|
||||
|
||||
配置 multiple: true
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"multiple": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB (with long suffix for testing ellipsis)",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 前缀和后缀
|
||||
|
||||
`prefix` 和 `suffix` 属性支持数据映射。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"data": {
|
||||
"unit": "MB"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"prefix": "¥",
|
||||
"suffix": "RMB"
|
||||
},
|
||||
{
|
||||
"name": "prefix",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"prefix": "¥"
|
||||
},
|
||||
{
|
||||
"name": "suffix",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"suffix": "${unit}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示计数器
|
||||
|
||||
配置`"showCounter": true`后输入框将显示计数器,一般会配合`maxLength`属性以限制输入长度,如果不设置`maxLength`,则仅展示计数器,并不会限制用户的输入长度。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "a",
|
||||
"type": "input-text",
|
||||
"label": "A",
|
||||
"showCounter": true,
|
||||
"placeholder": "请输入",
|
||||
"showCounter": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "aa",
|
||||
"value": "aa"
|
||||
},
|
||||
{
|
||||
"label": "bb",
|
||||
"value": "bb"
|
||||
},
|
||||
{
|
||||
"label": "cc",
|
||||
"value": "cc"
|
||||
},
|
||||
{
|
||||
"label": "dd",
|
||||
"value": "dd"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": "input-text",
|
||||
"label": "B",
|
||||
"showCounter": true,
|
||||
"maxLength": 20,
|
||||
"placeholder": "请输入"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动转换值
|
||||
|
||||
可以配置 transform,来自动转换值,支持转小写或大写。
|
||||
|
||||
> 注意下面第一个示例,只有输入的内容才会触发 transform,下拉框选中的值是不会处理的。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "lower",
|
||||
"type": "input-text",
|
||||
"label": "转换小写",
|
||||
"placeholder": "输入的英文自动转为小写",
|
||||
"transform": {
|
||||
"lowerCase": true
|
||||
},
|
||||
"multiple": true,
|
||||
"options": ["APPLE", "ORANGE", "WATERMELON"],
|
||||
},
|
||||
{
|
||||
"name": "upper",
|
||||
"type": "input-text",
|
||||
"label": "转换大写",
|
||||
"placeholder": "输入的英文自动转为大写",
|
||||
"transform": {
|
||||
"upperCase": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 文本内容为空时去掉这个值
|
||||
|
||||
> 2.4.0 及以上版本
|
||||
|
||||
如果设置了 `"clearValueOnEmpty": true`,当输入框的值清空时,提交的表单项里就不会有这个值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "内容为空时清理这个表单项",
|
||||
"value": "v",
|
||||
"clearValueOnEmpty": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "input-text",
|
||||
"label": "自动补全",
|
||||
"autoComplete": "/api/mock2/options/autoComplete?term=$term",
|
||||
"placeholder": "请输入",
|
||||
"multiple": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------------------- | ----------------------------------------- | --------- | ------------------------------------------------------------------------------------------- |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./options#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| autoComplete | `string`或 [API](../../../docs/types/api) | | [自动补全](./options#%E8%87%AA%E5%8A%A8%E8%A1%A5%E5%85%A8-autocomplete) |
|
||||
| multiple | `boolean` | | [是否多选](./options#%E5%A4%9A%E9%80%89-multiple) |
|
||||
| delimiter | `string` | `,` | [拼接符](./options#%E6%8B%BC%E6%8E%A5%E7%AC%A6-delimiter) |
|
||||
| labelField | `string` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `string` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
| addOn | `addOn` | | 输入框附加组件,比如附带一个提示文字,或者附带一个提交按钮。 |
|
||||
| addOn.type | `string` | | 请选择 `text` 、`button` 或者 `submit`。 |
|
||||
| addOn.label | `string` | | 文字说明 |
|
||||
| addOn.position | `'left' \| 'right'` | `'right'` | addOn 位置 |
|
||||
| addOn.xxx | `string` | | 其他参数请参考按钮文档 |
|
||||
| trimContents | `boolean` | | 是否去除首尾空白文本。 |
|
||||
| clearValueOnEmpty | `boolean` | | 文本内容为空时去掉这个值 |
|
||||
| creatable | `boolean` | | 是否可以创建,默认为可以,除非设置为 false 即只能选择选项中的值 |
|
||||
| clearable | `boolean` | | 是否可清除 |
|
||||
| resetValue | `string` | `""` | 清除后设置此配置项给定的值。 |
|
||||
| prefix | `string` | `""` | 前缀 |
|
||||
| suffix | `string` | `""` | 后缀 |
|
||||
| showCounter | `boolean` | | 是否显示计数器 |
|
||||
| minLength | `number` | | 限制最小字数 |
|
||||
| maxLength | `number` | | 限制最大字数 |
|
||||
| transform | `object` | | 自动转换值,可选 `transform: { lowerCase: true, upperCase: true }` |
|
||||
| borderMode | `"full"\| "half" \| "none"` | `"full"` | 输入框边框模式,全边框,还是半边框,或者没边框。 |
|
||||
| inputControlClassName | `string` | | control 节点的 CSS 类名 |
|
||||
| nativeInputClassName | `string` | | 原生 input 标签的 CSS 类名 |
|
||||
| nativeAutoComplete | `string` | `off` | 原生 input 标签的 `autoComplete` 属性,比如配置集成 `new-password` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | ---------------------------------------------- |
|
||||
| click | `[name]: string` 组件的值 | 点击输入框时触发,只针对选择器模式的输入框有效 |
|
||||
| enter | `[name]: string` 组件的值 | 回车时触发,只针对选择器模式的输入框有效 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点时触发 |
|
||||
| change | `[name]: string` 组件的值 | 值变化时触发 |
|
||||
| clear | `[name]: string` 组件的值 | 点击清除按钮时触发 |
|
||||
|
||||
### enter
|
||||
|
||||
选择器模式下,回车时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"options": [
|
||||
{
|
||||
"label": "aa",
|
||||
"value": "aa"
|
||||
},
|
||||
{
|
||||
"label": "bb",
|
||||
"value": "bb"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"enter": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### focus
|
||||
|
||||
当设置 `showInput` 为 true 时,输入框获取焦点时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"onEvent": {
|
||||
"focus": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### blur
|
||||
|
||||
当设置 `showInput` 为 true 时,输入框失去焦点时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"onEvent": {
|
||||
"blur": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### clear
|
||||
|
||||
配置`clearable`为 true,点击清除按钮时触发。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"clearable": true,
|
||||
"onEvent": {
|
||||
"clear": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | -------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 重置 |
|
||||
| focus | - | 获取焦点 |
|
||||
| reload | - | 刷新(重新加载),只针对配置了`source`的输入框有效 |
|
||||
| setValue | `value: string` 更新的值 | 更新数据,开启`multiple`多选时用`,`分隔 |
|
||||
|
||||
### clear
|
||||
|
||||
如果配置了`clearValueOnEmpty: true`,则清空时将置为`undefined`,否则置为空字符串。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "clear_text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"value": "清空我"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "reset_text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"value": "重置我"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### focus
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "focus_text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"value": "聚焦我"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "聚焦",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "focus",
|
||||
"componentId": "focus_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "reload_text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"value": "a",
|
||||
"source": "/api/mock2/form/getOptions?waitSeconds=1"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "setvalue_text",
|
||||
"type": "input-text",
|
||||
"label": "text",
|
||||
"value": "amis"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "amis go go go!"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
122
docs/zh-CN/components/form/input-time-range.md
Normal file
122
docs/zh-CN/components/form/input-time-range.md
Normal file
@@ -0,0 +1,122 @@
|
||||
---
|
||||
title: InputTimeRange 时间范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputTimeRange
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time-range",
|
||||
"name": "times",
|
||||
"label": "时间范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time-range",
|
||||
"name": "times",
|
||||
"label": "时间范围",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示秒
|
||||
|
||||
默认显示的是时和分,请参考以下配置,其中若`valueFormat`非时间戳格式时需与`displayFormat`精确度相同
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time-range",
|
||||
"name": "times",
|
||||
"label": "时间范围",
|
||||
"valueFormat": "HH:mm:ss",
|
||||
"displayFormat": "HH:mm:ss"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 存成两个字段
|
||||
|
||||
默认季度范围存储一个字段,用 `delimiter` 分割,如果配置 `extraName` 则会存两个字段。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time-range",
|
||||
"name": "begin",
|
||||
"extraName": "end",
|
||||
"label": "时间范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | --------- | ------------------ | --------------------------------------------------------------------- | ------- |
|
||||
| valueFormat | `string` | `HH:mm` | [时间范围选择器值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` |
|
||||
| displayFormat | `string` | `HH:mm` | [时间范围选择器显示格式](./date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` |
|
||||
| placeholder | `string` | `"请选择时间范围"` | 占位文本 |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| embed | `boolean` | `false` | 是否内联模式 |
|
||||
| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` |
|
||||
| extraName | `string` | | 是否存成两个字段 | `3.3.0` |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | -------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1617206400,1743436800' |
|
||||
283
docs/zh-CN/components/form/input-time.md
Executable file
283
docs/zh-CN/components/form/input-time.md
Executable file
@@ -0,0 +1,283 @@
|
||||
---
|
||||
title: InputTime 时间
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputTime 时间
|
||||
icon:
|
||||
order: 58
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示格式
|
||||
|
||||
选中任意时间,可以看到默认显示时间的格式是像`01:01`这样的格式,如果你想要自定义显示格式,那么可以配置`displayFormat`。
|
||||
|
||||
例如你想显示`01时01分`这样的格式,查找 moment 文档可知配置格式应为 `HH时mm分`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"displayFormat": "HH时mm分"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
调整时间,观察显示格式
|
||||
|
||||
## 值格式
|
||||
|
||||
选中任意时间,可以看到默认表单项的值格式是像`1591862818`这样的时间戳格式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果你想要其他格式的日期值,那么可以配置`valueFormat`参数用于调整表单项的值格式。
|
||||
|
||||
例如你调整值为`01:11`这样的格式,查找 moment 文档可知配置格式应为 `HH:mm`,即:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"valueFormat": "HH:mm"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
调整时间,观察数据域中表单项值的变化
|
||||
|
||||
## 显示秒
|
||||
|
||||
默认显示的是时和分,要显示秒可通过配置`displayFormat`实现,请参考以下配置,若配置`valueFormat`需与`displayFormat`精确度相同
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"valueFormat": "HH:mm:ss",
|
||||
"displayFormat": "HH:mm:ss"
|
||||
},
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time2",
|
||||
"label": "时间2",
|
||||
"displayFormat": "HH:mm:ss"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 默认值
|
||||
|
||||
可以设置`value`属性,设置日期选择器的默认值
|
||||
|
||||
### 基本配置
|
||||
|
||||
配置符合当前 [值格式](./date#%E5%80%BC%E6%A0%BC%E5%BC%8F) 的默认值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"value": "1591862818"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 相对值
|
||||
|
||||
`value` 还支持类似像`"+1hours"`这样的相对值,更加便捷的配置默认值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"value": "+1hours"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
上例中配置了`"value": "+1hours"`,默认就会选中一小时后。
|
||||
|
||||
支持的相对值关键字有:
|
||||
|
||||
- `now`: 当前时间
|
||||
- `hour`或`hours`: 时
|
||||
- `minute`或`minutes`: 分
|
||||
- `second`或`seconds`: 秒
|
||||
|
||||
## 控制输入范围
|
||||
|
||||
通过 `timeConstraints` 属性可以控制输入范围
|
||||
|
||||
默认值是
|
||||
|
||||
```json
|
||||
{
|
||||
"hours": {
|
||||
"min": 0,
|
||||
"max": 23,
|
||||
"step": 1
|
||||
},
|
||||
"minutes": {
|
||||
"min": 0,
|
||||
"max": 59,
|
||||
"step": 1
|
||||
},
|
||||
"seconds": {
|
||||
"min": 0,
|
||||
"max": 59,
|
||||
"step": 1
|
||||
},
|
||||
"milliseconds": {
|
||||
"min": 0,
|
||||
"max": 999,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
可以只修改其中的部分值,比如下面的示例将分钟每次加减改成了 15,小时的范围限制在 9 到 17
|
||||
|
||||
> 设置了`timeConstraints`后,点击「此刻」会选择最接近当前时间的有效值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-time",
|
||||
"name": "time",
|
||||
"label": "时间",
|
||||
"timeConstraints": {
|
||||
"hours": {
|
||||
"min": 9,
|
||||
"max": 17
|
||||
},
|
||||
"minutes": {
|
||||
"step": 15
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 原生时间组件
|
||||
|
||||
原生时间组件将直接使用浏览器的实现,最终展现效果和浏览器有关,而且只支持 `min`、`max`、`step` 这几个属性设置。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "native-time",
|
||||
"name": "time",
|
||||
"label": "时间"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | --------- | -------------- | ----------------------------------------------------------------------------------- | ---------------- |
|
||||
| value | `string` | | [默认值](./date#%E9%BB%98%E8%AE%A4%E5%80%BC) |
|
||||
| valueFormat | `string` | `X` | 时间选择器值格式,更多格式类型请参考 [moment](http://momentjs.com/) | 3.4.0 版本后支持 |
|
||||
| displayFormat | `string` | `HH:mm` | 时间选择器显示格式,即时间戳格式,更多格式类型请参考 [moment](http://momentjs.com/) | 3.4.0 版本后支持 |
|
||||
| placeholder | `string` | `"请选择时间"` | 占位文本 |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| timeConstraints | `object` | `true` | |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1648746120' |
|
||||
2150
docs/zh-CN/components/form/input-tree.md
Executable file
2150
docs/zh-CN/components/form/input-tree.md
Executable file
File diff suppressed because it is too large
Load Diff
160
docs/zh-CN/components/form/input-verification-code.md
Normal file
160
docs/zh-CN/components/form/input-verification-code.md
Normal file
@@ -0,0 +1,160 @@
|
||||
---
|
||||
title: 验证码输入 InputVerificationCode
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputVerificationCode 验证码
|
||||
icon:
|
||||
order: 63
|
||||
---
|
||||
|
||||
注意 InputVerificationCode, 可通过<b>粘贴</b>完成填充数据。
|
||||
|
||||
## 基本用法
|
||||
|
||||
基本用法。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-verification-code",
|
||||
"name": "verificationCode"
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 密码模式
|
||||
|
||||
指定 masked = true,可开启密码模式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-verification-code",
|
||||
"name": "verificationCode",
|
||||
"masked": true,
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义分隔符
|
||||
|
||||
指定 separator 可以自定义渲染分隔符。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-verification-code",
|
||||
"name": "verificationCode",
|
||||
"length": 9,
|
||||
"separator": "${((index + 1) % 3 || index > 7 ) ? null : '-'}",
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 状态
|
||||
|
||||
<p>指定 disabled = true,可开启禁用模式。</p>
|
||||
指定 readOnly = true,可开启只读模式。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-verification-code",
|
||||
"name": "verificationCodeDisabled",
|
||||
"value": "123456",
|
||||
"disabled": true,
|
||||
},
|
||||
{
|
||||
"type": "input-verification-code",
|
||||
"name": "verificationCodeReadOnly",
|
||||
"value": "987654",
|
||||
"readOnly": true,
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| --------- | --------- | ------ | ------------------------------------------------------------------------------ |
|
||||
| length | `number` | 6 | 验证码的长度,根据长度渲染对应个数的输入框 |
|
||||
| masked | `boolean` | false | 是否是密码模式 |
|
||||
| separator | `string` | | 分隔符,支持表达式, 表达式`只`可以访问 index、character 变量, 参考自定义分隔符 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | -------- | -------------------------- |
|
||||
| finish | - | 输入框都被填充后触发的回调 |
|
||||
| change | - | 输入值改变时触发的回调 |
|
||||
|
||||
### 事件
|
||||
|
||||
finish 输入框都被填充。可以尝试通过`${event.data.value}`获取填写的数据。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "input-verification-code",
|
||||
"onEvent": {
|
||||
"finish": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.data.value}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
change 输入值改变。可以尝试通过`${event.data.value}`获取填写的数据。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "input-verification-code",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "info",
|
||||
"msg": "${event.data.value}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
105
docs/zh-CN/components/form/input-year-range.md
Normal file
105
docs/zh-CN/components/form/input-year-range.md
Normal file
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: InputYearRange 年份范围
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: InputYearRange
|
||||
icon:
|
||||
order: 15
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-year-range",
|
||||
"name": "year-range",
|
||||
"label": "年份范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 内嵌模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "input-year-range",
|
||||
"name": "year-range",
|
||||
"label": "年份范围",
|
||||
"embed": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 存成两个字段
|
||||
|
||||
默认年份范围存储一个字段,用 `delimiter` 分割,如果配置 `extraName` 则会存两个字段。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-year-range",
|
||||
"name": "begin",
|
||||
"extraName": "end",
|
||||
"label": "年份范围"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ------------------------ | --------- | ------------------ | ---------------------------------------------------------------------------------- | ------- |
|
||||
| valueFormat | `string` | `X` | [年份选择器值格式](./input-date#%E5%80%BC%E6%A0%BC%E5%BC%8F) | `3.4.0` |
|
||||
| displayFormat | `string` | `YYYY` | [年份选择器显示格式](./input-date#%E6%98%BE%E7%A4%BA%E6%A0%BC%E5%BC%8F) | `3.4.0` |
|
||||
| placeholder | `string` | `"请选择年份范围"` | 占位文本 |
|
||||
| minDate | `string` | | 限制最小日期,用法同 [限制范围](./input-date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| maxDate | `string` | | 限制最大日期,用法同 [限制范围](./input-date#%E9%99%90%E5%88%B6%E8%8C%83%E5%9B%B4) |
|
||||
| minDuration | `string` | | 限制最小跨度,如: 2year |
|
||||
| maxDuration | `string` | | 限制最大跨度,如:4year |
|
||||
| utc | `boolean` | `false` | [保存 UTC 值](./input-date#utc) |
|
||||
| clearable | `boolean` | `true` | 是否可清除 |
|
||||
| embed | `boolean` | `false` | 是否内联模式 |
|
||||
| animation | `boolean` | `true` | 是否启用游标动画 | `2.2.0` |
|
||||
| popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | `6.4.0` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | -------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间区间值,用`,`隔开 | 更新数据,依赖格式`format`,例如 '1648746120,1648760760' |
|
||||
49
docs/zh-CN/components/form/input-year.md
Normal file
49
docs/zh-CN/components/form/input-year.md
Normal file
@@ -0,0 +1,49 @@
|
||||
---
|
||||
title: Year 年份选择
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Year 年份选择
|
||||
icon:
|
||||
order: 61
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "input-year",
|
||||
"name": "year",
|
||||
"label": "年份选择"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
更多用法和配置可以参考 [InputDate 日期](input-date),year 就是 data 的特定配置,所以 data 的所有配置都能使用。
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值 | 时间值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ---------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` 更新的时间值 | 更新数据,依赖格式`format`,例如:'1617206400' |
|
||||
220
docs/zh-CN/components/form/json-schema-editor.md
Normal file
220
docs/zh-CN/components/form/json-schema-editor.md
Normal file
@@ -0,0 +1,220 @@
|
||||
---
|
||||
title: JSONSchema Editor
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: JSONSchema Editor
|
||||
icon:
|
||||
order: 61
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
> 1.9.0 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
debug: true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema-editor",
|
||||
"name": "schema",
|
||||
"label": "字段类型"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 顶级类型可配置
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema-editor",
|
||||
"name": "schema",
|
||||
"label": "字段类型",
|
||||
"rootTypeMutable": true,
|
||||
"showRootInfo": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 预设类型
|
||||
|
||||
通过设置 definitions 属性可以提供一些默认类型,可以减少类型的定义成本。
|
||||
|
||||
```schema: scope="form-item"
|
||||
{
|
||||
label: 'JSON Schema Editor',
|
||||
name: 'schema',
|
||||
// showRootInfo: true,
|
||||
// rootTypeMutable: true,
|
||||
type: 'json-schema-editor',
|
||||
disabledTypes: ['null', 'interger', 'boolean'],
|
||||
definitions: {
|
||||
user: {
|
||||
type: 'object',
|
||||
title: '用户',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '用户名',
|
||||
description: '用户名信息'
|
||||
},
|
||||
|
||||
id: {
|
||||
type: 'interger',
|
||||
title: '用户ID'
|
||||
},
|
||||
|
||||
email: {
|
||||
type: 'string',
|
||||
title: '用户邮箱'
|
||||
},
|
||||
|
||||
displayName: {
|
||||
type: 'string',
|
||||
title: '用户昵称'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 开启高级配置
|
||||
|
||||
通过 `enableAdvancedSetting` 可以开启高级配置,同时通过 `advancedSettings` 可以定制弹窗中的配置面板。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema-editor",
|
||||
"name": "schema",
|
||||
"label": "字段类型",
|
||||
"enableAdvancedSetting": true,
|
||||
"advancedSettings": {
|
||||
"string": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "maxLength",
|
||||
"label": "Max Length"
|
||||
}
|
||||
],
|
||||
"number": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "max",
|
||||
"label": "Max"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Mini 版本
|
||||
|
||||
通过设置 `mini` 属性可以开启 mini 版本,适用于宽度窄的情况。同时通过 `advancedSettings` 可以定制弹窗中的配置面板。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema-editor",
|
||||
"name": "schema",
|
||||
"label": "字段类型",
|
||||
"mini": true,
|
||||
"style": {
|
||||
"width": 300
|
||||
},
|
||||
"advancedSettings": {
|
||||
"string": [
|
||||
{
|
||||
"type": "input-text",
|
||||
"name": "maxLength",
|
||||
"label": "Max Length"
|
||||
}
|
||||
],
|
||||
"number": [
|
||||
{
|
||||
"type": "input-number",
|
||||
"name": "max",
|
||||
"label": "Max"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 占位提示
|
||||
|
||||
> 2.8.0 及以上版本
|
||||
|
||||
设置`placeholder`属性,可以修改属性控件的默认占位提示文本,当前属性值会和默认值做合并
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema-editor",
|
||||
"name": "schema",
|
||||
"label": "字段类型",
|
||||
"enableAdvancedSetting": true,
|
||||
"placeholder": {
|
||||
"key": "请输入字段名称",
|
||||
"title": "请输入名称",
|
||||
"description": "请输入描述信息",
|
||||
"default": "",
|
||||
"empty": "暂无字段"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| --------------- | ----------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ------- |
|
||||
| rootTypeMutable | `boolean` | false | 顶级类型是否可配置 |
|
||||
| showRootInfo | `boolean` | false | 是否显示顶级类型信息 |
|
||||
| disabledTypes | `Array<string>` | | 用来禁用默认数据类型,默认类型有:string、number、interger、object、number、array、boolean、null |
|
||||
| definitions | `object` | | 用来配置预设类型 |
|
||||
| mini | `boolean` | | 用来开启迷你模式,适应于边栏面板,宽度较低的情况 |
|
||||
| placeholder | `SchemaEditorItemPlaceholder` | `{key: "字段名", title: "名称", description: "描述", default: "默认值", empty: "<空>",}` | 属性输入控件的占位提示文本 | `2.8.0` |
|
||||
|
||||
### SchemaEditorItemPlaceholder
|
||||
|
||||
```typescript
|
||||
interface SchemaEditorItemPlaceholder {
|
||||
/* 字段名称输入框占位文本 */
|
||||
key?: string;
|
||||
/* 名称输入框占位文本 */
|
||||
title?: string;
|
||||
/* 描述信息输入框占位文本 */
|
||||
description?: string;
|
||||
/* 默认值输入框占位文本 */
|
||||
default?: string;
|
||||
/* 默认值输入框占位文本 */
|
||||
empty?: string;
|
||||
}
|
||||
```
|
||||
272
docs/zh-CN/components/form/json-schema.md
Normal file
272
docs/zh-CN/components/form/json-schema.md
Normal file
@@ -0,0 +1,272 @@
|
||||
---
|
||||
title: JSONSchema
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: JSONSchema
|
||||
icon:
|
||||
order: 61
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
> 1.10.0 及以上版本
|
||||
|
||||
这个组件可以基于 JSON Schema 生成表单项,方便对接类似 OpenAPI/Swagger Specification 的接口规范,可基于接口定义自动生成 amis 表单项。
|
||||
|
||||
> 此组件还在实验阶段,很多 json-schema 属性没有对应实现,使用前请先确认你要的功能满足了需求
|
||||
|
||||
基于 json-schema 定义生成表单输入项。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
debug: true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema",
|
||||
"name": "value",
|
||||
"label": "字段值",
|
||||
"schema": {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'number',
|
||||
title: 'ID'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '名称'
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
title: '描述'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 复杂 case
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
debug: true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema",
|
||||
"name": "value",
|
||||
"label": "字段值",
|
||||
"schema": {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['id', 'name'],
|
||||
properties: {
|
||||
id: {
|
||||
type: 'number',
|
||||
title: 'ID'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '名称'
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
title: '描述'
|
||||
},
|
||||
date: {
|
||||
type: 'object',
|
||||
title: '日期',
|
||||
additionalProperties: false,
|
||||
required: ['year', 'month', 'day'],
|
||||
properties: {
|
||||
year: {
|
||||
type: 'number',
|
||||
title: '年'
|
||||
},
|
||||
month: {
|
||||
type: 'number',
|
||||
title: '月'
|
||||
},
|
||||
day: {
|
||||
type: 'number',
|
||||
title: '日'
|
||||
}
|
||||
}
|
||||
},
|
||||
tag: {
|
||||
type: 'array',
|
||||
title: '个人标签',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minContains: 2,
|
||||
maxContains: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 搭配公式使用
|
||||
|
||||
> 6.4.0 及以上版本
|
||||
|
||||
通过配置 `formula` 属性,可以配合公式使用。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
debug: true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema",
|
||||
"name": "value",
|
||||
"label": "字段值",
|
||||
"schema": {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['id', 'name'],
|
||||
properties: {
|
||||
id: {
|
||||
type: 'number',
|
||||
title: 'ID'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '名称'
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
title: '描述'
|
||||
},
|
||||
date: {
|
||||
type: 'object',
|
||||
title: '日期',
|
||||
additionalProperties: false,
|
||||
required: ['year', 'month', 'day'],
|
||||
properties: {
|
||||
year: {
|
||||
type: 'number',
|
||||
title: '年'
|
||||
},
|
||||
month: {
|
||||
type: 'number',
|
||||
title: '月'
|
||||
},
|
||||
day: {
|
||||
type: 'number',
|
||||
title: '日'
|
||||
}
|
||||
}
|
||||
},
|
||||
tag: {
|
||||
type: 'array',
|
||||
title: '个人标签',
|
||||
items: {
|
||||
type: 'string'
|
||||
},
|
||||
minContains: 2,
|
||||
maxContains: 10
|
||||
}
|
||||
}
|
||||
},
|
||||
"formula": {
|
||||
"mode":"input-group",
|
||||
"mixedMode": true,
|
||||
"variables": [
|
||||
{
|
||||
"label": "表单字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "文章名",
|
||||
"value": "name",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "作者",
|
||||
"value": "author",
|
||||
"tag": "文本"
|
||||
},
|
||||
{
|
||||
"label": "售价",
|
||||
"value": "price",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版时间",
|
||||
"value": "time",
|
||||
"tag": "时间"
|
||||
},
|
||||
{
|
||||
"label": "版本号",
|
||||
"value": "version",
|
||||
"tag": "数字"
|
||||
},
|
||||
{
|
||||
"label": "出版社",
|
||||
"value": "publisher",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "流程字段",
|
||||
"children": [
|
||||
{
|
||||
"label": "联系电话",
|
||||
"value": "telphone"
|
||||
},
|
||||
{
|
||||
"label": "地址",
|
||||
"value": "addr"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "长文本测试分类长文本测试分类长文本测试分类长文本测试分类",
|
||||
"children": [
|
||||
{
|
||||
"label": "这是一段测试长文本这是一段测试长文本这是一段测试长文本",
|
||||
"value": "longtext",
|
||||
"tag": "文本"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 远程获取 schema
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
debug: true,
|
||||
"body": [
|
||||
{
|
||||
"type": "json-schema",
|
||||
"name": "value",
|
||||
"label": "字段值",
|
||||
"schema": "/api/mock2/json-schema"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------ | -------------------- | ------ | ---------------- |
|
||||
| schema | `object` \| `string` | | 指定 json-schema |
|
||||
322
docs/zh-CN/components/form/list-select.md
Executable file
322
docs/zh-CN/components/form/list-select.md
Executable file
@@ -0,0 +1,322 @@
|
||||
---
|
||||
title: ListSelect 列表
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: ListSelect
|
||||
icon:
|
||||
order: 29
|
||||
---
|
||||
|
||||
ListSelect 一般用来实现选择,可以单选也可以多选,和 Radio/Checkboxs 最大的不同是在展现方面支持带图片。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "单选",
|
||||
"clearable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 选项带图片
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "图片",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d",
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------- | ----------------------------------------- | --------- | ------------------------------------------------------------------------------------------- |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./options#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| multiple | `boolean` | `false` | [多选](./options#%E5%A4%9A%E9%80%89-multiple) |
|
||||
| labelField | `string` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `string` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| joinValues | `boolean` | `true` | [拼接值](./options#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) |
|
||||
| extractValue | `boolean` | `false` | [提取值](./options#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue) |
|
||||
| autoFill | `object` | | [自动填充](./options#%E8%87%AA%E5%8A%A8%E5%A1%AB%E5%85%85-autofill) |
|
||||
| listClassName | `string` | | 支持配置 list div 的 css 类名。比如: `flex justify-between` |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------- | ---------------- |
|
||||
| change | `[name]: string` 组件的值 | 选中值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "单选",
|
||||
"clearable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
|
||||
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "单选",
|
||||
"clearable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
}
|
||||
],
|
||||
"value": "a",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "单选",
|
||||
"clearable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
}
|
||||
],
|
||||
"value": "a",
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "单选",
|
||||
"clearable": true,
|
||||
"id": "reload_type",
|
||||
"source": "/api/mock2/form/getOptions?waitSeconds=1",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "单选",
|
||||
"clearable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "Option A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "Option B",
|
||||
"value": "b"
|
||||
}
|
||||
],
|
||||
"value": "a",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "b"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
297
docs/zh-CN/components/form/location-picker.md
Normal file
297
docs/zh-CN/components/form/location-picker.md
Normal file
@@ -0,0 +1,297 @@
|
||||
---
|
||||
title: LocationPicker 地理位置
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: LocationPicker
|
||||
icon:
|
||||
order: 30
|
||||
---
|
||||
|
||||
用于选择地理位置
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
|
||||
"label": "地址"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
注意其中的 `ak` 参数只能在 amis 官网示例中使用,请前往[百度地图开放平台](http://lbsyun.baidu.com/)申请自己的 `ak`。
|
||||
|
||||
## 静态展示
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
|
||||
"label": "默认展示方式",
|
||||
"value": {
|
||||
"address": "北京市西城区复兴门内大街97号",
|
||||
"lat": 39.91404014231763,
|
||||
"lng": 116.36857981150743,
|
||||
"zoom": 12
|
||||
},
|
||||
"static": true
|
||||
},
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
|
||||
"label": "内嵌地图展示",
|
||||
"value": {
|
||||
"address": "北京市西城区复兴门内大街97号",
|
||||
"lat": 39.91404014231763,
|
||||
"lng": 116.36857981150743,
|
||||
"zoom": 12
|
||||
},
|
||||
"static": true,
|
||||
"staticSchema": {
|
||||
"embed": true,
|
||||
"showAddress": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 高德地图(暂不支持)
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"vendor": "gaode",
|
||||
"ak": "8ae6a7549ce3f37f8e5aab9d445df8ad",
|
||||
"label": "地址"
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
高德地图需要设置 `vendor` 为 `gaode`,并且需要设置 `ak`。其中的 ak 参数为随机值, 请替换为自己申请的 `ak` , 高德地图的 `ak` 申请地址:[高德地图开放平台](https://lbs.amap.com/)
|
||||
|
||||
请注意: **_高德地图不支持坐标转换_**
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------------------ | ------------------ | ------------------------------------ | -------------------------------------------------------------------------------- |
|
||||
| value | `LocationData` | 参考 [`LocationData`](#LocationData) | |
|
||||
| vendor | 'baidu' \| 'gaode' | 'baidu' | 地图厂商,目前只实现了百度地图和高德地图 |
|
||||
| ak | `string` | 无 | 百度/高德地图的 ak |
|
||||
| clearable | `boolean` | false | 输入框是否可清空 |
|
||||
| placeholder | `string` | '请选择位置' | 默认提示 |
|
||||
| autoSelectCurrentLoc | `boolean` | false | 是否自动选中当前地理位置 |
|
||||
| onlySelectCurrentLoc | `boolean` | false | 是否限制只能选中当前地理位置,设置为 true 后,可用于充当定位组件 |
|
||||
| coordinatesType | 'bd09' \| 'gcj02' | 'bd09' | 坐标系类型,默认百度坐标,使用高德地图时应设置为'gcj02', 高德地图不支持坐标转换 |
|
||||
| staticSchema | `object` | | 静态展示,内嵌模式`{static: true: embed: true}`时的额外配置 |
|
||||
| staticSchema.embed | `boolean` | false | 是否内嵌地图展示地理位置 |
|
||||
| staticSchema.showAddress | `boolean` | true | 内嵌模式是否展示文字地址 |
|
||||
| staticSchema.showGeoLoc | `boolean` | false | 内嵌模式是否展示定位当当前控件 |
|
||||
| staticSchema.mapStyle | `object` | | 内嵌模式地图的样式,可以传宽高控制大小 |
|
||||
|
||||
### 坐标系说明
|
||||
|
||||
- bd09:百度坐标系,在 GCJ02 坐标系基础上再次加密。
|
||||
- gcj02:火星坐标系,是由中国国家测绘局制定的地理坐标系统。
|
||||
|
||||
### LocationData
|
||||
|
||||
| 属性值 | 类型 | 是否必填 | 说明 |
|
||||
| ------- | ------------------ | -------- | ----------------------- |
|
||||
| address | `string` | 是 | 地址信息 |
|
||||
| lng | `number` | 是 | 经度,范围:[-180, 180] |
|
||||
| lat | `number` | 是 | 维度,范围:[-90, 90] |
|
||||
| vendor | 'baidu' \| 'gaode' | 否 | 地图厂商类型 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------- | ---------------- |
|
||||
| change | `[name]: LocationData` 组件的值 | 选中值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
|
||||
"label": "地址",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value` | 参考 [`LocationData`](#LocationData) |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
|
||||
"label": "地址",
|
||||
"value": {
|
||||
"address":"北京市西城区府右街131号",
|
||||
"lat":39.916383659908185,
|
||||
"lng":116.38854914523102,
|
||||
"city":"北京市",
|
||||
"vendor":"baidu"
|
||||
},
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
|
||||
"label": "地址",
|
||||
"value": {
|
||||
"address":"北京市西城区府右街131号",
|
||||
"lat":39.916383659908185,
|
||||
"lng":116.38854914523102,
|
||||
"city":"北京市",
|
||||
"vendor":"baidu"
|
||||
},
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "location-picker",
|
||||
"name": "location",
|
||||
"ak": "LiZT5dVbGTsPI91tFGcOlSpe5FDehpf7",
|
||||
"label": "地址",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": {
|
||||
"address":"北京市西城区府右街131号",
|
||||
"lat":39.916383659908185,
|
||||
"lng":116.38854914523102,
|
||||
"city":"北京市",
|
||||
"vendor":"baidu"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
639
docs/zh-CN/components/form/matrix-checkboxes.md
Executable file
639
docs/zh-CN/components/form/matrix-checkboxes.md
Executable file
@@ -0,0 +1,639 @@
|
||||
---
|
||||
title: MatrixCheckboxes 矩阵
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: MatrixCheckboxes
|
||||
icon:
|
||||
order: 30
|
||||
---
|
||||
|
||||
矩阵类型的输入框。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 全选
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"xCheckAll": true,
|
||||
"yCheckAll": true,
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 单选模式
|
||||
|
||||
配置`"multiple": false`可以设置单选,配置`singleSelectMode`可以设置单选模式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"multiple": false,
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动态选项
|
||||
|
||||
可以配置 source 渲染动态选项
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "matrix",
|
||||
"type": "matrix-checkboxes",
|
||||
"label": "动态矩阵组件",
|
||||
"source": "/api/mock2/options/matrix?waitSeconds=1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
以上面为例,source 接口返回格式如下:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "ok",
|
||||
"data": {
|
||||
"columns": [
|
||||
{
|
||||
"label": "Col A",
|
||||
"col": "a"
|
||||
},
|
||||
{
|
||||
"label": "Col B",
|
||||
"col": "b"
|
||||
},
|
||||
{
|
||||
"label": "Col C",
|
||||
"col": "c"
|
||||
},
|
||||
{
|
||||
"label": "Col D",
|
||||
"col": "d"
|
||||
},
|
||||
{
|
||||
"label": "Col E",
|
||||
"col": "e"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "Row 1",
|
||||
"rol": 1
|
||||
},
|
||||
{
|
||||
"label": "Row 2",
|
||||
"rol": 2
|
||||
},
|
||||
{
|
||||
"label": "Row 3",
|
||||
"rol": 3
|
||||
},
|
||||
{
|
||||
"label": "Row 4",
|
||||
"rol": 4
|
||||
},
|
||||
{
|
||||
"label": "Row 5",
|
||||
"rol": 5
|
||||
},
|
||||
{
|
||||
"label": "Row 6",
|
||||
"rol": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### column 模式
|
||||
|
||||
默认为 column 模式,即每列只能单选某个单元格
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"multiple": false,
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### cell 模式
|
||||
|
||||
cell 模式,指全部选项中只能单选某个单元格
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"multiple": false,
|
||||
"singleSelectMode": "cell",
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### row 模式
|
||||
|
||||
row 模式,每行只能单选某个单元格
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"multiple": false,
|
||||
"singleSelectMode": "row",
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------------- | ------------------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| columns | `Array<column>` | | 列信息,数组中 `label` 字段是必须给出的 |
|
||||
| rows | `Array<row>` | | 行信息, 数组中 `label` 字段是必须给出的 |
|
||||
| rowLabel | `string` | | 行标题说明 |
|
||||
| source | [API](../../../docs/types/api) | | Api 地址,如果选项组不固定,可以通过配置 `source` 动态拉取。 |
|
||||
| multiple | `boolean` | `true` | 是否多选 |
|
||||
| singleSelectMode | `string` | `"column"` | 设置单选模式,`multiple`为`false`时有效,可设置为`cell`, `row`, `column` 分别为全部选项中只能单选某个单元格、每行只能单选某个单元格,每列只能单选某个单元格 |
|
||||
| textAlign | `string` | `"center"` | 当开启多选+全选时,默认为'left' |
|
||||
| yCheckAll | `boolean` | `false` | 列上的全选 |
|
||||
| xCheckAll | `boolean` | `false` | 行上的全选 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------ | ---------------- |
|
||||
| change | `[name]: Array` 组件的值 | 选中值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ----------------------- | ------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
|
||||
| setValue | `value: Array` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
],
|
||||
"value": [
|
||||
[
|
||||
{
|
||||
"label": "列1",
|
||||
"checked": true
|
||||
},
|
||||
{
|
||||
"label": "列1",
|
||||
"checked": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "列2",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"label": "列2",
|
||||
"checked": true
|
||||
}
|
||||
]
|
||||
],
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
],
|
||||
"value": [
|
||||
[
|
||||
{
|
||||
"label": "列1",
|
||||
"checked": true
|
||||
},
|
||||
{
|
||||
"label": "列1",
|
||||
"checked": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "列2",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"label": "列2",
|
||||
"checked": true
|
||||
}
|
||||
]
|
||||
],
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "list-select",
|
||||
"name": "select",
|
||||
"label": "单选",
|
||||
"clearable": true,
|
||||
"id": "reload_type",
|
||||
"source": "/api/mock2/form/getOptions?waitSeconds=1",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "matrix-checkboxes",
|
||||
"name": "matrix",
|
||||
"label": "Matrix",
|
||||
"rowLabel": "行标题说明",
|
||||
"columns": [
|
||||
{
|
||||
"label": "列1"
|
||||
},
|
||||
{
|
||||
"label": "列2"
|
||||
}
|
||||
],
|
||||
"rows": [
|
||||
{
|
||||
"label": "行1"
|
||||
},
|
||||
{
|
||||
"label": "行2"
|
||||
}
|
||||
],
|
||||
"value": "a",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": [
|
||||
[
|
||||
{
|
||||
"label": "列1",
|
||||
"checked": true
|
||||
},
|
||||
{
|
||||
"label": "列1",
|
||||
"checked": true
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"label": "列2",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"label": "列2",
|
||||
"checked": true
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
1069
docs/zh-CN/components/form/nestedselect.md
Executable file
1069
docs/zh-CN/components/form/nestedselect.md
Executable file
File diff suppressed because it is too large
Load Diff
1644
docs/zh-CN/components/form/options.md
Executable file
1644
docs/zh-CN/components/form/options.md
Executable file
File diff suppressed because it is too large
Load Diff
1371
docs/zh-CN/components/form/picker.md
Executable file
1371
docs/zh-CN/components/form/picker.md
Executable file
File diff suppressed because it is too large
Load Diff
321
docs/zh-CN/components/form/radio.md
Normal file
321
docs/zh-CN/components/form/radio.md
Normal file
@@ -0,0 +1,321 @@
|
||||
---
|
||||
title: Radio 单选框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Radio
|
||||
icon:
|
||||
order: 8
|
||||
---
|
||||
|
||||
实现组合中的单选功能,此组件只有在 `combo` 和 `input-table` 中有意义。
|
||||
|
||||
## combo 中使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
data: {
|
||||
answers: [
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 1'
|
||||
},
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 2',
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
type: 'combo',
|
||||
label: '可选答案',
|
||||
name: 'answers',
|
||||
multiple: true,
|
||||
addable: true,
|
||||
strictMode: false,
|
||||
items: [
|
||||
{
|
||||
type: 'radio',
|
||||
name: 'isAnswer',
|
||||
columnClassName: 'no-grow'
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'answer',
|
||||
placeholder: '答案文案'
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## input-table 中使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
data: {
|
||||
answers: [
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 1'
|
||||
},
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 2',
|
||||
children: [
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 1'
|
||||
},
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 2'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
type: 'input-table',
|
||||
label: '可选答案',
|
||||
name: 'answers',
|
||||
multiple: true,
|
||||
addable: true,
|
||||
strictMode: false,
|
||||
columns: [
|
||||
{
|
||||
label: '',
|
||||
type: 'radio',
|
||||
name: 'isAnswer',
|
||||
},
|
||||
{
|
||||
label: '答案文案',
|
||||
type: 'input-text',
|
||||
name: 'answer',
|
||||
placeholder: '答案文案'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配置真假值
|
||||
|
||||
默认情况:
|
||||
|
||||
- 单选框勾选时,表单项值为:true
|
||||
- 单选框取消勾选时,表单项值为:false
|
||||
|
||||
如果你想调整这个值,可以配置`trueValue`和`falseValue`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
data: {
|
||||
answers: [
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 1'
|
||||
},
|
||||
{
|
||||
isAnswer: false,
|
||||
answer: '选项 2',
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
type: 'combo',
|
||||
label: '可选答案',
|
||||
name: 'answers',
|
||||
multiple: true,
|
||||
addable: true,
|
||||
strictMode: false,
|
||||
items: [
|
||||
{
|
||||
type: 'radio',
|
||||
name: 'isAnswer',
|
||||
columnClassName: 'no-grow',
|
||||
trueValue: 1,
|
||||
falseValue: 0
|
||||
},
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'answer',
|
||||
placeholder: '答案文案'
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------- | ------------------------- | ------- | -------- |
|
||||
| option | `string` | | 选项说明 |
|
||||
| trueValue | `string|number|boolean` | `true` | 标识真值 |
|
||||
| falseValue | `string|number|boolean` | `false` | 标识假值 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`来获取事件产生的数据(`< 2.3.2 及以下版本 为 ${event.data.[事件参数名]}`),详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | -------------------------- | ------------------ |
|
||||
| change | `[name]: boolean` 组件的值 | 选中状态变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "radio",
|
||||
"name": "radio",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------------- | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string \|number \|boolean` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "radio",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "clear_type",
|
||||
"option": "选项说明",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "radio",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "reset_type",
|
||||
"option": "选项说明",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"type": "radio",
|
||||
"label": "选项",
|
||||
"name": "type",
|
||||
"id": "setvalue_type",
|
||||
"option": "选项说明",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_type",
|
||||
"args": {
|
||||
"value": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
508
docs/zh-CN/components/form/radios.md
Normal file
508
docs/zh-CN/components/form/radios.md
Normal file
@@ -0,0 +1,508 @@
|
||||
---
|
||||
title: Radios 单选框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Radios 单选框
|
||||
icon:
|
||||
order: 36
|
||||
---
|
||||
|
||||
用于实现单选。
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 列显示
|
||||
|
||||
设置 `inline` 可以纵向显示,用于显示列很多的情况
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"inline": false,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 控制列显示的分裂
|
||||
|
||||
通过 columnsCount 来设置列显示的列数,比如下面例子是两列。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"inline": false,
|
||||
"columnsCount": 2,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 默认选择第一个
|
||||
|
||||
通过 `selectFirst` 属性配置
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"selectFirst": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动态选项
|
||||
|
||||
可以配置 `source` 来从上下文或远程 api 拉取选项数据
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"data": {
|
||||
"items": [
|
||||
{
|
||||
"label": "A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"label": "选项",
|
||||
"type": "radios",
|
||||
"name": "radios",
|
||||
"source": "${items}"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
远程 api
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"body": {
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"label": "选项",
|
||||
"type": "radios",
|
||||
"name": "radios",
|
||||
"source": "/api/mock2/form/getOptions?waitSeconds=1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
api 返回内容需要包含 options 字段
|
||||
|
||||
```json
|
||||
{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
"data": {
|
||||
"value": "b", // 可选,如果返回就会自动选中 b 选项
|
||||
// 必须用 options 作为选项组的 key 值
|
||||
"options": [
|
||||
{
|
||||
"label": "A",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "B",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "C",
|
||||
"value": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------ | ----------------------------------------- | --------- | ------------------------------------------------------------------------------------------- |
|
||||
| options | `Array<object>`或`Array<string>` | | [选项组](./options#%E9%9D%99%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-options) |
|
||||
| source | `string`或 [API](../../../docs/types/api) | | [动态选项组](./options#%E5%8A%A8%E6%80%81%E9%80%89%E9%A1%B9%E7%BB%84-source) |
|
||||
| labelField | `string` | `"label"` | [选项标签字段](./options#%E9%80%89%E9%A1%B9%E6%A0%87%E7%AD%BE%E5%AD%97%E6%AE%B5-labelfield) |
|
||||
| valueField | `string` | `"value"` | [选项值字段](./options#%E9%80%89%E9%A1%B9%E5%80%BC%E5%AD%97%E6%AE%B5-valuefield) |
|
||||
| columnsCount | `number` | `1` | 选项按几列显示,默认为一列 |
|
||||
| inline | `boolean` | `true` | 是否显示为一行 |
|
||||
| selectFirst | `boolean` | `false` | 是否默认选中第一个 |
|
||||
| autoFill | `object` | | [自动填充](./options#%E8%87%AA%E5%8A%A8%E5%A1%AB%E5%85%85-autofill) |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | --------------------------------------------------------------------------------------------- | ---------------- |
|
||||
| change | `[name]: string` 组件的值<br/>`selectedItems: Option` 选中的项<br/>`items: Option[]` 选项集合 | 选中值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
],
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msg": "${event.data.value|json}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| reload | - | 重新加载,调用 `source`,刷新数据域数据刷新(重新加载) |
|
||||
| setValue | `value: string` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
],
|
||||
"value": "a",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
],
|
||||
"value": "a",
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reload
|
||||
|
||||
只有选择器模式支持,即配置`source`,用于重新加载选择器的数据源。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"id": "reload_type",
|
||||
"source": "/api/mock2/form/getOptions",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重新加载",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reload",
|
||||
"componentId": "reload_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "radios",
|
||||
"type": "radios",
|
||||
"label": "radios",
|
||||
"options": [
|
||||
{
|
||||
"label": "OptionA",
|
||||
"value": "a"
|
||||
},
|
||||
{
|
||||
"label": "OptionB",
|
||||
"value": "b"
|
||||
},
|
||||
{
|
||||
"label": "OptionC",
|
||||
"value": "c"
|
||||
},
|
||||
{
|
||||
"label": "OptionD",
|
||||
"value": "d"
|
||||
}
|
||||
],
|
||||
"value": "a",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "b"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
1814
docs/zh-CN/components/form/select.md
Executable file
1814
docs/zh-CN/components/form/select.md
Executable file
File diff suppressed because it is too large
Load Diff
303
docs/zh-CN/components/form/static.md
Executable file
303
docs/zh-CN/components/form/static.md
Executable file
@@ -0,0 +1,303 @@
|
||||
---
|
||||
title: Static 静态展示
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Static 静态展示
|
||||
icon:
|
||||
order: 52
|
||||
---
|
||||
|
||||
> 推荐在`2.4.0`版本后使用[新版静态展示](./formitem#配置静态展示)来实现该功能
|
||||
> 常用表单项已支持静态展示:[支持静态展示的表单项](./formitem#支持静态展示的表单项),展示效果请查看[示例页](../../../examples/form/switchDisplay)
|
||||
> 新版静态展示还可以实现整个表单的静态展示及切换,具体用法请参考[表单静态展示](./index#表单静态展示)
|
||||
|
||||
用来在表单中,展示静态数据
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "static",
|
||||
"type": "static",
|
||||
"label": "静态展示",
|
||||
"value": "aaa"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 数据域变量映射
|
||||
|
||||
除了显式配置`value`属性,来展示数据以外,支持通过配置`name`属性,来自动映射数据域中的相关变量
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "select",
|
||||
"name": "select",
|
||||
"label": "select",
|
||||
"options": [
|
||||
{
|
||||
"label":"A",
|
||||
"value":"a"
|
||||
},
|
||||
{
|
||||
"label":"B",
|
||||
"value":"b"
|
||||
},
|
||||
{
|
||||
"label":"C",
|
||||
"value":"c"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "static",
|
||||
"name": "select",
|
||||
"label": "选中的值是"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 展示其他组件
|
||||
|
||||
支持通过配置`type`为`static-xxx`的形式,展示其他 **非[表单项](./formitem)** 组件,例如:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"type": "static-json",
|
||||
"name": "json",
|
||||
"label": "静态展示JSON",
|
||||
"value": {
|
||||
"a": "aaa",
|
||||
"b": "bbb"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
理论上可以支持所有非表达项的所有组件,并且支持对应的配置项,下面是一些示例:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"data": {
|
||||
"id": 1,
|
||||
"image": "https://suda.cdn.bcebos.com/amis/images/alice-macaw.jpg",
|
||||
"images": [
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692722/4f3cb4202335.jpeg"
|
||||
},
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395692942/d8e4992057f9.jpeg"
|
||||
},
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693148/1314a2a3d3f6.jpeg"
|
||||
},
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693379/8f2e79f82be0.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693379/8f2e79f82be0.jpeg"
|
||||
},
|
||||
{
|
||||
"image": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693566/552b175ef11d.jpeg@s_0,w_216,l_1,f_jpg,q_80",
|
||||
"src": "https://internal-amis-res.cdn.bcebos.com/images/2020-1/1578395693566/552b175ef11d.jpeg"
|
||||
}
|
||||
]
|
||||
},
|
||||
"api": "/api/mock2/saveForm?waitSeconds=2",
|
||||
"title": "表单项静态展示",
|
||||
"mode": "horizontal",
|
||||
"body": [
|
||||
{
|
||||
"type": "static",
|
||||
"label": "文本",
|
||||
"value": "文本"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-tpl",
|
||||
"label": "模板",
|
||||
"tpl": "自己拼接 HTML 取变量 \\${id}: ${id}"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-date",
|
||||
"label": "日期",
|
||||
"value": 1593327764
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-datetime",
|
||||
"label": "日期时间",
|
||||
"value": 1593327764
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-mapping",
|
||||
"label": "映射",
|
||||
"value": 2,
|
||||
"map": {
|
||||
"0": "<span class='label label-info'>一</span>",
|
||||
"1": "<span class='label label-success'>二</span>",
|
||||
"2": "<span class='label label-danger'>三</span>",
|
||||
"3": "<span class='label label-warning'>四</span>",
|
||||
"4": "<span class='label label-primary'>五</span>",
|
||||
"*": "<span class='label label-default'>-</span>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-progress",
|
||||
"label": "进度",
|
||||
"value": 66.66
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-image",
|
||||
"label": "图片",
|
||||
"name": "image",
|
||||
"thumbMode": "cover",
|
||||
"thumbRatio": "4:3",
|
||||
"title": "233",
|
||||
"imageCaption": "jfe fjkda fejfkda fejk fdajf dajfe jfkda",
|
||||
"popOver": {
|
||||
"title": "查看大图",
|
||||
"body": "<div class=\"w-xxl\"><img class=\"w-full\" src=\"${image}\"/></div>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-image",
|
||||
"label": "图片自带放大",
|
||||
"name": "image",
|
||||
"thumbMode": "cover",
|
||||
"thumbRatio": "4:3",
|
||||
"title": "233",
|
||||
"imageCaption": "jfe fjkda fejfkda fejk fdajf dajfe jfkda",
|
||||
"enlargeAble": true,
|
||||
"originalSrc": "${image}"
|
||||
},
|
||||
{
|
||||
"type": "static-images",
|
||||
"label": "图片集",
|
||||
"name": "images",
|
||||
"thumbMode": "cover",
|
||||
"thumbRatio": "4:3",
|
||||
"enlargeAble": true,
|
||||
"originalSrc": "${src}"
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static-json",
|
||||
"label": "JSON",
|
||||
"value": {
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": {
|
||||
"d": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static",
|
||||
"label": "可复制",
|
||||
"value": "文本",
|
||||
"copyable": {
|
||||
"content": "内容,支持变量 ${id}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "divider"
|
||||
},
|
||||
{
|
||||
"type": "static",
|
||||
"name": "text",
|
||||
"label": "可快速编辑",
|
||||
"value": "文本",
|
||||
"quickEdit": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
想要调整展示组件的配置,请查阅相应组件的文档。
|
||||
|
||||
## 快速编辑
|
||||
|
||||
通过 `quickEdit` 开启快速编辑功能,比如
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "static",
|
||||
"type": "static",
|
||||
"label": "静态展示",
|
||||
"value": "aaa",
|
||||
"quickEdit": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
其他配置项参考 [快速编辑](../crud#快速编辑)
|
||||
|
||||
## 弹出框(popOver)
|
||||
|
||||
可以通过 `popOver` 属性配置弹出框
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "static",
|
||||
"type": "static",
|
||||
"label": "静态展示",
|
||||
"value": "aaa",
|
||||
"popOver": {
|
||||
"body": {
|
||||
"type": "tpl",
|
||||
"tpl": "弹出内容"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
540
docs/zh-CN/components/form/switch.md
Executable file
540
docs/zh-CN/components/form/switch.md
Executable file
@@ -0,0 +1,540 @@
|
||||
---
|
||||
title: Switch 开关
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Switch
|
||||
icon:
|
||||
order: 51
|
||||
---
|
||||
|
||||
## 基本用法
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"label": "开关",
|
||||
"option": "开关说明"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 禁用状态
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"disabled": true,
|
||||
"label": "开关",
|
||||
"option": "开关说明"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 配置真假值
|
||||
|
||||
默认情况:
|
||||
|
||||
- 开关打开时,表单项值为:true
|
||||
- 开关关闭时,表单项值为:false
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"label": "开关"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果你想调整这个值,可以配置`trueValue`和`falseValue`
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"label": "开关",
|
||||
"trueValue": 1,
|
||||
"falseValue": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
调整开关,观察数据域变化,会发现打开后值为`1`,而关闭后为`0`
|
||||
|
||||
## 配置开启和关闭状态的文本
|
||||
|
||||
> `1.1.5` 版本之后支持
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"onText": "已开启飞行模式",
|
||||
"offText": "已关闭飞行模式"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 使用 Schema 配置文本
|
||||
|
||||
> `3.6.0` 版本之后支持
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"onText": [
|
||||
{
|
||||
"type": "icon",
|
||||
"icon": "fa fa-plane",
|
||||
"vendor": "",
|
||||
"className": "mr-1"
|
||||
},
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "飞行模式"
|
||||
}
|
||||
],
|
||||
"offText": [
|
||||
{
|
||||
"type": "icon",
|
||||
"icon": "fa fa-plane",
|
||||
"vendor": "",
|
||||
"className": "mr-1"
|
||||
},
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "飞行模式"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 默认值
|
||||
|
||||
和其它表单项一样,如果要设置默认值,可以使用 value 属性
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"label": "开关",
|
||||
"value": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 不同尺寸
|
||||
|
||||
> `2.0.0` 及以上版本
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"type": "switch",
|
||||
"label": ""
|
||||
},
|
||||
{
|
||||
"name": "switch-sm",
|
||||
"type": "switch",
|
||||
"label": "",
|
||||
"size": "sm"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 加载状态
|
||||
|
||||
> `3.6.0` 及以上版本
|
||||
|
||||
设置`"loading": true`, 标识开关操作的异步任务仍在执行中。另外`loadingOn`支持表达式
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"data": {
|
||||
"shouldLoading": true
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "switch1",
|
||||
"label": "",
|
||||
"loading": true,
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
|
||||
"type": "switch",
|
||||
"name": "switch2",
|
||||
"label": "",
|
||||
"size": "sm",
|
||||
"disabled": true,
|
||||
"loading": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
配合`ajax`动作,实现开关操作后台异步任务:
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "page",
|
||||
"body": [
|
||||
{
|
||||
"type": "form",
|
||||
"id": "demo-form",
|
||||
"body": [
|
||||
{
|
||||
"type": "hidden",
|
||||
"name": "isFetching",
|
||||
"value": false
|
||||
},
|
||||
{
|
||||
"type": "switch",
|
||||
"name": "switch",
|
||||
"label": "操作状态开关",
|
||||
"mode": "horizontal",
|
||||
"loadingOn": "${isFetching}",
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "toast",
|
||||
"args": {
|
||||
"msgType": "warning",
|
||||
"msg": "任务${switch === true ? '派发' : '取消'}成功,等待后台操作..."
|
||||
}
|
||||
},
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "demo-form",
|
||||
"args": {
|
||||
"value": {
|
||||
"isFetching": true
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"actionType": "ajax",
|
||||
"api": {
|
||||
"url": "/api/mock2/form/saveForm?waitSeconds=3",
|
||||
"method": "get",
|
||||
"messages": {
|
||||
"success": "操作成功",
|
||||
"failed": "操作失败"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "demo-form",
|
||||
"args": {
|
||||
"value": {
|
||||
"isFetching": false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 | 版本 |
|
||||
| ---------- | ------------------------------------------ | ------- | -------------------- | ------------------ |
|
||||
| option | `string` | | 选项说明 |
|
||||
| onText | `string \| IconSchema \| SchemaCollection` | | 开启时开关显示的内容 | `3.6.0`支持 Schema |
|
||||
| offText | `string \| IconSchema \| SchemaCollection` | | 关闭时开关显示的内容 | `3.6.0`支持 Schema |
|
||||
| trueValue | `boolean \| string \| number` | `true` | 标识真值 |
|
||||
| falseValue | `boolean \| string \| number` | `false` | 标识假值 |
|
||||
| size | `"sm" \| "md"` | `"md"` | 开关大小 |
|
||||
| loading | `boolean` | `false` | 是否处于加载状态 | `3.6.0` |
|
||||
|
||||
IconSchema 配置
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------- | -------- | --------- | ------------ |
|
||||
| type | `string` | | `icon` |
|
||||
| icon | `string` | | icon 的类型 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ------------------------------------ | ---------------- |
|
||||
| change | `[name]: string \| boolean` 组件的值 | 开关值变化时触发 |
|
||||
|
||||
### change
|
||||
|
||||
switch 值更新时弹出确认提示,确认后发送请求。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "crud",
|
||||
"syncLocation": false,
|
||||
"api": "/api/mock2/sample",
|
||||
"columns": [
|
||||
{
|
||||
"name": "id",
|
||||
"label": "ID",
|
||||
"id": "u:daa79afa2e53"
|
||||
},
|
||||
{
|
||||
"name": "engine",
|
||||
"label": "Rendering engine",
|
||||
"id": "u:3343cf518656"
|
||||
},
|
||||
{
|
||||
"name": "browser",
|
||||
"label": "Browser",
|
||||
"id": "u:fbdc85e45e2f"
|
||||
},
|
||||
{
|
||||
"name": "platform",
|
||||
"label": "Platform(s)",
|
||||
"id": "u:ccdb48cc1804"
|
||||
},
|
||||
{
|
||||
"name": "switch",
|
||||
"label": "开关",
|
||||
"id": "u:30a36768acce",
|
||||
"type": "switch",
|
||||
"inline": true,
|
||||
"onEvent": {
|
||||
"change": {
|
||||
"weight": 0,
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "confirmDialog",
|
||||
"dialog": {
|
||||
"type": "dialog",
|
||||
"title": "弹框标题",
|
||||
"body": [
|
||||
{
|
||||
"type": "tpl",
|
||||
"tpl": "确定要修改${id}吗?",
|
||||
"wrapperComponent": "",
|
||||
"inline": false,
|
||||
"id": "u:1965506c7599"
|
||||
}
|
||||
],
|
||||
"showCloseButton": true,
|
||||
"showErrorMsg": true,
|
||||
"showLoading": true,
|
||||
"className": "app-popover",
|
||||
"id": "u:d9783223df98",
|
||||
"actions": [
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "cancel",
|
||||
"label": "取消",
|
||||
"id": "u:302efee8613b"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"actionType": "confirm",
|
||||
"label": "确定",
|
||||
"primary": true,
|
||||
"id": "u:4a4d63cf35e1"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"actionType": "ajax",
|
||||
"outputVar": "responseResult",
|
||||
"options": {
|
||||
},
|
||||
"api": {
|
||||
"method": "get",
|
||||
"url": "/api/mock2/form/saveForm"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"value": false
|
||||
}
|
||||
],
|
||||
"id": "u:6c781a765f97"
|
||||
}
|
||||
```
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------------------- | ---------------------------------------------------------------------- | --- |
|
||||
| clear | - | 清空,6.3.1 及以上版本支持 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue`,6.3.1 及以上版本支持 | |
|
||||
| setValue | `value: string \| boolean` 更新的数据 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"label": "开关",
|
||||
"type": "switch",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "switch",
|
||||
"label": "开关",
|
||||
"type": "switch",
|
||||
"id": "reset_text",
|
||||
"value": true
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
[
|
||||
{
|
||||
"type": "button",
|
||||
"label": "修改开关的值",
|
||||
"className": "mb-2",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"componentId": "u:6613bfa3a18e",
|
||||
"actionType": "setValue",
|
||||
"args": {
|
||||
"value": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "u:9d7d695145bb"
|
||||
},
|
||||
{
|
||||
"type": "form",
|
||||
"title": "表单",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"label": "开启",
|
||||
"type": "switch",
|
||||
"name": "switch",
|
||||
"id": "u:6613bfa3a18e",
|
||||
"value": false,
|
||||
"mode": "inline"
|
||||
}
|
||||
],
|
||||
"id": "u:82d44e407eb0",
|
||||
"actions": [
|
||||
{
|
||||
"type": "submit",
|
||||
"label": "提交",
|
||||
"primary": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
559
docs/zh-CN/components/form/tabs-transfer-picker.md
Normal file
559
docs/zh-CN/components/form/tabs-transfer-picker.md
Normal file
@@ -0,0 +1,559 @@
|
||||
---
|
||||
title: TabsTransferPicker 穿梭选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: TabsTransferPicker 穿梭选择器
|
||||
icon:
|
||||
---
|
||||
|
||||
在[TabsTransfer 组合穿梭器](./tabs-transfer)的基础上扩充了弹窗选择模式,展示值用的是简单的 input 框,但是编辑的操作是弹窗个穿梭框来完成。
|
||||
|
||||
适合用来做复杂选人组件。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"label": "选人",
|
||||
"type": "tabs-transfer-picker",
|
||||
"name": "a",
|
||||
"sortable": true,
|
||||
"selectMode": "tree",
|
||||
"pickerSize": "md",
|
||||
"menuTpl": "<div class='flex justify-between'><span>${label}</span>${email ? `<div class='text-muted m-r-xs text-sm text-right'>${email}<br />${phone}</div>`: ''}</div>",
|
||||
"valueTpl": "${label}(${value})",
|
||||
"options": [
|
||||
{
|
||||
"label": "成员",
|
||||
"selectMode": "tree",
|
||||
"searchable": true,
|
||||
"children": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang",
|
||||
"email": "zhugeliang@timi.com",
|
||||
"phone": 13111111111
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao",
|
||||
"email": "caocao@timi.com",
|
||||
"phone": 13111111111
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan",
|
||||
"email": "zhongwuyan@timi.com",
|
||||
"phone": 13111111111
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai",
|
||||
"email": "libai@timi.com",
|
||||
"phone": 13111111111
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin",
|
||||
"email": "hanxin@timi.com",
|
||||
"phone": 13111111111
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun",
|
||||
"email": "yunzhongjun@timi.com",
|
||||
"phone": 13111111111
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "角色",
|
||||
"selectMode": "list",
|
||||
"children": [
|
||||
{
|
||||
"label": "角色 1",
|
||||
"value": "role1",
|
||||
},
|
||||
{
|
||||
"label": "角色 2",
|
||||
"value": "role2",
|
||||
},
|
||||
{
|
||||
"label": "角色 3",
|
||||
"value": "role3",
|
||||
},
|
||||
{
|
||||
"label": "角色 4",
|
||||
"value": "role4",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "部门",
|
||||
"selectMode": "tree",
|
||||
"children": [
|
||||
{
|
||||
"label": "总部",
|
||||
"value": "dep0",
|
||||
"children": [
|
||||
{
|
||||
"label": "部门 1",
|
||||
"value": "dep1",
|
||||
"children": [
|
||||
{
|
||||
"label": "部门 4",
|
||||
"value": "dep4",
|
||||
},
|
||||
{
|
||||
"label": "部门 5",
|
||||
"value": "dep5",
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "部门 2",
|
||||
"value": "dep2",
|
||||
},
|
||||
{
|
||||
"label": "部门 3",
|
||||
"value": "dep3",
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
更多配置请参考[TabsTransfer 组合穿梭器](./tabs-transfer)。
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | -------------------------------------------------------- | ------------------------- |
|
||||
| change | `[name]: string` 组件的值<br/>`items: object[]` 选项集合 | picker 弹窗确认提交时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 获取焦点(非内嵌模式) |
|
||||
| blur | `[name]: string` 组件的值 | 失去焦点(非内嵌模式) |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"label": "穿梭选择器",
|
||||
"type": "tabs-transfer-picker",
|
||||
"name": "a",
|
||||
"sortable": true,
|
||||
"selectMode": "tree",
|
||||
"options": [
|
||||
{
|
||||
"label": "成员",
|
||||
"selectMode": "tree",
|
||||
"searchable": true,
|
||||
"children": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "用户",
|
||||
"selectMode": "chained",
|
||||
"children": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao2"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai2"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin2"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"value": "zhugeliang",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"label": "穿梭选择器",
|
||||
"type": "tabs-transfer-picker",
|
||||
"name": "a",
|
||||
"sortable": true,
|
||||
"selectMode": "tree",
|
||||
"options": [
|
||||
{
|
||||
"label": "成员",
|
||||
"selectMode": "tree",
|
||||
"searchable": true,
|
||||
"children": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "用户",
|
||||
"selectMode": "chained",
|
||||
"children": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao2"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai2"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin2"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"value": "zhugeliang",
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"label": "穿梭选择器",
|
||||
"type": "tabs-transfer-picker",
|
||||
"name": "a",
|
||||
"sortable": true,
|
||||
"selectMode": "tree",
|
||||
"options": [
|
||||
{
|
||||
"label": "成员",
|
||||
"selectMode": "tree",
|
||||
"searchable": true,
|
||||
"children": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "用户",
|
||||
"selectMode": "chained",
|
||||
"children": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao2"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai2"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin2"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"value": "zhugeliang",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "yunzhongjun2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
1023
docs/zh-CN/components/form/tabs-transfer.md
Normal file
1023
docs/zh-CN/components/form/tabs-transfer.md
Normal file
File diff suppressed because it is too large
Load Diff
262
docs/zh-CN/components/form/textarea.md
Executable file
262
docs/zh-CN/components/form/textarea.md
Executable file
@@ -0,0 +1,262 @@
|
||||
---
|
||||
title: Textarea 多行文本输入框
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: Textarea 多行文本输入框
|
||||
icon:
|
||||
order: 57
|
||||
---
|
||||
|
||||
## 基本使用
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "textarea",
|
||||
"type": "textarea",
|
||||
"label": "多行文本"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 清空输入框
|
||||
|
||||
带移除图标的输入框,点击图标删除所有内容。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "textarea",
|
||||
"type": "textarea",
|
||||
"label": "多行文本",
|
||||
"clearable": true,
|
||||
"value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmodtion tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
设置`resetValue`,清空输入框后重置为指定值
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"name": "textarea",
|
||||
"type": "textarea",
|
||||
"label": "多行文本",
|
||||
"clearable": true,
|
||||
"resetValue": "reset"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 显示计数器
|
||||
|
||||
配置`"showCounter": true`后输入框将显示计数器,一般会配合`maxLength`属性以限制输入长度,如果不设置`maxLength`,则仅展示计数器,并不会限制用户的输入长度。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"name": "a",
|
||||
"type": "textarea",
|
||||
"label": "A",
|
||||
"showCounter": true,
|
||||
"placeholder": "请输入",
|
||||
"clearable": true
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"type": "textarea",
|
||||
"label": "B",
|
||||
"showCounter": true,
|
||||
"maxLength": 30,
|
||||
"placeholder": "请输入"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ------------ | --------- | ------- | ---------------------------- |
|
||||
| minRows | `number` | `3` | 最小行数 |
|
||||
| maxRows | `number` | `20` | 最大行数 |
|
||||
| trimContents | `boolean` | `true` | 是否去除首尾空白文本 |
|
||||
| readOnly | `boolean` | `false` | 是否只读 |
|
||||
| showCounter | `boolean` | `false` | 是否显示计数器 |
|
||||
| maxLength | `number` | - | 限制最大字数 |
|
||||
| clearable | `boolean` | `false` | 是否可清除 |
|
||||
| resetValue | `string` | `""` | 清除后设置此配置项给定的值。 |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | -------------------------- | -------------------- |
|
||||
| change | `[name]: string` 组件的值 | 值变化时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点时触发 |
|
||||
| blur | `[name]: string ` 组件的值 | 输入框失去焦点时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | ------------------------ | ------------------------------------------------ |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| focus | - | 获取焦点 |
|
||||
| setValue | `value: string` 更新的值 | 更新数据 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "clear_text",
|
||||
"type": "textarea",
|
||||
"label": "text",
|
||||
"value": "清空我"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "reset_text",
|
||||
"type": "textarea",
|
||||
"label": "text",
|
||||
"value": "重置我"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### focus
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "focus_text",
|
||||
"type": "textarea",
|
||||
"label": "text",
|
||||
"value": "聚焦我"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "聚焦",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "focus",
|
||||
"componentId": "focus_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"name": "text",
|
||||
"id": "setvalue_text",
|
||||
"type": "textarea",
|
||||
"label": "text",
|
||||
"value": "amis"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "amis go go go!"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
330
docs/zh-CN/components/form/transfer-picker.md
Normal file
330
docs/zh-CN/components/form/transfer-picker.md
Normal file
@@ -0,0 +1,330 @@
|
||||
---
|
||||
title: TransferPicker 穿梭选择器
|
||||
description:
|
||||
type: 0
|
||||
group: null
|
||||
menuName: TransferPicker 穿梭选择器
|
||||
icon:
|
||||
---
|
||||
|
||||
在[穿梭器(Transfer)](./transfer)的基础上扩充了弹窗选择模式,展示值用的是简单的 input 框,但是编辑的操作是弹窗个穿梭框来完成。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"api": "/api/mock2/form/saveForm",
|
||||
"body": [
|
||||
{
|
||||
"label": "组合穿梭器",
|
||||
"type": "transfer-picker",
|
||||
"name": "a",
|
||||
"sortable": true,
|
||||
"selectMode": "tree",
|
||||
"searchable": true,
|
||||
"options": [
|
||||
{
|
||||
"label": "法师",
|
||||
"children": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "战士",
|
||||
"children": [
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "打野",
|
||||
"children": [
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自定义选项展示
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"body": [
|
||||
{
|
||||
"label": "默认",
|
||||
"type": "transfer-picker",
|
||||
"name": "transfer",
|
||||
"menuTpl": "<div class='flex justify-between'><span>${label}</span><span class='text-muted m-r text-sm'>${tag}</span></div>",
|
||||
"valueTpl": "${label}(${value})",
|
||||
"options": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang",
|
||||
"tag": "法师",
|
||||
},
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao",
|
||||
"tag": "战士",
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan",
|
||||
"tag": "战士",
|
||||
},
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai",
|
||||
"tag": "打野"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin",
|
||||
"tag": "打野"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun",
|
||||
"tag": "打野"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 属性表
|
||||
|
||||
下面属性为`transfer-picker`独占属性,更多属性用法,参考[穿梭器(Transfer)](./transfer)
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ---------- | -------------------------------- | ------ | -------------------------------------------------------------- |
|
||||
| borderMode | `'full'` \| `'half'` \| `'none'` | | 边框模式,`'full'`为全边框,`'half'`为半边框,`'none'`为没边框 |
|
||||
| pickerSize | string | | 弹窗大小,支持: xs、sm、md、lg、xl、full |
|
||||
|
||||
## 事件表
|
||||
|
||||
当前组件会对外派发以下事件,可以通过`onEvent`来监听这些事件,并通过`actions`来配置执行的动作,在`actions`中可以通过`${事件参数名}`或`${event.data.[事件参数名]}`来获取事件产生的数据,详细请查看[事件动作](../../docs/concepts/event-action)。
|
||||
|
||||
> `[name]`表示当前组件绑定的名称,即`name`属性,如果没有配置`name`属性,则通过`value`取值。
|
||||
|
||||
| 事件名称 | 事件参数 | 说明 |
|
||||
| -------- | ----------------------------------------------------------------------------------------- | -------------------------------- |
|
||||
| change | `[name]: string` 组件的值<br/>`items: object[]`选项集合(< 2.3.2 及以下版本 为`options`) | picker 弹窗确认提交时触发 |
|
||||
| focus | `[name]: string` 组件的值 | 输入框获取焦点(非内嵌模式)时触发 |
|
||||
| blur | `[name]: string` 组件的值 | 输入框失去焦点(非内嵌模式)时触发 |
|
||||
|
||||
## 动作表
|
||||
|
||||
当前组件对外暴露以下特性动作,其他组件可以通过指定`actionType: 动作名称`、`componentId: 该组件id`来触发这些动作,动作配置可以通过`args: {动作配置项名称: xxx}`来配置具体的参数,详细请查看[事件动作](../../docs/concepts/event-action#触发其他组件的动作)。
|
||||
|
||||
| 动作名称 | 动作配置 | 说明 |
|
||||
| -------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
|
||||
| clear | - | 清空 |
|
||||
| reset | - | 将值重置为初始值。6.3.0 及以下版本为`resetValue` |
|
||||
| setValue | `value: string` \| `string[]` 更新的值 | 更新数据,开启`multiple`支持设置多项,开启`joinValues`时,多值用`,`分隔,否则多值用数组 |
|
||||
|
||||
### clear
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"label": "默认",
|
||||
"type": "transfer-picker",
|
||||
"name": "transfer",
|
||||
"value": "zhugeliang,libai",
|
||||
"options": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang"
|
||||
},
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan"
|
||||
},
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
],
|
||||
"value": "zhugeliang",
|
||||
"id": "clear_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "清空",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "clear",
|
||||
"componentId": "clear_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### reset
|
||||
|
||||
如果配置了`resetValue`,则重置时使用`resetValue`的值,否则使用初始值。
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"label": "默认",
|
||||
"type": "transfer-picker",
|
||||
"name": "transfer",
|
||||
"value": "zhugeliang,libai",
|
||||
"options": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang"
|
||||
},
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan"
|
||||
},
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
],
|
||||
"value": "zhugeliang",
|
||||
"id": "reset_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "重置",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "reset",
|
||||
"componentId": "reset_text"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### setValue
|
||||
|
||||
```schema: scope="body"
|
||||
{
|
||||
"type": "form",
|
||||
"debug": true,
|
||||
"body": [
|
||||
{
|
||||
"label": "默认",
|
||||
"type": "transfer-picker",
|
||||
"name": "transfer",
|
||||
"value": "zhugeliang,libai",
|
||||
"options": [
|
||||
{
|
||||
"label": "诸葛亮",
|
||||
"value": "zhugeliang"
|
||||
},
|
||||
{
|
||||
"label": "曹操",
|
||||
"value": "caocao"
|
||||
},
|
||||
{
|
||||
"label": "钟无艳",
|
||||
"value": "zhongwuyan"
|
||||
},
|
||||
{
|
||||
"label": "李白",
|
||||
"value": "libai"
|
||||
},
|
||||
{
|
||||
"label": "韩信",
|
||||
"value": "hanxin"
|
||||
},
|
||||
{
|
||||
"label": "云中君",
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
],
|
||||
"value": "zhugeliang",
|
||||
"id": "setvalue_text"
|
||||
},
|
||||
{
|
||||
"type": "button",
|
||||
"label": "赋值",
|
||||
"onEvent": {
|
||||
"click": {
|
||||
"actions": [
|
||||
{
|
||||
"actionType": "setValue",
|
||||
"componentId": "setvalue_text",
|
||||
"args": {
|
||||
"value": "yunzhongjun"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
1289
docs/zh-CN/components/form/transfer.md
Normal file
1289
docs/zh-CN/components/form/transfer.md
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user