-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Options 选择器表单项多选 multiple在联动时存在BUG,标签没被清除 #11210
Comments
👍 Thanks for this! Please review the labels and make any necessary changes. |
@2betop @TeCHiScy @luckyufei @weien601 使用source远程获取时也是一样,当我已经有选择的情况下,通过动作对此组件重新获取数据时,接口返回数据是空的,但是标签依然存在,点击下拉是提示没内容的,但是手动删除后,就自动给添加了一个标签的数据存储到了options里面 |
目前解决办法是,在type这个组件中添加一个清除事件 |
但是还有一个更加难处理的BUG,表单数据是从接口获取的,在这种情况下type这个组件不管你怎么去添加什么事件都没有,标签一直显示接口获取到的,手动清除后,在type这个组件值变化后platform的又恢复接口获取的 |
这个bug之前反馈过 ,我还提过pr,不过不规范, 后续官方估计会修改,先用自己方法搞定吧~~ Amis低代码前端框架交流群【QQ1群】:717791727 |
你的核心需求是,第2个选项框的options, 是根据第1个,选项选的值动态切换的,可以换一个联动思路绕一绕。 // 注册一个 filter ,根据第1个选项框,选项值,来设置 第2个选项框的 options。具体逻辑可以任意
registerFilter('setSelect2Options', (select1) => {
if (select1 === 'a') {
return [{
label: 'a1',
value: 'a1'
}, {
label: 'a2',
value: 'a2'
}]
}
if (select1 === 'b') {
return [{
label: 'b1',
value: 'b1'
}, {
label: 'b2',
value: 'b2'
}]
}
if (select1 === 'c') {
return [{
label: 'c1',
value: 'c1'
}, {
label: 'c2',
value: 'c2'
}]
}
})
// 具体配置的JSON
{
"type": "page",
"body": {
type: 'form',
debug: true,
"initApi": {
// 模拟API,同时返回 2个选项框的默认值
url: "/api/amis-mock/mock2/form/initData",
adaptor: () => {
return {
select1: 'a',
select2: 'a1'
}
}
},
body: [{
"type": "button-group-select",
label: 'select1',
name: 'select1',
"options": [
{
type: 'button',
label: 'a',
value: 'a'
},
{
type: 'button',
label: 'b',
value: 'b'
},
{
type: 'button',
label: 'c',
value: 'c'
}
],
// 第1个选项框的值发生变更,自动设置第2个选项框的值
autoFill: {
select2Options: '${value|setSelect2Options}'
},
// 第1个选项框的值发生切换,将第2个框的值删除
onEvent: {
change: {
actions: [{
actionType: 'setValue',
componentId: 'select2',
args: {
value: ''
}
}]
}
}
}
, {
label: 'select2',
name: 'select2',
id: 'select2',
type: 'select',
// 第2个选项框的值,来自于 动态设置的值
source: '${select2Options}',
}],
}
} |
描述问题:
在x'z选择多选的时候,由于options下我添加了hiddenOn来控制是否显示的,当我选择好数据时,再修改联动的组件,是靠这个组件来控制options的,这时由于条件生效,多项的部分就被隐藏了,但是BUG就来了标签没被清除,而是变为了预设值
截图或视频:
type
这个开始默认为1,select这时就是可选择1、4的,选择完后再重新选择type为4,这时候options就没可用的数据了下面这个更加诡异,当手动清除完标签后,下拉选项直接显示被隐藏的预设值

开始我是想使用动作去对表单重置的,这个效果有一点点好用。但是,如果是通过API方式获取表单数据的时候,这个方法就不可行了
如何复现(请务必完整填写下面内容):
你是如何使用 amis 的?
sdk
amis 版本是什么?请先在最新 beta 版本测试问题是否存在
6.9.0
粘贴有问题的完整
amis schema
代码:The text was updated successfully, but these errors were encountered: