sendEmailForm.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">{{title}}</block>
  6. </cu-custom>
  7. <form @submit="formSubmit" class="cu-list menu">
  8. <view class="cu-form-group">
  9. <view class="title">
  10. <text class="red-color">* </text> 发送到
  11. </view>
  12. <user-select v-model="inputForm.receiverIds"></user-select>
  13. </view>
  14. <view class="cu-form-group">
  15. <view class="title">
  16. <text class="red-color">* </text> 标题
  17. </view>
  18. <input placeholder="请输入标题" maxlength="200" v-model="inputForm.mailDTO.title" name="title"></input>
  19. </view>
  20. <view class="cu-form-group">
  21. <view class="title">
  22. <text class="red-color">* </text> 内容
  23. </view>
  24. <textarea maxlength="2000" v-model="inputForm.mailDTO.content" name="content" placeholder="请填写内容"></textarea>
  25. </view>
  26. <view class="bottom-wrap flex">
  27. <view class="flex-sub">
  28. <button class="cu-btn lg block buttonBox bg-gray" @click="saveDraft"> 存为草稿</button>
  29. </view>
  30. <view class="flex-sub">
  31. <button class="cu-btn lg buttonBox block bg-blue " @click="sendEmail">发送邮件</button>
  32. </view>
  33. </view>
  34. </form>
  35. </view>
  36. </template>
  37. <script>
  38. import userSelect from '@/components/user-select/user-select.vue'
  39. var graceChecker = require("@/common/graceChecker.js");
  40. import mailComposeService from "@/api/mail/mailComposeService";
  41. import userService from "@/api/sys/userService"
  42. export default {
  43. onShow() {
  44. this.$auth.checkLogin()
  45. userService.treeData().then(({data})=>{
  46. this.data = data
  47. }).catch((e)=>{
  48. throw e
  49. })
  50. },
  51. async onLoad(mail) {
  52. if(mail&&mail.id){
  53. this.titile = "编辑邮件";
  54. let {data} = await mailComposeService.queryById(mail.id);
  55. this.inputForm = this.recover(this.inputForm, data);
  56. }
  57. },
  58. components:{
  59. userSelect
  60. },
  61. data () {
  62. return {
  63. data: [],
  64. defaultProps: {
  65. children: 'children',
  66. label: 'label'
  67. },
  68. title: '发送邮件',
  69. modalName: null,
  70. inputForm: {
  71. id: '',
  72. status: '',
  73. receiverIds: '',
  74. mailDTO: {
  75. title: '',
  76. overview: '',
  77. content: ''
  78. }
  79. }
  80. }
  81. },
  82. methods: {
  83. PickerChange(e) {
  84. this.index = e.detail.value
  85. },
  86. radioChange (evt) {
  87. this.inputForm.status = evt.detail.value
  88. },
  89. saveDraft () {
  90. this.inputForm.status = '0'
  91. this.formSubmit()
  92. },
  93. sendEmail () {
  94. this.inputForm.status = '1'
  95. this.formSubmit()
  96. },
  97. selectUsers () {
  98. let ids = this.$refs.userTree.getCheckedNodes().filter((item)=>{
  99. return item.type === 'user'
  100. }).map((item)=>{
  101. return item.id
  102. }).join(",");
  103. let names = this.$refs.userTree.getCheckedNodes().filter((item)=>{
  104. return item.type === 'user'
  105. }).map((item)=>{
  106. return item.label
  107. }).join(",");
  108. this.inputForm.receiverIds = ids
  109. this.receiverNames = names
  110. this.hideModal()
  111. },
  112. showModal(e) {
  113. this.modalName = e.currentTarget.dataset.target
  114. },
  115. hideModal(e) {
  116. this.modalName = null
  117. },
  118. formSubmit: function(e) {
  119. //定义表单规则
  120. var rule = [
  121. {name:"receiverIds", checkType : "notnull", checkRule:"", errorMsg:"收件人不能为空"},
  122. {name:"mailDTO.title", checkType : "notnull", checkRule:"", errorMsg:"标题不能为空"},
  123. {name:"mailDTO.content", checkType : "notnull", checkRule:"", errorMsg:"内容不能为空"}
  124. ];
  125. //进行表单检查
  126. var formData = this.inputForm;
  127. var checkRes = graceChecker.check(formData, rule);
  128. if(checkRes){
  129. uni.showLoading()
  130. mailComposeService.save(this.inputForm).then(({data}) => {
  131. uni.showToast({title:data, icon:"success"});
  132. uni.navigateTo({
  133. url: '/pages/apps/mail/inbox'
  134. })
  135. }).catch((e)=>{
  136. console.log(e)
  137. })
  138. }else{
  139. uni.showToast({ title: graceChecker.error, icon: "none" });
  140. }
  141. }
  142. }
  143. }
  144. </script>
  145. <style>
  146. .cu-form-group .title {
  147. min-width: calc(4em + 30px);
  148. }
  149. .cu-form-group.arrow:before {
  150. position: absolute;
  151. /* top: 0; */
  152. right: 17px;
  153. /* bottom: 0; */
  154. display: block;
  155. margin: auto;
  156. width: 17px;
  157. height: 17px;
  158. color: #8799a3;
  159. content: "\e6a3";
  160. text-align: center;
  161. font-size: 20px;
  162. font-family: cuIcon;
  163. line-height: 17px;
  164. }
  165. .ellipsis-description {
  166. display: -webkit-box;/*作为弹性伸缩盒子模型显示*/
  167. -webkit-line-clamp: 1; /*显示的行数;如果要设置2行加...则设置为2*/
  168. overflow: hidden; /*超出的文本隐藏*/
  169. text-overflow: ellipsis; /* 溢出用省略号*/
  170. -webkit-box-orient: vertical;/*伸缩盒子的子元素排列:从上到下*/
  171. }
  172. .cu-form-group .title {
  173. min-width: calc(4em + 40px);
  174. }
  175. </style>