mirror of https://github.com/1099438829/apeblog
285 lines
12 KiB
HTML
285 lines
12 KiB
HTML
<!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="code">邀请码</label>
|
||
<div class="input-group">
|
||
<div class="input-group">
|
||
<input type="text" class="form-control" id="code" name="code" placeholder="请输入操作人名称,ID">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="start_time">操作时间</label>
|
||
<div class="input-group">
|
||
<input class="form-control js-datetimepicker" type="text" id="start_time" name="start_time" autocomplete="off" data-side-by-side="true" data-locale="zh-cn" data-format="YYYY-MM-DD" placeholder="开始时间">
|
||
<span class="input-group-addon">~</span>
|
||
<input class="form-control js-datetimepicker" type="text" id="end_time" name="end_time" autocomplete="off" data-side-by-side="true" data-locale="zh-cn" data-format="YYYY-MM-DD" placeholder="结束时间">
|
||
</div>
|
||
</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-toolbar clearfix">
|
||
<div class="toolbar-btn-action">
|
||
<button id="btn_add" type="button" class="btn btn-primary m-r-5">
|
||
<span class="mdi mdi-plus" aria-hidden="true"></span>新增
|
||
</button>
|
||
<button id="btn_add_multiple" type="button" class="btn btn-primary m-r-5">
|
||
<span class="mdi mdi-plus" aria-hidden="true"></span>批量新增
|
||
</button>
|
||
<a class="btn btn-warning" href="#!" onclick="delSelect()"><i class="mdi mdi-window-close"></i> 删除</a>
|
||
</div>
|
||
</div>
|
||
<div class="card-body">
|
||
<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/invitation/Lst',
|
||
method: 'post',
|
||
dataType : 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
|
||
uniqueId: 'id',
|
||
idField: 'id', // 每行的唯一标识字段
|
||
toolbar: '#toolbar', // 工具按钮容器
|
||
showColumns: false, // 是否显示所有的列
|
||
showRefresh: false, // 是否显示刷新按钮
|
||
responseHandler: function (res) {
|
||
return {
|
||
"total": res.count,
|
||
"rows": res.data,
|
||
};
|
||
},
|
||
pagination: true,
|
||
queryParams: function(params) {
|
||
let temp = toArrayList($(".searchForm").serializeArray());
|
||
temp['limit'] = params.limit;
|
||
temp['page'] = (params.offset / params.limit) + 1;
|
||
return temp;
|
||
},
|
||
sidePagination: "server",
|
||
pageNumber: 1,
|
||
pageSize: 10,
|
||
pageList: [10, 20, 50, 100],
|
||
columns: [{
|
||
checkbox: true, // 是否显示复选框
|
||
},{
|
||
field: 'id',
|
||
title: '序号'
|
||
},{
|
||
field: 'code',
|
||
title: '邀请码'
|
||
},{
|
||
field: 'status',
|
||
title: '状态',
|
||
formatter:function (value,row,index) {
|
||
if (value){
|
||
return '已使用';
|
||
}else{
|
||
return "未使用";
|
||
}
|
||
}
|
||
},{
|
||
field: 'user',
|
||
title: '使用人',
|
||
},{
|
||
field: 'operate',
|
||
title: '操作',
|
||
formatter:function (value,row,index) {
|
||
let html ='<a class="btn btn-xs btn-default btn-del" href="#!" title="删除" data-toggle="tooltip" onclick="delOne('+row.id+')"><i class="mdi mdi-window-close"></i></a>';
|
||
return html;
|
||
}
|
||
}],
|
||
onLoadSuccess: function(data){
|
||
$("[data-toggle='tooltip']").tooltip();
|
||
}
|
||
});
|
||
|
||
//搜索
|
||
$("#search").click(function () {
|
||
let start_time = $('#start_time').val();
|
||
let end_time = $('#end_time').val();
|
||
if(start_time && end_time && start_time > end_time ){
|
||
alert('开始时间不能大于结束时间');
|
||
return false;
|
||
}
|
||
$("#tb_departments").bootstrapTable('refresh',{query:{page:1},pageNumber:1});
|
||
});
|
||
|
||
|
||
//新增邀请码
|
||
$('body').on('click','#btn_add',function(){
|
||
$.confirm({
|
||
title: '新增邀请码',
|
||
content: '' +
|
||
'<form action="" class="formName">' +
|
||
'<div class="form-group">' +
|
||
'<input type="text" placeholder="请输入邀请码" name="code" class="name form-control" required />' +
|
||
'</div>' +
|
||
'</form>',
|
||
buttons: {
|
||
formSubmit: {
|
||
text: '提交',
|
||
btnClass: 'btn-primary',
|
||
action: function () {
|
||
var name = this.$content.find('.name').val();
|
||
if(!name){
|
||
$.alert('请输入邀请码');
|
||
return false;
|
||
}
|
||
$.post(url="/admin/invitation/save",this.$content.find('form').serialize(),function (res) {
|
||
if (res.code == 200 || res.status == 200) {
|
||
parent.lightyear.notify('操作成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||
$("#tb_departments").bootstrapTable('refresh',{query:{page:1},pageNumber:1});
|
||
} else{
|
||
parent.lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||
}
|
||
});
|
||
}
|
||
},
|
||
cancel: {
|
||
text: '取消'
|
||
},
|
||
},
|
||
onContentReady: function () {
|
||
var jc = this;
|
||
this.$content.find('form').on('submit', function (e) {
|
||
e.preventDefault();
|
||
jc.$$formSubmit.trigger('click');
|
||
});
|
||
}
|
||
});
|
||
});
|
||
|
||
//批量新增邀请码
|
||
$('body').on('click','#btn_add_multiple',function(){
|
||
$.confirm({
|
||
title: '新增邀请码',
|
||
content: '' +
|
||
'<form action="" class="searchForm">' +
|
||
' <div class="form-group">\n' +
|
||
' <label>邀请码前缀</label>\n' +
|
||
' <input class="form-control" type="text"name="name" placeholder="请输入邀请码前缀">\n' +
|
||
' </div>\n' +
|
||
' <div class="form-group">\n' +
|
||
' <label>生成个数</label>\n' +
|
||
' <input type="text" class="form-control" name="number" placeholder="请输入要生成的个数" />\n' +
|
||
' </div>\n' +
|
||
'</form>',
|
||
buttons: {
|
||
formSubmit: {
|
||
text: '提交',
|
||
btnClass: 'btn-primary',
|
||
action: function () {
|
||
let field = this.$content.find('form').serializeArray();
|
||
for(j = 0;j < field.length; j++) {
|
||
if(!field[j].value){
|
||
$.alert('请检查填写!');
|
||
return false;
|
||
}
|
||
}
|
||
$.post(url="/admin/invitation/addMultiple",this.$content.find('form').serialize(),function (res) {
|
||
if (res.code == 200 || res.status == 200) {
|
||
parent.lightyear.notify('操作成功', 'success', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||
$("#tb_departments").bootstrapTable('refresh',{query:{page:1},pageNumber:1});
|
||
} else{
|
||
parent.lightyear.notify(res.msg, 'danger', 3000, 'mdi mdi-emoticon-happy', 'top', 'center');
|
||
}
|
||
});
|
||
}
|
||
},
|
||
cancel: {
|
||
text: '取消'
|
||
},
|
||
},
|
||
onContentReady: function () {
|
||
var jc = this;
|
||
this.$content.find('form').on('submit', function (e) {
|
||
e.preventDefault();
|
||
jc.$$formSubmit.trigger('click');
|
||
});
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
function delOne(id) {
|
||
$.confirm({
|
||
title: '重要提醒!',
|
||
content: '删除后将不可恢复,请谨慎操作!',
|
||
backgroundDismiss: true,
|
||
buttons: {
|
||
ok: {
|
||
text: '确认',
|
||
btnClass: 'btn-danger',
|
||
action: function () {
|
||
$.post("/admin/invitation/del",data={id:id},function (res) {
|
||
if (res.status == 200 || res.code == 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'
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
function delSelect() {
|
||
var checkID = "";
|
||
var selectedItem = $('#tb_departments').bootstrapTable('getSelections');
|
||
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/invitation/del",data={id:checkID},function (res) {
|
||
if (res.status == 200 || res.code == 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'
|
||
}
|
||
}
|
||
});
|
||
}
|
||
</script>
|
||
</body>
|
||
</html> |