2020-07-28 10:03:53 +08:00
|
|
|
|
---
|
2021-06-03 22:09:30 +08:00
|
|
|
|
title: InputCity 城市选择器
|
2020-12-02 15:08:47 +08:00
|
|
|
|
description:
|
2020-07-28 10:03:53 +08:00
|
|
|
|
type: 0
|
|
|
|
|
group: null
|
2021-06-03 22:09:30 +08:00
|
|
|
|
menuName: InputCity
|
2020-12-02 15:08:47 +08:00
|
|
|
|
icon:
|
2020-07-28 10:03:53 +08:00
|
|
|
|
order: 10
|
|
|
|
|
---
|
2020-12-02 15:08:47 +08:00
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
|
城市选择器,方便输入城市,可以理解为自动配置了国内城市选项的 Select,支持到县级别。
|
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-03 22:09:30 +08:00
|
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
|
{
|
|
|
|
|
"name": "city",
|
2021-06-03 22:09:30 +08:00
|
|
|
|
"type": "input-city",
|
2020-12-02 15:08:47 +08:00
|
|
|
|
"label": "城市",
|
|
|
|
|
"searchable": true
|
2020-07-28 10:03:53 +08:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
观察数据域中表单项的值,存储的是位置邮编。
|
|
|
|
|
|
|
|
|
|
## 配置选择级别
|
|
|
|
|
|
|
|
|
|
可以通过设置 `allowDistrict` 和 `allowCity` 设置用户选择级别,例如只选择省份:
|
|
|
|
|
|
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-03 22:09:30 +08:00
|
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
|
{
|
|
|
|
|
"name": "city",
|
2021-06-03 22:09:30 +08:00
|
|
|
|
"type": "input-city",
|
2020-07-28 10:03:53 +08:00
|
|
|
|
"label": "城市",
|
|
|
|
|
"allowDistrict": false,
|
|
|
|
|
"allowCity": false
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 获取更多选项信息
|
|
|
|
|
|
|
|
|
|
表单项值默认格式是编码(即 `code`),如果你想要详细点的信息,可以把 `extractValue` 设置成 `false`。
|
|
|
|
|
|
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-03 22:09:30 +08:00
|
|
|
|
"body": [
|
2020-07-28 10:03:53 +08:00
|
|
|
|
{
|
|
|
|
|
"name": "city",
|
2021-06-03 22:09:30 +08:00
|
|
|
|
"type": "input-city",
|
2020-07-28 10:03:53 +08:00
|
|
|
|
"label": "城市",
|
|
|
|
|
"extractValue": false
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 属性表
|
|
|
|
|
|
|
|
|
|
当做选择器表单项使用时,除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
|
|
|
|
|
2020-12-02 15:08:47 +08:00
|
|
|
|
| 属性名 | 类型 | 默认值 | 说明 |
|
|
|
|
|
| ------------- | --------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
|
|
|
| allowCity | `boolean` | `true` | 允许选择城市 |
|
|
|
|
|
| allowDistrict | `boolean` | `true` | 允许选择区域 |
|
|
|
|
|
| searchable | `boolean` | `false` | 是否出搜索框 |
|
|
|
|
|
| extractValue | `boolean` | `true` | 默认 `true` 是否抽取值,如果设置成 `false` 值格式会变成对象,包含 `code`、`province`、`city` 和 `district` 文字信息。 |
|
2022-03-16 10:12:21 +08:00
|
|
|
|
|
|
|
|
|
## 事件表
|
|
|
|
|
|
|
|
|
|
| 事件名称 | 事件参数 | 说明 |
|
|
|
|
|
| -------- | -------------------------------------------------------------------------------------------------- | ---- |
|
2022-03-16 10:39:12 +08:00
|
|
|
|
| change | `value: number \| string` 选中值 | 选中值发生变化时触发 |
|
2022-03-16 10:12:21 +08:00
|
|
|
|
|
|
|
|
|
## 动作表
|
|
|
|
|
|
|
|
|
|
| 动作名称 | 动作配置 | 说明 |
|
|
|
|
|
| -------- | -------------------------------------------------------------------------------------------------- | ---- |
|
|
|
|
|
| clear | - | 清空 |
|
2022-03-18 13:45:29 +08:00
|
|
|
|
| reset | - | 重置 |
|