sendEmailForm.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view>
  3. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm">
  4. <u-form-item label="标题" borderBottom prop="mailDTO.title">
  5. <u--input v-model="inputForm.mailDTO.title" placeholder="请输入标题" border="none"></u--input>
  6. </u-form-item>
  7. <u-form-item label="发送到" borderBottom prop="receiverIds">
  8. <user-select v-model="inputForm.receiverIds"></user-select>
  9. </u-form-item>
  10. <u-form-item label="内容" borderBottom prop="mailDTO.content">
  11. <u--textarea v-model="inputForm.mailDTO.content" placeholder="请输入内容" border="none"></u--textarea>
  12. </u-form-item>
  13. </u--form>
  14. <view class="bottom-wrap flex">
  15. <u-button
  16. type="error"
  17. text="存为草稿"
  18. @click="saveDraft"
  19. ></u-button>
  20. <u-button
  21. type="primary"
  22. text="发送邮件"
  23. @click="sendEmail"
  24. ></u-button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import userSelect from '@/components/user-select/user-select.vue'
  30. var graceChecker = require("@/common/graceChecker.js");
  31. import mailComposeService from "@/api/mail/mailComposeService";
  32. import userService from "@/api/sys/userService"
  33. export default {
  34. async onLoad(mail) {
  35. if(mail&&mail.id){
  36. let data = await mailComposeService.queryById(mail.id);
  37. this.inputForm = this.recover(this.inputForm, data);
  38. }
  39. },
  40. components:{
  41. userSelect
  42. },
  43. data () {
  44. return {
  45. data: [],
  46. inputForm: {
  47. id: '',
  48. status: '',
  49. receiverIds: '',
  50. mailDTO: {
  51. title: '',
  52. overview: '',
  53. content: ''
  54. }
  55. },
  56. rules: {
  57. 'receiverIds': [
  58. {
  59. required: true,
  60. message: '请选择收件人',
  61. trigger: ['blur', 'change']
  62. }
  63. ],
  64. 'mailDTO.title': [
  65. {
  66. required: true,
  67. message: '请输入邮件标题',
  68. trigger: ['blur', 'change']
  69. }
  70. ],
  71. 'mailDTO.content': [
  72. {
  73. required: true,
  74. message: '请输入邮件内容',
  75. trigger: ['blur', 'change']
  76. }
  77. ]
  78. }
  79. }
  80. },
  81. methods: {
  82. saveDraft () {
  83. this.inputForm.status = '0'
  84. this.formSubmit()
  85. },
  86. sendEmail () {
  87. this.inputForm.status = '1'
  88. this.formSubmit()
  89. },
  90. formSubmit: function(e) {
  91. //定义表单规则
  92. this.$refs.inputForm.validate().then(res => {
  93. uni.showLoading()
  94. mailComposeService.save(this.inputForm).then((data) => {
  95. uni.showToast({title:data, icon:"success"});
  96. uni.navigateTo({
  97. url: '/pages/apps/mail/inbox'
  98. })
  99. }).catch((e)=>{
  100. console.log(e)
  101. })
  102. })
  103. }
  104. }
  105. }
  106. </script>