修改ry-ui.js中判断是否为空函数,增加对undefined的判断,优化if判断

This commit is contained in:
杨玄 2019-01-09 08:09:45 +08:00
parent dc07b97cdb
commit 36ddf23f27
1 changed files with 576 additions and 550 deletions

View File

@ -61,10 +61,16 @@
// 请求获取数据后处理回调函数
responseHandler: function(res) {
if (res.code == 0) {
return { rows: res.rows, total: res.total };
return {
rows: res.rows,
total: res.total
};
} else {
$.modal.alertWarning(res.msg);
return { rows: [], total: 0 };
return {
rows: [],
total: 0
};
}
},
// 序列号生成
@ -234,7 +240,11 @@
// 消息提示
msg: function(content, type) {
if (type != undefined) {
layer.msg(content, { icon: $.modal.icon(type), time: 1000, shift: 5 });
layer.msg(content, {
icon: $.modal.icon(type),
time: 1000,
shift: 5
});
} else {
layer.msg(content);
}
@ -358,7 +368,8 @@
btn: ['<i class="fa fa-check"></i> 确认', '<i class="fa fa-close"></i> 关闭'],
yes: function(index, layero) {
options.callBack(index, layero)
}, cancel: function () {
},
cancel: function() {
return true;
}
});
@ -406,7 +417,9 @@
},
// 打开遮罩层
loading: function(message) {
$.blockUI({ message: '<div class="loaderbox"><div class="loading-activity"></div> ' + message + '</div>' });
$.blockUI({
message: '<div class="loaderbox"><div class="loading-activity"></div> ' + message + '</div>'
});
},
// 关闭遮罩层
closeLoading: function() {
@ -477,7 +490,9 @@
remove: function(id) {
$.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗?", function() {
var url = $.common.isEmpty(id) ? $.table._option.removeUrl : $.table._option.removeUrl.replace("{id}", id);
var data = { "ids": id };
var data = {
"ids": id
};
$.operate.submit(url, "post", "json", data);
});
},
@ -490,7 +505,9 @@
}
$.modal.confirm("确认要删除选中的" + rows.length + "条数据吗?", function() {
var url = $.table._option.removeUrl;
var data = { "ids": rows.join() };
var data = {
"ids": rows.join()
};
$.operate.submit(url, "post", "json", data);
});
},
@ -629,9 +646,21 @@
// 树结构初始化加载
var setting = {
check: options.check,
view: { selectedMulti: false, nameIsHTML: true },
data: { key: { title: "title" }, simpleData: { enable: true } },
callback: { onClick: options.onClick }
view: {
selectedMulti: false,
nameIsHTML: true
},
data: {
key: {
title: "title"
},
simpleData: {
enable: true
}
},
callback: {
onClick: options.onClick
}
};
$.get(options.url, function(data) {
var treeName = $("#treeName").val();
@ -794,10 +823,7 @@
common: {
// 判断字符串是否为空
isEmpty: function(value) {
if (value == null || this.trim(value) == "") {
return true;
}
return false;
return value == null || this.trim(value) === "" || typeof(value) == "undefined";
},
// 判断一个字符串是否为非空串
isNotEmpty: function(value) {