将「登录用户」与「登录网站」两个表格页统一为后台通用风格,未改动 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 提示
213 lines
8.8 KiB
HTML
213 lines
8.8 KiB
HTML
<!DOCTYPE html>
|
|
<html data-page-node-id="nQ3ITuR4zDwbCF6p13JV3O">
|
|
<head data-page-node-id="362DYrCMG2OfSNeB1CrBUI">
|
|
<title>登录用户</title>
|
|
{% include 'system/common/header.html' %}
|
|
</head>
|
|
<body class="pear-container" data-page-node-id="vuCo8sukVr7NEXTFDw4ukr">
|
|
{# 查询表单 #}
|
|
<div class="layui-card" data-page-node-id="FkafykRVcgd3J5QM701u9m">
|
|
<div class="layui-card-body" data-page-node-id="NhR1BdkceCvxnNalFio2Ex">
|
|
<form class="layui-form" action="" lay-filter="cookie-user-query-form" data-page-node-id="oOeYUkHNWDWhgZEgAB4orE">
|
|
<div class="layui-form-item" style="margin-bottom: unset;" data-page-node-id="AFgBQnMe9yarnPTWhBcIRK">
|
|
<label class="layui-form-label" data-page-node-id="Xb4iWfiiqhbNRHdWjbAb3E">用户名</label>
|
|
<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>
|
|
<label class="layui-form-label" data-page-node-id="NUTFOHrZgMUAxAO1WOUQrG">网站名称</label>
|
|
<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 type="reset" class="layui-btn layui-btn-primary layui-btn-md" data-page-node-id="545NTjMd1cnk4zmGYh6FP1">
|
|
<i class="layui-icon layui-icon-refresh" data-page-node-id="T1uDenvLCistNzsdmC718A"></i>
|
|
重置
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{# 用户表格 #}
|
|
<div class="layui-card" data-page-node-id="LYGYvZo2bjHlAZyxZn4EVj">
|
|
<div class="layui-card-body" data-page-node-id="5SmK9lErPfo0dBsQ2Xj9lC">
|
|
<table id="cookie-user-table" lay-filter="cookie-user-table" data-page-node-id="7NfVW6oi3HIO1OO5GIbzZB"></table>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
|
|
{% 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 %}
|
|
<script type="text/html" id="cookie-user-enable">
|
|
<input type="checkbox" name="enable" value="{{ d.id }}" lay-skin="switch" lay-text="启用|禁用"
|
|
lay-filter="cookie-user-enable" {{# if(d.enable==1){ }} checked {{# } }} />
|
|
</script>
|
|
|
|
<script type="text/html" id="col-cookie-user-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_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}
|
|
]
|
|
]
|
|
|
|
table.render({
|
|
elem: '#cookie-user-table',
|
|
url: MODULE_PATH + 'data',
|
|
page: true,
|
|
cols: cols,
|
|
skin: 'line',
|
|
toolbar: '#cookie-user-toolbar', /*工具栏*/
|
|
text: {none: '暂无登录用户'},
|
|
defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'] /*默认工具栏*/
|
|
})
|
|
|
|
table.on('tool(cookie-user-table)', function (obj) {
|
|
if (obj.event === 'remove') {
|
|
window.remove(obj)
|
|
} else if (obj.event === 'edit') {
|
|
window.edit(obj)
|
|
}
|
|
})
|
|
|
|
table.on('toolbar(cookie-user-table)', function (obj) {
|
|
if (obj.event === 'add') {
|
|
window.add()
|
|
} else if (obj.event === 'refresh') {
|
|
window.refresh()
|
|
}
|
|
})
|
|
|
|
form.on('submit(cookie-user-query)', function (data) {
|
|
window.refresh(data.field)
|
|
return false
|
|
})
|
|
|
|
form.on('switch(cookie-user-enable)', function (obj) {
|
|
let operate = obj.elem.checked ? 'enable' : 'disable'
|
|
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({
|
|
type: 2,
|
|
title: '编辑登录用户',
|
|
shade: 0.1,
|
|
area: ['700px', '680px'],
|
|
content: MODULE_PATH + 'edit?cookieUserId=' + 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-user-table', {where: param})
|
|
}
|
|
})
|
|
</script>
|
|
</html>
|