Ver código fonte

refactor(game-event): 优化赛事管理功能

- 在 GameEventConfigType 类型中添加 typeId 字段
- 修复 imageOrUrlInput 组件中的 URL 验证逻辑
- 更新游戏事件编辑页面中的项目类型选择
- 优化游戏事件列表页面的路由监听和数据刷新
- 调整游戏事件配置类型页面的字典引用
zhou 3 semanas atrás
pai
commit
91abc63dd1

+ 14 - 4
src/api/system/gameEventConfigType/types.ts

@@ -1,4 +1,9 @@
 export interface GameEventConfigTypeVO {
+  /**
+   * 主键
+   */
+  typeId: string | number;
+
   /**
    * 类型编码
    */
@@ -37,6 +42,11 @@ export interface GameEventConfigTypeVO {
 }
 
 export interface GameEventConfigTypeForm extends BaseEntity {
+  /**
+   * 主键
+   */
+  typeId?: string | number;
+
   /**
    * 类型编码
    */
@@ -106,10 +116,10 @@ export interface GameEventConfigTypeQuery extends PageQuery {
    */
   status?: string;
 
-    /**
-     * 日期范围参数
-     */
-    params?: any;
+  /**
+   * 日期范围参数
+   */
+  params?: any;
 }
 
 

+ 7 - 15
src/components/ImageOrUrlInput/index.vue

@@ -129,17 +129,15 @@ const validateUrl = (url: string) => {
 const handleUrlInput = (value: string) => {
   urlValue.value = value;
   isValidUrl.value = validateUrl(value);
+  if (isValidUrl.value) {
+    emit('update:modelValue', value);
+  }
 };
 
-// 修改: 在blur事件中处理modelValue的更新,无论URL是否合法
+// 处理URL失焦
 const handleUrlBlur = () => {
-  if (urlValue.value) {
-    emit('update:modelValue', urlValue.value); // 直接更新modelValue,无论URL是否合法
-    if (!isValidUrl.value) {
-      proxy?.$modal.msgWarning('请输入有效的链接地址');
-    }
-  } else {
-    emit('update:modelValue', ''); // 如果urlValue为空,清空modelValue
+  if (urlValue.value && isValidUrl.value) {
+    emit('update:modelValue', urlValue.value);
   }
 };
 
@@ -154,7 +152,7 @@ const handleTabClick = () => {
   }
 };
 
-// 修改: 监听 modelValue 变化,正确设置 urlValue
+// 监听 modelValue 变化
 watch(
   () => props.modelValue,
   (val: string) => {
@@ -169,13 +167,7 @@ watch(
         if (/^\d+$/.test(val)) {
           activeTab.value = 'upload';
           loadOssData(val);
-        }else{
-          // 如果不是ossID可能是普通文本,也显示在输入框中
-          activeTab.value = 'url';
-          urlValue.value = val;
-          isValidUrl.value = false;
         }
-        
       }
     } else {
       urlValue.value = '';

+ 15 - 8
src/views/system/gameEvent/edit.vue

@@ -189,7 +189,7 @@
                   <el-input v-model="scope.row.siteLink" placeholder="请输入链接" />
                 </template>
               </el-table-column>
-              <el-table-column label="排序" prop="orderNum" width="100">
+              <el-table-column label="排序" prop="orderNum" width="180">
                 <template #default="scope">
                   <el-input-number v-model="scope.row.orderNum" :min="1" :max="999" />
                 </template>
@@ -212,12 +212,16 @@
             </div>
 
             <el-table :data="projectItems" border style="width: 100%">
-              <el-table-column label="类型" prop="projectType" width="100">
+              <el-table-column label="項目类型" prop="projectType" width="180">
                 <template #default="scope">
-                  <el-radio-group v-model="scope.row.projectType">
-                    <el-radio value="0">个人</el-radio>
-                    <el-radio value="1">团体</el-radio>
-                  </el-radio-group>
+                  <el-select v-model="scope.row.projectType" placeholder="请选择項目类型" style="width: 100%">
+                    <el-option
+                      v-for="dict in game_project_type"
+                      :key="dict.value"
+                      :label="dict.label"
+                      :value="dict.value"
+                    />
+                  </el-select>
                 </template>
               </el-table-column>
               <el-table-column label="项目名称" prop="projectName" width="200">
@@ -400,8 +404,8 @@ import { GameEventProjectForm, GameEventProjectVO } from '@/api/system/gameEvent
 const route = useRoute();
 const router = useRouter();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
-const { game_event_type, game_event_purpose, game_event_status, sys_yes_no } = toRefs<any>(
-  proxy?.useDict('game_event_type', 'game_event_purpose', 'game_event_status', 'sys_yes_no')
+const { game_event_type, game_event_purpose, game_event_status, sys_yes_no,game_project_type } = toRefs<any>(
+  proxy?.useDict('game_event_type', 'game_event_purpose', 'game_event_status', 'sys_yes_no','game_project_type')
 );
 
 // 页面状态
@@ -964,6 +968,9 @@ const saveEvent = async () => {
     await saveProjectData(savedEventId);
     
     proxy?.$modal.msgSuccess('保存成功');
+    
+    // 保存成功后,设置一个标识,表示需要刷新列表数据
+    sessionStorage.setItem('needRefreshGameEventList', 'true');
     goBack();
 
   } catch (error) {

+ 13 - 89
src/views/system/gameEvent/index.vue

@@ -160,95 +160,6 @@
 
       <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
     </el-card>
-    <!-- 添加或修改赛事基本信息对话框 -->
-    <!-- <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
-      <el-form ref="gameEventFormRef" :model="form" :rules="rules" label-width="80px">
-        <el-form-item label="赛事编号" prop="eventCode">
-          <el-input v-model="form.eventCode" placeholder="请输入赛事编号" />
-        </el-form-item>
-        <el-form-item label="赛事名称" prop="eventName">
-          <el-input v-model="form.eventName" placeholder="请输入赛事名称" />
-        </el-form-item>
-        <el-form-item label="赛事类型" prop="eventType">
-          <el-select v-model="form.eventType" placeholder="请选择赛事类型">
-            <el-option
-                v-for="dict in game_event_type"
-                :key="dict.value"
-                :label="dict.label"
-                :value="dict.value"
-            ></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="举办地点" prop="location">
-          <el-input v-model="form.location" placeholder="请输入举办地点" />
-        </el-form-item>
-        <el-form-item label="用途" prop="purpose">
-          <el-select v-model="form.purpose" placeholder="请选择用途">
-            <el-option
-                v-for="dict in game_event_purpose"
-                :key="dict.value"
-                :label="dict.label"
-                :value="dict.value"
-            ></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="开始时间" prop="startTime">
-          <el-date-picker clearable
-            v-model="form.startTime"
-            type="datetime"
-            value-format="YYYY-MM-DD HH:mm:ss"
-            placeholder="请选择开始时间">
-          </el-date-picker>
-        </el-form-item>
-        <el-form-item label="结束时间" prop="endTime">
-          <el-date-picker clearable
-            v-model="form.endTime"
-            type="datetime"
-            value-format="YYYY-MM-DD HH:mm:ss"
-            placeholder="请选择结束时间">
-          </el-date-picker>
-        </el-form-item>
-        <el-form-item label="赛事链接" prop="eventUrl">
-          <image-upload v-model="form.eventUrl"/>
-        </el-form-item>
-        <el-form-item label="裁判码" prop="refereeUrl">
-          <image-upload v-model="form.refereeUrl"/>
-        </el-form-item>
-        <el-form-item label="签到码" prop="registerUrl">
-          <image-upload v-model="form.registerUrl"/>
-        </el-form-item>
-        <el-form-item label="举办单位" prop="unit">
-          <el-input v-model="form.unit" placeholder="请输入举办单位" />
-        </el-form-item>
-        <el-form-item label="是否默认赛事" prop="isDefault">
-          <el-radio-group v-model="form.isDefault">
-            <el-radio
-              v-for="dict in sys_yes_no"
-              :key="dict.value"
-              :value="dict.value"
-            >{{dict.label}}</el-radio>
-          </el-radio-group>
-        </el-form-item>
-        <el-form-item label="状态" prop="status">
-          <el-radio-group v-model="form.status">
-            <el-radio
-              v-for="dict in game_event_status"
-              :key="dict.value"
-              :value="dict.value"
-            >{{dict.label}}</el-radio>
-          </el-radio-group>
-        </el-form-item>
-        <el-form-item label="备注" prop="remark">
-            <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
-        </el-form-item>
-      </el-form>
-      <template #footer>
-        <div class="dialog-footer">
-          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
-          <el-button @click="cancel">取 消</el-button>
-        </div>
-      </template>
-    </el-dialog> -->
     <!-- 注册 RefereeForm 组件 -->
     <RefereeForm ref="refereeFormRef" />
     <!-- 排行榜对话框 -->
@@ -555,4 +466,17 @@ const openRankingBoard = (eventId: string) => {
 onMounted(() => {
   getList();
 });
+
+// 监听路由变化,当从编辑页返回时检查是否需要刷新列表
+onActivated(() => {
+  // 检查是否有需要刷新的标识
+  const needRefresh = sessionStorage.getItem('needRefreshGameEventList');
+  if (needRefresh === 'true') {
+    // 清除标识
+    sessionStorage.removeItem('needRefreshGameEventList');
+    // 刷新列表数据
+    getList();
+  }
+});
+
 </script>

+ 5 - 5
src/views/system/gameEventConfigType/index.vue

@@ -18,7 +18,7 @@
             </el-form-item>
             <el-form-item label="是否启用" prop="isEnabled">
               <el-select v-model="queryParams.isEnabled" placeholder="请选择是否启用" clearable >
-                <el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="dict.value"/>
+                <el-option v-for="dict in game_yes_no" :key="dict.value" :label="dict.label" :value="dict.value"/>
               </el-select>
             </el-form-item>
             <el-form-item>
@@ -58,10 +58,9 @@
         <el-table-column label="排序字段" align="center" prop="sortField" />
         <el-table-column label="是否启用" align="center" prop="isEnabled">
           <template #default="scope">
-            <dict-tag :options="sys_yes_no" :value="scope.row.isEnabled"/>
+            <dict-tag :options="game_yes_no" :value="scope.row.isEnabled"/>
           </template>
         </el-table-column>
-        <el-table-column label="状态" align="center" prop="status" />
         <el-table-column label="备注" align="center" prop="remark" />
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
           <template #default="scope">
@@ -95,7 +94,7 @@
         <el-form-item label="是否启用" prop="isEnabled">
           <el-radio-group v-model="form.isEnabled">
             <el-radio
-              v-for="dict in sys_yes_no"
+              v-for="dict in game_yes_no"
               :key="dict.value"
               :value="dict.value"
             >{{dict.label}}</el-radio>
@@ -120,7 +119,7 @@ import { listGameEventConfigType, getGameEventConfigType, delGameEventConfigType
 import { GameEventConfigTypeVO, GameEventConfigTypeQuery, GameEventConfigTypeForm } from '@/api/system/gameEventConfigType/types';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
-const { sys_yes_no } = toRefs<any>(proxy?.useDict('sys_yes_no'));
+const { game_yes_no } = toRefs<any>(proxy?.useDict('game_yes_no'));
 
 const gameEventConfigTypeList = ref<GameEventConfigTypeVO[]>([]);
 const buttonLoading = ref(false);
@@ -140,6 +139,7 @@ const dialog = reactive<DialogOption>({
 });
 
 const initFormData: GameEventConfigTypeForm = {
+  typeId: undefined,
   typeCode: undefined,
   typeName: undefined,
   typeDesc: undefined,

+ 1 - 0
vite.config.ts

@@ -24,6 +24,7 @@ export default defineConfig(({ mode, command }) => {
       open: true,
       proxy: {
         [env.VITE_APP_BASE_API]: {
+          // target: 'http://meet2.sportsrobo.club:8080',
           target: 'http://localhost:8080',
           changeOrigin: true,
           ws: true,