| ... | ... | @@ -26,15 +26,15 @@ | 
|  |  | </el-button> | 
|  |  | </el-col> | 
|  |  | </el-row> | 
|  |  | <el-input v-model="message" style="width: 460px;margin-top: 20px" | 
|  |  | <el-input v-model="message" style="width: 460px;margin-top: 20px" type="textarea" | 
|  |  | placeholder="获取数据进度" readonly> | 
|  |  | </el-input> | 
|  |  | </div> | 
|  |  | <div> | 
|  |  | 状态 :{{this.socketApi.socketStatus}} | 
|  |  | 状态 : | 
|  |  | </div> | 
|  |  | <div> | 
|  |  | 消息 :{{this.socketApi.socketMessage}} | 
|  |  | 消息 :{{socketResponse.message}} | 
|  |  | </div> | 
|  |  | <!-- 列表显示区域 --> | 
|  |  | <!-- | 
| ... | ... | @@ -95,6 +95,8 @@ | 
|  |  | import FilenameOption from '../excel/components/FilenameOption' | 
|  |  | import AutoWidthOption from '../excel/components/AutoWidthOption' | 
|  |  | import BookTypeOption from '../excel/components/BookTypeOption' | 
|  |  | import VueWebsocket from '@/utils/websocket' | 
|  |  | import {msgJson, socketDataList, socketMessage, socketStatus} from "@/api/socket"; | 
|  |  |  | 
|  |  | export default { | 
|  |  | name: "ExitAnalysis", | 
| ... | ... | @@ -105,7 +107,13 @@ | 
|  |  | * 出港业务统计列表 | 
|  |  | */ | 
|  |  | exitInfoList: [], | 
|  |  |  | 
|  |  | resultStatus: '0', | 
|  |  | message: '', | 
|  |  | socketResponse: { | 
|  |  | message: '', | 
|  |  | data: '', | 
|  |  | status: '' | 
|  |  | }, | 
|  |  | /** | 
|  |  | * 查询列表 | 
|  |  | */ | 
| ... | ... | @@ -121,15 +129,6 @@ | 
|  |  | downloadLoading: false, | 
|  |  | } | 
|  |  | }, | 
|  |  | sockets: { | 
|  |  | connect() { | 
|  |  | this.$socket.emit("sendMessageToServer", "0025520"); //监听connect事件 | 
|  |  | }, | 
|  |  | servermessage(data) { | 
|  |  | // 监听message事件,方法是后台定义和提供的 | 
|  |  | console.log(data); | 
|  |  | } | 
|  |  | }, | 
|  |  | methods: { | 
|  |  | /** | 
|  |  | * 获取出港信息列表 | 
| ... | ... | @@ -160,8 +159,31 @@ | 
|  |  | this.$message.error(error.toString()); | 
|  |  | }); | 
|  |  | }, | 
|  |  | socket_onmessage: function (e) { | 
|  |  | // eslint-disable-next-line no-console | 
|  |  | console.log("从websocket接收到新的消息-->>"+e.data); | 
|  |  | this.message = this.message+e.data+"\n"; | 
|  |  | let msgJson = JSON.parse(e.data); | 
|  |  | this.socketResponse = JSON.parse(e.data); | 
|  |  | let socketMessage = msgJson.message; | 
|  |  | // eslint-disable-next-line no-console | 
|  |  | console.log(socketMessage) | 
|  |  | let socketStatus = msgJson.status; | 
|  |  | let socketDataList = msgJson.data; | 
|  |  | // eslint-disable-next-line no-console | 
|  |  | console.log(msgJson); | 
|  |  | }, | 
|  |  | socket_onopen: function (e) { | 
|  |  | // eslint-disable-next-line no-console | 
|  |  | console.log("websocket->>链接已链接"); | 
|  |  | } | 
|  |  | }, | 
|  |  | created() { | 
|  |  | VueWebsocket.onopen = this.socket_onopen; | 
|  |  | VueWebsocket.onmessage = this.socket_onmessage; | 
|  |  | VueWebsocket.init(); | 
|  |  |  | 
|  |  |  | 
|  |  | }, | 
|  |  | destroyed() { | 
|  |  | }, | 
... | ... |  |