Jelajahi Sumber

图片格式传值错误

xiaomin 4 tahun lalu
induk
melakukan
2951817702
1 mengubah file dengan 5 tambahan dan 18 penghapusan
  1. 5 18
      src/views/journalism/journalism.vue

+ 5 - 18
src/views/journalism/journalism.vue

@@ -373,7 +373,10 @@ export default {
       this.$refs[formName].validate(async (valid) => {
         if(valid) {
             const formData = new FormData();
-            formData.append('photo', this.formList.photo);
+            if(this.flag == 1) {
+              formData.append('photo', this.formList.photo);
+            }
+
             formData.append('title', this.formList.title);
             formData.append('newsAbstract', this.formList.newsAbstract);
             this.treeIds = this.$refs.tree.getCheckedNodes(false, true);
@@ -482,21 +485,6 @@ export default {
     onEditorFocus(){}, // 获得焦点事件
     onEditorChange(event){
       this.formList.content = event.html;
-      	// console.log(event.html);
-       //  var imgReg = /<img.*?(?:>|\/>)/gi;
-       //  var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i;
-       //  this.picList = event.html.match(imgReg);
-       //  if( this.picList == []) {
-       //    return;
-       //  }else{
-       //    for (var i = 0; i < this.picList.length; i++) {
-       //      var src = this.picList[i].match(srcReg);
-       //      //获取图片地址
-       //      // console.log('图片地址'+(i+1)+':'+src[1]);
-       //      // console.log(src[1]);
-       //    }
-       //    console.log(src);
-       //  }
 
     }, // 内容改变事件
 
@@ -587,10 +575,9 @@ export default {
       console.log(file);
     },
     handleSuccess (a) {
-      // console.log(this.formList.photo)
-      this.formList.photo = a.raw;
       if(a !== '') {
         this.flag = 1
+        this.formList.photo = a.raw;
         this.formChangeList.photo = a.raw;
       }else {
         this.flag = 0