Browse Source

业务空间台账-其他分区中的实例查看空间详情时,无数据

shaun-sheep 5 years ago
parent
commit
05f1004ac0

+ 1 - 0
src/utils/scan/tools.js

@@ -554,6 +554,7 @@ tools.setDataForKey = function (data, key, value) {
   }
 }
 tools.flattenKeys = function (obj) {
+  if(obj == undefined) return
   let res = {}
 
   function isObject(val) {

+ 3 - 3
src/views/ledger/facility/details/index.vue

@@ -164,9 +164,9 @@
           list: []
         },
         instance: {},//实例信息处理
-        isShowImage: true,
-        isShowVideo: true,
-        isShowFile: true,
+        isShowImage: false,
+        isShowVideo: false,
+        isShowFile: false,
       }
     },
     methods: {

+ 19 - 19
src/views/ledger/spacelist/spaceDetail/index.vue

@@ -42,9 +42,9 @@
                 <exhibitionMaintain :exhibitionMaintain="exhibitionMaintain"/>
               </div>
               <div class="content-media">
-                <exhibitionImage :exhibitionImage="exhibitionImage" v-show="isShowImage"/>
-                <exhibitionVideo :exhibitionVideo="exhibitionVideo" v-show="isShowVideo"/>
-                <exhibitionFile :exhibitionFile="exhibitionFile" v-show="isShowFile"/>
+                <exhibitionImage :exhibitionImage="exhibitionImage" v-if="isShowImage"/>
+                <exhibitionVideo :exhibitionVideo="exhibitionVideo" v-if="isShowVideo"/>
+                <exhibitionFile :exhibitionFile="exhibitionFile" v-if="isShowFile"/>
               </div>
             </div>
           </div>
@@ -140,9 +140,9 @@
           title: '视频',
           list: {}
         },
-        isShowImage: true,
-        isShowVideo: true,
-        isShowFile: true,
+        isShowImage: false,
+        isShowVideo: false,
+        isShowFile: false,
       }
   },
   computed: {
@@ -210,8 +210,8 @@
       Promise.all([promise1, promise2]).then(values => {
         this.pointData = values[0].Content;
         this.exampleData = values[1].Content[0];
+        let obj = values[1].Content[0] ? this.deepCopy(values[1].Content[0]) :values[1].Content[0];
 
-        let obj = this.deepCopy(values[1].Content[0]);
         obj = tools.flattenKeys(obj);
         this.instance = obj;
         this.handleRadios(this.currentRadio)
@@ -262,7 +262,7 @@
       let isList = this.pointData
       let isArr = []
       isList.map(j => {
-        if (this.instance.hasOwnProperty(j.Path)) {
+        if (this.instance &&this.instance.hasOwnProperty(j.Path)) {
           j.value = this.instance[j.Path]
           return j
         }
@@ -276,7 +276,7 @@
       //关键信息点
       this.exhibitionCrux.cruxArray = this.pointData.filter(i => i.KeyWord)
       this.exhibitionCrux.cruxArray.map(i => {
-        if (this.instance.hasOwnProperty(i.Path)) {
+        if (this.instance &&this.instance.hasOwnProperty(i.Path)) {
           return {
             ...i,
             value: this.instance[i.Path]
@@ -293,7 +293,7 @@
       } else if (val == 2) { //有值信息点
         let list = this.pointData
         list.map(j => {
-          if (this.instance.hasOwnProperty(j.Path)) {
+          if (this.instance && this.instance.hasOwnProperty(j.Path)) {
             return {
               ...j,
               value: this.instance[j.Path]
@@ -323,7 +323,7 @@
             case 'LedgerParam.PhotoDoc.Nameplate':
             case 'Pic' :
 
-              if (this.instance.hasOwnProperty(i.Path)) {
+              if (this.instance &&this.instance.hasOwnProperty(i.Path)) {
                 i.PicList = this.instance[i.Path]
 
               }
@@ -343,7 +343,6 @@
       })
       //展示图片
       this.exhibitionImage.list = picObject
-
       let isArray = [] //获取图片数组
       for (let i in picObject) {
         if (Array.isArray(picObject[i])) {
@@ -358,8 +357,10 @@
       this.exhibitionImage.arr = isArray
       let video = isArray.filter(i => i.Type != 'image' &&i.type != 'image' )
       this.exhibitionVideo.list = video
+
       //判断是否显示图片组件
-      this.isShowImage = isArray.length ? true : false
+      this.isShowImage = isArray.length  ? true : false
+
       //判断是否显示video组件
       this.isShowVideo = video.length ? true : false
     },
@@ -372,7 +373,7 @@
             case 'LedgerParam.InsuranceDoc.InsuranceFile':
             case 'LedgerParam.PhotoDoc.Archive':
             case 'LedgerParam.Siteinstall.CheckReport':
-              if (this.instance.hasOwnProperty(i.Path)) {
+              if (this.instance &&this.instance.hasOwnProperty(i.Path)) {
                 i.fileList = this.instance[i.Path]
               }
               if (picObject[i.InfoPointName]) {
@@ -423,11 +424,11 @@
     displayData(arr) {//对数据进行处理传给组件展示
       const result = {}
       arr.forEach(i => {
-        if (this.instance.hasOwnProperty(i.Path) && this.currentRadio != 2) {
+        if (this.instance && this.instance.hasOwnProperty(i.Path) && this.currentRadio != 2) {
           i.value = this.instance[i.Path]
         }
         if (i.InputMode == 'C5') {
-          if (this.instance.hasOwnProperty(i.Path)) {
+          if (this.instance && this.instance.hasOwnProperty(i.Path)) {
             let time = this.instance[i.Path]
             i.value = this.formatDate(time)
           }
@@ -443,7 +444,7 @@
               }
             })
           } else if (i.InputMode == 'D2' || i.InputMode == 'C6') {
-            if (this.instance.hasOwnProperty(i.Path)) {
+            if (this.instance &&this.instance.hasOwnProperty(i.Path)) {
               if (!Array.isArray(this.instance[i.Path])) {
                 let transArray = this.instance[i.Path].split(',')
                 i.value = source.filter(item => transArray.includes(item.Code)).map(item => item.Name).join(',')
@@ -451,8 +452,7 @@
             }
           }
           source.forEach(j => {
-            if (j.Code == this.instance[i.Path]) {
-              console.log(j.Name, '===name===')
+            if (this.instance && j.Code == this.instance[i.Path]) {
               i.value = j.Name
             }
           })