DicePlayRecord添加字段super_win_coin和reward_win_coin记录不同的中奖金额类型
This commit is contained in:
@@ -15,7 +15,13 @@
|
||||
<el-input v-model="formData.name" placeholder="请输入昵称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="formData.phone" placeholder="请输入手机号" clearable maxlength="20" show-word-limit />
|
||||
<el-input
|
||||
v-model="formData.phone"
|
||||
placeholder="请输入手机号"
|
||||
clearable
|
||||
maxlength="20"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="password" :rules="passwordRules">
|
||||
<el-input
|
||||
@@ -38,29 +44,39 @@
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="倍率" prop="is_up">
|
||||
<el-select v-model="formData.is_up" placeholder="请选择倍率" clearable style="width: 100%">
|
||||
<el-option label="正常" :value="0" />
|
||||
<el-option label="强制杀猪" :value="1" />
|
||||
<el-option label="T1高倍率" :value="2" />
|
||||
<el-form-item label="彩金池配置" prop="lottery_config_id">
|
||||
<el-select
|
||||
v-model="formData.lottery_config_id"
|
||||
placeholder="不选则使用下方自定义权重"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@change="onLotteryConfigChange"
|
||||
>
|
||||
<el-option label="自定义权重" :value="0" />
|
||||
<el-option
|
||||
v-for="item in lotteryConfigOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="T1池权重(%)" prop="t1_weight">
|
||||
<el-form-item v-if="!formData.lottery_config_id" label="T1池权重(%)" prop="t1_weight">
|
||||
<el-slider v-model="formData.t1_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T2池权重(%)" prop="t2_weight">
|
||||
<el-form-item v-if="!formData.lottery_config_id" label="T2池权重(%)" prop="t2_weight">
|
||||
<el-slider v-model="formData.t2_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T3池权重(%)" prop="t3_weight">
|
||||
<el-form-item v-if="!formData.lottery_config_id" label="T3池权重(%)" prop="t3_weight">
|
||||
<el-slider v-model="formData.t3_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T4池权重(%)" prop="t4_weight">
|
||||
<el-form-item v-if="!formData.lottery_config_id" label="T4池权重(%)" prop="t4_weight">
|
||||
<el-slider v-model="formData.t4_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item label="T5池权重(%)" prop="t5_weight">
|
||||
<el-form-item v-if="!formData.lottery_config_id" label="T5池权重(%)" prop="t5_weight">
|
||||
<el-slider v-model="formData.t5_weight" :min="0" :max="100" :step="0.01" show-input />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item v-if="!formData.lottery_config_id">
|
||||
<div class="text-gray-500 text-sm">
|
||||
五个池权重总和:<span :class="Math.abs(weightsSum - 100) > 0.01 ? 'text-red-500' : ''">{{
|
||||
weightsSum
|
||||
@@ -78,9 +94,12 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/player/index'
|
||||
import lotteryConfigApi from '../../../api/lottery_config/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
|
||||
const WEIGHT_FIELDS = ['t1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'] as const
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean
|
||||
dialogType: string
|
||||
@@ -107,9 +126,8 @@
|
||||
set: (value) => emit('update:modelValue', value)
|
||||
})
|
||||
|
||||
const WEIGHT_KEYS = ['t1_weight', 't2_weight', 't3_weight', 't4_weight', 't5_weight'] as const
|
||||
const weightsSum = computed(() => {
|
||||
return WEIGHT_KEYS.reduce((sum, key) => sum + Number(formData[key] ?? 0), 0)
|
||||
return WEIGHT_FIELDS.reduce((sum, key) => sum + Number(formData[key] ?? 0), 0)
|
||||
})
|
||||
|
||||
/** 新增时密码必填,编辑时选填 */
|
||||
@@ -133,7 +151,7 @@
|
||||
password: '',
|
||||
status: 1 as number,
|
||||
coin: 0 as number,
|
||||
is_up: null as number | null,
|
||||
lottery_config_id: null as number | null,
|
||||
t1_weight: 0 as number,
|
||||
t2_weight: 0 as number,
|
||||
t3_weight: 0 as number,
|
||||
@@ -143,6 +161,9 @@
|
||||
|
||||
const formData = reactive({ ...initialFormData })
|
||||
|
||||
/** 彩金池配置下拉选项 */
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
@@ -150,19 +171,45 @@
|
||||
}
|
||||
)
|
||||
|
||||
/** 选择彩金池配置时,拉取该配置的权重填入表单(仅展示/备份;lottery_config_id 非空时后端以配置为准) */
|
||||
async function onLotteryConfigChange(lotteryConfigId: number | null) {
|
||||
if (!lotteryConfigId) return
|
||||
try {
|
||||
const res = await lotteryConfigApi.read(lotteryConfigId)
|
||||
const row = (res as any)?.data
|
||||
if (row) {
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(formData as any)[key] = Number(row[key] ?? 0)
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('拉取彩金池配置权重失败', err)
|
||||
}
|
||||
}
|
||||
|
||||
const initPage = async () => {
|
||||
Object.assign(formData, initialFormData)
|
||||
await loadLotteryConfigOptions()
|
||||
if (props.data) {
|
||||
await nextTick()
|
||||
initForm()
|
||||
}
|
||||
}
|
||||
|
||||
/** 从 DiceLotteryConfig 拉取彩金池配置下拉选项 */
|
||||
async function loadLotteryConfigOptions() {
|
||||
try {
|
||||
lotteryConfigOptions.value = await lotteryConfigApi.getOptions()
|
||||
} catch {
|
||||
lotteryConfigOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const numKeys = [
|
||||
'id',
|
||||
'status',
|
||||
'coin',
|
||||
'is_up',
|
||||
'lottery_config_id',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
't3_weight',
|
||||
@@ -197,7 +244,8 @@
|
||||
if (!formRef.value) return
|
||||
try {
|
||||
await formRef.value.validate()
|
||||
if (Math.abs(weightsSum.value - 100) > 0.01) {
|
||||
const useCustomWeights = !formData.lottery_config_id
|
||||
if (useCustomWeights && Math.abs(weightsSum.value - 100) > 0.01) {
|
||||
ElMessage.warning('五个池权重总和必须为100%')
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user