From ab8f3297f7c8243d486c9da0900e4f813b2ea2df Mon Sep 17 00:00:00 2001 From: suerprisePlus <15810472099@163.com> Date: 星期三, 27 十一月 2024 17:16:46 +0800 Subject: [PATCH] 功能更新 --- src/components/RuoYi/Msgger/index.vue | 125 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 118 insertions(+), 7 deletions(-) diff --git a/src/components/RuoYi/Msgger/index.vue b/src/components/RuoYi/Msgger/index.vue index 3fd0286..614994f 100644 --- a/src/components/RuoYi/Msgger/index.vue +++ b/src/components/RuoYi/Msgger/index.vue @@ -1,32 +1,143 @@ <template> - <div class="msgBox" @click="setShowMenuClick"> + <div class="msgBox" @click.stop="setShowMenuClick(true)"> <i style="font-size: 20px;" class="el-icon-chat-line-round"></i> - <el-badge v-show="msgCount > 0" :value="msgCount" class="item"> + <el-badge v-show="$store.state.mapLayers.msgList.length > 0" :value="$store.state.mapLayers.msgList.length" + class="item"> </el-badge> + <el-dialog title="鏁呴殰淇℃伅" :visible.sync="dialogVisible" width="30%" :show-close="false"> + <el-table :data="$store.state.mapLayers.msgList" style="width: 100%"> + <el-table-column prop="msg" label="璁惧鍚嶇О"> + </el-table-column> + <el-table-column prop="point" label="璁惧浣嶇疆"> + </el-table-column> + <el-table-column label="鎿嶄綔" width="100"> + <template slot-scope="scope"> + <el-button @click="handleClick(scope.row)" type="text" size="small">鏌ョ湅</el-button> + <el-button @click="handleClick2(scope.row)" type="text" size="small">鍒嗗彂</el-button> + </template> + </el-table-column> + </el-table> + <span slot="footer" class="dialog-footer"> + <el-button @click.stop="dialogVisible = false">鍏� 闂�</el-button> + </span> + <el-dialog width="30%" title="浣嶇疆" :visible.sync="innerVisible" append-to-body> + <div style="height: 540px"> + <olMap v-if="innerVisible" :parentData="parentData"></olMap> + </div> + </el-dialog> + </el-dialog> </div> </template> <script> + +import olMap from '@/components/mapOl/index.vue'; + export default { name: 'RouYiMsg', + components: { + olMap + }, data() { return { - msgCount: 0, - dialogVisible: false + msgCount: 1, + dialogVisible: false, + dialogFlag: false, + wsSocket: null, + innerVisible: false, + msgData: [], + parentData: null, } }, methods: { - setShowMenuClick() { + handleClick2(row) { + this.$message({ + showClose: true, + message: '宸插垎鍙戝埌鐩稿叧璐熻矗浜�', + type: 'success' + }); + }, + handleClick(row) { + const obj = { + val: row, + type: 'point', + isShow: false, + } + + this.parentData = JSON.stringify([obj]) + this.innerVisible = true + }, + setShowMenuClick(res) { + this.dialogVisible = true + + }, handleClose() { this.dialogVisible = false - } + }, + createSocket() { + this.wsSocket = new WebSocket(config.pySocket); + this.wsSocket.onopen = (event) => { + console.log('WebSocket杩炴帴鎴愬姛'); + }; + this.wsSocket.onclose = () => { + console.log('WebSocket杩炴帴鍏抽棴'); + this.wsSocket = null + }; + this.wsSocket.onmessage = (event) => { + + if (event.data != "杩炴帴鎴愬姛") { + const obj = JSON.parse(event.data); + if (obj.type == "error") { + if (this.$store.state.mapLayers.msgList.length == 0) { + this.$store.state.mapLayers.msgList.push(obj) + } else { + + var rs = this.$store.state.mapLayers.msgList; + var st = rs.filter(item => { + if (item.msg == obj.msg && item.point == obj.point && item.line == obj.line) { + return item + } + }) + if (st.length <= 0) { + this.$store.state.mapLayers.msgList.push(obj) + } + + + + + } + } + } + // 澶勭悊鎺ユ敹鍒扮殑娑堟伅 + }; + }, + setShowMsg(res) { + const filter = this.msgData.filter(item => { + if (item.msg == res.msg && item.point == res.point) { + return item; + } + }) + if (filter.length > 0) return; + this.msgData.push(res) + this.msgCount = this.msgData.length; + + }, }, mounted() { - console.log(123); + if (!this.wsSocket) { + this.createSocket(); + } + + }, + beforeDestroy() { + if (this.wsSocket) { + this.wsSocket.close(); + + } }, } -- Gitblit v1.9.3