修改DiceLotteryPoolConfig-type改为name映射
This commit is contained in:
@@ -17,14 +17,13 @@ export default {
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取 DiceLotteryPoolConfig 列表数据,含 id、name、type、t1_weight~t5_weight,用于一键测试权重档位类型下拉
|
||||
* type:0=付费抽奖券,1=免费抽奖券;付费默认选 type=0,免费默认选 type=1
|
||||
* 获取 DiceLotteryPoolConfig 列表数据,含 id、name、t1_weight~t5_weight,用于一键测试权重档位类型下拉
|
||||
* name 映射:default=原 type=0,killScore=原 type=1,up=原 type=2
|
||||
*/
|
||||
async getOptions(): Promise<
|
||||
Array<{
|
||||
id: number
|
||||
name: string
|
||||
type: number
|
||||
t1_weight: number
|
||||
t2_weight: number
|
||||
t3_weight: number
|
||||
@@ -40,7 +39,6 @@ export default {
|
||||
return rows.map((r: any) => ({
|
||||
id: Number(r.id),
|
||||
name: String(r.name ?? r.id ?? ''),
|
||||
type: Number(r.type ?? 0),
|
||||
t1_weight: Number(r.t1_weight ?? 0),
|
||||
t2_weight: Number(r.t2_weight ?? 0),
|
||||
t3_weight: Number(r.t3_weight ?? 0),
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: undefined,
|
||||
type: undefined
|
||||
// type 字段已移除,改用 name 区分:default/killScore/up
|
||||
})
|
||||
|
||||
// 搜索处理
|
||||
@@ -82,9 +82,14 @@
|
||||
getData()
|
||||
}
|
||||
|
||||
// 奖池类型展示:0=正常 1=强制杀猪 2=T1高倍率
|
||||
const typeFormatter = (row: Record<string, unknown>) =>
|
||||
row.type === 0 ? t('page.search.poolTypeNormal') : row.type === 1 ? t('page.search.poolTypeKill') : row.type === 2 ? t('page.search.poolTypeT1') : '-'
|
||||
// 奖池类型展示:按 name 映射
|
||||
const typeFormatter = (row: Record<string, unknown>) => {
|
||||
const n = String(row.name ?? '')
|
||||
if (n === 'default') return t('page.search.poolTypeNormal')
|
||||
if (n === 'killScore') return t('page.search.poolTypeKill')
|
||||
if (n === 'up') return t('page.search.poolTypeT1')
|
||||
return n || '-'
|
||||
}
|
||||
|
||||
// 权重列带 %
|
||||
const weightFormatter = (prop: string) => (row: Record<string, unknown>) => {
|
||||
@@ -111,7 +116,7 @@
|
||||
apiFn: api.list,
|
||||
columnsFactory: () => [
|
||||
{ prop: 'name', label: 'page.table.name', align: 'center' },
|
||||
{ prop: 'type', label: 'page.table.poolType', width: 100, align: 'center', formatter: typeFormatter },
|
||||
{ prop: 'name', label: 'page.table.poolType', width: 100, align: 'center', formatter: typeFormatter },
|
||||
{ prop: 'safety_line', label: 'page.table.safetyLine', align: 'center' },
|
||||
{
|
||||
prop: 't1_weight',
|
||||
|
||||
@@ -25,19 +25,7 @@
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('page.form.poolType')" prop="type">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
:placeholder="$t('page.form.placeholderPoolType')"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
:disabled="dialogType === 'edit'"
|
||||
>
|
||||
<el-option :label="$t('page.form.poolTypeNormal')" :value="0" />
|
||||
<el-option :label="$t('page.form.poolTypeKill')" :value="1" />
|
||||
<el-option :label="$t('page.form.poolTypeT1')" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- dice_lottery_pool_config 已移除 type 字段,按 name 区分 default/killScore/up;name 在新增时填写,编辑时禁用 -->
|
||||
<el-form-item :label="$t('page.form.safetyLine')" prop="safety_line">
|
||||
<el-input-number
|
||||
v-model="formData.safety_line"
|
||||
@@ -127,7 +115,6 @@
|
||||
*/
|
||||
const rules = computed<FormRules>(() => ({
|
||||
name: [{ required: true, message: t('page.form.ruleNameRequired'), trigger: 'blur' }],
|
||||
type: [{ required: true, message: t('page.form.rulePoolTypeRequired'), trigger: 'change' }],
|
||||
t1_weight: [{ required: true, message: t('page.form.ruleT1Required'), trigger: 'blur' }],
|
||||
t2_weight: [{ required: true, message: t('page.form.ruleT2Required'), trigger: 'blur' }],
|
||||
t3_weight: [{ required: true, message: t('page.form.ruleT3Required'), trigger: 'blur' }],
|
||||
@@ -142,7 +129,6 @@
|
||||
id: null as number | null,
|
||||
name: '',
|
||||
remark: '',
|
||||
type: null as number | null,
|
||||
safety_line: 0 as number,
|
||||
t1_weight: 0 as number,
|
||||
t2_weight: 0 as number,
|
||||
@@ -188,7 +174,6 @@
|
||||
if (!props.data) return
|
||||
const numKeys = [
|
||||
'id',
|
||||
'type',
|
||||
'safety_line',
|
||||
't1_weight',
|
||||
't2_weight',
|
||||
|
||||
@@ -13,16 +13,7 @@
|
||||
<el-input v-model="formData.name" :placeholder="$t('page.search.placeholderName')" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-bind="setSpan(6)">
|
||||
<el-form-item :label="$t('page.search.poolType')" prop="type">
|
||||
<el-select
|
||||
v-model="formData.type"
|
||||
:options="typeOptions"
|
||||
:placeholder="$t('page.search.placeholderPoolType')"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<!-- dice_lottery_pool_config 已移除 type 字段,按 name 区分 default/killScore/up -->
|
||||
</sa-search-bar>
|
||||
</template>
|
||||
|
||||
@@ -42,11 +33,7 @@
|
||||
const isExpanded = ref<boolean>(false)
|
||||
|
||||
const { t } = useI18n()
|
||||
const typeOptions = computed(() => [
|
||||
{ name: '0', value: t('page.search.poolTypeNormal') },
|
||||
{ name: '1', value: t('page.search.poolTypeKill') },
|
||||
{ name: '2', value: t('page.search.poolTypeT1') }
|
||||
])
|
||||
// type 字段已移除
|
||||
// 表单数据双向绑定
|
||||
const searchBarRef = ref()
|
||||
const formData = computed({
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelType') }}:</span>
|
||||
<span>{{ lotteryConfigTypeText(currentLotteryConfig.type) }}</span>
|
||||
<span>{{ lotteryConfigTypeText(currentLotteryConfig.name) }}</span>
|
||||
</div>
|
||||
<div class="config-row">
|
||||
<span class="config-label">{{ $t('page.form.configLabelWeights') }}:</span>
|
||||
@@ -265,11 +265,12 @@
|
||||
/** 当前选中的 DiceLotteryConfig 完整数据(用于展示) */
|
||||
const currentLotteryConfig = ref<Record<string, any> | null>(null)
|
||||
|
||||
function lotteryConfigTypeText(type: unknown): string {
|
||||
const t = Number(type)
|
||||
if (t === 0) return '付费'
|
||||
if (t === 1) return '赠送'
|
||||
return t ? `类型${t}` : '-'
|
||||
function lotteryConfigTypeText(name: unknown): string {
|
||||
const n = String(name ?? '')
|
||||
if (n === 'default') return '默认'
|
||||
if (n === 'killScore') return '杀分'
|
||||
if (n === 'up') return '上分'
|
||||
return n || '-'
|
||||
}
|
||||
|
||||
/** 是否为空/自定义权重(未选彩金池或选 0) */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<ElFormItem label="测试数据档位类型" prop="paid_lottery_config_id">
|
||||
<ElSelect
|
||||
v-model="form.paid_lottery_config_id"
|
||||
placeholder="不选则下方自定义档位概率(默认 type=0)"
|
||||
placeholder="不选则下方自定义档位概率(默认 default)"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -70,7 +70,7 @@
|
||||
<ElFormItem label="测试数据档位类型" prop="free_lottery_config_id">
|
||||
<ElSelect
|
||||
v-model="form.free_lottery_config_id"
|
||||
placeholder="不选则下方自定义档位概率(默认 type=1)"
|
||||
placeholder="不选则下方自定义档位概率(默认 killScore)"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 100%"
|
||||
@@ -153,22 +153,13 @@
|
||||
free_s_count: 100,
|
||||
free_n_count: 100
|
||||
})
|
||||
const lotteryOptions = ref<Array<{ id: number; name: string; type: number }>>([])
|
||||
/** 将 type 转为数字(接口可能返回字符串 "0"/"1") */
|
||||
function tierTypeNum(r: { type?: number | string }): number {
|
||||
const t = r.type ?? 0
|
||||
return typeof t === 'number' ? t : Number(t) || 0
|
||||
}
|
||||
/** 付费抽奖券可选档位:type=0 */
|
||||
const paidLotteryOptions = computed(() =>
|
||||
lotteryOptions.value.filter((r) => tierTypeNum(r) === 0)
|
||||
)
|
||||
/**
|
||||
* 免费抽奖券可选档位:优先 type=1(DiceLotteryPoolConfig.type=1),若无则显示全部以便下拉有选项
|
||||
*/
|
||||
const lotteryOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
/** 付费抽奖券可选档位:name=default */
|
||||
const paidLotteryOptions = computed(() => lotteryOptions.value.filter((r) => r.name === 'default'))
|
||||
/** 免费抽奖券可选档位:优先 name=killScore,若无则显示全部以便下拉有选项 */
|
||||
const freeLotteryOptions = computed(() => {
|
||||
const type1List = lotteryOptions.value.filter((r) => tierTypeNum(r) === 1)
|
||||
return type1List.length > 0 ? type1List : lotteryOptions.value
|
||||
const list = lotteryOptions.value.filter((r) => r.name === 'killScore')
|
||||
return list.length > 0 ? list : lotteryOptions.value
|
||||
})
|
||||
const running = ref(false)
|
||||
|
||||
@@ -211,22 +202,16 @@
|
||||
async function loadLotteryOptions() {
|
||||
try {
|
||||
const list = await lotteryPoolApi.getOptions()
|
||||
lotteryOptions.value = list.map(
|
||||
(r: { id: number; name: string; type?: number | string }) => ({
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
type: tierTypeNum(r)
|
||||
})
|
||||
)
|
||||
// 付费抽奖券默认使用 type=0 的档位类型
|
||||
const type0 = list.find((r: { type?: number | string }) => tierTypeNum(r) === 0)
|
||||
if (type0) {
|
||||
form.paid_lottery_config_id = type0.id
|
||||
lotteryOptions.value = list.map((r: { id: number; name: string }) => ({ id: r.id, name: r.name }))
|
||||
// 付费抽奖券默认使用 name=default
|
||||
const normal = list.find((r: { name?: string }) => r.name === 'default')
|
||||
if (normal) {
|
||||
form.paid_lottery_config_id = normal.id
|
||||
}
|
||||
// 免费抽奖券默认使用 type=1 的档位类型(DiceLotteryPoolConfig.type=1);若无 type=1 则默认选第一项
|
||||
const type1 = list.find((r: { type?: number | string }) => tierTypeNum(r) === 1)
|
||||
if (type1) {
|
||||
form.free_lottery_config_id = type1.id
|
||||
// 免费抽奖券默认使用 name=killScore;若无则默认选第一项
|
||||
const kill = list.find((r: { name?: string }) => r.name === 'killScore')
|
||||
if (kill) {
|
||||
form.free_lottery_config_id = kill.id
|
||||
} else if (list.length > 0) {
|
||||
form.free_lottery_config_id = list[0].id
|
||||
}
|
||||
@@ -312,7 +297,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
// 切换到免费步骤时,若当前选中 id 不在免费档位列表中,则重置为第一个 type=1 的选项,避免显示错误
|
||||
// 切换到免费步骤时,若当前选中 id 不在免费档位列表中,则重置为第一个 killScore 的选项,避免显示错误
|
||||
watch(currentStep, (step) => {
|
||||
if (step === 1) {
|
||||
const freeOpts = freeLotteryOptions.value
|
||||
|
||||
@@ -266,7 +266,7 @@
|
||||
const importing = ref(false)
|
||||
const importPaidLotteryConfigId = ref<number | null>(null)
|
||||
const importFreeLotteryConfigId = ref<number | null>(null)
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string; type: number }>>([])
|
||||
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
|
||||
|
||||
function tierWeightsToTableData(t: Record<string, number> | null | undefined) {
|
||||
if (!t || typeof t !== 'object') return []
|
||||
|
||||
Reference in New Issue
Block a user