From f2138817fdd6e9141c5911514280b8d0b6ca08f1 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期三, 20 十一月 2024 14:48:49 +0800
Subject: [PATCH] 子组件刷新父组件不刷新页面,表单验证,upload组件预览图片,弹窗放在组件内部,bug修复

---
 src/views/fysp/check/components/ArbitraryPhoto.vue |   28 ++++++++++------------------
 1 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/views/fysp/check/components/ArbitraryPhoto.vue b/src/views/fysp/check/components/ArbitraryPhoto.vue
index 46b1c88..4593d21 100644
--- a/src/views/fysp/check/components/ArbitraryPhoto.vue
+++ b/src/views/fysp/check/components/ArbitraryPhoto.vue
@@ -19,7 +19,7 @@
     return {
       // 鏃犳暟鎹�
       typesList: [],
-      typesMap: new Map(),
+      typesMap: new Map()
     };
   },
   mounted() {
@@ -31,19 +31,6 @@
       mediafileApi.getRoutineByStGuid(this.subtask.stGuid).then((res) => {
         let typeList = [];
         let typeMap = new Map();
-        function hasThisTypeName(typeName) {
-          return typeList.map((item) => item.typeName).indexOf(typeName) != -1;
-        }
-        function addNewType(typeId, typeName, img) {
-          typeList.push({
-            typeId: typeId,
-            typeName: typeName
-          });
-          typeMap.set(typeId, [img]);
-        }
-        function addToThisType(typeId, img) {
-          typeMap.get(typeId).push(img);
-        }
         const data = res.data;
         for (const e of data) {
           let img = {
@@ -51,13 +38,18 @@
           };
           const businesstype = e.businesstype;
           const businesstypeid = e.businesstypeid;
-          if (hasThisTypeName(businesstype)) {
-            addToThisType(businesstypeid, img);
+          if (
+            typeList.find((item) => item.typeName == businesstype) != undefined
+          ) {
+            typeMap.get(businesstypeid).push(img);
           } else {
-            addNewType(businesstypeid, businesstype, img);
+            typeList.push({
+              typeId: businesstypeid,
+              typeName: businesstype
+            });
+            typeMap.set(businesstypeid, [img]);
           }
         }
-
         this.typesList = typeList;
         this.typesMap = typeMap;
       });

--
Gitblit v1.9.3