Files
peko-admin-web/src/views/finance/FinanceStatisticsView.vue
2024-04-28 10:26:23 +08:00

192 lines
8.7 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>
<!-- .content -->
<div id="table"></div>
<div id="toolbar">
<div class="col-sm-12">
<h3 id="version"></h3>
<div class="pull-left">
<form id="searchForm" class="col-sm-pull-12" action="/admin/finance/export" method="post"
target="_blank">
<div class="col-sm-11">
<label for="beginDate" class="col-sm-2 control-label">开始日期:</label>
<div class="col-sm-4"><input type="text" class="form-control" name="beginDate"
id="beginDate">
</div>
<label for="endDate" class="col-sm-2 control-label">结束日期:</label>
<div class="col-sm-4"><input type="text" class="form-control" name="endDate"
id="endDate"></div>
</div>
</form>
</div>
<div class="pull-right">
<button id="btnSearch" class="btn btn-default">
<i class="glyphicon glyphicon-search"></i>查询
</button>
<button id="btnExport" class="btn btn-default">
<i class="glyphicon glyphicon-export"></i>导出总额
</button>
<button id="btnExportDetail" class="btn btn-default">
<i class="glyphicon glyphicon-export"></i>导出明细
</button>
</div>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import TableHelper from '@/utils/bootstrap-table-helper';
export default {
name: "FinanceStatisticView",
setup() {
return {};
},
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
$(function () {
$('#table').bootstrapTable('destroy');
$('#table').bootstrapTable({
columns: [
// {field: 'tmp', title: 'id', align: 'center', checkbox: true, width: '5%'},
{
field: 'billTime',
title: '日期',
align: 'center',
valign: 'middle',
width: '5%',
formatter: function (val, row, index) {
if (val) {
var date = new Date(val);
return date.format("yyyy-MM-dd hh:mm:ss");
} else {
return '-';
}
}
},
{ field: 'goldIncreaseNum', title: '钻石增加', align: 'center', width: '5%' },
{ field: 'goldDecreaseNum', title: '钻石减少', align: 'center', width: '5%' },
{ field: 'goldNum', title: '钻石余额', align: 'center', width: '5%' },
{ field: 'diamondIncreaseNum', title: '金币增加', align: 'center', width: '5%' },
{ field: 'diamondDecreaseNum', title: '金币减少', align: 'center', width: '5%' },
{ field: 'diamondNum', title: '金币余额', align: 'center', width: '5%' },
{ field: 'totalNum', title: '总额', align: 'center', width: '5%' },
],
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 = {
pageNum: params.pageNumber,
pageSize: params.pageSize,
selectType: $('#selectType').val(),
beginDate: $('#beginDate').val(),
endDate: $('#endDate').val(),
};
return param;
},
toolbar: '#toolbar',
url: '/admin/finance/statistics',
onLoadSuccess: function (json) { //加载成功时执行
var updateTime = json.updateTime;
$("#version").html('财务数据' + '&nbsp;&nbsp;&nbsp;&nbsp;' + updateTime + '&nbsp;&nbsp;&nbsp;&nbsp;更新');
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
});
// 导出EXCEL
$('#btnExport').on('click', function () {
if (!$('#beginDate').val() || !$('#endDate').val()) {
$("#tipMsg").text("请选择导出的开始和结束日期");
$("#tipModal").modal('show');
return;
}
// var rows = $("#table").bootstrapTable("getSelections");
// if (rows.length == 0) {
// alert("请先选择要导出行");
// return;
// }
// var idArr = [];
// for (var i = 0; i < rows.length; i++) {
// console.log(rows[i]['pinyinName'])
// idArr.push(rows[i]['pinyinName']);
// }
var form = $("#searchForm");
form.attr("action", "/admin/finance/export?type=1");
// form.attr('type', 1);
form.submit();
});
$('#btnExportDetail').on('click', function () {
if (!$('#beginDate').val() || !$('#endDate').val()) {
$("#tipMsg").text("请选择导出的开始和结束日期");
$("#tipModal").modal('show');
return;
}
// var rows = $("#table").bootstrapTable("getSelections");
// if (rows.length == 0) {
// alert("请先选择要导出行");
// return;
// }
// var idArr = [];
// for (var i = 0; i < rows.length; i++) {
// console.log(rows[i]['pinyinName'])
// idArr.push(rows[i]['pinyinName']);
// }
var form = $("#searchForm");
form.attr("action", "/admin/finance/export?type=2");
// form.attr('type', 2);
form.submit();
});
// 查询刷新
$('#btnSearch').on('click', function () {
TableHelper.doRefresh('#table');
});
var chargeStart = $('#beginDate').datepicker({
format: 'yyyy-mm-dd',
autoclose: true
});
var chargeEnd = $('#endDate').datepicker({
format: 'yyyy-mm-dd',
autoclose: true
});
chargeStart.on('changeDate', function () {
var date = $('#beginDate').datepicker('getDate');
chargeEnd.datepicker('setStartDate', date);
});
chargeEnd.on('changeDate', function () {
var date = $('#endDate').datepicker('getDate');
chargeStart.datepicker('setEndDate', date);
});
});
}
},
};
</script>
<style scoped></style>