Prechádzať zdrojové kódy

富文本中的图片获取临时地址错误修复

lizhenhao 2 rokov pred
rodič
commit
3db89a805e

+ 11 - 14
src/views/modules/klgBase/questions/KlgBaseQuestionsDetailForm.vue

@@ -446,38 +446,35 @@
       },
       getEditorFilesDTOList () {
         let a = []
-        // this.inputForm.content.splice('amp;', '')
         if (this.commonJS.isNotEmpty(this.inputForm.editorFilesDTOList)) {
+          this.inputForm.content = this.inputForm.content.replace(/&/g, '&')
           this.inputForm.editorFilesDTOList.forEach((item) => {
             if (this.inputForm.content.includes(item.temporaryUrl)) {
               a.push(item)
             }
           })
         }
-        setTimeout(() => {
-          this.inputForm.editorFilesDTOList = []
-          a.forEach((item) => {
-            this.inputForm.editorFilesDTOList.push(item)
-          })
-        }, 200)
+        this.inputForm.editorFilesDTOList = []
+        a.forEach((item) => {
+          this.inputForm.editorFilesDTOList.push(item)
+        })
       },
       getEditorFilesDTOS () {
         if (this.commonJS.isNotEmpty(this.inputForm.klgBaseReplyDTOList)) {
           this.inputForm.klgBaseReplyDTOList.forEach((item, index) => {
+            item.content = item.content.replace(/&/g, '&')
             let a = []
             if (this.commonJS.isNotEmpty(item.editorFilesDTOList)) {
               item.editorFilesDTOList.forEach((item2) => {
                 if (item.content.includes(item2.temporaryUrl)) {
-                  a.push(item)
+                  a.push(item2)
                 }
               })
             }
-            setTimeout(() => {
-              this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList = []
-              a.forEach((item) => {
-                this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList.push(item)
-              })
-            }, 200)
+            this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList = []
+            a.forEach((item) => {
+              this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList.push(item)
+            })
           })
         }
       },

+ 11 - 14
src/views/modules/klgBase/questions/KlgBaseQuestionsForm.vue

@@ -431,38 +431,35 @@
       },
       getEditorFilesDTOList () {
         let a = []
-        // this.inputForm.content.splice('amp;', '')
         if (this.commonJS.isNotEmpty(this.inputForm.editorFilesDTOList)) {
+          this.inputForm.content = this.inputForm.content.replace(/&/g, '&')
           this.inputForm.editorFilesDTOList.forEach((item) => {
             if (this.inputForm.content.includes(item.temporaryUrl)) {
               a.push(item)
             }
           })
         }
-        setTimeout(() => {
-          this.inputForm.editorFilesDTOList = []
-          a.forEach((item) => {
-            this.inputForm.editorFilesDTOList.push(item)
-          })
-        }, 200)
+        this.inputForm.editorFilesDTOList = []
+        a.forEach((item) => {
+          this.inputForm.editorFilesDTOList.push(item)
+        })
       },
       getEditorFilesDTOS () {
         if (this.commonJS.isNotEmpty(this.inputForm.klgBaseReplyDTOList)) {
           this.inputForm.klgBaseReplyDTOList.forEach((item, index) => {
+            item.content = item.content.replace(/&/g, '&')
             let a = []
             if (this.commonJS.isNotEmpty(item.editorFilesDTOList)) {
               item.editorFilesDTOList.forEach((item2) => {
                 if (item.content.includes(item2.temporaryUrl)) {
-                  a.push(item)
+                  a.push(item2)
                 }
               })
             }
-            setTimeout(() => {
-              this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList = []
-              a.forEach((item) => {
-                this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList.push(item)
-              })
-            }, 200)
+            this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList = []
+            a.forEach((item) => {
+              this.inputForm.klgBaseReplyDTOList[index].editorFilesDTOList.push(item)
+            })
           })
         }
       },

+ 57 - 60
src/views/modules/notify/NotifyForm.vue

@@ -107,11 +107,10 @@
         <el-col :span="24">
           <el-form-item label="内容" prop="content"
                         :rules="[
-                          {required: true, message:'内容不能为空', trigger:'blur'}
                    ]">
             <WangEditor ref="contentEditor" v-model="inputForm.content" @getUrl="(url, lsUrl) => {
                         inputForm.editorFilesDTOList.push({temporaryUrl: lsUrl, url: url})
-                        }"/>
+                        }" @change="changeEditor"/>
           </el-form-item>
         </el-col>
       </el-row>
@@ -221,7 +220,7 @@
 
       <span slot="footer" class="dialog-footer">
       <el-button size="small" @click="close()" icon="el-icon-circle-close">关闭</el-button>
-      <el-button size="small" v-if="method === 'edit'" type="primary" icon="el-icon-circle-check" @click="doSubmit()">确定</el-button>
+      <el-button size="small" v-if="method === 'edit'" type="primary" icon="el-icon-circle-check" @click="doSubmitBefore()">确定</el-button>
     </span>
     </el-dialog>
 
@@ -434,67 +433,69 @@
           })
         })
       },
+      doSubmitBefore () {
+        if (this.inputForm.status === '5') {
+          this.$confirm(`修改后会重新发起通告,确定修改数据吗?`, '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+            this.doSubmit()
+          })
+        } else {
+          this.doSubmit()
+        }
+      },
       // 表单提交
       doSubmit () {
-        this.$confirm(`修改后会重新发起通告,确定修改数据吗?`, '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          this.$refs['inputForm'].validate((valid) => {
-            if (valid) {
-              this.loading = true
-              if (this.$refs.uploadComponent.checkProgress()) {
-                this.loading = false
-                return
-              }
-              if (this.commonJS.isEmpty(this.inputForm.pluginNotifyOfficesDTOList) && this.commonJS.isEmpty(this.inputForm.pluginNotifyUserDTOList)) {
-                this.$message.error('通告范围(部门或成员),至少填写一项')
-                this.loading = false
-                throw new Error('通告范围(部门或成员),至少填写一项')
-              }
-              this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
-              if (this.commonJS.isNotEmpty(this.inputForm.dates)) {
-                this.inputForm.beginDate = this.inputForm.dates[0]
-                this.inputForm.endDate = this.inputForm.dates[1]
-                if (this.commonJS.isNotEmpty(this.inputForm.beginDate) && this.commonJS.isNotEmpty(this.inputForm.endDate)) {
-                  if (this.inputForm.beginDate === this.inputForm.endDate) {
-                    if (this.inputForm.notifyType === '0') {
-                      this.$message.error('通告起止时间不可以相同')
-                      this.loading = false
-                      throw new Error('通告起止时间不可以相同')
-                    }
-                  }
-                } else {
+        this.$refs['inputForm'].validate((valid) => {
+          if (valid) {
+            this.loading = true
+            if (this.$refs.uploadComponent.checkProgress()) {
+              this.loading = false
+              return
+            }
+            if (this.commonJS.isEmpty(this.inputForm.pluginNotifyOfficesDTOList) && this.commonJS.isEmpty(this.inputForm.pluginNotifyUserDTOList)) {
+              this.$message.error('通告范围(部门或成员),至少填写一项')
+              this.loading = false
+              throw new Error('通告范围(部门或成员),至少填写一项')
+            }
+            this.inputForm.workAttachmentDtoList = this.$refs.uploadComponent.getDataList()
+            if (this.commonJS.isNotEmpty(this.inputForm.dates)) {
+              this.inputForm.beginDate = this.inputForm.dates[0]
+              this.inputForm.endDate = this.inputForm.dates[1]
+              if (this.commonJS.isNotEmpty(this.inputForm.beginDate) && this.commonJS.isNotEmpty(this.inputForm.endDate)) {
+                if (this.inputForm.beginDate === this.inputForm.endDate) {
                   if (this.inputForm.notifyType === '0') {
-                    this.$message.error('请填写通告时间')
+                    this.$message.error('通告起止时间不可以相同')
                     this.loading = false
-                    throw new Error('请填写通告时间')
+                    throw new Error('通告起止时间不可以相同')
                   }
                 }
               } else {
-                this.inputForm.beginDate = ''
-                this.inputForm.endDate = ''
                 if (this.inputForm.notifyType === '0') {
                   this.$message.error('请填写通告时间')
                   this.loading = false
                   throw new Error('请填写通告时间')
                 }
               }
-              if (this.commonJS.isEmpty(this.inputForm.content)) {
-                this.$message.error('请填写内容')
+            } else {
+              this.inputForm.beginDate = ''
+              this.inputForm.endDate = ''
+              if (this.inputForm.notifyType === '0') {
+                this.$message.error('请填写通告时间')
                 this.loading = false
-                throw new Error('请填写内容')
+                throw new Error('请填写通告时间')
               }
-              this.getEditorFilesDTOList()
-              this.notifyService.saveForm(this.inputForm).then(({data}) => {
-                this.loading = false
-                this.close()
-              }).catch(() => {
-                this.loading = false
-              })
             }
-          })
+            this.getEditorFilesDTOList()
+            this.notifyService.saveForm(this.inputForm).then(({data}) => {
+              this.loading = false
+              this.close()
+            }).catch(() => {
+              this.loading = false
+            })
+          }
         })
       },
       close () {
@@ -542,24 +543,17 @@
       getEditorFilesDTOList () {
         let a = []
         if (this.commonJS.isNotEmpty(this.inputForm.editorFilesDTOList)) {
-          this.inputForm.content = this.inputForm.content.replace(/&amp;/, '&')
-          console.log('content', this.inputForm.content)
-          console.log('editorFilesDTOList', this.inputForm.editorFilesDTOList)
+          this.inputForm.content = this.inputForm.content.replace(/&amp;/g, '&')
           this.inputForm.editorFilesDTOList.forEach((item) => {
-            console.log('尽')
             if (this.inputForm.content.includes(item.temporaryUrl)) {
               a.push(item)
-              console.log('a', a)
             }
           })
         }
-        setTimeout(() => {
-          this.inputForm.editorFilesDTOList = []
-          a.forEach((item) => {
-            console.log('editorFilesDTOList', this.inputForm.editorFilesDTOList)
-            this.inputForm.editorFilesDTOList.push(item)
-          })
-        }, 200)
+        this.inputForm.editorFilesDTOList = []
+        a.forEach((item) => {
+          this.inputForm.editorFilesDTOList.push(item)
+        })
       },
       openOfficeChoose () {
         this.$refs.officeTreeSelect.init()
@@ -661,6 +655,9 @@
         this.notifyService.delComment(id).then(() => {
           this.init(this.method, this.inputForm.id)
         })
+      },
+      changeEditor (cont) {
+        this.inputForm.content = cont
       }
     }
   }

+ 5 - 18
src/views/modules/notify/NotifyTaskForm.vue

@@ -97,7 +97,6 @@
           <el-col :span="24">
             <el-form-item label="内容" prop="content"
                           :rules="[
-                          {required: true, message:'内容不能为空', trigger:'blur'}
                    ]">
               <WangEditor ref="contentEditor" v-model="inputForm.content" @getUrl="(url, lsUrl) => {
                         inputForm.editorFilesDTOList.push({temporaryUrl: lsUrl, url: url})
@@ -465,11 +464,6 @@
                 throw new Error('请填写通告时间')
               }
             }
-            if (this.commonJS.isEmpty(this.inputForm.content)) {
-              this.$message.error('请填写内容')
-              this.loading = false
-              throw new Error('请填写内容')
-            }
             this.getEditorFilesDTOList()
             this.notifyService.saveForm(this.inputForm).then(({data}) => {
               this.loading = false
@@ -571,24 +565,17 @@
       getEditorFilesDTOList () {
         let a = []
         if (this.commonJS.isNotEmpty(this.inputForm.editorFilesDTOList)) {
-          this.inputForm.content = this.inputForm.content.replace(/&amp;/, '&')
-          console.log('content', this.inputForm.content)
-          console.log('editorFilesDTOList', this.inputForm.editorFilesDTOList)
+          this.inputForm.content = this.inputForm.content.replace(/&amp;/g, '&')
           this.inputForm.editorFilesDTOList.forEach((item) => {
-            console.log('尽')
             if (this.inputForm.content.includes(item.temporaryUrl)) {
               a.push(item)
-              console.log('a', a)
             }
           })
         }
-        setTimeout(() => {
-          this.inputForm.editorFilesDTOList = []
-          a.forEach((item) => {
-            console.log('editorFilesDTOList', this.inputForm.editorFilesDTOList)
-            this.inputForm.editorFilesDTOList.push(item)
-          })
-        }, 200)
+        this.inputForm.editorFilesDTOList = []
+        a.forEach((item) => {
+          this.inputForm.editorFilesDTOList.push(item)
+        })
       },
       openOfficeChoose () {
         this.$refs.officeTreeSelect.init()