ソースを参照

解决检验出错时导出报错

zhangxc 5 年 前
コミット
374e885925
1 ファイル変更94 行追加76 行削除
  1. 94 76
      src/components/diagBase/AddDiagBase.vue

+ 94 - 76
src/components/diagBase/AddDiagBase.vue

@@ -549,44 +549,55 @@
         //     inp.value = "";   
         // },
         updateNeo() {
-            this.submitForm('updateNeo').then(() => {
-                if(this.hasQuestion == 0) {
-                    const param = {
-                        id: this.id,
-                        modifier: this.modifier
-                    }
-                    api.diagBaseUpdateNeo(param).then((res) => {
-                        if(res.data.code == 0) {
-                            this.warning('更新成功', 'success');
-                        } else {
-                            this.warning(res.data.msg)
+            const submitFormResult = this.submitForm('updateNeo')
+            if(!submitFormResult) {
+                return
+            } else {
+                submitFormResult.then(() => {
+                    if(this.hasQuestion == 0) {
+                        const param = {
+                            id: this.id,
+                            modifier: this.modifier
                         }
-                    })
-                } else {
-                    this.warning('更新失败');
-                }
-                
-            })
-            // api.diagBaseUpdateNeo(param).then((res) =>{
-
-            // })
+                        api.diagBaseUpdateNeo(param).then((res) => {
+                            if(res.data.code == 0) {
+                                this.warning('更新成功', 'success');
+                            } else {
+                                this.warning(res.data.msg)
+                            }
+                        })
+                    } else {
+                        this.warning('更新失败');
+                    }
+                    
+                })
+            
+            }
         },
         exportDiagnosticAll(){
-            this.submitForm('export').then(() => {
-                if(this.hasQuestion == 0) {
-                    const param = {
-                        diagnoseId: this.id
-                    }
-                    api.exportDiagnosticAll(param).then((res) => {
-                        utils.downloadExportedData(res.data,'诊断依据.xls');
-                    })
-                }else {
-                    if(!this.hasNoUniqueName) {
-                        this.warning('导出失败');
+            const submitFormResult = this.submitForm('export')
+            if(!submitFormResult) {
+                return
+            } else {
+                submitFormResult.then(() => {
+                    if(this.hasQuestion == 0) {
+                        const param = {
+                            diagnoseId: this.id
+                        }
+                        api.exportDiagnosticAll(param).then((res) => {
+                            utils.downloadExportedData(res.data,'诊断依据.xls');
+                        })
+                    }else {
+                        if(!this.hasNoUniqueName) {
+                            this.warning('导出失败');
+                        }
                     }
-                }
-                
-            })
+                    
+                }).catch((e)=>{
+                })
+
+            }
+            
            
         },
         saveTemp(){
@@ -652,6 +663,7 @@
            
         },
         diagBaseVerifyData(type) {
+           
             //判断诊断依据先判断化验有没有公表项
              const labArr= []
             for (let i = 0; i < this.disFeatureList.length; i++) {
@@ -672,10 +684,10 @@
                 this.isReady = true
             }
             if(labArr.length > 0) {
+                
                 return this.labVerifyData(labArr, loading,type).then(() =>{
                     if(this.hasNoUniqueName) {
                         loading.close()
-                        return  
                     }else {
                          return this.verifyDiagBase(loading,type)
                     }
@@ -848,7 +860,7 @@
                 this.isReady=false
                 return  false
             }
-            return true
+             return true
         },
         labVerifyData(labArr, loading,type) {
             const labArrParam = {
@@ -899,7 +911,6 @@
             }).catch(()=>{ this.isReady=false;loading.close()})
         },
         verifyDiagBase(loading,type) {
-            
             const param = {
                 disFeature: this.disFeatureListResult,
                 disName: this.disName,
@@ -907,50 +918,57 @@
                 id: this.id,
                 modifier: this.modifier
             }
+            
+            const diagBaseVerifyDataResult =  api.diagBaseVerifyData(param)
             const hasErrorData =  this.errorDataVerify(loading)
             if(!hasErrorData) {
-                return
-            }
-            return api.diagBaseVerifyData(param).then((res) => {
-                if(+res.data.code === 0) {
-                    const data = res.data.data
-                    this.isReady=false
-                    if(type =='save') {
-                        if(data.hasQuestion) {
-                            this.warning('校验完成请先调整错误数据,该数据已保存')
-                        } else {
-                            this.warning('校验成功', 'success')
+                return false
+            } else {
+                return diagBaseVerifyDataResult.then((res) => {
+                    if(+res.data.code === 0) {
+                        const data = res.data.data
+                        this.isReady=false
+                        if(type =='save') {
+                            if(data.hasQuestion) {
+                                this.warning('校验完成请先调整错误数据,该数据已保存')
+                            } else {
+                                this.warning('校验成功', 'success')
+                            }
                         }
+                        
+                        this.id = data.id
+                        this.disNameExist = data.disNameExist
+                        this.disFeatureList = data.disFeature                                                                           
+                        if(data.disformula.length) {
+                            this.disFormulaList = data.disformula
+                        }else {
+                            this.disFormulaList = [
+                                {
+                                    type:92,
+                                    code:'',
+                                    standard:'',
+                                    relation:'',
+                                    result:'',
+                                    midResult:'',
+                                    formula:'',
+                                    uniqueName:''
+                                }
+                            ]
+                        }  
+                        this.hasQuestion = data.hasQuestion
+                    } else {
+                        this.hasQuestion = 1
+                        this.warning(res.msg)
                     }
                     
-                    this.id = data.id
-                    this.disNameExist = data.disNameExist
-                    this.disFeatureList = data.disFeature
-                    if(data.disformula.length) {
-                        this.disFormulaList = data.disformula
-                    }else {
-                        this.disFormulaList = [
-                            {
-                                type:92,
-                                code:'',
-                                standard:'',
-                                relation:'',
-                                result:'',
-                                midResult:'',
-                                formula:'',
-                                uniqueName:''
-                            }
-                        ]
-                    }  
-                    this.hasQuestion = data.hasQuestion
-                } else {
-                    this.hasQuestion = 1
-                    this.warning(res.msg)
-                }
-                
-                loading.close()
-                
-            }).catch(()=>{ this.hasQuestion = false; this.isReady=false; loading.close()})
+                    loading.close()
+                    
+                    }).catch(()=>{ this.hasQuestion = false; this.isReady=false; loading.close()})
+
+
+            }
+            
+            
         },
         showConfirmDialog(msg, resolve) {
             this.$alert(msg, '提示', {