Skip to content
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

弹出窗口中下拉框联动CRUD表格内容不刷新数据 #10152

Open
760985933 opened this issue May 1, 2024 · 3 comments
Open

弹出窗口中下拉框联动CRUD表格内容不刷新数据 #10152

760985933 opened this issue May 1, 2024 · 3 comments

Comments

@760985933
Copy link

描述问题:

弹出窗口中下拉框联动CRUD表格内容不刷新数据

截图或视频:

只有在第一次查看ping历史记录时点击打开的弹窗界面有数据,当在下拉框点击2或1版本历史查看时,请求数据已经获取到,但是CRUD表格未刷新新数据。

涉及代码部分在 "title": "查看详情"下面

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

  1. 你是如何使用 amis 的?
    sdk

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

  3. 粘贴有问题的完整 amis schema 代码:

(function() {
	const response =

    {
        "type": "page",
        "title": "ping",
        "body": [
          
          {
            "type": "crud",
            "syncLocation": false,
            "api": {
              "method": "get",
              "url": "/api/op/v1/get_ping_tasks"
            },
            "columns": [
              {
                "name": "ping_task_id",
                "label": "ID",
                "type": "text",
                "id": "u:4ed28ad066ba"
              },
              {
                "name": "ping_task_name",
                "label": "任务名称",
                "type": "text",
                "id": "u:062fff6f2a39"
              },
              {
                "type": "progress",
                "label": "ping执行进度",
                "animate": true,
                "name": "ping_process",
                "id": "u:a9b2fb01fb97"
              },
              {
                "type": "operation",
                "label": "操作",
                "buttons": [
                  {
                    "label": "查看",
                    "type": "button",
                    "actionType": "dialog",
                    "level": "link",
                    "editorSetting": {
                      "behavior": "view"
                    },
                    "dialog": {
                      "title": "查看详情",
                      "body": [
                        
                        {
                          "type": "crud",
                          "syncLocation": true,
                          "name":"crudId",
                          
                          "headerToolbar": [
                            {
                              "type": "bulk-actions"
                            },
                            {
                              "type": "export-excel",
                              "tpl": "内容",
                              "wrapperComponent": "",
                              "id": "u:2abf93a0ee07"
                            },
                            {
                              "type": "select",
                              "id": "u:cb255d782dc7",
                              // "label": "历史版本",
                              "name": "ping_task_ip_history_version",
                              "multiple": false,
                              "clearable": false,
                              "searchable": false,
                              "source": {
                                "url": "/api/op/v1/get_ping_task_ip_version_info?ping_task_id=${ping_task_id}",
                                "method": "get"
                              },
                              "labelField": "version",
                              "valueField": "version",
                              "selectFirst": true,
                              
                            
                              "onEvent": {
                                "change": {
                                  "weight": 0,
                                  "actions": [
                                    // {
                                    //   "actionType": "setValue",
                                    //   "componentId": "u:52a46a32d58e",
                                    //   "args": {
                                    //     "value": {
                                    //       "items": []
                                    //     }
                                    //   }
                                    // },

                                    // {
                                    //   "actionType": "setValue",
                                    //   "componentId": "u:52a46a32d58e",
                                    //   "args": {
                                        
                                    //     "value": {
                                    //       "count": 2,
                                    //       "items": [
                                    //         {
                                    //           "sequence": "Trident - f12fj",
                                    //           "name": "Internet Explorer 4.0",
                                              
                                    //         },
                                    //         {
                                    //           "name": "Trident - oqvc0e",
                                    //           "sequence": "Internet Explorer 5.0",
                                              
                                    //         }
                                    //       ]
                                    //     }
                                    //   }
                                    // },
                                  
                                    {
                                      "ignoreError": false,
                                      "outputVar": "responseResult",
                                      "actionType": "ajax",
                                      
                                      "options": {},
                                      "args": {
                                        
                                        "api": {
                                          
                                          "method": "get",
                                          // "url": "/api/op/v1/get_ping_task_ip_history_info?ping_task_id=${ping_task_id}&version=${ping_task_ip_history_version}",
                                          "url": "/api/op/v1/get_ping_task_ip_info/${ping_task_id}?version=${ping_task_ip_history_version}",
                                        },
                                        
                                        "requestAdaptor": "",
                                        "adaptor": "",
                                        "messages": {},
                                        
                                      },
                                     
                                      },
                                     
                                      
                                  ],
                                  
                                }
                              },
                              

                            }

                          ],


                          "api": {
                            "method": "get",
                            "url": "/api/op/v1/get_ping_task_ip_info/${ping_task_id}?version=${ping_task_ip_history_version}",
                            
                          },
                          "columns": [
                            {
                              "name": "sequence",
                              "label": "序号",
                              "type": "text",
                              "id": "u:29b4ad9a7f94"
                            },
                            {
                              "name": "ip_name",
                              "label": "IP对应名称",
                              "type": "text",
                              "id": "u:29b4ad9a7f94"
                            },
                            {
                              "type": "text",
                              "label": "IP地址",
                              "name": "ip_address",
                              "id": "u:723f234f603a"
                            },
                            {
                              "type": "status",
                              "label": "ping状态",
                              "name": "ping_status",
                              "fixed": "left",
                              "id": "u:a7ec66f10e71"
                            },
                            
                            {
                              "type": "text",
                              "label": "探测时间",
                              "name": "ping_time",
                              "id": "u:e6a6e145bb25"
                            }
                          ],
                          "bulkActions": [],
                          "itemActions": [],
                          "id": "u:52a46a32d58e",
                          "perPageAvailable": [
                            10
                          ],
                          "messages": {},
                          "initFetch": true,
                          "silentPolling": true,
                          
                        }
                      ],
                      "type": "dialog",
                      "id": "u:9a50964a6cd7",
                      "actions": [
                        {
                          "type": "button",
                          "actionType": "cancel",
                          "label": "取消",
                          "id": "u:878d35d4977d"
                        },
                        {
                          "type": "button",
                          "actionType": "confirm",
                          "label": "确定",
                          "primary": true,
                          "id": "u:88e878839b3a"
                        }
                      ],
                      "showCloseButton": true,
                      "closeOnOutside": false,
                      "closeOnEsc": true,
                      "showErrorMsg": true,
                      "showLoading": true,
                      "draggable": false,
                      "size": "lg"
                    },
                    "id": "u:257272045c77"
                  },
                  {
                    "label": "编辑",
                    "type": "button",
                    "actionType": "dialog",
                    "level": "link",
                    "editorSetting": {
                      "behavior": "update"
                    },
                  
                    
                    "dialog": {
                      "title": "编辑",
                      
                      "body": [
                        {
                          "type": "input-text",
                          "name": "ping_task_name",
                          "label": "任务名称",
                          "clearable": true,
                          },
                        {
                          "type": "input-file",
                          "label": "Excel文件上传",
                          "autoUpload": false,
                          "proxy": true,
                          "uploadType": "fileReceptor",
                          "name": "excel_update_file",
                          "id": "u:9c1499533b88",
                          "btnLabel": "Excel文件上传",
                          "multiple": false,
                          "useChunk": false,
                          "accept": ".xlsx",
                          "drag": true,
                          "autoFill": {},
                          "asBlob": false,
                          "formType": "asBlob",
                          "asBase64": false,
                          
                          "receiver": {
                            "url": "/api/op/v1/upload_ping_task_ip_info_excel?ping_task_id=${ping_task_id}",

                            "method": "post",
                            "requestAdaptor": "",
                            "adaptor": "",
                            "messages": {}
                          },
                          "description": "EXCEL具备字段:\nip_address、name两个Excel列名称。ip_address取单元格第一个数组值,name主要用于标识iP归属信息"
                        }
                      ],
                      "type": "dialog",
                      "id": "u:5fbba892b9fb",
                      "actions": [
                        {
                          "type": "button",
                          "actionType": "cancel",
                          "label": "取消",
                          "id": "u:c801ec25e873"
                        },
                        {
                          "type": "button",
                          "actionType": "confirm",
                          "label": "确定",
                          "primary": true,
                          "id": "u:b5b1eff5af1a",
                          "onEvent": {
                            "click": {
                            "actions": [
            
                              {
                                "ignoreError": false,
                                "outputVar": "responseResult",
                                "actionType": "ajax",
                                "options": {},
                                "args": {
                                "api": {
                                  "method": "put",
                                  "url": "/api/op/v1/update_ping_task_name/${ping_task_id}?ping_task_name=${ping_task_name}",
                                  
                                },
                                  "requestAdaptor": "",
                                  "adaptor": "",
                                  "messages": {}
                                }
                                }
            
                            ]
                            }
                          },
                        }
                      ]
                    },
                    "id": "u:e63e074e106d"
                  },
                  {
                    "type": "button",
                    "label": "执行ping测试",
                    "actionType": "ajax",
                    "level": "link",
                    "api": {
                                "url": "/api/op/v1/ping_task/${ping_task_id}",
                                "method": "get",
                                "requestAdaptor": "",
                                // "adaptor": "return {\n    ...payload,\n    data: {\n        ...payload.data,\n        response: response.data\n    }\n}",
                                // "messages": {}
                                
                              },
                    "className": "text-info",
                    // "onEvent": {
                    //   "click": {
                    //     "actions": [{
                    //       "ignoreError": false,
                    //       "outputVar": "responseResult",
                    //       "actionType": "ajax",
                    //       "args": {
                    //         "options": {},
                    //         "api": {
                    //           "url": "/api/op/v1/ping_task/${ping_task_id}",
                    //           "method": "get",
                    //           "requestAdaptor": "",
                    //           // "adaptor": "return {\n    ...payload,\n    data: {\n        ...payload.data,\n        response: response.data\n    }\n}",
                    //           // "messages": {}
                              
                    //         }
                            
                    //       }
                    //     },
                        
                    //     ]
                    //   },
                    // },
                  
                    "id": "u:0d407034f375"
                  },
                  
                ],
                "id": "u:5d1b0311f9f7"
              }
            ],
            "bulkActions": [],
            "itemActions": [],
            "headerToolbar": [
              {
                "label": "新增",
                "type": "button",
                "actionType": "dialog",
                "level": "primary",
                "editorSetting": {
                  "behavior": "create"
                },
                "dialog": {
                  "title": "新增",
                  "body": {
                    "type": "form",
                    "api": {
                      "method": "post",
                      "url": "/api/op/v1/create_ping_task?ping_task_name=${ping_task_name}"
                    },
                    "body": [
                      {
                        "type": "input-text",
                        "name": "ping_task_name",
                        "label": "任务名称"
                      }
                    ]
                  }
                },
                "id": "u:5f38481b2471"
              },
              {
                "type": "bulk-actions"
              }
            ],
            "id": "u:a478517447de",
            "perPageAvailable": [
              10
            ],
            "messages": {},
            "interval": 3000
          }
        ],
        "id": "u:b527ca0edbe3",
        "asideResizor": false,
        "pullRefresh": {
          "disabled": true
        },
        "regions": [
          "body"
        ]
      }

	window.jsonpCallback && window.jsonpCallback(response);
})();
  1. 操作步骤
    点击查看,打开查看详情页面,显示最新版本的ping记录,点击下拉菜单选择其他版本历史记录,请求到数据,CRUD表格中没有刷新内容。
    请求到的数据,举例
{
    "status": 0,
    "msg": 70,
    "data": [
        {
            "sequence": 1,
            "ip_name": "1.2.3.19",
            "ip_address": "1.2.3.19",
            "ping_status": "0",
            "ping_time": "2024-04-30 17:28:31"
        }
    ]
}
Copy link

github-actions bot commented May 1, 2024

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

Please review the labels and make any necessary changes.

@github-actions github-actions bot added the fix label May 1, 2024
@760985933
Copy link
Author

760985933 commented May 1, 2024 via email

@760985933
Copy link
Author

760985933 commented May 1, 2024

下拉框联动CRUD

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