mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-15 01:11:15 +08:00
ecd2e441a3
* fix: 按钮disabledOn属性失效问题 (#4324)
* fix: Service组件条件轮询会多调用一次api; docs: 补充轮询相关属性示例 (#4317)
* fix: 公式变量检索问题 (#4325)
* fix #1536: actionType为ajax时sendOn属性未生效问题 (#4326)
* fix:修复disabled失效问题 (#4329)
* fix:修复disabled失效问题
* test:补充事件动作测试用例
* style:组件对齐云舍4.1主题 (#4337)
* Select Options等组件样式对齐4.0
* 更新测试快照
* 修改部分测试用例
* feat:4.0样式修改
* 修改checkboxes hover问题
* Feat image 4.0 (#4242)
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* feat: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* fix: 点状步骤条样式修改
* fix: inputTree组件对齐4.0标准
* fix: textarea组件对齐4.0标准
* fix: textarea组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: image组件样式优化
* fix: image组件样式优化
* fix: image组件样式优化
* fix: image组件样式优化
Co-authored-by: qiaoganggang <qiaoganggang@baidu.com>
* fix: textarea组件对齐4.0标准 (#4149)
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* feat: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* fix: 点状步骤条样式修改
* fix: inputTree组件对齐4.0标准
* fix: inputTree组件对齐4.0标准
* fix: textarea组件对齐4.0标准
* fix: textarea组件对齐4.0标准
Co-authored-by: qiaoganggang <qiaoganggang@baidu.com>
* fix: inputTree 组价对齐4.0标准 (#4148)
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* feat: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* fix: 点状步骤条样式修改
* fix: inputTree组件对齐4.0标准
* fix: inputTree组件对齐4.0标准
* fix: inputtree组件图标颜色修改
Co-authored-by: qiaoganggang <qiaoganggang@baidu.com>
* feat: 部分组件样式问题修复 (#4154)
* feat: input-text 样式
* feat: input-range 样式
* feat: table 样式 1
* feat: search-box
* feat: curd icon
* feat: table 空状态
* feat: input-text 多选,最大宽度设置
* feat: search-box 搜索图标颜色
* feat: crud 编辑、过滤、搜索、排序 图标样式修改
* feat: 更新快照
* feat: 更新快照 2
* feat: curd fix
* feat: curd edit icon fix
* feat: input-password 不可见 icon 修改
* feat: input-password snapshot update
* docs:完善对话框size参数说明
* feat: Log 组件支持虚拟渲染及限制最大行数
* 修复不支持 loading 问题
* 换一下名字
Co-authored-by: liuzedong02 <liuzedong02@baidu.com>
Co-authored-by: liweijian <liweijian@hkmtl.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
Co-authored-by: RUNZE LU <36724300+lurunze1226@users.noreply.github.com>
* fix:修复删除图标颜色问题 (#4245)
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* feat: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* faet: Step组件支持点状步骤条、指定标签放置位置、新增超出内容显示浮层
* fix: 点状步骤条样式修改
* fix: inputTree组件对齐4.0标准
* fix: textarea组件对齐4.0标准
* fix: textarea组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: inputImage组件对齐4.0标准
* fix: image组件样式优化
* fix: image组件样式优化
* fix: image组件样式优化
* fix: image组件样式优化
* fix: 修复conditionbuilder组价图标颜色问题
Co-authored-by: qiaoganggang <qiaoganggang@baidu.com>
* form表单对齐云社4.0 (#4248)
* feat: form增加表单项 label文本对齐方式选项
* fix: remark 支持在表单内配置
* style: form 间距对齐云社4.0
Co-authored-by: sarding <hongfuquan@baidu.com>
* Fix chart radios name (#4251)
* fix: Chart 单选框 修改为 ChartRadios 图表单选框
* fix: input-password 修改 可见 图标
Co-authored-by: liuzedong02 <liuzedong02@baidu.com>
* feat: checkboxes内边距&nestedSelect箭头修改 (#4254)
Co-authored-by: xujiahao01 <xujiahao01@baidu.com>
* Feature style 4.0 cxd (#4261)
* feat: 日期&折叠面板&提示样式对齐
* fix:测试用例修复
* feat: timeRange开始和结束分开&日期样式优化
* styles: 日历样式修复
Co-authored-by: hongyang03 <hongyang03@baidu.com>
* 整体字体大小调整 (#4264)
* feat: form增加表单项 label文本对齐方式选项
* fix: remark 支持在表单内配置
* style: form 间距对齐云社4.0
* 修改表单的字体
Co-authored-by: sarding <hongfuquan@baidu.com>
* inputfile 和 drawer对齐云社4.0 (#4249)
* fix: drawer 和 inputfile 关闭图标对齐云社4.0
* fix:修改 drawer的图标大小 和边框圆角
* drawer 样式调整
Co-authored-by: sarding <hongfuquan@baidu.com>
* Fix style (#4265)
* fix: input-password icon 高度
* fix: input-password icon 换行问题
Co-authored-by: liuzedong02 <liuzedong02@baidu.com>
* fix: curd 图标垂直居中 (#4271)
Co-authored-by: liuzedong02 <liuzedong02@baidu.com>
* fix:修复nestedSelect无法动态调整位置及溢出问题 (#4292)
Co-authored-by: xujiahao01 <xujiahao01@baidu.com>
* style: 优化switch组件动效 (#4302)
* style:优化date组件最小宽度 (#4303)
* style:cxd主题移动端基础字号调整为16px (#4305)
* marge master into style-cxd (#4306)
* docs:完善对话框size参数说明
* feat: Log 组件支持虚拟渲染及限制最大行数
* 修复不支持 loading 问题
* 换一下名字
* fix: 公式编辑器 variableMode 失效 (#4252)
* 提交事件支持禁用默认提示
* fix:修改执行方式
* 修改测试api
* 去掉无效引用
* fix: 修复datetime移动端报错
* chore: jssdk 的 responseAdaptor 扩充参数,支持拿 response 整个对象,包括返回的 headers 和… (#4229)
* chore: jssdk 的 responseAdpator 扩充参数,支持拿 response 整个对象,包括返回的 headers 和状态码信息
* chore: jssdk 的 responseAdpator 扩充参数,支持拿 response 整个对象,包括返回的 headers 和状态码信息
* docs: 切换主题文档描述不正确问题
* 优化逻辑
* 调整格式
* 处理异步
* 增加兼容逻辑
* feat: 更新实时日志组件,增加可操作按钮:停止、显示行号等 (#4250)
* feat: 更新实时日志组件,增加可操作按钮:停止、显示行号等
* 日志容器针对操作按钮增加相对定位
* 改变工具栏为侧边隐藏样式
* 调整 log 操作按钮位置避免遮挡内容
* 补充翻译
* 修复 Log 行样式丢失
Co-authored-by: lvchenguang <lvchenguang@zhihu.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
* fixup (#4263)
Co-authored-by: zhyc <zhyc@hzsuoyi.com>
* fix #4240: 修复input-datetime组件timeConstraints属性不生效问题,修复时间选取后自动滚动位置错误 (#4253)
* chore: action countDown 在actionType为ajax时,请求通过再执行倒计时操作、dialog header 传递动作属性 (#4000)
* LocationPicker ak支持数据解析,可用于统一地图配置
* drawer header传递动作属性,在header中也可以提交、关闭等操作
* action countDown 在actionType为ajax时,请求通过再执行倒计时操作
* dialog header 传递动作属性
* 修一些编码规范问题
Co-authored-by: metooweb <1058776960@qq.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
* chore: 修几个单元测试报错 (#4272)
* feat:toast支持取消合并state
* fix: 修正ContextMenu 二次触发时遮挡问题 (#4282)
* fix(ContextMenu): 增加判空处理 (#4283)
* 人员选择组件支持部门、角色、岗位选择 (#4285)
* 人员选择组件
* 修复ts报错
Co-authored-by: zhangxulong <zhangxulong@baidu.com>
* fix:修复事件动作对禁用状态控制失效问题&更新文档示例 (#4278)
* fix:修复事件动作对禁用状态控制失效问题&更新文档示例
* fix:修复事件动作对禁用状态控制失效问题
* fix:修复事件动作对禁用状态控制失效问题
* fix:动作执行时对组件查找失败的容错 (#4290)
* feat:Table2支持配置单元格样式、行操作按钮 (#4268)
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
* fix #4270: checkboxes组件checkAll属性失效问题 (#4287)
* feat:事件干预支持表达式 (#4295)
* fix #4258: sdk方式下toast配置不生效问题 (#4274)
* feat: 添加 json-schema 渲染器 (#4269)
* feat: 添加 json-schema 渲染器
* draft: 组件层添加 form 逻辑
* 补充组件form相关逻辑
* json-schema-editor 组件内部实现调整
* 添加 json-schema 渲染器
* 补充外部 value 变化更新成员的逻辑
* 补充外部 value 变化更新成员的逻辑
* 优化 json-schema 交互
* 修改 snapshot
* 可能死循环
* 补充文档
* 优化逻辑
* 具备远程获取能力
* 固定值优化
* fix(custom): 完善custom自定义组件,增加属性变动更新逻辑 (#4288)
* fix(custom): 完善custom自定义组件,增加属性变动更新逻辑
* fix(custom): update
* fix(custom): 更新测试用例
* 类型只有一个时不显示切换按钮
* fix: Pagination 切换页码后每页显示重置问题 (#4298)
Co-authored-by: liweijian <liweijian@hkmtl.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
Co-authored-by: RUNZE LU <36724300+lurunze1226@users.noreply.github.com>
Co-authored-by: Allen <yupeng.fe@qq.com>
Co-authored-by: pianruijie <13522335863@163.com>
Co-authored-by: zhangtao07 <zhang.tao.1006@163.com>
Co-authored-by: liaoxuezhi <2betop.cn@gmail.com>
Co-authored-by: hsm-lv <80095014+hsm-lv@users.noreply.github.com>
Co-authored-by: mr-chenguang <37072324+lcgash@users.noreply.github.com>
Co-authored-by: lvchenguang <lvchenguang@zhihu.com>
Co-authored-by: decarp <zhycde@gmail.com>
Co-authored-by: zhyc <zhyc@hzsuoyi.com>
Co-authored-by: metooweb <2947550545@qq.com>
Co-authored-by: metooweb <1058776960@qq.com>
Co-authored-by: 刘丹 <365533093@qq.com>
Co-authored-by: 龙少 <1769057083@qq.com>
Co-authored-by: zhangxulong <zhangxulong@baidu.com>
Co-authored-by: wanglinfang2014 <w.l.fang@foxmail.com>
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
* fix:transfer组件云舍样式完善 (#4310)
Co-authored-by: sqzhou <zhoushengqiang01@MacBook-Pro-2.local>
* merge master (#4335)
* docs:完善对话框size参数说明
* feat: Log 组件支持虚拟渲染及限制最大行数
* 修复不支持 loading 问题
* 换一下名字
* fix: 公式编辑器 variableMode 失效 (#4252)
* 提交事件支持禁用默认提示
* fix:修改执行方式
* 修改测试api
* 去掉无效引用
* fix: 修复datetime移动端报错
* chore: jssdk 的 responseAdaptor 扩充参数,支持拿 response 整个对象,包括返回的 headers 和… (#4229)
* chore: jssdk 的 responseAdpator 扩充参数,支持拿 response 整个对象,包括返回的 headers 和状态码信息
* chore: jssdk 的 responseAdpator 扩充参数,支持拿 response 整个对象,包括返回的 headers 和状态码信息
* docs: 切换主题文档描述不正确问题
* 优化逻辑
* 调整格式
* 处理异步
* 增加兼容逻辑
* feat: 更新实时日志组件,增加可操作按钮:停止、显示行号等 (#4250)
* feat: 更新实时日志组件,增加可操作按钮:停止、显示行号等
* 日志容器针对操作按钮增加相对定位
* 改变工具栏为侧边隐藏样式
* 调整 log 操作按钮位置避免遮挡内容
* 补充翻译
* 修复 Log 行样式丢失
Co-authored-by: lvchenguang <lvchenguang@zhihu.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
* fixup (#4263)
Co-authored-by: zhyc <zhyc@hzsuoyi.com>
* fix #4240: 修复input-datetime组件timeConstraints属性不生效问题,修复时间选取后自动滚动位置错误 (#4253)
* chore: action countDown 在actionType为ajax时,请求通过再执行倒计时操作、dialog header 传递动作属性 (#4000)
* LocationPicker ak支持数据解析,可用于统一地图配置
* drawer header传递动作属性,在header中也可以提交、关闭等操作
* action countDown 在actionType为ajax时,请求通过再执行倒计时操作
* dialog header 传递动作属性
* 修一些编码规范问题
Co-authored-by: metooweb <1058776960@qq.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
* chore: 修几个单元测试报错 (#4272)
* feat:toast支持取消合并state
* fix: 修正ContextMenu 二次触发时遮挡问题 (#4282)
* fix(ContextMenu): 增加判空处理 (#4283)
* 人员选择组件支持部门、角色、岗位选择 (#4285)
* 人员选择组件
* 修复ts报错
Co-authored-by: zhangxulong <zhangxulong@baidu.com>
* fix:修复事件动作对禁用状态控制失效问题&更新文档示例 (#4278)
* fix:修复事件动作对禁用状态控制失效问题&更新文档示例
* fix:修复事件动作对禁用状态控制失效问题
* fix:修复事件动作对禁用状态控制失效问题
* fix:动作执行时对组件查找失败的容错 (#4290)
* feat:Table2支持配置单元格样式、行操作按钮 (#4268)
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
* fix #4270: checkboxes组件checkAll属性失效问题 (#4287)
* feat:事件干预支持表达式 (#4295)
* fix #4258: sdk方式下toast配置不生效问题 (#4274)
* feat: 添加 json-schema 渲染器 (#4269)
* feat: 添加 json-schema 渲染器
* draft: 组件层添加 form 逻辑
* 补充组件form相关逻辑
* json-schema-editor 组件内部实现调整
* 添加 json-schema 渲染器
* 补充外部 value 变化更新成员的逻辑
* 补充外部 value 变化更新成员的逻辑
* 优化 json-schema 交互
* 修改 snapshot
* 可能死循环
* 补充文档
* 优化逻辑
* 具备远程获取能力
* 固定值优化
* fix(custom): 完善custom自定义组件,增加属性变动更新逻辑 (#4288)
* fix(custom): 完善custom自定义组件,增加属性变动更新逻辑
* fix(custom): update
* fix(custom): 更新测试用例
* 类型只有一个时不显示切换按钮
* fix: Pagination 切换页码后每页显示重置问题 (#4298)
* feat:transfer组件功能完善 (#3696)
* feat:transfer组件功能完善
* update-snapshot
* feat:transfer组件功能完善
* update-snapshot
* feat:transfer组件功能完善
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* update-snapshot
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* feat:transfer组件云舍4.0功能
* update-snapshot
Co-authored-by: sqzhou <zhoushengqiang01@baidu.com>
* feat: 表单label支持左右对齐方式 (#4311)
* fix: 修复 replaceText 不支持 schemaApi 问题 (#4300)
* fix: deferloadOptions 在defer模式下的处理问题
* fix: 按钮disabledOn属性失效问题 (#4324)
* fix: Service组件条件轮询会多调用一次api; docs: 补充轮询相关属性示例 (#4317)
* fix: 公式变量检索问题 (#4325)
* fix #1536: actionType为ajax时sendOn属性未生效问题 (#4326)
* fix:修复disabled失效问题 (#4329)
* fix:修复disabled失效问题
* test:补充事件动作测试用例
* fix:样式问题
Co-authored-by: liweijian <liweijian@hkmtl.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
Co-authored-by: RUNZE LU <36724300+lurunze1226@users.noreply.github.com>
Co-authored-by: Allen <yupeng.fe@qq.com>
Co-authored-by: pianruijie <13522335863@163.com>
Co-authored-by: zhangtao07 <zhang.tao.1006@163.com>
Co-authored-by: liaoxuezhi <2betop.cn@gmail.com>
Co-authored-by: hsm-lv <80095014+hsm-lv@users.noreply.github.com>
Co-authored-by: mr-chenguang <37072324+lcgash@users.noreply.github.com>
Co-authored-by: lvchenguang <lvchenguang@zhihu.com>
Co-authored-by: decarp <zhycde@gmail.com>
Co-authored-by: zhyc <zhyc@hzsuoyi.com>
Co-authored-by: metooweb <2947550545@qq.com>
Co-authored-by: metooweb <1058776960@qq.com>
Co-authored-by: 刘丹 <365533093@qq.com>
Co-authored-by: 龙少 <1769057083@qq.com>
Co-authored-by: zhangxulong <zhangxulong@baidu.com>
Co-authored-by: wanglinfang2014 <w.l.fang@foxmail.com>
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
Co-authored-by: zhou999 <zhousq809@163.com>
Co-authored-by: sqzhou <zhoushengqiang01@baidu.com>
Co-authored-by: xujiahao01 <xujiahao01@baidu.com>
Co-authored-by: qiaogg <43558337+qiaogg@users.noreply.github.com>
Co-authored-by: qiaoganggang <qiaoganggang@baidu.com>
Co-authored-by: sansiro <sansiro@sansiro.me>
Co-authored-by: liuzedong02 <liuzedong02@baidu.com>
Co-authored-by: liweijian <liweijian@hkmtl.com>
Co-authored-by: wuduoyi <wuduoyi@baidu.com>
Co-authored-by: RUNZE LU <36724300+lurunze1226@users.noreply.github.com>
Co-authored-by: sarding <37691952+sarding@users.noreply.github.com>
Co-authored-by: sarding <hongfuquan@baidu.com>
Co-authored-by: 徐佳豪 <53201551+blue-squirrel@users.noreply.github.com>
Co-authored-by: HongYang <33488114+hy993658052@users.noreply.github.com>
Co-authored-by: hongyang03 <hongyang03@baidu.com>
Co-authored-by: Allen <yupeng.fe@qq.com>
Co-authored-by: pianruijie <13522335863@163.com>
Co-authored-by: zhangtao07 <zhang.tao.1006@163.com>
Co-authored-by: liaoxuezhi <2betop.cn@gmail.com>
Co-authored-by: hsm-lv <80095014+hsm-lv@users.noreply.github.com>
Co-authored-by: mr-chenguang <37072324+lcgash@users.noreply.github.com>
Co-authored-by: lvchenguang <lvchenguang@zhihu.com>
Co-authored-by: decarp <zhycde@gmail.com>
Co-authored-by: zhyc <zhyc@hzsuoyi.com>
Co-authored-by: metooweb <2947550545@qq.com>
Co-authored-by: metooweb <1058776960@qq.com>
Co-authored-by: 刘丹 <365533093@qq.com>
Co-authored-by: 龙少 <1769057083@qq.com>
Co-authored-by: zhangxulong <zhangxulong@baidu.com>
Co-authored-by: wanglinfang2014 <w.l.fang@foxmail.com>
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
Co-authored-by: zhou999 <zhousq809@163.com>
Co-authored-by: sqzhou <zhoushengqiang01@MacBook-Pro-2.local>
Co-authored-by: sqzhou <zhoushengqiang01@baidu.com>
* Revert "style:组件对齐云舍4.1主题 (#4337)" (#4343)
This reverts commit 75918c3f5d
.
* test:补充事件动作测试用例 (#4350)
* feat: table支持事件动作
* feat:options 支持在虚拟渲染时控制选项高度
* 恢复之前的 100 阀值避免单元测试报错
* 恢复之前的用例
Co-authored-by: RUNZE LU <36724300+lurunze1226@users.noreply.github.com>
Co-authored-by: Allen <yupeng.fe@qq.com>
Co-authored-by: hsm-lv <80095014+hsm-lv@users.noreply.github.com>
Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com>
Co-authored-by: xujiahao01 <xujiahao01@baidu.com>
Co-authored-by: qiaogg <43558337+qiaogg@users.noreply.github.com>
Co-authored-by: qiaoganggang <qiaoganggang@baidu.com>
Co-authored-by: sansiro <sansiro@sansiro.me>
Co-authored-by: liuzedong02 <liuzedong02@baidu.com>
Co-authored-by: liweijian <liweijian@hkmtl.com>
Co-authored-by: sarding <37691952+sarding@users.noreply.github.com>
Co-authored-by: sarding <hongfuquan@baidu.com>
Co-authored-by: 徐佳豪 <53201551+blue-squirrel@users.noreply.github.com>
Co-authored-by: HongYang <33488114+hy993658052@users.noreply.github.com>
Co-authored-by: hongyang03 <hongyang03@baidu.com>
Co-authored-by: pianruijie <13522335863@163.com>
Co-authored-by: zhangtao07 <zhang.tao.1006@163.com>
Co-authored-by: liaoxuezhi <2betop.cn@gmail.com>
Co-authored-by: mr-chenguang <37072324+lcgash@users.noreply.github.com>
Co-authored-by: lvchenguang <lvchenguang@zhihu.com>
Co-authored-by: decarp <zhycde@gmail.com>
Co-authored-by: zhyc <zhyc@hzsuoyi.com>
Co-authored-by: metooweb <2947550545@qq.com>
Co-authored-by: metooweb <1058776960@qq.com>
Co-authored-by: 刘丹 <365533093@qq.com>
Co-authored-by: 龙少 <1769057083@qq.com>
Co-authored-by: zhangxulong <zhangxulong@baidu.com>
Co-authored-by: wanglinfang2014 <w.l.fang@foxmail.com>
Co-authored-by: wanglinfang <wanglinfang@baidu.com>
Co-authored-by: zhou999 <zhousq809@163.com>
Co-authored-by: sqzhou <zhoushengqiang01@MacBook-Pro-2.local>
Co-authored-by: sqzhou <zhoushengqiang01@baidu.com>
1426 lines
37 KiB
Markdown
Executable File
1426 lines
37 KiB
Markdown
Executable File
---
|
||
title: Options 选择器表单项
|
||
description:
|
||
type: 0
|
||
group: null
|
||
menuName: Options 选择器表单项
|
||
icon:
|
||
order: 2
|
||
---
|
||
|
||
**选择器表单项** 是指那些(例如下拉选择框)具有选择器特性的表单项
|
||
|
||
它派生自 [表单项](./formitem),拥有表单项所有的特性。
|
||
|
||
## 选项组格式
|
||
|
||
选择器表单项可以通过配置一组选项(`options`),可以供给用户选择,如下:
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
`options`属性配置的对象数组就是`select`选择器组件的选项组。
|
||
|
||
### 标准格式
|
||
|
||
```json
|
||
{
|
||
"options": [
|
||
{
|
||
"label": "xxx1",
|
||
"value": "value1",
|
||
"children": []
|
||
... // 其他变量值
|
||
},
|
||
{
|
||
"label": "xxx2",
|
||
"value": "value2",
|
||
"children": []
|
||
... // 其他变量值
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
标准的选项格式为对象数组,数组中的每个对象需要两个必备字段:
|
||
|
||
- `label`:标识当前选项的显示文本,帮助用户选择
|
||
- `value`:标识当前选项的值,用作数据保存和映射
|
||
- `children`:嵌套子选项,只有在 Tree 或 Nested-Select 等支持嵌套功能的组件中才有用
|
||
|
||
查看下面例子,修改选项你会发现数据域会发发生变化,改数据域中该表单项的值为选中选项的`value`值。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
### 简单格式
|
||
|
||
也可以配置简单的字符串或数字数组,此时默认`label`和`value`保持一致
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"options": ["A", "B", "C"]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 静态选项组 options
|
||
|
||
可以使用静态方式,配置一组选项组:
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 动态选项组 source
|
||
|
||
### 通过数据域中变量配置
|
||
|
||
你也可以配置`source`属性,利用 [数据映射](../../../docs/concepts/data-mapping),获取当前数据链中的变量
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"data": {
|
||
"items": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
},
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"source": "${items}"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
上例中,我们给 select 组件,配置`"source": "${items}"`,获取了当前数据域中的`items`变量作为选项组。
|
||
|
||
### 远程拉取
|
||
|
||
除了可以通过数据映射获取当前数据域中的变量以外,`source`还支持配置接口,格式为 [API](../../../docs/types/api),用于动态返回选项组。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"source": "/api/mock2/form/getOptions?waitSeconds=1"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
远程拉取接口时,返回的数据结构除了需要满足 [amis 接口要求的基本数据结构](../../../docs/types/api#%E6%8E%A5%E5%8F%A3%E8%BF%94%E5%9B%9E%E6%A0%BC%E5%BC%8F-%E9%87%8D%E8%A6%81-) 以外,必须用`"options"`作为选项组的`key`值,如下
|
||
|
||
```json
|
||
{
|
||
"status": 0,
|
||
"msg": "",
|
||
"data": {
|
||
// 必须用 options 作为选项组的 key 值
|
||
"options": [
|
||
{
|
||
"label": "A",
|
||
"value": "a"
|
||
},
|
||
{
|
||
"label": "B",
|
||
"value": "b"
|
||
},
|
||
{
|
||
"label": "C",
|
||
"value": "c"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
## 默认值/自动选中 value
|
||
|
||
我们知道表单项可以通过配置`value`属性来设置默认值
|
||
|
||
而选择器表单项如果设置`value`属性,为某一个选项中的`value`值,那么该选择器将自动选中该选项。
|
||
|
||
### 静态配置
|
||
|
||
静态配置同表单项默认值配置方式,直接在组件上配置`value`属性。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"value": "b",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
上例我们设置默认值为`b`,则会自动匹配到选项`B`并选中。
|
||
|
||
如果想默认选择第一个,可以直接配置 `selectFirst` 属性。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"selectFirst": true,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
### 动态配置
|
||
|
||
有时候我们想默认选中一个选项,但是`options`又是远程拉取的,无法确定默认值是啥,这时候,**需要在`source`接口中返回`value`,来动态设置默认值**,**接口返回数据结构**如下:
|
||
|
||
```json
|
||
{
|
||
"status": 0,
|
||
"msg": "",
|
||
"data": {
|
||
"value": "b", // 这样就会自动选中b选项
|
||
"options": [
|
||
{
|
||
"label": "A",
|
||
"value": "a"
|
||
},
|
||
{
|
||
"label": "B",
|
||
"value": "b"
|
||
},
|
||
{
|
||
"label": "C",
|
||
"value": "c"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
### 数据格式一致性问题
|
||
|
||
当使用 `source` 或 `value` 配置默认值的时候,需要保持数据格式的一致性。
|
||
|
||
如果使用 `source` 或 `value` 配置的默认值与当前表单项配置的数据格式不符合,而且用户没有再次操作该表单项,而直接提交表单,那么会将当前默认值原封不动的提交给后端,可能会导致不一致性的问题,我们看一个例子:
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"multiple": true,
|
||
"value": ["a", "c"],
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
上例中, `select` 我们配置了`"multiple": true`,预期中,我们希望选中 `A` 和 `C` 项时,表单项的数据格式为:`"a,c"`,但是我们设置了`"value": ["a", "c"]`,并不符合我们当前表单项的数据格式配置,这样会导致两个问题:
|
||
|
||
1. 有可能不会默认选中 `A` 和 `C` 选项;
|
||
2. 当不操作该表单项,直接提交时,预期是:`"a,c"`,但提交给后端的数据为:`["a", "c"]`,导致了不一致性的问题。
|
||
|
||
> 通过 `source` 配置默认值同理,不再赘述
|
||
|
||
因此一定确保默认值与选择器表单项数据格式配置相匹配。
|
||
|
||
## 多选 multiple
|
||
|
||
大部分选择器组件默认是单选的,可以配置`"multiple": true`支持多选。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"data": {
|
||
"options": [
|
||
{
|
||
"label": "A",
|
||
"value": "a"
|
||
},
|
||
{
|
||
"label": "B",
|
||
"value": "b"
|
||
},
|
||
{
|
||
"label": "C",
|
||
"value": "c"
|
||
}
|
||
]
|
||
},
|
||
"body": [
|
||
{
|
||
"label": "单选",
|
||
"type": "select",
|
||
"name": "select1",
|
||
"source": "${options}"
|
||
},
|
||
{
|
||
"type": "divider"
|
||
},
|
||
{
|
||
"label": "多选",
|
||
"type": "select",
|
||
"name": "select2",
|
||
"multiple": true,
|
||
"source": "${options}"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
还可以通过 `checkAll` 开启全选。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "多选",
|
||
"type": "select",
|
||
"name": "select2",
|
||
"checkAll": true,
|
||
"multiple": true,
|
||
"source": "/api/mock2/form/getOptions"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
默认多选的值格式为逗号拼接 value 值,例如:`1,2,3`,如果需要改变值格式,请阅读下面 [拼接符 delimiter](#%E6%8B%BC%E6%8E%A5%E7%AC%A6-delimiter)、[拼接值 joinValues](#%E6%8B%BC%E6%8E%A5%E5%80%BC-joinvalues) 和 [提取多选值 extractValue](#%E6%8F%90%E5%8F%96%E5%A4%9A%E9%80%89%E5%80%BC-extractvalue)配置项。
|
||
|
||
如果值太多折行可以通过 `valuesNoWrap` 来避免折行。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "多选",
|
||
"type": "select",
|
||
"name": "select2",
|
||
"checkAll": true,
|
||
"valuesNoWrap": true,
|
||
"multiple": true,
|
||
"source": "/api/mock2/form/getOptions"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 拼接符 delimiter
|
||
|
||
多选模式下,默认表单项值为选中的选项的`value`值,用默认拼接符`,`拼接,如下
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"multiple": true,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
默认的拼接符是逗号`,`,但是当你的某个选项中的`value`值内包含`,`这个字符,这样会造成一些预期中的问题
|
||
|
||
你可以设置`delimiter`属性,自定义拼接符,保证不与你选项中的`value`值冲突
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"multiple": true,
|
||
"delimiter": "|",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a,1"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b,2"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c,3"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
上例我们`value`中有逗号,与默认拼接符冲突,这时设置`"delimiter": "|"`,可以看到选择多个选项时,每个选项的`value`属性会用`|`拼接起来,作为表单项的值
|
||
|
||
## 拼接值 joinValues
|
||
|
||
当选择器表单项选中某一选项后,当前表单项的值格式默认:
|
||
|
||
- 单选:选中选项的`value`值
|
||
- 多选:选中所有选项的`value`,用拼接符进行拼接,默认拼接符为`,`
|
||
|
||
选中下面两个选择器,观察数据域值变化。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "单选",
|
||
"type": "select",
|
||
"name": "select1",
|
||
"options": [
|
||
{
|
||
"label": "A",
|
||
"value": "a"
|
||
},
|
||
{
|
||
"label": "B",
|
||
"value": "b"
|
||
},
|
||
{
|
||
"label": "C",
|
||
"value": "c"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"type": "divider"
|
||
},
|
||
{
|
||
"label": "多选",
|
||
"type": "select",
|
||
"name": "select2",
|
||
"multiple": true,
|
||
"options": [
|
||
{
|
||
"label": "A",
|
||
"value": "a"
|
||
},
|
||
{
|
||
"label": "B",
|
||
"value": "b"
|
||
},
|
||
{
|
||
"label": "C",
|
||
"value": "c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
但是你可以通过配置`"joinValues": false`,来获取完整的选项对象
|
||
|
||
### 单选模式
|
||
|
||
单选模式下,配置`"joinValues": false`,该表单项值为选中选项的完整对象值,选中下例中的任意选项,观察数据域变化。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"joinValues": false,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
### 多选模式
|
||
|
||
多选模式下,配置`"joinValues": false`,该表单项值为所有选中项的对象数组
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"multiple": true,
|
||
"joinValues": false,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
### 自动选中问题
|
||
|
||
当你通过`joinValues`调整选择器表单项的数据结构后,设置默认值时,格式也要和设置的数据结构保持一致
|
||
|
||
例如下面这个例子,当你给`select`设置了`"joinValues": false`时,选中 B 选项,则该表单项值为`{"label":"B","value":"b"}`,如果你想要默认选中某一项,则也需要设置`value`为完整的对象:`{"label":"B","value":"b"}`
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"joinValues": false,
|
||
"value": {
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 提取多选值 extractValue
|
||
|
||
当`"joinValues": false`时,默认会将选中的所有选项组成的对象数组,作为表单项的值,如果你想只抽取选项中的 value 值,拼成新的数组,那么可以配置`"extractValue": true`
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"multiple": true,
|
||
"joinValues": false,
|
||
"extractValue": true,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
选中所有选型,你会看到表单项的值为:`["a", "b", "c"]`。
|
||
|
||
### 自动选中问题
|
||
|
||
当你通过`joinValues`和`extractValue`调整选择器表单项的数据结构后,设置默认值时,格式也要和设置的数据结构保持一致
|
||
|
||
例如下面这个例子,当你给`select`设置了`"joinValues": false`和`"extractValue": true`时,选中 A、B 选项,则该表单项值为`["a", "b"]`,如果你想要默认选中某一项,则也需要设置`value`为同样格式:`["a", "b"]`
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"multiple": true,
|
||
"joinValues": false,
|
||
"extractValue": true,
|
||
"value": ["a", "b"],
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 检索 searchable
|
||
|
||
可以配置 `"searchable": true` 显示前端过滤,适合用于有大量内容的列表。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"searchable": true,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
## 自动补全 autoComplete
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"name": "select",
|
||
"type": "select",
|
||
"label": "选项自动补全",
|
||
"autoComplete": "/api/mock2/options/autoComplete?term=$term",
|
||
"placeholder": "请输入"
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
可以在`autoComplete`配置中,用数据映射,获取变量`term`,为当前输入的关键字。
|
||
|
||
支持该配置项的组件有:Text、Select、Chained-Select、TreeSelect、Condition-Builder。
|
||
|
||
## 选项标签字段 labelField
|
||
|
||
默认渲染选项组,会获取每一项中的`label`变量作为展示文本,如果你的选中项中没有`label`字段,可能会有显示问题
|
||
|
||
例如下例中,options 中只有`text`和`value`字段而没有 `label` 字段,这时点开下拉框,你会发现选项无法正常显示。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"options": [
|
||
{
|
||
"text":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"text":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"text":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
这种情况下如果你想自定义该字段,则可以设置`labelField`
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"labelField": "text",
|
||
"options": [
|
||
{
|
||
"text":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"text":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"text":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
> 不推荐使用该方式,建议格式化好选项组数据结构
|
||
|
||
## 选项值字段 valueField
|
||
|
||
默认渲染选项组,会获取每一项中的`value`变量作为表单项值,如果你的选中项中没有`value`字段,将会无法选中
|
||
|
||
例如下例中,options 中只有`label`和`val`字段而没有`value`字段,这时点开下拉框,你会发现选项无法正常选中。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"val":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"val":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"val":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
这种情况下如果你想自定义该字段,则可以设置`valueField`
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"valueField": "val",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"val":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"val":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"val":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
> 不推荐使用该方式,建议格式化好选项组数据结构
|
||
|
||
## 新增选项
|
||
|
||
部分选择器组件支持在前端进行新增选项的操作。
|
||
|
||
支持该功能的组件有:CheckBoxes、Select、Tree
|
||
|
||
### 前端新增 creatable
|
||
|
||
,可以配置`"creatable": true`,支持在前端临时新增选项。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"creatable": true,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
点开下拉框,会看到选项列表底部有`新增选项`按钮,点击后会显示一个包含简单表单的弹框,点击提交可以新增选项,不同组件交互会有不同。
|
||
|
||
新增选项表单弹框的默认配置如下:
|
||
|
||
```json
|
||
{
|
||
"type": "dialog",
|
||
"title": "新增选项",
|
||
"body": {
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"type": "text",
|
||
"name": "label",
|
||
"label": false,
|
||
"placeholder": "请输入名称"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
- 你可以配置`createBtnLabel`来自定义这个弹框的标题;
|
||
- 你也可以配置`optionLabel`,来替换`"选项"`这个字符,如我们配置`"optionLabel": "员工"`,标题会显示:`新增员工`;
|
||
- 默认表单项的`name`属性为`labelField`所配置的值,默认为`label`
|
||
|
||
### 自定义新增表单项 addControls
|
||
|
||
默认只有一个文本框,也就是意味着,默认添加选项后,该选项`label`和`value`是一样的,如果你想自定义该表单中的表单项,你可以通过配置`addControls`属性
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"creatable": true,
|
||
"addControls": [
|
||
{
|
||
"type": "text",
|
||
"name": "label",
|
||
"label": "选项标题"
|
||
},
|
||
{
|
||
"type": "text",
|
||
"name": "value",
|
||
"label": "选项值"
|
||
}
|
||
],
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
上例中你可以选项标题输入`D`,选项值输入`d`。实现自定义添加选项格式
|
||
|
||
不过在没配置保存接口时,`addControls`中务必需要有`labelField`和`valueField`所配置的`name`表单项才可以正确保存
|
||
|
||
> `addControls`属性格式为表单项数组,更多细节参考 [FormItem 表单项](./formitem)。
|
||
|
||
### 配置新增接口 addApi
|
||
|
||
默认新增只会暂时把新增的值保存在前端,如果你想前端新增选项后,同时把该选项保存到后端,则可以配置保存接口`addApi`。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"addApi": "/api/mock2/form/saveForm",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
> 配置`addApi`实际上将该配置值设置给该表单的`api`属性。
|
||
>
|
||
> 如果同时配置了`source`和`addApi`,添加选项成功后会重新获取请求`source`接口
|
||
|
||
## 编辑选项
|
||
|
||
部分选择器组件支持在前端编辑选项
|
||
|
||
支持该功能的组件有:CheckBoxes、Select、Tree、Table-formitem
|
||
|
||
### 前端编辑 editable
|
||
|
||
配置`"editable": true`,支持在前端编辑选项。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"editable": true,
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
点开下拉框,会看到每个选项右侧有一个编辑图标,点击后会显示一个编辑选项的弹框,修改后点击提交可以编辑选项标签。不同组件交互会有不同
|
||
|
||
编辑选项弹框的默认配置如下:
|
||
|
||
```json
|
||
{
|
||
"type": "dialog",
|
||
"title": "新增选项",
|
||
"body": {
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"type": "text",
|
||
"name": "label",
|
||
"label": false,
|
||
"placeholder": "请输入名称"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
```
|
||
|
||
- 你也可以配置`optionLabel`,来替换`"选项"`这个字符,如我们配置`"optionLabel": "员工"`,标题会显示:`新增员工`;
|
||
- 默认表单项的`name`属性为`labelField`所配置的值,默认为`label`
|
||
|
||
### 自定义编辑表单项 editControls
|
||
|
||
默认只能修改当前选项的`label`属性,如果你想要修改其他属性,可以配置`editControls`,自定义编辑表单项
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"editable": true,
|
||
"editControls": [
|
||
{
|
||
"type": "text",
|
||
"name": "label",
|
||
"label": "选项标题"
|
||
},
|
||
{
|
||
"type": "text",
|
||
"name": "value",
|
||
"label": "选项值"
|
||
}
|
||
],
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
修改后重新选中该表单项,观察数据域中数据变化。
|
||
|
||
### 配置编辑接口 editApi
|
||
|
||
默认编辑只会作用在前端,如果你想前端编辑选项后,同时把该选项保存到后端,则可以配置保存接口`editApi`。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"editApi": "/api/mock2/form/saveForm",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
> 配置`editApi`实际上将该配置值设置给编辑表单的`api`属性。
|
||
>
|
||
> 如果同时配置了`source`和`editApi`,添加选项成功后会重新获取请求`source`接口
|
||
|
||
## 删除选项
|
||
|
||
部分选择器组件,支持在前端进行编辑选项操作
|
||
|
||
支持该功能的组件有:CheckBoxes、Select、Tree、Table-formitem
|
||
|
||
### 配置删除接口 deleteApi
|
||
|
||
删除选项不支持在前端级别删除,我们认为是没有意义的,必须要配置`deleteApi`使用接口进行删除
|
||
|
||
配置`"removable": true`和`deleteApi`,支持在前端删除选项。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"label": "选项",
|
||
"type": "select",
|
||
"name": "select",
|
||
"deleteApi": "/api/mock2/form/saveForm",
|
||
"options": [
|
||
{
|
||
"label":"A",
|
||
"value":"a"
|
||
},
|
||
{
|
||
"label":"B",
|
||
"value":"b"
|
||
},
|
||
{
|
||
"label":"C",
|
||
"value":"c"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
点开下拉框,鼠标悬浮在选项上,可以看到右侧会有删除图标,点击可请求删除接口进行删除
|
||
|
||
## 自动填充 autoFill
|
||
|
||
一些选择器组件,支持配置`autoFill`,将当前已选中的选项的某个字段的值,自动填充到表单中某个表单项中,支持[数据映射](../../../docs/concepts/data-mapping)
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"api": "/api/mock2/form/saveForm",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"type": "select",
|
||
"label": "选项",
|
||
"name": "select",
|
||
"autoFill": {
|
||
"option.instantValidate": "${label}",
|
||
"option.submitValidate": "${label}",
|
||
},
|
||
"clearable": true,
|
||
"options": [
|
||
{
|
||
"label": "Option A",
|
||
"value": "a"
|
||
},
|
||
{
|
||
"label": "Option B",
|
||
"value": "b"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"type": "input-text",
|
||
"name": "option.instantValidate",
|
||
"label": "选中项",
|
||
"description": "填充后立即校验",
|
||
"required": true,
|
||
"validateOnChange": true,
|
||
"validations": {
|
||
"equals": "Option B"
|
||
},
|
||
"validationErrors": {
|
||
"equals": "校验失败,数据必须为Option B"
|
||
}
|
||
},
|
||
{
|
||
"type": "input-text",
|
||
"name": "option.submitValidate",
|
||
"label": "选中项1",
|
||
"description": "填充后提交表单时才校验",
|
||
"required": true,
|
||
"validations": {
|
||
"equals": "Option B"
|
||
},
|
||
"validationErrors": {
|
||
"equals": "校验失败,数据必须为Option B"
|
||
}
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
上例中我们配置了`"autoFill": {"option.instantValidate": "${label}"}`,表示将选中项中的`label`的值,自动填充到当前表单项中`name`为`option.instantValidate`的文本框中。可以额外配置`"validateOnChange": true`,实现自动填充后立即校验填充项。
|
||
|
||
**多选模式**
|
||
|
||
当表单项为多选模式时,不能再直接取选项中的值了,而是通过 `items` 变量来取,通过它可以获取当前选中的选项集合。
|
||
|
||
```schema: scope="body"
|
||
{
|
||
"type": "form",
|
||
"api": "/api/mock2/form/saveForm",
|
||
"debug": true,
|
||
"body": [
|
||
{
|
||
"type": "select",
|
||
"label": "选项",
|
||
"name": "select",
|
||
"autoFill": {
|
||
"options": "${items|pick:label}",
|
||
"firstOption": "${items|first|pick:label}"
|
||
},
|
||
"multiple": true,
|
||
"clearable": true,
|
||
"options": [
|
||
{
|
||
"label": "Option A",
|
||
"value": "a"
|
||
},
|
||
{
|
||
"label": "Option B",
|
||
"value": "b"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
```
|
||
|
||
支持该配置项的有:ButtonGroup、List、NestedSelect、Picker、Radios、Select。
|
||
|
||
## 控制选项高度
|
||
|
||
> 1.10.0 及以上版本
|
||
|
||
下拉框在数据量较大时(超过 200,可以通过 `virtualThreshold` 控制)会自动切换到虚拟渲染模式,如果选项的内容较长会导致内容重叠,这时需要设置 `itemHeight` 来避免。
|
||
|
||
## 属性表
|
||
|
||
除了支持 [普通表单项属性表](./formitem#%E5%B1%9E%E6%80%A7%E8%A1%A8) 中的配置以外,还支持下面一些配置
|
||
|
||
| 属性名 | 类型 | 默认值 | 说明 |
|
||
| ---------------- | --------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------- |
|
||
| options | `Array<object>`或`Array<string>` | | 选项组,供用户选择 |
|
||
| source | [API](../../../docs/types/api) 或 [数据映射](../../../docs/concepts/data-mapping) | | 选项组源,可通过数据映射获取当前数据域变量、或者配置 API 对象 |
|
||
| multiple | `boolean` | `false` | 是否支持多选 |
|
||
| labelField | `boolean` | `"label"` | 标识选项中哪个字段是`label`值 |
|
||
| valueField | `boolean` | `"value"` | 标识选项中哪个字段是`value`值 |
|
||
| joinValues | `boolean` | `true` | 是否拼接`value`值 |
|
||
| extractValue | `boolean` | `false` | 是否将`value`值抽取出来组成新的数组,只有在`joinValues`是`false`是生效 |
|
||
| itemHeight | `number` | | 每个选项的高度,用于虚拟渲染 |
|
||
| virtualThreshold | `number` | | 在选项数量超过多少时开启虚拟渲染 |
|
||
| valuesNoWrap | `boolean` | `false` | 默认情况下多选所有选项都会显示,通过这个可以最多显示一行,超出的部分变成 ... |
|