From 6c5be1a15a57ceef9bbf36f3fcb43a291c0f8e0f Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 10 Sep 2026 18:27:29 +0000 Subject: [PATCH] =?UTF-8?q?feat(table):=20=E8=A3=85=E8=BD=BD=20reloadData?= =?UTF-8?q?=20shim=20=E4=B8=8E=20checkStatus=20=E5=88=86=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/base/admin/view/common/_require.html | 1 + .../static/plugs/ulthon-admin/admin-listen.js | 6 ++-- .../static/plugs/ulthon-admin/admin-table.js | 31 ++++++++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/extend/base/admin/view/common/_require.html b/extend/base/admin/view/common/_require.html index b974a1f..d5bcad6 100644 --- a/extend/base/admin/view/common/_require.html +++ b/extend/base/admin/view/common/_require.html @@ -47,6 +47,7 @@ + diff --git a/public/static/plugs/ulthon-admin/admin-listen.js b/public/static/plugs/ulthon-admin/admin-listen.js index b273e9f..27fcb32 100644 --- a/public/static/plugs/ulthon-admin/admin-listen.js +++ b/public/static/plugs/ulthon-admin/admin-listen.js @@ -71,7 +71,7 @@ if (checkbox === 'true') { tableId = tableId || init.tableRenderId; - var checkStatus = table.checkStatus(tableId), + var checkStatus = ua.table.checkStatus(tableId), data = checkStatus.data; if (data.length <= 0) { ua.msg.error('请勾选需要操作的数据'); @@ -245,7 +245,7 @@ var postData = {}; if (checkbox === 'true') { tableId = tableId || init.tableRenderId; - var checkStatus = table.checkStatus(tableId), + var checkStatus = ua.table.checkStatus(tableId), data = checkStatus.data; if (data.length <= 0) { ua.msg.error('请勾选需要操作的数据'); @@ -286,7 +286,7 @@ url = $(this).attr('data-url'); tableId = tableId || init.tableRenderId; url = url !== undefined ? ua.url(url) : window.location.href; - var checkStatus = table.checkStatus(tableId), + var checkStatus = ua.table.checkStatus(tableId), data = checkStatus.data; if (data.length <= 0) { ua.msg.error('请勾选需要删除的数据'); diff --git a/public/static/plugs/ulthon-admin/admin-table.js b/public/static/plugs/ulthon-admin/admin-table.js index e555531..84ba31f 100644 --- a/public/static/plugs/ulthon-admin/admin-table.js +++ b/public/static/plugs/ulthon-admin/admin-table.js @@ -10,7 +10,36 @@ var lastTableWhere = {}; var selectMode, selectConfirmCallback; + // reloadData 引擎接线(加载期执行一次):受控表(UA_TABLE_STORE 已注册)的数据 + // 重载分流到 store,非受控表透传原引擎调用。原引用只备份一次,防止重复加载时 + // 把包装层当原引用再包一层;透传用 arguments 保真,reloadData(id, opts, type) + // 三参形态的 type 语义不变。 + if (table.__uaOriginalReloadData === undefined) { + table.__uaOriginalReloadData = table.reloadData; + } + var originalTableReloadData = table.__uaOriginalReloadData; + table.reloadData = function (tableId, opts) { + if (window.UA_TABLE_STORE.has(tableId)) { + return window.UA_TABLE_STORE.reload(tableId, opts); + } + return originalTableReloadData.apply(this, arguments); + }; + ua.table = { + // 受控/非受控分发入口(后续任务直呼改造的定义点):非受控路径走备份的 + // 原引擎引用,不经过上方已包装的 table.reloadData,避免递归 + reloadData: function (tableId, opts) { + if (window.UA_TABLE_STORE.has(tableId)) { + return window.UA_TABLE_STORE.reload(tableId, opts); + } + return originalTableReloadData.apply(this, arguments); + }, + checkStatus: function (tableId) { + if (window.UA_TABLE_STORE.has(tableId)) { + return window.UA_TABLE_STORE.checkStatus(tableId); + } + return table.checkStatus(tableId); + }, render: function (options) { options.init = options.init || ua.init; options.modifyReload = ua.parame(options.modifyReload, true); @@ -1218,7 +1247,7 @@ }, listenTableSelectConfirm(options) { $('.select-confirm').click(function () { - var checkStatus = table.checkStatus(options.id); + var checkStatus = ua.table.checkStatus(options.id); if (checkStatus.data.length == 0) { layer.msg('请选择数据');