Browse Source

feat:拖拽到画布问题

ananzhusen 1 year ago
parent
commit
027d8b0bfb
1 changed files with 31 additions and 5 deletions
  1. 31 5
      src/views/components/Graphics.vue

+ 31 - 5
src/views/components/Graphics.vue

@@ -457,6 +457,13 @@ const componentCaches = [];
 const materials = [];
 const materials = [];
 const pngs = [];
 const pngs = [];
 
 
+const components = [
+  {
+    name:"默认",
+    list:[]
+  }
+];
+
 let dropped = false;
 let dropped = false;
 const chargeDialog = reactive<any>({});
 const chargeDialog = reactive<any>({});
 const wechatPayDialog = reactive<any>({
 const wechatPayDialog = reactive<any>({
@@ -601,9 +608,24 @@ const groupChange = async (name: string) => {
           loading.value = true;
           loading.value = true;
           componentCaches.push(...(await getCaseProjects('系统组件',1)));
           componentCaches.push(...(await getCaseProjects('系统组件',1)));
           loading.value = false;
           loading.value = false;
+          for (const component of componentCaches) {
+            if(component.case){
+             let group =  components.filter((item)=>{item.name===component.case});
+             if(group&&group.length){
+              group[0].list.push(component);
+             }else{
+              components.push({
+                name:component.case,
+                list:[component]
+              })
+             }
+            }else{
+              components[0].list.push(component);
+            }
+          }
         }
         }
         groupType.value = 1;
         groupType.value = 1;
-        subGroups.value = componentCaches;
+        subGroups.value = components;
         lastName = name;
         lastName = name;
       } else {
       } else {
           // subGroups.value = await getUserComponents();
           // subGroups.value = await getUserComponents();
@@ -706,9 +728,9 @@ const getCollectionImageList = async (name?: string, collection?: string, userFl
   }
   }
 
 
   for (const item of res.list) {
   for (const item of res.list) {
-    // if(collection === 'v.component') {
-    //   item.component = true;
-    // }
+    if(collection === 'v.component') {
+      item.component = true;
+    }
     if (item.folder && resultsMap[item.folder]) {
     if (item.folder && resultsMap[item.folder]) {
       resultsMap[item.folder].push(item);
       resultsMap[item.folder].push(item);
     } else {
     } else {
@@ -811,7 +833,11 @@ const getCaseProjects = async (name: string,systemFlag = 1, current = 1, pageSiz
     if (!item.id) {
     if (!item.id) {
       item.id = item._id;
       item.id = item._id;
     }
     }
-    item.draggable = false;
+    if(name !== '系统组件'){
+      item.draggable = false;
+    }else{
+      item.component = true;
+    }
   }
   }
   return ret.list;
   return ret.list;
 };
 };