msg.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="查看消息"
  5. width="70%"
  6. :close-on-click-modal="false"
  7. :visible.sync="visible">
  8. <el-form :model="dataForm" ref="dataForm" label-width="auto">
  9. <el-form-item label="消息类型" prop="type">
  10. <el-input v-model="dataForm.type"/>
  11. </el-form-item>
  12. <el-form-item label="标题" prop="title">
  13. <el-input v-model="dataForm.title"/>
  14. </el-form-item>
  15. <el-form-item label="内容" prop="content">
  16. <el-input v-model="dataForm.content"/>
  17. </el-form-item>
  18. </el-form>
  19. </el-dialog>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'msg',
  25. data () {
  26. return {
  27. visible: false,
  28. id: 0,
  29. dataForm: {}
  30. }
  31. },
  32. mounted () {
  33. const that = this
  34. this.$nextTick(() => {
  35. this.$store.state.websocket.webSocket.onmessage = async function (event) {
  36. if (!event || !event.data) {
  37. return
  38. }
  39. that.dataForm = JSON.parse(event.data)
  40. // if (!that.visible) {
  41. // that.visible = true
  42. // }
  43. }
  44. })
  45. },
  46. methods: {
  47. // todo
  48. }
  49. }
  50. </script>
  51. <style scoped>
  52. </style>