[色子游戏]奖池配置-优化样式

This commit is contained in:
2026-03-03 14:36:13 +08:00
parent a54f4623c5
commit 2cf409345e
2 changed files with 36 additions and 19 deletions

View File

@@ -8,7 +8,11 @@
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
<template #left>
<ElSpace wrap>
<ElButton v-permission="'dice:lottery_config:index:save'" @click="showDialog('add')" v-ripple>
<ElButton
v-permission="'dice:lottery_config:index:save'"
@click="showDialog('add')"
v-ripple
>
<template #icon>
<ArtSvgIcon icon="ri:add-fill" />
</template>
@@ -77,11 +81,10 @@
import TableSearch from './modules/table-search.vue'
import EditDialog from './modules/edit-dialog.vue'
// 搜索表单
const searchForm = ref({
name: undefined,
type: undefined,
type: undefined
})
// 搜索处理
@@ -90,6 +93,16 @@
getData()
}
// 奖池类型展示0=正常 1=强制杀猪 2=T1高倍率
const typeFormatter = (row: Record<string, unknown>) =>
row.type === 0 ? '正常' : row.type === 1 ? '强制杀猪' : row.type === 2 ? 'T1高倍率' : '-'
// 权重列带 %
const weightFormatter = (prop: string) => (row: Record<string, unknown>) => {
const v = row[prop]
return v != null && v !== '' ? `${v}%` : '-'
}
// 表格配置
const {
columns,
@@ -110,13 +123,13 @@
columnsFactory: () => [
{ type: 'selection' },
{ prop: 'name', label: '名称' },
{ prop: 'type', label: '奖池类型' },
{ prop: 'type', label: '奖池类型', width: 100, formatter: typeFormatter },
{ prop: 'safety_line', 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: 't1_wight', label: 'T1池权重', width: 100, formatter: weightFormatter('t1_wight') },
{ prop: 't2_wight', label: 'T2池权重', width: 100, formatter: weightFormatter('t2_wight') },
{ prop: 't3_wight', label: 'T3池权重', width: 100, formatter: weightFormatter('t3_wight') },
{ prop: 't4_wight', label: 'T4池权重', width: 100, formatter: weightFormatter('t4_wight') },
{ prop: 't5_wight', label: 'T5池权重', width: 100, formatter: weightFormatter('t5_wight') },
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
]
}
@@ -133,5 +146,4 @@
handleSelectionChange,
selectedRows
} = useSaiAdmin()
</script>

View File

@@ -58,10 +58,10 @@
</el-form-item>
<el-form-item>
<div class="text-gray-500 text-sm">
五个池权重总和<span :class="weightsSum > 100 ? 'text-red-500' : ''">{{
五个池权重总和<span :class="Math.abs(weightsSum - 100) > 0.01 ? 'text-red-500' : ''">{{
weightsSum
}}</span
>% / 100%100%
>% / 100%100%
</div>
</el-form-item>
</el-form>
@@ -174,11 +174,12 @@
}
/**
* 初始化表单数据(数值字段转为 number 便于输入框与校验)
* 初始化表单数据(数值字段转为 number 便于滑块/输入框回显与校验)
*/
const initForm = () => {
if (!props.data) return
const numKeys = [
'id',
'type',
'safety_line',
't1_wight',
@@ -187,10 +188,14 @@
't4_wight',
't5_wight'
]
for (const key in formData) {
if (props.data[key] != null && props.data[key] !== undefined) {
const val = props.data[key]
;(formData as any)[key] = numKeys.includes(key) ? Number(val) : val
for (const key of Object.keys(formData)) {
if (!(key in props.data)) continue
const val = props.data[key]
if (numKeys.includes(key)) {
;(formData as any)[key] =
key === 'id' ? (val != null ? Number(val) || null : null) : Number(val) || 0
} else {
;(formData as any)[key] = val ?? ''
}
}
}
@@ -210,8 +215,8 @@
if (!formRef.value) return
try {
await formRef.value.validate()
if (weightsSum.value > 100) {
ElMessage.warning('五个池权重总和不能超过100%')
if (Math.abs(weightsSum.value - 100) > 0.01) {
ElMessage.warning('五个池权重总和必须为100%')
return
}
if (props.dialogType === 'add') {