1.修改彩金池配置中的playerDefault时自动修改绑定该配置的用户
This commit is contained in:
@@ -336,6 +336,13 @@
|
||||
return v == null || v === 0
|
||||
}
|
||||
|
||||
/** 将彩金池配置的 T1–T5 写入表单(绑定彩金池时展示与提交均以池为准) */
|
||||
function applyPoolWeightsToForm(cfg: LotteryPoolConfigOption) {
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(formData as Record<string, number>)[key] = Number(cfg[key] ?? 0)
|
||||
})
|
||||
}
|
||||
|
||||
/** 根据当前 lottery_config_id 加载 DiceLotteryConfig,并将五个权重写入当前 player.*_weight */
|
||||
async function loadCurrentLotteryConfig() {
|
||||
const id = formData.lottery_config_id
|
||||
@@ -349,9 +356,7 @@
|
||||
if (payload) {
|
||||
const row = parseLotteryPoolConfigOption(payload)
|
||||
currentLotteryConfig.value = row
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(formData as any)[key] = Number(row[key] ?? 0)
|
||||
})
|
||||
applyPoolWeightsToForm(row)
|
||||
} else {
|
||||
currentLotteryConfig.value = null
|
||||
}
|
||||
@@ -360,6 +365,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => currentLotteryConfig.value,
|
||||
(cfg) => {
|
||||
if (cfg && !isLotteryConfigEmpty()) {
|
||||
applyPoolWeightsToForm(cfg)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
@@ -378,9 +392,7 @@
|
||||
const payload = extractReadPayload(res)
|
||||
if (payload) {
|
||||
const row = parseLotteryPoolConfigOption(payload)
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(formData as any)[key] = Number(row[key] ?? 0)
|
||||
})
|
||||
applyPoolWeightsToForm(row)
|
||||
currentLotteryConfig.value = row
|
||||
} else {
|
||||
currentLotteryConfig.value = null
|
||||
@@ -513,6 +525,13 @@
|
||||
const payload = { ...formData }
|
||||
if (isLotteryConfigEmpty()) {
|
||||
;(payload as any).lottery_config_id = null
|
||||
} else if (currentLotteryConfig.value) {
|
||||
applyPoolWeightsToForm(currentLotteryConfig.value)
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(payload as Record<string, number>)[key] = Number(
|
||||
(formData as Record<string, number>)[key] ?? 0
|
||||
)
|
||||
})
|
||||
}
|
||||
if (props.dialogType === 'edit' && !payload.password) {
|
||||
delete (payload as any).password
|
||||
|
||||
Reference in New Issue
Block a user