From 72a1585e26568d042b3fe38b12b9249799285a09 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 27 Jul 2019 14:36:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=91=E8=A1=A8=E6=A0=BC=E6=B7=BB=E5=8A=A0re?= =?UTF-8?q?sponseHandler=EF=BC=88=E8=AF=B7=E6=B1=82=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=90=8E=E5=A4=84=E7=90=86=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E6=A0=A1=E9=AA=8C=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=8F=90=E9=86=92=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bootstrap-treetable.js | 34 +++++++++++++++++-- .../main/resources/static/ruoyi/js/ry-ui.js | 12 ++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js index 70842ca70..3033bd4bc 100644 --- a/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js +++ b/ruoyi-admin/src/main/resources/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js @@ -165,6 +165,7 @@ data: parms ? parms : options.ajaxParams, dataType: "JSON", success: function(data, textStatus, jqXHR) { + data = calculateObjectValue(options, options.responseHandler, [data], data); renderTable(data); }, error: function(xhr, textStatus) { @@ -608,6 +609,33 @@ } return value; }; + // ruoyi 发起对目标(target)函数的调用 + var calculateObjectValue = function (self, name, args, defaultValue) { + var func = name; + + if (typeof name === 'string') { + var names = name.split('.'); + + if (names.length > 1) { + func = window; + $.each(names, function (i, f) { + func = func[f]; + }); + } else { + func = window[name]; + } + } + if (typeof func === 'object') { + return func; + } + if (typeof func === 'function') { + return func.apply(self, args); + } + if (!func && typeof name === 'string' && sprintf.apply(this, [name].concat(args))) { + return sprintf.apply(this, [name].concat(args)); + } + return defaultValue; + }; // 初始化 init(); return target; @@ -700,7 +728,9 @@ showColumns: true, // 是否显示内容列下拉框 showRefresh: true, // 是否显示刷新按钮 expanderExpandedClass: 'glyphicon glyphicon-chevron-down', // 展开的按钮的图标 - expanderCollapsedClass: 'glyphicon glyphicon-chevron-right' // 缩起的按钮的图标 - + expanderCollapsedClass: 'glyphicon glyphicon-chevron-right', // 缩起的按钮的图标 + responseHandler: function(res) { + return false; + } }; })(jQuery); \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index f955c534a..1fe635c64 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -443,7 +443,8 @@ showColumns: options.showColumns, // 是否显示隐藏某列下拉框 expandAll: options.expandAll, // 是否全部展开 expandFirst: options.expandFirst, // 是否默认第一级展开--expandAll为false时生效 - columns: options.columns + columns: options.columns, // 显示列信息(*) + responseHandler: $.treeTable.responseHandler // 当所有数据被加载时触发处理函数 }); }, // 条件查询 @@ -463,6 +464,15 @@ }); return $.common.uniqueFn(rows); }, + // 请求获取数据后处理回调函数,校验异常状态提醒 + responseHandler: function(data) { + if (data.code != undefined && data.code != 0) { + $.modal.alertWarning(data.msg); + return []; + } else { + return data; + } + }, }, // 表单封装处理 form: {