1337 lines
70 KiB
Vue
1337 lines
70 KiB
Vue
<template>
|
||
<section class="content">
|
||
<div class="box box-primary">
|
||
<div class="box-body">
|
||
<!-- Content Header (Page header) -->
|
||
<section class="content-header">
|
||
<h1 id="itemTitle"></h1>
|
||
</section>
|
||
<div id="toolbar">
|
||
<div class="col-sm-12">
|
||
<button id="btnAddRecord" class="btn btn-default">
|
||
<i class="glyphicon glyphicon-plus"></i>新建快速赛类型
|
||
</button>
|
||
游戏平台:<select id="queryStatus" name="queryStatus" class="input-sm">
|
||
<option value="" selected="selected">不限制</option>
|
||
<option value="1">QQ</option>
|
||
<option value="2">微信</option>
|
||
</select>
|
||
<button id="btnSearch" class="btn btn-sm btn-primary">查询</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- .content -->
|
||
<div id="table"></div>
|
||
|
||
</div>
|
||
</section>
|
||
|
||
<!-- 编辑弹框 -->
|
||
<div class="modal fade" id="editMatchModal" 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">×</span>
|
||
</button>
|
||
<h4 class="modal-title" id="modalLabel">新建/编辑</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" id="addForm">
|
||
<input type="hidden" name="groupId" id="groupId" />
|
||
<div class="form-group">
|
||
<label for="matchType" class="col-sm-3 control-label">游戏分类:</label>
|
||
<div class="col-sm-9">
|
||
<select id="matchType" name="matchType" class="input-sm">
|
||
<option value="1" selected="selected">和平精英</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="title" class="col-sm-3 control-label">比赛名称<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="title" id="title"
|
||
placeholder="请填写">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="platformType" class="col-sm-3 control-label">比赛平台:<font color="red">*</font>
|
||
:</label>
|
||
<div class="col-sm-9">
|
||
<select name="platformType" id="platformType" class="form-control validate[required]">
|
||
<option value="1">QQ</option>
|
||
<option value="2">微信</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="groupType" class="col-sm-3 control-label">参赛规模:<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<select name="groupType" id="groupType" class="form-control validate[required]">
|
||
<option value="1">单排</option>
|
||
<option value="2">双排</option>
|
||
<option value="3">四排</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="ticketId" class="col-sm-3 control-label">报名要求:</label>
|
||
<div class="col-sm-9">
|
||
<select id="ticketId" name="ticketId" class="input-sm">
|
||
<option value="" selected="selected">请选择</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="quotaLimit" class="col-sm-3 control-label">报名名额<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="quotaLimit" id="quotaLimit"
|
||
placeholder="不可大于100">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="minQuota" class="col-sm-3 control-label">最小开赛人数<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="minQuota" id="minQuota"
|
||
placeholder="不可<8或大于报名名额">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="dismissMinute" class="col-sm-3 control-label">单场流局时间<font color="red">*</font>
|
||
:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="dismissMinute"
|
||
id="dismissMinute" placeholder="多久未达到开赛要求就流局,单位分钟">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="subGameNum" class="col-sm-3 control-label">可报名总场次数:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control" name="subGameNum" id="subGameNum"
|
||
placeholder="本类型可报名总场次数,不填为不限制">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="seqNo" class="col-sm-3 control-label">排序:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control" name="seqNo" id="seqNo" placeholder="排序,值越小越靠前">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">奖励模式<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<label class="radio-inline"><input class="awardType" type="radio" name="awardType" value="1"
|
||
checked>排名</label>
|
||
<label class="radio-inline"><input class="awardType" type="radio" name="awardType"
|
||
value="2">淘汰数</label>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="award" class="col-sm-3 control-label">奖励<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<textarea type="text" class="form-control validate[required]" name="award" id="award"
|
||
placeholder="排名奖励模式: 请从第一名的奖励到第N名奖励输入(元),用','隔开;淘汰数奖励模式:填写每淘汰一名玩家可获得奖励(元)"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="matchRule" class="col-sm-3 control-label">比赛规则<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<textarea type="text" class="form-control validate[required]" name="matchRule"
|
||
id="matchRule" placeholder=""></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="chatRoomUid" class="col-sm-3 control-label">聊天室房间号:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control" name="chatRoomUid" id="chatRoomUid"
|
||
placeholder="房间平台号">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">比赛图标<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<img src="" id="picImage" style="width:250px;height:90px;" alt="">
|
||
<input type="file" id="picUploadFile" name="file">
|
||
<button class="btn btn-success" type="button" id="picUploadBtn">上传</button>
|
||
<input type="hidden" id="matchUrl" name="matchUrl"
|
||
class="form-control validate[required]" />
|
||
<span id="picImgInfo" style="color:red;"></span>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-primary" id="btnConfirmEdit">保存</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 集合内赛事列表弹窗 -->
|
||
<div class="modal fade" id="matchListModel" 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">×</span>
|
||
</button>
|
||
<h4 class="modal-title" id="matchListModelTitle"></h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div id="matchListModelTable"></div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- 报名用户列表弹窗 -->
|
||
<div class="modal fade" id="joinedUserListModal" 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">×</span>
|
||
</button>
|
||
<h4 class="modal-title" id="joinedUserListModalTitle"></h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div id="joinedUsersTable"></div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-primary" id="exportJoinUserList">导出</button>
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 奖励发放列表弹窗 -->
|
||
<div class="modal fade" id="awardListModal" 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">×</span>
|
||
</button>
|
||
<h4 class="modal-title" id="awardListModalTitle"></h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div id="awardListTable"></div>
|
||
</div>
|
||
<div class="modal-footer js-award-list-footer">
|
||
<button type="button" class="btn btn-primary" id="saveAwardListBtn">保存</button>
|
||
<button type="button" class="btn btn-default" id="sendAwardBtn">确认发放</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 上传进场链接弹框 -->
|
||
<div class="modal fade" id="submitEnterLinkModal" 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">×</span>
|
||
</button>
|
||
<h4 class="modal-title" id="submitEnterLinkModalLable">上传进场链接</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" id="submitEnterLinkForm">
|
||
<input type="hidden" name="submitEnterLinkMatchId" id="submitEnterLinkMatchId" />
|
||
<div class="form-group">
|
||
<label for="roomUrl" class="col-sm-3 control-label">进场链接<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="roomUrl" id="roomUrl"
|
||
placeholder="">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-primary" id="btnConfirmSubmitEnterLink">保存</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!--手动关闭比赛弹窗-->
|
||
<div class="modal fade" id="closeMatchManualModal" 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">×</span>
|
||
</button>
|
||
<h4 class="modal-title" id="closeMatchManualLable">操作关闭</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" id="closeMatchManualForm">
|
||
<input type="hidden" name="matchId" id="closeMatchManualMatchId" />
|
||
<div class="form-group">
|
||
<label for="closeReason" class="col-sm-3 control-label">关闭原因<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="closeReason"
|
||
id="closeReason" placeholder="">
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label">是否退门票:</label>
|
||
<div class="col-sm-9">
|
||
<label class="radio-inline"><input type="radio" name="giveBackTicket" value="false"
|
||
checked>否</label>
|
||
<label class="radio-inline"><input type="radio" name="giveBackTicket" value="true">是</label>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-primary" id="btnConfirmcloseMatchManual">保存</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!--添加机器人弹窗-->
|
||
<div class="modal fade" id="addRobotModal" 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">×</span>
|
||
</button>
|
||
<h4 class="modal-title" id="addRobotLable">添加机器人</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" id="addRobotForm">
|
||
<input type="hidden" name="matchId" id="addRobotMatchId" />
|
||
<div class="form-group">
|
||
<label for="closeReason" class="col-sm-3 control-label">添加数量<font color="red">*</font>:</label>
|
||
<div class="col-sm-9">
|
||
<input type="text" class="form-control validate[required]" name="robotNum" id="robotNum"
|
||
placeholder="">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-primary" id="btnConfirmAddRobot">保存</button>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
import TableHelper from '@/utils/bootstrap-table-helper';
|
||
|
||
const groupIdObj = {};
|
||
const ticketIdObj = {};
|
||
const integer_max = 2147483647;
|
||
let searchType;
|
||
export default {
|
||
name: "GameManageQuickGameInfoAdminView",
|
||
setup() {
|
||
return {};
|
||
},
|
||
created() {
|
||
this.$nextTick(function () {
|
||
this.initData();
|
||
});
|
||
},
|
||
methods: {
|
||
initData() {
|
||
$(function () {
|
||
|
||
const main = {
|
||
init: function () {
|
||
this.getTicketDataFormBack();
|
||
},
|
||
// 获取游戏门票列表
|
||
getTicketDataFormBack: function () {
|
||
$.get('/admin/gameManage/listTicketByPage', { page: 1, pageSize: integer_max }, function (res) {
|
||
if (res) {
|
||
let str = '<option value="" selected= "selected" >请选择</option>';
|
||
for (let i = 0; i < res.rows.length; i++) {
|
||
// id对象存储
|
||
const id = '' + res.rows[i].ticketId;
|
||
ticketIdObj[id] = res.rows[i];
|
||
str += '<option value="' + res.rows[i].ticketId + '">' + res.rows[i].ticketName + '</option>';
|
||
}
|
||
$('#ticketId').html(str);
|
||
console.log('ticketIdObj', ticketIdObj);
|
||
}
|
||
});
|
||
},
|
||
};
|
||
main.init();
|
||
|
||
const QQ_PLATFORM = 1;
|
||
const WECHAT_PLATFORM = 2;
|
||
|
||
const GROUP_TYPE_SINGLE = 1;
|
||
const GROUP_TYPE_CP = 2;
|
||
const GROUP_TYPE_4P = 3;
|
||
|
||
const GAME_TYPE_HPJY = 1;
|
||
const QUICK_GAME_TYPE = 2;
|
||
|
||
const MATCH_STATUS = {
|
||
VALID: 1, // 报名中
|
||
QUOTA_END: 2, // 截止报名
|
||
NOT_EMPTY_QUOTA: 3, // 报满但不处于进场时间段
|
||
ENTER_STAGE: 4, //进场中
|
||
GAME_START: 5, // 比赛中
|
||
NOT_START_ENROLL: 6, // 未开始报名
|
||
GAME_END: 7, // 结束统计中
|
||
FINISHED: 9, // 完结
|
||
CLOSE_AUTO: 10, // 已关闭(未报满)
|
||
CLOSE_MANUAL: 11, // 手动关闭
|
||
ENTER_STAGE_NOT_EMPTY_QUOTA: 12, // 报满且处于进场时间段
|
||
PRE_ENTER_STAGE: 13,//进场准备阶段
|
||
AUTO_DISMISS_STAGE: 14,//自动流局阶段
|
||
MANUAL_DISMISS_STAGE: 15,//手动流局阶段
|
||
}
|
||
|
||
const GAME_NOT_START_STATUS = [MATCH_STATUS.VALID, MATCH_STATUS.QUOTA_END,
|
||
MATCH_STATUS.NOT_EMPTY_QUOTA, MATCH_STATUS.ENTER_STAGE, MATCH_STATUS.NOT_START_ENROLL,
|
||
MATCH_STATUS.PRE_ENTER_STAGE, MATCH_STATUS.ENTER_STAGE_NOT_EMPTY_QUOTA];
|
||
|
||
let groupList = [];
|
||
let matchList = [];
|
||
$('.datetime').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
});
|
||
$('#table').bootstrapTable('destroy');
|
||
$('#table').bootstrapTable({
|
||
columns: [
|
||
{ field: 'groupId', title: '快速赛集合ID', align: 'center', width: '5%' },
|
||
{ field: 'title', title: '名称', align: 'center', width: '8%' },
|
||
{ field: 'status', title: '状态', visible: false, align: 'center', width: '8%' },
|
||
{
|
||
field: 'matchType', title: '游戏类型', align: 'center', width: '5%',
|
||
formatter: function (val) {
|
||
if (val == GAME_TYPE_HPJY) {
|
||
return '和平精英'
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'platformType', title: '平台', align: 'center', width: '5%', formatter: function (val) {
|
||
if (val == QQ_PLATFORM) {
|
||
return 'QQ'
|
||
} else if (val == WECHAT_PLATFORM) {
|
||
return '微信';
|
||
} else {
|
||
return '';
|
||
}
|
||
}
|
||
},
|
||
{ field: 'minQuota', title: '开赛报名名额', align: 'center', width: '5%' },
|
||
{
|
||
field: 'tmp', title: '场次消耗情况', align: 'center', width: '5%',
|
||
formatter: function (val, row) {
|
||
console.log('row.remainGameNum', row.remainGameNum)
|
||
let remainCount = row.remainGameNum == null ? '不限' : row.remainGameNum
|
||
console.log('remainCount', remainCount)
|
||
return `正常开启:${row.validGameNum}<br>
|
||
流局:${row.dismissGameNum}<br>
|
||
剩余: ${remainCount}`
|
||
}
|
||
},
|
||
{
|
||
field: 'groupStatus', title: '当前状态', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row) {
|
||
if (row.status == 2) {
|
||
return '入口已关闭';
|
||
} else if (row.remainGameNum == 0) {
|
||
return '场次消耗完'
|
||
} else if (!row.subGameRoomUrl) {
|
||
return '报名中<br>需上传进场链接';
|
||
} else if (val == MATCH_STATUS.VALID) {
|
||
return '报名中<br>未到达开赛要求';
|
||
} else {
|
||
return '报名中<br>进场中';
|
||
}
|
||
}
|
||
},
|
||
{ field: 'seqNo', title: '排序', align: 'center', width: '20%' },
|
||
{
|
||
field: 'tmp',
|
||
title: '操作',
|
||
align: 'center',
|
||
width: '10%',
|
||
formatter: function (val, row, index) {
|
||
const actions = [];
|
||
let groupId = row.groupId;
|
||
actions.push('<button class="btn btn-sm btn-success opt-list-game" data-idx=' + index + '>' +
|
||
'<i class="glyphicon glyphicon-edit"></i>查看详情</button>');
|
||
actions.push('<button class="btn btn-sm btn-success opt-edit" data-idx=' + index + '>' +
|
||
'<i class="glyphicon glyphicon-edit"></i>编辑</button>');
|
||
if (row.status == 1) {
|
||
actions.push('<button class="btn btn-sm btn-danger opt-change-status" data-id=' + groupId + ' data-status="2">' +
|
||
'<i class="glyphicon glyphicon-edit"></i>关闭入口</button>')
|
||
actions.push('<button class="btn btn-sm btn-danger opt-change-status" data-id=' + groupId + ' data-status="0">' +
|
||
'<i class="glyphicon glyphicon-edit"></i>删除入口</button>')
|
||
} else if (row.status == 2) {
|
||
actions.push('<button class="btn btn-sm btn-warning opt-change-status" data-id=' + groupId + ' data-status="1">' +
|
||
'<i class="glyphicon glyphicon-edit"></i>开启入口</button>')
|
||
}
|
||
return actions.join(" ");
|
||
}
|
||
}
|
||
],
|
||
undefinedText: "0",
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: true,
|
||
pageSize: 20,
|
||
pagination: true,
|
||
pageList: [20, 50, 100, 200, 300, 500],
|
||
search: false,
|
||
sidePagination: "server", //表示服务端请求
|
||
queryParamsType: "undefined",
|
||
queryParams: function queryParams(params) { //设置查询参数
|
||
var param = {
|
||
page: params.pageNumber,
|
||
pageSize: params.pageSize,
|
||
platformType: $("#queryStatus").val()
|
||
};
|
||
return param;
|
||
},
|
||
url: '/admin/gamemanage/quickgame/listQuickGameGroupByPage',
|
||
toolbar: '#toolbar',
|
||
onLoadSuccess: function (data) { //加载成功时执行
|
||
console.log("load success");
|
||
groupList = data.rows;
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.log("load fail");
|
||
}
|
||
});
|
||
|
||
|
||
// 查询刷新
|
||
$('#btnSearch').on('click', function () {
|
||
TableHelper.doRefresh('#table');
|
||
});
|
||
|
||
// 添加打开弹窗
|
||
$("#btnAddRecord").on('click', function () {
|
||
//清除数据
|
||
clearModal()
|
||
$('#editMatchModal').modal('show');
|
||
});
|
||
|
||
|
||
// 编辑
|
||
$("#btnConfirmEdit").click(function () {
|
||
if ($("#addForm").validationEngine('validate')) {
|
||
console.log('$("#addForm").serialize()', $("#addForm").serialize())
|
||
$.ajax({
|
||
type: "post",
|
||
url: '/admin/gamemanage/quickgame/saveOrUpdateGroup',
|
||
data: $("#addForm").serialize(),
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("保存成功");
|
||
$("#tipModal").modal('show');
|
||
$("#editMatchModal").modal('hide');
|
||
TableHelper.doRefresh('#table');
|
||
} else {
|
||
$("#tipMsg").text("保存失败." + json.data.msg);
|
||
$("#tipModal").modal('show');
|
||
$("#editMatchModal").modal('hide');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
// 更改入口状态
|
||
$('#table').on("click", '.opt-change-status', function () {
|
||
var groupId = $(this).attr("data-id");
|
||
var status = $(this).attr("data-status");
|
||
let tips = '';
|
||
if (status == 1) {
|
||
tips = "开启入口"
|
||
} else if (status == 2) {
|
||
tips = "关闭入口"
|
||
} else {
|
||
tips = "删除入口"
|
||
}
|
||
if (confirm(`你确认要${tips}吗?`)) {
|
||
$.ajax({
|
||
type: 'get',
|
||
url: "/admin/gamemanage/quickgame/changeQuickGameGroupStatus",
|
||
data: { 'groupId': groupId, 'status': status },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json.code == 200) {
|
||
$("#tipMsg").text(`${tips}成功`);
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text(`${tips}失败`);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
// 编辑获取信息
|
||
$("#table").on("click", '.opt-edit', function () {
|
||
var idx = $(this).attr("data-idx");
|
||
console.log("=== idx groupList", idx, groupList)
|
||
const matchInfo = groupList[idx];
|
||
$("#addForm #groupId").val(matchInfo.groupId);
|
||
$("#addForm #matchType").val(matchInfo.matchType);
|
||
$("#addForm #title").val(matchInfo.title);
|
||
$("#addForm #platformType").val(matchInfo.platformType);
|
||
$("#addForm #groupType").val(matchInfo.groupType);
|
||
$("#addForm #quotaLimit").val(matchInfo.quotaLimit);
|
||
$("#addForm #minQuota").val(matchInfo.minQuota);
|
||
$("#addForm #quotaPrice").val(matchInfo.quotaPrice);
|
||
$("#addForm #award").val(matchInfo.award);
|
||
if (matchInfo.awardType == 1) {
|
||
$("input[name='awardType'][value= 1]").prop("checked", true);
|
||
$("input[name='awardType'][value= 2]").prop("checked", false);
|
||
} else {
|
||
$("input[name='awardType'][value= 1]").prop("checked", false);
|
||
$("input[name='awardType'][value= 2]").prop("checked", true);
|
||
}
|
||
$("#addForm #matchStartTime").val(formatTime(matchInfo.matchStartTime));
|
||
$("#addForm #matchRule").val(matchInfo.matchRule);
|
||
$("#addForm #matchGroupId").val(matchInfo.matchGroupId);
|
||
$("#addForm #ticketId").val(matchInfo.ticketId);
|
||
$("#addForm #dismissMinute").val(matchInfo.dismissMinute);
|
||
$("#addForm #subGameNum").val(matchInfo.subGameNum);
|
||
$("#addForm #seqNo").val(matchInfo.seqNo);
|
||
$("#addForm #chatRoomUid").val(matchInfo.chatRoomUid);
|
||
$('#addForm #matchUrl').val(matchInfo.matchUrl);
|
||
$('#addForm #picImage').attr("src", matchInfo.matchUrl);
|
||
if (matchInfo.matchUrl != '' && matchInfo.matchUrl != null) {
|
||
$("#addForm #picImgInfo").html('已上传成功');
|
||
} else {
|
||
$("#addForm #picImgInfo").html('未上传成功');
|
||
}
|
||
$("#editMatchModal").modal('show');
|
||
});
|
||
|
||
// 展示比赛列表
|
||
$("#table").on("click", '.opt-list-game', function () {
|
||
var idx = $(this).attr("data-idx");
|
||
console.log("=== idx groupList", idx, groupList)
|
||
const groupInfo = groupList[idx];
|
||
let gameName = ''
|
||
let platformName = ''
|
||
let ticketName = ''
|
||
$('#matchListModel #matchListModelTitle').text(`快速赛名称:${groupInfo.title} ${gameName} ${platformName} 报名要求`)
|
||
$('#matchListModelTable').bootstrapTable('destroy');
|
||
$('#matchListModelTable').bootstrapTable({
|
||
columns: [
|
||
{ field: 'matchId', title: '快速赛ID', align: 'center', width: '5%' },
|
||
{
|
||
field: 'tmp', title: '当前报名情况', align: 'center', width: '5%',
|
||
formatter: function (val, row, index) {
|
||
return `开赛:${row.hasQuotaCount}/${row.minQuota}<br>总数:${row.hasQuotaCount}/${row.quotaLimit}<br><a href="javascript:void()" class="opt-show-join-users" data-match-id="${row.matchId}">查看></a>`
|
||
}
|
||
},
|
||
{
|
||
field: 'status', title: '当前状态', align: 'center', valign: 'middle', width: '10%', formatter: function (val, row) {
|
||
if (val == MATCH_STATUS.VALID) {
|
||
return '报名中';
|
||
} else if (val == MATCH_STATUS.ENTER_STAGE) {
|
||
return '进场中';
|
||
} else if (val == MATCH_STATUS.GAME_START) {
|
||
if (row.canEnterRoomAfterGameStart == 1) {
|
||
return `比赛中<br>可继续进场<br><a href="javascript:void()" style="text-decoration:underline;" class="opt-disable-enter" data-matchId="${row.matchId}">设为不可进场</a>`;
|
||
} else {
|
||
return '比赛中<br>不可进场';
|
||
}
|
||
} else if (val == MATCH_STATUS.GAME_END) {
|
||
return '结束统计中';
|
||
} else if (val == MATCH_STATUS.CLOSE_MANUAL) {
|
||
return '已关闭';
|
||
} else if (val == MATCH_STATUS.NOT_START_ENROLL) {
|
||
return '未开始报名';
|
||
} else if (val == MATCH_STATUS.FINISHED) {
|
||
return '完结';
|
||
} else if (val == MATCH_STATUS.NOT_EMPTY_QUOTA) {
|
||
return '已报满';
|
||
} else if (val == MATCH_STATUS.ENTER_STAGE_NOT_EMPTY_QUOTA) {
|
||
return '进场中';
|
||
} else if (val == MATCH_STATUS.AUTO_DISMISS_STAGE) {
|
||
return `流局<br>${formatTime(row.dismissMatchTime)}<br>自动流局`;
|
||
} else if (val == MATCH_STATUS.MANUAL_DISMISS_STAGE) {
|
||
return `流局<br>${formatTime(row.dismissMatchTime)}<br>手动流局`;
|
||
}
|
||
}
|
||
},
|
||
{ field: 'dismissMatchTime', title: '自动流局时间', align: 'center', valign: 'middle', width: '10%', formatter: formatTime },
|
||
{
|
||
field: 'tmp', title: '比赛时间', align: 'center', valign: 'middle', width: '30%',
|
||
formatter: function (val, row, index) {
|
||
let quotaStartTime = !row.quotaStartTime ? '/' : formatTime(row.quotaStartTime)
|
||
let enoughQuotaTime = !row.enoughQuotaTime ? '/' : formatTime(row.enoughQuotaTime)
|
||
let enterStartTime = !row.enterStartTime ? '/' : formatTime(row.enterStartTime)
|
||
let matchStartTime = !row.matchStartTime ? '/' : formatTime(row.matchStartTime)
|
||
let matchEndTime = !row.matchEndTime ? '/' : formatTime(row.matchEndTime)
|
||
let sendRewardTime = !row.sendRewardTime ? '/' : formatTime(row.sendRewardTime)
|
||
return `开始报名:${quotaStartTime}<br>
|
||
达到开赛要求:${enoughQuotaTime}<br>
|
||
进入房间:${enterStartTime}<br>
|
||
开始比赛:${matchStartTime}<br>
|
||
结束比赛:${matchEndTime}<br>
|
||
发放奖励:${sendRewardTime}
|
||
`
|
||
}
|
||
},
|
||
{
|
||
field: 'roomUrl', title: '进场链接', align: 'center', width: '20%', formatter: function (val, row, index) {
|
||
if (!val) {
|
||
return '未上传'
|
||
} else {
|
||
return val;
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'id',
|
||
title: '操作',
|
||
align: 'center',
|
||
width: '10%',
|
||
formatter: function (val, row, index) {
|
||
const actions = [];
|
||
if (GAME_NOT_START_STATUS.indexOf(row.status) >= 0) {
|
||
// 可以上传进场链接
|
||
actions.push('<button class="btn btn-sm btn-primary opt-submit-enter-link" data-idx=' + index + '>上传进场链接</button>');
|
||
actions.push('<button class="btn btn-sm btn-primary opt-dismiss-match" data-matchId=' + row.matchId + '>流局</button>');
|
||
actions.push('<button class="btn btn-sm btn-primary opt-add_robot" data-matchId=' + row.matchId + '>添加机器人</button>');
|
||
} else if (row.status == MATCH_STATUS.GAME_START) {
|
||
actions.push('<button class="btn btn-sm btn-primary opt-end-match" data-matchId=' + row.matchId + '>比赛结束</button>');
|
||
actions.push('<button class="btn btn-sm btn-primary opt-dismiss-match" data-matchId=' + row.matchId + '>流局</button>');
|
||
} else if (row.status == MATCH_STATUS.GAME_END) {
|
||
actions.push('<button class="btn btn-sm btn-primary opt-open-award-list" data-idx=' + index + '>发放奖励</button>');
|
||
} else if (row.status == MATCH_STATUS.FINISHED) {
|
||
actions.push('<button class="btn btn-sm btn-primary opt-open-award-list" data-idx=' + index + '>查看奖励</button>');
|
||
}
|
||
if (row.status != MATCH_STATUS.CLOSE_AUTO && row.status != MATCH_STATUS.CLOSE_MANUAL) {
|
||
actions.push('<button class="btn btn-sm btn-danger opt-close-match" data-matchId=' + row.matchId + '>强制关闭</button>');
|
||
}
|
||
return actions.join(" ");
|
||
}
|
||
}
|
||
],
|
||
undefinedText: "0",
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: true,
|
||
pageSize: 20,
|
||
pagination: true,
|
||
pageList: [20, 50, 100, 200, 300, 500],
|
||
search: false,
|
||
sidePagination: "server", //表示服务端请求
|
||
queryParamsType: "undefined",
|
||
queryParams: function queryParams(params) { //设置查询参数
|
||
var param = {
|
||
page: params.pageNumber,
|
||
pageSize: params.pageSize,
|
||
groupId: groupInfo.groupId,
|
||
type: QUICK_GAME_TYPE
|
||
};
|
||
return param;
|
||
},
|
||
url: '/admin/gameManage/listGameByPage',
|
||
onLoadSuccess: function (data) { //加载成功时执行
|
||
console.log("load success");
|
||
matchList = data.rows;
|
||
$("#matchListModel").modal('show');
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.log("load fail");
|
||
}
|
||
});
|
||
});
|
||
|
||
// 设置为不可进场
|
||
$("#matchListModelTable").on("click", '.opt-disable-enter', function () {
|
||
if (confirm("你确认设为不可进场吗? ")) {
|
||
var matchId = $(this).attr("data-matchId");
|
||
console.log("matchId", matchId)
|
||
$.ajax({
|
||
type: 'get',
|
||
url: "/admin/gamemanage/quickgame/disableEnterAfterMatchStart",
|
||
data: { matchId: matchId },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("操作成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#matchListModelTable");
|
||
} else {
|
||
$("#tipMsg").text("操作失败" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
// 添加机器人
|
||
$("#matchListModelTable").on("click", '.opt-add_robot', function () {
|
||
var matchId = $(this).attr("data-matchId");
|
||
console.log(matchId);
|
||
$("#addRobotMatchId").val(matchId);
|
||
$("#addRobotModal").modal('show');
|
||
});
|
||
|
||
|
||
// 确认添加
|
||
$("#btnConfirmAddRobot").click(function () {
|
||
const matchId = $("#addRobotMatchId").val();
|
||
const reqParams = {
|
||
matchId: matchId,
|
||
robotNum: $("#robotNum").val(),
|
||
}
|
||
$.ajax({
|
||
type: "get",
|
||
url: "/admin/gamemanage/quickgame/addRobot",
|
||
data: reqParams,
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("添加成功");
|
||
$("#tipModal").modal('show');
|
||
$("#addRobotModal").modal('hide');
|
||
TableHelper.doRefresh('#matchListModelTable');
|
||
} else {
|
||
$("#tipMsg").text("添加失败." + json.data.msg);
|
||
$("#tipModal").modal('show');
|
||
$("#addRobotModal").modal('hide');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
|
||
|
||
// 关闭比赛
|
||
$("#matchListModelTable").on("click", '.opt-close-match', function () {
|
||
var matchId = $(this).attr("data-matchId");
|
||
console.log(matchId);
|
||
$("#closeMatchManualMatchId").val(matchId);
|
||
$("#closeMatchManualModal").modal('show');
|
||
});
|
||
|
||
|
||
// 确认关闭
|
||
$("#btnConfirmcloseMatchManual").click(function () {
|
||
if (confirm("你确认关闭比赛吗? ")) {
|
||
const matchId = $("#closeMatchManualMatchId").val();
|
||
const reqParams = {
|
||
matchId: matchId,
|
||
giveBackTicket: $("input[name='giveBackTicket']:checked").val(),
|
||
closeReason: $("#closeReason").val(),
|
||
}
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameManage/closeMatchManual",
|
||
data: reqParams,
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("关闭成功");
|
||
$("#tipModal").modal('show');
|
||
$("#closeMatchManualModal").modal('hide');
|
||
TableHelper.doRefresh('#matchListModelTable');
|
||
} else {
|
||
$("#tipMsg").text("保存失败." + json.data.msg);
|
||
$("#tipModal").modal('show');
|
||
$("#submitEnterLinkModal").modal('hide');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
// 结束比赛
|
||
$("#matchListModelTable").on("click", '.opt-end-match', function () {
|
||
var matchId = $(this).attr("data-matchId");
|
||
console.log(matchId);
|
||
if (confirm("你确认结束比赛吗? ")) {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: "/admin/gameManage/endMatch",
|
||
data: { matchId },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("操作成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#matchListModelTable");
|
||
} else {
|
||
$("#tipMsg").text("操作失败" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
// 展示参赛用户
|
||
let currShowedJoinListMatchId;
|
||
$("#matchListModelTable").on("click", '.opt-show-join-users', function () {
|
||
var matchId = $(this).attr("data-match-id");
|
||
currShowedJoinListMatchId = matchId;
|
||
$('#joinedUserListModal #joinedUserListModalTitle').text(`${matchId}报名情况`)
|
||
$('#joinedUsersTable').bootstrapTable('destroy');
|
||
$('#joinedUsersTable').bootstrapTable({
|
||
columns: [
|
||
{ field: 'uid', title: 'uid', align: 'center', width: '5%' },
|
||
{ field: 'erbanNo', title: '平台号', align: 'center', width: '5%' },
|
||
{ field: 'nick', title: '用户昵称', align: 'center', width: '15%' },
|
||
{ field: 'gameNick', title: '绑定昵称', align: 'center', width: '15%', },
|
||
{ field: 'gameId', title: '绑定编号', align: 'center', width: '15%', },
|
||
{
|
||
field: 'isRobot', title: '是否机器人', align: 'center', width: '15%',
|
||
formatter: function (val) {
|
||
if (val == 1) {
|
||
return '是'
|
||
} else {
|
||
return '否';
|
||
}
|
||
}
|
||
}
|
||
],
|
||
undefinedText: 0,
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: false,
|
||
pageSize: 20,
|
||
pagination: true,
|
||
pageList: [20, 50, 100, 200, 300, 500],
|
||
search: false,
|
||
sidePagination: "server", //表示服务端请求
|
||
queryParamsType: "undefined",
|
||
queryParams: function queryParams(params) { //设置查询参数
|
||
var param = {
|
||
page: params.pageNumber,
|
||
pageSize: params.pageSize,
|
||
matchId: matchId,
|
||
};
|
||
return param;
|
||
},
|
||
url: '/admin/gameManage/listGameJoinRecordByPage',
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
$("#joinedUserListModal").modal('show');
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.log("load fail");
|
||
}
|
||
});
|
||
});
|
||
|
||
// 上传进场链接
|
||
$("#matchListModelTable").on("click", '.opt-submit-enter-link', function () {
|
||
var idx = $(this).attr("data-idx");
|
||
console.debug("=== idx matchList", idx, matchList);
|
||
const matchInfo = matchList[idx];
|
||
$("#submitEnterLinkForm #submitEnterLinkMatchId").val(matchInfo.matchId);
|
||
$("#submitEnterLinkForm #roomUrl").val(matchInfo.roomUrl);
|
||
$("#submitEnterLinkModal").modal('show');
|
||
});
|
||
|
||
// 流局
|
||
$("#matchListModelTable").on("click", '.opt-dismiss-match', function () {
|
||
var matchId = $(this).attr("data-matchId");
|
||
console.log(matchId);
|
||
if (confirm("你确认流局比赛吗? ")) {
|
||
$.ajax({
|
||
type: 'get',
|
||
url: "/admin/gamemanage/quickgame/manualDismissStage",
|
||
data: { matchId },
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("操作成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#matchListModelTable");
|
||
} else {
|
||
$("#tipMsg").text("操作失败" + json.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
|
||
|
||
// 上传进场链接
|
||
$("#btnConfirmSubmitEnterLink").click(function () {
|
||
if ($("#addForm").validationEngine('validate')) {
|
||
const matchId = $("#submitEnterLinkMatchId").val();
|
||
const reqParams = {
|
||
matchId: matchId,
|
||
roomUrl: $("#submitEnterLinkForm #roomUrl").val(),
|
||
}
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameManage/submitEnterLink",
|
||
data: reqParams,
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("保存成功");
|
||
$("#tipModal").modal('show');
|
||
$("#submitEnterLinkModal").modal('hide');
|
||
TableHelper.doRefresh('#matchListModelTable');
|
||
} else {
|
||
$("#tipMsg").text("保存失败." + json.data.msg);
|
||
$("#tipModal").modal('show');
|
||
$("#submitEnterLinkModal").modal('hide');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
// 发放奖励列表弹窗
|
||
let joinRecords = [];
|
||
$("#matchListModelTable").on("click", '.opt-open-award-list', function () {
|
||
var idx = $(this).attr("data-idx");
|
||
const matchInfo = matchList[idx];
|
||
currShowedJoinListMatchId = matchInfo.matchId;
|
||
if (matchInfo.status == MATCH_STATUS.GAME_END) {
|
||
$('#awardListModal #awardListModalTitle').text(`发放奖励`);
|
||
$('#awardListModal .js-award-list-footer').show();
|
||
|
||
} else if (matchInfo.status == MATCH_STATUS.FINISHED) {
|
||
$('#awardListModal #awardListModalTitle').text(`查看奖励`);
|
||
$('#awardListModal .js-award-list-footer').hide();
|
||
}
|
||
$('#awardListTable').bootstrapTable('destroy');
|
||
$('#awardListTable').bootstrapTable({
|
||
columns: [
|
||
{ field: 'uid', title: 'uid', align: 'center', width: '5%' },
|
||
{ field: 'erbanNo', title: '平台号', align: 'center', width: '5%' },
|
||
{ field: 'nick', title: '用户昵称', align: 'center', width: '15%' },
|
||
{ field: 'gameNick', title: '绑定昵称', align: 'center', width: '15%' },
|
||
{ field: 'gameId', title: '绑定编号', align: 'center', width: '15%' },
|
||
{
|
||
field: 'isRobot', title: '是否机器人', align: 'center', width: '15%',
|
||
formatter: function (val) {
|
||
if (val == 1) {
|
||
return '是'
|
||
} else {
|
||
return '否';
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'hasJoinGame', title: '是否参赛', align: 'center', width: '15%',
|
||
formatter: function (val, row, index) {
|
||
if (matchInfo.status == MATCH_STATUS.GAME_END) {
|
||
return '<select name="hasJoinGameSelector_' + index + '" id="hasJoinGameSelector_' + index + '" class="form-control js-hasJoinGameSelector" value="0">' +
|
||
`<option value="0" ${val == 0 ? 'selected = "selected"' : ''}>否</option>` +
|
||
`<option value="1" ${val == 1 ? 'selected = "selected"' : ''} >是</option>` +
|
||
'</select>'
|
||
} else if (matchInfo.status == MATCH_STATUS.FINISHED) {
|
||
if (val == 1) {
|
||
return '是'
|
||
} else {
|
||
return '否';
|
||
}
|
||
}
|
||
|
||
}
|
||
},
|
||
{
|
||
field: 'eliminateNum', title: '淘汰人数', align: 'center', width: '15%',
|
||
formatter: function (val, row, index) {
|
||
if (matchInfo.status == MATCH_STATUS.GAME_END) {
|
||
return '<input type="text" class="input-sm form-control js-eliminateNumInput" name="eliminateNum_' + index + '" id="eliminateNum_' + index + '" value="' + val + '">'
|
||
} else if (matchInfo.status == MATCH_STATUS.FINISHED) {
|
||
return val
|
||
}
|
||
|
||
}
|
||
},
|
||
{
|
||
field: 'ranking', title: '名次', align: 'center', width: '15%',
|
||
formatter: function (val, row, index) {
|
||
if (matchInfo.status == MATCH_STATUS.GAME_END) {
|
||
return '<input type="text" class="input-sm form-control js-rankingInput" name="ranking_' + index + '" id="ranking_' + index + '" value="' + val + '">'
|
||
} else if (matchInfo.status == MATCH_STATUS.FINISHED) {
|
||
return val
|
||
}
|
||
|
||
}
|
||
},
|
||
],
|
||
undefinedText: 0,
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: false,
|
||
// pageSize: 1,
|
||
pagination: false,
|
||
// pageList: [20, 50, 100, 200, 300, 500],
|
||
search: false,
|
||
// sidePagination: "server", //表示服务端请求
|
||
queryParamsType: "undefined",
|
||
queryParams: function queryParams(params) { //设置查询参数
|
||
var param = {
|
||
matchId: matchInfo.matchId,
|
||
};
|
||
return param;
|
||
},
|
||
url: '/admin/gameManage/listGameJoinRecord',
|
||
onLoadSuccess: function (data) { //加载成功时执行
|
||
$("#awardListModal").modal('show');
|
||
joinRecords = data;
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.log("load fail");
|
||
}
|
||
});
|
||
});
|
||
|
||
// 保存比赛结果数据
|
||
$("#saveAwardListBtn").click(function () {
|
||
doSaveGameResultDatas((data) => {
|
||
$("#tipMsg").text("保存成功");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh('#awardListTable');
|
||
})
|
||
});
|
||
|
||
function doSaveGameResultDatas(successCb) {
|
||
const hasJoinGameSelectors = $('#awardListTable .js-hasJoinGameSelector');
|
||
const eliminateNumInputs = $('#awardListTable .js-eliminateNumInput');
|
||
const rankingInputs = $('#awardListTable .js-rankingInput');
|
||
|
||
const gameResultDatas = [];
|
||
for (let idx = 0; idx < joinRecords.length; idx++) {
|
||
const joinRecord = joinRecords[idx];
|
||
const hasJoinGameSelector = hasJoinGameSelectors[idx];
|
||
const hasJoinGame = $(hasJoinGameSelector).val();
|
||
const eliminateNumInput = eliminateNumInputs[idx];
|
||
const eliminateNum = $(eliminateNumInput).val();
|
||
const rankingInput = rankingInputs[idx];
|
||
const ranking = $(rankingInput).val();
|
||
|
||
const gameResultData = {
|
||
joinRecordId: joinRecord.joinRecordId,
|
||
hasJoinGame,
|
||
}
|
||
if (parseInt(eliminateNum) >= 0) {
|
||
gameResultData.eliminateNum = eliminateNum;
|
||
}
|
||
if (parseInt(ranking) >= 0) {
|
||
gameResultData.ranking = ranking;
|
||
}
|
||
|
||
gameResultDatas.push(gameResultData);
|
||
}
|
||
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameManage/saveGameResultData",
|
||
data: {
|
||
resultDatas: JSON.stringify(gameResultDatas)
|
||
},
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
if (successCb) {
|
||
successCb(json);
|
||
}
|
||
} else {
|
||
$("#tipMsg").text("保存失败." + json.data.msg);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 发放奖励
|
||
$("#sendAwardBtn").click(function () {
|
||
// 先报错数据
|
||
doSaveGameResultDatas((data) => {
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/gameManage/sendReward",
|
||
data: {
|
||
matchId: currShowedJoinListMatchId,
|
||
},
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (apiResult(json)) {
|
||
$("#tipMsg").text("发放成功");
|
||
$("#tipModal").modal('show');
|
||
$("#awardListModal").modal('hide');
|
||
TableHelper.doRefresh('#table');
|
||
} else {
|
||
$("#tipMsg").text("发放失败." + json.data.msg);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
},
|
||
error: function (req) {
|
||
serverError(req);
|
||
}
|
||
});
|
||
})
|
||
});
|
||
|
||
|
||
$('#picUploadBtn').on('click', function () {
|
||
$.ajaxFileUpload({
|
||
fileElementId: 'picUploadFile', //需要上传的文件域的ID,即<input type="file">的ID。
|
||
url: '/admin/luckySea/upload', //后台方法的路径
|
||
type: 'post', //当要提交自定义参数时,这个参数要设置成post
|
||
dataType: 'json', //服务器返回的数据类型。可以为xml,script,json,html。如果不填写,jQuery会自动判断。
|
||
secureuri: false, //是否启用安全提交,默认为false。
|
||
async: true, //是否是异步
|
||
success: function (json) { //提交成功后自动执行的处理函数,参数data就是服务器返回的数据。
|
||
if (json.path) {
|
||
$('#matchUrl').val(json.path);
|
||
$('#picImage').attr("src", json.path);
|
||
if (json.path != '') {
|
||
$("#picImgInfo").html('已上传成功');
|
||
} else {
|
||
$("#picImgInfo").html('未上传成功');
|
||
}
|
||
console.log(json.path);
|
||
|
||
} else {
|
||
$("#tipMsg").text(json.msg);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
},
|
||
error: function (data, status, e) { //提交失败自动执行的处理函数。
|
||
console.error(e);
|
||
}
|
||
});
|
||
})
|
||
|
||
function formatTime(val) {
|
||
if (val) {
|
||
var date = new Date(val);
|
||
return date.format('yyyy-MM-dd hh:mm:ss');
|
||
} else {
|
||
return '-';
|
||
}
|
||
}
|
||
|
||
function serverError(req) {
|
||
$("#tipMsg").text(req.responseJSON.message);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
|
||
function apiResult(json) {
|
||
if (json.code == 200 && json.message == 'success') {
|
||
return true;
|
||
}
|
||
$("#tipMsg").text("请求失败,错误信息:" + json.message);
|
||
$("#tipModal").modal('show');
|
||
return false;
|
||
}
|
||
|
||
var picker1 = $("#queryMatchStartTime").datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
var picker2 = $('#queryMatchEndTime').datetimepicker({
|
||
format: 'yyyy-mm-dd hh:ii:00',
|
||
autoclose: true
|
||
})
|
||
picker1.on('changeDate', function () {
|
||
var date = $('#queryMatchStartTime').datetimepicker('getDate');
|
||
picker2.datetimepicker('setStartDate', date);
|
||
});
|
||
picker2.on('changeDate', function () {
|
||
var date = $('#queryMatchEndTime').datetimepicker('getDate');
|
||
picker1.datetimepicker('setEndDate', date);
|
||
});
|
||
|
||
$("#exportJoinUserList").on("click", function () {
|
||
window.location.href = `/admin/gameMatch/exportMatchJoinedUsers?matchId=${currShowedJoinListMatchId}`
|
||
});
|
||
});
|
||
}
|
||
},
|
||
|
||
};
|
||
|
||
function clearModal() {
|
||
$('#addForm').find('input[type=text],select,input[type=hidden]').each(function () {
|
||
$(this).val('');
|
||
});
|
||
$("#addForm #platformType").removeAttr("disabled");
|
||
$("#addForm #groupType").removeAttr("disabled");
|
||
$("#addForm #matchStartTime").removeAttr("disabled");
|
||
$('#editMatchModal').find('textarea').val('');
|
||
$('#matchUrl').val('');
|
||
$('#picImage').attr("src", '');
|
||
$("#picImgInfo").html('');
|
||
$("#picUploadFile").val('');
|
||
}
|
||
|
||
</script>
|
||
|
||
<style scoped>#awardListModal .modal-dialog {
|
||
width: 900px;
|
||
}
|
||
|
||
#awardListModal .fixed-table-body {
|
||
height: 80%;
|
||
}
|
||
|
||
#matchListModel .modal-dialog {
|
||
width: 1200px;
|
||
height: 80%;
|
||
}</style> |