Rap 原分销系统代码Web
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

99 lignes
2.7KB

  1. <template>
  2. <div>
  3. <el-form ref="form" :model="form" :rules="rules" style="margin-top: 6px;" size="small" label-width="100px">
  4. <el-form-item label="邮件标题" prop="subject">
  5. <el-input v-model="form.subject" style="width: 646px" placeholder="请输入邮件标题,标题不能为空" />
  6. </el-form-item>
  7. <el-form-item label="收件地址" prop="tos">
  8. <el-input v-model="form.tos" style="width: 646px" placeholder="请输入收件地址,多个地址英文逗号,隔开" />
  9. </el-form-item>
  10. <div ref="editor" class="editor" />
  11. <el-button :loading="loading" style="margin-left:1.6%;margin-bottom: 30px" size="medium" type="primary" @click="doSubmit">发送邮件</el-button>
  12. </el-form>
  13. </div>
  14. </template>
  15. <script>
  16. import { send } from '@/api/tools/email'
  17. import { upload } from '@/utils/upload'
  18. import { mapGetters } from 'vuex'
  19. import E from 'wangeditor'
  20. export default {
  21. name: 'Index',
  22. data() {
  23. return {
  24. loading: false, form: { subject: '', tos: '', content: '' },
  25. rules: {
  26. subject: [
  27. { required: true, message: '标题不能为空', trigger: 'blur' }
  28. ],
  29. tos: [
  30. { required: true, message: '收件人不能为空', trigger: 'blur' }
  31. ]
  32. }
  33. }
  34. },
  35. computed: {
  36. ...mapGetters([
  37. 'imagesUploadApi',
  38. 'baseApi'
  39. ])
  40. },
  41. mounted() {
  42. const _this = this
  43. var editor = new E(this.$refs.editor)
  44. // 自定义菜单配置
  45. editor.config.zIndex = 10
  46. // 文件上传
  47. editor.config.customUploadImg = function(files, insert) {
  48. // files 是 input 中选中的文件列表
  49. // insert 是获取图片 url 后,插入到编辑器的方法
  50. files.forEach(image => {
  51. upload(_this.imagesUploadApi, image).then(res => {
  52. const data = res.data
  53. const url = _this.baseApi + '/file/' + data.type + '/' + data.realName
  54. insert(url)
  55. })
  56. })
  57. }
  58. editor.config.onchange = (html) => {
  59. this.form.content = html
  60. }
  61. editor.create()
  62. },
  63. methods: {
  64. doSubmit() {
  65. this.$refs['form'].validate((valid) => {
  66. if (valid) {
  67. this.loading = true
  68. send(this.form).then(res => {
  69. this.$notify({
  70. title: '发送成功',
  71. type: 'success',
  72. duration: 2500
  73. })
  74. this.loading = false
  75. }).catch(err => {
  76. this.loading = false
  77. console.log(err.response.data.message)
  78. })
  79. } else {
  80. return false
  81. }
  82. })
  83. }
  84. }
  85. }
  86. </script>
  87. <style scoped>
  88. .editor{
  89. text-align:left;
  90. margin: 20px;
  91. width: 730px;
  92. }
  93. ::v-deep .w-e-text-container {
  94. height: 360px !important;
  95. }
  96. </style>