Browse Source

添加封面

achao 2 years ago
parent
commit
34c9f1153f

+ 4 - 4
src/views/enterpriseManagement/enterpriseAudit.vue

@@ -26,10 +26,10 @@
               <div :class="search == 1 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(1)">
                 待审核
               </div>
-              <div :class="search == 3 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(3)">
+              <div :class="search == 2 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(2)">
                 已通过
               </div>
-              <div :class="search == 2 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(2)">
+              <div :class="search == 3 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(3)">
                 已驳回
               </div>
               <div :class="search == 4 ? 'search' : 'searchNo'" class="search_item" @click="searchBtn(4)">
@@ -183,8 +183,8 @@
   } from '@/api/enterpriseManagement'
   export default {
      components: {
-      "el-image-viewer": () =>
-        import("element-ui/packages/image/src/image-viewer"),
+      'el-image-viewer': () =>
+        import('element-ui/packages/image/src/image-viewer'),
     },
     data() {
       return {

+ 187 - 161
src/views/officialWebsiteManagement/publicityAdd.vue

@@ -14,10 +14,16 @@
           <el-form-item label="发布机构">
             <el-input v-model="form.issuingAgency" clearable placeholder=""></el-input>
           </el-form-item>
+          <el-form-item label="封面图片">
+            <el-upload class="avatar-uploader1" :action="uploadPath"
+              :show-file-list="false" :on-success="handleAvatarSuccess">
+              <img v-if="imageUrl" :src="imageUrl" class="avatar">
+              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+            </el-upload>
+          </el-form-item>
           <div class="quill-editor">
             <!-- 图片上传组件辅助,组件内添加v-show=“false”属性,把该组件隐藏起来。-->
-            <el-upload class="avatar-uploader" :action="uploadPath" :show-file-list="false"
-              :on-success="uploadSuccess">
+            <el-upload class="avatar-uploader" :action="uploadPath" :show-file-list="false" :on-success="uploadSuccess">
             </el-upload>
             <!--富文本编辑器组件-->
             <quill-editor v-model="form.releaseContent" :content="form.releaseContent" :options="editorOption"
@@ -38,182 +44,202 @@
 </template>
 
 <script>
-  import {
-    addFormData,
-    uploadPath
-  } from '@/api/officialWebsiteManagement'
-  import quillEditor from 'vue-quill-editor';
-  const toolbarOptions = [
-    ['bold', 'italic', 'underline', 'strike'], // 加粗,斜体,下划线,删除线
-    ['blockquote', 'code-block'], //引用,代码块
-    [{
-      'header': 1
-    }, {
-      'header': 2
-    }], // 几级标题
-    [{
-      'list': 'ordered'
-    }, {
-      'list': 'bullet'
-    }], // 有序列表,无序列表
-    [{
-      'script': 'sub'
-    }, {
-      'script': 'super'
-    }], // 下角标,上角标
-    [{
-      'indent': '-1'
-    }, {
-      'indent': '+1'
-    }], // 缩进
-    [{
-      'direction': 'rtl'
-    }], // 文字输入方向
-    [{
-      'size': ['small', false, 'large', 'huge']
-    }], // 字体大小
-    [{
-      'header': [1, 2, 3, 4, 5, 6, false]
-    }], // 标题
-    [{
-      'color': []
-    }, {
-      'background': []
-    }], // 颜色选择
-    [{
-      'font': ['SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial']
-    }], // 字体
-    [{
-      'align': []
-    }], // 居中
-    ['clean'], // 清除样式,
-    ['link', 'image'], // 上传图片、上传视频
-  ]
-  export default {
-    data() {
-      return {
-        uploadPath,
-        editorOption: {
-          modules: {
-            toolbar: {
-              container: toolbarOptions,
-              handlers: {
-                image: function(value) {
-                  if (value) {
-                    // 调用element的图片上传组件
-                    document.querySelector('.avatar-uploader input').click()
-                  } else {
-                    this.quill.format('image', false)
-                  }
+import {
+  addFormData,
+  uploadPath
+} from '@/api/officialWebsiteManagement'
+const toolbarOptions = [
+  ['bold', 'italic', 'underline', 'strike'], // 加粗,斜体,下划线,删除线
+  ['blockquote', 'code-block'], //引用,代码块
+  [{
+    'header': 1
+  }, {
+    'header': 2
+  }], // 几级标题
+  [{
+    'list': 'ordered'
+  }, {
+    'list': 'bullet'
+  }], // 有序列表,无序列表
+  [{
+    'script': 'sub'
+  }, {
+    'script': 'super'
+  }], // 下角标,上角标
+  [{
+    'indent': '-1'
+  }, {
+    'indent': '+1'
+  }], // 缩进
+  [{
+    'direction': 'rtl'
+  }], // 文字输入方向
+  [{
+    'size': ['small', false, 'large', 'huge']
+  }], // 字体大小
+  [{
+    'header': [1, 2, 3, 4, 5, 6, false]
+  }], // 标题
+  [{
+    'color': []
+  }, {
+    'background': []
+  }], // 颜色选择
+  [{
+    'font': ['SimSun', 'SimHei', 'Microsoft-YaHei', 'KaiTi', 'FangSong', 'Arial']
+  }], // 字体
+  [{
+    'align': []
+  }], // 居中
+  ['clean'], // 清除样式,
+  ['link', 'image'], // 上传图片、上传视频
+]
+export default {
+  data() {
+    return {
+      imageUrl: '',
+      uploadPath,
+      editorOption: {
+        modules: {
+          toolbar: {
+            container: toolbarOptions,
+            handlers: {
+              image: function (value) {
+                if (value) {
+                  // 调用element的图片上传组件
+                  document.querySelector('.avatar-uploader input').click()
+                } else {
+                  this.quill.format('image', false)
                 }
               }
             }
           }
-        },
-        form: {
-          issuingAgency: '畅运通信息部'
-        },
-        regulations: {},
-        version: [],
-        count: ""
-      }
-    },
-    created() {
-      this.form.makeUser = JSON.parse(localStorage.getItem('UserInfo')).deptName
-    },
-    methods: {
-      // 失去焦点
-      onEditorBlur(editor) {},
-      // 获得焦点
-      onEditorFocus(editor) {},
-      // 开始
-      onEditorReady(editor) {},
-      // 值发生变化
-      onEditorChange(editor) {
-        this.form.releaseContent = editor.html;
-        console.log(editor);
-      },
-      beforeUpload(file) {
-        const isIMAGE =''
-          file.type === 'image/jpeg' || 'image/gif' || 'image/png' || 'image/jpg'
-        const isLt1M = file.size / 1024 / 1024 < 1
-
-        if (!isIMAGE) {
-          this.$message.error('上传文件只能是图片格式!')
-        }
-        if (!isLt1M) {
-          this.$message.error('上传文件大小不能超过 1MB!')
         }
-        return isIMAGE && isLt1M
       },
-      uploadSuccess(res) {
-        debugger
-        // 获取富文本组件实例
-        let quill = this.$refs.QuillEditor.quill
-        // 如果上传成功
-        if (res.data.errno = 200 && res.data.url) {
-          // 获取光标所在位置
-          let length = quill.getSelection().index;
-          // 插入图片,res为服务器返回的图片链接地址
-          quill.insertEmbed(length, 'image', res.data.url)
-          // 调整光标到最后
-          quill.setSelection(length + 1)
-        } else {
-          // 提示信息,需引入Message
-          this.$message.error('图片插入失败!')
-        }
+      form: {
+        issuingAgency: '畅运通信息部'
       },
+      regulations: {},
+      version: [],
+      count: ''
+    }
+  },
+  created() {
+    this.form.makeUser = JSON.parse(localStorage.getItem('UserInfo')).deptName
+  },
+  methods: {
+    handleAvatarSuccess(res, file) {
+      this.imageUrl = URL.createObjectURL(file.raw);
+      this.form.cover =  res.data.url
+    },
+
+    // 失去焦点
+    onEditorBlur(editor) { },
+    // 获得焦点
+    onEditorFocus(editor) { },
+    // 开始
+    onEditorReady(editor) { },
+    // 值发生变化
+    onEditorChange(editor) {
+      this.form.releaseContent = editor.html;
+      console.log(editor);
+    },
 
-      submit() {
-        this.listLoading = true
-        this.form.contentType = '资讯'
-        addFormData(this.form).then(response => {
-            this.$notify({
-              title: '成功',
-              message: '添加成功!',
-              type: 'success'
-            });
-            this.listLoading = false
-            this.$router.go(-1)
-          })
-          .catch(() => {
-            this.loading = false
-          })
+    uploadSuccess(res) {
+      debugger
+      // 获取富文本组件实例
+      let quill = this.$refs.QuillEditor.quill
+      // 如果上传成功
+      if (res.data.errno = 200 && res.data.url) {
+        // 获取光标所在位置
+        let length = quill.getSelection().index;
+        // 插入图片,res为服务器返回的图片链接地址
+        quill.insertEmbed(length, 'image', res.data.url)
+        // 调整光标到最后
+        quill.setSelection(length + 1)
+      } else {
+        // 提示信息,需引入Message
+        this.$message.error('图片插入失败!')
       }
+    },
+
+    submit() {
+      this.listLoading = true
+      this.form.contentType = '资讯'
+      addFormData(this.form).then(response => {
+        this.$notify({
+          title: '成功',
+          message: '添加成功!',
+          type: 'success'
+        });
+        this.listLoading = false
+        this.$router.go(-1)
+      })
+        .catch(() => {
+          this.loading = false
+        })
     }
   }
+}
 </script>
 
 <style lang="scss" scoped>
-  .center {
-    background: #F5F6F7;
-    height: calc(100vh - 4.5vh);
-    padding-top: 20px;
+.center {
+  background: #F5F6F7;
+  height: calc(100vh - 4.5vh);
+  padding-top: 20px;
 
-  }
+}
 
-  .main_css {
-    width: 96%;
-    height: 90vh;
-    overflow-y: scroll;
-    background: #FFFFFF;
-    margin: 20px auto;
-    padding-top: 20px;
-  }
+.main_css {
+  width: 96%;
+  height: 90vh;
+  overflow-y: scroll;
+  background: #FFFFFF;
+  margin: 20px auto;
+  padding-top: 20px;
+}
 
-  .formData {
-    width: 50%;
-    margin: 20px 0 0 140px;
-  }
+.formData {
+  width: 50%;
+  margin: 20px 0 0 140px;
+}
 
-  .btn {
-    text-align: right;
-    position: absolute;
-    right: 200px;
-    bottom: 100px;
-  }
+.btn {
+  text-align: right;
+  position: absolute;
+  right: 200px;
+  bottom: 100px;
+}
 
-  .ql-editor {
-    height: 400px !important;
-  }
+.ql-editor {
+  height: 400px !important;
+}
+
+.avatar-uploader .el-upload {
+  border: 1px dashed #d9d9d9;
+  border-radius: 6px;
+  cursor: pointer;
+  position: relative;
+  overflow: hidden;
+}
+
+.avatar-uploader .el-upload:hover {
+  border-color: #409EFF;
+}
+
+.avatar-uploader-icon {
+  font-size: 28px;
+  color: #8c939d;
+  width: 178px;
+  height: 178px;
+  line-height: 178px;
+  text-align: center;
+}
+
+.avatar {
+  width: 178px;
+  height: 178px;
+  display: block;
+}
 </style>

+ 37 - 3
src/views/officialWebsiteManagement/publicityEdit.vue

@@ -14,6 +14,13 @@
           <el-form-item label="发布机构">
             <el-input v-model="form.issuingAgency" clearable placeholder=""></el-input>
           </el-form-item>
+          <el-form-item label="封面图片">
+            <el-upload class="avatar-uploader1" :action="uploadPath"
+              :show-file-list="false" :on-success="handleAvatarSuccess">
+              <img v-if="imageUrl" :src="imageUrl" class="avatar">
+              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
+            </el-upload>
+          </el-form-item>
           <div class="quill-editor">
             <!-- 图片上传组件辅助,组件内添加v-show=“false”属性,把该组件隐藏起来。-->
             <el-upload class="avatar-uploader" :action="uploadPath" :show-file-list="false" :on-success="uploadSuccess">
@@ -92,6 +99,7 @@
   export default {
     data() {
       return {
+         imageUrl: '',
         uploadPath,
         editorOption: {
           modules: {
@@ -115,7 +123,7 @@
         },
         regulations: {},
         version: [],
-        count: ""
+        count: ''
       }
     },
     created() {
@@ -126,14 +134,17 @@
       this.getList()
     },
     methods: {
+         handleAvatarSuccess(res, file) {
+      this.imageUrl = URL.createObjectURL(file.raw);
+      this.form.cover =  res.data.url
+    },
       getList() {
-        debugger
         this.listLoading = true
         var _obj = {}
         _obj.id = this.id
         seeData(_obj).then(response => {
-            debugger
             this.form = response.data
+            this.imageUrl =  response.data.cover
             console.log(this.form)
             this.listLoading = false
           })
@@ -241,4 +252,27 @@
   .ql-editor {
     height: 400px !important;
   }
+    .avatar-uploader1 .el-upload {
+    border: 1px dashed #d9d9d9;
+    border-radius: 6px;
+    cursor: pointer;
+    position: relative;
+    overflow: hidden;
+  }
+  .avatar-uploader1 .el-upload:hover {
+    border-color: #409EFF;
+  }
+  .avatar-uploader-icon {
+    font-size: 28px;
+    color: #8c939d;
+    width: 178px;
+    height: 178px;
+    line-height: 178px;
+    text-align: center;
+  }
+  .avatar {
+    width: 178px;
+    height: 178px;
+    display: block;
+  }
 </style>