@@ -2,15 +2,15 @@
< div class = "default-main bookkeeping-dashboard" >
< section class = "dashboard-grid" >
< div class = "dashboard-panel bank-panel" >
< div class = "panel-title" > Available Bank Balance< / div >
< div class = "panel-title" > { { t ( 'dashboard. Available Bank Balance' ) } } < / div >
< div class = "table-scroll" >
< table class = "bank-table" >
< thead >
< tr >
< th > Bank Name< / th >
< th > Current Balance< / th >
< th > Transaction Breakdown< / th >
< th > Safe Alert< / th >
< th > { { t ( 'dashboard. Bank Name' ) } } < / th >
< th > { { t ( 'dashboard. Current Balance' ) } } < / th >
< th > { { t ( 'dashboard. Transaction Breakdown' ) } } < / th >
< th > { { t ( 'dashboard. Safe Alert' ) } } < / th >
< / tr >
< / thead >
< tbody >
@@ -23,7 +23,7 @@
< td >
< div class = "bank-operate" >
< el-button size = "small" :icon = "Coin" circle / >
< el-button size = "small" :icon = "Switch" @click ="openTransfer(bank)" > Transfer < / el -button >
< el-button size = "small" :icon = "Switch" @click ="openTransfer(bank)" > {{ t ( ' dashboard.Transfer ' ) }} < / el -button >
< div class = "breakdown" >
< span > < i class = "dot income" > ↓ < / i > ( { { bank . depositCount } } ) { { money ( bank . deposit ) } } < / span >
< span > < i class = "dot outcome" > ↑ < / i > ( { { bank . withdrawCount } } ) { { money ( bank . withdraw ) } } < / span >
@@ -31,24 +31,26 @@
< / div >
< / td >
< td >
< el-tag size = "small" effect = "plain" : type = "bank.alert ? 'danger' : 'info'" > { { bank . alert || 'No Alert' } } < / el-tag >
< el-tag size = "small" effect = "plain" : type = "bank.alertCode !== '0' ? 'danger' : 'info'" >
{ { safeAlertText ( bank . alertCode ) } }
< / el-tag >
< / td >
< / tr >
< tr v-if = "!visibleBanks.length" >
< td class = "empty-banks" colspan = "4" > No bank data< / td >
< td class = "empty-banks" colspan = "4" > { { t ( 'dashboard.No bank data' ) } } < / td >
< / tr >
< / tbody >
< / table >
< / div >
< button v-if = "banks.length > 4" class="more-info" type="button" @click="showAllBanks = !showAllBanks" >
{{ showAllBanks ? ' s how less ' : ' m ore info ' }}
{{ showAllBanks ? t ( ' dashboard.S how less ' ) : t ( ' dashboard.M ore info ' ) }}
< Icon : name = "showAllBanks ? 'fa fa-caret-up' : 'fa fa-caret-down'" / >
< / button >
< / div >
< aside class = "summary-side" >
< div class = "dashboard-panel summary-panel" >
< div class = "panel-title" > Customer Summary< / div >
< div class = "panel-title" > { { t ( 'dashboard. Customer Summary' ) } } < / div >
< dl >
< template v-for = "item in summary" :key="item.label" >
< dt > { { item . label } } : < / dt >
@@ -56,66 +58,68 @@
< / template >
< / dl >
< / div >
< el-button class = "create-button" type = "success" @click ="openCreate" > CREATE NEW TRANSACTION < / el -button >
< el-button class = "create-button" type = "success" @click ="openCreate" > {{ t ( ' dashboard.Create New Transaction ' ) }} < / el -button >
< / aside >
< / section >
< el-alert class = "webhook-alert" type = "warning" :closable = "true" show -icon >
< template # title >
< strong > The Transaction Mode you currently set has the Webhook ( JDK ) feature enabled < / strong >
< strong > { { t ( 'dashboard.Webhook enabled' ) } } < / strong >
< / template >
< p >
Hint : If a transaction approved in the JK backend is not automatically recorded here within 10 minutes , click "Create New Transaction"
to record it manually .
< / p >
< p > 提示 : 如果 JK 后台 Approved 的 Transaction 在这里 10 分钟内没有自动记录 , 请点击 "Create New Transaction" 手动记录 。 < / p >
< p > { { t ( 'dashboard.Webhook hint' ) } } < / p >
< / el-alert >
< section class = "transaction-section" >
< div class = "filter-row" >
< div class = "date-filter" >
< label > Start Date: < / label >
< label > { { t ( 'dashboard. Start Date' ) } } : < / label >
< el-date-picker v-model = "filters.startDate" type="date" value-format="YYYY-MM-DD" / >
< label > End Date : < / label >
< label > { { t ( 'dashboard.End Date' ) } } : < / label >
< el-date-picker v-model = "filters.endDate" type="date" value-format="YYYY-MM-DD" / >
< el-button @click ="search" > Search < / el -button >
< el-button @click ="setToday" > Today < / el -button >
< el-button @click ="search" > {{ t ( ' Search ' ) }} < / el -button >
< el-button @click ="setToday" > {{ t ( ' dashboard.Today ' ) }} < / el -button >
< / div >
< div class = "totals" >
< span > Date of data : { { dateRangeText } } < / span >
< span > { { t ( 'dashboard.Date of data' ) } } : { { dateRangeText } } < / span >
< b
> Total Deposit / IN : < em > AUD { { money ( totalDeposit ) } } < / em > < / b
> { { t ( 'dashboard. Total Deposit / IN' ) } } : < em > AUD { { money ( totalDeposit ) } } < / em > < / b
>
< b
> Total Withdraw / OUT : < em > AUD { { money ( totalWithdraw ) } } < / em > < / b
> { { t ( 'dashboard. Total Withdraw / OUT' ) } } : < em > AUD { { money ( totalWithdraw ) } } < / em > < / b
>
< / div >
< / div >
< el-table :data = "transactions" border size = "small" class = "transaction-table" :row-class-name = "transactionRowClass" >
< el-table-column prop = "createdBy" label = "Created by" width = "110" / >
< el-table-column prop = "createdTime" label = "Created Time" width = "170" / >
< el-table-column prop = "category" label = " Category" width = "100" / >
< el-table-column prop = "username" label = "Username" width = "110" / >
< el-table-column prop = "remark" label = "Remark" min -width = " 205 " / >
< el-table-column prop = "bank " label= "Bank" min - width =" 165 " / >
< el-table-column prop = "type " label= "Type" width ="95 " / >
< el-table-column label = "Amount (AUD)" width ="130" align = "right" >
< el-table-column prop = "createdBy" : label = "t('dashboard. Created by') " width = "110" / >
< el-table-column prop = "createdTime" : label = "t('dashboard. Created Time') " width = "170" / >
< el-table-column :label = "t('dashboard. Category') " width = "100" >
< template # default = "{ row }" > { { categoryText ( row . categoryId ) } } < / template >
< / el-table-column >
< el-table-column prop = "username " : label= "t('dashboard.Username')" width ="110 " / >
< el-table-column prop = "remark " : label= "t('dashboard.Remark')" min - width =" 205 " / >
< el-table-column prop = "bank" :label = "t('dashboard.Bank')" min - width =" 165 " / >
< el-table-column :label = "t('dashboard.Type')" width = "95" >
< template # default = "{ row }" > { { typeText ( row . typeId ) } } < / template >
< / el-table-column >
< el-table-column : label = "t('dashboard.Amount (AUD)')" width = "130" align = "right" >
< template # default = "{ row }" >
< strong : class = "row.flow === 'in' ? 'amount-in' : 'amount-out'" > { { money ( row . amount ) } } < / strong >
< / template >
< / el-table-column >
< el-table-column prop = "label" label = " Label" width = "100" / >
< el-table-column label = "Game Ticket" min -width = " 140 " >
< el-table-column :label = "t('dashboard. Label') " width = "100" >
< template # default = "{ row }" > { { transactionLabelText ( row . labelId ) } } < / template >
< / el-table-column >
< el-table-column : label = "t('dashboard.Game Ticket')" min -width = " 140 " >
< template # default = "{ row }" >
< div v-for = "(ticket, index) in row.ticket" :key="`${ticket}-${index}`" > {{ ticket }} < / div >
< / template >
< / el -table -column >
< el-table-column label= "Action" fixed = "right" width = "180" >
< el-table-column : label= "t('dashboard. Action') " fixed = "right" width = "180" >
< template # default = "{ row }" >
< el-button link type = "primary" size = "small" @click ="openHistory(row)" > history < / el -button >
< el-button link type = "primary" size = "small" @click ="openEdit(row)" > edit < / el -button >
< el-button link type = "danger" size = "small" @click ="removeTransaction(row)" > delete < / el -button >
< el-button link type = "primary" size = "small" @click ="openHistory(row)" > {{ t ( ' dashboard.History ' ) }} < / el -button >
< el-button link type = "primary" size = "small" @click ="openEdit(row)" > {{ t ( ' Edit ' ) }} < / el -button >
< el-button link type = "danger" size = "small" @click ="removeTransaction(row)" > {{ t ( ' Delete ' ) }} < / el -button >
< / template >
< / el-table-column >
< / el-table >
@@ -132,80 +136,85 @@
< / div >
< / section >
< el-dialog v-model = "transactionDialog.visible" :title="transactionDialog.t itle" width="680px" >
< el-dialog v-model = "transactionDialog.visible" :title="transactionDialogT itle" width="680px" >
< el -form :model = "transactionForm" label -width = " 145px " >
< el-form-item label = "Date & Time" >
< el-form-item : label = "t('dashboard. Date & Time') " >
< el-date-picker v-model = "transactionForm.time" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" / >
< el-radio-group v-model = "transactionForm.timeMode" class="inline-mode" >
< el -radio value = "Auto" > Auto < / el-radio >
< el-radio value = "Manual" > Manual < / el-radio >
< el -radio value = "Auto" > { { t ( 'dashboard.Auto' ) } } < / el-radio >
< el-radio value = "Manual" > { { t ( 'dashboard.Manual' ) } } < / el-radio >
< / el-radio-group >
< / el-form-item >
< el-form-item label= "Category" >
< el-form-item : label= "t('dashboard. Category') " >
< el-select v-model = "transactionForm.category" >
< el -option label= "Customer" :value = "1" / >
< el-option label = "Other Adjust" :value = "2" / >
< el -option : label= "t('dashboard. Customer') " :value = "1" / >
< el-option : label = "t('dashboard. Other Adjust') " :value = "2" / >
< / el-select >
< / el-form-item >
< el-form-item label= "Type" >
< el-form-item : label= "t('dashboard. Type') " >
< el-radio-group v-model = "transactionForm.type" >
< el -radio -button :value = "1" > Deposit < / el-radio-button >
< el-radio-button :value = "2" > Withdraw < / el-radio-button >
< el -radio -button :value = "1" > { { t ( 'dashboard.Deposit' ) } } < / el-radio-button >
< el-radio-button :value = "2" > { { t ( 'dashboard.Withdraw' ) } } < / el-radio-button >
< el-radio-button :value = "3" > IN < / el-radio-button >
< el-radio-button :value = "4" > OUT < / el-radio-button >
< / el-radio-group >
< / el-form-item >
< el-form-item label= "Username" >
< el-input v-model = "transactionForm.username" :disabled="transactionDialog.mode === 'edit'" placeholder="e.g. PLAYER001" / >
< el-form-item : label= "t('dashboard. Username') " >
< el-input
v-model = "transactionForm.username"
: disabled = "transactionDialog.mode === 'edit'"
: placeholder = "t('dashboard.Username placeholder')"
/ >
< / el-form-item >
< el-form-item label= "Remark" >
< el-input v-model = "transactionForm.remark" placeholder="(o ptional)" / >
< el-form-item : label= "t('dashboard. Remark') " >
< el-input v-model = "transactionForm.remark" : placeholder="t('dashboard.O ptional' )" / >
< / el-form-item >
< el-form-item label = "Amount (AUD)" >
< el-form-item : label = "t('dashboard. Amount (AUD)') " >
< el-input-number v-model = "transactionForm.amount" :min="0" :precision="2" / >
< / el-form-item >
< el-form-item label= "Bank" >
< el-select v-model = "transactionForm.bank" placeholder="- (optional) - " >
< el-form-item : label= "t('dashboard. Bank') " >
< el-select v-model = "transactionForm.bank" : placeholder="t('dashboard.Optional select') " >
< el -option v-for = "bank in banks" :key="bank.id" :label="bank.name" :value="bank.id" / >
< / el-select >
< / el-form-item >
< el-form-item label= "Label" >
< el-select v-model = "transactionForm.label" placeholder="- (optional) - " >
< el -option label = "First Deposit" :value = "1" / >
< el-option label= "Unclaim" :value = "2" / >
< el-form-item : label= "t('dashboard. Label') " >
< el-select v-model = "transactionForm.label" : placeholder="t('dashboard.Optional select') " >
< el -option : label = "t('dashboard. First Deposit') " :value = "1" / >
< el-option : label= "t('dashboard. Unclaim') " :value = "2" / >
< / el-select >
< / el-form-item >
< el-form-item label = "Game Ticket Auto" >
< el-checkbox v-model = "transactionForm.ticketAuto" > Auto generate ticket < / el -checkbox >
< el-form-item : label = "t('dashboard. Game Ticket Auto') " >
< el-checkbox v-model = "transactionForm.ticketAuto" > {{ t ( ' dashboard. Auto generate ticket ' ) }} </ el -checkbox >
< / el-form-item >
< / el-form >
< template # footer >
< el-button type = "primary" :loading = "transactionDialog.loading" @click ="submitTransaction" > CONFIRM < / el -button >
< el-button @click ="transactionDialog.visible = false" > CANCEL < / el -button >
< el-button type = "primary" :loading = "transactionDialog.loading" @click ="submitTransaction" > {{ t ( ' Confirm ' ) }} < / el -button >
< el-button @click ="transactionDialog.visible = false" > {{ t ( ' Cancel ' ) }} < / el -button >
< / template >
< / el-dialog >
< el-dialog v-model = "historyDialog.visible" title="Transaction Edit History" width="720px" >
< p class = "dialog-note" > Transaction edit history is only kept for the most recent 12 months . < / p >
< p class = "dialog-note" > Transaction 的编辑历史记录仅保存最近 12 个月 。 < / p >
< 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 = "10 0" / >
< el-table-column prop = "editedBy" label = "Edit By " width = "12 0" / >
< el-table-column prop = "editedTime" label = "Edit Time" width = "170" / >
< el-table-column prop = "changes" label = "Changes (Old → New)" / >
< el-dialog v-model = "historyDialog.visible" : title="t('dashboard. Transaction Edit History') " width="720px" >
< p class = "dialog-note" > { { t ( 'dashboard.History retention note' ) } } < / p >
< el-table v-loading = "historyDialog.loading" :data="historyDialog.rows" border size="small" :empty-text="t('dashboard.No Record')" >
< el -table -column prop = "id" : label = "t('dash boa rd.Tx ID')" width = "100" / >
< el-table-column prop = "editedBy" : label = "t('dashboard.Edit By') " width = "12 0" / >
< el-table-column prop = "editedTime" : label = "t('dashboard.Edit Time') " width = "17 0" / >
< el-table-column :label = "t('dashboard.Changes')" >
< template # default = "{ row }" > { { historyChangeText ( row ) } } < / template >
< / el-table-column >
< / el-table >
< template # footer >
< el-button @click ="historyDialog.visible = false" > CANCEL < / el -button >
< el-button @click ="historyDialog.visible = false" > {{ t ( ' Cancel ' ) }} < / el -button >
< / template >
< / el-dialog >
< el-dialog v-model = "transferDialog.visible" title="Bank Transfer" width="560px" >
< el-dialog v-model = "transferDialog.visible" : title="t('dashboard. Bank Transfer') " width="560px" >
< el -form :model = "transferForm" label -width = " 125px " >
< el-form-item label = "Transfer (From)" >
< el-form-item : label = "t('dashboard. Transfer (From)') " >
< el-input v-model = "transferForm.fromName" disabled / >
< / el-form-item >
< el-form-item label = "Transfer (To)" >
< el-select v-model = "transferForm.bankTo" placeholder="- Select Bank - " >
< el-form-item : label = "t('dashboard. Transfer (To)') " >
< el-select v-model = "transferForm.bankTo" : placeholder="t('dashboard. Select Bank') " >
< el -option
v-for = "bank in banks"
:key = "bank.id"
@@ -215,16 +224,16 @@
/ >
< / el-select >
< / el-form-item >
< el-form-item label= "Amount" >
< el-form-item : label= "t('dashboard. Amount') " >
< el-input-number v-model = "transferForm.money" :min="0" :precision="2" / >
< / el-form-item >
< el-form-item label= "Remark" >
< el-input v-model = "transferForm.remark" placeholder="(o ptional)" / >
< el-form-item : label= "t('dashboard. Remark') " >
< el-input v-model = "transferForm.remark" : placeholder="t('dashboard.O ptional' )" / >
< / el-form-item >
< / el-form >
< template # footer >
< el-button type = "primary" :loading = "transferDialog.loading" @click ="submitBankTransfer" > CONFIRM < / el -button >
< el-button @click ="transferDialog.visible = false" > CANCEL < / el -button >
< el-button type = "primary" :loading = "transferDialog.loading" @click ="submitBankTransfer" > {{ t ( ' Confirm ' ) }} < / el -button >
< el-button @click ="transferDialog.visible = false" > {{ t ( ' Cancel ' ) }} < / el -button >
< / template >
< / el-dialog >
< / div >
@@ -233,6 +242,7 @@
< script setup lang = "ts" >
import { Coin , Switch } from '@element-plus/icons-vue'
import { computed , onMounted , reactive , ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { bankTransact , delTransact , editTransact , index as getDashboard , logHistory , newTransact } from '/@/api/backend/dashboard'
import type { DashboardTransactPayload } from '/@/api/backend/dashboard'
@@ -240,6 +250,8 @@ defineOptions({
name : 'dashboard' ,
} )
const { t } = useI18n ( )
interface Bank {
id : number | string
name : string
@@ -249,7 +261,7 @@ interface Bank {
withdraw : number
depositCount : number
withdrawCount : number
alert? : string
alertCode : string
rowClass ? : string
labelColor ? : string
}
@@ -279,14 +291,15 @@ interface Transaction {
id : number
createdBy : string
createdTime : string
category : string
categoryId : string
username : string
remark : string
bank : string
type : string
bankId : number | string
typeId : string
flow : 'in' | 'out'
amount : number
label : string
labelId : string
ticket : string [ ]
}
@@ -340,7 +353,8 @@ interface HistoryRow {
id : number | string
editedBy : string
editedTime : string
changes : string
bankBefore : string
bankAfter : string
}
const today = ( ) => {
@@ -355,15 +369,6 @@ const money = (value: number) =>
maximumFractionDigits : 2 ,
} )
const safeAlertLabels : Record < string , string > = {
'1' : 'Hourly Alert' ,
'2' : 'Daily Alert' ,
'3' : 'Weekly Alert' ,
'4' : 'Monthly Alert' ,
'5' : 'Yearly Alert' ,
'6' : 'Lifetime Alert' ,
}
const toNumber = ( value : unknown ) => {
const number = Number ( value )
return Number . isFinite ( number ) ? number : 0
@@ -396,7 +401,7 @@ const mapBank = (bank: DashboardBank): Bank => {
withdraw : fundOut ,
depositCount : toNumber ( bank . count _fund _in ? ? bank . deposit _count ? ? bank . tx _in ) ,
withdrawCount : toNumber ( bank . count _fund _out ? ? bank . withdraw _count ? ? bank . tx _out ) ,
alert : safeAlertLabels [ safeAlert ] ,
alertCode : safeAlert ,
rowClass : String ( bank . status ? ? '1' ) === '0' ? 'bank-muted' : '' ,
labelColor : bank . label _color || '' ,
}
@@ -433,26 +438,33 @@ const dateRangeText = computed(() => {
const start = new Date ( ` ${ filters . startDate } T00:00:00 ` )
const end = new Date ( ` ${ filters . endDate } T00:00:00 ` )
const diffDays = Math . max ( 1 , Math . floor ( ( end . getTime ( ) - start . getTime ( ) ) / 86400000 ) + 1 )
return ` ${ filters . startDate } to ${ filters . endDate } ( ${ diffDays } ${ diffDays === 1 ? 'Day' : 'Days' } ) `
return t ( 'dashboard.Date range' , {
start : filters . startDate ,
end : filters . endDate ,
days : diffDays ,
unit : t ( diffDays === 1 ? 'dashboard.Day' : 'dashboard.Days' ) ,
} )
} )
const summary = computed ( ( ) => [
{ label : ' Total Deposit / IN', value : ` AUD ${ money ( totalDeposit . value ) } ` } ,
{ label : ' Total Withdraw / OUT', value : ` AUD ${ money ( totalWithdraw . value ) } ` } ,
{ label : ' Deposit Count', value : customerSummary . countDeposit } ,
{ label : ' Withdraw Count', value : customerSummary . countWithdraw } ,
{ label : ' Active Player', value : customerSummary . activePlayer } ,
{ label : ' First Deposit Player', value : customerSummary . firstDeposit } ,
{ label : ' Unclaimed Amount', value : ` AUD ${ money ( customerSummary . unclaimAmount ) } ` } ,
{ label : ' Unclaimed Receipt', value : customerSummary . unclaimReceipt } ,
{ label : t ( 'dashboard. Total Deposit / IN') , value : ` AUD ${ money ( totalDeposit . value ) } ` } ,
{ label : t ( 'dashboard. Total Withdraw / OUT') , value : ` AUD ${ money ( totalWithdraw . value ) } ` } ,
{ label : t ( 'dashboard. Deposit Count') , value : customerSummary . countDeposit } ,
{ label : t ( 'dashboard. Withdraw Count') , value : customerSummary . countWithdraw } ,
{ label : t ( 'dashboard. Active Player') , value : customerSummary . activePlayer } ,
{ label : t ( 'dashboard. First Deposit Player') , value : customerSummary . firstDeposit } ,
{ label : t ( 'dashboard. Unclaimed Amount') , value : ` AUD ${ money ( customerSummary . unclaimAmount ) } ` } ,
{ label : t ( 'dashboard. Unclaimed Receipt') , value : customerSummary . unclaimReceipt } ,
] )
const transactionDialog = reactive < { visible : boolean ; title : string ; loading : boolean ; mode : 'create' | 'edit' ; editId : number | string | '' } > ( {
const transactionDialog = reactive < { visible : boolean ; loading : boolean ; mode : 'create' | 'edit' ; editId : number | string | '' } > ( {
visible : false ,
title : 'Create New Transaction' ,
loading : false ,
mode : 'create' ,
editId : '' ,
} )
const transactionDialogTitle = computed ( ( ) =>
transactionDialog . mode === 'edit' ? t ( 'dashboard.Edit Transaction' , { id : transactionDialog . editId } ) : t ( 'dashboard.Create New Transaction' )
)
const transactionForm = reactive ( {
time : '' ,
timeMode : 'Auto' ,
@@ -479,38 +491,42 @@ const transferForm = reactive<{ bankFrom: Bank['id'] | ''; fromName: string; ban
remark : '' ,
} )
const typeLabels : Record < string , string> = {
'1' : 'Deposit' ,
'2 ' : 'Withdraw' ,
'3 ' : 'IN' ,
'4 ' : 'OUT' ,
const safeAlertText = ( code : string) => {
const labels : Record < string , string > = {
'1 ' : t ( 'dashboard.Hourly Alert' ) ,
'2 ' : t ( 'dashboard.Daily Alert' ) ,
'3 ' : t ( 'dashboard.Weekly Alert' ) ,
'4' : t ( 'dashboard.Monthly Alert' ) ,
'5' : t ( 'dashboard.Yearly Alert' ) ,
'6' : t ( 'dashboard.Lifetime Alert' ) ,
}
return labels [ code ] || t ( 'dashboard.No Alert' )
}
const categoryLabels : Record < string , string> = {
'1' : 'Customer' ,
'2 ' : 'Other Adjust' ,
const typeText = ( type : string) => {
const labels : Record < string , string > = {
'1 ' : t ( 'dashboard.Deposit' ) ,
'2' : t ( 'dashboard.Withdraw' ) ,
'3' : 'IN' ,
'4' : 'OUT' ,
}
return labels [ type ] || type
}
const transactionLabelTexts : Record < string , string> = {
'1' : 'First Deposit' ,
'2 ' : 'Unclaim' ,
const categoryText = ( category : string) => {
const labels : Record < string , string > = {
'1 ' : t ( 'dashboard.Customer' ) ,
'2' : t ( 'dashboard.Other Adjust' ) ,
}
return labels [ category ] || category
}
const categoryValues : Record < string , number > = {
Customer : 1 ,
'Other Adjust' : 2 ,
}
const typeValues : Record < string , number > = {
Deposit : 1 ,
Withdraw : 2 ,
IN : 3 ,
OUT : 4 ,
}
const labelValues : Record < string , number > = {
'First Deposit' : 1 ,
Unclaim : 2 ,
const transactionLabelText = ( label : string ) => {
const labels : Record < string , string > = {
'1' : t ( 'dashboard.First Deposit' ) ,
'2' : t ( 'dashboard.Unclaim' ) ,
}
return labels [ label ] || ''
}
const mapTransaction = ( transaction : DashboardTransaction ) : Transaction => {
@@ -519,14 +535,15 @@ const mapTransaction = (transaction: DashboardTransaction): Transaction => {
id : transaction . id ,
createdBy : transaction . created _by || '' ,
createdTime : formatDateTime ( transaction . create _time ) ,
category : categoryLabels [ String ( transaction . category ? ? '' ) ] || '' ,
categoryId : String ( transaction . category ? ? '' ) ,
username : transaction . user _name || '' ,
remark : transaction . memo || '' ,
bank : transaction . bank _name || '' ,
type : typeLabels [ type ] || type ,
bankId : transaction . bank _id || '' ,
typeId : type ,
flow : [ '1' , '3' ] . includes ( type ) ? 'in' : 'out' ,
amount : toNumber ( transaction . money ) ,
label : transactionLabelTexts [ String ( transaction . label ? ? '' ) ] || '' ,
labelId : String ( transaction . label ? ? '' ) ,
ticket : Array . isArray ( transaction . scoreLog )
? transaction . scoreLog . map ( ( score ) => ` ${ score . game _type _text || '' } : ${ score . score ? ? '' } ` ) . filter ( ( score ) => score . trim ( ) !== ':' )
: [ ] ,
@@ -579,7 +596,6 @@ const resetTransactionForm = () => {
const openCreate = ( ) => {
resetTransactionForm ( )
transactionDialog . title = 'Create New Transaction'
transactionDialog . mode = 'create'
transactionDialog . editId = ''
transactionDialog . visible = true
@@ -589,16 +605,15 @@ const openEdit = (row: Transaction) => {
Object . assign ( transactionForm , {
time : row . createdTime ,
timeMode : 'Manual' ,
category : categoryValues [ row . category ] || 1 ,
type : typeValues [ row . type ] || 1 ,
category : toNumber ( row . categoryId ) || 1 ,
type : toNumber ( row . typeId ) || 1 ,
username : row . username ,
remark : row . remark ,
amount : row . amount ,
bank : banks . value . find ( ( bank ) => bank . name === row . bank ) ? . id || '' ,
label : labelValues [ row . label ] || '' ,
bank : row . bankId || banks. value . find ( ( bank ) => bank . name === row . bank ) ? . id || '' ,
label : row . labelId ? toNumber ( row . labelId ) : '' ,
ticketAuto : row . ticket . length > 0 ,
} )
transactionDialog . title = ` Edit Transaction # ${ row . id } `
transactionDialog . mode = 'edit'
transactionDialog . editId = row . id
transactionDialog . visible = true
@@ -644,21 +659,16 @@ const submitTransaction = () => {
} )
}
const stringifyChange = ( history : Record < string , unknown > ) => {
if ( history . bank _befter !== undefined || history . bank _after !== undefined ) {
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 : s tringifyChange ( history ) ,
bankBefore : S tring( history . bank _befter ? ? '' ),
bankAfter : String ( history . bank _after ? ? '' ) ,
} )
const historyChangeText = ( row : HistoryRow ) => t ( 'dashboard.Bank change' , { before : row . bankBefore , after : row . bankAfter } )
const openHistory = ( row : Transaction ) => {
historyDialog . visible = true
historyDialog . loading = true