apeblog/app/admin/view/system_config_tab/index.html

243 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh">
<head>
<title>开发者配置 - {:system_config('title')}后台管理系统</title>
{include file="public/header" /}
</head>
<body>
<div class="container-fluid p-t-15">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header"><h4>搜索</h4></div>
<div class="card-body">
<form class="form-inline searchForm" onsubmit="return false;">
<div class="form-group">
<label for="name">配置项名称</label>
<div class="input-group">
<div class="input-group">
<input type="text" class="form-control" id="name" value="" name="name"
placeholder="请输入名称或者ID">
</div>
</div>
</div>
<div class="form-group">
<label for="status">是否启用</label>
<select name="status" id="status" class="form-control">
<option value="">所有</option>
<option value="1">启用</option>
<option value="0">禁用</option>
</select>
</div>
<button type="submit" class="btn btn-success" style="margin: -10px 0 0 10px;" id="search">搜索
</button>
</form>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="card">
<div class="card-header"><h4>开发者配置</h4></div>
<div class="card-body">
<div id="toolbar" class="toolbar-btn-action">
<button id="btn_add" type="button" class="btn btn-primary m-r-5"
onclick="iframe.createIframe('添加配置','/admin/system_config_tab/add')">
<span class="mdi mdi-plus" aria-hidden="true"></span>新增
</button>
<button id="btn_edit" type="button" class="btn btn-success m-r-5" onclick="isEnable('enable')">
<span class="mdi mdi-check" aria-hidden="true"></span>启用
</button>
<button id="btn_disable" type="button" class="btn btn-warning m-r-5"
onclick="isEnable('disable')">
<span class="mdi mdi-block-helper" aria-hidden="true"></span>禁用
</button>
<button id="btn_delete" type="button" class="btn btn-danger" onclick="del()">
<span class="mdi mdi-window-close" aria-hidden="true"></span>删除
</button>
</div>
<table id="tb_departments"></table>
</div>
</div>
</div>
</div>
</div>
{include file="public/footer"/}
<script type="text/javascript">
$('#tb_departments').bootstrapTable({
classes: 'table table-bordered table-hover table-striped',
url: '/admin/system_config_tab/lst',
method: 'post',
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
uniqueId: 'id',
idField: 'id', // 每行的唯一标识字段
toolbar: '#toolbar', // 工具按钮容器
showColumns: true, // 是否显示所有的列
showRefresh: true, // 是否显示刷新按钮
responseHandler: function (res) {
return {
"total": res.count,
"rows": res.data,
};
},
pagination: true, // 是否显示分页
queryParams: function (params) {
var temp = toArrayList($(".searchForm").serializeArray());
temp['limit'] = params.limit;
temp['page'] = (params.offset / params.limit) + 1;
return temp;
}, // 传递参数
sidePagination: "server", // 分页方式client客户端分页server服务端分页
pageNumber: 1, // 初始化加载第一页,默认第一页
pageSize: 20, // 每页的记录行数
pageList: [20, 50, 100], // 可供选择的每页的行数
columns: [{
checkbox: true // 是否显示复选框
}, {
field: 'id',
title: '配置ID',
sortable: true // 是否排序
}, {
field: 'name',
title: '配置名称'
}, {
field: 'rank',
title: '排序'
}, {
field: 'status',
title: '状态',
formatter: function (value, row, index) {
switch (value) {
case 0:
return '禁用';
case 1:
return '启用';
}
},
}, {
field: 'operate',
title: '操作',
formatter: btnGroup, // 自定义方法
events: {
'click .btn-edit': function (event, value, row, index) {
iframe.createIframe('修改配置', '/admin/system_config_tab/edit?id=' + row.id)
},
'click .add-btn': function (event, value, row, index) {
window.location.href = "/admin/system_config/index?tab_id=" + row.id;
},
'click .btn-del': function (event, value, row, index) {
$.alert({
title: '系统提示',
content: '删除提醒',
buttons: {
confirm: {
text: '确认',
btnClass: 'btn-primary',
action: function () {
$.post(url = "/admin/system_config_tab/del", data = {"id": row.id}, function (res) {
if (res.status == 200) {
parent.lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
$("#tb_departments").bootstrapTable('refresh');
} else parent.lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
});
}
},
cancel: {
text: '取消'
}
}
});
}
}
}],
});
$("#search").click(function () {
$("#tb_departments").bootstrapTable('refresh', {query: {page: 1}, pageNumber: 1});
});
// 操作按钮
function btnGroup() {
let html =
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-edit" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>' +
'<a href="#!" class="btn btn-xs btn-default m-r-5 btn-del" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>' +
'<a href="#!" class="btn btn-xs btn-default add-btn" title="添加" data-toggle="tooltip"><i class="mdi mdi-plus"></i></a>';
return html;
}
// 删除
function del() {
var checkID = "";
var selectedItem = $('#tb_departments').bootstrapTable('getAllSelections');
if (selectedItem == "") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
for (var i = 0; i < selectedItem.length; i++) {
checkID += selectedItem[i]['id'] + ",";
}
if (checkID == "") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
$.confirm({
title: '重要提醒!',
content: '选中项将全部被删除,请谨慎操作!',
backgroundDismiss: true,
buttons: {
ok: {
text: '确认',
btnClass: 'btn-danger',
action: function () {
$.post("/admin/system_config_tab/del", data = {id: checkID}, function (res) {
if (res.status == 200) {
lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
location.reload();
} else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
})
}
},
cancel: {
text: '取消',
btnClass: 'btn-primary'
}
}
});
}
// 批量启用或者禁用
function isEnable(type) {
var checkID = "";
var selectedItem = $('#tb_departments').bootstrapTable('getAllSelections');
if (selectedItem == "") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
for (var i = 0; i < selectedItem.length; i++) {
checkID += selectedItem[i]['id'] + ",";
}
if (checkID == "") return lightyear.notify("没有选中项", 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
$.confirm({
title: '重要提醒!',
content: type == 'enable' ? '选中项将全部启用,请谨慎操作!' : '选中项将全部禁用,请谨慎操作!',
backgroundDismiss: true,
buttons: {
ok: {
text: '确认',
btnClass: 'btn-danger',
action: function () {
if (type == 'enable') {
$.post("/admin/system_config_tab/enabled", data = {id: checkID}, function (res) {
if (res.status == 200) lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
location.reload();
})
} else {
$.post("/admin/system_config_tab/disabled", data = {id: checkID}, function (res) {
if (res.status == 200) lightyear.notify(res.msg, 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
else lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-neutral', 'top', 'center');
location.reload();
})
}
}
},
cancel: {
text: '取消',
btnClass: 'btn-primary'
}
}
});
}
</script>
</body>
</html>