From 69c8929c438f5dc966e0c3eee32d580bdb49b8cd Mon Sep 17 00:00:00 2001 From: augushong Date: Fri, 11 Sep 2026 15:09:49 +0000 Subject: [PATCH] =?UTF-8?q?fix(table):=20=E5=A4=B1=E8=B4=A5=E9=80=9A?= =?UTF-8?q?=E9=81=93=E6=91=98=E9=99=A4=E6=A8=A1=E6=9D=BF=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=80=81=E5=B9=B6=E6=98=8E=E7=A4=BA=20where?= =?UTF-8?q?=20=E7=99=BD=E5=90=8D=E5=8D=95=E5=A5=91=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugs/ulthon-admin/admin-table-store.js | 18 +++++++++++++++--- .../static/plugs/ulthon-admin/admin-table.js | 11 ++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/public/static/plugs/ulthon-admin/admin-table-store.js b/public/static/plugs/ulthon-admin/admin-table-store.js index 4db3a93..421b3fe 100644 --- a/public/static/plugs/ulthon-admin/admin-table-store.js +++ b/public/static/plugs/ulthon-admin/admin-table-store.js @@ -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 + ',请稍后再试!
' + 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 注册表 ========== diff --git a/public/static/plugs/ulthon-admin/admin-table.js b/public/static/plugs/ulthon-admin/admin-table.js index 8d59921..ae073be 100644 --- a/public/static/plugs/ulthon-admin/admin-table.js +++ b/public/static/plugs/ulthon-admin/admin-table.js @@ -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 渲染错误)时