mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-10-29 08:58:22 +08:00
fix(table): 失败通道摘除模板容器加载态并明示 where 白名单契约
This commit is contained in:
@@ -140,8 +140,9 @@
|
||||
* @param {string} tableId 已注册的表格 ID
|
||||
* @param {function} [done] 成功回调,入参为后端响应 {code:0, msg, count, data}
|
||||
* @param {boolean} [isCorrection] 页码纠偏自动重取标记(防递归兜底,业务不传)
|
||||
* @param {function} [fail] 失败回调(res.code != 0 与 HTTP error 两个失败通道各调用一次)
|
||||
*/
|
||||
var fetch = function (tableId, done, isCorrection) {
|
||||
var fetch = function (tableId, done, isCorrection, fail) {
|
||||
var state = getState(tableId);
|
||||
|
||||
if (!state) {
|
||||
@@ -176,7 +177,7 @@
|
||||
if (state.page.curr > lastPage) {
|
||||
state.page.curr = lastPage;
|
||||
if (!isCorrection) {
|
||||
fetch(tableId, done, true);
|
||||
fetch(tableId, done, true, fail);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -198,6 +199,10 @@
|
||||
// res.code != 0:错误提示并保持当前视图(不改动已渲染数据)
|
||||
var msg = res.msg == undefined ? '返回数据格式有误' : res.msg;
|
||||
ua.msg.error(msg);
|
||||
|
||||
if (typeof fail === 'function') {
|
||||
fail(res);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr, textstatus, thrown) {
|
||||
@@ -210,6 +215,10 @@
|
||||
errorMsg = xhr.responseJSON.message;
|
||||
}
|
||||
ua.msg.error('Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!<br/>' + errorMsg);
|
||||
|
||||
if (typeof fail === 'function') {
|
||||
fail(xhr, textstatus, thrown);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -428,6 +437,9 @@
|
||||
* - opts.page:{curr, limit} 部分合入;搜索场景由调用方传 {curr: 1}
|
||||
* (语义平移 listenTableSearch 的 reloadData page.curr=1)
|
||||
* - opts.done:透传给 fetch 的成功回调
|
||||
* - opts.fail:透传给 fetch 的失败回调
|
||||
* - opts.where 中仅 filter/op/sort 三键生效(normalizeWhere 白名单),其他自定义键会被丢弃——
|
||||
* 需要额外请求参数的场景应在后端以 filter 解析或页面用 dataProvider.setWhere 全量构造
|
||||
*/
|
||||
var reload = function (tableId, opts) {
|
||||
var state = getState(tableId);
|
||||
@@ -452,7 +464,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
fetch(tableId, opts.done);
|
||||
fetch(tableId, opts.done, undefined, opts.fail);
|
||||
};
|
||||
|
||||
// ========== register / has 注册表 ==========
|
||||
|
||||
@@ -338,10 +338,19 @@
|
||||
window.UA_TABLE_STORE.reload = function (tableId, opts) {
|
||||
opts = opts || {};
|
||||
var userDone = opts.done;
|
||||
var userFail = opts.fail;
|
||||
// 模板形态的加载态容器标记(容器内加载样式由任务 14 的内置形态接入)
|
||||
var $layoutContainer = $('#ua-layout-' + tableId);
|
||||
$layoutContainer.addClass('ua-layout-loading');
|
||||
opts.done = function (res) {
|
||||
// 失败通道(res.code != 0 / HTTP error)不进 done,需经 fail 摘除加载态,
|
||||
// 避免请求失败后容器残留半透明禁点状态
|
||||
opts.fail = function () {
|
||||
$layoutContainer.removeClass('ua-layout-loading');
|
||||
if (typeof userFail === 'function') {
|
||||
userFail.apply(null, arguments);
|
||||
}
|
||||
};
|
||||
opts.done = function (res) {
|
||||
// 受控渲染分发:table 形态走引擎纯渲染(现状),非 table 形态走
|
||||
// 模板管线(渲染上下文 + 行级循环);模板管线不可用(Vue 未引入/
|
||||
// 挂载渲染失败;tplLayId/tplVueId 节点缺失/laytpl 渲染错误)时
|
||||
|
||||
Reference in New Issue
Block a user