8000 dialog嵌套crud获取行数据 · Issue #11968 · baidu/amis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dialog嵌套crud获取行数据 #11968

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
Protagonistss opened this issue May 10, 2025 · 6 comments
Open

dialog嵌套crud获取行数据 #11968

Protagonistss opened this issue May 10, 2025 · 6 comments

Comments

@Protagonistss
Copy link

实现场景:

dialog嵌套crud,crud是单选模式,通过点击dialog的按钮 获取单选行的数据

存在的问题:

目前无法获取到单选行的数据

当前方案:

{
  "type": "page",
  "body": {
    "type": "button",
    "label": "打开选择弹窗",
    "actionType": "dialog",
    "dialog": {
      "title": "选择数据",
      "size": "lg",
      "body": [
        {
          "type": "crud",
          "id": "selectCrud",
          "name": "selectCrud",
          "primaryField": "id",
          "selectable": true,
          "multiple": false,
          "columns": [
            {
              "name": "name",
              "label": "名称",
              "type": "text"
            },
            {
              "name": "code",
              "label": "编码",
              "type": "text"
            }
          ],
          "data": {
            "items": [
              {
                "id": 1,
                "name": "选项1",
                "code": "001"
              },
              {
                "id": 2,
                "name": "选项2",
                "code": "002"
              }
            ]
          }
        }
      ],
      "actions": [
        {
          "type": "button",
          "label": "取消",
          "actionType": "cancel"
        },
        {
          "type": "button",
          "label": "确认",
          "level": "primary",
          "onEvent": {
            "click": {
              "actions": [
                {
                  "actionType": "toast",
                  "args": {
                    "msgType": "success",
                    "msg": "你选择了:${event.data.selectedItems[0].name}(编码:${event.data.selectedItems[0].code})"
                  }
                },
                {
                  "actionType": "closeDialog"
                }
              ]
            }
          }
        }
      ]
    }
  }
}
@lhtuling
Copy link
Contributor
lhtuling commented May 12, 2025

感觉你的需求完全可以用选择器组件,没必要自己造轮子了~ 而且你代码我大概看了下你弹窗里面也没做选择

感觉换这个组件更简单,试试看
https://aisuda.bce.baidu.com/amis/zh-CN/components/form/picker

官方示例:
https://aisuda.bce.baidu.com/amis/examples/form/picker

欢迎加入最大的,人数最多的,含佬量极高的社区群
Amis社区交流群【QQ1群】:717791727
Amis社区交流群【QQ2群】:721182449

@Protagonistss
Copy link
Author
Protagonistss commented May 13, 2025

感觉你的需求完全可以用选择器组件,没必要自己造轮子了~ 而且你代码我大概看了下你弹窗里面也没做选择

感觉换这个组件更简单,试试看 https://aisuda.bce.baidu.com/amis/zh-CN/components/form/picker

官方示例: https://aisuda.bce.baidu.com/amis/examples/form/picker

欢迎加入最大的,人数最多的,含佬量极高的社区群 Amis社区交流群【QQ1群】:717791727 Amis社区交流群【QQ2群】:721182449

咱们的picker我看着都是和表单放到一块使用的,picker可以通过一个按钮去唤起吗?

@Protagonistss
Copy link
Author

已解决,谢谢了

@isOUWENacu
Copy link

你看下 其实可以取的不过要用表达式

@isOUWENacu
Copy link

{
"type": "page",
"body": [
{
"type": "button",
"label": "打开选择弹窗",
"actionType": "dialog",
"dialog": {
"type": "dialog",
"title": "选择数据",
"size": "lg",
"body": [
{
"type": "crud",
"id": "selectCrud",
"name": "selectCrud",
"primaryField": "id",
"selectable": true,
"multiple": false,
"columns": [
{
"name": "name",
"label": "名称",
"type": "text",
"id": "u:6868c06a173b",
"placeholder": "-"
},
{
"name": "code",
"label": "编码",
"type": "text",
"id": "u:ff8f53208a45",
"placeholder": "-"
}
],
"perPageAvailable": [
5,
10,
20,
50,
100
],
"messages": {}
}
],
"actions": [
{
"type": "button",
"label": "取消",
"actionType": "cancel",
"id": "u:7d947ec76a64"
},
{
"type": "button",
"label": "确认",
"level": "primary",
"onEvent": {
"click": {
"actions": [
{
"actionType": "toast",
"args": {
"msgType": "success",
"msg": "${LAST(items).name}-${LAST(items).code}"
}
},
{
"actionType": "closeDialog"
}
]
}
},
"id": "u:fc1fd9e7fa7a",
"disabledOnAction": false
}
],
"id": "u:55c17a749dfe",
"showCloseButton": true,
"closeOnOutside": false,
"closeOnEsc": false,
"showErrorMsg": true,
"showLoading": true,
"draggable": false
},
"id": "u:e75a6b819f30",
"disabledOnAction": false
}
],
"id": "u:7e1e23901805",
"asideResizor": false,
"pullRefresh": {
"disabled": true
},
"data": {
"items": [
{
"id": 1,
"name": "选项1",
"code": "001"
},
{
"id": 2,
"name": "选项2",
"code": "002"
}
]
}
}

@Protagonistss
Copy link
Author

{ "type": "page", "body": [ { "type": "button", "label": "打开选择弹窗", "actionType": "dialog", "dialog": { "type": "dialog", "title": "选择数据", "size": "lg", "body": [ { "type": "crud", "id": "selectCrud", "name": "selectCrud", "primaryField": "id", "selectable": true, "multiple": false, "columns": [ { "name": "name", "label": "名称", "type": "text", "id": "u:6868c06a173b", "placeholder": "-" }, { "name": "code", "label": "编码", "type": "text", "id": "u:ff8f53208a45", "placeholder": "-" } ], "perPageAvailable": [ 5, 10, 20, 50, 100 ], "messages": {} } ], "actions": [ { "type": "button", "label": "取消", "actionType": "cancel", "id": "u:7d947ec76a64" }, { "type": "button", "label": "确认", "level": "primary", "onEvent": { "click": { "actions": [ { "actionType": "toast", "args": { "msgType": "success", "msg": "${LAST(items).name}-${LAST(items).code}" } }, { "actionType": "closeDialog" } ] } }, "id": "u:fc1fd9e7fa7a", "disabledOnAction": false } ], "id": "u:55c17a749dfe", "showCloseButton": true, "closeOnOutside": false, "closeOnEsc": false, "showErrorMsg": true, "showLoading": true, "draggable": false }, "id": "u:e75a6b819f30", "disabledOnAction": false } ], "id": "u:7e1e23901805", "asideResizor": false, "pullRefresh": { "disabled": true }, "data": { "items": [ { "id": 1, "name": "选项1", "code": "001" }, { "id": 2, "name": "选项2", "code": "002" } ] } }

我这边用使用picker解决了,谢谢啦。

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

No branches or pull requests

3 participants
0