Skip to content

当CRUD组件设置syncLocation为false时,出现筛选参数未携带的情况 #11852

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

Open
kliuoi opened this issue Apr 11, 2025 · 1 comment

Comments

@kliuoi
Copy link

kliuoi commented Apr 11, 2025

描述问题:

在当CRUD组件设置syncLocation为false时,出现筛选参数未携带的情况:

筛选启用状态为启用时,筛选参数正常携带,但筛选启用状态为禁用时,筛选参数未携带

Image

后来发现当搜索配置的value设置为"1"、"0", 效果也可以正常

Image

是否可以修复一下,正常使用true、false做为筛选参数的值

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的?

使用js sdk app方式

  1. amis 版本是什么?请先在最新 beta 版本测试问题是否存在

6.11.0、6.12.0均可复现

  1. 粘贴有问题的完整 amis schema 代码:
{
    "type": "crud",
    "perPage": 20,
    "api": {
        "url": "/kadmin/api/v1/user/list",
        "method": "get",
        "data": {
            "&": "$$",
            "page": "${page}",
            "perPage": "${perPage}",
            "orderBy": "${orderBy|default:undefined}",
            "orderDir": "${orderDir|default:undefined}",
            "email": "${email|default:undefined}",
            "name": "${name|default:undefined}",
            "status": "${status|default:undefined}"
        }
    },
    // 是否显示列筛选开关
    "columnsTogglable": true,
    // 自动搜素配置
    "autoGenerateFilter": {
        // 搜索列数
        "columnsNum": 3,
        // 默认自动收起
        "defaultCollapsed": false
    },
    "showIndex": true,
    // 列配置
    "columns": [
        {
            "type": "text",
            "label": "UID",
            "name": "id",
            // 默认不显示
            "visible": false
        },
        {
            "type": "text",
            "label": "邮箱",
            "name": "email",
            "align": "left",
            "sortable": true,
            "searchable": {
                "type": "input-text",
                "label": "邮箱",
                "name": "email",
                "placeholder": "输入邮箱查询",
                // 是否可清除
                "clearable": true
            }
        },
        {
            "type": "text",
            "label": "昵称",
            "name": "name",
            "align": "center",
            // 是否可排序
            "sortable": true,
            "searchable": {
                "type": "input-text",
                "label": "昵称",
                "name": "name",
                "placeholder": "输入昵称查询",
                // 是否可清除
                "clearable": true
            }
        },
        {
            "type": "switch",
            "label": "启用状态",
            "name": "status",
            "align": "center",
            "onText": "启用",
            "offText": "禁用",
            "onEvent": {
                "change": {
                    "actions": [
                        {
                            "actionType": "ajax",
                            "api": {
                                "url": "/kadmin/api/v1/user/update/info",
                                "method": "put",
                                "dataType": "json",
                                "data": {
                                    "id": "${id}",
                                    "status": "${status}"
                                }
                            }
                        }
                    ]
                }
            },
            // 搜索配置
            "searchable": {
                "type": "select",
                "label": "启用状态",
                "name": "status",
                "options": [
                    // 在设置syncLocation为false后,配置value为"1"、"0"后,筛选效果正常
                    {
                        "label": "启用",
                        "value": true
                        // "value": "1"
                    },
                    {
                        "label": "禁用",
                        "value": false
                        // "value": "0"
                    }
                ],
                // 是否可清除
                "clearable": true
            }
        },
        {
            "type": "operation",
            "label": "操作",
            "fixed": "right",
            "buttons": [
                {
                    "type": "button",
                    "label": "详情",
                    "level": "link",
                    "icon": "fa fa-eye",
                    "actionType": "dialog",
                    "dialog": {
                        "title": "查看",
                        "body": [
                            {
                                "type": "form",
                                "body": [
                                    {
                                        "type": "static",
                                        "label": "UID",
                                        "name": "id"
                                    },
                                    {
                                        "type": "static",
                                        "label": "邮箱",
                                        "name": "email"
                                    },
                                    {
                                        "type": "static",
                                        "label": "昵称",
                                        "name": "name"
                                    },
                                    {
                                        "type": "static",
                                        "label": "启用状态",
                                        "name": "status",
                                        "tpl": "${IF(status === true, \"启用\",\"禁用\")}"
                                    }
                                ]
                            }
                        ]
                    }
                }
            ]
        }
    ],
    // ...
    // 是否开启拖拽排序
    "draggable": false,
    // 是否将过滤条件的参数同步到地址栏,默认为true
    "syncLocation": false
}
Copy link

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant