Przeglądaj źródła

fix(component): 优化多个组件的功能和交互

- imageOrUrlInput: 改进 URL 输入和验证逻辑
- imageUploadCropper: 增加对普通 URL 的支持
- gameEventConfig: 更新字典选项和表单验证规则
- gameEventSchedule: 添加默认赛事选择和自动加载功能
zhou 3 tygodni temu
rodzic
commit
455fafd9c6

+ 17 - 9
src/components/ImageOrUrlInput/index.vue

@@ -37,7 +37,7 @@
         </div>
       </el-tab-pane>
       
-             <el-tab-pane label="输入链接" name="url">
+      <el-tab-pane label="输入链接" name="url">
          <div class="url-container">
            <el-input
              v-model="urlValue"
@@ -52,7 +52,7 @@
              <el-alert title="请输入有效的链接地址" type="warning" :closable="false" />
            </div>
          </div>
-       </el-tab-pane>
+      </el-tab-pane>
     </el-tabs>
 
     <el-dialog v-model="dialogVisible" title="预览" width="800px" append-to-body>
@@ -129,15 +129,17 @@ const validateUrl = (url: string) => {
 const handleUrlInput = (value: string) => {
   urlValue.value = value;
   isValidUrl.value = validateUrl(value);
-  if (isValidUrl.value) {
-    emit('update:modelValue', value);
-  }
 };
 
-// 处理URL失焦
+// 修改: 在blur事件中处理modelValue的更新,无论URL是否合法
 const handleUrlBlur = () => {
-  if (urlValue.value && isValidUrl.value) {
-    emit('update:modelValue', urlValue.value);
+  if (urlValue.value) {
+    emit('update:modelValue', urlValue.value); // 直接更新modelValue,无论URL是否合法
+    if (!isValidUrl.value) {
+      proxy?.$modal.msgWarning('请输入有效的链接地址');
+    }
+  } else {
+    emit('update:modelValue', ''); // 如果urlValue为空,清空modelValue
   }
 };
 
@@ -152,7 +154,7 @@ const handleTabClick = () => {
   }
 };
 
-// 监听 modelValue 变化
+// 修改: 监听 modelValue 变化,正确设置 urlValue
 watch(
   () => props.modelValue,
   (val: string) => {
@@ -167,7 +169,13 @@ watch(
         if (/^\d+$/.test(val)) {
           activeTab.value = 'upload';
           loadOssData(val);
+        }else{
+          // 如果不是ossID可能是普通文本,也显示在输入框中
+          activeTab.value = 'url';
+          urlValue.value = val;
+          isValidUrl.value = false;
         }
+        
       }
     } else {
       urlValue.value = '';

+ 10 - 3
src/components/ImageUploadCropper/index.vue

@@ -253,8 +253,15 @@ watch(
       if (Array.isArray(val)) {
         list = val as OssVO[];
       } else {
-        const res = await listByIds(val);
-        list = res.data;
+        // 判断是否为URL路径(包含http/https协议或相对路径)
+        if (typeof val === 'string' && (val.startsWith('http') || val.startsWith('/'))) {
+          // 直接使用URL路径作为图片显示
+          list = [{ url: val } as OssVO];
+        } else {
+          // 原有逻辑,调用API获取信息
+          const res = await listByIds(val);
+          list = res.data;
+        }
       }
       // 然后将数组转为对象数组
       fileList.value = list.map((item) => {
@@ -264,7 +271,7 @@ watch(
           itemData = { name: item, url: item };
         } else {
           // 此处name使用ossId 防止删除出现重名
-          itemData = { name: item.ossId, url: item.url, ossId: item.ossId };
+          itemData = { name: item.ossId || item.url, url: item.url, ossId: item.ossId };
         }
         return itemData;
       });

+ 12 - 6
src/views/system/gameEventConfig/index.vue

@@ -15,7 +15,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 label="状态" prop="status">
@@ -61,7 +61,7 @@
         <el-table-column label="配置描述" align="center" prop="configDesc" />
         <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">
@@ -102,7 +102,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>
@@ -136,7 +136,7 @@ import { listGameEventConfig, getGameEventConfig, delGameEventConfig, addGameEve
 import { GameEventConfigVO, GameEventConfigQuery, GameEventConfigForm } from '@/api/system/gameEventConfig/types';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
-const { game_event_status, sys_yes_no } = toRefs<any>(proxy?.useDict('game_event_status', 'sys_yes_no'));
+const { game_event_status, game_yes_no } = toRefs<any>(proxy?.useDict('game_event_status', 'game_yes_no'));
 
 const gameEventConfigList = ref<GameEventConfigVO[]>([]);
 const buttonLoading = ref(false);
@@ -180,9 +180,15 @@ const data = reactive<PageData<GameEventConfigForm, GameEventConfigQuery>>({
     }
   },
   rules: {
-    configValue: [
-      { required: true, message: "配置值不能为空", trigger: "blur" }
+    eventId: [
+      { required: true, message: "赛事ID不能为空", trigger: "blur" }
     ],
+    configKey: [
+      { required: true, message: "配置键不能为空", trigger: "blur" }
+    ],
+    // configValue: [
+    //   { required: true, message: "配置值不能为空", trigger: "blur" }
+    // ],
     configDesc: [
       { required: true, message: "配置描述不能为空", trigger: "blur" }
     ],

+ 7 - 0
src/views/system/gameEventSchedule/index.vue

@@ -205,6 +205,13 @@ const loadEventList = async () => {
       pageSize: 1000
     })
     eventList.value = res.rows
+    
+    // 如果赛事列表不为空,默认选择第一条赛事
+    if (eventList.value.length > 0 && !selectedEventId.value) {
+      selectedEventId.value = eventList.value[0].eventId
+      // 自动加载第一条赛事的数据
+      await loadEventData(selectedEventId.value)
+    }
   } catch (error) {
     ElMessage.error('加载赛事列表失败')
   }