优化页面不显示小数
This commit is contained in:
@@ -71,6 +71,16 @@
|
||||
{{ row.direction === 0 ? t('page.search.clockwise') : row.direction === 1 ? t('page.search.anticlockwise') : '-' }}
|
||||
</ElTag>
|
||||
</template>
|
||||
<!-- 平台币相关:统一整数显示 -->
|
||||
<template #win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.win_coin) }}</span>
|
||||
</template>
|
||||
<template #super_win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.super_win_coin) }}</span>
|
||||
</template>
|
||||
<template #reward_win_coin="{ row }">
|
||||
<span>{{ formatPlatformCoin(row?.reward_win_coin) }}</span>
|
||||
</template>
|
||||
<!-- 摇取点数 tag -->
|
||||
<template #roll_array="{ row }">
|
||||
<ElTag size="small">
|
||||
@@ -166,6 +176,13 @@
|
||||
return String(val)
|
||||
}
|
||||
|
||||
function formatPlatformCoin(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return String(Math.trunc(n))
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
@@ -202,9 +219,9 @@
|
||||
{ prop: 'ante', label: 'page.table.ante', width: 80, align: 'center' },
|
||||
{ prop: 'paid_amount', label: 'page.table.paidAmount', width: 110, align: 'center' },
|
||||
{ prop: 'is_win', label: 'page.table.isBigWin', width: 100, useSlot: true },
|
||||
{ prop: 'win_coin', label: 'page.table.winCoin', width: 110 },
|
||||
{ prop: 'super_win_coin', label: 'page.table.superWinCoin', width: 120 },
|
||||
{ prop: 'reward_win_coin', label: 'page.table.rewardWinCoin', width: 140 },
|
||||
{ prop: 'win_coin', label: 'page.table.winCoin', width: 110, useSlot: true },
|
||||
{ prop: 'super_win_coin', label: 'page.table.superWinCoin', width: 120, useSlot: true },
|
||||
{ prop: 'reward_win_coin', label: 'page.table.rewardWinCoin', width: 140, useSlot: true },
|
||||
{ prop: 'direction', label: 'page.table.direction', width: 90, useSlot: true },
|
||||
{ prop: 'start_index', label: 'page.table.startIndex', width: 90 },
|
||||
{ prop: 'target_index', label: 'page.table.targetIndex', width: 90 },
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.win_coin"
|
||||
:placeholder="$t('page.form.placeholderWinCoin')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
/>
|
||||
@@ -79,7 +79,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.super_win_coin"
|
||||
:placeholder="$t('page.form.placeholderSuperWinCoin')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
@@ -89,7 +89,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.reward_win_coin"
|
||||
:placeholder="$t('page.form.placeholderRewardWinCoin')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
:min="0"
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_min"
|
||||
:placeholder="$t('table.searchBar.min')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
@@ -56,7 +56,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.win_coin_max"
|
||||
:placeholder="$t('table.searchBar.max')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
class="range-input"
|
||||
/>
|
||||
|
||||
@@ -146,6 +146,13 @@
|
||||
return player?.username ?? row.player_id ?? '-'
|
||||
}
|
||||
|
||||
function formatInteger(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return String(Math.trunc(n))
|
||||
}
|
||||
|
||||
// 表格配置
|
||||
const {
|
||||
columns,
|
||||
@@ -190,8 +197,20 @@
|
||||
align: 'center',
|
||||
formatter: operatorFormatter
|
||||
},
|
||||
{ prop: 'wallet_before', label: 'page.table.walletBefore', width: 110, align: 'center' },
|
||||
{ prop: 'wallet_after', label: 'page.table.walletAfter', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'wallet_before',
|
||||
label: 'page.table.walletBefore',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: (row: Record<string, any>) => formatInteger(row?.wallet_before)
|
||||
},
|
||||
{
|
||||
prop: 'wallet_after',
|
||||
label: 'page.table.walletAfter',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: (row: Record<string, any>) => formatInteger(row?.wallet_after)
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
label: 'page.table.remark',
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.coin"
|
||||
:placeholder="$t('page.form.placeholderCoinChange')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
@change="onCoinChange"
|
||||
:disabled="dialogType === 'edit'"
|
||||
@@ -55,7 +55,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.wallet_before"
|
||||
:placeholder="$t('page.form.placeholderWalletBefore')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
disabled
|
||||
style="width: 100%"
|
||||
/>
|
||||
@@ -64,7 +64,7 @@
|
||||
<el-input-number
|
||||
v-model="formData.wallet_after"
|
||||
:placeholder="$t('page.form.placeholderWalletAfter')"
|
||||
:precision="2"
|
||||
:precision="0"
|
||||
disabled
|
||||
style="width: 100%"
|
||||
/>
|
||||
@@ -131,14 +131,22 @@
|
||||
type: [{ required: true, message: '请选择类型', trigger: 'change' }]
|
||||
})
|
||||
|
||||
const initialFormData = {
|
||||
id: null as number | null,
|
||||
player_id: null as number | null,
|
||||
coin: 0 as number,
|
||||
type: null as number | null,
|
||||
wallet_before: 0 as number,
|
||||
wallet_after: 0 as number,
|
||||
remark: '' as string
|
||||
const initialFormData: {
|
||||
id: number | null
|
||||
player_id: number | null
|
||||
coin: number
|
||||
type: number | null
|
||||
wallet_before: number
|
||||
wallet_after: number
|
||||
remark: string
|
||||
} = {
|
||||
id: null,
|
||||
player_id: null,
|
||||
coin: 0,
|
||||
type: null,
|
||||
wallet_before: 0,
|
||||
wallet_after: 0,
|
||||
remark: ''
|
||||
}
|
||||
|
||||
const formData = reactive({ ...initialFormData })
|
||||
@@ -170,7 +178,7 @@
|
||||
function calcWalletAfter() {
|
||||
const before = Number(formData.wallet_before) || 0
|
||||
const coin = Number(formData.coin) || 0
|
||||
formData.wallet_after = Math.round((before + coin) * 100) / 100
|
||||
formData.wallet_after = Math.trunc(before + coin)
|
||||
}
|
||||
|
||||
watch(
|
||||
@@ -196,23 +204,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
const numKeys = ['id', 'player_id', 'coin', 'type', 'wallet_before', 'wallet_after']
|
||||
function normalizeInteger(val: unknown, fallback: number): number {
|
||||
if (val === '' || val === null || val === undefined) return fallback
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return fallback
|
||||
return Math.trunc(n)
|
||||
}
|
||||
|
||||
const initForm = () => {
|
||||
if (!props.data) return
|
||||
for (const key of Object.keys(formData)) {
|
||||
if (!(key in props.data)) continue
|
||||
const val = props.data[key]
|
||||
if (numKeys.includes(key)) {
|
||||
if (key === 'id' || key === 'player_id' || key === 'type') {
|
||||
;(formData as any)[key] = val != null && val !== '' ? Number(val) : null
|
||||
} else {
|
||||
;(formData as any)[key] = val != null && val !== '' ? Number(val) : 0
|
||||
}
|
||||
} else {
|
||||
;(formData as any)[key] = val ?? ''
|
||||
}
|
||||
}
|
||||
|
||||
formData.id = props.data.id != null && props.data.id !== '' ? Number(props.data.id) : null
|
||||
formData.player_id =
|
||||
props.data.player_id != null && props.data.player_id !== '' ? Number(props.data.player_id) : null
|
||||
formData.type = props.data.type != null && props.data.type !== '' ? Number(props.data.type) : null
|
||||
formData.coin = normalizeInteger(props.data.coin, 0)
|
||||
formData.wallet_before = normalizeInteger(props.data.wallet_before, 0)
|
||||
formData.wallet_after = normalizeInteger(props.data.wallet_after, 0)
|
||||
formData.remark = props.data.remark ?? ''
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
|
||||
@@ -70,6 +70,13 @@
|
||||
return api.list({ ...params, direction: currentDirection.value })
|
||||
}
|
||||
|
||||
function formatInteger(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return String(Math.trunc(n))
|
||||
}
|
||||
|
||||
const handleSearch = (params: Record<string, any>) => {
|
||||
Object.assign(searchParams, { ...params, direction: currentDirection.value })
|
||||
getData()
|
||||
@@ -117,7 +124,13 @@
|
||||
align: 'center',
|
||||
showOverflowTooltip: true
|
||||
},
|
||||
{ prop: 'real_ev', label: 'page.table.realEv', width: 110, align: 'center' },
|
||||
{
|
||||
prop: 'real_ev',
|
||||
label: 'page.table.realEv',
|
||||
width: 110,
|
||||
align: 'center',
|
||||
formatter: (row: Record<string, any>) => formatInteger(row?.real_ev)
|
||||
},
|
||||
{ prop: 'remark', label: 'page.table.remark', minWidth: 80, align: 'center', showOverflowTooltip: true },
|
||||
{ prop: 'weight', label: 'page.table.weight', width: 110, align: 'center' }
|
||||
]
|
||||
|
||||
@@ -60,7 +60,11 @@
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ formatInteger(row?.real_ev) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
@@ -250,6 +254,13 @@
|
||||
import api from '../../../api/reward/index'
|
||||
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
function formatInteger(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return String(Math.trunc(n))
|
||||
}
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -54,7 +54,11 @@
|
||||
width="90"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span>{{ formatInteger(row?.real_ev) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('page.weightShared.colUiText')"
|
||||
prop="ui_text"
|
||||
@@ -315,6 +319,13 @@
|
||||
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
function formatInteger(val: unknown): string {
|
||||
if (val === '' || val === null || val === undefined) return '-'
|
||||
const n = typeof val === 'number' ? val : Number(val)
|
||||
if (!Number.isFinite(n)) return '-'
|
||||
return String(Math.trunc(n))
|
||||
}
|
||||
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user