Pārlūkot izejas kodu

提交修改代码

xiaomin 4 gadi atpakaļ
vecāks
revīzija
01c0ac7013
2 mainītis faili ar 33 papildinājumiem un 66 dzēšanām
  1. 0 1
      src/router/index.js
  2. 33 65
      src/views/journalism/journalism.vue

+ 0 - 1
src/router/index.js

@@ -13,7 +13,6 @@ const Journalism = () => import('@/views/journalism/journalism');
 //友情链接管理部分
 const Friendship = () => import('@/views/friendship/friendship');
 
-
 import { Message } from 'element-ui';
 
 Vue.use(Router);

+ 33 - 65
src/views/journalism/journalism.vue

@@ -97,19 +97,6 @@
               </el-upload>
             </el-form-item>
 
-           <!--  <el-form-item label="新闻封面" prop="photoId">
-              <el-upload
-              class="anniu"
-              ref="upload"
-              action="http://192.168.1.199:18083/newsmess/save_news"
-              :on-preview="handlePreview"
-              :on-remove="handleRemove"
-              :on-change="handleSuccess"
-              :auto-upload="false">
-              <el-button slot="trigger" size="small" type="primary">选取封面</el-button>
-              </el-upload>
-            </el-form-item> -->
-
             <el-form-item label="导航分类">
               <el-tree
                 :data="menuList"
@@ -132,6 +119,8 @@
                 class="avatar-uploader"
                 :action="serverUrl"
                 name="photo"
+                :format="['jpg','jpeg','png','gif']"
+                :max-size="2048"
                 :headers="header"
                 :show-file-list="false"
                 :on-success="uploadSuccess"
@@ -189,20 +178,6 @@
             <img style="width: 150px; height: 150px;" :src="dialogImageUrl" alt="">
           </el-form-item>
 
-          <!--   <el-form-item label="新闻封面">
-              <el-upload
-              class="anniu"
-              ref="upload"
-              action="http://192.168.1.199:18083/newsmess/save_news"
-              :on-preview="handlePreview"
-              :on-remove="handleRemove"
-              :on-change="handleSuccess"
-              :auto-upload="false">
-              <el-button slot="trigger" size="small" type="primary">选取封面</el-button>
-              <img style="width: 150px; height: 150px;" :src= "dialogImageUrl" alt="">
-              </el-upload>
-            </el-form-item> -->
-
             <el-form-item label="导航分类">
               <el-tree
                 :data="menuList"
@@ -224,6 +199,8 @@
                 class="avatar-uploader"
                 :action="serverUrl"
                 name="photo"
+                :format="['jpg','jpeg','png','gif']"
+                :max-size="2048"
                 :headers="header"
                 :show-file-list="false"
                 :on-success="uploadSuccessOne"
@@ -486,30 +463,22 @@ 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);
+       //  }
 
-
-        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]);
-          }
-
-        }
-
-        // this.photoList.push(src);
-        // console.log(this.photoList);
-      // console.log(event.html)
-      // console.log(document.getElementsByTagName('img'));
-      // this.picList.push(document.getElementsByTagName('img').src);
-      // console.log(this.picList)
-      // console.log(this.formList.content)
     }, // 内容改变事件
 
     // 打开修改并赋予信息
@@ -526,7 +495,6 @@ export default {
         this.haveRight = response.data.responseData.navigationBarIds;
         this.formChangeList.urlList = response.data.responseData.urlList;
         console.log(this.formChangeList.urlList);
-        // console.log(response.data.responseData)
       }
 
     },
@@ -549,20 +517,20 @@ export default {
       formData.append('navigationBarIds', this.formChangeList.navigationBarIds);
       formData.append('content', this.detailContent);
 
-      // const response = await this.$http.put(`app/newsArticle`, formData);
-      // if(response.data.code === 1) {
-      //   this.loadData();
-      //   this.changeUser = false;
-      //   this.$message({
-      //     type: 'success',
-      //     message: '修改新闻成功'
-      //   });
-      // }else {
-      //   this.$message({
-      //     type: 'error',
-      //     message: '修改新闻失败'
-      //   });
-      // }
+      const response = await this.$http.put(`app/newsArticle`, formData);
+      if(response.data.code === 1) {
+        this.loadData();
+        this.changeUser = false;
+        this.$message({
+          type: 'success',
+          message: '修改新闻成功'
+        });
+      }else {
+        this.$message({
+          type: 'error',
+          message: '修改新闻失败'
+        });
+      }
     },
      // 点击删除按钮
     Delete(id) {