[色子游戏]奖池配置-优化样式
This commit is contained in:
@@ -8,7 +8,11 @@
|
|||||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||||
<template #left>
|
<template #left>
|
||||||
<ElSpace wrap>
|
<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>
|
<template #icon>
|
||||||
<ArtSvgIcon icon="ri:add-fill" />
|
<ArtSvgIcon icon="ri:add-fill" />
|
||||||
</template>
|
</template>
|
||||||
@@ -77,11 +81,10 @@
|
|||||||
import TableSearch from './modules/table-search.vue'
|
import TableSearch from './modules/table-search.vue'
|
||||||
import EditDialog from './modules/edit-dialog.vue'
|
import EditDialog from './modules/edit-dialog.vue'
|
||||||
|
|
||||||
|
|
||||||
// 搜索表单
|
// 搜索表单
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
name: undefined,
|
name: undefined,
|
||||||
type: undefined,
|
type: undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
// 搜索处理
|
// 搜索处理
|
||||||
@@ -90,6 +93,16 @@
|
|||||||
getData()
|
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 {
|
const {
|
||||||
columns,
|
columns,
|
||||||
@@ -110,13 +123,13 @@
|
|||||||
columnsFactory: () => [
|
columnsFactory: () => [
|
||||||
{ type: 'selection' },
|
{ type: 'selection' },
|
||||||
{ prop: 'name', label: '名称' },
|
{ prop: 'name', label: '名称' },
|
||||||
{ prop: 'type', label: '奖池类型' },
|
{ prop: 'type', label: '奖池类型', width: 100, formatter: typeFormatter },
|
||||||
{ prop: 'safety_line', label: '安全线' },
|
{ prop: 'safety_line', label: '安全线' },
|
||||||
{ prop: 't1_wight', label: 'T1池权重' },
|
{ prop: 't1_wight', label: 'T1池权重', width: 100, formatter: weightFormatter('t1_wight') },
|
||||||
{ prop: 't2_wight', label: 'T2池权重' },
|
{ prop: 't2_wight', label: 'T2池权重', width: 100, formatter: weightFormatter('t2_wight') },
|
||||||
{ prop: 't3_wight', label: 'T3池权重' },
|
{ prop: 't3_wight', label: 'T3池权重', width: 100, formatter: weightFormatter('t3_wight') },
|
||||||
{ prop: 't4_wight', label: 'T4池权重' },
|
{ prop: 't4_wight', label: 'T4池权重', width: 100, formatter: weightFormatter('t4_wight') },
|
||||||
{ prop: 't5_wight', label: 'T5池权重' },
|
{ prop: 't5_wight', label: 'T5池权重', width: 100, formatter: weightFormatter('t5_wight') },
|
||||||
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
{ prop: 'operation', label: '操作', width: 100, fixed: 'right', useSlot: true }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -133,5 +146,4 @@
|
|||||||
handleSelectionChange,
|
handleSelectionChange,
|
||||||
selectedRows
|
selectedRows
|
||||||
} = useSaiAdmin()
|
} = useSaiAdmin()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -58,10 +58,10 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<div class="text-gray-500 text-sm">
|
<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
|
weightsSum
|
||||||
}}</span
|
}}</span
|
||||||
>% / 100%(不可超过100%)
|
>% / 100%(必须为100%)
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
@@ -174,11 +174,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化表单数据(数值字段转为 number 便于输入框与校验)
|
* 初始化表单数据(数值字段转为 number 便于滑块/输入框回显与校验)
|
||||||
*/
|
*/
|
||||||
const initForm = () => {
|
const initForm = () => {
|
||||||
if (!props.data) return
|
if (!props.data) return
|
||||||
const numKeys = [
|
const numKeys = [
|
||||||
|
'id',
|
||||||
'type',
|
'type',
|
||||||
'safety_line',
|
'safety_line',
|
||||||
't1_wight',
|
't1_wight',
|
||||||
@@ -187,10 +188,14 @@
|
|||||||
't4_wight',
|
't4_wight',
|
||||||
't5_wight'
|
't5_wight'
|
||||||
]
|
]
|
||||||
for (const key in formData) {
|
for (const key of Object.keys(formData)) {
|
||||||
if (props.data[key] != null && props.data[key] !== undefined) {
|
if (!(key in props.data)) continue
|
||||||
const val = props.data[key]
|
const val = props.data[key]
|
||||||
;(formData as any)[key] = numKeys.includes(key) ? Number(val) : val
|
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
|
if (!formRef.value) return
|
||||||
try {
|
try {
|
||||||
await formRef.value.validate()
|
await formRef.value.validate()
|
||||||
if (weightsSum.value > 100) {
|
if (Math.abs(weightsSum.value - 100) > 0.01) {
|
||||||
ElMessage.warning('五个池权重总和不能超过100%')
|
ElMessage.warning('五个池权重总和必须为100%')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (props.dialogType === 'add') {
|
if (props.dialogType === 'add') {
|
||||||
|
|||||||
Reference in New Issue
Block a user