From bf5ccf5a977b79843855a2c3e95bf667d7a9bc3f Mon Sep 17 00:00:00 2001 From: Anyon Date: Wed, 19 Aug 2026 10:18:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=BC=B9=E7=AA=97=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/static/admin.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/public/static/admin.js b/public/static/admin.js index 2a1033f18..b1bd28cca 100644 --- a/public/static/admin.js +++ b/public/static/admin.js @@ -100,19 +100,29 @@ $(function () { }; /*! 获取加载回调 */ - this.onConfirm.getLoadCallable = function (tabldId, callable) { + this.onConfirm.getLoadCallable = function (tabldId, callable, options) { typeof callable === 'function' && callable(); - return tabldId ? function (ret, time) { + options = options || {}; + let errorAlert = options.errorAlert === true || String(options.errorAlert) === 'true'; + if (!tabldId && !errorAlert) return false; + return function (ret, time) { // 单独处理 javascript: 返回内容处理 if (typeof ret.data === 'string' && ret.data.indexOf('javascript:') === 0) { $.msg.goto(ret.data) } - if (ret.code < 1) return true; + if (parseInt(ret.code) < 1) { + if (errorAlert) { + $.msg.alert(ret.info || ret.msg || '操作失败'); + return false; + } + return true; + } + if (!tabldId) return true; time === 'false' ? $.layTable.reload(tabldId) : $.msg.success(ret.info, time, function () { $.layTable.reload(tabldId); }); return false; - } : false; + }; }; /*! 读取 data-value & data-rule 并应用到 callable */ @@ -877,7 +887,7 @@ $(function () { /*! 注册 data-load 事件行为 */ $.base.onEvent('click', '[data-load]', function () { $.base.applyRuleValue(this, {}, function (data, elem, dset) { - $.form.load(dset.load, data, 'get', $.base.onConfirm.getLoadCallable(dset.tableId), true, dset.tips, dset.time); + $.form.load(dset.load, data, 'get', $.base.onConfirm.getLoadCallable(dset.tableId, null, {errorAlert: dset.errorAlert}), true, dset.tips, dset.time); }); }); @@ -948,7 +958,7 @@ $(function () { $.base.applyRuleValue(this, {}, function (data, elem, dset) { Object.assign(data, {'_token_': dset.token || dset.csrf || '--'}) let load = dset.loading !== 'false', tips = typeof load === 'string' ? load : undefined; - $.form.load(dset.action, data, dset.method || 'post', $.base.onConfirm.getLoadCallable(dset.tableId), load, tips, dset.time) + $.form.load(dset.action, data, dset.method || 'post', $.base.onConfirm.getLoadCallable(dset.tableId, null, {errorAlert: dset.errorAlert}), load, tips, dset.time) }); });