消息通知

main
HUOJIN\92525 2024-09-14 10:59:22 +08:00
parent 6751c58e3b
commit 7a21d75343
2 changed files with 77 additions and 27 deletions

View File

@ -72,4 +72,12 @@ export function containerOut(data) {
}) })
} }
export default { add, edit, del,containerIn,containerOut,updateStockStatus,updateStock} export function stockMsg(data) {
return request({
url: 'api/stock/stockMsg',
method: 'post',
data
})
}
export default { add, edit, del,containerIn,containerOut,updateStockStatus,stockMsg}

View File

@ -1,5 +1,4 @@
<template> <template>
</template> </template>
<script> <script>
@ -7,6 +6,7 @@
import PanelGroup from './dashboard/PanelGroup' import PanelGroup from './dashboard/PanelGroup'
import LineChart from './dashboard/LineChart' import LineChart from './dashboard/LineChart'
import crudOperation from "@crud/CRUD.operation.vue"; import crudOperation from "@crud/CRUD.operation.vue";
import stockUrl from "@/api/stock";
const lineChartData = { const lineChartData = {
newVisitis: { newVisitis: {
@ -39,10 +39,50 @@ export default {
lineChartData: lineChartData.newVisitis lineChartData: lineChartData.newVisitis
} }
}, },
mounted() {
this.initWebSocket();
},
methods: { methods: {
handleSetLineChartData(type) { handleSetLineChartData(type) {
this.lineChartData = lineChartData[type] this.lineChartData = lineChartData[type]
},
initWebSocket() {
stockUrl.stockMsg()
const wsUri = (process.env.VUE_APP_WS_API === '/' ? '/' : (process.env.VUE_APP_WS_API + '/')) + 'webSocket/stock'
this.websock = new WebSocket(wsUri)
this.websock.onerror = this.webSocketOnError
this.websock.onmessage = this.webSocketOnMessage
},
webSocketOnError(e) {
this.$notify({
title: 'WebSocket连接发生错误',
type: 'error',
duration: 0
})
}, webSocketOnMessage(e) {
const data = JSON.parse(e.data)
console.log(data)
if (data.msgType === 'INFO') {
this.$notify({
title: '点击关注公众号',
message: data.msg,
type: 'success',
duration: 0
});
} else if (data.msgType === 'ERROR') {
this.$notify({
title: '',
message: data.msg,
dangerouslyUseHTMLString: true,
type: 'error',
duration: 0
})
} }
},
webSocketSend(agentData) {
this.websock.send(agentData)
},
} }
} }
</script> </script>
@ -52,6 +92,7 @@ export default {
padding: 2px; padding: 2px;
background-color: rgb(240, 242, 245); background-color: rgb(240, 242, 245);
position: relative; position: relative;
.chart-wrapper { .chart-wrapper {
background: #fff; background: #fff;
padding: 16px 16px; padding: 16px 16px;
@ -59,6 +100,7 @@ export default {
margin-right: 10px; margin-right: 10px;
margin-left: 10px; margin-left: 10px;
} }
.chart-wrapper2 { .chart-wrapper2 {
background: #fff; background: #fff;
padding: 16px 16px; padding: 16px 16px;