mirror of https://gitee.com/y_project/RuoYi.git
树表格添加responseHandler(请求获取数据后处理回调函数,校验异常状态提醒)
parent
38c84fbdc6
commit
72a1585e26
|
@ -165,6 +165,7 @@
|
||||||
data: parms ? parms : options.ajaxParams,
|
data: parms ? parms : options.ajaxParams,
|
||||||
dataType: "JSON",
|
dataType: "JSON",
|
||||||
success: function(data, textStatus, jqXHR) {
|
success: function(data, textStatus, jqXHR) {
|
||||||
|
data = calculateObjectValue(options, options.responseHandler, [data], data);
|
||||||
renderTable(data);
|
renderTable(data);
|
||||||
},
|
},
|
||||||
error: function(xhr, textStatus) {
|
error: function(xhr, textStatus) {
|
||||||
|
@ -608,6 +609,33 @@
|
||||||
}
|
}
|
||||||
return value;
|
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();
|
init();
|
||||||
return target;
|
return target;
|
||||||
|
@ -700,7 +728,9 @@
|
||||||
showColumns: true, // 是否显示内容列下拉框
|
showColumns: true, // 是否显示内容列下拉框
|
||||||
showRefresh: true, // 是否显示刷新按钮
|
showRefresh: true, // 是否显示刷新按钮
|
||||||
expanderExpandedClass: 'glyphicon glyphicon-chevron-down', // 展开的按钮的图标
|
expanderExpandedClass: 'glyphicon glyphicon-chevron-down', // 展开的按钮的图标
|
||||||
expanderCollapsedClass: 'glyphicon glyphicon-chevron-right' // 缩起的按钮的图标
|
expanderCollapsedClass: 'glyphicon glyphicon-chevron-right', // 缩起的按钮的图标
|
||||||
|
responseHandler: function(res) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
})(jQuery);
|
})(jQuery);
|
|
@ -443,7 +443,8 @@
|
||||||
showColumns: options.showColumns, // 是否显示隐藏某列下拉框
|
showColumns: options.showColumns, // 是否显示隐藏某列下拉框
|
||||||
expandAll: options.expandAll, // 是否全部展开
|
expandAll: options.expandAll, // 是否全部展开
|
||||||
expandFirst: options.expandFirst, // 是否默认第一级展开--expandAll为false时生效
|
expandFirst: options.expandFirst, // 是否默认第一级展开--expandAll为false时生效
|
||||||
columns: options.columns
|
columns: options.columns, // 显示列信息(*)
|
||||||
|
responseHandler: $.treeTable.responseHandler // 当所有数据被加载时触发处理函数
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 条件查询
|
// 条件查询
|
||||||
|
@ -463,6 +464,15 @@
|
||||||
});
|
});
|
||||||
return $.common.uniqueFn(rows);
|
return $.common.uniqueFn(rows);
|
||||||
},
|
},
|
||||||
|
// 请求获取数据后处理回调函数,校验异常状态提醒
|
||||||
|
responseHandler: function(data) {
|
||||||
|
if (data.code != undefined && data.code != 0) {
|
||||||
|
$.modal.alertWarning(data.msg);
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
// 表单封装处理
|
// 表单封装处理
|
||||||
form: {
|
form: {
|
||||||
|
|
Loading…
Reference in New Issue