فهرست منبع

♻️refactor(item): simplify selectedFiles assignment using map and filter

Shinohara Haruna 6 ماه پیش
والد
کامیت
0a7e988123
1فایلهای تغییر یافته به همراه8 افزوده شده و 6 حذف شده
  1. 8 6
      smsb-plus-ui/src/views/smsb/item/index.vue

+ 8 - 6
smsb-plus-ui/src/views/smsb/item/index.vue

@@ -525,18 +525,20 @@ const handleUpdate = async (row?: ItemVO) => {
       const fileIds = Array.isArray(res.data.fileIdList) ? res.data.fileIdList : [];
       if (fileIds.length > 0) {
         const fileRes = await listMinioData({ ids: fileIds });
-        selectedFiles.value = fileIds.map((id: string | number, idx: number) => {
-          const file = fileRes.rows.find((f: any) => String(f.id) === String(id));
-          return file
-            ? {
+        selectedFiles.value = fileIds
+          .map((id: string | number, idx: number) => {
+            const file = fileRes.rows.find((f: any) => String(f.id) === String(id));
+            return file
+              ? {
                 id: file.id,
                 name: file.originalName,
                 type: file.type,
                 duration: file.type === 1 ? 10 : Number(file.duration),
                 order: idx + 1
               }
-            : null;
-        }).filter(Boolean);
+              : null;
+          })
+          .filter(Boolean);
       } else {
         selectedFiles.value = [];
       }