Bläddra i källkod

重新修改抓取模块信息获取

lrf402788946 5 år sedan
förälder
incheckning
6620ee3143
1 ändrade filer med 31 tillägg och 28 borttagningar
  1. 31 28
      src/views/index/index.vue

+ 31 - 28
src/views/index/index.vue

@@ -62,8 +62,8 @@ export default {
     coopList: [],
     linkList: [],
   }),
-  created() {
-    this.getSite();
+  async created() {
+    await this.getSite();
     this.search();
     this.getModule();
     this.getLink();
@@ -124,47 +124,48 @@ export default {
       } else {
         this.$message.error(result.errmsg ? result.errmsg : 'error');
       }
-      // result = await this.newsOperation({ type: 'list', data: { site: this.$site, limit: 4, skip: 0 } });
-      // if (`${result.errcode}` === '0') {
-      //   //给this=>vue的实例下在中的list属性,赋予result。data的值
-      //   this.$set(this, 'newList', result.data);
-      // } else {
-      //   this.$message.error(result.errmsg ? result.errmsg : 'error');
-      // }
-
-      // result = await this.getBugInfo({ data: { skip: 0, limit: this.$limit } });
-      // if (`${result.errcode}` === '0') {
-      //   //给this=>vue的实例下在中的list属性,赋予result。data的值
-      //   this.$set(this, 'cause', result.data);
-      // } else {
-      //   this.$message.error(result.errmsg ? result.errmsg : 'error');
-      // }
     },
     async getModule() {
-      //获取分站所有模块
+      //获取分站所有模块 TODO:site=>_tenant
       let result = await this.moduleOperation({ type: 'list', data: { site: this.$site } });
       if (`${result.errcode}` === '0') {
         let moduleList = result.data;
         for (let item of moduleList) {
           //item为模块信息,拿着模块信息去查该模块下有什么栏目
-          item = await this.getColumn(item);
-          this.makeList(item);
-          // console.log(item);
+          if (`${item.is_use}` === '0') {
+            item = await this.getColumn(item);
+            this.makeList(item);
+          } // console.log(item);
         }
       }
     },
     async getColumn(item) {
-      let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
-      if (`${res.errcode}` === '0') {
-        //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
-        for (const col of res.data) {
+      // console.log(item);
+      // console.log(this.site);
+      if (!item.category.includes('self')) {
+        let res = await this.columnOperation({ type: 'list', data: { parent_id: item.id, site: item.site } });
+        if (`${res.errcode}` === '0') {
+          //组合path:res.data内容都为栏目.所以,点击这些栏目显示的列表应该是信息列表,需要用栏目的id作为查询信息的parten_id查出不同栏目的信息
+          for (const col of res.data) {
+            col.path = `/info/list/${col.id}`;
+            //再将栏目下的前几条数据查出来(暂定limit=6)
+            col.children = await this.getNews(col);
+          }
+          item.children = res.data;
+        }
+      } else {
+        let selfUseList = JSON.parse(this.site.bug_column);
+        let res = selfUseList.filter(fil => {
+          if (fil) return fil.parent_id === item.id;
+        });
+        for (const col of res) {
+          col.id = col.column;
           col.path = `/info/list/${col.id}`;
-          //再将栏目下的前几条数据查出来(暂定limit=6)
           col.children = await this.getNews(col);
         }
-        item.children = res.data;
-        return item;
+        item.children = res;
       }
+      return item;
     },
     async getNews(item) {
       //这个item是栏目列表,循环查每个栏目6条信息
@@ -174,6 +175,7 @@ export default {
       }
     },
     makeList(item) {
+      if (!item) return;
       if (item.category === 'news') {
         let arr = [];
         let colObject = {};
@@ -199,6 +201,7 @@ export default {
       } else if (item.category === 'self1') {
         this.$set(this, `self1List`, item.children);
       } else if (item.category === 'self2') {
+        console.log(item);
         this.$set(this, `self2List`, item.children);
       }
     },