|
@@ -402,6 +402,19 @@ const isEdit = ref(false);
|
|
|
const activeTab = ref('basic');
|
|
|
const saveLoading = ref(false);
|
|
|
|
|
|
+// 判断是否为默认赛事操作
|
|
|
+const isDefaultEventOperation = () => {
|
|
|
+ return basicForm.value.isDefault === '0';
|
|
|
+};
|
|
|
+
|
|
|
+// 获取有效的赛事ID(默认赛事返回空字符串,否则返回实际ID)
|
|
|
+const getEffectiveEventId = (eventId?: string | number): string => {
|
|
|
+ if (isDefaultEventOperation()) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ return String(eventId || (route.params.id as string) || '');
|
|
|
+};
|
|
|
+
|
|
|
// 表单引用
|
|
|
const basicFormRef = ref<ElFormInstance>();
|
|
|
|
|
@@ -456,21 +469,22 @@ const loadEventData = async (eventId: string | number) => {
|
|
|
// 填充基本信息
|
|
|
Object.assign(basicForm.value, data);
|
|
|
|
|
|
+ // 获取有效的赛事ID
|
|
|
+ const effectiveEventId = getEffectiveEventId(eventId);
|
|
|
+
|
|
|
// 加载图片配置数据
|
|
|
try {
|
|
|
- await loadImageConfigData(eventId);
|
|
|
+ await loadImageConfigData(effectiveEventId);
|
|
|
} catch (error) {
|
|
|
console.warn('加载图片配置数据失败,继续加载其他数据:', error);
|
|
|
// 不中断其他数据的加载
|
|
|
}
|
|
|
|
|
|
- await loadMenuData(eventId); // 加载菜单数据
|
|
|
- await loadGroupData(eventId); // 加载分组数据
|
|
|
- await loadProjectData(eventId); // 加载项目数据
|
|
|
- await loadTeamData(eventId); //// 加载队伍数据
|
|
|
- await loadConfigData(eventId); // 加载配置数据
|
|
|
- // TODO: 加载菜单、项目、配置数据
|
|
|
- // 这里需要调用相应的API来加载数据
|
|
|
+ await loadMenuData(effectiveEventId); // 加载菜单数据
|
|
|
+ await loadGroupData(effectiveEventId); // 加载分组数据
|
|
|
+ await loadProjectData(effectiveEventId); // 加载项目数据
|
|
|
+ await loadTeamData(effectiveEventId); // 加载队伍数据
|
|
|
+ await loadConfigData(effectiveEventId); // 加载配置数据
|
|
|
} catch (error) {
|
|
|
proxy?.$modal.msgError('加载赛事数据失败');
|
|
|
}
|
|
@@ -497,7 +511,7 @@ const groupItems = ref<GameEventGroupForm[]>([]);
|
|
|
const loadGroupData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventGroup({
|
|
|
- eventId,
|
|
|
+ eventId: eventId === '' ? '' : eventId,
|
|
|
pageNum: 1,
|
|
|
pageSize: 1000,
|
|
|
orderByColumn: '',
|
|
@@ -512,7 +526,7 @@ const loadGroupData = async (eventId: string | number) => {
|
|
|
const addGroupItem = () => {
|
|
|
groupItems.value.push({
|
|
|
groupId: '',
|
|
|
- eventId: '',
|
|
|
+ eventId: getEffectiveEventId(),
|
|
|
groupName: '',
|
|
|
memberGender: ''
|
|
|
});
|
|
@@ -529,7 +543,7 @@ const removeGroupItem = (index: number) => {
|
|
|
}
|
|
|
};
|
|
|
// 保存赛事分组数据
|
|
|
-const saveGroupData = async (eventId: string) => {
|
|
|
+const saveGroupData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
for (const item of groupItems.value) {
|
|
|
// 确保eventId被正确设置
|
|
@@ -555,7 +569,7 @@ const menuItems = ref<GameEventMenuForm[]>([]);
|
|
|
const loadMenuData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventMenu({
|
|
|
- eventId,
|
|
|
+ eventId: eventId === '' ? '' : eventId,
|
|
|
pageNum: 1,
|
|
|
pageSize: 1000,
|
|
|
orderByColumn: '',
|
|
@@ -578,7 +592,7 @@ const addMenuItem = () => {
|
|
|
isFrame: 1,
|
|
|
siteLink: '',
|
|
|
orderNum: menuItems.value.length + 1,
|
|
|
- eventId: isEdit.value ? (route.params.id as string) : '' // 关联赛事ID
|
|
|
+ eventId: getEffectiveEventId() // 使用有效的赛事ID
|
|
|
});
|
|
|
};
|
|
|
// 删除菜单项
|
|
@@ -593,7 +607,7 @@ const removeMenuItem = (index: number) => {
|
|
|
}
|
|
|
};
|
|
|
// 保存菜单数据
|
|
|
-const saveMenuData = async (eventId: string) => {
|
|
|
+const saveMenuData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
for (const item of menuItems.value) {
|
|
|
// 确保eventId被正确设置
|
|
@@ -630,9 +644,9 @@ const loadImageConfigData = async (eventId: string | number) => {
|
|
|
// 获取所有图片配置模板
|
|
|
const allImageConfigs = Array.isArray(templateRes.rows) ? templateRes.rows : [];
|
|
|
|
|
|
- // 查询当前赛事的图片配置数据
|
|
|
+ // 查询当前赛事的图片配置数据(如果是默认赛事,eventId为空字符串)
|
|
|
const eventRes = await listGameEventConfig({
|
|
|
- eventId: eventId,
|
|
|
+ eventId: eventId === '' ? '' : eventId,
|
|
|
configType: 'IMAGE',
|
|
|
pageNum: 1,
|
|
|
pageSize: 100,
|
|
@@ -665,7 +679,7 @@ const loadImageConfigData = async (eventId: string | number) => {
|
|
|
const refreshImageConfigs = async () => {
|
|
|
const eventId = route.params.id as string;
|
|
|
if (eventId && eventId !== 'add') {
|
|
|
- await loadImageConfigData(eventId);
|
|
|
+ await loadImageConfigData(getEffectiveEventId(eventId));
|
|
|
} else {
|
|
|
// 新增模式,只加载配置模板
|
|
|
// await loadImageConfigTemplates();
|
|
@@ -703,7 +717,8 @@ const refreshImageConfigs = async () => {
|
|
|
// 保存图片配置数据
|
|
|
const saveImageConfigData = async (eventId?: string | number) => {
|
|
|
try {
|
|
|
- const targetEventId = eventId || (route.params.id as string);
|
|
|
+ // 如果是默认赛事操作,使用空字符串作为eventId
|
|
|
+ const targetEventId = eventId === '' ? '' : (eventId || (route.params.id as string));
|
|
|
const updates: GameEventConfigForm[] = [];
|
|
|
const adds: GameEventConfigForm[] = [];
|
|
|
|
|
@@ -750,7 +765,7 @@ const projectItems = ref<GameEventProjectForm[]>([]);
|
|
|
const loadProjectData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventProject({
|
|
|
- eventId,
|
|
|
+ eventId: eventId === '' ? '' : eventId,
|
|
|
pageNum: 1,
|
|
|
pageSize: 1000,
|
|
|
orderByColumn: '',
|
|
@@ -764,7 +779,7 @@ const loadProjectData = async (eventId: string | number) => {
|
|
|
// 添加项目项
|
|
|
const addProjectItem = () => {
|
|
|
projectItems.value.push({
|
|
|
- eventId: '',
|
|
|
+ eventId: getEffectiveEventId(),
|
|
|
projectId: '',
|
|
|
projectName: '',
|
|
|
projectType: '',
|
|
@@ -830,7 +845,7 @@ const loadConfigTypes = async () => {
|
|
|
const loadConfigData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameEventConfig({
|
|
|
- eventId,
|
|
|
+ eventId: eventId === '' ? '' : eventId,
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
orderByColumn: '',
|
|
@@ -892,7 +907,7 @@ const teamItems = ref<GameTeamForm[]>([]);
|
|
|
const loadTeamData = async (eventId: string | number) => {
|
|
|
try {
|
|
|
const res = await listGameTeam({
|
|
|
- eventId,
|
|
|
+ eventId: eventId === '' ? '' : eventId,
|
|
|
pageNum: 1,
|
|
|
pageSize: 1000,
|
|
|
orderByColumn: '',
|
|
@@ -908,7 +923,7 @@ const addTeamItem = () => {
|
|
|
teamItems.value.push({
|
|
|
teamName: '',
|
|
|
teamCode: '',
|
|
|
- eventId: '',
|
|
|
+ eventId: getEffectiveEventId(),
|
|
|
teamDescribe: '',
|
|
|
remark: ''
|
|
|
});
|
|
@@ -961,7 +976,11 @@ const saveEvent = async () => {
|
|
|
let savedEventId: string;
|
|
|
// 如果设置为默认赛事,则取消其他赛事的默认状态
|
|
|
if(basicForm.value.isDefault === '0'){
|
|
|
- handleStatusChange({ eventId: basicForm.value.eventId, isDefault: basicForm.value.isDefault } as GameEventVO);
|
|
|
+ handleStatusChange({
|
|
|
+ eventId: basicForm.value.eventId,
|
|
|
+ isDefault: basicForm.value.isDefault,
|
|
|
+ eventName: basicForm.value.eventName
|
|
|
+ } as GameEventVO);
|
|
|
}
|
|
|
|
|
|
// 保存基本信息
|
|
@@ -974,18 +993,21 @@ const saveEvent = async () => {
|
|
|
savedEventId = addRes?.data as string;
|
|
|
}
|
|
|
|
|
|
+ // 获取有效的赛事ID用于保存相关数据
|
|
|
+ const effectiveEventId = getEffectiveEventId(savedEventId);
|
|
|
+
|
|
|
// 保存图片配置数据
|
|
|
- await saveImageConfigData(savedEventId);
|
|
|
+ await saveImageConfigData(effectiveEventId);
|
|
|
// 保存赛事配置项数据
|
|
|
- await saveconfigData(savedEventId);
|
|
|
+ await saveconfigData(effectiveEventId);
|
|
|
// 保存菜单数据
|
|
|
- await saveMenuData(savedEventId);
|
|
|
+ await saveMenuData(effectiveEventId);
|
|
|
// 保存参赛队伍数据
|
|
|
- await saveTeamData(savedEventId);
|
|
|
+ await saveTeamData(effectiveEventId);
|
|
|
// 保存赛事项目分组数据
|
|
|
- await saveGroupData(savedEventId);
|
|
|
+ await saveGroupData(effectiveEventId);
|
|
|
// 保存赛事项目数据
|
|
|
- await saveProjectData(savedEventId);
|
|
|
+ await saveProjectData(effectiveEventId);
|
|
|
|
|
|
proxy?.$modal.msgSuccess('保存成功');
|
|
|
|