baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.38k stars 2.52k forks source link

CRUD的批量数据提取 #4355

Closed vexos-io closed 1 year ago

vexos-io commented 2 years ago

无法用表达式: ${selectedItems|pick:x.x}

但可以用:${selectedItems|json|toJson|pick:x.x}

请问是什么原因?

meerkat-morecats commented 2 years ago

无法用表达式: ${selectedItems|pick:x.x}

但可以用:${selectedItems|json|toJson|pick:x.x}

请问是什么原因?

麻烦提供一下可复现问题的json

vexos-io commented 2 years ago

使用${selectedItems|pick:任何数据}都是无法成功的,转化为json再转回来就成功了

vexos-io commented 2 years ago

多谢关注,我猜测不是pick本身的问题,应该是【CRUD的selectedItems】有什么特殊的情况,因为对于同样的JSON,直接pick是没问题的

meerkat-morecats commented 2 years ago

是我之前没有说清楚,你可以在这个网站 https://aisuda.github.io/amis-editor-demo/#/hello-world 上复现问题,并把生成的json代码发一下吗

vexos-io commented 2 years ago

{ "type": "page", "title": "Hello world", "body": [ { "type": "tpl", "tpl": "初始页面", "inline": false }, { "type": "crud", "api": "", "columns": [ { "name": "id", "label": "ID", "type": "text" }, { "name": "engine", "label": "渲染引擎", "type": "text" }, { "type": "operation", "label": "操作", "buttons": [ ] } ], "bulkActions": [ { "label": "PICK测试", "type": "button", "actionType": "ajax", "api": "/xxx/foo?bar=${selectedItems|pick:id|join:,}" } ], "itemActions": [ ], "features": [ "bulkDelete", "bulkUpdate" ], "perPageAvailable": [ 10 ], "messages": { }, "data": { "items": [ { "id": "101", "engine": "A" }, { "id": "102", "engine": "B" } ] } } ] }

以上代码的"PICK测试"按钮获取不到 ${selectedItems|pick:id|join:,}

vexos-io commented 2 years ago

好像试出来了,是items变量,不应该是selectedItems,求确认是不是这个原因

meerkat-morecats commented 2 years ago

还是按照你之前的用法${selectedItems|json|toJson|pick:x.x}吧,我们近期修复一下

vexos-io commented 2 years ago

好的,辛苦了,您来决定是否关闭这个issue吧