amis input-tree| nav 联动CRUD默认请求及input-tree远程配置拉取

dgiusagp  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(48)
实现场景:

使用input-tree侧边栏联动crud

存在的问题:
  1. 进入相关页面时,页面不会请求crud中的api,必须点击侧边栏才会有api请求拉取数据,如何在进入页面时就可以默认请求某一个侧边栏的联动数据呢?
  2. 想通过远程api拉取input-tree的options数据,参考nav的数据返回格式,无效,也没有看到相关的配置文档
当前方案:

请粘贴你当前方案的完整 amis schema 代码...

"aside": {
        "type": "form",
        "wrapWithPanel": false,
        "target": "hosts",
        "submitOninit": true,
        "body": [
            {
                "type": "input-tree",
                "name": "groupid",
                "inputClassName": "no-border no-padder mt-1",
                "heightAuto": true,
                "submitOnChange": true,
                "selectFirst": true,
                "inputOnly": true,
                "options": [
                    {
                        "label": "国际服",
                        "value": 1
                    },
                    {
                        "label": "硬核联盟",
                        "value": 2
                    }
                ]
            }
        ]
    },
   "body": {
        "type": "crud",
        "name": "hosts",
        "draggable": true,
        "api": {
            "url": "{domain}/api/cmdb/v1/get_hosts?page=${page}&perPage=${perPage}&groupid=${groupid}",
            "sendOn": "this.groupid"
        },
        "showPerPage": true,
        "perPage": 10,
        "keepItemSelectionOnPageChange": true,
        "syncLocation": true,
        "footerToolbar": [
            "statistics",
            "switch-per-page",
            "pagination",
            "reload"
        ],
        "columns": [
            {
                "name": "id",
                "label": "ID",
                "type": "text"
            }
         ]
}
# 远程返回
{"data":{"links":[{"label":"国际服","value":1,"to":"?groupid=1"},{"label":"硬核联盟","value":2,"to":"?groupid=2"}]},"msg":"ok","status":0}
dvtswwa3

dvtswwa31#

crud 的 api 接口不要配置 sendOn ,考虑使用事件动作来触发 CRUD 的 reload

相关问题