[色子游戏]玩家抽奖记录测试数据
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="visible"
|
||||
title="一键测试权重"
|
||||
width="520px"
|
||||
:close-on-click-modal="false"
|
||||
destroy-on-close
|
||||
@close="onClose"
|
||||
>
|
||||
<ElForm ref="formRef" :model="form" label-width="140px" :disabled="running">
|
||||
<ElFormItem label="测试数据档位类型" prop="lottery_config_id" required>
|
||||
<ElSelect
|
||||
v-model="form.lottery_config_id"
|
||||
placeholder="请选择奖池配置"
|
||||
filterable
|
||||
style="width: 100%"
|
||||
>
|
||||
<ElOption
|
||||
v-for="item in lotteryOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="顺时针方向次数" prop="s_count" required>
|
||||
<ElSelect v-model="form.s_count" placeholder="请选择" style="width: 100%">
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="逆时针方向次数" prop="n_count" required>
|
||||
<ElSelect v-model="form.n_count" placeholder="请选择" style="width: 100%">
|
||||
<ElOption v-for="c in countOptions" :key="c" :label="String(c)" :value="c" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<ElButton @click="visible = false">取消</ElButton>
|
||||
<ElButton type="primary" :loading="running" @click="handleStart">开始测试</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import api from '../../../api/reward/index'
|
||||
import lotteryPoolApi from '../../../api/lottery_pool_config/index'
|
||||
|
||||
const countOptions = [100, 500, 1000, 5000]
|
||||
|
||||
const visible = defineModel<boolean>({ default: false })
|
||||
const emit = defineEmits<{ (e: 'success'): void }>()
|
||||
|
||||
const formRef = ref()
|
||||
const form = reactive({
|
||||
lottery_config_id: undefined as number | undefined,
|
||||
s_count: 100,
|
||||
n_count: 100
|
||||
})
|
||||
const lotteryOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
const running = ref(false)
|
||||
|
||||
function onClose() {
|
||||
running.value = false
|
||||
}
|
||||
|
||||
async function loadLotteryOptions() {
|
||||
try {
|
||||
const list = await lotteryPoolApi.getOptions()
|
||||
lotteryOptions.value = list.map((r: { id: number; name: string }) => ({ id: r.id, name: r.name }))
|
||||
if (list.length && !form.lottery_config_id) {
|
||||
form.lottery_config_id = list[0].id
|
||||
}
|
||||
} catch (_) {
|
||||
lotteryOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
async function handleStart() {
|
||||
if (!form.lottery_config_id) {
|
||||
ElMessage.warning('请选择测试数据档位类型')
|
||||
return
|
||||
}
|
||||
running.value = true
|
||||
try {
|
||||
await api.startWeightTest({
|
||||
lottery_config_id: form.lottery_config_id,
|
||||
s_count: form.s_count,
|
||||
n_count: form.n_count
|
||||
})
|
||||
ElMessage.success('测试任务已创建,后台将自动执行。请在【玩家抽奖记录(测试数据)】中查看生成的测试数据')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.message || '创建测试任务失败')
|
||||
} finally {
|
||||
running.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(visible, (v) => {
|
||||
if (v) {
|
||||
loadLotteryOptions()
|
||||
} else {
|
||||
onClose()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user