Files
peko-admin-web/src/views/game/GameAccessUrlView.vue
2024-04-22 10:45:13 +08:00

331 lines
16 KiB
Vue
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.

<template>
<section class="content">
<div class="box box-primary">
<section class="content-header">
<h1 id="itemTitle">游戏白名单</h1>
</section>
<section class="content">
<div id="table"></div>
<div id="toolbar">
<button id="addBtn" class="btn btn-default">
<i class="glyphicon glyphicon-plus"></i>增加
</button>&nbsp;&nbsp;&nbsp;
<!--厂商id: <input type="text" id='channelId' placeholder=''>-->
访问路径: <input type="text" id='accessUrl' placeholder=''>
<button id="btnSearch" class="btn btn-sm btn-primary" data-id=" + accessUrl + ">查询</button>
</div>
</section>
</div>
</section>
<div class="modal fade" id="actModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">x</span></button>
<h4 class="modal-title" id="addModalLabel">新增白名单</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" id="actForm">
<input type="hidden" name="id" id="actId" value="0">
<input type="hidden" name="status" id="actStatus">
<div class="form-group">
<div class="form-group">
<label for="accessUrl" class="col-sm-3 control-label">访问路径:</label>
<div class="col-sm-9">
<input type="text" class="form-control validate[required]" name="accessUrl"
id="accessUrlName" style="width:400px">
</div>
</div>
<div class="form-group">
<label for="whiteList" class="col-sm-3 control-label">白名单列表:</label>
<div class="col-sm-9">
<input type="text" class="form-control validate[required]" name="whiteList"
id="whiteList" style="width:400px">
</div>
</div>
<div class="form-group">
<label for="blackList" class="col-sm-3 control-label">黑名单列表:</label>
<div class="col-sm-9">
<input type="text" class="form-control validate[required]" name="blackList"
id="blackList" style="width:400px">
</div>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" id="save">保存</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">x</span></button>
<h4 class="modal-title" id="editModalLabel">白名单编辑</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" id="editForm">
<input type="hidden" name="id" id="e_id">
<input type="hidden" name="status" id="editStatus">
<!--<div class="form-group">
<label for="channelId" class="col-sm-3 control-label">厂商渠道ID:</label>
<div class="col-sm-9">
<input type="hidden" class="form-control validate[required]" name="channelId" id="e_channelId"
style="width:400px">
</div>
</div>-->
<div class="form-group">
<label for="accessUrl" class="col-sm-3 control-label">访问路径:</label>
<div class="col-sm-9">
<input type="text" class="form-control validate[required]" name="accessUrl" id="e_accessUrl"
style="width:400px">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" id="edit">保存</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="sureModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" id="sure">确定</button>
</div>
</div>
</div>
</div>
</template>
<script>
import TableHelper from '@/utils/bootstrap-table-helper';
export default {
name: "GameAccessUrlView",
setup() {
return {};
},
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
$(function () {
$('#table').bootstrapTable('destroy');
initTable();
// 查询刷新
$('#btnSearch').on('click', function () {
$('#table').bootstrapTable('destroy');
initTable();
});
$('#addBtn').on('click', function () {
cleanModal();
$("#actForm")[0].reset();
$('#actModal').modal('show');
});
$('#table').on('click', '.opt-edit', function () {
var id = $(this).attr("data-id-1");
var accessUrl = $(this).attr("data-id-2");
cleanModal();
$('#e_id').val(id);
$('#e_accessUrl').val(accessUrl);
$('#editModal').modal('show');
});
$('#save').on('click', function () {
if ($('#actForm').validationEngine('validate')) {
$.ajax({
type: "post",
url: "/admin/gameAccessUrl/add",
data: $('#actForm').serialize(),
dataType: 'json',
success: function (json) {
if (json.success == 'true') {
$("#actModal").modal('hide');
$("#tipMsg").text(json.msg);
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("保存失败,错误码:" + json.message);
$("#tipModal").modal('show');
}
}
})
}
});
$('#edit').on('click', function () {
if ($('#editForm').validationEngine('validate')) {
$.ajax({
type: "post",
url: "/admin/gameAccessUrl/update",
data: $('#editForm').serialize(),
dataType: 'json',
success: function (json) {
if (json.success == 'true') {
$("#editModal").modal('hide');
$("#tipMsg").text(json.msg);
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("修改失败,错误码:" + json.message);
$("#tipModal").modal('show');
}
}
})
}
});
$("#table").on("click", '.opt-del', function () {
var id = $(this).attr("data-id");
if (id == 'undefined') {
$("#tipMsg").text("id参数有误");
$("#tipModal").modal('show');
return;
}
if (confirm("你确认删除吗?")) {
$.ajax({
type: 'post',
url: '/admin/gameAccessUrl/delete',
data: { 'id': id },
dataType: 'json',
success: function (json) {
if (json.success == 'true') {
$("#tipMsg").text("删除成功");
$("#tipModal").modal('show');
TableHelper.doRefresh("#table");
} else {
$("#tipMsg").text("删除失败,错误码:" + json.message);
$("#tipModal").modal('show');
}
}
});
}
});
function cleanModal() {
$('#actForm').find('input[type=text],input[type=hidden],input[type=file]').each(function () {
$(this).val('');
})
$('#actForm').find('img').attr('src', '');
}
function initTable() {
$('#table').bootstrapTable({
columns: [
{ field: 'id', title: 'id', align: 'center', valign: 'middle', width: '10%' },
{ field: 'accessUrl', title: '访问路径', align: 'center', valign: 'middle', width: '10%' },
{ field: 'whiteList', title: '白名单列表', align: 'center', valign: 'middle', width: '10%' },
{ field: 'blackList', title: '黑民单列表', align: 'center', valign: 'middle', width: '10%' },
{
field: 'updateTime',
title: '创建时间',
align: 'center',
width: '10%',
valign: 'middle',
formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:ss");
} else {
return '-';
}
}
},
{
field: 'createTime',
title: '创建时间',
align: 'center',
width: '10%',
valign: 'middle',
formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:ss");
} else {
return '-';
}
}
},
{
field: 'tmp',
title: '操作',
align: 'center',
width: '10%',
valign: 'middle',
formatter: function (val, row, index) {
var id = row.id;
var accessUrl = row.accessUrl;
return '<button class="btn btn-sm btn-success opt-edit" data-id-1 ="' + id + ' "data-id-2="' + accessUrl + '">' + '编辑</button>' + "&nbsp;&nbsp;&nbsp;" +
"<button class='btn btn-sm btn-danger opt-del' data-id=" + id + ">删除</button>";
}
}
],
cache: false,
striped: true,
showRefresh: false,
pageSize: 20,
pagination: true,
pageList: [10, 20, 30, 50],
sidePagination: "server", //表示服务端请求
//设置为undefined可以获取pageNumberpageSizesearchTextsortNamesortOrder
//设置为limit可以获取limit, offset, search, sort, order
queryParamsType: "undefined",
queryParams: function queryParams(params) { //设置查询参数
var param = {
pageSize: params.pageSize,
pageNumber: params.pageNumber,
accessUrl: $("#accessUrl").val()
};
// console.log(param);
return param;
},
uniqueId: 'accessUrl',
toolbar: '#toolbar',
url: '/admin/gameAccessUrl/list',
onLoadSuccess: function () { //加载成功时执行
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
})
}
})
}
},
};
</script>
<style scoped>
#imgMask {
position: absolute;
top: 0;
left: 0;
width: 250px;
height: 600px;
padding: 4px;
background: #fff;
z-index: 999;
display: none;
}
#imgMask img {
width: 100%;
height: 100%;
vertical-align: top;
}
</style>