|
@@ -1,22 +1,5 @@
|
|
|
<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>
|
|
|
|
|
@@ -31,24 +14,44 @@
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
- // const that = this
|
|
|
+ const that = this
|
|
|
+ const h = this.$createElement
|
|
|
this.$nextTick(() => {
|
|
|
this.$store.state.websocket.webSocket.onmessage = async function (event) {
|
|
|
if (!event || !event.data) {
|
|
|
return
|
|
|
}
|
|
|
- let json = JSON.stringify(event.data)
|
|
|
- console.log('json = ' + json)
|
|
|
- this.$notify({
|
|
|
- title: event.data.title,
|
|
|
- message: event.data.content,
|
|
|
- duration: 0
|
|
|
- })
|
|
|
+ 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: {
|
|
|
- // todo
|
|
|
+ getMsgType (type) {
|
|
|
+ if (!type) return '未知消息类型'
|
|
|
+ if (type === 1) {
|
|
|
+ return '公告消息'
|
|
|
+ } else if (type === 2) {
|
|
|
+ return '审批消息'
|
|
|
+ } else {
|
|
|
+ return '未知消息类型'
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|