Luolei1992 5 роки тому
батько
коміт
8e2d286868
3 змінених файлів з 35 додано та 32 видалено
  1. 27 29
      src/components/Preview.vue
  2. 3 2
      src/components/TabPage.vue
  3. 5 1
      src/store.js

+ 27 - 29
src/components/Preview.vue

@@ -42,16 +42,16 @@
             <span v-for="(item,idx) in others.text" :key="item.text+idx">{{item.text+(idx == others.text.length-1?'。':';')}}</span>
           </p>
         </li>
+        <li v-if="showLis[moduleCP['suplement']]==1">
+          <h4><i></i> 补充内容:</h4>
+          <p>{{addContent.txt}}</p>
+        </li>
         <li v-if="JSON.stringify(diagnose.imgSrc) !='{}'">
           <h4><i></i> 最近一次治疗报告:</h4>
           <div v-for="(value,key) in diagnose.imgSrc" class="imgView">
             <img :src="value" alt="">
           </div>
         </li>
-        <li v-if="showLis[moduleCP['suplement']]==1">
-          <h4><i></i> 补充内容:</h4>
-          <p>{{addContent.txt}}</p>
-        </li>
       </ul>
     </div>
     <div class="foot">
@@ -69,7 +69,7 @@
       :showType="showType"
       @showSubmit="showSubmit"
     ></Submit>
-    <Loading v-if="show"></Loading>
+    <Loading v-if="loadingShow"></Loading>
   </div>
 </template>
 <script>
@@ -78,9 +78,9 @@ import Submit from '../common/Submit';
 import Loading from '../common/Loading';
 import {moduleCP} from '@utils/tools.js'
 export default {
-  props: ['preName','showLis'],
+  props: ['preName','showLis','loadingShow'],
   data() {
-    const { pathInfo, originDatas } = this.$store.state;
+    const { pathInfo, originDatas,loadingShow } = this.$store.state;
     let symptomDate = this.$store.state.symptom;
     let diagnoseDate = this.$store.state.diagnose;
     let othersDate = this.$store.state.others;
@@ -95,7 +95,7 @@ export default {
       submit: false,
       showType: 'fail',
       imgList:[],
-      show:false,//提交等待的动画loading
+      // show:loadingShow,//提交等待的动画loading
       tmpNum:0,
       moduleCP:moduleCP
     }
@@ -113,7 +113,7 @@ export default {
       // let tmpNum = this.tmpNum;
       // var dateBegin = new Date();//获取当前时间
       if (imgList.length > 0) {//有图片先上传图片
-        this.show = true
+        this.$store.commit('handleToggleShow', true);
         for (let i = 0; i < imgList.length; i++) {
           let pageFile = imgList[i].file
           formData.append('upfiles', imgList[i].file);
@@ -128,7 +128,6 @@ export default {
           //       var dateEnd = new Date();//获取当前时间
           //       var dateDiff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数
           //       var dayDiff = dateDiff / 1000;//计算出秒数
-          //       this.show = false
           //       alert('图片上传完成:'+dayDiff+'s')
           //     }
           //   }
@@ -136,7 +135,6 @@ export default {
         }
         // return
         api.uploadImageThums(formData).then((res) => {//获取图片
-          console.log(res.data)
           let result = res.data;
           if (result.code == 0) {//图片提交成功再保存数据
             // this.showType = 'success'
@@ -156,22 +154,17 @@ export default {
                 // var dateEnd = new Date();//获取当前时间
                 // var dateDiff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数
                 // var dayDiff = dateDiff / 1000;//计算出秒数
-                // this.show = false
                 // alert('图片上传完成:'+dayDiff+'s')
             this.saveAllDate()
           } else {//提交失败提示
-            this.show=false
-            this.showType = 'fail'
-            this.submit = true
-            let timer = setTimeout(() => {
-              this.submit = false
-              clearTimeout(timer)
-            }, 2000);
+            this.defaultWaring()
           }
+        }).catch((err)=>{
+          this.defaultWaring()
         })
         return;
       } else {//没有图片直接保存数据
-        this.show = true
+        this.$store.commit('handleToggleShow', true);
         this.saveAllDate()
       }
     },
@@ -233,19 +226,24 @@ export default {
       api.saveInquiry(params).then((res) => {
         console.log(res)
         if (res.data.code == 0) {
-          this.show=false
+          this.$store.commit('handleToggleShow', false);
           this.showType = 'success'
           this.submit = true
         } else {
-          this.show=false
-          this.showType = 'fail'
-          this.submit = true
-          let timer = setTimeout(() => {
-            this.submit = false
-            clearTimeout(timer)
-          }, 2000);
+          this.defaultWaring()
         }
-      })
+      }).catch((err)=>{
+          this.defaultWaring()
+        })
+    },
+    defaultWaring(){
+      this.$store.commit('handleToggleShow', false);
+      this.showType = 'fail'
+      this.submit = true
+      let timer = setTimeout(() => {
+        this.submit = false
+        clearTimeout(timer)
+      }, 2000);
     }
   },
   components: {

+ 3 - 2
src/components/TabPage.vue

@@ -51,8 +51,9 @@
           @back="beBack"
         />
       </template>
-      <Preview v-show="!moduleShow" 
+      <Preview v-if="!moduleShow" 
         :preName="getPreviewName()"
+        :loadingShow="this.$store.state.loadingShow"
         :showLis="type"
         @back="beBack" 
       />
@@ -91,7 +92,7 @@ export default {
         '52':false
       },
       number:0,
-      moduleCP:moduleCP
+      moduleCP:moduleCP,
     }
   },
   created() {

+ 5 - 1
src/store.js

@@ -31,7 +31,8 @@ const store = new Vuex.Store({
     addContent:{
       origin:[],
       txt:'',
-    }
+    },
+    loadingShow:false
   },
   mutations:{
     initAllData(state){
@@ -363,6 +364,9 @@ const store = new Vuex.Store({
       }
       
     },
+    handleToggleShow(state,flg){
+      state.loadingShow = flg
+    }
   }
 })