<template>
  <div>
    <el-dialog
      title="查看消息"
      width="70%"
      :close-on-click-modal="false"
      :visible.sync="visible">
      <el-form :model="dataForm" ref="dataForm" label-width="auto">
        <el-form-item label="消息类型" prop="type">
          <el-input v-model="dataForm.type"/>
        </el-form-item>
        <el-form-item label="标题" prop="title">
          <el-input v-model="dataForm.title"/>
        </el-form-item>
        <el-form-item label="内容" prop="content">
          <el-input v-model="dataForm.content"/>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    name: 'msg',
    data () {
      return {
        visible: false,
        id: 0,
        dataForm: {}
      }
    },
    mounted () {
      const that = this
      this.$nextTick(() => {
        this.$store.state.websocket.webSocket.onmessage = async function (event) {
          if (!event || !event.data) {
            return
          }
          that.dataForm = JSON.parse(event.data)
          // if (!that.visible) {
          //   that.visible = true
          // }
        }
      })
    },
    methods: {
      // todo
    }
  }
</script>

<style scoped>

</style>
