将「登录用户」与「登录网站」两个表格页统一为后台通用风格,未改动 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 提示
218 lines
8.1 KiB
HTML
218 lines
8.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>登录网站</title>
|
|
{% include 'system/common/header.html' %}
|
|
</head>
|
|
<body class="pear-container">
|
|
{# 查询表单 #}
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<form class="layui-form" action="" lay-filter="cookie-site-query-form">
|
|
<div class="layui-form-item" style="margin-bottom: unset;">
|
|
<label class="layui-form-label">网站名称</label>
|
|
<div class="layui-input-inline">
|
|
<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>
|
|
<button class="layui-btn layui-btn-md" lay-submit lay-filter="cookie-site-query">
|
|
<i class="layui-icon layui-icon-search"></i>
|
|
查询
|
|
</button>
|
|
<button type="reset" class="layui-btn layui-btn-primary layui-btn-md">
|
|
<i class="layui-icon layui-icon-refresh"></i>
|
|
重置
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{# 网站表格 #}
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<table id="cookie-site-table" lay-filter="cookie-site-table"></table>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
|
|
{% 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 %}
|
|
<script type="text/html" id="cookie-site-enable">
|
|
<input type="checkbox" name="enable" value="{{ d.id }}" lay-skin="switch" lay-text="启用|禁用"
|
|
lay-filter="cookie-site-enable" {{# if(d.enable==1){ }} checked {{# } }} />
|
|
</script>
|
|
|
|
<script type="text/html" id="col-cookie-site-value">
|
|
{{# var v = d.cookie_value || ''; }}
|
|
{{# if(v.length > 30){ }}
|
|
<span title="{{ v }}">{{ v.slice(0, 30) }}...</span>
|
|
{{# } else { }}
|
|
<span>{{ v }}</span>
|
|
{{# } }}
|
|
</script>
|
|
{% endraw %}
|
|
|
|
<script>
|
|
layui.use(['table', 'form', 'jquery', 'popup', 'common'], function () {
|
|
let table = layui.table
|
|
let form = layui.form
|
|
let $ = layui.jquery
|
|
let popup = layui.popup
|
|
let common = layui.common
|
|
let MODULE_PATH = "{{ url_for('cookie_site.main') }}"
|
|
|
|
let cols = [
|
|
[
|
|
{title: '编号', field: 'id', align: 'center', width: 80},
|
|
{title: '网站名称', field: 'name', align: 'center'},
|
|
{title: '网站URL', field: 'url', align: 'center', minWidth: 200},
|
|
{title: 'Cookie值', field: 'cookie_value', align: 'center', minWidth: 200, templet: '#col-cookie-site-value'},
|
|
{title: '域名', field: 'domain', align: 'center'},
|
|
{title: '路径', field: 'path', align: 'center'},
|
|
{title: '过期时间', field: 'expiry', align: 'center'},
|
|
{title: 'Secure', field: 'secure', align: 'center', templet: function (d) {
|
|
return d.secure === 1 ? '<span class="layui-badge">是</span>' : '<span class="layui-badge layui-bg-gray">否</span>';
|
|
}},
|
|
{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>';
|
|
}},
|
|
{title: '状态', field: 'enable', align: 'center', templet: '#cookie-site-enable', width: 100},
|
|
{title: '创建时间', field: 'create_at', align: 'center'},
|
|
{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',
|
|
toolbar: '#cookie-site-toolbar', /*工具栏*/
|
|
text: {none: '暂无登录网站'},
|
|
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'] /*默认工具栏*/
|
|
})
|
|
|
|
table.on('tool(cookie-site-table)', function (obj) {
|
|
if (obj.event === 'remove') {
|
|
window.remove(obj)
|
|
} else if (obj.event === 'edit') {
|
|
window.edit(obj)
|
|
}
|
|
})
|
|
|
|
table.on('toolbar(cookie-site-table)', function (obj) {
|
|
if (obj.event === 'add') {
|
|
window.add()
|
|
} else if (obj.event === 'refresh') {
|
|
window.refresh()
|
|
}
|
|
})
|
|
|
|
form.on('submit(cookie-site-query)', function (data) {
|
|
window.refresh(data.field)
|
|
return false
|
|
})
|
|
|
|
form.on('switch(cookie-site-enable)', function (obj) {
|
|
let operate = obj.elem.checked ? 'enable' : 'disable'
|
|
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({
|
|
type: 2,
|
|
title: '编辑登录网站',
|
|
shade: 0.1,
|
|
area: ['700px', '680px'],
|
|
content: MODULE_PATH + 'edit?cookieSiteId=' + obj.data['id']
|
|
})
|
|
}
|
|
|
|
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>
|
|
</html>
|