Appearance
2.10 表单字段待选值
此章节主要展示通过自动化设置列表选择的选项值的功能。
2.10.1 待选值概念说明
待选值指的是列表选择的选择弹框中展示的选项,一般我们设置好一个列表选择的选项值后,所有选项值都是该列表选择的待选值。在实际使用场景中,我们有可能需要一个列表选择只展示其选项值的一部分作为待选值,例如一个列表选择有a、b、c、d四个选项值,但在表单中我只希望展示a、b,这就需要通过设置列表选择的待选值来实现。
2.10.2 实现逻辑
在列表选择、树形选择、级联选择、用户选择、部门选择五个类型字段设置的设置板块中,有一个配置项为[使用自动化设置待选列表],可在配置中添加一个自动化来实现控制表单字段待选值的效果。该自动化中需要将需要展示的选项设置为自动化的返回值。
2.10.3 自动化返回值说明
通过自动化设置的返回值需要是一个数组,数组中的对象的结构取决于当前字段的存储结构。以下是几个典型的类型字段的案例说明:
列表选择:
列表选择的选项值如图
设置该列表选择字段的待选值,在自动化中的返回值需要为如下结构:
js
[
"finish",
"close",
"cancel"
]
效果展示:
用户选择:
用户选择字段的数据源是团队成员,所有在设置用户选择字段的待选值,在自动化中的返回值需要按团队成员的数据结构构建数组进行返回,成员案例如下:
js
${
[
{
"id": "900001",
"name": "深圳XXX科技有限公司",
"type": "department",
"children": [
{
"avatar": "pic16.png",
"hint": "zhaosunfu",
"id": "zhaosunfu",
"name": "赵孙福",
"remark": "zhaosunfu001",
"type": "member",
"departmentIdList": [
"900001",
"900103"
]
},
{
"id": "900103",
"name": "总办",
"type": "department",
"children": [
{
"avatar": "pic16.png",
"hint": "zhaosunfu",
"id": "zhaosunfu",
"name": "赵孙福",
"remark": "zhaosunfu001",
"type": "member",
"departmentIdList": [
"900001",
"900103"
]
},
{
"avatar": "pic16.png",
"hint": "lisiming",
"id": "lisiming",
"name": "李思明",
"remark": "mingsi.li",
"type": "member",
"departmentIdList": [
"900101",
"900103"
]
}
]
},
{
"id": "900101",
"name": "研发部",
"type": "department",
"children": [
{
"avatar": "pic16.png",
"hint": "lisiming",
"id": "lisiming",
"name": "李思明",
"remark": "mingsi.li",
"type": "member",
"departmentIdList": [
"900101"
]
},
{
"avatar": "pic17.png",
"hint": "wangmingjun",
"id": "wangmingjun",
"name": "王明君",
"remark": "wangmingjun992",
"type": "member",
"departmentIdList": [
"900101"
]
}
]
},
{
"id": "900102",
"name": "市场部",
"type": "department",
"children": [
{
"id": "900111",
"name": "上海部",
"type": "department",
"children": [
{
"avatar": "pic17.png",
"hint": "qiansijiang",
"id": "qiansijiang",
"name": "钱思疆",
"remark": "qiansijiang003",
"type": "member",
"departmentIdList": [
"900111"
]
}
]
},
{
"id": "900112",
"name": "深圳部",
"type": "department",
"children": [
{
"avatar": "pic17.png",
"hint": "sunming",
"id": "sunming",
"name": "孙明",
"remark": "sunming004",
"type": "member",
"departmentIdList": [
"900112"
]
}
]
},
{
"id": "900113",
"name": "西安部",
"type": "department",
"children": [
{
"avatar": "pic17.png",
"hint": "zhangwu",
"id": "zhangwu",
"name": "张武",
"remark": "zhangwu",
"type": "member",
"departmentIdList": [
"900113"
]
}
]
}
]
}
]
}
]
}
展示效果
这里我们发现用户选择的自动化返回值返回的成员不是我们已有的成员,除用户选择和部门选择类型的字段外,通过自动化设置待选值时只能基于原有的选项值进行控制,不能新增选项值。