明梦爽
2022-01-25 546c0df2c7d278cb2a3e6fa6fc2ff730d410fdbd
src/components/Administrator/Edit.vue
@@ -1,11 +1,25 @@
<template>
  <div class="box">
    <el-row><h3 style="margin-top: 0px">{{ $route.query.title }}</h3></el-row>
    新闻标题:<el-input v-model="title" placeholder="请输入新闻标题"></el-input><br/><br/>
    发布日期:<el-date-picker v-model="releaseTime" placeholder="请选择新闻发布日期"></el-date-picker><br/><br/>
    发布日期:<el-date-picker  format="yyyy 年 MM 月 dd 日" value-format="yyyy-MM-dd" v-model="releaseTime" placeholder="请选择新闻发布日期"></el-date-picker><br/><br/>
    <!-- <el-upload
      class="upload-demo"
      ref="upload"
      drag
      action
      :auto-upload="false"
      :http-request="httpRequest"
      multiple
      :file-list="fileList">
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
      <div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过500kb</div>
    </el-upload><br/> -->
    新闻内容:<quill-editor ref="text" v-model="content" class="myQuillEditor" :options="editorOption" />
    <div class="btn">
    <el-row style="margin-top:50px;">
      <el-button  type="success" @click="submit">发布</el-button>
    </div>
    </el-row>
  </div>
</template>
<script>
@@ -32,6 +46,7 @@
        size: 10000000,  // 可选参数   图片大小,单位为Kb, 1M = 1024Kb
        accept: 'multipart/form-data, image/png, image/gif, image/jpeg, image/bmp, image/x-icon,image/jpg'  // 可选 可上传的图片格式
      } ,  //编辑器新闻对象
      fileList:[],
    }
  },
  created(){
@@ -39,7 +54,33 @@
    this.newsCategoryId = this.$route.query.id
  },
  methods:{
    // jsonData(formData){ var jsonData = {}; formData.forEach((value, key) => jsonData[key] = value); return jsonData },
    // httpRequest(params){
    //   const pictureFile = params.file;
    //   const newsCategoryId = this.newsCategoryId;
    //   const content = this.content;
    //   const title = this.title;
    //   const releaseTime = this.releaseTime;
    //   var formData = new FormData();
    //   formData.append("pictureFile",pictureFile)
    //   formData.append("newsCategoryId",newsCategoryId)
    //   formData.append("content",content)
    //   formData.append("title",title)
    //   formData.append("releaseTime",releaseTime)
    //   console.log(this.jsonData(formData));
    //   add(this.jsonData(formData)).then(res => {
    //     console.log(res);
    //     if(res.code !== 200){
    //       return this.$message.error('发布新闻失败,请重试!')
    //     }else{
    //       this.$message.success('新闻发布成功!')
    //       console.log(this.content);
    //       this.$router.go(-1)
    //     }
    //   })
    // },
    submit(){
      // this.$refs.upload.submit();
      const data = {
        newsCategoryId:this.newsCategoryId,
        content:this.content,