[update]新增annualReport页面
This commit is contained in:
@@ -20,7 +20,7 @@ export function logHistory(params: { id: number | string }) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function annualReport(params: { id: number | string }) {
|
export function annualReport(params: { year: number | string }) {
|
||||||
return createAxios({
|
return createAxios({
|
||||||
url: url + 'annualReport',
|
url: url + 'annualReport',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export default {
|
|||||||
'/': ['./frontend/${lang}/index.ts'],
|
'/': ['./frontend/${lang}/index.ts'],
|
||||||
[adminBaseRoutePath + '/moduleStore']: ['./backend/${lang}/module.ts'],
|
[adminBaseRoutePath + '/moduleStore']: ['./backend/${lang}/module.ts'],
|
||||||
[adminBaseRoutePath + '/user/rule']: ['./backend/${lang}/auth/rule.ts'],
|
[adminBaseRoutePath + '/user/rule']: ['./backend/${lang}/auth/rule.ts'],
|
||||||
|
[adminBaseRoutePath + '/user/moneyLog/annualReport']: ['./backend/${lang}/user/moneyLog.ts'],
|
||||||
[adminBaseRoutePath + '/user/scoreLog']: ['./backend/${lang}/user/moneyLog.ts'],
|
[adminBaseRoutePath + '/user/scoreLog']: ['./backend/${lang}/user/moneyLog.ts'],
|
||||||
[adminBaseRoutePath + '/crud/crud']: ['./backend/${lang}/crud/log.ts', './backend/${lang}/crud/state.ts'],
|
[adminBaseRoutePath + '/crud/crud']: ['./backend/${lang}/crud/log.ts', './backend/${lang}/crud/state.ts'],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,4 +30,33 @@ export default {
|
|||||||
1004 : 'Plinko Ball'
|
1004 : 'Plinko Ball'
|
||||||
},
|
},
|
||||||
'bank_id': 'Bank Account',
|
'bank_id': 'Bank Account',
|
||||||
|
annualReport: {
|
||||||
|
title: 'ANNUAL REPORT',
|
||||||
|
year: 'YEAR',
|
||||||
|
deposit: 'DEPOSIT',
|
||||||
|
withdraw: 'WITHDRAW',
|
||||||
|
transactionDeposit: 'TRANSACTION (DEPOSIT)',
|
||||||
|
transactionWithdraw: 'TRANSACTION (WITHDRAW)',
|
||||||
|
activePlayer: 'ACTIVE PLAYER',
|
||||||
|
firstDeposit: 'FIRST DEPOSIT',
|
||||||
|
unclaimReceipt: 'UNCLAIM RECEIPT',
|
||||||
|
unclaimAmount: 'UNCLAIM AMOUNT',
|
||||||
|
depositWithdraw: 'Deposit & Withdraw',
|
||||||
|
transactionActive: 'Transaction & Active',
|
||||||
|
download: 'Download',
|
||||||
|
months: {
|
||||||
|
jan: 'JAN',
|
||||||
|
feb: 'FEB',
|
||||||
|
mar: 'MAR',
|
||||||
|
apr: 'APR',
|
||||||
|
may: 'MAY',
|
||||||
|
jun: 'JUN',
|
||||||
|
jul: 'JUL',
|
||||||
|
aug: 'AUG',
|
||||||
|
sep: 'SEP',
|
||||||
|
oct: 'OCT',
|
||||||
|
nov: 'NOV',
|
||||||
|
dec: 'DEC',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,4 +30,33 @@ export default {
|
|||||||
1004 : 'Plinko Ball'
|
1004 : 'Plinko Ball'
|
||||||
},
|
},
|
||||||
'bank_id': '银行账户',
|
'bank_id': '银行账户',
|
||||||
|
annualReport: {
|
||||||
|
title: '年度报表',
|
||||||
|
year: '全年',
|
||||||
|
deposit: '存款',
|
||||||
|
withdraw: '提款',
|
||||||
|
transactionDeposit: '交易(存款)',
|
||||||
|
transactionWithdraw: '交易(提款)',
|
||||||
|
activePlayer: '活跃玩家',
|
||||||
|
firstDeposit: '首次存款',
|
||||||
|
unclaimReceipt: '未认领收据',
|
||||||
|
unclaimAmount: '未认领金额',
|
||||||
|
depositWithdraw: '存款与提款',
|
||||||
|
transactionActive: '交易与活跃玩家',
|
||||||
|
download: '下载',
|
||||||
|
months: {
|
||||||
|
jan: '一月',
|
||||||
|
feb: '二月',
|
||||||
|
mar: '三月',
|
||||||
|
apr: '四月',
|
||||||
|
may: '五月',
|
||||||
|
jun: '六月',
|
||||||
|
jul: '七月',
|
||||||
|
aug: '八月',
|
||||||
|
sep: '九月',
|
||||||
|
oct: '十月',
|
||||||
|
nov: '十一月',
|
||||||
|
dec: '十二月',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,282 +1,410 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="default-main ba-table-box">
|
<div class="default-main annual-report">
|
||||||
<el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info" show-icon />
|
<div class="report-heading">
|
||||||
|
<h1>{{ t('user.moneyLog.annualReport.title') }}</h1>
|
||||||
|
<el-select v-model="selectedYear" class="year-select" @change="loadReport">
|
||||||
|
<el-option v-for="year in yearOptions" :key="year" :label="year" :value="year" />
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<TableHeader
|
<div v-loading="loading" class="report-content">
|
||||||
:buttons="['refresh', 'add', 'delete', 'comSearch', 'quickSearch', 'columnDisplay']"
|
<div class="report-table-wrap">
|
||||||
:quick-search-placeholder="
|
<table class="report-table">
|
||||||
t('Quick search placeholder', { fields: t('user.moneyLog.User name') + '/' + t('user.moneyLog.User nickname') })
|
<thead>
|
||||||
"
|
<tr>
|
||||||
>
|
<th></th>
|
||||||
<el-button v-if="!isEmpty(state.userInfo)" v-blur class="table-header-operate">
|
<th v-for="month in monthLabels" :key="month">{{ month }}</th>
|
||||||
<span class="table-header-operate-text">
|
<th>{{ t('user.moneyLog.annualReport.year') }}</th>
|
||||||
{{ state.userInfo.username + '(ID:' + state.userInfo.id + ') ' + t('user.moneyLog.balance') + ':' + state.userInfo.money }}
|
</tr>
|
||||||
</span>
|
</thead>
|
||||||
</el-button>
|
<tbody>
|
||||||
</TableHeader>
|
<tr v-for="metric in metrics" :key="metric.key">
|
||||||
|
<th>{{ t(metric.label) }}</th>
|
||||||
|
<td v-for="(value, index) in reportData[metric.key]" :key="index">
|
||||||
|
{{ formatValue(value, metric.currency) }}
|
||||||
|
</td>
|
||||||
|
<td class="year-total">{{ formatValue(reportTotals[metric.key], metric.currency) }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Table />
|
<div class="chart-card">
|
||||||
|
<h2>{{ selectedYear }} {{ t('user.moneyLog.annualReport.depositWithdraw') }}</h2>
|
||||||
|
<div ref="depositChartRef" class="report-chart"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<PopupForm />
|
<div class="chart-card">
|
||||||
|
<h2>{{ selectedYear }} {{ t('user.moneyLog.annualReport.transactionActive') }}</h2>
|
||||||
<el-dialog v-model="historyDialog.visible" title="Transaction Edit History" width="720px">
|
<div ref="transactionChartRef" class="report-chart"></div>
|
||||||
<p class="dialog-note">Transaction edit history is only kept for the most recent 12 months.</p>
|
</div>
|
||||||
<p class="dialog-note">Transaction 的编辑历史记录仅保存最近 12 个月。</p>
|
</div>
|
||||||
<el-table v-loading="historyDialog.loading" :data="historyDialog.rows" border size="small" empty-text="No Record">
|
|
||||||
<el-table-column prop="id" label="Tx ID" width="100" />
|
|
||||||
<el-table-column prop="editedBy" label="Edit By" width="120" />
|
|
||||||
<el-table-column prop="editedTime" label="Edit Time" width="170" />
|
|
||||||
<el-table-column prop="changes" label="Changes (Old → New)" />
|
|
||||||
</el-table>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="historyDialog.visible = false">CANCEL</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { debounce, isEmpty, parseInt } from 'lodash-es'
|
import * as echarts from 'echarts'
|
||||||
import { provide, reactive, watch } from 'vue'
|
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useRoute } from 'vue-router'
|
import { annualReport } from '/@/api/backend/user/moneyLog'
|
||||||
import PopupForm from './popupForm.vue'
|
|
||||||
import { add, annualReport, url } from '/@/api/backend/user/moneyLog' // 🌟 已修复:移除了别名前面的绝对斜杠
|
|
||||||
import { baTableApi } from '/@/api/common'
|
|
||||||
import TableHeader from '/@/components/table/header/index.vue'
|
|
||||||
import Table from '/@/components/table/index.vue'
|
|
||||||
import baTableClass from '/@/utils/baTable'
|
|
||||||
import scoreLog from '/@/lang/backend/zh-cn/user/scoreLog'
|
|
||||||
import { defaultOptButtons } from '/@/components/table'
|
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'user/moneyLog',
|
name: 'user/moneyLog/annualReport',
|
||||||
})
|
})
|
||||||
|
|
||||||
const { t, tm } = useI18n()
|
type MetricKey =
|
||||||
const route = useRoute()
|
| 'deposit'
|
||||||
const defalutUser = (route.query.user_id ?? '') as string
|
| 'withdraw'
|
||||||
const state = reactive({
|
| 'transactionDeposit'
|
||||||
userInfo: {} as anyObj,
|
| 'transactionWithdraw'
|
||||||
})
|
| 'activePlayer'
|
||||||
interface HistoryRow {
|
| 'firstDeposit'
|
||||||
id: number | string
|
| 'unclaimReceipt'
|
||||||
editedBy: string
|
| 'unclaimAmount'
|
||||||
editedTime: string
|
|
||||||
changes: string
|
type ReportData = Record<MetricKey, number[]>
|
||||||
|
type ReportTotals = Record<MetricKey, number>
|
||||||
|
|
||||||
|
interface ReportTableRow {
|
||||||
|
title: string
|
||||||
|
year_total: number | string
|
||||||
|
[key: `month_${number}`]: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
const historyDialog = reactive({
|
const { locale, t } = useI18n()
|
||||||
visible: false,
|
const currentYear = new Date().getFullYear()
|
||||||
loading: false,
|
const selectedYear = ref(currentYear)
|
||||||
rows: [] as HistoryRow[],
|
const loading = ref(false)
|
||||||
})
|
const depositChartRef = ref<HTMLElement>()
|
||||||
const gameTypeMap = scoreLog.game_type as Record<string, string>
|
const transactionChartRef = ref<HTMLElement>()
|
||||||
const optButtons: OptButton[] = [
|
let depositChart: echarts.ECharts | undefined
|
||||||
{
|
let transactionChart: echarts.ECharts | undefined
|
||||||
render: 'tipButton',
|
|
||||||
name: 'history',
|
const monthLabels = computed(() => [
|
||||||
title: 'History',
|
t('user.moneyLog.annualReport.months.jan'),
|
||||||
text: '',
|
t('user.moneyLog.annualReport.months.feb'),
|
||||||
type: 'primary',
|
t('user.moneyLog.annualReport.months.mar'),
|
||||||
icon: 'fa fa-history',
|
t('user.moneyLog.annualReport.months.apr'),
|
||||||
class: 'table-row-history',
|
t('user.moneyLog.annualReport.months.may'),
|
||||||
disabledTip: false,
|
t('user.moneyLog.annualReport.months.jun'),
|
||||||
click: (row: TableRow) => {
|
t('user.moneyLog.annualReport.months.jul'),
|
||||||
openHistory(row)
|
t('user.moneyLog.annualReport.months.aug'),
|
||||||
},
|
t('user.moneyLog.annualReport.months.sep'),
|
||||||
},
|
t('user.moneyLog.annualReport.months.oct'),
|
||||||
...defaultOptButtons(['edit']),
|
t('user.moneyLog.annualReport.months.nov'),
|
||||||
...defaultOptButtons(['delete']),
|
t('user.moneyLog.annualReport.months.dec'),
|
||||||
|
])
|
||||||
|
|
||||||
|
const metrics: { key: MetricKey; label: string; currency: boolean }[] = [
|
||||||
|
{ key: 'deposit', label: 'user.moneyLog.annualReport.deposit', currency: true },
|
||||||
|
{ key: 'withdraw', label: 'user.moneyLog.annualReport.withdraw', currency: true },
|
||||||
|
{ key: 'transactionDeposit', label: 'user.moneyLog.annualReport.transactionDeposit', currency: false },
|
||||||
|
{ key: 'transactionWithdraw', label: 'user.moneyLog.annualReport.transactionWithdraw', currency: false },
|
||||||
|
{ key: 'activePlayer', label: 'user.moneyLog.annualReport.activePlayer', currency: false },
|
||||||
|
{ key: 'firstDeposit', label: 'user.moneyLog.annualReport.firstDeposit', currency: false },
|
||||||
|
{ key: 'unclaimReceipt', label: 'user.moneyLog.annualReport.unclaimReceipt', currency: false },
|
||||||
|
{ key: 'unclaimAmount', label: 'user.moneyLog.annualReport.unclaimAmount', currency: true },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const createEmptyReport = (): ReportData => ({
|
||||||
|
deposit: Array(12).fill(0),
|
||||||
|
withdraw: Array(12).fill(0),
|
||||||
|
transactionDeposit: Array(12).fill(0),
|
||||||
|
transactionWithdraw: Array(12).fill(0),
|
||||||
|
activePlayer: Array(12).fill(0),
|
||||||
|
firstDeposit: Array(12).fill(0),
|
||||||
|
unclaimReceipt: Array(12).fill(0),
|
||||||
|
unclaimAmount: Array(12).fill(0),
|
||||||
|
})
|
||||||
|
|
||||||
|
const createEmptyTotals = (): ReportTotals => ({
|
||||||
|
deposit: 0,
|
||||||
|
withdraw: 0,
|
||||||
|
transactionDeposit: 0,
|
||||||
|
transactionWithdraw: 0,
|
||||||
|
activePlayer: 0,
|
||||||
|
firstDeposit: 0,
|
||||||
|
unclaimReceipt: 0,
|
||||||
|
unclaimAmount: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
const reportData = reactive<ReportData>(createEmptyReport())
|
||||||
|
const reportTotals = reactive<ReportTotals>(createEmptyTotals())
|
||||||
|
const yearOptions = computed(() => Array.from({ length: 8 }, (_, index) => currentYear - index))
|
||||||
|
|
||||||
|
const titleMetricMap: Record<string, MetricKey> = {
|
||||||
|
DEPOSIT: 'deposit',
|
||||||
|
WITHDRAW: 'withdraw',
|
||||||
|
'TRANSACTION (DEPOSIT)': 'transactionDeposit',
|
||||||
|
'TRANSACTION (WITHDRAW)': 'transactionWithdraw',
|
||||||
|
'ACTIVE PLAYER': 'activePlayer',
|
||||||
|
'FIRST DEPOSIT': 'firstDeposit',
|
||||||
|
'UNCLAIM RECEIPT': 'unclaimReceipt',
|
||||||
|
'UNCLAIM AMOUNT': 'unclaimAmount',
|
||||||
|
}
|
||||||
|
|
||||||
const toNumber = (value: unknown) => {
|
const toNumber = (value: unknown) => {
|
||||||
const number = Number(value)
|
const number = Number(value)
|
||||||
return Number.isFinite(number) ? number : 0
|
return Number.isFinite(number) ? number : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatDateTime = (value: unknown) => {
|
const normalizeReport = (responseData: any) => {
|
||||||
if (typeof value === 'string' && value.trim() && !Number.isFinite(Number(value))) {
|
const data = createEmptyReport()
|
||||||
return value
|
const totals = createEmptyTotals()
|
||||||
}
|
const reportTable = responseData?.report_table ?? responseData?.data?.report_table
|
||||||
|
|
||||||
const timestamp = toNumber(value)
|
if (!Array.isArray(reportTable)) return { data, totals }
|
||||||
if (!timestamp) return ''
|
|
||||||
|
|
||||||
const date = new Date(timestamp * 1000)
|
reportTable.forEach((row: ReportTableRow) => {
|
||||||
const pad = (number: number) => number.toString().padStart(2, '0')
|
const key = titleMetricMap[String(row.title || '').trim().toUpperCase()]
|
||||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
if (!key) return
|
||||||
}
|
|
||||||
|
|
||||||
const stringifyChange = (history: Record<string, unknown>) => {
|
data[key] = Array.from({ length: 12 }, (_, index) => toNumber(row[`month_${index + 1}`]))
|
||||||
if (history.bank_befter !== undefined || history.bank_after !== undefined) {
|
totals[key] = toNumber(row.year_total)
|
||||||
return `Bank:${history.bank_befter ?? ''}→${history.bank_after ?? ''}`
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.stringify(history)
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapHistory = (history: Record<string, unknown>): HistoryRow => ({
|
|
||||||
id: (history.id || history.money_log_id || '') as number | string,
|
|
||||||
editedBy: String(history.admin_name || ''),
|
|
||||||
editedTime: formatDateTime(history.create_time),
|
|
||||||
changes: stringifyChange(history),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const openHistory = (row: TableRow) => {
|
return { data, totals }
|
||||||
historyDialog.visible = true
|
|
||||||
historyDialog.loading = true
|
|
||||||
historyDialog.rows = []
|
|
||||||
|
|
||||||
annualReport({ id: row.id })
|
|
||||||
.then((res) => {
|
|
||||||
const data = Array.isArray(res.data) ? res.data : res.data?.list
|
|
||||||
historyDialog.rows = Array.isArray(data) ? data.map((item) => mapHistory(item as Record<string, unknown>)) : []
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
historyDialog.loading = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🌟 核心修改点:在实例化之前强行改掉 API 的 index 映射路径
|
const formatValue = (value: number, currency: boolean) =>
|
||||||
const myTableApi = new baTableApi(url)
|
new Intl.NumberFormat(undefined, {
|
||||||
myTableApi.actionUrl.set('index', 'admin/user.MoneyLog/annualReport')
|
minimumFractionDigits: currency ? 2 : 0,
|
||||||
|
maximumFractionDigits: currency ? 2 : 0,
|
||||||
|
}).format(value)
|
||||||
|
|
||||||
const baTable = new baTableClass(
|
const chartBaseOption = (): echarts.EChartsOption => ({
|
||||||
myTableApi, // 🌟 传入已经被提前覆写好映射的驱动实例
|
animationDuration: 500,
|
||||||
{
|
grid: { left: 58, right: 24, top: 52, bottom: 70 },
|
||||||
column: [
|
toolbox: {
|
||||||
{ type: 'selection', align: 'center', operator: false },
|
right: 14,
|
||||||
{
|
feature: { saveAsImage: { title: t('user.moneyLog.annualReport.download') } },
|
||||||
label: t('user.moneyLog.Created by'),
|
|
||||||
prop: 'admin.username',
|
|
||||||
align: 'center',
|
|
||||||
width: 70,
|
|
||||||
formatter: (row: TableRow) => {
|
|
||||||
return row.admin?.username || 'web'
|
|
||||||
},
|
},
|
||||||
|
tooltip: { trigger: 'axis' },
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
boundaryGap: false,
|
||||||
|
data: monthLabels.value,
|
||||||
|
axisLine: { lineStyle: { color: '#d8d8d8' } },
|
||||||
|
axisLabel: { color: '#777' },
|
||||||
},
|
},
|
||||||
{ label: t('user.moneyLog.User name'), prop: 'user.jk_username', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
yAxis: {
|
||||||
{ label: t('user.moneyLog.Change balance'), prop: 'money', align: 'center', operator: 'RANGE', sortable: 'custom' },
|
type: 'value',
|
||||||
{ label: t('user.moneyLog.bank_id'), prop: 'bank.bank_name', align: 'center', operator: 'LIKE', operatorPlaceholder: t('Fuzzy query') },
|
splitLine: { lineStyle: { color: '#ededed' } },
|
||||||
{ label: t('user.moneyLog.Transaction id'), prop: 'transaction_id', align: 'center', operator: 'RANGE' },
|
axisLabel: { color: '#777' },
|
||||||
{
|
},
|
||||||
label: t('user.moneyLog.Game Ticket'),
|
dataZoom: [{ type: 'slider', height: 18, bottom: 14, start: 0, end: 100 }, { type: 'inside' }],
|
||||||
prop: 'scoreLog',
|
|
||||||
align: 'center',
|
|
||||||
formatter: (row: TableRow) => {
|
|
||||||
if (!row.scoreLog || row.scoreLog.length === 0) return '-'
|
|
||||||
return row.scoreLog
|
|
||||||
.map((item: any) => {
|
|
||||||
const gameName = gameTypeMap[String(item.game_type)] || item.game_type
|
|
||||||
return `${gameName}: ${item.score}`
|
|
||||||
})
|
})
|
||||||
.join(' | ')
|
|
||||||
},
|
const renderCharts = () => {
|
||||||
|
if (depositChartRef.value) {
|
||||||
|
depositChart ||= echarts.init(depositChartRef.value)
|
||||||
|
depositChart.setOption({
|
||||||
|
...chartBaseOption(),
|
||||||
|
legend: { top: 10, data: [t('user.moneyLog.annualReport.deposit'), t('user.moneyLog.annualReport.withdraw')] },
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: t('user.moneyLog.annualReport.deposit'),
|
||||||
|
type: 'line',
|
||||||
|
smooth: true,
|
||||||
|
symbolSize: 6,
|
||||||
|
data: reportData.deposit,
|
||||||
|
itemStyle: { color: '#32b36b' },
|
||||||
|
lineStyle: { width: 2 },
|
||||||
|
areaStyle: { color: 'rgba(50, 179, 107, 0.22)' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('user.moneyLog.type'),
|
name: t('user.moneyLog.annualReport.withdraw'),
|
||||||
prop: 'type',
|
type: 'line',
|
||||||
align: 'center',
|
smooth: true,
|
||||||
operator: 'eq',
|
symbolSize: 6,
|
||||||
sortable: false,
|
data: reportData.withdraw,
|
||||||
render: 'tag',
|
itemStyle: { color: '#ef5b5b' },
|
||||||
custom: {
|
lineStyle: { width: 2 },
|
||||||
'1': 'success',
|
areaStyle: { color: 'rgba(239, 91, 91, 0.18)' },
|
||||||
'2': 'danger',
|
|
||||||
'3': 'success',
|
|
||||||
'4': 'danger',
|
|
||||||
},
|
},
|
||||||
replaceValue: { ...tm('user.moneyLog.type_list') },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('user.moneyLog.remarks'),
|
|
||||||
prop: 'memo',
|
|
||||||
align: 'center',
|
|
||||||
operator: 'LIKE',
|
|
||||||
operatorPlaceholder: t('Fuzzy query'),
|
|
||||||
showOverflowTooltip: true,
|
|
||||||
},
|
|
||||||
{ label: t('Create time'), prop: 'create_time', align: 'center', render: 'datetime', sortable: 'custom', operator: 'RANGE', width: 160 },
|
|
||||||
{ label: t('Operate'), align: 'center', width: '130', render: 'buttons', buttons: optButtons },
|
|
||||||
],
|
],
|
||||||
dblClickNotEditColumn: ['all'],
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionChartRef.value) {
|
||||||
|
transactionChart ||= echarts.init(transactionChartRef.value)
|
||||||
|
transactionChart.setOption({
|
||||||
|
...chartBaseOption(),
|
||||||
|
xAxis: { ...(chartBaseOption().xAxis as object), boundaryGap: true },
|
||||||
|
legend: {
|
||||||
|
top: 10,
|
||||||
|
data: [
|
||||||
|
t('user.moneyLog.annualReport.activePlayer'),
|
||||||
|
t('user.moneyLog.annualReport.transactionDeposit'),
|
||||||
|
t('user.moneyLog.annualReport.transactionWithdraw'),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
name: t('user.moneyLog.annualReport.activePlayer'),
|
||||||
|
type: 'bar',
|
||||||
|
data: reportData.activePlayer,
|
||||||
|
itemStyle: { color: '#4f8edc' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
defaultItems: {
|
name: t('user.moneyLog.annualReport.transactionDeposit'),
|
||||||
user_id: defalutUser,
|
type: 'bar',
|
||||||
memo: '',
|
data: reportData.transactionDeposit,
|
||||||
|
itemStyle: { color: '#32b36b' },
|
||||||
},
|
},
|
||||||
}
|
{
|
||||||
)
|
name: t('user.moneyLog.annualReport.transactionWithdraw'),
|
||||||
|
type: 'bar',
|
||||||
// 表单提交后
|
data: reportData.transactionWithdraw,
|
||||||
baTable.after.onSubmit = () => {
|
itemStyle: { color: '#f2b441' },
|
||||||
getUserInfo(baTable.comSearch.form.user_id)
|
},
|
||||||
}
|
],
|
||||||
baTable.after.onTableHeaderAction = ({ event }) => {
|
|
||||||
if (event == 'refresh') {
|
|
||||||
getUserInfo(baTable.comSearch.form.user_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
baTable.before.onTableAction = ({ event }) => {
|
|
||||||
// 公共搜索逻辑
|
|
||||||
if (event === 'com-search') {
|
|
||||||
baTable.table.filter!.search = baTable.getComSearchData()
|
|
||||||
|
|
||||||
for (const key in baTable.table.filter!.search) {
|
|
||||||
if (['money', 'before', 'after'].includes(baTable.table.filter!.search[key].field)) {
|
|
||||||
const val = (baTable.table.filter!.search[key].val as string).split(',')
|
|
||||||
const newVal: (string | number)[] = []
|
|
||||||
for (const k in val) {
|
|
||||||
newVal.push(isNaN(parseFloat(val[k])) ? '' : parseFloat(val[k]) * 100)
|
|
||||||
}
|
|
||||||
baTable.table.filter!.search[key].val = newVal.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
baTable.onTableHeaderAction('refresh', { event: 'com-search', data: baTable.table.filter!.search })
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果年报接口返回了特殊的聚合统计数据(如 search_result),在这里捕获存进表格
|
|
||||||
baTable.after.onTableAction = ({ event, res }) => {
|
|
||||||
if (event === 'get-data' && res && res.data) {
|
|
||||||
if (res.data.search_result) {
|
|
||||||
baTable.table.extend = {
|
|
||||||
...baTable.table.extend,
|
|
||||||
searchResult: res.data.search_result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
baTable.mount()
|
|
||||||
baTable.getData()
|
|
||||||
|
|
||||||
provide('baTable', baTable)
|
|
||||||
|
|
||||||
const getUserInfo = debounce((userId: string) => {
|
|
||||||
if (userId && parseInt(userId) > 0) {
|
|
||||||
add(userId).then((res) => {
|
|
||||||
state.userInfo = res.data.user
|
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
state.userInfo = {}
|
|
||||||
}
|
}
|
||||||
}, 300)
|
|
||||||
|
|
||||||
getUserInfo(baTable.comSearch.form.user_id)
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => baTable.comSearch.form.user_id,
|
|
||||||
(newVal) => {
|
|
||||||
baTable.form.defaultItems!.user_id = newVal
|
|
||||||
getUserInfo(newVal)
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
const loadReport = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const response = await annualReport({ year: selectedYear.value })
|
||||||
|
const normalized = normalizeReport(response.data)
|
||||||
|
Object.assign(reportData, normalized.data)
|
||||||
|
Object.assign(reportTotals, normalized.totals)
|
||||||
|
await nextTick()
|
||||||
|
renderCharts()
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const resizeCharts = () => {
|
||||||
|
depositChart?.resize()
|
||||||
|
transactionChart?.resize()
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(locale, async () => {
|
||||||
|
await nextTick()
|
||||||
|
renderCharts()
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
window.addEventListener('resize', resizeCharts)
|
||||||
|
loadReport()
|
||||||
|
})
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener('resize', resizeCharts)
|
||||||
|
depositChart?.dispose()
|
||||||
|
transactionChart?.dispose()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss"></style>
|
<style scoped lang="scss">
|
||||||
|
.annual-report {
|
||||||
|
padding: 22px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.year-select {
|
||||||
|
width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-content {
|
||||||
|
min-height: 420px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-table-wrap {
|
||||||
|
overflow-x: auto;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-table {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 1080px;
|
||||||
|
border-collapse: collapse;
|
||||||
|
table-layout: fixed;
|
||||||
|
font-size: 12px;
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
height: 39px;
|
||||||
|
padding: 5px 7px;
|
||||||
|
border: 1px solid #dedede;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead th {
|
||||||
|
background: #f7f7f7;
|
||||||
|
color: #555;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead th:first-child {
|
||||||
|
width: 178px;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody th {
|
||||||
|
background: #fafafa;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 18px;
|
||||||
|
white-space: normal;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.year-total {
|
||||||
|
background: #fafafa;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-card {
|
||||||
|
margin-bottom: 18px;
|
||||||
|
border: 1px solid #dedede;
|
||||||
|
background: #fff;
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border-bottom: 1px solid #e5e5e5;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-chart {
|
||||||
|
width: 100%;
|
||||||
|
height: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.annual-report {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-heading h1 {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-chart {
|
||||||
|
height: 260px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user