Files
peko-admin-web/src/views/record/ChargeRecordView.vue

386 lines
13 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">
<div class="box-body">
<section class="content-header">
<h1 id="itemTitle"></h1>
</section>
<form id="form2" action="" method="post" target="_blank">
<input type="hidden" name="erbanNo" id="exportErbanNo" />
<input type="hidden" name="channel" id="exportChannel" />
<input type="hidden" name="startTime" id="exportStartTime" />
<input type="hidden" name="endTime" id="exportEndTime" />
<input type="hidden" name="status" id="exportStatus" />
<input type="hidden" name="newUser" id="exportNewUser" />
<input type="hidden" name="appChannel" id="exportAppChannel" />
<input type="hidden" name="regionId" id="exportRegionId" />
<input type="hidden" name="chargeRecordId" id="exportChargeRecordId" />
<input type="hidden" name="pingxxChargeId" id="exportPingxxChargeId" />
</form>
<section class="content">
<div id="toolbar">
<form class="form-inline">
<div class="form-group">
<label for="qErbanNo">平台号</label>
<input type="text" class="form-control" name="erbanNo" id="qErbanNo" />
</div>
<div class="form-group">
<label for="qChannel">渠道:</label>
<input type="text" class="form-control" name="channel" id="qChannel" />
</div>
<div class="form-group">
<label for="qChannel">时间:</label>
<input type="text" class="form-control datetime" name="startTime" id="qStartTime" />
<label for="qChannel">-</label>
<input type="text" class="form-control datetime" name="endTime" id="qEndTime" />
</div>
<div class="form-group">
<label for="qStatus">状态:</label>
<select class="form-control" name="status" id="qStatus">
<option value="">全部</option>
<option value="1">发起充值</option>
<option value="2">充值成功</option>
</select>
</div>
<div class="form-group">
<label for="qNewUser">新用户:</label>
<select class="form-control" name="newUser" id="qNewUser">
<option value="">全部</option>
<option value="1"></option>
<option value="0"></option>
</select>
</div>
<div class="form-group">
<label for="qChannel">app渠道</label>
<input type="text" class="form-control" name="appChannel" id="qAppChannel" />
</div>
<div class="form-group">
<label for="regionId">国家</label>
<select name="regionId" id="regionId" class="form-control"></select>
</div>
<div class="form-group">
<label for="qErbanNo">商户订单号</label>
<input type="text" class="form-control" name="chargeRecordId" id="chargeRecordId" />
</div>
<div class="form-group">
<label for="qErbanNo">第三方订单号</label>
<input type="text" class="form-control" name="pingxxChargeId" id="pingxxChargeId" />
</div>
</form>
<div id="mapObjHtml"></div>
<button id="btnSearch" class="btn btn-sm btn-primary">查询</button>
<button id="btnExport" class="btn btn-sm btn-primary">导出</button>
</div>
<!-- .content -->
<div class="content" id="table"></div>
</section>
</div>
</div>
</section>
</template>
<script>
import TableHelper from "@/utils/bootstrap-table-helper";
import { buildSelectOption } from '@/utils/system-helper';
import {
regionInfoList,
} from "@/api/refund/refund";
export default {
name: "ChargeRecordView",
created() {
this.$nextTick(function () {
this.initData();
this.initRegionInfoList();
});
},
methods: {
initData() {
$("#qStatus").val(2)
$(".datetime").datetimepicker({
format: "yyyy-mm-dd hh:ii:00",
autoclose: true,
});
$('#table').bootstrapTable('destroy');
// 初始化表格,但不设置 `ajax` 方法,也不绑定 `url`,只提供列配置
$("#table").bootstrapTable({
columns: [
{ field: "erbanNo", title: "平台号", align: "center", width: "5%" },
{ field: "uid", title: "uid", align: "center", width: "5%" },
{ field: "nick", title: "昵称", align: "center", width: "5%" },
{
field: "partitionName",
title: "分区",
align: "center",
width: "5%",
},
{
field: "regionName",
title: "国家",
align: "center",
width: "5%",
},
{
field: "createTime",
title: "创建时间",
align: "center",
valign: "middle",
width: "10%",
},
{ field: "channel", title: "渠道", align: "center", width: "5%" },
{
field: "localCurrencyCode",
title: "当地货币代码",
align: "center",
width: "5%",
},
{
field: "localAmount",
title: "当地金额",
align: "center",
width: "5%",
},
{
field: "chargeRecordId",
title: "商户订单号",
align: "center",
width: "5%",
},
{
field: "pingxxChargeId",
title: "第三方订单号",
align: "center",
width: "5%",
},
{
field: "status",
title: "状态",
align: "center",
width: "5%",
formatter: function (val, row, index) {
return val == 2 ? "充值成功" : "发起充值";
},
},
{
field: "newUser",
title: "是否新用户",
align: "center",
width: "5%",
formatter: function (val, row, index) {
return val ? "是" : "否";
},
},
{
field: "appChannel",
title: "app渠道",
align: "center",
width: "5%",
},
{
field: "updateTime",
title: "更新时间",
align: "center",
width: "5%",
},
],
undefinedText: "-",
cache: false,
striped: true,
showRefresh: false,
pageSize: 20,
pagination: true,
pageList: [20, 50, 100, 200, 300, 500],
search: false,
sidePagination: "server",
queryParamsType: "undefined",
data: [], // 初始化为空数据
queryParams: function queryParams(params) {
//设置查询参数
var param = {
pageNumber: params.pageNumber,
pageSize: params.pageSize,
erbanNo: $("#qErbanNo").val(),
channel: $("#qChannel").val(),
startTime: $("#qStartTime").val(),
endTime: $("#qEndTime").val(),
status: $("#qStatus").val(),
newUser: $("#qNewUser").val(),
appChannel: $("#qAppChannel").val(),
regionId: $("#regionId").val(),
pingxxChargeId: $("#pingxxChargeId").val(),
chargeRecordId: $("#chargeRecordId").val(),
};
return param;
},
uniqueId: 'id',
toolbar: "#toolbar",
url: "/admin/chargeRecord/list",
onLoadSuccess: function (res) {
console.log('load success');
$("#table").bootstrapTable("load", {
rows: res.data.rows,
total: res.data.total,
});
$("#mapObjHtml span").remove();
const totalMap = res.data.totalMap;
if($("#qErbanNo").val()){
let str = "";
const sortedKeys = Object.keys(totalMap).sort((keyA, keyB) => {
return keyA === "总充值{USD}"
? -1
: keyB === "总充值{USD}"
? 1
: 0;
});
console.log(sortedKeys, '-------sortedKeys');
// for (const key of sortedKeys) {
// str += `
// <span style="margin-right:10px;display: inline-block;font-size: 18px;color: #2049a9;" type="text">${key}: ${totalMap[key]}, </span>
// `;
// }
// 处理第二项和最后一项
sortedKeys.forEach((key, index) => {
let value = totalMap[key];
if (index === 1) {
key = `包括(${key}`;
}
if (index === sortedKeys.length - 1) {
value = `${value})`;
}
str += `
<span style="margin-right:10px;display: inline-block;font-size: 18px;color: #2049a9;" type="text">${key}: ${value}</span>
`;
});
$("#mapObjHtml").append(str);
}
},
onLoadError: function (err) {
console.log('load fail');
serverError(err);
}
});
// 查询刷新
$("#btnSearch").on("click", function () {
const params = {
pageNumber: 1,
pageSize: 20,
erbanNo: $("#qErbanNo").val(),
channel: $("#qChannel").val(),
startTime: $("#qStartTime").val(),
endTime: $("#qEndTime").val(),
status: $("#qStatus").val(),
newUser: $("#qNewUser").val(),
appChannel: $("#qAppChannel").val(),
regionId: $("#regionId").val(),
chargeRecordId: $("#chargeRecordId").val(),
pingxxChargeId: $("#pingxxChargeId").val(),
};
// 手动加载数据
$.ajax({
type: "GET",
url: "/admin/chargeRecord/list",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: params,
success: function (res) {
if (apiResult(res)) {
$("#table").bootstrapTable("load", {
rows: res.data.rows,
total: res.data.total,
});
$("#mapObjHtml span").remove();
const totalMap = res.data.totalMap;
if(params.erbanNo){
let str = "";
const sortedKeys = Object.keys(totalMap).sort((keyA, keyB) => {
return keyA === "总充值{USD}"
? -1
: keyB === "总充值{USD}"
? 1
: 0;
});
console.log(sortedKeys, '-------sortedKeys');
// for (const key of sortedKeys) {
// str += `
// <span style="margin-right:10px;display: inline-block;font-size: 18px;color: #2049a9;" type="text">${key}: ${totalMap[key]}, </span>
// `;
// }
// 处理第二项和最后一项
sortedKeys.forEach((key, index) => {
let value = totalMap[key];
if (index === 1) {
key = `包括(${key}`;
}
if (index === sortedKeys.length - 1) {
value = `${value})`;
}
str += `
<span style="margin-right:10px;display: inline-block;font-size: 18px;color: #2049a9;" type="text">${key}: ${value}</span>
`;
});
$("#mapObjHtml").append(str);
}
}
},
error: function (req) {
serverError(req);
},
});
});
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;
}
// 导出excel
$("#btnExport").on("click", function () {
const form = $("#form2");
form.attr("action", "/admin/chargeRecord/exportChargeDetail");
$("#exportErbanNo").val($("#qErbanNo").val());
$("#exportChannel").val($("#qChannel").val());
$("#exportStartTime").val($("#qStartTime").val());
$("#exportEndTime").val($("#qEndTime").val());
$("#exportStatus").val($("#qStatus").val());
$("#exportNewUser").val($("#qNewUser").val());
$("#exportAppChannel").val($("#qAppChannel").val());
$("#exportRegionId").val($("#regionId").val());
$("#exportPingxxChargeId").val($("#pingxxChargeId").val());
$("#exportChargeRecordId").val($("#chargeRecordId").val());
form.submit();
});
},
initRegionInfoList() {
regionInfoList().then(res => {
let data = res.data;
buildSelectOption(
"#regionId",
null,
data.map((v) => {
return {
value: v.id,
text: v.regionDesc,
};
})
);
});
},
},
};
</script>
<style scoped></style>