天波用户运营管理后台系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
5.0KB

  1. <!--
  2. * @Date: 2022-08-08 10:09:45
  3. * @LastEditors: JinxChen
  4. * @LastEditTime: 2022-08-09 16:44:50
  5. * @FilePath: \TelpoUserManageAdmin\src\views\message-manage\main\add-articles\index.vue
  6. * @description: 添加文章
  7. -->
  8. <template>
  9. <div class="home-container">
  10. <!-- 顶部内容 -->
  11. <div class="top-container">
  12. <TopMenu :buttonList="buttonList"/>
  13. </div>
  14. <!-- 表单 -->
  15. <el-form ref="form" :model="form" label-width="80px" size="small">
  16. <el-form-item label="文章标题:">
  17. <el-input v-model="form.articleTitle" ></el-input>
  18. </el-form-item>
  19. <el-form-item label="文章类型:">
  20. <el-select v-model="form.articleType" placeholder="请选择文章类型">
  21. <el-option :label="item.label" :value="item.label" v-for="(item, index) in articleTypes" :key="index"/>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="分享标题:">
  25. <el-input v-model="form.shareTitle"></el-input>
  26. </el-form-item>
  27. <el-form-item label="分享简介:">
  28. <el-input v-model="form.shareAbout"></el-input>
  29. </el-form-item>
  30. <el-form-item label="分享图片:">
  31. <el-button v-show="fileList.length > 0" disabled type="warning">请删除图片后再上传</el-button>
  32. <el-upload
  33. class="upload-img"
  34. action="https://jsonplaceholder.typicode.com/posts/"
  35. :on-preview="onPreview"
  36. :on-remove="onRemove"
  37. :on-progress="onProgress"
  38. :before-remove="beforeRemove"
  39. :before-upload="beforeUpload"
  40. :on-error="onError"
  41. :on-success="onSuccess"
  42. :on-change="onUploadChange"
  43. :auto-upload="false"
  44. :limit="1"
  45. list-type="picture"
  46. :file-list="fileList">
  47. <el-button size="small" type="primary" v-show="fileList.length <= 0">点击上传</el-button>
  48. <div slot="tip" class="el-upload__tip">
  49. <p>最多上传一张,尺寸750X300</p>
  50. </div>
  51. </el-upload>
  52. </el-form-item>
  53. <!-- 富文本编辑器 -->
  54. <el-form-item label="文章内容:">
  55. <tinymce v-model="form.articleContent" :height="5" menubar="false" />
  56. <!-- <p>文章内容:{{form.articleContent}}</p> -->
  57. </el-form-item>
  58. <!-- 保存 -->
  59. <el-form-item class="footer-btn">
  60. <el-button type="primary" @click="onSave">保存</el-button>
  61. <el-button>取消</el-button>
  62. </el-form-item>
  63. </el-form>
  64. </div>
  65. </template>
  66. <script>
  67. import TopMenu from "@/components/TopMenu/index";
  68. import Tinymce from '@/components/Tinymce'
  69. export default {
  70. name: 'wechat-fans',
  71. components: { TopMenu, Tinymce },
  72. data(){
  73. return {
  74. buttonList: [], // 头部按钮,例子: {name: '添加', type: 'primary', icon: 'el-icon-circle-plus', click: () => { this.AddDialog();}}
  75. // 表单数据
  76. form: {
  77. articleTitle: '', //文章标题
  78. articleType: '普通文章', //文章类型
  79. shareTitle: '', //分享标题
  80. shareAbout: '', //分享简介
  81. shareImage: '', //分享图片
  82. articleContent: '', //文章内容
  83. },
  84. // 文章类型
  85. articleTypes: [
  86. { label: '普通文章', value: '普通文章' },
  87. { label: '特别文章', value: '特别文章' },
  88. { label: '其它文章', value: '其它文章' },
  89. ],
  90. // 图片列表
  91. fileList: [],
  92. }
  93. },
  94. mounted() {},
  95. created() {
  96. this.clearFiles();
  97. console.log("本地的上传图片列表", this.fileList);
  98. },
  99. methods: {
  100. // 清空本地上传的图片列表
  101. clearFiles() {},
  102. // 删除上传的图片
  103. onRemove() {
  104. this.fileList = []
  105. },
  106. // 点击文件列表中已上传的文件时的钩子
  107. onPreview(file) {
  108. console.log("点击了上传图片", file);
  109. },
  110. // 删除上传图片
  111. beforeRemove(file) {
  112. return this.$confirm(`确定删除 ${ file.name }?`);
  113. },
  114. // 上传图片前
  115. beforeUpload(file) {
  116. console.log("上传图片前::", file);
  117. },
  118. // 上传失败
  119. onError(err) {
  120. return this.$confirm(`上传失败,请联系管理人`);
  121. },
  122. // 上传成功
  123. onSuccess(file) {
  124. console.log("上传成功", file);
  125. },
  126. // 文件上传时
  127. onProgress(fileList) {
  128. console.log("fileList", fileList);
  129. },
  130. // 上传文件发生变化时
  131. onUploadChange(file) {
  132. console.log('传文件发生变化时', file);
  133. if(this.fileList.length > 0) {
  134. this.fileList.length = 0
  135. } else {
  136. this.fileList.push(file);
  137. }
  138. },
  139. // 保存
  140. onSave() {
  141. console.log("保存的内容::", this.form);
  142. }
  143. }
  144. }
  145. </script>
  146. <style scoped lang="scss">
  147. .home-container {
  148. position: relative;
  149. height: 600px;
  150. overflow-y: scroll;
  151. overflow-x: hidden;
  152. padding: 0 20px;
  153. p {
  154. padding: 5px;
  155. }
  156. }
  157. .upload-img {
  158. width: 400px;
  159. .el-button {
  160. margin-left: 0;
  161. }
  162. }
  163. </style>