2020-07-28 10:03:53 +08:00
|
|
|
|
---
|
2021-10-26 14:25:12 +08:00
|
|
|
|
title: Chained-Select 链式下拉框
|
2020-07-29 16:20:21 +08:00
|
|
|
|
description:
|
2020-07-28 10:03:53 +08:00
|
|
|
|
type: 0
|
|
|
|
|
group: null
|
2021-10-26 14:25:12 +08:00
|
|
|
|
menuName: Chained-Select
|
2020-07-29 16:20:21 +08:00
|
|
|
|
icon:
|
2020-07-28 10:03:53 +08:00
|
|
|
|
order: 7
|
|
|
|
|
---
|
2020-07-29 16:20:21 +08:00
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
|
## 基本用法
|
|
|
|
|
|
2021-01-04 20:10:08 +08:00
|
|
|
|
用于实现无限级别下拉,只支持单选,且必须和 `source` 搭配,通过 API 拉取数据,只要 API 有返回结果,就能一直无限级别下拉。
|
2020-07-28 10:03:53 +08:00
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
|
{
|
|
|
|
|
"type": "form",
|
|
|
|
|
"debug": true,
|
2021-08-09 18:05:01 +08:00
|
|
|
|
"api": "/api/mock2/form/saveForm",
|
2021-06-07 10:09:55 +08:00
|
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
|
{
|
|
|
|
|
"name": "select3",
|
|
|
|
|
"type": "chained-select",
|
|
|
|
|
"label": "级联下拉",
|
2021-08-09 18:05:01 +08:00
|
|
|
|
"source": "/api/mock2/options/chainedOptions?waitSeconds=1&parentId=$parentId&level=$level&maxLevel=4",
|
2020-07-28 10:03:53 +08:00
|
|
|
|
"value": "a,b"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
> `source`接口中配置的参数`waitSeconds=1`和`maxLevel=4`是测试接口所需参数,实际使用自己接口时不需要添加这两个参数
|
|
|
|
|
|
|
|
|
|
## 暴露参数
|
|
|
|
|
|
2020-07-29 16:20:21 +08:00
|
|
|
|
为了帮助后端接口获取当前选择器状态,chained-select 会默认给 source 接口的数据域中,添加若干个参数:
|
2020-07-28 10:03:53 +08:00
|
|
|
|
|
|
|
|
|
- `value`: 选中的表单项值;
|
|
|
|
|
- `level`: 当前拉取数据时的层级,
|
|
|
|
|
- `parentId`: 上一级选项的值,数据格式基于配置的`joinValues`和`extractValue`属性
|
|
|
|
|
- `parent`: 上一级选项的完整的数据格式
|
|
|
|
|
|
|
|
|
|
## 属性表
|
|
|
|
|
|
|
|
|
|
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
|
|
|
|
|
2021-02-01 20:44:49 +08:00
|
|
|
|
| 属性名 | 类型 | 默认值 | 说明 |
|
|
|
|
|
| ------------ | ----------------------------------------- | --------- | ------------------------------------------------------------------------------------------- |
|
|
|
|
|
| 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) |
|
2022-03-16 10:12:21 +08:00
|
|
|
|
|
|
|
|
|
## 事件表
|
|
|
|
|
|
|
|
|
|
| 事件名称 | 事件参数 | 说明 |
|
|
|
|
|
| -------- | -------------------------------------------------------------------------------------------------- | ---- |
|
2022-03-16 10:39:12 +08:00
|
|
|
|
| change | `value: string \| Option[]` 选中值 | 选中值发生变化时触发 |
|
2022-03-16 10:12:21 +08:00
|
|
|
|
|
|
|
|
|
## 动作表
|
|
|
|
|
|
|
|
|
|
| 动作名称 | 动作配置 | 说明 |
|
|
|
|
|
| -------- | -------------------------------------------------------------------------------------------------- | ---- |
|
|
|
|
|
| clear | - | 清空 |
|
2022-03-18 13:45:29 +08:00
|
|
|
|
| reset | - | 重置 |
|