相关记录表admin_id关联当前管理员id

This commit is contained in:
2026-03-10 12:30:56 +08:00
parent b1efeb8b31
commit fdd8f6dffa
18 changed files with 290 additions and 26 deletions

View File

@@ -34,6 +34,23 @@
<el-form-item label="状态" prop="status">
<sa-switch v-model="formData.status" />
</el-form-item>
<el-form-item label="所属管理员" prop="admin_id">
<el-select
v-model="formData.admin_id"
placeholder="选择后台管理员(可选)"
clearable
filterable
style="width: 100%"
:loading="systemUserOptionsLoading"
>
<el-option
v-for="item in systemUserOptions"
:key="item.id"
:label="item.label || item.username || `#${item.id}`"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="平台币" prop="coin">
<el-input-number
v-model="formData.coin"
@@ -221,6 +238,8 @@
phone: '',
password: '',
status: 1 as number,
/** 所属后台管理员 IDSystemUser.id */
admin_id: null as number | null,
coin: 0 as number,
/** 彩金池配置 ID空 = 自定义权重,否则 = DiceLotteryConfig.id */
lottery_config_id: null as number | null,
@@ -237,6 +256,12 @@
const lotteryConfigOptions = ref<Array<{ id: number; name: string }>>([])
/** 彩金池选项加载中 */
const lotteryConfigLoading = ref(false)
/** 后台管理员下拉选项SystemUser */
const systemUserOptions = ref<
Array<{ id: number; username: string; realname: string; label: string }>
>([])
/** 管理员选项加载中 */
const systemUserOptionsLoading = ref(false)
/** 当前选中的 DiceLotteryConfig 完整数据(用于展示) */
const currentLotteryConfig = ref<Record<string, any> | null>(null)
@@ -306,10 +331,22 @@
}
}
/** 加载后台管理员选项 */
async function loadSystemUserOptions() {
systemUserOptionsLoading.value = true
try {
systemUserOptions.value = await api.getSystemUserOptions()
} catch {
systemUserOptions.value = []
} finally {
systemUserOptionsLoading.value = false
}
}
const initPage = async () => {
currentLotteryConfig.value = null
Object.assign(formData, initialFormData)
await loadLotteryConfigOptions()
await Promise.all([loadLotteryConfigOptions(), loadSystemUserOptions()])
if (props.data) {
await nextTick()
initForm()
@@ -355,7 +392,7 @@
if (numKeys.includes(key)) {
if (key === 'id') {
;(formData as any)[key] = val != null ? Number(val) || null : null
} else if (key === 'lottery_config_id') {
} else if (key === 'lottery_config_id' || key === 'admin_id') {
const num = Number(val)
;(formData as any)[key] = val != null && !Number.isNaN(num) && num !== 0 ? num : null
} else {