描述问题:
在CRUD中的一列(type: "switch", name: "enabled")设定quickEdit,提交后做了一层校验,对id是自己的enabled修改不应用,只修改其他字段。此时重新请求了一次表格数据,表格中渲染显示的数据与返回的数据不同
同时我想要问一下有没有请求后status返回非0值时重新获取并渲染表格数据的方法?
截图或视频:
如何复现(请务必完整填写下面内容):
- 你是如何使用 amis 的?
django + amis
- amis 版本是什么?请先在最新 beta 版本测试问题是否存在
v3.4.2
- 粘贴有问题的完整
amis schema
代码:
{
"type": "page",
"title": "用户管理",
"body": [
{
"type": "crud",
"syncLocation": false,
"api": {
"method": "get",
"url": "/user/list/data",
"messages": {},
"requestAdaptor": "",
"adaptor": "",
"dataType": "json"
},
"bulkActions": [
{
"label": "批量删除",
"type": "button",
"id": "u:21cb24253950",
"confirmText": "确定删除选中用户吗?",
"level": "danger",
"onEvent": {
"click": {
"weight": 0,
"actions": [],
"debounce": {
"wait": 100
}
}
}
}
],
"itemActions": [],
"features": [
"create",
"filter"
],
"filterColumnCount": 3,
"headerToolbar": [
{
"type": "filter-toggler",
"id": "u:ceff4884a270",
"tpl": "内容",
"wrapperComponent": ""
},
{
"type": "button",
"label": "新增",
"actionType": "dialog",
"level": "primary",
"dialog": {
"title": "新增",
"body": {
"type": "form",
"api": {
"method": "post",
"url": "/user/list/data",
"messages": {},
"requestAdaptor": "",
"adaptor": "",
"dataType": "json"
},
"body": [
{
"type": "input-text",
"name": "id",
"label": "ID",
"id": "u:7700698d5850"
},
{
"type": "input-text",
"name": "username",
"label": "用户名",
"id": "u:fc169659c9fd"
},
{
"type": "input-text",
"name": "nickname",
"label": "昵称",
"id": "u:9672ce0727f9"
},
{
"type": "input-text",
"name": "email",
"label": "邮箱",
"id": "u:5dbb7bc54206"
},
{
"type": "input-text",
"name": "role",
"label": "角色",
"id": "u:e7e899d20e8e"
},
{
"type": "input-date",
"name": "last_login",
"label": "最后登陆",
"id": "u:3ed1de0320b7"
},
{
"type": "select",
"name": "enabled",
"label": "是否启用",
"id": "u:87fd53435d75"
},
{
"type": "input-operation",
"label": "操作",
"id": "u:089e898852b6"
}
],
"id": "u:60e25ced64e6"
}
},
"id": "u:49a713d1933c"
},
{
"type": "bulk-actions"
}
],
"id": "u:96b6923a086a",
"perPageAvailable": [
10,
20,
50
],
"messages": {},
"alwaysShowPagination": true,
"hideQuickSaveBtn": false,
"mode": "table",
"columns": [
{
"name": "id",
"label": "ID",
"type": "text",
"id": "u:17e2176e6a51"
},
{
"name": "username",
"label": "用户名",
"type": "text",
"id": "u:3d0fdfd25ef4"
},
{
"type": "text",
"label": "昵称",
"name": "nickname",
"id": "u:db6f57bf8fa8"
},
{
"type": "text",
"label": "邮箱",
"name": "email",
"id": "u:105dd9b950c2"
},
{
"type": "text",
"label": "角色",
"name": "role",
"id": "u:5ab9b0a4a5f4"
},
{
"type": "date",
"label": "最后登陆",
"name": "last_login",
"id": "u:587823930d27"
},
{
"type": "switch",
"label": "是否启用",
"name": "enabled",
"id": "u:d67e849fe0f0",
"quickEdit": {
"mode": "inline",
"type": "switch",
"id": "u:42cee739c26d",
"saveImmediately": true,
"required": false
},
"buttons": [],
"value": false
},
{
"type": "operation",
"label": "操作",
"buttons": [
{
"type": "button-group",
"buttons": [
{
"type": "button",
"label": "编辑",
"onEvent": {
"click": {
"actions": []
}
},
"id": "u:a8fec34f318f"
},
{
"type": "button",
"label": "删除",
"onEvent": {
"click": {
"actions": []
}
},
"id": "u:4059023d145f",
"confirmText": "确认删除用户\"${username}\"吗?",
"level": "danger"
}
],
"id": "u:07c37fa7ddb8"
}
],
"id": "u:135d5e73a3c3"
}
],
"footerToolbar": [
{
"type": "switch-per-page",
"tpl": "内容",
"wrapperComponent": "",
"id": "u:9ad9fb92bdf5"
},
{
"type": "statistics",
"id": "u:9eeb8edfe55e"
},
{
"type": "pagination",
"id": "u:2b3698e12840"
}
],
"keepItemSelectionOnPageChange": false,
"autoFillHeight": false,
"filter": {
"title": "查询条件",
"body": [
{
"type": "input-text",
"name": "keywords",
"label": "关键字",
"id": "u:ebaea606d35b"
}
],
"id": "u:618eeefed8aa",
"actions": [
{
"type": "submit",
"label": "搜索",
"primary": true,
"id": "u:cb62fef4d103"
}
],
"loadingConfig": {
"show": true
}
},
"filterTogglable": true,
"filterDefaultVisible": false,
"columnsTogglable": "auto",
"placeholder": "暂无数据",
"footable": false,
"quickSaveItemApi": {
"url": "/user/$id",
"method": "put",
"messages": {},
"requestAdaptor": "",
"adaptor": "",
"dataType": "json",
"cache": 3000
},
"initFetch": true,
"draggable": false,
"affixHeader": true
}
],
"id": "u:d6ecd4fd0b09",
"aside": [],
"asideResizor": false,
"pullRefresh": {
"disabled": true
},
"regions": [
"body"
]
}
- 操作步骤
点击enabled按钮修改状态即可复现,不过需要后端不处理相关enabled修改
3条答案
按热度按时间cmssoen21#
👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.
Please review the labels and make any necessary changes.
r1wp621o2#
我同样遇到了表格中渲染显示的数据与返回的数据不同问题。查找到的问题原因是:CRUD中不会更新是上次和刷新返回的列表,都是一样,就不会更新。
我的解决方法是在每行的表格数据中添加一个随机数,确保每次请求返回的数据不同,进而刷新CRUD表。
同问 有没有请求后status返回非0值时重新获取并渲染表格数据的方法?
tjvv9vkg3#
我同样遇到了表格中渲染显示的数据与返回的数据不同问题。查找到的问题原因是:CRUD中不会更新是上次和刷新返回的列表,都是一样,就不会更新。 我的解决方法是在每行的表格数据中添加一个随机数,确保每次请求返回的数据不同,进而刷新CRUD表。
同问 有没有请求后status返回非0值时重新获取并渲染表格数据的方法?
目前我采取了一个折中的办法,直接添加一个action,不论成功还是失败,都直接刷新表格数据