amis icon indicating copy to clipboard operation
amis copied to clipboard

组件间联动清空

Open chenyphaaa opened this issue 6 years ago • 2 comments

实现场景:

radios切换时清空表单中table的数据

存在的问题:

可以添加roles角色列表,在table中显示出来,想做到 radios控件切换时清空表单中roles的数据,在数据联动中没有找到合适的方法

当前方案:

 {
    "label": "玩家类型",
    "type": "radios",
    "name": "idType",
    value: 2,
    reload:"roles",
    "inline": true,
    "options": [
        {
            "label": "OpenId",
            "value": 1,
        },
        {
            "label": "Uid",
            "value": 2,
        },
        {
            "label": "RoleId",
            "value": 3,
        }
    ]
},
{
    type: 'form',
    btnLabel: "添加信息",
    name: "roles",
    label: "添加信息",
    multiple: true,
    form: {
        title: "添加信息",
        controls: [

            {
                "label": "区服",
                "type": "select",
                "name": "serverId",
                "source": "http://127.0.0.1:8003/api/game/get-secs?plat=${plat}",
                "visibleOn": "data.forbidType != 1",
                "initFetchOn": "data.plat",
            },
            {
                type: "text",
                label: "玩家标识",
                name: 'id',
                placeholder: "根据类型添加玩家标识",
            },
        ],
    }
},

{
    "type": "table",
    "name": "roles",
    "columns": [
        {
            "name": "serverId",
            "label": "区服"
        },
        {
            type:"mapping",
            "name": "idType",
            "label": "玩家类型",
            "map":{
                "1":"OpenId",
                "2":"Uid",
                "3":"RoleId"
            }
        },
        {
            "name": "id",
            "label": "玩家标识"
        }
    ]
},

chenyphaaa avatar Sep 17 '20 03:09 chenyphaaa

应该可以用formula,先看下文档试试 https://baidu.gitee.io/amis/docs/components/form/formula

RickCole21 avatar Sep 17 '20 10:09 RickCole21

谢谢,可以了

{
    "type": "formula",
    "name": "roles",
    "value": [],
    "formula": "''",
    "condition": "${idType}||${forbidType}",
    "initSet": false
},

chenyphaaa avatar Sep 18 '20 03:09 chenyphaaa