|
@@ -93,7 +93,7 @@
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="是否默认赛事" prop="isDefault">
|
|
|
- <el-radio-group v-model="basicForm.isDefault">
|
|
|
+ <el-radio-group v-model="basicForm.isDefault" >
|
|
|
<el-radio
|
|
|
v-for="dict in sys_yes_no"
|
|
|
:key="dict.value"
|
|
@@ -282,6 +282,18 @@
|
|
|
</div>
|
|
|
|
|
|
<el-table :data="configItems" border style="width: 100%">
|
|
|
+ <el-table-column label="配置类型" prop="configType" width="150">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-select v-model="scope.row.configType" placeholder="请选择配置类型" style="width: 100%">
|
|
|
+ <el-option
|
|
|
+ v-for="type in configTypes"
|
|
|
+ :key="type.typeCode"
|
|
|
+ :label="type.typeName"
|
|
|
+ :value="type.typeCode"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="配置键" prop="configKey" width="200">
|
|
|
<template #default="scope">
|
|
|
<el-input v-model="scope.row.configKey" placeholder="请输入配置键" />
|
|
@@ -387,10 +399,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="GameEventEdit" lang="ts">
|
|
|
-import { getGameEvent, addGameEvent, updateGameEvent } from '@/api/system/gameEvent';
|
|
|
+import { getGameEvent, addGameEvent, updateGameEvent,changeEventDefault } from '@/api/system/gameEvent';
|
|
|
import { GameEventVO, GameEventForm } from '@/api/system/gameEvent/types';
|
|
|
import { listGameEventConfig, addGameEventConfig, updateGameEventConfig, delGameEventConfig } from '@/api/system/gameEventConfig';
|
|
|
import { GameEventConfigVO, GameEventConfigForm } from '@/api/system/gameEventConfig/types';
|
|
|
+import { listGameEventConfigType } from '@/api/system/gameEventConfigType'; // 添加导入
|
|
|
+import { GameEventConfigTypeVO } from '@/api/system/gameEventConfigType/types'; // 添加导入
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
import { listGameEventMenu, addGameEventMenu, updateGameEventMenu, delGameEventMenu } from '@/api/system/gameEventMenu';
|
|
|
import { GameEventMenuVO, GameEventMenuForm } from '@/api/system/gameEventMenu/types';
|
|
@@ -458,18 +472,20 @@ const basicRules = {
|
|
|
// 初始化页面
|
|
|
onMounted(async () => {
|
|
|
const eventId = route.params.id as string;
|
|
|
- if (eventId && eventId !== 'add') {
|
|
|
+ if (eventId) {
|
|
|
isEdit.value = true;
|
|
|
await loadEventData(eventId);
|
|
|
} else {
|
|
|
// 新增模式,加载图片配置模板
|
|
|
- await loadImageConfigTemplates();
|
|
|
+ // await loadImageConfigTemplates();
|
|
|
}
|
|
|
+ // 加载配置类型选项
|
|
|
+ await loadConfigTypes();
|
|
|
// console.log('Initial image configs:', imageConfigItems.value); // 添加调试信息
|
|
|
});
|
|
|
|
|
|
// 加载赛事数据
|
|
|
-const loadEventData = async (eventId: string) => {
|
|
|
+const loadEventData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await getGameEvent(eventId);
|
|
|
const data = res.data;
|
|
@@ -498,11 +514,25 @@ const loadEventData = async (eventId: string) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+/** 状态修改 */
|
|
|
+const handleStatusChange = async (row: GameEventVO) => {
|
|
|
+ const text = row.isDefault === '0' ? '启用' : '停用';
|
|
|
+ try {
|
|
|
+ await proxy?.$modal.confirm('确认要"' + text + '""' + row.eventName + '"为默认赛事吗?');
|
|
|
+ await changeEventDefault(row.eventId, row.isDefault);
|
|
|
+ await loadEventData(row.eventId);
|
|
|
+ proxy?.$modal.msgSuccess(text + '成功');
|
|
|
+ } catch {
|
|
|
+ return;
|
|
|
+ } finally {
|
|
|
+ row.isDefault = row.isDefault === '0' ? '1' : '0';
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
// 赛事分组数据
|
|
|
const groupItems = ref<GameEventGroupForm[]>([]);
|
|
|
// 加载项目分组数据
|
|
|
-const loadGroupData = async (eventId: string) => {
|
|
|
+const loadGroupData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventGroup({
|
|
|
eventId,
|
|
@@ -558,14 +588,13 @@ const saveGroupData = async (eventId: string) => {
|
|
|
// 菜单列表数据
|
|
|
const menuItems = ref<GameEventMenuForm[]>([]);
|
|
|
// 加载菜单数据
|
|
|
-const loadMenuData = async (eventId: string) => {
|
|
|
+const loadMenuData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventMenu({
|
|
|
eventId,
|
|
|
pageNum: 1,
|
|
|
pageSize: 1000
|
|
|
});
|
|
|
- // console.log('Menu response:', res);
|
|
|
menuItems.value = Array.isArray(res.rows) ? res.rows : [];
|
|
|
} catch (error) {
|
|
|
proxy?.$modal.msgError('加载菜单数据失败');
|
|
@@ -603,12 +632,7 @@ const saveMenuData = async (eventId: string) => {
|
|
|
for (const item of menuItems.value) {
|
|
|
// 确保eventId被正确设置
|
|
|
const menuData = { ...item, eventId };
|
|
|
- // 如果是编辑模式且item中没有eventId,则手动添加
|
|
|
- // if (!menuData.eventId) {
|
|
|
- // menuData.eventId = eventId;
|
|
|
- // }
|
|
|
-
|
|
|
- // console.log('Menu data:', item);
|
|
|
+
|
|
|
if (item.menuId) {
|
|
|
// 更新现有菜单
|
|
|
await updateGameEventMenu(menuData);
|
|
@@ -626,7 +650,7 @@ const saveMenuData = async (eventId: string) => {
|
|
|
// 图片配置数据
|
|
|
const imageConfigItems = ref<GameEventConfigForm[]>([]);
|
|
|
// 加载图片配置数据(用于编辑模式)
|
|
|
-const loadImageConfigData = async (eventId: string) => {
|
|
|
+const loadImageConfigData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
// 先查询所有image类型的配置模板(不限制eventId,获取所有可用的图片配置项)
|
|
|
const templateRes = await listGameEventConfig({
|
|
@@ -635,11 +659,8 @@ const loadImageConfigData = async (eventId: string) => {
|
|
|
pageSize: 100
|
|
|
});
|
|
|
|
|
|
- // console.log('Template response:', templateRes);
|
|
|
-
|
|
|
// 获取所有图片配置模板
|
|
|
const allImageConfigs = Array.isArray(templateRes.rows) ? templateRes.rows : [];
|
|
|
- // console.log('All image configs:', allImageConfigs);
|
|
|
|
|
|
// 查询当前赛事的图片配置数据
|
|
|
const eventRes = await listGameEventConfig({
|
|
@@ -650,8 +671,6 @@ const loadImageConfigData = async (eventId: string) => {
|
|
|
});
|
|
|
|
|
|
const eventImageConfigs = Array.isArray(eventRes.rows) ? eventRes.rows : [];
|
|
|
- // console.log('Event image configs:', eventImageConfigs);
|
|
|
- //console.log('Event image configs:', eventRes);
|
|
|
|
|
|
// 合并配置:以模板为基础,用当前赛事的数据覆盖
|
|
|
imageConfigItems.value = allImageConfigs.map(template => {
|
|
@@ -666,7 +685,6 @@ const loadImageConfigData = async (eventId: string) => {
|
|
|
};
|
|
|
});
|
|
|
|
|
|
- // console.log('Final image config items:', imageConfigItems.value);
|
|
|
} catch (error) {
|
|
|
console.error('加载图片配置数据失败:', error);
|
|
|
proxy?.$modal.msgError('加载图片配置数据失败: ' + (error as Error).message);
|
|
@@ -680,39 +698,40 @@ const refreshImageConfigs = async () => {
|
|
|
await loadImageConfigData(eventId);
|
|
|
} else {
|
|
|
// 新增模式,只加载配置模板
|
|
|
- await loadImageConfigTemplates();
|
|
|
+ // await loadImageConfigTemplates();
|
|
|
}
|
|
|
};
|
|
|
// 加载图片配置模板(用于新增模式)
|
|
|
-const loadImageConfigTemplates = async () => {
|
|
|
- try {
|
|
|
- const res = await listGameEventConfig({
|
|
|
- configType: 'IMAGE',
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 100
|
|
|
- });
|
|
|
-
|
|
|
- // console.log('Template response (new mode):', res);
|
|
|
-
|
|
|
- const imageData = Array.isArray(res.rows) ? res.rows : []; // 修改此处,确保正确访问数组数据
|
|
|
- // console.log('Image data (new mode):', imageData);
|
|
|
-
|
|
|
- imageConfigItems.value = imageData.map(item => ({
|
|
|
- ...item,
|
|
|
- configValue: item.configValue || '', // 确保 configValue 初始化正确
|
|
|
- isEnabled: item.isEnabled || '0', // 确保 isEnabled 初始化正确
|
|
|
- status: item.status || '0' // 确保 status 初始化正确
|
|
|
- }));
|
|
|
-
|
|
|
- // console.log('Image config items (new mode):', imageConfigItems.value);
|
|
|
- } catch (error) {
|
|
|
- console.error('加载图片配置模板失败:', error);
|
|
|
- proxy?.$modal.msgError('加载图片配置模板失败: ' + (error as Error).message);
|
|
|
- imageConfigItems.value = [];
|
|
|
- }
|
|
|
-};
|
|
|
+// const loadImageConfigTemplates = async () => {
|
|
|
+// try {
|
|
|
+// const res = await listGameEventConfig({
|
|
|
+// eventId: '',
|
|
|
+// configType: 'IMAGE',
|
|
|
+// pageNum: 1,
|
|
|
+// pageSize: 100
|
|
|
+// });
|
|
|
+
|
|
|
+// // console.log('Template response (new mode):', res);
|
|
|
+
|
|
|
+// const imageData = Array.isArray(res.rows) ? res.rows : []; // 修改此处,确保正确访问数组数据
|
|
|
+// // console.log('Image data (new mode):', imageData);
|
|
|
+
|
|
|
+// imageConfigItems.value = imageData.map(item => ({
|
|
|
+// ...item,
|
|
|
+// configValue: item.configValue || '', // 确保 configValue 初始化正确
|
|
|
+// isEnabled: item.isEnabled || '0', // 确保 isEnabled 初始化正确
|
|
|
+// status: item.status || '0' // 确保 status 初始化正确
|
|
|
+// }));
|
|
|
+
|
|
|
+// // console.log('Image config items (new mode):', imageConfigItems.value);
|
|
|
+// } catch (error) {
|
|
|
+// console.error('加载图片配置模板失败:', error);
|
|
|
+// proxy?.$modal.msgError('加载图片配置模板失败: ' + (error as Error).message);
|
|
|
+// imageConfigItems.value = [];
|
|
|
+// }
|
|
|
+// };
|
|
|
// 保存图片配置数据
|
|
|
-const saveImageConfigData = async (eventId?: string) => {
|
|
|
+const saveImageConfigData = async (eventId?: string | number) => {
|
|
|
try {
|
|
|
const targetEventId = eventId || route.params.id as string;
|
|
|
const updates: GameEventConfigForm[] = [];
|
|
@@ -758,7 +777,7 @@ const handleTabClick = () => {
|
|
|
// 项目数据
|
|
|
const projectItems = ref<GameEventProjectForm[]>([]);
|
|
|
// 加载项目数据
|
|
|
-const loadProjectData = async (eventId: string) => {
|
|
|
+const loadProjectData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventProject({
|
|
|
eventId,
|
|
@@ -795,7 +814,7 @@ const removeProjectItem = (index: number) => {
|
|
|
}
|
|
|
};
|
|
|
//保存项目数据
|
|
|
-const saveProjectData = async (eventId: string) => {
|
|
|
+const saveProjectData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
for (const item of projectItems.value) {
|
|
|
// 确保eventId被正确设置
|
|
@@ -818,8 +837,24 @@ const saveProjectData = async (eventId: string) => {
|
|
|
|
|
|
// 配置信息数据
|
|
|
const configItems = ref<GameEventConfigForm[]>([]);
|
|
|
+// 配置类型选项
|
|
|
+const configTypes = ref<GameEventConfigTypeVO[]>([]);
|
|
|
+
|
|
|
+// 加载配置类型数据
|
|
|
+const loadConfigTypes = async () => {
|
|
|
+ try {
|
|
|
+ const res = await listGameEventConfigType({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 1000
|
|
|
+ });
|
|
|
+ configTypes.value = Array.isArray(res.rows) ? res.rows : [];
|
|
|
+ } catch (error) {
|
|
|
+ proxy?.$modal.msgError('加载配置类型数据失败');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
// 加载赛事配置数据
|
|
|
-const loadConfigData = async (eventId: string) => {
|
|
|
+const loadConfigData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventConfig({
|
|
|
eventId,
|
|
@@ -828,17 +863,21 @@ const loadConfigData = async (eventId: string) => {
|
|
|
});
|
|
|
configItems.value = Array.isArray(res.rows) ? res.rows : [];
|
|
|
} catch (error) {
|
|
|
- proxy?.$modal.msgError('加载赛事配置数据失败');
|
|
|
+ console.error('加载赛事配置数据失败:', error);
|
|
|
+ proxy?.$modal.msgError('加载赛事配置数据失败: ' + (error as Error).message);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
// 添加配置项
|
|
|
const addConfigItem = () => {
|
|
|
configItems.value.push({
|
|
|
configKey: '',
|
|
|
configValue: '',
|
|
|
configDesc: '',
|
|
|
+ configType: '', // 添加配置类型字段
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
// 删除配置项
|
|
|
const removeConfigItem = (index: number) => {
|
|
|
const configItem = configItems.value[index];
|
|
@@ -850,8 +889,9 @@ const removeConfigItem = (index: number) => {
|
|
|
configItems.value.splice(index, 1);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
// 保存赛事配置数据
|
|
|
-const saveconfigData = async (eventId: string) => {
|
|
|
+const saveconfigData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
for (const item of configItems.value) {
|
|
|
// 确保eventId被正确设置
|
|
@@ -875,7 +915,7 @@ const saveconfigData = async (eventId: string) => {
|
|
|
// 参赛队伍数据
|
|
|
const teamItems = ref<GameTeamForm[]>([]);
|
|
|
// 加载队伍数据
|
|
|
-const loadTeamData = async (eventId: string) => {
|
|
|
+const loadTeamData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameTeam({
|
|
|
eventId,
|
|
@@ -909,7 +949,7 @@ const removeTeamItem = (index: number) => {
|
|
|
}
|
|
|
};
|
|
|
// 保存参赛队伍数据
|
|
|
-const saveTeamData = async (eventId: string) => {
|
|
|
+const saveTeamData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
for (const item of teamItems.value) {
|
|
|
// 确保eventId被正确设置
|
|
@@ -943,6 +983,10 @@ const saveEvent = async () => {
|
|
|
};
|
|
|
|
|
|
let savedEventId: string;
|
|
|
+ // 如果设置为默认赛事,则取消其他赛事的默认状态
|
|
|
+ if(basicForm.value.isDefault === '0'){
|
|
|
+ handleStatusChange({ eventId: basicForm.value.eventId, isDefault: basicForm.value.isDefault } as GameEventVO);
|
|
|
+ }
|
|
|
|
|
|
// 保存基本信息
|
|
|
if (isEdit.value) {
|
|
@@ -951,7 +995,8 @@ const saveEvent = async () => {
|
|
|
} else {
|
|
|
const addRes = await addGameEvent(formData);
|
|
|
// 假设返回的数据中包含新创建的赛事ID
|
|
|
- savedEventId = addRes.data?.eventId || route.params.id as string;
|
|
|
+ console.log('addRes', addRes);
|
|
|
+ savedEventId = addRes?.data as string;
|
|
|
}
|
|
|
|
|
|
// 保存图片配置数据
|