1.优化彩金池配置中的playerDefault时自动修改绑定该配置的用户
This commit is contained in:
@@ -261,18 +261,25 @@ export function getChannelDeptRequestParams(): { dept_id?: number } {
|
||||
return {}
|
||||
}
|
||||
|
||||
/** 保存/更新时附带 dept_id(优先渠道栏选中值,其次表单/行数据中的 dept_id) */
|
||||
/** 保存/更新时附带 dept_id(新增优先渠道栏;更新优先行内 dept_id,避免默认模板 0 覆盖真实渠道) */
|
||||
export function withChannelDeptParams<T extends Record<string, unknown>>(payload: T): T {
|
||||
const rowDeptRaw = payload.dept_id
|
||||
const hasRowDept =
|
||||
rowDeptRaw !== undefined && rowDeptRaw !== null && rowDeptRaw !== ''
|
||||
const rowDeptNum = hasRowDept ? Number(rowDeptRaw) : NaN
|
||||
const isUpdate =
|
||||
payload.id !== undefined && payload.id !== null && payload.id !== ''
|
||||
|
||||
if (isUpdate && hasRowDept && Number.isFinite(rowDeptNum) && rowDeptNum >= 0) {
|
||||
return { ...payload, dept_id: rowDeptNum }
|
||||
}
|
||||
|
||||
const extra = getChannelDeptRequestParams()
|
||||
if ('dept_id' in extra) {
|
||||
return { ...payload, ...extra }
|
||||
}
|
||||
const rowDeptId = payload.dept_id
|
||||
if (rowDeptId !== undefined && rowDeptId !== null && rowDeptId !== '') {
|
||||
const num = Number(rowDeptId)
|
||||
if (num > 0) {
|
||||
return { ...payload, dept_id: num }
|
||||
}
|
||||
if (hasRowDept && Number.isFinite(rowDeptNum) && rowDeptNum > 0) {
|
||||
return { ...payload, dept_id: rowDeptNum }
|
||||
}
|
||||
const channel = useInjectedChannelDept()
|
||||
if (channel && channel.selectedDeptId.value > 0) {
|
||||
|
||||
@@ -338,9 +338,11 @@
|
||||
|
||||
/** 将彩金池配置的 T1–T5 写入表单(绑定彩金池时展示与提交均以池为准) */
|
||||
function applyPoolWeightsToForm(cfg: LotteryPoolConfigOption) {
|
||||
WEIGHT_FIELDS.forEach((key) => {
|
||||
;(formData as Record<string, number>)[key] = Number(cfg[key] ?? 0)
|
||||
})
|
||||
formData.t1_weight = Number(cfg.t1_weight ?? 0)
|
||||
formData.t2_weight = Number(cfg.t2_weight ?? 0)
|
||||
formData.t3_weight = Number(cfg.t3_weight ?? 0)
|
||||
formData.t4_weight = Number(cfg.t4_weight ?? 0)
|
||||
formData.t5_weight = Number(cfg.t5_weight ?? 0)
|
||||
}
|
||||
|
||||
/** 根据当前 lottery_config_id 加载 DiceLotteryConfig,并将五个权重写入当前 player.*_weight */
|
||||
@@ -522,16 +524,12 @@
|
||||
ElMessage.warning(t('page.form.ruleWeightsSumMustBe100'))
|
||||
return
|
||||
}
|
||||
if (!isLotteryConfigEmpty() && currentLotteryConfig.value) {
|
||||
applyPoolWeightsToForm(currentLotteryConfig.value)
|
||||
}
|
||||
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
|
||||
)
|
||||
})
|
||||
payload.lottery_config_id = null
|
||||
}
|
||||
if (props.dialogType === 'edit' && !payload.password) {
|
||||
delete (payload as any).password
|
||||
|
||||
Reference in New Issue
Block a user