Explorar el Código

1-30-zl-前端

林小张 hace 2 meses
padre
commit
35feeb29d1

+ 2 - 2
src/components/ImageUpload/index.vue

@@ -226,8 +226,8 @@ const listToString = (list: any[], separator?: string) => {
   let strs = '';
   separator = separator || ',';
   for (const i in list) {
-    if (undefined !== list[i].ossId && list[i].url.indexOf('blob:') !== 0) {
-      strs += list[i].ossId + separator;
+    if (undefined !== list[i].url && list[i].url.indexOf('blob:') !== 0) {
+      strs += list[i].url + separator;
     }
   }
   return strs != '' ? strs.substring(0, strs.length - 1) : '';

+ 2 - 22
src/views/platform/decoration/carousel/index.vue

@@ -139,7 +139,6 @@
 
 <script setup name="DecorationCarousel" lang="ts">
 import { listAdContent, addAdContent, updateAdContent, delAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 import dayjs from 'dayjs';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -202,25 +201,7 @@ const getList = async () => {
     params.endTime = dateRange.value[1];
   }
   const res = await listAdContent(params);
-  const rows = res.rows || [];
-  // 把 ossId 转换成真正的图片 URL
-  const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-  if (ossIds) {
-    try {
-      const ossRes = await listByIds(ossIds);
-      const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-      rows.forEach((item: any) => {
-        // 保存原始ossId用于编辑回显
-        item.imageOssId = item.imageUrl;
-        if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-          item.imageUrl = ossMap.get(String(item.imageUrl));
-        }
-      });
-    } catch (e) {
-      console.error('获取图片URL失败', e);
-    }
-  }
-  carouselList.value = rows;
+  carouselList.value = res.rows || [];
   total.value = res.total || 0;
   loading.value = false;
 };
@@ -269,8 +250,7 @@ const handleUpdate = (row: any) => {
   form.value = {
     ...row,
     adType: 'decoration_banner',
-    // 编辑时用ossId,这样image-upload组件才能正确回显
-    imageUrl: row.imageOssId || row.imageUrl || '',
+    imageUrl: row.imageUrl || '',
     status: row.status ?? 1,
     color: row.color || '#ffffff',
     remark: row.remark || '',

+ 1 - 12
src/views/platform/decoration/caseAd/index.vue

@@ -21,7 +21,6 @@ import { ref, onMounted, watch } from 'vue';
 import { ElMessage } from 'element-plus';
 import { Picture } from '@element-plus/icons-vue';
 import { listAdContent, updateAdContent, addAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 import dayjs from 'dayjs';
 
 const uploadRef = ref();
@@ -54,17 +53,7 @@ const loadAdData = async () => {
       adData.value.startTime = item.startTime || '';
       adData.value.endTime = item.endTime || '';
       imageOssId.value = item.imageUrl || '';
-      // 获取图片URL
-      if (item.imageUrl) {
-        try {
-          const ossRes = await listByIds(item.imageUrl);
-          if (ossRes.data && ossRes.data.length > 0) {
-            imageUrl.value = ossRes.data[0].url;
-          }
-        } catch (e) {
-          console.error('获取图片URL失败', e);
-        }
-      }
+      imageUrl.value = item.imageUrl || '';
     }
   } catch (error) {
     console.error('加载广告数据失败', error);

+ 2 - 20
src/views/platform/decoration/floorAd/index.vue

@@ -121,7 +121,6 @@ import { ElMessage } from 'element-plus';
 import type { FormInstance } from 'element-plus';
 import { Picture } from '@element-plus/icons-vue';
 import { listAdContent, updateAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 import dayjs from 'dayjs';
 
 // 当前标签页
@@ -163,24 +162,7 @@ const loadAdList = async () => {
   try {
     const adType = adTypeMap[activeTab.value];
     const res = await listAdContent({ adType, pageSize: 100 });
-    const rows = res.rows || [];
-    // 转换图片URL
-    const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-    if (ossIds) {
-      try {
-        const ossRes = await listByIds(ossIds);
-        const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-        rows.forEach((item: any) => {
-          if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-            item.imageOssId = item.imageUrl;
-            item.imageUrl = ossMap.get(String(item.imageUrl));
-          }
-        });
-      } catch (e) {
-        console.error('获取图片URL失败', e);
-      }
-    }
-    adList.value = rows;
+    adList.value = res.rows || [];
     // 不默认选中,点击才展开
     selectedIndex.value = null;
   } catch (error) {
@@ -214,7 +196,7 @@ const loadFormData = () => {
     title: item.title || '',
     remark: item.remark || '',
     link: item.link || '',
-    imageUrl: item.imageOssId || item.imageUrl || '',
+    imageUrl: item.imageUrl || '',
     color: item.color || '#e74c3c',
     sort: item.sort || 0,
     status: item.status ?? 1,

+ 2 - 19
src/views/platform/gift/banner/index.vue

@@ -95,7 +95,6 @@ import type { FormInstance } from 'element-plus';
 import { Picture } from '@element-plus/icons-vue';
 import dayjs from 'dayjs';
 import { listAdContent, addAdContent, updateAdContent, delAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -145,23 +144,7 @@ const getList = async () => {
       pageNum: queryParams.pageNum,
       pageSize: queryParams.pageSize
     });
-    const rows = res.rows || [];
-    const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-    if (ossIds) {
-      try {
-        const ossRes = await listByIds(ossIds);
-        const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-        rows.forEach((item: any) => {
-          item.imageOssId = item.imageUrl;
-          if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-            item.imageUrl = ossMap.get(String(item.imageUrl));
-          }
-        });
-      } catch (e) {
-        console.error('获取图片URL失败', e);
-      }
-    }
-    bannerList.value = rows;
+    bannerList.value = res.rows || [];
     total.value = res.total || 0;
   } catch (error) {
     console.error('加载列表失败', error);
@@ -190,7 +173,7 @@ const handleEdit = (row: any) => {
   form.value = {
     ...row,
     adType: AD_TYPE,
-    imageUrl: row.imageOssId || row.imageUrl || '',
+    imageUrl: row.imageUrl || '',
     status: row.status ?? 1,
     color: row.color || '#ffffff',
     remark: row.remark || '',

+ 2 - 22
src/views/platform/gift/carousel/index.vue

@@ -172,7 +172,6 @@ import type { ComponentInternalInstance } from 'vue';
 import type { ElFormInstance } from 'element-plus';
 import dayjs from 'dayjs';
 import { listAdContent, addAdContent, updateAdContent, delAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -235,25 +234,7 @@ const getList = async () => {
     params.endTime = dateRange.value[1];
   }
   const res = await listAdContent(params);
-  const rows = res.rows || [];
-  // 把 ossId 转换成真正的图片 URL
-  const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-  if (ossIds) {
-    try {
-      const ossRes = await listByIds(ossIds);
-      const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-      rows.forEach((item: any) => {
-        if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-          // 保存原始ossId用于编辑回显
-          item.imageOssId = item.imageUrl;
-          item.imageUrl = ossMap.get(String(item.imageUrl));
-        }
-      });
-    } catch (e) {
-      console.error('获取图片URL失败', e);
-    }
-  }
-  carouselList.value = rows;
+  carouselList.value = res.rows || [];
   total.value = res.total || 0;
   loading.value = false;
 };
@@ -302,8 +283,7 @@ const handleUpdate = (row: any) => {
   form.value = {
     ...row,
     adType: 'gift_banner',
-    // 使用原始ossId用于image-upload组件回显
-    imageUrl: row.imageOssId || row.imageUrl,
+    imageUrl: row.imageUrl || '',
     status: row.status ?? 1,
     color: row.color || '#ffffff',
     remark: row.remark || '',

+ 1 - 20
src/views/platform/gift/icon/index.vue

@@ -119,7 +119,6 @@ import type { ComponentInternalInstance } from 'vue';
 import type { FormInstance } from 'element-plus';
 import dayjs from 'dayjs';
 import { listAdContent, addAdContent, updateAdContent, delAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -168,25 +167,7 @@ const getList = async () => {
     pageSize: queryParams.value.pageSize,
     adType: queryParams.value.adType
   });
-  const rows = res.rows || [];
-  // 把 ossId 转换成真正的图片 URL
-  const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-  if (ossIds) {
-    try {
-      const ossRes = await listByIds(ossIds);
-      const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-      rows.forEach((item: any) => {
-        // 保存原始ossId用于编辑回显
-        item.imageOssId = item.imageUrl;
-        if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-          item.imageUrl = ossMap.get(String(item.imageUrl));
-        }
-      });
-    } catch (e) {
-      console.error('获取图片URL失败', e);
-    }
-  }
-  iconList.value = rows;
+  iconList.value = res.rows || [];
   total.value = res.total || 0;
   loading.value = false;
 };

+ 1 - 14
src/views/platform/gift/longAd/index.vue

@@ -55,7 +55,6 @@ import { ElMessage } from 'element-plus';
 import { Picture } from '@element-plus/icons-vue';
 import dayjs from 'dayjs';
 import { listAdContent, addAdContent, updateAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 
 const AD_TYPE = 'gift_long_ad';
 
@@ -64,7 +63,6 @@ const showForm = ref(false);
 const adData = ref({
   id: null as number | null,
   imageUrl: '',
-  imageOssId: '',
   link: ''
 });
 
@@ -80,21 +78,10 @@ const loadAdData = async () => {
     if (rows.length > 0) {
       const data = rows[0];
       adData.value.id = data.id;
-      adData.value.imageOssId = data.imageUrl;
+      adData.value.imageUrl = data.imageUrl || '';
       adData.value.link = data.link || '';
       form.link = data.link || '';
       form.imageUrl = data.imageUrl || '';
-      // 转换图片URL
-      if (data.imageUrl) {
-        try {
-          const ossRes = await listByIds(data.imageUrl);
-          if (ossRes.data && ossRes.data.length > 0) {
-            adData.value.imageUrl = ossRes.data[0].url;
-          }
-        } catch (e) {
-          console.error('获取图片URL失败', e);
-        }
-      }
     }
   } catch (error) {
     console.error('加载广告数据失败', error);

+ 2 - 19
src/views/platform/gift/recommendAd/index.vue

@@ -95,7 +95,6 @@ import type { FormInstance } from 'element-plus';
 import { Picture } from '@element-plus/icons-vue';
 import dayjs from 'dayjs';
 import { listAdContent, addAdContent, updateAdContent, delAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -145,23 +144,7 @@ const getList = async () => {
       pageNum: queryParams.pageNum,
       pageSize: queryParams.pageSize
     });
-    const rows = res.rows || [];
-    const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-    if (ossIds) {
-      try {
-        const ossRes = await listByIds(ossIds);
-        const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-        rows.forEach((item: any) => {
-          item.imageOssId = item.imageUrl;
-          if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-            item.imageUrl = ossMap.get(String(item.imageUrl));
-          }
-        });
-      } catch (e) {
-        console.error('获取图片URL失败', e);
-      }
-    }
-    adList.value = rows;
+    adList.value = res.rows || [];
     total.value = res.total || 0;
   } catch (error) {
     console.error('加载列表失败', error);
@@ -190,7 +173,7 @@ const handleEdit = (row: any) => {
   form.value = {
     ...row,
     adType: AD_TYPE,
-    imageUrl: row.imageOssId || row.imageUrl || '',
+    imageUrl: row.imageUrl || '',
     status: row.status ?? 1,
     color: row.color || '#ffffff',
     remark: row.remark || '',

+ 2 - 22
src/views/platform/industrial/carousel/index.vue

@@ -139,7 +139,6 @@
 
 <script setup name="IndustrialCarousel" lang="ts">
 import { listAdContent, addAdContent, updateAdContent, delAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 import dayjs from 'dayjs';
 
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -202,25 +201,7 @@ const getList = async () => {
     params.endTime = dateRange.value[1];
   }
   const res = await listAdContent(params);
-  const rows = res.rows || [];
-  // 把 ossId 转换成真正的图片 URL
-  const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-  if (ossIds) {
-    try {
-      const ossRes = await listByIds(ossIds);
-      const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-      rows.forEach((item: any) => {
-        if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-          // 保存原始ossId用于编辑回显
-          item.imageOssId = item.imageUrl;
-          item.imageUrl = ossMap.get(String(item.imageUrl));
-        }
-      });
-    } catch (e) {
-      console.error('获取图片URL失败', e);
-    }
-  }
-  carouselList.value = rows;
+  carouselList.value = res.rows || [];
   total.value = res.total || 0;
   loading.value = false;
 };
@@ -269,8 +250,7 @@ const handleUpdate = (row: any) => {
   form.value = {
     ...row,
     adType: 'industrial_banner',
-    // 编辑时用ossId,这样image-upload组件才能正确回显
-    imageUrl: row.imageOssId || row.imageUrl || '',
+    imageUrl: row.imageUrl || '',
     status: row.status ?? 1,
     color: row.color || '#ffffff',
     remark: row.remark || '',

+ 2 - 19
src/views/platform/industrial/floorAd/index.vue

@@ -152,7 +152,6 @@ import { ref, reactive, onMounted } from 'vue';
 import { ElMessage } from 'element-plus';
 import { Picture } from '@element-plus/icons-vue';
 import { listAdContent, updateAdContent, addAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 import dayjs from 'dayjs';
 
 const activeTab = ref('triple');
@@ -192,23 +191,7 @@ const loadAdList = async () => {
   try {
     const adType = adTypeMap[activeTab.value];
     const res = await listAdContent({ adType, pageSize: 100 });
-    const rows = res.rows || [];
-    const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id).join(',');
-    if (ossIds) {
-      try {
-        const ossRes = await listByIds(ossIds);
-        const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-        rows.forEach((item: any) => {
-          if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-            item.imageOssId = item.imageUrl;
-            item.imageUrl = ossMap.get(String(item.imageUrl));
-          }
-        });
-      } catch (e) {
-        console.error('获取图片URL失败', e);
-      }
-    }
-    adList.value = rows;
+    adList.value = res.rows || [];
     selectedIndex.value = null;
     selectedContactIndex.value = null;
   } catch (error) {
@@ -238,7 +221,7 @@ const loadFormData = () => {
     title: item.title || '',
     remark: item.remark || '',
     link: item.link || '',
-    imageUrl: item.imageOssId || item.imageUrl || '',
+    imageUrl: item.imageUrl || '',
     sort: item.sort || 0,
     status: item.status ?? 1,
     startTime: item.startTime ? dayjs(item.startTime).format('YYYY-MM-DD') : '',

+ 2 - 20
src/views/platform/industrial/tag/index.vue

@@ -61,7 +61,6 @@ import { ElMessage } from 'element-plus';
 import type { FormInstance } from 'element-plus';
 import { Picture, ArrowRight } from '@element-plus/icons-vue';
 import { listAdContent, updateAdContent } from '@/api/ad/content';
-import { listByIds } from '@/api/system/oss';
 import dayjs from 'dayjs';
 
 // 标签列表
@@ -71,24 +70,7 @@ const tagList = ref<any[]>([]);
 const loadTagList = async () => {
   try {
     const res = await listAdContent({ adType: 'industrial_tag', pageSize: 100 });
-    const rows = res.rows || [];
-    // 转换图片URL
-    const ossIds = rows.map((item: any) => item.imageUrl).filter((id: any) => id && !String(id).startsWith('http')).join(',');
-    if (ossIds) {
-      try {
-        const ossRes = await listByIds(ossIds);
-        const ossMap = new Map(ossRes.data.map((oss: any) => [String(oss.ossId), oss.url]));
-        rows.forEach((item: any) => {
-          if (item.imageUrl && ossMap.has(String(item.imageUrl))) {
-            item.imageOssId = item.imageUrl;
-            item.imageUrl = ossMap.get(String(item.imageUrl));
-          }
-        });
-      } catch (e) {
-        console.error('获取图片URL失败', e);
-      }
-    }
-    tagList.value = rows;
+    tagList.value = res.rows || [];
   } catch (error) {
     console.error('加载列表失败', error);
     tagList.value = [];
@@ -129,7 +111,7 @@ const handleEdit = (item: any) => {
     adType: 'industrial_tag',
     title: item.title || '',
     link: item.link || '',
-    imageUrl: item.imageOssId || item.imageUrl || '',
+    imageUrl: item.imageUrl || '',
     remark: item.remark || '',
     sort: item.sort || 0,
     status: item.status ?? 1,