wenkai 1 неделя назад
Родитель
Сommit
d719b7fadd

+ 1 - 1
src/views/system/activityIntroduction/index.vue

@@ -88,7 +88,7 @@
         <el-form-item label="标题" prop="title">
           <el-input v-model="form.title" placeholder="请输入标题" />
         </el-form-item>
-        <el-form-item label="内容">
+        <el-form-item label="内容" prop="content">
           <editor v-model="form.content" :min-height="192" />
         </el-form-item>
         <el-form-item label="文章类型" prop="type">

+ 4 - 8
src/views/system/gameEvent/index.vue

@@ -95,7 +95,7 @@
                   ></el-button>
                 </el-tooltip>
               </div>
-              
+
               <!-- 第二行:管理操作 -->
               <div class="button-row">
                 <el-tooltip content="下载模板" placement="top">
@@ -132,7 +132,7 @@
                   ></el-button>
                 </el-tooltip>
               </div>
-              
+
               <!-- 第三行:文章操作 -->
               <div class="button-row">
                 <el-tooltip content="编写文章" placement="top">
@@ -352,10 +352,6 @@
         <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
         <template #tip>
           <div class="text-center el-upload__tip">
-            <!--            <div class="el-upload__tip">-->
-            <!--              <el-checkbox v-model="upload.updateSupport" />-->
-            <!--              是否更新已经存在的用户数据-->
-            <!--            </div>-->
             <span>仅允许导入.xlsx格式文件。</span>
           </div>
         </template>
@@ -989,7 +985,7 @@ onActivated(() => {
   .operation-buttons {
     min-width: 180px;
   }
-  
+
   .button-row {
     gap: 4px;
   }
@@ -1006,7 +1002,7 @@ onActivated(() => {
     min-width: 160px;
     gap: 2px;
   }
-  
+
   .button-row {
     gap: 2px;
   }

+ 152 - 202
src/views/system/gameEventSchedule/index.vue

@@ -5,14 +5,10 @@
         <div class="flex items-center justify-between">
           <div class="flex items-center gap-4">
             <h3 class="text-lg font-bold">赛事日程安排</h3>
-            <el-button type="primary" @click="loadEventData()" :disabled="!defaultEvent.eventId">
-              加载赛事数据
-            </el-button>
+            <el-button type="primary" @click="loadEventData()" :disabled="!defaultEvent.eventId"> 加载赛事数据 </el-button>
           </div>
           <div>
-            <el-button type="success" @click="exportSchedule" :disabled="!defaultEvent.eventId || scheduleData.length === 0">
-              导出日程表
-            </el-button>
+            <el-button type="success" @click="exportSchedule" :disabled="!defaultEvent.eventId || scheduleData.length === 0"> 导出日程表 </el-button>
           </div>
         </div>
       </template>
@@ -22,9 +18,7 @@
         <div class="flex items-center justify-between">
           <div>
             <h3 class="text-lg font-bold">{{ defaultEvent.eventName }}</h3>
-            <p class="text-gray-600">
-              比赛时间: {{ parseTime(defaultEvent.startTime) }} 至 {{ parseTime(defaultEvent.endTime) }}
-            </p>
+            <p class="text-gray-600">比赛时间: {{ parseTime(defaultEvent.startTime) }} 至 {{ parseTime(defaultEvent.endTime) }}</p>
           </div>
           <div>
             <p>赛事地点: {{ defaultEvent.location }}</p>
@@ -37,23 +31,18 @@
         <template #header>
           <span class="font-bold">项目分组与时间安排</span>
         </template>
-        
+
         <el-tabs v-model="activeGroupTab">
-          <el-tab-pane
-            v-for="group in projectGroups"
-            :key="group.type"
-            :label="`${group.type} (${group.projects.length})`"
-            :name="group.type"
-          >
+          <el-tab-pane v-for="group in projectGroups" :key="group.type" :label="`${group.type} (${group.projects.length})`" :name="group.type">
             <el-table :data="group.projects" border class="mb-4">
-              <el-table-column label="项目名称" prop="projectName" width="150" />
+              <el-table-column label="项目名称" prop="projectName" />
               <!-- <el-table-column label="项目组别" prop="groupType" width="120" /> -->
-              <el-table-column label="项目类型" width="100">
+              <el-table-column label="项目类型">
                 <template #default="scope">
                   <dict-tag :options="game_project_type" :value="scope.row.projectType || ''" />
                 </template>
               </el-table-column>
-              <el-table-column label="比赛日期" width="180">
+              <el-table-column label="比赛日期">
                 <template #default="scope">
                   <el-date-picker
                     v-model="scope.row.scheduleDate"
@@ -65,59 +54,35 @@
                   />
                 </template>
               </el-table-column>
-              <el-table-column label="开始时间" width="180">
+              <el-table-column label="开始时间">
                 <template #default="scope">
-                  <el-time-picker
-                    v-model="scope.row.startTime"
-                    placeholder="开始时间"
-                    format="HH:mm"
-                    value-format="HH:mm"
-                    style="width: 100%"
-                  />
+                  <el-time-picker v-model="scope.row.startTime" placeholder="开始时间" format="HH:mm" value-format="HH:mm" style="width: 100%" />
                 </template>
               </el-table-column>
-              <el-table-column label="结束时间" width="180">
+              <el-table-column label="结束时间">
                 <template #default="scope">
-                  <el-time-picker
-                    v-model="scope.row.endTime"
-                    placeholder="结束时间"
-                    format="HH:mm"
-                    value-format="HH:mm"
-                    style="width: 100%"
-                  />
+                  <el-time-picker v-model="scope.row.endTime" placeholder="结束时间" format="HH:mm" value-format="HH:mm" style="width: 100%" />
                 </template>
               </el-table-column>
-              <el-table-column label="比赛场地" width="150">
+              <el-table-column label="比赛场地">
                 <template #default="scope">
                   <el-input v-model="scope.row.location" placeholder="输入比赛场地" />
                 </template>
               </el-table-column>
-              <el-table-column label="分组数" width="150">
+              <el-table-column label="分组数">
                 <template #default="scope">
-                  <el-input-number
-                    v-model="scope.row.groupNum"
-                    :min="1"
-                    :max="20"
-                    controls-position="right"
-                    size="small"
-                  />
+                  <el-input-number v-model="scope.row.groupNum" :min="1" :max="20" controls-position="right" size="small" />
                 </template>
               </el-table-column>
-              <el-table-column label="每组人数" width="150">
+              <el-table-column label="每组人数">
                 <template #default="scope">
-                  <el-input-number
-                    v-model="scope.row.participateNum"
-                    :min="1"
-                    :max="100"
-                    controls-position="right"
-                    size="small"
-                  />
+                  <el-input-number v-model="scope.row.participateNum" :min="1" :max="100" controls-position="right" size="small" />
                 </template>
               </el-table-column>
             </el-table>
           </el-tab-pane>
         </el-tabs>
-        
+
         <div class="flex justify-end">
           <el-button type="primary" @click="saveSchedule">保存日程安排</el-button>
         </div>
@@ -128,32 +93,25 @@
         <template #header>
           <span class="font-bold">日程预览</span>
         </template>
-        
+
         <el-table :data="scheduleData" border stripe>
-          <el-table-column label="日期" prop="scheduleDate" width="120" />
-          <el-table-column label="时间" width="200">
-            <template #default="scope">
-              {{ scope.row.startTime }} - {{ scope.row.endTime }}
-            </template>
+          <el-table-column label="日期" prop="scheduleDate" />
+          <el-table-column label="时间">
+            <template #default="scope"> {{ scope.row.startTime }} - {{ scope.row.endTime }}</template>
           </el-table-column>
-          <el-table-column label="项目名称" prop="projectName" width="150" />
-          <el-table-column label="项目类型" width="100">
+          <el-table-column label="项目名称" prop="projectName" />
+          <el-table-column label="项目类型">
             <template #default="scope">
               <dict-tag :options="game_project_type" :value="scope.row.projectType || ''" />
             </template>
           </el-table-column>
           <!-- <el-table-column label="项目组别" prop="groupType" width="120" /> -->
-          <el-table-column label="比赛场地" prop="location" width="120" />
-          <el-table-column label="分组数" prop="groupNum" width="80" />
-          <el-table-column label="每组人数" prop="participateNum" width="100" />
-          <el-table-column label="操作" width="100">
+          <el-table-column label="比赛场地" prop="location" />
+          <el-table-column label="分组数" prop="groupNum" />
+          <el-table-column label="每组人数" prop="participateNum" />
+          <el-table-column label="操作">
             <template #default="scope">
-              <el-button 
-                type="danger" 
-                size="small" 
-                @click="deleteSchedule(scope.row)"
-                v-hasPermi="['system:gameeventproject:remove']"
-              >
+              <el-button type="danger" size="small" @click="deleteSchedule(scope.row)" v-hasPermi="['system:gameeventproject:remove']">
                 删除
               </el-button>
             </template>
@@ -165,44 +123,44 @@
 </template>
 
 <script setup name="GameEventSchedule" lang="ts">
-import { ref, reactive, computed, onMounted } from 'vue'
-import { listGameEventProject, updateGameEventProject } from '@/api/system/gameEventProject'
-import { getDefaultEvent } from '@/api/system/gameEvent'
-import { GameEventVO } from '@/api/system/gameEvent/types'
-import { GameEventProjectVO } from '@/api/system/gameEventProject/types'
-import { parseTime } from '@/utils/ruoyi'
-import { ElMessage, ElMessageBox } from 'element-plus'
-import DictTag from '@/components/DictTag/index.vue'
-
-const { proxy } = getCurrentInstance() as any
+import { ref, reactive, computed, onMounted } from 'vue';
+import { listGameEventProject, updateGameEventProject } from '@/api/system/gameEventProject';
+import { getDefaultEvent } from '@/api/system/gameEvent';
+import { GameEventVO } from '@/api/system/gameEvent/types';
+import { GameEventProjectVO } from '@/api/system/gameEventProject/types';
+import { parseTime } from '@/utils/ruoyi';
+import { ElMessage, ElMessageBox } from 'element-plus';
+import DictTag from '@/components/DictTag/index.vue';
+
+const { proxy } = getCurrentInstance() as any;
 const { game_project_type } = toRefs<any>(proxy?.useDict('game_project_type'));
 
 // 默认赛事信息
-const defaultEvent = ref<GameEventVO>({} as GameEventVO)
+const defaultEvent = ref<GameEventVO>({} as GameEventVO);
 // 项目分组(按项目类型分组)
-const projectGroups = ref<{type: string, projects: GameEventProjectVO[]}[]>([])
+const projectGroups = ref<{ type: string; projects: GameEventProjectVO[] }[]>([]);
 // 活动的项目分组标签页
-const activeGroupTab = ref('个人')
+const activeGroupTab = ref('个人');
 // 日程数据(用于预览和导出)
-const scheduleData = ref<GameEventProjectVO[]>([])
+const scheduleData = ref<GameEventProjectVO[]>([]);
 
 // 获取默认赛事
 const loadDefaultEvent = async () => {
   try {
-    const res = await getDefaultEvent()
-    defaultEvent.value = res.data
+    const res = await getDefaultEvent();
+    defaultEvent.value = res.data;
   } catch (error) {
-    ElMessage.error('获取默认赛事失败')
+    ElMessage.error('获取默认赛事失败');
   }
-}
+};
 
 // 加载赛事数据
 const loadEventData = async () => {
   if (!defaultEvent.value.eventId) {
-    ElMessage.warning('请先指定默认赛事')
-    return
+    ElMessage.warning('请先指定默认赛事');
+    return;
   }
-  
+
   try {
     // 获取赛事项目
     const projectRes = await listGameEventProject({
@@ -211,95 +169,91 @@ const loadEventData = async () => {
       pageSize: 1000,
       orderByColumn: '',
       isAsc: ''
-    })
-    
+    });
+
     // 按项目类型分组
-    const groups: { [key: string]: GameEventProjectVO[] } = {}
-    projectRes.rows.forEach(project => {
+    const groups: { [key: string]: GameEventProjectVO[] } = {};
+    projectRes.rows.forEach((project) => {
       // 使用字典标签作为分组键
-      const projectTypeDict = game_project_type.value.find((dict: any) => dict.value === project.projectType)
-      const type = projectTypeDict ? projectTypeDict.label : '未知类型'
+      const projectTypeDict = game_project_type.value.find((dict: any) => dict.value === project.projectType);
+      const type = projectTypeDict ? projectTypeDict.label : '未知类型';
       if (!groups[type]) {
-        groups[type] = []
+        groups[type] = [];
       }
       // 初始化时间字段
       // 从数据库加载时,将开始时间和结束时间拆分为日期和时间部分
       if (project.startTime) {
         // 提取日期部分
-        project.scheduleDate = project.startTime.split(' ')[0]
+        project.scheduleDate = project.startTime.split(' ')[0];
         // 只保留时间部分
-        project.startTime = project.startTime.split(' ')[1]?.substring(0, 5) || ''
+        project.startTime = project.startTime.split(' ')[1]?.substring(0, 5) || '';
       }
-      
+
       if (project.endTime) {
         // 只保留时间部分(日期部分应该与startTime相同)
-        project.endTime = project.endTime.split(' ')[1]?.substring(0, 5) || ''
+        project.endTime = project.endTime.split(' ')[1]?.substring(0, 5) || '';
       }
-      
-      if (!project.groupNum) project.groupNum = 1
-      if (!project.participateNum) project.participateNum = 1
-      groups[type].push(project)
-    })
-    
-    projectGroups.value = Object.keys(groups).map(type => ({
+
+      if (!project.groupNum) project.groupNum = 1;
+      if (!project.participateNum) project.participateNum = 1;
+      groups[type].push(project);
+    });
+
+    projectGroups.value = Object.keys(groups).map((type) => ({
       type,
       projects: groups[type]
-    }))
-    
+    }));
+
     // 设置默认活动标签页
     if (projectGroups.value.length > 0) {
-      activeGroupTab.value = projectGroups.value[0].type
+      activeGroupTab.value = projectGroups.value[0].type;
     }
-    
+
     // 更新日程预览数据
-    updateScheduleData()
-    
-    ElMessage.success('赛事数据加载成功')
+    updateScheduleData();
+
+    ElMessage.success('赛事数据加载成功');
   } catch (error) {
-    ElMessage.error('加载赛事数据失败')
+    ElMessage.error('加载赛事数据失败');
   }
-}
+};
 
 // 更新日程预览数据
 const updateScheduleData = () => {
-  const allProjects: GameEventProjectVO[] = []
-  projectGroups.value.forEach(group => {
-    group.projects.forEach(project => {
+  const allProjects: GameEventProjectVO[] = [];
+  projectGroups.value.forEach((group) => {
+    group.projects.forEach((project) => {
       // 只添加已安排时间的项目
       if (project.scheduleDate && project.startTime && project.endTime) {
-        allProjects.push(project)
+        allProjects.push(project);
       }
-    })
-  })
-  
+    });
+  });
+
   // 按日期和时间排序
   scheduleData.value = allProjects.sort((a, b) => {
     if (a.scheduleDate !== b.scheduleDate) {
-      return a.scheduleDate.localeCompare(b.scheduleDate)
+      return a.scheduleDate.localeCompare(b.scheduleDate);
     }
-    return a.startTime.localeCompare(b.startTime)
-  })
-}
+    return a.startTime.localeCompare(b.startTime);
+  });
+};
 
 // 保存日程安排
 const saveSchedule = async () => {
   try {
-    const allProjects: GameEventProjectVO[] = []
-    projectGroups.value.forEach(group => {
-      allProjects.push(...group.projects)
-    })
-    
+    const allProjects: GameEventProjectVO[] = [];
+    projectGroups.value.forEach((group) => {
+      allProjects.push(...group.projects);
+    });
+
     // 保存每个项目的时间安排
     for (const project of allProjects) {
       // 组合日期和时间部分为完整的日期时间格式
-      const startDateTime = project.scheduleDate && project.startTime 
-        ? `${project.scheduleDate} ${project.startTime}:00` 
-        : null;
-      
-      const endDateTime = project.scheduleDate && project.endTime 
-        ? `${project.scheduleDate} ${project.endTime}:00` 
-        : null;
-      
+      const startDateTime = project.scheduleDate && project.startTime ? `${project.scheduleDate} ${project.startTime}:00` : null;
+
+      const endDateTime = project.scheduleDate && project.endTime ? `${project.scheduleDate} ${project.endTime}:00` : null;
+
       await updateGameEventProject({
         projectId: project.projectId,
         startTime: startDateTime,
@@ -311,30 +265,26 @@ const saveSchedule = async () => {
         eventId: defaultEvent.value.eventId,
         projectName: project.projectName,
         projectType: project.projectType,
-        groupType: project.groupType,
-      } as any)
+        groupType: project.groupType
+      } as any);
     }
-    
-    ElMessage.success('日程安排保存成功')
-    updateScheduleData()
+
+    ElMessage.success('日程安排保存成功');
+    updateScheduleData();
   } catch (error) {
-    ElMessage.error('保存日程安排失败')
+    ElMessage.error('保存日程安排失败');
   }
-}
+};
 
 // 删除日程安排
 const deleteSchedule = async (project: GameEventProjectVO) => {
   try {
-    await ElMessageBox.confirm(
-      `确定要删除项目 "${project.projectName}" 的日程安排吗?`,
-      '删除确认',
-      {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }
-    )
-    
+    await ElMessageBox.confirm(`确定要删除项目 "${project.projectName}" 的日程安排吗?`, '删除确认', {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning'
+    });
+
     // 清除该项目的时间安排
     await updateGameEventProject({
       projectId: project.projectId,
@@ -347,45 +297,45 @@ const deleteSchedule = async (project: GameEventProjectVO) => {
       eventId: defaultEvent.value.eventId,
       projectName: project.projectName,
       projectType: project.projectType,
-      groupType: project.groupType,
-    } as any)
-    
+      groupType: project.groupType
+    } as any);
+
     // 更新本地数据
-    const group = projectGroups.value.find(g => {
-      const projectTypeDict = game_project_type.value.find((dict: any) => dict.value === project.projectType)
-      const type = projectTypeDict ? projectTypeDict.label : '未知类型'
-      return g.type === type
-    })
+    const group = projectGroups.value.find((g) => {
+      const projectTypeDict = game_project_type.value.find((dict: any) => dict.value === project.projectType);
+      const type = projectTypeDict ? projectTypeDict.label : '未知类型';
+      return g.type === type;
+    });
     if (group) {
-      const projectItem = group.projects.find(p => p.projectId === project.projectId)
+      const projectItem = group.projects.find((p) => p.projectId === project.projectId);
       if (projectItem) {
-        projectItem.scheduleDate = ''
-        projectItem.startTime = ''
-        projectItem.endTime = ''
+        projectItem.scheduleDate = '';
+        projectItem.startTime = '';
+        projectItem.endTime = '';
       }
     }
-    
-    ElMessage.success('日程安排删除成功')
-    updateScheduleData()
+
+    ElMessage.success('日程安排删除成功');
+    updateScheduleData();
   } catch (error) {
     if (error !== 'cancel') {
-      ElMessage.error('删除日程安排失败')
+      ElMessage.error('删除日程安排失败');
     }
   }
-}
+};
 
 // 导出日程表
 const exportSchedule = () => {
   if (scheduleData.value.length === 0) {
-    ElMessage.warning('暂无日程安排数据可导出')
-    return
+    ElMessage.warning('暂无日程安排数据可导出');
+    return;
   }
-  
+
   // 创建表格数据
-  const headers = ['日期', '时间', '项目名称', '项目类型', '项目组别', '比赛场地', '分组数', '每组人数']
-  let csvContent = headers.join(',') + '\n'
-  
-  scheduleData.value.forEach(item => {
+  const headers = ['日期', '时间', '项目名称', '项目类型', '项目组别', '比赛场地', '分组数', '每组人数'];
+  let csvContent = headers.join(',') + '\n';
+
+  scheduleData.value.forEach((item) => {
     const row = [
       item.scheduleDate,
       `${item.startTime}-${item.endTime}`,
@@ -395,30 +345,30 @@ const exportSchedule = () => {
       item.location,
       item.groupNum,
       item.participateNum
-    ].join(',')
-    csvContent += row + '\n'
-  })
-  
+    ].join(',');
+    csvContent += row + '\n';
+  });
+
   // 创建下载链接
-  const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' })
-  const link = document.createElement('a')
-  const url = URL.createObjectURL(blob)
-  link.setAttribute('href', url)
-  link.setAttribute('download', `赛事日程安排_${defaultEvent.value.eventName}_${parseTime(new Date(), '{y}{m}{d}')}.csv`)
-  link.style.visibility = 'hidden'
-  document.body.appendChild(link)
-  link.click()
-  document.body.removeChild(link)
-}
+  const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' });
+  const link = document.createElement('a');
+  const url = URL.createObjectURL(blob);
+  link.setAttribute('href', url);
+  link.setAttribute('download', `赛事日程安排_${defaultEvent.value.eventName}_${parseTime(new Date(), '{y}{m}{d}')}.csv`);
+  link.style.visibility = 'hidden';
+  document.body.appendChild(link);
+  link.click();
+  document.body.removeChild(link);
+};
 
 onMounted(() => {
   loadDefaultEvent().then(() => {
     // 自动加载默认赛事数据
     if (defaultEvent.value.eventId) {
-      loadEventData()
+      loadEventData();
     }
-  })
-})
+  });
+});
 </script>
 
 <style scoped>
@@ -457,4 +407,4 @@ onMounted(() => {
 .text-gray-600 {
   color: #6b7280;
 }
-</style>
+</style>