Browse Source

fix: 1. 修复时间相差12小时 2.修复系统原理图切换tab之后,图不变的问题

yunxing 4 years ago
parent
commit
2b6e7dabba
2 changed files with 22 additions and 11 deletions
  1. 1 1
      src/utils/format.js
  2. 21 10
      src/views/equipment/eqDialog.vue

+ 1 - 1
src/utils/format.js

@@ -6,7 +6,7 @@ const formatter = (date) => {
     return moment.unix(date / 1000).format("YYYY.MM.DD")
 }
 const formatterTime = (date) => {
-    return moment.unix(date / 1000).format("YYYY.MM.DD hh:mm")
+    return moment.unix(date / 1000).format("YYYY.MM.DD HH:mm")
 }
 const number_format = (number, decimals, dec_point, thousands_sep) => {
     /*

+ 21 - 10
src/views/equipment/eqDialog.vue

@@ -14,7 +14,7 @@
             <div v-if='Object.keys(dialogInfo).length>0 && dialogInfo.children.length==0' style='padding-top:16px;height:100%'>
                 <!-- 原理图 -->
                 <div v-if='dialogInfo.id.slice(2,4)=="YL"' style='width:100%;overflow:auto;height:100%;margin:0 auto'>
-                    <rotation type='3' v-if='rotationImg.length>0' :size='sizePic' :rotationImg='rotationImg'></rotation>
+                    <rotation :key='`rotaion_${rotationKey}`' type='3' v-if='rotationImg.length>0' :size='sizePic' :rotationImg='rotationImg'></rotation>
                 </div>
                 <!-- 土建装饰主要材料清单 -->
                 <!-- <tj-table v-else-if='dialogInfo.id.slice(0,4)=="TJQD"' :param='param'></tj-table> -->
@@ -133,7 +133,13 @@
                                 >
                                     <!-- 有tab的原理图 -->
                                     <div style='width:100%;height:600px;'>
-                                        <rotation :size='sizePic' v-if='rotationImg.length>0' type='3' :rotationImg='rotationImg'></rotation>
+                                        <rotation
+                                            :key='`tab_rotaion_${rotationKey}`'
+                                            :size='sizePic'
+                                            v-if='rotationImg.length>0'
+                                            type='3'
+                                            :rotationImg='rotationImg'
+                                        ></rotation>
                                     </div>
                                 </el-tab-pane>
                                 <!-- 发布之后的编辑器的分支图 -->
@@ -183,6 +189,7 @@ export default {
             diff: '',
             difference: '', //区分给水排水
             rotationImg: [],
+            rotationKey: 1,
             tabLabel: '',
             tabCount: [],
             sizePic: '',
@@ -332,7 +339,7 @@ export default {
                 plazaId: this.$store.state.plazaId,
                 module: '1002',
                 neTypename: '位置布置图',
-                typecode: typecode,
+                typecode,
             }
             switch (this.systemName) {
                 case '暖通系统':
@@ -364,15 +371,19 @@ export default {
                 this.rotationImg = res.data || []
                 let img = new Image()
                 img.src = this.rotationImg && this.rotationImg[0] ? this.rotationImg[0].url : ''
-                const vm = this
-                img.onload = function () {
-                    vm.$set(vm.imgInfo, 'width', img.width)
-                    vm.$set(vm.imgInfo, 'height', img.height)
-                    if (vm.imgInfo.width > vm.imgInfo.height) {
-                        vm.sizePic = 'width'
+                if (!img.src) {
+                    this.rotationKey++
+                    return true
+                }
+                img.onload = () => {
+                    this.$set(this.imgInfo, 'width', img.width)
+                    this.$set(this.imgInfo, 'height', img.height)
+                    if (this.imgInfo.width > this.imgInfo.height) {
+                        this.sizePic = 'width'
                     } else {
-                        vm.sizePic = 'height'
+                        this.sizePic = 'height'
                     }
+                    this.rotationKey++
                 }
             })
         },