Parcourir la source

模板列表获取容错

zhouna il y a 6 ans
Parent
commit
f9b01751f6
1 fichiers modifiés avec 20 ajouts et 12 suppressions
  1. 20 12
      src/components/preTreat/QuestionModules.vue

+ 20 - 12
src/components/preTreat/QuestionModules.vue

@@ -151,22 +151,30 @@
       getDataList() {
         const param = this.getFilterItems();
         api.getModuleList(param).then((res) => {
-          const list = [...res.data.data.records];
-          for (var i = 0; i < list.length; i++) {
-            for (var j =  0; j < this.tagTypes.length; j++) {
-              if(list[i].moduleType == this.tagTypes[j].val) {
-                list[i].tagTypeCn = this.tagTypes[j].name;
+          if (res.data.code === '0') {
+            const list = res.data.data&&res.data.data.records?[...res.data.data.records]:[];
+            for (var i = 0; i < list.length; i++) {
+              for (var j =  0; j < this.tagTypes.length; j++) {
+                if(list[i].moduleType == this.tagTypes[j].val) {
+                  list[i].tagTypeCn = this.tagTypes[j].name;
+                }
               }
-            }
-            //后台数据typeCn转换为筛选中对应的字段名称
-            for (var z =  0; z < this.Adscriptions.length; z++) {
-              if(list[i].type == this.Adscriptions[z].val) {
-                list[i].typeCn = this.Adscriptions[z].name;
+              //后台数据typeCn转换为筛选中对应的字段名称
+              for (var z =  0; z < this.Adscriptions.length; z++) {
+                if(list[i].type == this.Adscriptions[z].val) {
+                  list[i].typeCn = this.Adscriptions[z].name;
+                }
               }
             }
+            this.list = list;
+            this.total = res.data.data.total;
+          }else{
+            this.$message({
+              message: res.data.msg,
+              type: 'warning'
+            });
           }
-          this.list = list;
-          this.total = res.data.data.total;
+
         })
       },
       filterDatas() {