feat(plugins): Cookie 管理两个表格页 UI 对齐用户管理标准
将「登录用户」与「登录网站」两个表格页统一为后台通用风格,未改动 framework。 过滤栏 - 由单一"关键词"改为按字段过滤: * cookie_user:用户名 / 网站名称 / 状态 * cookie_site:网站名称 / 域名 / 状态 - view 的 data() 同步支持上述字段(enable 为 0/1,None 不参与过滤) 表格工具栏与默认工具栏 - 新增 toolbar(新增按钮,带 authorize 权限判断) - 补齐 defaultToolbar:刷新 / 筛选列 / 打印 / 导出 状态与操作 - 状态列由徽章改为 switch 开关,点击即调既有 /enable、/disable 接口 - 操作列仅保留编辑/删除(带 authorize),删除原冗余的启用/禁用行按钮 - 统一 window.add/edit/remove/refresh 与 popup.success/popup.failure 提示
This commit is contained in:
@@ -1,47 +1,78 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>登录网站</title>
|
<title>登录网站</title>
|
||||||
{% include 'system/common/header.html' %}
|
{% include 'system/common/header.html' %}
|
||||||
</head>
|
</head>
|
||||||
<body class="pear-container">
|
<body class="pear-container">
|
||||||
|
{# 查询表单 #}
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<form class="layui-form" action="" lay-filter="cookie-site-query-form">
|
<form class="layui-form" action="" lay-filter="cookie-site-query-form">
|
||||||
<div class="layui-form-item" style="margin-bottom: unset;">
|
<div class="layui-form-item" style="margin-bottom: unset;">
|
||||||
<label class="layui-form-label">关键词</label>
|
<label class="layui-form-label">网站名称</label>
|
||||||
<div class="layui-input-inline">
|
<div class="layui-input-inline">
|
||||||
<input type="text" name="keyword" placeholder="网站名称/链接" class="layui-input">
|
<input type="text" name="name" placeholder="" class="layui-input">
|
||||||
|
</div>
|
||||||
|
<label class="layui-form-label">域名</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<input type="text" name="domain" placeholder="" class="layui-input">
|
||||||
|
</div>
|
||||||
|
<label class="layui-form-label">状态</label>
|
||||||
|
<div class="layui-input-inline">
|
||||||
|
<select name="enable">
|
||||||
|
<option value="">全部</option>
|
||||||
|
<option value="1">启用</option>
|
||||||
|
<option value="0">禁用</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<button class="layui-btn layui-btn-md" lay-submit lay-filter="cookie-site-query">
|
<button class="layui-btn layui-btn-md" lay-submit lay-filter="cookie-site-query">
|
||||||
<i class="layui-icon layui-icon-search"></i> 查询
|
<i class="layui-icon layui-icon-search"></i>
|
||||||
|
查询
|
||||||
</button>
|
</button>
|
||||||
<button type="reset" class="layui-btn layui-btn-primary layui-btn-md">
|
<button type="reset" class="layui-btn layui-btn-primary layui-btn-md">
|
||||||
<i class="layui-icon layui-icon-refresh"></i> 重置
|
<i class="layui-icon layui-icon-refresh"></i>
|
||||||
</button>
|
重置
|
||||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-md" id="btn-add">
|
|
||||||
<i class="layui-icon layui-icon-add-1"></i> 新增登录网站
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{# 网站表格 #}
|
||||||
<div class="layui-card">
|
<div class="layui-card">
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body">
|
||||||
<table id="cookie-site-table" lay-filter="cookie-site-table"></table>
|
<table id="cookie-site-table" lay-filter="cookie-site-table"></table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
{% include 'system/common/footer.html' %}
|
{% include 'system/common/footer.html' %}
|
||||||
|
{# 表格工具栏 #}
|
||||||
|
<script type="text/html" id="cookie-site-toolbar">
|
||||||
|
{% if authorize("system:cookie-site:add") %}
|
||||||
|
<button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="add">
|
||||||
|
<i class="pear-icon pear-icon-add"></i>
|
||||||
|
新增
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{# 行操作 #}
|
||||||
|
<script type="text/html" id="cookie-site-op">
|
||||||
|
{% if authorize("system:cookie-site:edit") %}
|
||||||
|
<button class="layui-btn layui-btn-xs" lay-event="edit"><i class="pear-icon pear-icon-edit"></i> 编辑</button>
|
||||||
|
{% endif %}
|
||||||
|
{% if authorize("system:cookie-site:remove") %}
|
||||||
|
<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="remove"><i
|
||||||
|
class="pear-icon pear-icon-ashbin"></i> 删除
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</script>
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
<script type="text/html" id="col-cookie-site-status">
|
<script type="text/html" id="cookie-site-enable">
|
||||||
{{# if(d.enable === 1){ }}
|
<input type="checkbox" name="enable" value="{{ d.id }}" lay-skin="switch" lay-text="启用|禁用"
|
||||||
<span class="layui-badge layui-bg-green">启用</span>
|
lay-filter="cookie-site-enable" {{# if(d.enable==1){ }} checked {{# } }} />
|
||||||
{{# } else { }}
|
|
||||||
<span class="layui-badge layui-bg-gray">禁用</span>
|
|
||||||
{{# } }}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="col-cookie-site-value">
|
<script type="text/html" id="col-cookie-site-value">
|
||||||
@@ -52,112 +83,135 @@
|
|||||||
<span>{{ v }}</span>
|
<span>{{ v }}</span>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="col-cookie-site-op">
|
|
||||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
|
||||||
{{# if(d.enable === 1){ }}
|
|
||||||
<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="disable">禁用</a>
|
|
||||||
{{# } else { }}
|
|
||||||
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="enable">启用</a>
|
|
||||||
{{# } }}
|
|
||||||
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="remove">删除</a>
|
|
||||||
</script>
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
layui.use(['table', 'form', 'layer'], function(){
|
layui.use(['table', 'form', 'jquery', 'popup', 'common'], function () {
|
||||||
var table = layui.table;
|
let table = layui.table
|
||||||
var form = layui.form;
|
let form = layui.form
|
||||||
var layer = layui.layer;
|
let $ = layui.jquery
|
||||||
var $ = layui.$;
|
let popup = layui.popup
|
||||||
|
let common = layui.common
|
||||||
|
let MODULE_PATH = "{{ url_for('cookie_site.main') }}"
|
||||||
|
|
||||||
var renderTable = function(){
|
let cols = [
|
||||||
var keyword = $('input[name="keyword"]').val() || '';
|
[
|
||||||
table.render({
|
{title: '编号', field: 'id', align: 'center', width: 80},
|
||||||
elem: '#cookie-site-table',
|
{title: '网站名称', field: 'name', align: 'center'},
|
||||||
url: '/system/cookie-site/data',
|
{title: '网站URL', field: 'url', align: 'center', minWidth: 200},
|
||||||
where: { keyword: keyword },
|
{title: 'Cookie值', field: 'cookie_value', align: 'center', minWidth: 200, templet: '#col-cookie-site-value'},
|
||||||
page: true,
|
{title: '域名', field: 'domain', align: 'center'},
|
||||||
limit: 20,
|
{title: '路径', field: 'path', align: 'center'},
|
||||||
cols: [[
|
{title: '过期时间', field: 'expiry', align: 'center'},
|
||||||
{field: 'id', title: 'ID', width: 60},
|
{title: 'Secure', field: 'secure', align: 'center', templet: function (d) {
|
||||||
{field: 'name', title: '网站名称', width: 150},
|
|
||||||
{field: 'url', title: '网站URL', minWidth: 200},
|
|
||||||
{field: 'cookie_value', title: 'Cookie值', minWidth: 200, templet: '#col-cookie-site-value'},
|
|
||||||
{field: 'domain', title: '域名', width: 150},
|
|
||||||
{field: 'path', title: '路径', width: 100},
|
|
||||||
{field: 'expiry', title: '过期时间', width: 160},
|
|
||||||
{field: 'secure', title: 'Secure', width: 80, templet: function(d){
|
|
||||||
return d.secure === 1 ? '<span class="layui-badge">是</span>' : '<span class="layui-badge layui-bg-gray">否</span>';
|
return d.secure === 1 ? '<span class="layui-badge">是</span>' : '<span class="layui-badge layui-bg-gray">否</span>';
|
||||||
}},
|
}},
|
||||||
{field: 'http_only', title: 'HTTPOnly', width: 90, templet: function(d){
|
{title: 'HTTPOnly', field: 'http_only', align: 'center', templet: function (d) {
|
||||||
return d.http_only === 1 ? '<span class="layui-badge">是</span>' : '<span class="layui-badge layui-bg-gray">否</span>';
|
return d.http_only === 1 ? '<span class="layui-badge">是</span>' : '<span class="layui-badge layui-bg-gray">否</span>';
|
||||||
}},
|
}},
|
||||||
{field: 'enable', title: '状态', width: 80, templet: '#col-cookie-site-status'},
|
{title: '状态', field: 'enable', align: 'center', templet: '#cookie-site-enable', width: 100},
|
||||||
{field: 'create_at', title: '创建时间', width: 160},
|
{title: '创建时间', field: 'create_at', align: 'center'},
|
||||||
{fixed: 'right', title: '操作', toolbar: '#col-cookie-site-op', width: 200}
|
{title: '操作', toolbar: '#cookie-site-op', align: 'center', width: 140}
|
||||||
]],
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
table.render({
|
||||||
|
elem: '#cookie-site-table',
|
||||||
|
url: MODULE_PATH + 'data',
|
||||||
|
page: true,
|
||||||
|
cols: cols,
|
||||||
skin: 'line',
|
skin: 'line',
|
||||||
|
toolbar: '#cookie-site-toolbar', /*工具栏*/
|
||||||
text: {none: '暂无登录网站'},
|
text: {none: '暂无登录网站'},
|
||||||
});
|
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'] /*默认工具栏*/
|
||||||
};
|
})
|
||||||
|
|
||||||
renderTable();
|
table.on('tool(cookie-site-table)', function (obj) {
|
||||||
|
if (obj.event === 'remove') {
|
||||||
|
window.remove(obj)
|
||||||
|
} else if (obj.event === 'edit') {
|
||||||
|
window.edit(obj)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
form.on('submit(cookie-site-query)', function(){
|
table.on('toolbar(cookie-site-table)', function (obj) {
|
||||||
renderTable();
|
if (obj.event === 'add') {
|
||||||
return false;
|
window.add()
|
||||||
});
|
} else if (obj.event === 'refresh') {
|
||||||
|
window.refresh()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
$('#btn-add').on('click', function(){
|
form.on('submit(cookie-site-query)', function (data) {
|
||||||
layer.open({
|
window.refresh(data.field)
|
||||||
type: 2,
|
return false
|
||||||
title: '新增登录网站',
|
})
|
||||||
area: ['700px', '680px'],
|
|
||||||
content: '/system/cookie-site/add'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
table.on('tool(cookie-site-table)', function(obj){
|
form.on('switch(cookie-site-enable)', function (obj) {
|
||||||
var data = obj.data;
|
let operate = obj.elem.checked ? 'enable' : 'disable'
|
||||||
if (obj.event === 'edit'){
|
let loading = layer.load()
|
||||||
|
$.ajax({
|
||||||
|
url: MODULE_PATH + operate,
|
||||||
|
data: JSON.stringify({cookieSiteId: this.value}),
|
||||||
|
dataType: 'json',
|
||||||
|
contentType: 'application/json',
|
||||||
|
type: 'put',
|
||||||
|
success: function (result) {
|
||||||
|
layer.close(loading)
|
||||||
|
if (result.success) {
|
||||||
|
popup.success(result.msg)
|
||||||
|
} else {
|
||||||
|
popup.failure(result.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
window.add = function () {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '新增登录网站',
|
||||||
|
shade: 0.1,
|
||||||
|
area: ['700px', '680px'],
|
||||||
|
content: MODULE_PATH + 'add'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
window.edit = function (obj) {
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 2,
|
type: 2,
|
||||||
title: '编辑登录网站',
|
title: '编辑登录网站',
|
||||||
|
shade: 0.1,
|
||||||
area: ['700px', '680px'],
|
area: ['700px', '680px'],
|
||||||
content: '/system/cookie-site/edit?cookieSiteId=' + data.id
|
content: MODULE_PATH + 'edit?cookieSiteId=' + obj.data['id']
|
||||||
});
|
})
|
||||||
} else if (obj.event === 'remove'){
|
|
||||||
layer.confirm('确定删除该登录网站吗?', function(idx){
|
|
||||||
$.ajax({
|
|
||||||
url: '/system/cookie-site/remove/' + data.id,
|
|
||||||
type: 'DELETE',
|
|
||||||
success: function(res){
|
|
||||||
if (res.code === 0 || res.success) { layer.msg(res.msg); obj.del(); }
|
|
||||||
else layer.msg(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
layer.close(idx);
|
|
||||||
});
|
|
||||||
} else if (obj.event === 'enable'){
|
|
||||||
$.ajax({
|
|
||||||
url: '/system/cookie-site/enable',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify({cookieSiteId: data.id}),
|
|
||||||
success: function(res){ layer.msg(res.msg); renderTable(); }
|
|
||||||
});
|
|
||||||
} else if (obj.event === 'disable'){
|
|
||||||
$.ajax({
|
|
||||||
url: '/system/cookie-site/disable',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify({cookieSiteId: data.id}),
|
|
||||||
success: function(res){ layer.msg(res.msg); renderTable(); }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
window.remove = function (obj) {
|
||||||
|
layer.confirm('确定要删除该登录网站吗?', {icon: 3, title: '提示'}, function (index) {
|
||||||
|
layer.close(index)
|
||||||
|
let loading = layer.load()
|
||||||
|
$.ajax({
|
||||||
|
url: MODULE_PATH + 'remove/' + obj.data['id'],
|
||||||
|
dataType: 'json',
|
||||||
|
type: 'delete',
|
||||||
|
success: function (result) {
|
||||||
|
layer.close(loading)
|
||||||
|
if (result.success) {
|
||||||
|
popup.success(result.msg, function () {
|
||||||
|
obj.del()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
popup.failure(result.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
window.refresh = function (param) {
|
||||||
|
table.reload('cookie-site-table', {where: param})
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,47 +1,78 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html data-page-node-id="nQ3ITuR4zDwbCF6p13JV3O">
|
||||||
<head>
|
<head data-page-node-id="362DYrCMG2OfSNeB1CrBUI">
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>登录用户</title>
|
<title>登录用户</title>
|
||||||
{% include 'system/common/header.html' %}
|
{% include 'system/common/header.html' %}
|
||||||
</head>
|
</head>
|
||||||
<body class="pear-container">
|
<body class="pear-container" data-page-node-id="vuCo8sukVr7NEXTFDw4ukr">
|
||||||
<div class="layui-card">
|
{# 查询表单 #}
|
||||||
<div class="layui-card-body">
|
<div class="layui-card" data-page-node-id="FkafykRVcgd3J5QM701u9m">
|
||||||
<form class="layui-form" action="" lay-filter="cookie-user-query-form">
|
<div class="layui-card-body" data-page-node-id="NhR1BdkceCvxnNalFio2Ex">
|
||||||
<div class="layui-form-item" style="margin-bottom: unset;">
|
<form class="layui-form" action="" lay-filter="cookie-user-query-form" data-page-node-id="oOeYUkHNWDWhgZEgAB4orE">
|
||||||
<label class="layui-form-label">关键词</label>
|
<div class="layui-form-item" style="margin-bottom: unset;" data-page-node-id="AFgBQnMe9yarnPTWhBcIRK">
|
||||||
<div class="layui-input-inline">
|
<label class="layui-form-label" data-page-node-id="Xb4iWfiiqhbNRHdWjbAb3E">用户名</label>
|
||||||
<input type="text" name="keyword" placeholder="用户名/网站名/链接" class="layui-input">
|
<div class="layui-input-inline" data-page-node-id="DK3ArwBhRytS3ngGklfh7w">
|
||||||
|
<input type="text" name="username" placeholder="" class="layui-input" data-page-node-id="ZYzp5udhYsqFTnA2wE5M6p">
|
||||||
</div>
|
</div>
|
||||||
<button class="layui-btn layui-btn-md" lay-submit lay-filter="cookie-user-query">
|
<label class="layui-form-label" data-page-node-id="NUTFOHrZgMUAxAO1WOUQrG">网站名称</label>
|
||||||
<i class="layui-icon layui-icon-search"></i> 查询
|
<div class="layui-input-inline" data-page-node-id="ZxghmnDL6c3yHIPdtHWowq">
|
||||||
|
<input type="text" name="website_name" placeholder="" class="layui-input" data-page-node-id="dL40ElcUT6mf0xTBmYe1z1">
|
||||||
|
</div>
|
||||||
|
<label class="layui-form-label" data-page-node-id="B2wAnrFYnJdiJEqiObxY8H">状态</label>
|
||||||
|
<div class="layui-input-inline" data-page-node-id="5Hbez5BZiHn8ex8StE3jeo">
|
||||||
|
<select name="enable" data-page-node-id="fXvV5XXzpzdWODebmoYuiK">
|
||||||
|
<option value="" data-page-node-id="w2RiYtN3dpyd04Q2GdFhhY">全部</option>
|
||||||
|
<option value="1" data-page-node-id="GZOFDvlu334UlLr94jv5fF">启用</option>
|
||||||
|
<option value="0" data-page-node-id="HHiccr1lHku4DZEQBvSNqE">禁用</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<button class="layui-btn layui-btn-md" lay-submit lay-filter="cookie-user-query" data-page-node-id="gNH72uHn51mmqnHJ2Ja7wz">
|
||||||
|
<i class="layui-icon layui-icon-search" data-page-node-id="eCxLvl4XjRfJxK3uUmhrm0"></i>
|
||||||
|
查询
|
||||||
</button>
|
</button>
|
||||||
<button type="reset" class="layui-btn layui-btn-primary layui-btn-md">
|
<button type="reset" class="layui-btn layui-btn-primary layui-btn-md" data-page-node-id="545NTjMd1cnk4zmGYh6FP1">
|
||||||
<i class="layui-icon layui-icon-refresh"></i> 重置
|
<i class="layui-icon layui-icon-refresh" data-page-node-id="T1uDenvLCistNzsdmC718A"></i>
|
||||||
</button>
|
重置
|
||||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-md" id="btn-add">
|
|
||||||
<i class="layui-icon layui-icon-add-1"></i> 新增登录用户
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{# 用户表格 #}
|
||||||
<div class="layui-card">
|
<div class="layui-card" data-page-node-id="LYGYvZo2bjHlAZyxZn4EVj">
|
||||||
<div class="layui-card-body">
|
<div class="layui-card-body" data-page-node-id="5SmK9lErPfo0dBsQ2Xj9lC">
|
||||||
<table id="cookie-user-table" lay-filter="cookie-user-table"></table>
|
<table id="cookie-user-table" lay-filter="cookie-user-table" data-page-node-id="7NfVW6oi3HIO1OO5GIbzZB"></table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
{% include 'system/common/footer.html' %}
|
{% include 'system/common/footer.html' %}
|
||||||
|
{# 表格工具栏 #}
|
||||||
|
<script type="text/html" id="cookie-user-toolbar">
|
||||||
|
{% if authorize("system:cookie-user:add") %}
|
||||||
|
<button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="add">
|
||||||
|
<i class="pear-icon pear-icon-add"></i>
|
||||||
|
新增
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{# 行操作 #}
|
||||||
|
<script type="text/html" id="cookie-user-op">
|
||||||
|
{% if authorize("system:cookie-user:edit") %}
|
||||||
|
<button class="layui-btn layui-btn-xs" lay-event="edit"><i class="pear-icon pear-icon-edit"></i> 编辑</button>
|
||||||
|
{% endif %}
|
||||||
|
{% if authorize("system:cookie-user:remove") %}
|
||||||
|
<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="remove"><i
|
||||||
|
class="pear-icon pear-icon-ashbin"></i> 删除
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</script>
|
||||||
|
|
||||||
{% raw %}
|
{% raw %}
|
||||||
<script type="text/html" id="col-cookie-user-status">
|
<script type="text/html" id="cookie-user-enable">
|
||||||
{{# if(d.enable === 1){ }}
|
<input type="checkbox" name="enable" value="{{ d.id }}" lay-skin="switch" lay-text="启用|禁用"
|
||||||
<span class="layui-badge layui-bg-green">启用</span>
|
lay-filter="cookie-user-enable" {{# if(d.enable==1){ }} checked {{# } }} />
|
||||||
{{# } else { }}
|
|
||||||
<span class="layui-badge layui-bg-gray">禁用</span>
|
|
||||||
{{# } }}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="col-cookie-user-value">
|
<script type="text/html" id="col-cookie-user-value">
|
||||||
@@ -52,107 +83,130 @@
|
|||||||
<span>{{ v }}</span>
|
<span>{{ v }}</span>
|
||||||
{{# } }}
|
{{# } }}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="col-cookie-user-op">
|
|
||||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
|
||||||
{{# if(d.enable === 1){ }}
|
|
||||||
<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="disable">禁用</a>
|
|
||||||
{{# } else { }}
|
|
||||||
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="enable">启用</a>
|
|
||||||
{{# } }}
|
|
||||||
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="remove">删除</a>
|
|
||||||
</script>
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
layui.use(['table', 'form', 'layer'], function(){
|
layui.use(['table', 'form', 'jquery', 'popup', 'common'], function () {
|
||||||
var table = layui.table;
|
let table = layui.table
|
||||||
var form = layui.form;
|
let form = layui.form
|
||||||
var layer = layui.layer;
|
let $ = layui.jquery
|
||||||
var $ = layui.$;
|
let popup = layui.popup
|
||||||
|
let common = layui.common
|
||||||
|
let MODULE_PATH = "{{ url_for('cookie_user.main') }}"
|
||||||
|
|
||||||
|
let cols = [
|
||||||
|
[
|
||||||
|
{title: '编号', field: 'id', align: 'center', width: 80},
|
||||||
|
{title: '用户名', field: 'username', align: 'center'},
|
||||||
|
{title: '昵称', field: 'nickname', align: 'center'},
|
||||||
|
{title: '网站名称', field: 'website_name', align: 'center'},
|
||||||
|
{title: '网站链接', field: 'website_url', align: 'center', minWidth: 200},
|
||||||
|
{title: 'Cookie值', field: 'cookie_value', align: 'center', minWidth: 200, templet: '#col-cookie-user-value'},
|
||||||
|
{title: '域名', field: 'domain', align: 'center'},
|
||||||
|
{title: '过期时间', field: 'expiry', align: 'center'},
|
||||||
|
{title: '状态', field: 'enable', align: 'center', templet: '#cookie-user-enable', width: 100},
|
||||||
|
{title: '创建时间', field: 'create_at', align: 'center'},
|
||||||
|
{title: '操作', toolbar: '#cookie-user-op', align: 'center', width: 140}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
var renderTable = function(){
|
|
||||||
var keyword = $('input[name="keyword"]').val() || '';
|
|
||||||
table.render({
|
table.render({
|
||||||
elem: '#cookie-user-table',
|
elem: '#cookie-user-table',
|
||||||
url: '/system/cookie-user/data',
|
url: MODULE_PATH + 'data',
|
||||||
where: { keyword: keyword },
|
|
||||||
page: true,
|
page: true,
|
||||||
limit: 20,
|
cols: cols,
|
||||||
cols: [[
|
|
||||||
{field: 'id', title: 'ID', width: 60},
|
|
||||||
{field: 'username', title: '用户名', width: 150},
|
|
||||||
{field: 'nickname', title: '昵称', width: 120},
|
|
||||||
{field: 'website_name', title: '网站名称', width: 150},
|
|
||||||
{field: 'website_url', title: '网站链接', minWidth: 200},
|
|
||||||
{field: 'cookie_value', title: 'Cookie值', minWidth: 200, templet: '#col-cookie-user-value'},
|
|
||||||
{field: 'domain', title: '域名', width: 150},
|
|
||||||
{field: 'expiry', title: '过期时间', width: 160},
|
|
||||||
{field: 'enable', title: '状态', width: 80, templet: '#col-cookie-user-status'},
|
|
||||||
{field: 'create_at', title: '创建时间', width: 160},
|
|
||||||
{fixed: 'right', title: '操作', toolbar: '#col-cookie-user-op', width: 200}
|
|
||||||
]],
|
|
||||||
skin: 'line',
|
skin: 'line',
|
||||||
|
toolbar: '#cookie-user-toolbar', /*工具栏*/
|
||||||
text: {none: '暂无登录用户'},
|
text: {none: '暂无登录用户'},
|
||||||
});
|
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'] /*默认工具栏*/
|
||||||
};
|
})
|
||||||
|
|
||||||
renderTable();
|
table.on('tool(cookie-user-table)', function (obj) {
|
||||||
|
if (obj.event === 'remove') {
|
||||||
|
window.remove(obj)
|
||||||
|
} else if (obj.event === 'edit') {
|
||||||
|
window.edit(obj)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
form.on('submit(cookie-user-query)', function(){
|
table.on('toolbar(cookie-user-table)', function (obj) {
|
||||||
renderTable();
|
if (obj.event === 'add') {
|
||||||
return false;
|
window.add()
|
||||||
});
|
} else if (obj.event === 'refresh') {
|
||||||
|
window.refresh()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
$('#btn-add').on('click', function(){
|
form.on('submit(cookie-user-query)', function (data) {
|
||||||
layer.open({
|
window.refresh(data.field)
|
||||||
type: 2,
|
return false
|
||||||
title: '新增登录用户',
|
})
|
||||||
area: ['700px', '680px'],
|
|
||||||
content: '/system/cookie-user/add'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
table.on('tool(cookie-user-table)', function(obj){
|
form.on('switch(cookie-user-enable)', function (obj) {
|
||||||
var data = obj.data;
|
let operate = obj.elem.checked ? 'enable' : 'disable'
|
||||||
if (obj.event === 'edit'){
|
let loading = layer.load()
|
||||||
|
$.ajax({
|
||||||
|
url: MODULE_PATH + operate,
|
||||||
|
data: JSON.stringify({cookieUserId: this.value}),
|
||||||
|
dataType: 'json',
|
||||||
|
contentType: 'application/json',
|
||||||
|
type: 'put',
|
||||||
|
success: function (result) {
|
||||||
|
layer.close(loading)
|
||||||
|
if (result.success) {
|
||||||
|
popup.success(result.msg)
|
||||||
|
} else {
|
||||||
|
popup.failure(result.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
window.add = function () {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '新增登录用户',
|
||||||
|
shade: 0.1,
|
||||||
|
area: ['700px', '680px'],
|
||||||
|
content: MODULE_PATH + 'add'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
window.edit = function (obj) {
|
||||||
layer.open({
|
layer.open({
|
||||||
type: 2,
|
type: 2,
|
||||||
title: '编辑登录用户',
|
title: '编辑登录用户',
|
||||||
|
shade: 0.1,
|
||||||
area: ['700px', '680px'],
|
area: ['700px', '680px'],
|
||||||
content: '/system/cookie-user/edit?cookieUserId=' + data.id
|
content: MODULE_PATH + 'edit?cookieUserId=' + obj.data['id']
|
||||||
});
|
})
|
||||||
} else if (obj.event === 'remove'){
|
|
||||||
layer.confirm('确定删除该登录用户吗?', function(idx){
|
|
||||||
$.ajax({
|
|
||||||
url: '/system/cookie-user/remove/' + data.id,
|
|
||||||
type: 'DELETE',
|
|
||||||
success: function(res){
|
|
||||||
if (res.code === 0 || res.success) { layer.msg(res.msg); obj.del(); }
|
|
||||||
else layer.msg(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
layer.close(idx);
|
|
||||||
});
|
|
||||||
} else if (obj.event === 'enable'){
|
|
||||||
$.ajax({
|
|
||||||
url: '/system/cookie-user/enable',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify({cookieUserId: data.id}),
|
|
||||||
success: function(res){ layer.msg(res.msg); renderTable(); }
|
|
||||||
});
|
|
||||||
} else if (obj.event === 'disable'){
|
|
||||||
$.ajax({
|
|
||||||
url: '/system/cookie-user/disable',
|
|
||||||
type: 'PUT',
|
|
||||||
contentType: 'application/json',
|
|
||||||
data: JSON.stringify({cookieUserId: data.id}),
|
|
||||||
success: function(res){ layer.msg(res.msg); renderTable(); }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
window.remove = function (obj) {
|
||||||
|
layer.confirm('确定要删除该登录用户吗?', {icon: 3, title: '提示'}, function (index) {
|
||||||
|
layer.close(index)
|
||||||
|
let loading = layer.load()
|
||||||
|
$.ajax({
|
||||||
|
url: MODULE_PATH + 'remove/' + obj.data['id'],
|
||||||
|
dataType: 'json',
|
||||||
|
type: 'delete',
|
||||||
|
success: function (result) {
|
||||||
|
layer.close(loading)
|
||||||
|
if (result.success) {
|
||||||
|
popup.success(result.msg, function () {
|
||||||
|
obj.del()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
popup.failure(result.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
window.refresh = function (param) {
|
||||||
|
table.reload('cookie-user-table', {where: param})
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -32,15 +32,16 @@ def main():
|
|||||||
@limiter.limit("60 per minute")
|
@limiter.limit("60 per minute")
|
||||||
@authorize("system:cookie-site:main")
|
@authorize("system:cookie-site:main")
|
||||||
def data():
|
def data():
|
||||||
keyword = str_escape(request.args.get('keyword', type=str))
|
name = str_escape(request.args.get('name', type=str))
|
||||||
|
domain = str_escape(request.args.get('domain', type=str))
|
||||||
|
enable = request.args.get('enable', type=int)
|
||||||
query = CookieSite.query.filter()
|
query = CookieSite.query.filter()
|
||||||
if keyword:
|
if name:
|
||||||
query = query.filter(
|
query = query.filter(CookieSite.name.contains(name))
|
||||||
db.or_(
|
if domain:
|
||||||
CookieSite.name.contains(keyword),
|
query = query.filter(CookieSite.domain.contains(domain))
|
||||||
CookieSite.url.contains(keyword),
|
if enable is not None:
|
||||||
)
|
query = query.filter(CookieSite.enable == enable)
|
||||||
)
|
|
||||||
items = query.order_by(CookieSite.id.desc()).layui_paginate()
|
items = query.order_by(CookieSite.id.desc()).layui_paginate()
|
||||||
return table_api(
|
return table_api(
|
||||||
msg="请求成功",
|
msg="请求成功",
|
||||||
|
|||||||
@@ -32,16 +32,16 @@ def main():
|
|||||||
@limiter.limit("60 per minute")
|
@limiter.limit("60 per minute")
|
||||||
@authorize("system:cookie-user:main")
|
@authorize("system:cookie-user:main")
|
||||||
def data():
|
def data():
|
||||||
keyword = str_escape(request.args.get('keyword', type=str))
|
username = str_escape(request.args.get('username', type=str))
|
||||||
|
website_name = str_escape(request.args.get('website_name', type=str))
|
||||||
|
enable = request.args.get('enable', type=int)
|
||||||
query = CookieUser.query.filter()
|
query = CookieUser.query.filter()
|
||||||
if keyword:
|
if username:
|
||||||
query = query.filter(
|
query = query.filter(CookieUser.username.contains(username))
|
||||||
db.or_(
|
if website_name:
|
||||||
CookieUser.username.contains(keyword),
|
query = query.filter(CookieUser.website_name.contains(website_name))
|
||||||
CookieUser.website_name.contains(keyword),
|
if enable is not None:
|
||||||
CookieUser.website_url.contains(keyword),
|
query = query.filter(CookieUser.enable == enable)
|
||||||
)
|
|
||||||
)
|
|
||||||
items = query.order_by(CookieUser.id.desc()).layui_paginate()
|
items = query.order_by(CookieUser.id.desc()).layui_paginate()
|
||||||
return table_api(
|
return table_api(
|
||||||
msg="请求成功",
|
msg="请求成功",
|
||||||
|
|||||||
Reference in New Issue
Block a user