优化导入权重测试数据
This commit is contained in:
@@ -27,6 +27,14 @@
|
||||
<el-descriptions-item label="免费奖池配置ID">
|
||||
{{ record.free_lottery_config_id ?? '—' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="BIGWIN 权重快照">
|
||||
<template v-if="bigwinWeightDisplay.length">
|
||||
<span v-for="item in bigwinWeightDisplay" :key="item.grid" class="mr-2">
|
||||
{{ item.grid }}:{{ item.weight }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>—</template>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
@@ -68,19 +76,53 @@
|
||||
|
||||
<div class="detail-section">
|
||||
<div class="section-title">权重配比快照(测试时使用的 T1-T5/BIGWIN 配置)</div>
|
||||
<el-table
|
||||
:data="snapshotTableData"
|
||||
border
|
||||
size="small"
|
||||
max-height="280"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="tier" label="档位" width="80" align="center" />
|
||||
<el-table-column prop="grid_number" label="色子点数" width="100" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="90" align="center" />
|
||||
<el-table-column prop="id" label="配置ID" width="80" align="center" />
|
||||
</el-table>
|
||||
<div v-if="!snapshotTableData.length" class="empty-tip">暂无快照数据</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">顺时针(非 BIGWIN)</div>
|
||||
<el-table
|
||||
:data="snapshotClockwise"
|
||||
border
|
||||
size="small"
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="tier" label="档位" width="80" align="center" />
|
||||
<el-table-column prop="grid_number" label="色子点数" width="100" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="90" align="center" />
|
||||
</el-table>
|
||||
<div v-if="!snapshotClockwise.length" class="empty-tip">暂无顺时针数据</div>
|
||||
</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">逆时针(非 BIGWIN)</div>
|
||||
<el-table
|
||||
:data="snapshotCounterclockwise"
|
||||
border
|
||||
size="small"
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="tier" label="档位" width="80" align="center" />
|
||||
<el-table-column prop="grid_number" label="色子点数" width="100" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="90" align="center" />
|
||||
</el-table>
|
||||
<div v-if="!snapshotCounterclockwise.length" class="empty-tip">暂无逆时针数据</div>
|
||||
</div>
|
||||
|
||||
<div class="snapshot-group">
|
||||
<div class="snapshot-subtitle">BIGWIN(按 DiceRewardConfig 配置快照)</div>
|
||||
<el-table
|
||||
:data="bigwinTableData"
|
||||
border
|
||||
size="small"
|
||||
max-height="180"
|
||||
class="snapshot-table"
|
||||
>
|
||||
<el-table-column prop="grid_number" label="色子点数" width="100" align="center" />
|
||||
<el-table-column prop="weight" label="权重" width="90" align="center" />
|
||||
</el-table>
|
||||
<div v-if="!bigwinTableData.length" class="empty-tip">暂无 BIGWIN 数据</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-section">
|
||||
@@ -181,6 +223,7 @@
|
||||
lottery_config_id?: number | null
|
||||
paid_lottery_config_id?: number | null
|
||||
free_lottery_config_id?: number | null
|
||||
bigwin_weight?: Record<string, number> | Array<[number, number]> | null
|
||||
// 新结构:{ paid: {T1..T5}, free: {T1..T5} },兼容旧结构直接是 {T1..T5}
|
||||
tier_weights_snapshot?:
|
||||
| {
|
||||
@@ -279,6 +322,26 @@
|
||||
return tierWeightsToTableData(source || undefined)
|
||||
})
|
||||
|
||||
const bigwinWeightDisplay = computed(() => {
|
||||
const raw = props.record?.bigwin_weight
|
||||
if (!raw) return []
|
||||
const entries: Array<{ grid: number; weight: number }> = []
|
||||
if (Array.isArray(raw)) {
|
||||
raw.forEach(([grid, weight]) => {
|
||||
entries.push({ grid: Number(grid), weight: Number(weight) })
|
||||
})
|
||||
} else if (typeof raw === 'object') {
|
||||
Object.keys(raw).forEach((k) => {
|
||||
const grid = Number(k)
|
||||
const w = Number((raw as Record<string, number>)[k])
|
||||
if (!Number.isNaN(grid) && !Number.isNaN(w)) {
|
||||
entries.push({ grid, weight: w })
|
||||
}
|
||||
})
|
||||
}
|
||||
return entries.sort((a, b) => a.grid - b.grid)
|
||||
})
|
||||
|
||||
// 导入不限制奖池类型,两个下拉都可选任意 DiceLotteryPoolConfig
|
||||
const paidLotteryOptions = computed(() => lotteryConfigOptions.value)
|
||||
const freeLotteryOptions = computed(() => lotteryConfigOptions.value)
|
||||
@@ -289,25 +352,65 @@
|
||||
})
|
||||
|
||||
const snapshotTableData = computed(() => {
|
||||
const snapshot = props.record?.weight_config_snapshot
|
||||
const snapshot = props.record?.weight_config_snapshot as
|
||||
| Array<{
|
||||
tier?: string
|
||||
direction?: number
|
||||
grid_number?: number
|
||||
weight?: number
|
||||
}>
|
||||
| undefined
|
||||
if (!Array.isArray(snapshot)) return []
|
||||
return snapshot.map((item) => ({
|
||||
id: item.id ?? '—',
|
||||
grid_number: item.grid_number ?? '—',
|
||||
tier: item.tier ?? '—',
|
||||
weight: item.weight ?? '—'
|
||||
}))
|
||||
return snapshot.map((item) => {
|
||||
const dir = item.direction
|
||||
return {
|
||||
tier: item.tier ?? '—',
|
||||
direction: dir,
|
||||
direction_label: dir === 0 ? '顺时针' : dir === 1 ? '逆时针' : '—',
|
||||
grid_number: item.grid_number ?? '—',
|
||||
weight: item.weight ?? '—'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const snapshotClockwise = computed(() =>
|
||||
snapshotTableData.value.filter((row) => row.direction === 0 && row.tier !== 'BIGWIN')
|
||||
)
|
||||
const snapshotCounterclockwise = computed(() =>
|
||||
snapshotTableData.value.filter((row) => row.direction === 1 && row.tier !== 'BIGWIN')
|
||||
)
|
||||
const bigwinTableData = computed(() =>
|
||||
bigwinWeightDisplay.value.map((item) => ({
|
||||
grid_number: item.grid,
|
||||
weight: item.weight
|
||||
}))
|
||||
)
|
||||
|
||||
const chartLabels = computed(() => GRID_NUMBERS.map((n) => String(n)))
|
||||
|
||||
const chartData = computed(() => {
|
||||
const counts = props.record?.result_counts
|
||||
if (!counts || typeof counts !== 'object') return GRID_NUMBERS.map(() => 0)
|
||||
return GRID_NUMBERS.map((n) => {
|
||||
const v = counts[String(n)] ?? counts[n]
|
||||
return typeof v === 'number' && !Number.isNaN(v) ? v : 0
|
||||
})
|
||||
if (!counts) return GRID_NUMBERS.map(() => 0)
|
||||
|
||||
// 兼容两种结构:对象 {5:10,...} 或数组 [10, ...]
|
||||
if (Array.isArray(counts)) {
|
||||
// 如果是数组,按顺序映射到 GRID_NUMBERS
|
||||
return GRID_NUMBERS.map((_, idx) => {
|
||||
const v = counts[idx]
|
||||
return typeof v === 'number' && !Number.isNaN(v) ? v : 0
|
||||
})
|
||||
}
|
||||
|
||||
if (typeof counts === 'object') {
|
||||
return GRID_NUMBERS.map((n) => {
|
||||
const byString = (counts as Record<string, number>)[String(n)]
|
||||
const byNumber = (counts as Record<number, number>)[n]
|
||||
const v = byString ?? byNumber
|
||||
return typeof v === 'number' && !Number.isNaN(v) ? v : 0
|
||||
})
|
||||
}
|
||||
|
||||
return GRID_NUMBERS.map(() => 0)
|
||||
})
|
||||
|
||||
const resultTotal = computed(() => {
|
||||
@@ -385,6 +488,15 @@
|
||||
.snapshot-table {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.snapshot-group {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.snapshot-subtitle {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
margin: 4px 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
.chart-wrap {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user