瀏覽代碼

报告管理新增页面-附件上传bug

lizhenhao 2 年之前
父節點
當前提交
c327317378

+ 93 - 88
src/views/modules/cw/reportManagement/ReportManagementAddForm.vue

@@ -842,36 +842,105 @@
         })
       }, */
       // 表单提交
-      doSubmit (status, callback) {
-        if (status === 'save') {
-          console.log('save111111')
-          // 暂存
-          this.inputForm.status = '5'
-          this.loading = true
+      async doSubmit (status, callback) {
+        if (this.$refs.enclosure.checkProgress()) {
+          this.loading = false
+          throw new Error()
+        } else {
+          if (status === 'save') {
+            console.log('save111111')
+            // 暂存
+            this.inputForm.status = '5'
+            this.loading = true
+            this.$refs['inputForm'].validate((valid) => {
+              if (valid) {
+                this.loading = true
+                let _this = this
+                let _num = 0
+                const wait = function () {
+                  return new Promise((resolve, reject) => {
+                    if (_this.commonJS.isNotEmpty(_this.inputForm.signatureAnnotator1) &&
+                      _this.commonJS.isEmpty(_this.inputForm.signatureAnnotator2) &&
+                      _this.inputForm.signatureAnnotator1 !== _this.inputForm.projectMasterId1 &&
+                      _this.inputForm.signatureAnnotator1 !== _this.inputForm.projectMasterId2) {
+                      _this.$message.error('签字注师1和签字注师2至少有一个与项目经理相同')
+                      _num = 1
+                      _this.loading = false
+                    }
+                    if (_this.commonJS.isNotEmpty(_this.inputForm.signatureAnnotator2) &&
+                      _this.commonJS.isEmpty(_this.inputForm.signatureAnnotator1) &&
+                      _this.inputForm.signatureAnnotator2 !== _this.inputForm.projectMasterId1 &&
+                      _this.inputForm.signatureAnnotator2 !== _this.inputForm.projectMasterId2) {
+                      _this.$message.error('签字注师1和签字注师2至少有一个与项目经理相同')
+                      _num = 1
+                      _this.loading = false
+                    }
+                    _this.inputForm.cwFileInfoList2 = _this.$refs.enclosure.getDataList()
+                    // _this.$refs.archiveFile.getDataList().then((data) => {
+                    //   _this.inputForm.cwFileInfoList = data
+                    //   if (_this.commonJS.isNotEmpty(_this.inputForm.cwFileInfoList)) {
+                    //     _this.inputForm.cwFileInfoList.forEach((item, index) => {
+                    //       if (_this.commonJS.isEmpty(item.fileType)) {
+                    //         _this.$message.error('签章文件中,第' + (index + 1) + '条数据的“文件类型”未填写')
+                    //         _num = 1
+                    //         _this.loading = false
+                    //         throw new Error('签章文件中,第' + (index + 1) + '条数据的“文件类型”未填写')
+                    //       } else if (_this.commonJS.isEmpty(item.sealType)) {
+                    //         _this.$message.error('签章文件中,第' + (index + 1) + '条数据的“盖章类型”未填写')
+                    //         _num = 1
+                    //         _this.loading = false
+                    //         throw new Error('签章文件中,第' + (index + 1) + '条数据的“盖章类型”未填写')
+                    //       }
+                    //     })
+                    //   } else {
+                    //     _this.$message.error('最少有一条签章文件数据!')
+                    //     _num = 1
+                    //     _this.loading = false
+                    //   }
+                    // })
+                    resolve()
+                  })
+                }
+                wait().then(() => {
+                  if (_num !== 1) {
+                    if (this.commonJS.isEmpty(this.inputForm.createDate)) {
+                      this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
+                    }
+                    this.projectReportService.saveForm(this.inputForm).then(({data}) => {
+                      this.$emit('refreshList')
+                      callback(data.businessTable, data.businessId, this.inputForm)
+                      this.close()
+                      this.loading = false
+                    }).catch(() => {
+                      this.close()
+                      this.loading = false
+                    })
+                  }
+                })
+              } else {
+                this.loading = false
+              }
+            })
+            return
+          } else if (status === 'start') {
+            // 送审  待审核
+            this.inputForm.status = '2'
+          } else if (status === 'agree') {
+            // 审核同意
+            this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
+            this.inputForm.agreeUserId = this.$store.state.user.id
+            this.inputForm.status = '5'
+          } else if (status === 'reapply') {
+            this.inputForm.status = '2'
+          }
           this.$refs['inputForm'].validate((valid) => {
             if (valid) {
               this.loading = true
+              // eslint-disable-next-line no-unused-vars
               let _this = this
               let _num = 0
               const wait = function () {
                 return new Promise((resolve, reject) => {
-                  if (_this.commonJS.isNotEmpty(_this.inputForm.signatureAnnotator1) &&
-                    _this.commonJS.isEmpty(_this.inputForm.signatureAnnotator2) &&
-                    _this.inputForm.signatureAnnotator1 !== _this.inputForm.projectMasterId1 &&
-                    _this.inputForm.signatureAnnotator1 !== _this.inputForm.projectMasterId2) {
-                    _this.$message.error('签字注师1和签字注师2至少有一个与项目经理相同')
-                    _num = 1
-                    _this.loading = false
-                  }
-                  if (_this.commonJS.isNotEmpty(_this.inputForm.signatureAnnotator2) &&
-                    _this.commonJS.isEmpty(_this.inputForm.signatureAnnotator1) &&
-                    _this.inputForm.signatureAnnotator2 !== _this.inputForm.projectMasterId1 &&
-                    _this.inputForm.signatureAnnotator2 !== _this.inputForm.projectMasterId2) {
-                    _this.$message.error('签字注师1和签字注师2至少有一个与项目经理相同')
-                    _num = 1
-                    _this.loading = false
-                  }
-                  _this.inputForm.cwFileInfoList2 = _this.$refs.enclosure.getDataList()
                   // _this.$refs.archiveFile.getDataList().then((data) => {
                   //   _this.inputForm.cwFileInfoList = data
                   //   if (_this.commonJS.isNotEmpty(_this.inputForm.cwFileInfoList)) {
@@ -903,81 +972,17 @@
                     this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
                   }
                   this.projectReportService.saveForm(this.inputForm).then(({data}) => {
-                    this.$emit('refreshList')
                     callback(data.businessTable, data.businessId, this.inputForm)
-                    this.close()
+                    this.$emit('refreshList')
                     this.loading = false
                   }).catch(() => {
-                    this.close()
                     this.loading = false
                   })
                 }
               })
-            } else {
-              this.loading = false
             }
           })
-          return
-        } else if (status === 'start') {
-          // 送审  待审核
-          this.inputForm.status = '2'
-        } else if (status === 'agree') {
-          // 审核同意
-          this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
-          this.inputForm.agreeUserId = this.$store.state.user.id
-          this.inputForm.status = '5'
-        } else if (status === 'reapply') {
-          this.inputForm.status = '2'
         }
-        this.$refs['inputForm'].validate((valid) => {
-          if (valid) {
-            this.loading = true
-            // eslint-disable-next-line no-unused-vars
-            let _this = this
-            let _num = 0
-            const wait = function () {
-              return new Promise((resolve, reject) => {
-                // _this.$refs.archiveFile.getDataList().then((data) => {
-                //   _this.inputForm.cwFileInfoList = data
-                //   if (_this.commonJS.isNotEmpty(_this.inputForm.cwFileInfoList)) {
-                //     _this.inputForm.cwFileInfoList.forEach((item, index) => {
-                //       if (_this.commonJS.isEmpty(item.fileType)) {
-                //         _this.$message.error('签章文件中,第' + (index + 1) + '条数据的“文件类型”未填写')
-                //         _num = 1
-                //         _this.loading = false
-                //         throw new Error('签章文件中,第' + (index + 1) + '条数据的“文件类型”未填写')
-                //       } else if (_this.commonJS.isEmpty(item.sealType)) {
-                //         _this.$message.error('签章文件中,第' + (index + 1) + '条数据的“盖章类型”未填写')
-                //         _num = 1
-                //         _this.loading = false
-                //         throw new Error('签章文件中,第' + (index + 1) + '条数据的“盖章类型”未填写')
-                //       }
-                //     })
-                //   } else {
-                //     _this.$message.error('最少有一条签章文件数据!')
-                //     _num = 1
-                //     _this.loading = false
-                //   }
-                // })
-                resolve()
-              })
-            }
-            wait().then(() => {
-              if (_num !== 1) {
-                if (this.commonJS.isEmpty(this.inputForm.createDate)) {
-                  this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
-                }
-                this.projectReportService.saveForm(this.inputForm).then(({data}) => {
-                  callback(data.businessTable, data.businessId, this.inputForm)
-                  this.$emit('refreshList')
-                  this.loading = false
-                }).catch(() => {
-                  this.loading = false
-                })
-              }
-            })
-          }
-        })
       },
       /* async updateStatusById (type, callback) {
         if (await this.$refs.archiveFile.checkProgress()) {

+ 71 - 63
src/views/modules/cw/reportManagement/ReportManagementForm.vue

@@ -1225,84 +1225,92 @@
       },
       // 表单提交
       doSubmit (status, callback) {
-        if (status === 'save') {
+        if (this.$refs.enclosure.checkProgress()) {
+          this.loading = false
+          throw new Error()
+        } else if (this.$refs.signatureFile.checkProgress()) {
+          this.loading = false
+          throw new Error()
+        } else {
+          if (status === 'save') {
+            this.$refs['inputForm'].validate((valid) => {
+              if (valid) {
+                // 暂存
+                // this.inputForm.status = '1'
+                this.loading = true
+                this.inputForm.cwFileInfoList2 = this.$refs.enclosure.getDataList()
+                // this.$refs.archiveFile.getDataList().then((data) => {
+                //   this.inputForm.cwFileInfoList = data
+                // })
+                // if (this.commonJS.isNotEmpty(this.$refs.signatureFile.getDataList())) {
+                // this.$refs.signatureFile.getDataList().then((data) => {
+                //   this.inputForm.signatureFileList = data
+                // })
+                // }
+                this.inputForm.signatureFileList = this.$refs.signatureFile.getDataList()
+                // 列表处理
+                this.inputForm.details = []
+                this.inputForm.detailFor1010.forEach(item => { this.inputForm.details.push(item) })
+                this.inputForm.detailFor1020.forEach(item => { this.inputForm.details.push(item) })
+                this.inputForm.detailFor1030.forEach(item => { this.inputForm.details.push(item) })
+                this.reportReviewService.save(this.inputForm).then(() => {
+                  this.projectReportService.saveForm(this.inputForm).then(() => {
+                    this.close()
+                    this.loading = false
+                  }).catch(() => {
+                    this.loading = false
+                  })
+                })
+              }
+            })
+            return
+          } else if (status === 'start') {
+            // 送审  待审核
+            this.inputForm.status = '2'
+          } else if (status === 'agree') {
+            // 审核同意
+            this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
+            this.inputForm.agreeUserId = this.$store.state.user.id
+            this.inputForm.status = '5'
+          }
           this.$refs['inputForm'].validate((valid) => {
             if (valid) {
-              // 暂存
-              // this.inputForm.status = '1'
               this.loading = true
+              // if (this.$refs.uploadComponent.checkProgress()) {
+              //   this.loading = false
+              //   return
+              // }
+              // this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
+              if (this.commonJS.isEmpty(this.inputForm.createDate)) {
+                this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
+              }
+              if (this.commonJS.isEmpty(this.inputForm.reportDate)) {
+                this.$message.error('报告日期不能为空')
+                this.loading = false
+                throw new Error('报告日期不能为空')
+              }
+              if (this.commonJS.isEmpty(this.inputForm.reportType)) {
+                this.$message.error('报告类型不能为空')
+                this.loading = false
+                throw new Error('报告类型不能为空')
+              }
               this.inputForm.cwFileInfoList2 = this.$refs.enclosure.getDataList()
               // this.$refs.archiveFile.getDataList().then((data) => {
               //   this.inputForm.cwFileInfoList = data
               // })
-              // if (this.commonJS.isNotEmpty(this.$refs.signatureFile.getDataList())) {
               // this.$refs.signatureFile.getDataList().then((data) => {
               //   this.inputForm.signatureFileList = data
               // })
-              // }
               this.inputForm.signatureFileList = this.$refs.signatureFile.getDataList()
-              // 列表处理
-              this.inputForm.details = []
-              this.inputForm.detailFor1010.forEach(item => { this.inputForm.details.push(item) })
-              this.inputForm.detailFor1020.forEach(item => { this.inputForm.details.push(item) })
-              this.inputForm.detailFor1030.forEach(item => { this.inputForm.details.push(item) })
-              this.reportReviewService.save(this.inputForm).then(() => {
-                this.projectReportService.saveForm(this.inputForm).then(() => {
-                  this.close()
-                  this.loading = false
-                }).catch(() => {
-                  this.loading = false
-                })
+              this.projectReportService.saveForm(this.inputForm).then(({data}) => {
+                callback(data.businessTable, data.businessId, this.inputForm)
+                this.loading = false
+              }).catch(() => {
+                this.loading = false
               })
             }
           })
-          return
-        } else if (status === 'start') {
-          // 送审  待审核
-          this.inputForm.status = '2'
-        } else if (status === 'agree') {
-          // 审核同意
-          this.inputForm.agreeDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
-          this.inputForm.agreeUserId = this.$store.state.user.id
-          this.inputForm.status = '5'
         }
-        this.$refs['inputForm'].validate((valid) => {
-          if (valid) {
-            this.loading = true
-            // if (this.$refs.uploadComponent.checkProgress()) {
-            //   this.loading = false
-            //   return
-            // }
-            // this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
-            if (this.commonJS.isEmpty(this.inputForm.createDate)) {
-              this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
-            }
-            if (this.commonJS.isEmpty(this.inputForm.reportDate)) {
-              this.$message.error('报告日期不能为空')
-              this.loading = false
-              throw new Error('报告日期不能为空')
-            }
-            if (this.commonJS.isEmpty(this.inputForm.reportType)) {
-              this.$message.error('报告类型不能为空')
-              this.loading = false
-              throw new Error('报告类型不能为空')
-            }
-            this.inputForm.cwFileInfoList2 = this.$refs.enclosure.getDataList()
-            // this.$refs.archiveFile.getDataList().then((data) => {
-            //   this.inputForm.cwFileInfoList = data
-            // })
-            // this.$refs.signatureFile.getDataList().then((data) => {
-            //   this.inputForm.signatureFileList = data
-            // })
-            this.inputForm.signatureFileList = this.$refs.signatureFile.getDataList()
-            this.projectReportService.saveForm(this.inputForm).then(({data}) => {
-              callback(data.businessTable, data.businessId, this.inputForm)
-              this.loading = false
-            }).catch(() => {
-              this.loading = false
-            })
-          }
-        })
       },
       async updateStatusById (type) {
         if (type === 'reject' || type === 'reback') {