381 lines
17 KiB
Vue
381 lines
17 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>
|
|
<form id="formOuter" action="" method="post" target="_blank">
|
|
<input type="hidden" name="erbanNo" id="exportErbanNo">
|
|
<input type="hidden" name="queryStartDate" id="exportQueryStartDate">
|
|
<input type="hidden" name="queryEndDate" id="exportQueryEndDate">
|
|
</form>
|
|
<div id="toolbar">
|
|
|
|
<div class="col-sm-12">
|
|
|
|
<div class="col-sm-4">
|
|
<label htmlFor="erbanNo" class="col-sm-4 control-label">房主平台号:</label>
|
|
<div class="col-sm-8">
|
|
<input type="text" class="input-sm form-control" name="erbanNo" id="erbanNo">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-sm-4">
|
|
<label class="col-sm-4 control-label">开始时间:</label>
|
|
<div class="col-sm-8">
|
|
<input type="text" class="input-sm datetime" name="queryStartDate" id="queryStartDate">
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-4">
|
|
<label class="col-sm-4 control-label">结束时间:</label>
|
|
<div class="col-sm-8">
|
|
<input type="text" class="input-sm datetime" name="queryEndDate" id="queryEndDate">
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col-sm-12">
|
|
<button id="btnSearch" class="btn btn-default">
|
|
<i class="glyphicon glyphicon-search"></i>查询
|
|
</button>
|
|
<button class="btn btn-default js-quick-search js-quick-search-1 active" data-days="1">
|
|
昨天
|
|
</button>
|
|
<button class="btn btn-default js-quick-search js-quick-search-7" data-days="7">
|
|
最近7天
|
|
</button>
|
|
<button class="btn btn-default js-quick-search js-quick-search-30" data-days="30">
|
|
最近30天
|
|
</button>
|
|
<button id="btnExport" class="btn btn-sm btn-primary">导出</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<!-- .content -->
|
|
<div id="table"></div>
|
|
|
|
</div>
|
|
</section>
|
|
|
|
<!-- 编辑弹框 -->
|
|
<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">×</span>
|
|
</button>
|
|
<h4 class="modal-title" id="editModalLabel">详情列表</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="form" action="" method="post" target="_blank">
|
|
<input type="hidden" name="erbanNo" id="exportDetailErbanNo">
|
|
<input type="hidden" name="queryStartDate" id="exportDetailQueryStartDate">
|
|
<input type="hidden" name="queryEndDate" id="exportDetailQueryEndDate">
|
|
</form>
|
|
<div id="toolbar2">
|
|
<div class="col-sm-12">
|
|
<button id="btnExportDetail" class="btn btn-sm btn-primary">导出</button>
|
|
</div>
|
|
</div>
|
|
<div id="table2"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import TableHelper from '@/utils/bootstrap-table-helper';
|
|
import { cleanArray } from '@/utils/maintainer';
|
|
|
|
export default {
|
|
name: "SingleRoomPkAdminView",
|
|
setup() {
|
|
return {};
|
|
},
|
|
created() {
|
|
this.$nextTick(function () {
|
|
this.initData();
|
|
});
|
|
},
|
|
methods: {
|
|
initData() {
|
|
$(function () {
|
|
$('.datetime').datetimepicker({
|
|
format: 'yyyy-mm-dd hh:ii:00',
|
|
autoclose: true
|
|
});
|
|
|
|
$("#queryStartDate").datetimepicker({
|
|
minView: "month",
|
|
language: 'zh-CN',
|
|
todayBtn: 1,
|
|
autoclose: 1
|
|
}).on("changeDate", function (event) {
|
|
$("#queryEndDate").datetimepicker('setStartDate', event.date);
|
|
});
|
|
|
|
$("#queryEndDate").datetimepicker({
|
|
minView: "month",
|
|
language: 'zh-CN',
|
|
todayBtn: 1,
|
|
autoclose: 1,
|
|
useCurrent: false
|
|
}).on("changeDate", function (event) {
|
|
$("#queryStartDate").datetimepicker('setEndDate', event.date);
|
|
});
|
|
|
|
|
|
$('.js-quick-search').on('click', function () {
|
|
$('.js-quick-search').removeClass('active')
|
|
$(this).addClass('active');
|
|
setSearchTimeUseQuickWay($(this));
|
|
|
|
TableHelper.doRefresh('#table');
|
|
});
|
|
|
|
function setSearchTimeUseQuickWay(quickDom) {
|
|
const days = quickDom.attr("data-days");
|
|
const today = new Date(new Date().setHours(0, 0, 0, 0));
|
|
const todayStr = formatTime(today);
|
|
const startTime = formatTime(new Date(today.getTime() - days * 24 * 60 * 60 * 1000));
|
|
|
|
$('#queryStartDate').val(startTime);
|
|
$('#queryEndDate').val(todayStr);
|
|
}
|
|
|
|
|
|
|
|
$('#table').bootstrapTable('destroy');
|
|
$('#table').bootstrapTable({
|
|
columns: [
|
|
{ field: 'title', title: '房间名称', align: 'center', width: '10%' },
|
|
{ field: 'erbanNo', title: '房间平台号', align: 'center', width: '5%' },
|
|
{ field: 'validPkNum', title: '有效pk次数', align: 'center', width: '10%' },
|
|
{ field: 'validWinNum', title: '有效pk胜利次数', align: 'center', width: '10%' },
|
|
{ field: 'pkNum', title: 'pk次数', align: 'center', width: '10%' },
|
|
{ field: 'pkMin', title: 'pk总时长/分钟', align: 'center', width: '10%' },
|
|
{ field: 'pkAmount', title: 'pk总流水', align: 'center', width: '10%' },
|
|
{ field: 'normalAmount', title: '普通礼物总流水', align: 'center', width: '10%' },
|
|
{ field: 'bagAmount', title: '背包礼物总流水', align: 'center', width: '10%' },
|
|
{
|
|
field: 'erbanNo',
|
|
title: '其他',
|
|
align: 'center',
|
|
width: '10%',
|
|
formatter: function (val) {
|
|
console.log("erbanNo = " + val);
|
|
return '<button id="btnEdit" name="btnEdit" class="btn btn-sm btn-success opt-edit" data-id=' + val + '>' +
|
|
'<i class="glyphicon glyphicon-edit"></i>详情</button>';
|
|
}
|
|
}
|
|
],
|
|
undefinedText: "-",
|
|
cache: false,
|
|
striped: true,
|
|
showRefresh: false,
|
|
pageSize: 10,
|
|
pagination: true,
|
|
pageList: [10, 20, 50, 100],
|
|
search: false,
|
|
sidePagination: "server", //表示服务端请求
|
|
queryParamsType: "undefined",
|
|
queryParams: function queryParams(params) { //设置查询参数
|
|
var param = {
|
|
erbanNo: $('#erbanNo').val(),
|
|
queryStartDate: $('#queryStartDate').val(),
|
|
queryEndDate: $('#queryEndDate').val(),
|
|
pageSize: params.pageSize,
|
|
pageNumber: params.pageNumber,
|
|
pkType: 2,
|
|
};
|
|
return param;
|
|
},
|
|
ajax: function (request) { //使用ajax请求
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/admin/crossRoom/pk/statisList.action',
|
|
contentType: 'application/json;charset=utf-8',
|
|
dataType: 'json',
|
|
data: request.data,
|
|
success: function (res) {
|
|
apiResult(res);
|
|
request.success({
|
|
rows: res.data.rows,
|
|
total: res.data.total,
|
|
});
|
|
},
|
|
error: function (req) {
|
|
serverError(req);
|
|
}
|
|
})
|
|
},
|
|
toolbar: '#toolbar',
|
|
onLoadSuccess: function () { //加载成功时执行
|
|
console.log("load success");
|
|
},
|
|
onLoadError: function () { //加载失败时执行
|
|
console.log("load fail");
|
|
}
|
|
});
|
|
|
|
// 查询刷新
|
|
$('#btnSearch').on('click', function () {
|
|
TableHelper.doRefresh('#table');
|
|
});
|
|
|
|
// 编辑获取信息
|
|
$("#table").on("click", '.opt-edit', function () {
|
|
let erbanNo = $(this).attr("data-id");
|
|
$('#exportDetailErbanNo').val(erbanNo);
|
|
$('#table2').bootstrapTable('destroy');
|
|
$('#table2').bootstrapTable({
|
|
columns: [
|
|
{ field: 'roundId', title: '场次', align: 'center', width: '5%' },
|
|
{
|
|
field: 'beginTime',
|
|
title: 'pk开始时间',
|
|
align: 'center',
|
|
valign: 'middle',
|
|
width: '5%',
|
|
formatter: function (val, row, index) {
|
|
if (val == undefined || val == null) return '';
|
|
var date = new Date(val);
|
|
return date.format("yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
},
|
|
{ field: 'duration', title: 'pk时长/分钟', align: 'center', width: '5%' },
|
|
{ field: 'pkAmount', title: 'pk流水', align: 'center', width: '5%' },
|
|
{ field: 'normalAmount', title: '普通礼物流水', align: 'center', width: '5%' },
|
|
{ field: 'bagAmount', title: '背包礼物流水', align: 'center', width: '5%' },
|
|
{ field: 'pkResult', title: '结果', align: 'center', width: '5%' }
|
|
],
|
|
undefinedText: "0",
|
|
cache: false,
|
|
striped: true,
|
|
showRefresh: false,
|
|
pageSize: 10,
|
|
pageList: [10, 20, 50, 100],
|
|
pagination: true,
|
|
search: false,
|
|
sidePagination: "server", //表示服务端请求
|
|
queryParamsType: "undefined",
|
|
queryParams: function queryParams(params) { //设置查询参数
|
|
var param = {
|
|
erbanNo: erbanNo,
|
|
queryStartDate: $('#queryStartDate').val(),
|
|
queryEndDate: $('#queryEndDate').val(),
|
|
pageSize: params.pageSize,
|
|
pageNumber: params.pageNumber,
|
|
pkType: 2,
|
|
};
|
|
return param;
|
|
},
|
|
ajax: function (request) { //使用ajax请求
|
|
$.ajax({
|
|
type: "GET",
|
|
url: '/admin/crossRoom/pk/detailList.action',
|
|
contentType: 'application/json;charset=utf-8',
|
|
dataType: 'json',
|
|
data: request.data,
|
|
success: function (res) {
|
|
apiResult(res);
|
|
request.success({
|
|
rows: res.data.rows,
|
|
total: res.data.total,
|
|
});
|
|
// 打开编辑弹窗
|
|
$("#editModal").modal('show');
|
|
$('#erbanNoExport').val(erbanNo);
|
|
},
|
|
error: function (req) {
|
|
serverError(req);
|
|
}
|
|
})
|
|
},
|
|
onLoadSuccess: function () { //加载成功时执行
|
|
console.log("load success");
|
|
},
|
|
onLoadError: function () { //加载失败时执行
|
|
console.log("load fail");
|
|
}
|
|
});
|
|
})
|
|
|
|
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;
|
|
}
|
|
|
|
function getQueryParams() {
|
|
var param = {
|
|
erbanNo: $('#erbanNo').val(),
|
|
queryStartDate: $('#queryStartDate').val(),
|
|
queryEndDate: $('#queryEndDate').val(),
|
|
pkType: 2
|
|
};
|
|
return param;
|
|
}
|
|
|
|
function getDetailQueryParams() {
|
|
var param = {
|
|
erbanNo: $('#exportDetailErbanNo').val(),
|
|
queryStartDate: $('#queryStartDate').val(),
|
|
queryEndDate: $('#queryEndDate').val(),
|
|
pkType: 2,
|
|
};
|
|
return param;
|
|
}
|
|
|
|
function param(json) {
|
|
if (!json) return ''
|
|
return cleanArray(Object.keys(json).map(key => {
|
|
if (json[key] === undefined) return ''
|
|
return encodeURIComponent(key) + '=' +
|
|
encodeURIComponent(json[key])
|
|
})).join('&')
|
|
}
|
|
|
|
// 导出
|
|
$('#btnExport').on('click', function () {
|
|
console.log("导出")
|
|
window.location.href = `/admin/crossRoom/pk/statisListExport?${param(getQueryParams())}`
|
|
})
|
|
|
|
|
|
// 详情导出
|
|
$('#btnExportDetail').on('click', function () {
|
|
console.log("详情导出")
|
|
window.location.href = `/admin/crossRoom/pk/detailListExport?${param(getDetailQueryParams())}`
|
|
})
|
|
|
|
});
|
|
}
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style scoped></style> |