main.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <el-dialog
  3. v-dialogdrag
  4. title="发送通知"
  5. :visible.sync="visible"
  6. append-to-body
  7. width="45%"
  8. :close-on-click-modal="false"
  9. :destroy-on-close="true"
  10. :close-on-press-escape="false"
  11. :before-close="closeDialog"
  12. >
  13. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  14. <el-form-item label="接受者" prop="userList">
  15. <el-select
  16. v-model="form.userList"
  17. clearable
  18. filterable
  19. multiple
  20. size="small"
  21. style="width: 100%"
  22. >
  23. <el-option
  24. v-for="(item, index) in userOption"
  25. :key="index"
  26. :label="item.realName"
  27. :value="item.id"
  28. @change="getUserName"
  29. ></el-option>
  30. </el-select>
  31. </el-form-item>
  32. <el-form-item label="发送内容" prop="messageBody">
  33. <el-input type="textarea" v-model="form.messageBody" size="small" placeholder="请输入发送内容"></el-input>
  34. </el-form-item>
  35. </el-form>
  36. <span slot="footer" class="dialog-footer">
  37. <el-button type="primary" @click="sendHandle">发送</el-button>
  38. <el-button @click="closeDialog">取消</el-button>
  39. </span>
  40. </el-dialog>
  41. </template>
  42. <script>
  43. import { getList } from "@/api/system/user";
  44. import { sendMessage,sendManyMessage } from "@/api/basicData/message"
  45. export default {
  46. name: "main",
  47. props: {},
  48. data() {
  49. return {
  50. visible: false,
  51. form: {
  52. userList: [],
  53. messageBody: null,
  54. },
  55. userOption: [],
  56. rules: {
  57. userList: [{required: true, message: " ", trigger: "change"}],
  58. messageBody: [{required: true, message: " ", trigger: "blur"}],
  59. },
  60. }
  61. },
  62. created() {
  63. getList().then(res => {
  64. this.userOption = res.data.data.records;
  65. })
  66. },
  67. methods: {
  68. // 打开
  69. init() {
  70. this.visible = true;
  71. },
  72. closeDialog() {
  73. this.visible = false;
  74. this.form = {}
  75. this.$refs.form.clearValidate();
  76. this.$emit("closeDialog")
  77. },
  78. // 发送消息
  79. sendHandle() {
  80. this.$refs["form"].validate(valid => {
  81. if (valid) {
  82. const data = {
  83. ...this.form,
  84. messageType: 1
  85. }
  86. sendManyMessage(data).then(res => {
  87. this.$message.success('发送成功')
  88. this.closeDialog()
  89. })
  90. }
  91. })
  92. },
  93. getUserName() {
  94. },
  95. },
  96. }
  97. </script>
  98. <style scoped>
  99. </style>