[色子游戏]玩家-优化样式

This commit is contained in:
2026-03-03 14:36:04 +08:00
parent fc5f8bb1ca
commit a54f4623c5
8 changed files with 276 additions and 95 deletions

View File

@@ -42,6 +42,19 @@
@pagination:size-change="handleSizeChange"
@pagination:current-change="handleCurrentChange"
>
<!-- 状态开关直接修改 -->
<template #status="{ row }">
<ElSwitch
v-permission="'dice:player:index:update'"
:model-value="row.status === 1"
:loading="row._statusLoading"
@change="(v: boolean) => handleStatusChange(row, v ? 1 : 0)"
/>
</template>
<!-- 平台币tag 展示 -->
<template #coin="{ row }">
<ElTag type="info" size="small">{{ row.coin ?? 0 }}</ElTag>
</template>
<!-- 操作列 -->
<template #operation="{ row }">
<div class="flex gap-2">
@@ -77,11 +90,13 @@
import TableSearch from './modules/table-search.vue'
import EditDialog from './modules/edit-dialog.vue'
// 搜索表单
const searchForm = ref({
username: undefined,
name: undefined,
status: undefined,
coin: undefined,
is_up: undefined
})
// 搜索处理
@@ -90,6 +105,14 @@
getData()
}
// 权重列带 % 的 formatter
const weightFormatter = (_row: any, _column: any, cellValue: unknown) =>
cellValue != null && cellValue !== '' ? `${cellValue}%` : '-'
// 倍率列展示0=正常 1=强制杀猪 2=T1高倍率
const isUpFormatter = (_row: any, _column: any, cellValue: unknown) =>
cellValue === 0 ? '正常' : cellValue === 1 ? '强制杀猪' : cellValue === 2 ? 'T1高倍率' : '-'
// 表格配置
const {
columns,
@@ -109,27 +132,39 @@
apiFn: api.list,
columnsFactory: () => [
{ type: 'selection' },
{ prop: 'username', label: '用户名' },
{ prop: 'name', label: '昵称' },
{ prop: 'password', label: '密码' },
{ prop: 'status', label: '状态' },
{ prop: 'coin', label: '平台币' },
{ prop: 'is_up', label: '倍率' },
{ prop: 't1_wight', label: 'T1池权重' },
{ prop: 't2_wight', label: 'T2池权重' },
{ prop: 't3_wight', label: 'T3池权重' },
{ prop: 't4_wight', label: 'T4池权重' },
{ prop: 't5_wight', label: 'T5池权重' },
{ prop: 'status', label: '状态', width: 88, useSlot: true },
{ prop: 'coin', label: '平台币', width: 100, useSlot: true },
{ prop: 'is_up', label: '倍率', width: 80, formatter: isUpFormatter },
{ prop: 't1_wight', label: 'T1池权重', width: 100, formatter: weightFormatter },
{ prop: 't2_wight', label: 'T2池权重', width: 100, formatter: weightFormatter },
{ prop: 't3_wight', label: 'T3池权重', width: 100, formatter: weightFormatter },
{ prop: 't4_wight', label: 'T4池权重', width: 100, formatter: weightFormatter },
{ prop: 't5_wight', label: 'T5池权重', width: 100, formatter: weightFormatter },
{ prop: 'total_draw_count', label: '总抽奖次数' },
{ prop: 'paid_draw_count', label: '购买抽奖次数' },
{ prop: 'free_draw_count', label: '赠送抽奖次数' },
{ prop: 'created_at', label: '创建时间' },
{ prop: 'updated_at', label: '更新时间' },
{ prop: 'deleted_at', label: '删除时间' },
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
{ prop: 'operation', label: '操作', width: 120, fixed: 'right', useSlot: true }
]
}
})
// 状态开关切换(列表内直接修改)
const handleStatusChange = async (row: Record<string, any>, status: number) => {
row._statusLoading = true
try {
await api.updateStatus({ id: row.id, status })
row.status = status
} catch {
refreshData()
} finally {
row._statusLoading = false
}
}
// 编辑配置
const {
dialogType,
@@ -141,5 +176,4 @@
handleSelectionChange,
selectedRows
} = useSaiAdmin()
</script>