dongfeng-pay/legend/views/scale-template.html

124 lines
5.4 KiB
Go
Raw Normal View History

2021-04-27 15:33:49 +08:00
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title>充值商户后台</title>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="../static/x-admin/css/font.css">
<link rel="stylesheet" href="../static/x-admin/css/xadmin.css">
<link rel="stylesheet" href="../static/x-admin/lib/layui/css/layui.css">
<!-- <link rel="stylesheet" href="./css/theme5.css"> -->
<script src="../static/x-admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../static/x-admin/js/xadmin.js"></script>
<script type="text/javascript" src="../static/js/jquery-3.5.1.min.js"></script>
2021-05-16 15:21:52 +08:00
2021-04-27 15:33:49 +08:00
</head>
<body>
<div class="layui-fluid">
<div class="layui-card">
<div class="layui-card-body">
<table id="demo" lay-filter="test"></table>
<script type="text/html" id="toolbarHead">
<div class="layui-btn-container">
2021-05-16 15:21:52 +08:00
<button class="layui-btn layui-btn-sm" lay-event="create-template"><i class="layui-icon layui-icon-add-1"></i>创建模板</button>
2021-04-27 15:33:49 +08:00
</div>
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
2021-05-16 15:21:52 +08:00
<button class="layui-btn layui-btn-sm" lay-event="edit-template"><i class="layui-icon layui-icon-edit"></i> 编辑</button>
<button class="layui-btn layui-btn-danger" lay-event="delete-template"><i class="layui-icon layui-icon-delete"></i>删除</button>
2021-04-27 15:33:49 +08:00
</div>
</script>
<script>
layui.use('table', function(){
let table = layui.table;
//第一个实例
table.render({
elem: '#demo'
2021-05-16 15:21:52 +08:00
,height: 460
2021-04-27 15:33:49 +08:00
// ,width: 480
2021-05-16 15:21:52 +08:00
,url: '/template/list' //数据接口
2021-04-27 15:33:49 +08:00
,page: true //开启分页
,limits: [10, 20, 30, 50, 100, 200]
,cols: [[ //表头
2021-05-16 15:21:52 +08:00
{field: 'Id', title: 'ID', sort: true, fixed: 'left'}
,{field: 'TemplateName', title: '模板名称'}
,{field: 'UserUid', title: '用户标识'}
,{field: 'UserWarn', title: '提醒标语'}
,{field: 'CreateTime', title: '创建时间', sort: true}
2021-04-27 15:33:49 +08:00
,{fixed: 'right', title: "操作", width:180, align:'center', toolbar: '#toolbarDemo'}
]]
,toolbar: "#toolbarHead"
});
// 监听头工具栏事件
table.on('toolbar(test)', function (obj) {
let event = obj.event;
// 头工具栏的监听事件
2021-05-16 15:21:52 +08:00
if (event === "create-template") {
location.href = "/templateAdd.html"
2021-04-27 15:33:49 +08:00
}
});
//监听行工具栏事件
table.on('tool(test)', function (obj) {
let data = obj.data;
let event = obj.event;
// 编辑行内容
2021-05-16 15:21:52 +08:00
if (event === "edit-template") {
location.href = "/templateEdit.html?templateName=" + data.TemplateName;
2021-04-27 15:33:49 +08:00
}
// 删除该行
2021-05-16 15:21:52 +08:00
if (event === "delete-template") {
2021-04-27 15:33:49 +08:00
layer.confirm("确定删除该行?", function (index) {
2021-05-16 15:21:52 +08:00
$.ajax({
url: "/delete/template",
data: {
"TemplateName": data.TemplateName
},
success: function (res) {
console.log(res)
if (res.Code === 0) {
obj.del()
table.reload('demo', {
url: "/template/list",
where: {
"page":1
}
2021-05-16 15:21:52 +08:00
})
} else {
alert(res.Msg)
}
},
error: function () {
alert("系统异常")
}
})
2021-04-27 15:33:49 +08:00
layer.close(index);
})
}
2021-05-16 15:21:52 +08:00
});
2021-04-27 15:33:49 +08:00
});
</script>
</div>
</div>
</div>
</body>
</html>