|
@@ -1,22 +1,5 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<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>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -32,20 +15,43 @@
|
|
},
|
|
},
|
|
mounted () {
|
|
mounted () {
|
|
const that = this
|
|
const that = this
|
|
|
|
+ const h = this.$createElement
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.$store.state.websocket.webSocket.onmessage = async function (event) {
|
|
this.$store.state.websocket.webSocket.onmessage = async function (event) {
|
|
if (!event || !event.data) {
|
|
if (!event || !event.data) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- that.dataForm = JSON.parse(event.data)
|
|
|
|
- // if (!that.visible) {
|
|
|
|
- // that.visible = true
|
|
|
|
- // }
|
|
|
|
|
|
+ let json = JSON.parse(event.data)
|
|
|
|
+ console.log('json = ' + JSON.stringify(json))
|
|
|
|
+ if (json) {
|
|
|
|
+ that.$emit('noticeAdded', json.length)
|
|
|
|
+ json.forEach((item) => {
|
|
|
|
+ that.$notify({
|
|
|
|
+ title: item.title,
|
|
|
|
+ // dangerouslyUseHTMLString: true,
|
|
|
|
+ // message: h('i', {style: 'color: teal'}, item.content),
|
|
|
|
+ message: h('div', {}, [
|
|
|
|
+ h('p', {}, '消息类别:' + that.getMsgType(item.type)),
|
|
|
|
+ h('p', {}, '消息内容:' + item.content)
|
|
|
|
+ ]),
|
|
|
|
+ duration: 0
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- // todo
|
|
|
|
|
|
+ getMsgType (type) {
|
|
|
|
+ if (!type) return '未知消息类型'
|
|
|
|
+ if (type === 1) {
|
|
|
|
+ return '公告消息'
|
|
|
|
+ } else if (type === 2) {
|
|
|
|
+ return '审批消息'
|
|
|
|
+ } else {
|
|
|
|
+ return '未知消息类型'
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|