Просмотр исходного кода

feat:接口更新为system&template

ananzhusen 1 год назад
Родитель
Сommit
fcb11fac83
3 измененных файлов с 24 добавлено и 14 удалено
  1. 4 2
      src/services/common.ts
  2. 18 11
      src/views/components/Graphics.vue
  3. 2 1
      src/views/components/Header.vue

+ 4 - 2
src/services/common.ts

@@ -488,7 +488,8 @@ export const save = async (
       image:comData.image,
       name:comData.name,
       folder: '',
-      userFlag,
+      // userFlag,
+      template:userFlag===2?true:false,
       case:comData.case
     }
     let ret: any = await addCollection('v.component', body); // 新增
@@ -644,7 +645,8 @@ export const save = async (
     name:data.name,
     folder:data.folder,
     // shared:true,
-    userFlag,
+    // userFlag,
+    template:userFlag===2?true:false,
     case:data.case,
     childIds
   }

+ 18 - 11
src/views/components/Graphics.vue

@@ -557,7 +557,7 @@ const groupChange = async (name: string) => {
       if (activeAssets.value === 'system') {
         if (!caseCaches.length) {
           loading.value = true;
-          caseCaches.push(...(await getCaseProjects('系统方案',1)));
+          caseCaches.push(...(await getCaseProjects('系统方案',true,false)));
           for (const group of cases) {
             group.list = [];
             for (const item of caseCaches) {
@@ -579,7 +579,7 @@ const groupChange = async (name: string) => {
         // userLastName = name;
 
         //用户方案
-        subGroups.value = await getCollectionImageList('方案', 'v',1);
+        subGroups.value = await getCollectionImageList('方案', 'v',false,false);
         moveGroups['方案'] = [];
         subGroups.value.forEach((item)=>{if(item.name!=='默认'){ moveGroups['方案'].push({name:item.name})}});
         groupType.value = 1;
@@ -590,7 +590,7 @@ const groupChange = async (name: string) => {
       if (activeAssets.value === 'system') {
         if (!templateCaches.length) {
           loading.value = true;
-          templateCaches.push(...(await getCaseProjects('系统模板',2)));
+          templateCaches.push(...(await getCaseProjects('系统模板',true,true)));
           for (const group of templates) {
             group.list = [];
             for (const item of templateCaches) {
@@ -610,7 +610,7 @@ const groupChange = async (name: string) => {
         // groupType.value = 1;
         // await getPrivateProjects('le5leV-template');
         // userLastName = name;
-        subGroups.value = await getCollectionImageList('模板', 'v',2);
+        subGroups.value = await getCollectionImageList('模板', 'v',false,true);
         moveGroups['模板'] = [];
         subGroups.value.forEach((item)=>{if(item.name!=='默认'){ moveGroups['模板'].push({name:item.name})}});
         groupType.value = 1;
@@ -664,7 +664,7 @@ const groupChange = async (name: string) => {
       if (activeAssets.value === 'system') {
         if (!componentCaches.length) {
           loading.value = true;
-          componentCaches.push(...(await getCaseProjects('系统组件',1)));
+          componentCaches.push(...(await getCaseProjects('系统组件',true,false)));
           loading.value = false;
           for (const component of componentCaches) {
             if(component.case){
@@ -693,7 +693,8 @@ const groupChange = async (name: string) => {
         subGroups.value = await getCollectionImageList(
           '组件',
           'v.component',
-          1
+          false,
+          false
         );
         groupType.value = 1;
         userLastName = name;
@@ -732,7 +733,7 @@ const groupChange = async (name: string) => {
 };
 // TODO 获取方案文件
 //获取方案文件夹
-const getCollectionImageList = async (name?: string, collection?: string, userFlag?:number) => {
+const getCollectionImageList = async (name?: string, collection?: string, system?:boolean, template?:boolean) => {
   //1. 获取网盘文件夹
   const fullpath = `/大屏/${name}`;
   let ret: { list: any[] } = await axios.post('/api/directory/list', {
@@ -757,7 +758,9 @@ const getCollectionImageList = async (name?: string, collection?: string, userFl
     //   // folder: '',
     //   tags: name !== '组件' ? name : undefined,
     // },
-    userFlag,
+    // userFlag,
+    system,
+    template
     // projection: {
     //   image: 1,
     //   id: 1,
@@ -866,7 +869,7 @@ const getImageList = async () => {
   );
 };
 
-const getCaseProjects = async (name: string,systemFlag = 1, current = 1, pageSize = 1000) => {
+const getCaseProjects = async (name: string, system:boolean, template:boolean, current = 1, pageSize = 1000) => {
   const query: any = { tags: name };
   let collection = name == '系统组件' ? 'v.component' : 'v';
   const ret: any = await axios.post(
@@ -878,7 +881,9 @@ const getCaseProjects = async (name: string,systemFlag = 1, current = 1, pageSiz
       //shared: true,
       // projection: "id,_id,name,image,price,case",
       // sort: { createdAt: 1 },
-      systemFlag
+      // systemFlag
+      system,
+      template
     },
     {
       params: {
@@ -1696,7 +1701,9 @@ const onMenu = async (val: string) => {
         let ret = await updateCollection('v', {
           id,
           folder: val === '默认' ? '' : val,
-          userFlag:activedGroup.value === '方案' ? 2 : 1
+          system:false,
+          template:activedGroup.value === '方案' ? true : false
+          // userFlag:activedGroup.value === '方案' ? 2 : 1
         });
         if (!ret) {
           return;

+ 2 - 1
src/views/components/Header.vue

@@ -926,7 +926,8 @@ const openZip = async (file: File) => {
             image:idata.image||'xxx',
             name:idata.name,
             folder:idata.folder,
-            userFlag:2,
+            // userFlag:2,
+            system:false,
             case:idata.case,
           });
           if(!ret){