方法抽取

v1.0
bobi 2019-05-14 12:12:13 +08:00
parent 05696d812d
commit bb90a65d2b
1 changed files with 20 additions and 12 deletions

View File

@ -63,7 +63,7 @@
}).extend({
okLayer: "okLayer/okLayer",
okUtils: "okUtils/okUtils"
}).use(["element", "table", "form", "jquery", "laydate", "okLayer", "okUtils"], function () {
}).use(["element", "table", "form", "laydate", "okLayer", "okUtils"], function () {
var table = layui.table;
var form = layui.form;
var $ = layui.jquery;
@ -108,18 +108,9 @@
var data = obj.data;
var layEvent = obj.event;
if (layEvent === "edit") {
okLayer.open("编辑用户", "user-edit.html", "90%", "90%", function () {
$(".layui-laypage-btn")[0].click();
})
edit(data.id)
} else if (layEvent === "del") {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/user/batchDel", "post", {idsStr: data.id}).done(function (response) {
console.log(response)
okUtils.table.operationSuccessMsg("删除成功");
}).fail(function (error) {
console.log(error)
});
})
del(data.id);
}
});
@ -175,6 +166,23 @@
$(".layui-laypage-btn")[0].click();
})
})
function edit (id) {
okLayer.open("编辑用户", "user-edit.html?id=" + id, "90%", "90%", function () {
$(".layui-laypage-btn")[0].click();
})
}
function del (id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/user/batchDel", "post", {idsStr: id}).done(function (response) {
console.log(response)
okUtils.table.operationSuccessMsg("删除成功");
}).fail(function (error) {
console.log(error)
});
})
}
})
</script>
<!--模板-->