70-71 修补

This commit is contained in:
Rain 2024-10-26 17:09:33 +08:00
parent b3597a9440
commit 534773ff8a
4 changed files with 160 additions and 133 deletions

View File

@ -3,12 +3,20 @@
<!-- <div @click="send" style="line-height: 60px;">发送消息</div> --> <!-- <div @click="send" style="line-height: 60px;">发送消息</div> -->
<el-popover v-if="showQrCode" placement="bottom" class="header-btn" width="200" trigger="click"> <el-popover v-if="showQrCode" placement="bottom" class="header-btn" width="200" trigger="click">
<div id="qrCode" ref="qrCodeDiv"></div> <div id="qrCode" ref="qrCodeDiv"></div>
<el-button class="btn" slot="reference">车辆录入二维码<i class="el-icon-arrow-down"></i></el-button> <el-button class="btn" slot="reference">
车辆录入二维码
<i class="el-icon-arrow-down"></i>
</el-button>
</el-popover> </el-popover>
<p class="header-btn" @click="goMsgCenter" @mouseover="showDialog = true" @mouseleave="showDialog = false"> <p
class="header-btn"
@click="goMsgCenter"
@mouseover="showDialog = true"
@mouseleave="showDialog = false"
>
<i class="el-icon-message-solid"></i> 消息 <i class="el-icon-message-solid"></i> 消息
</p> </p>
<i class="redDot" v-show="messageList.length"></i> <i class="redDot" v-show="newsStatus"></i>
<div <div
class="messageList whiteBlock" class="messageList whiteBlock"
v-show="showDialog && messageList.length > 0" v-show="showDialog && messageList.length > 0"
@ -21,7 +29,13 @@
</ul> </ul>
</div> </div>
<!-- <span @click="sendmes">发送消息</span> --> <!-- <span @click="sendmes">发送消息</span> -->
<el-dialog :title="dialogTitle" :modal-append-to-body="false" :visible.sync="messsageCenterDialog" width="80%" class="dialog-wrap"> <el-dialog
:title="dialogTitle"
:modal-append-to-body="false"
:visible.sync="messsageCenterDialog"
width="80%"
class="dialog-wrap"
>
<div style="height: 738px"> <div style="height: 738px">
<messageCenter></messageCenter> <messageCenter></messageCenter>
</div> </div>
@ -30,25 +44,25 @@
</template> </template>
<script> <script>
import { getNoticeListApi } from '@/assets/js/api/company/project' import { getNoticeListApi } from "@/assets/js/api/company/project";
import messageCenter from './../views/messageV2.vue' import messageCenter from "./../views/messageV2.vue";
import mqtt from 'mqtt' import mqtt from "mqtt";
import mqttX from 'xhl-mqttx' import mqttX from "xhl-mqttx";
import QRCode from 'qrcodejs2' import QRCode from "qrcodejs2";
import axios from 'axios' import axios from "axios";
const options = { const options = {
connectTimeout: 40000, connectTimeout: 40000,
clientId: clientId:
'mqttjs_' + "mqttjs_" +
Math.random() Math.random()
.toString(16) .toString(16)
.substr(2, 8), .substr(2, 8),
username: 'root', username: "root",
password: '123456', password: "123456",
clean: true clean: true
} };
var client = null var client = null;
let i = 0 let i = 0;
// var client = mqtt.connect("mqtt://139.159.226.224:1883", options); // var client = mqtt.connect("mqtt://139.159.226.224:1883", options);
export default { export default {
components: { components: {
@ -57,149 +71,154 @@ export default {
data() { data() {
return { return {
showQrCode: false, showQrCode: false,
showUrl: '', showUrl: "",
messsageCenterDialog: false, messsageCenterDialog: false,
dialogTitle: '消息中心', dialogTitle: "消息中心",
messageList: [], messageList: [],
showDialog: false, showDialog: false,
userId: '', userId: "",
topicName: 'topic', topicName: "topic",
toDayDate: '', toDayDate: "",
soundList: [], soundList: [],
typeList: [ typeList: [
{ {
label: '高空火警', label: "高空火警",
value: '8' value: "8"
}, },
{ {
label: '考勤提醒', label: "考勤提醒",
value: '1' value: "1"
}, },
{ {
label: '防疫人员通知', label: "防疫人员通知",
value: '2' value: "2"
}, },
{ {
label: '防疫车辆通知', label: "防疫车辆通知",
value: '3' value: "3"
}, },
{ {
label: '访客通知', label: "访客通知",
value: '16' value: "16"
}, },
{ {
label: '混凝土监测', label: "混凝土监测",
value: '4' value: "4"
}, },
{ {
label: '卸料平台', label: "卸料平台",
value: '5' value: "5"
}, },
{ {
label: '配电箱', label: "配电箱",
value: '6' value: "6"
}, },
{ {
label: '扬尘', label: "扬尘",
value: '7' value: "7"
}, },
{ {
label: '标养室', label: "标养室",
value: '9' value: "9"
}, },
{ {
label: '安全检查', label: "安全检查",
value: '10' value: "10"
}, },
{ {
label: '质量检查', label: "质量检查",
value: '11' value: "11"
}, },
{ {
label: '塔吊', label: "塔吊",
value: '12' value: "12"
}, },
{ {
label: '升降机', label: "升降机",
value: '13' value: "13"
}, },
{ {
label: '电表', label: "电表",
value: '14' value: "14"
}, },
{ {
label: '水表', label: "水表",
value: '15' value: "15"
} }
] ],
} //
newsStatus: false
};
}, },
beforeDestroy() { beforeDestroy() {
// console.log(client) // console.log(client)
if (client) { if (client) {
client.unsubscribe(this.topicName + this.userId, options) client.unsubscribe(this.topicName + this.userId, options);
client.end() client.end();
} }
client = null client = null;
console.log(client) console.log(client);
// client = null // client = null
// mqttX.unsubscribe(this.topicName + this.userId); // mqttX.unsubscribe(this.topicName + this.userId);
}, },
mounted() { mounted() {
this.selectNowDate() this.selectNowDate();
if (localStorage.getItem('soundList')) { if (localStorage.getItem("soundList")) {
this.soundList = JSON.parse(localStorage.getItem('soundList')) this.soundList = JSON.parse(localStorage.getItem("soundList"));
} }
if (process.env.NODE_ENV == 'development') { if (process.env.NODE_ENV == "development") {
this.userId = this.$store.state.userInfo.userId this.userId = this.$store.state.userInfo.userId;
this.topicName = this.$store.state.userInfo.scope this.topicName = this.$store.state.userInfo.scope;
// // client = mqtt.connect("ws://182.90.224.147:8083/mqtt", options); // // client = mqtt.connect("ws://182.90.224.147:8083/mqtt", options);
client = mqtt.connect(mqttUrl, options) client = mqtt.connect(mqttUrl, options);
this.getData() this.getData();
this.mqttMSG() this.mqttMSG();
} else if (process.env.NODE_ENV == 'debug') { } else if (process.env.NODE_ENV == "debug") {
} else if (process.env.NODE_ENV == 'production') { } else if (process.env.NODE_ENV == "production") {
this.userId = this.$store.state.userInfo.userId this.userId = this.$store.state.userInfo.userId;
this.topicName = this.$store.state.userInfo.scope this.topicName = this.$store.state.userInfo.scope;
// client = mqtt.connect("ws://182.90.224.147:8083/mqtt", options); // client = mqtt.connect("ws://182.90.224.147:8083/mqtt", options);
client = mqtt.connect(mqttUrl, options) client = mqtt.connect(mqttUrl, options);
this.getData() this.getData();
this.mqttMSG() this.mqttMSG();
} }
}, },
watch: { watch: {
$route: { $route: {
handler(newVal) { handler(newVal) {
if(newVal.path == '/project/quality/makeAnAppointment'){ if (newVal.path == "/project/quality/makeAnAppointment") {
this.showQrCode = true; this.showQrCode = true;
this.bindQRCode(); this.bindQRCode();
}else{ } else {
this.showQrCode = false this.showQrCode = false;
} }
}, }
}, }
}, },
methods: { methods: {
// //
bindQRCode: function() { bindQRCode: function() {
document.getElementById('qrCode').innerHTML = '' document.getElementById("qrCode").innerHTML = "";
let httpUrl = window.location.origin let httpUrl = window.location.origin;
let projectSn = this.$store.state.projectSn let projectSn = this.$store.state.projectSn;
let baseUrl = axios.defaults.baseURL let baseUrl = axios.defaults.baseURL;
let newBaseUrl = baseUrl.slice(0, baseUrl.length - 1) let newBaseUrl = baseUrl.slice(0, baseUrl.length - 1);
setTimeout(() => { setTimeout(() => {
var qrcode = new QRCode(this.$refs.qrCodeDiv, { var qrcode = new QRCode(this.$refs.qrCodeDiv, {
text: httpUrl + '/doc/h52/index.html?projectSn=' + projectSn + '&baseUrl=' + newBaseUrl, text:
httpUrl +
"/doc/h52/index.html?projectSn=" +
projectSn +
"&baseUrl=" +
newBaseUrl,
// text:"", // text:"",
width: 200, width: 200,
height: 200, height: 200,
colorDark: '#333333', // colorDark: "#333333", //
colorLight: '#ffffff', // colorLight: "#ffffff", //
correctLevel: QRCode.CorrectLevel.L //L/M/H correctLevel: QRCode.CorrectLevel.L //L/M/H
}) });
}, 0);
}, 0)
}, },
// sendmes(){ // sendmes(){
// console.log(1) // console.log(1)
@ -213,16 +232,16 @@ export default {
day = date.getDate(), day = date.getDate(),
hours = date.getHours(), //(0-23) hours = date.getHours(), //(0-23)
minutes = date.getMinutes(), //(0-59) minutes = date.getMinutes(), //(0-59)
seconds = date.getSeconds() seconds = date.getSeconds();
month >= 1 && month <= 9 ? (month = '0' + month) : '' month >= 1 && month <= 9 ? (month = "0" + month) : "";
day >= 0 && day <= 9 ? (day = '0' + day) : '' day >= 0 && day <= 9 ? (day = "0" + day) : "";
hours >= 0 && hours <= 9 ? (hours = '0' + hours) : '' hours >= 0 && hours <= 9 ? (hours = "0" + hours) : "";
minutes >= 0 && minutes <= 9 ? (minutes = '0' + minutes) : '' minutes >= 0 && minutes <= 9 ? (minutes = "0" + minutes) : "";
seconds >= 0 && seconds <= 9 ? (seconds = '0' + seconds) : '' seconds >= 0 && seconds <= 9 ? (seconds = "0" + seconds) : "";
// var timer = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes+ ':' + seconds; // var timer = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes+ ':' + seconds;
var timer = year + '-' + month + '-' + day var timer = year + "-" + month + "-" + day;
this.toDayDate = timer this.toDayDate = timer;
console.log(timer) console.log(timer);
// return timer; // return timer;
}, },
// send(){ // send(){
@ -235,8 +254,8 @@ export default {
// }); // });
// window.open(routeUrl.href, "_blank"); // window.open(routeUrl.href, "_blank");
this.messsageCenterDialog = true this.messsageCenterDialog = true;
this.getData() this.getData();
}, },
mqttMSG() { mqttMSG() {
// //
@ -252,7 +271,7 @@ export default {
// .substr(2, 8), // .substr(2, 8),
// password: "123456", // password: "123456",
// clean: true // clean: true
console.log('mqtt') console.log("mqtt");
// let _this = this // let _this = this
// mqttX.init({ // mqttX.init({
// id:"mqttjs_" + // id:"mqttjs_" +
@ -292,43 +311,43 @@ export default {
// }); // });
// mqtt +"/#" +workerId // mqtt +"/#" +workerId
client.on('connect', e => { client.on("connect", e => {
// console.log(':', this.topicName + this.userId) // console.log(':', this.topicName + this.userId)
client.subscribe(this.topicName + this.userId, { qos: 0 }, error => { client.subscribe(this.topicName + this.userId, { qos: 0 }, error => {
if (!error) { if (!error) {
// console.log('') // console.log('')
} else { } else {
console.log('订阅失败') console.log("订阅失败");
} }
}) });
}) });
// //
client.on('message', (topic, message) => { client.on("message", (topic, message) => {
// console.log(message); // console.log(message);
console.log('收到来自', topic, '的消息', message.toString()) console.log("收到来自", topic, "的消息", message.toString());
message = JSON.parse(message) message = JSON.parse(message);
// if(message.content){ // if(message.content){
// if(message.content.indexOf("") > -1 || message.content.indexOf("") > -1){ // if(message.content.indexOf("") > -1 || message.content.indexOf("") > -1){
// this.$emit('sendMsg') // this.$emit('sendMsg')
// } // }
// } // }
setTimeout(() => { setTimeout(() => {
this.$emit('sendMsg', message) this.$emit("sendMsg", message);
this.$notify({ this.$notify({
title: message.title, title: message.title,
message: message.content, message: message.content,
position: 'bottom-right' position: "bottom-right"
}) });
}, 500) }, 500);
}) });
// //
// client.on("reconnect", (error) => { // client.on("reconnect", (error) => {
// console.log(":", error); // console.log(":", error);
// }); // });
// //
client.on('error', error => { client.on("error", error => {
console.log('连接失败:', error) console.log("连接失败:", error);
}) });
}, },
getData() { getData() {
getNoticeListApi({ getNoticeListApi({
@ -338,11 +357,19 @@ export default {
pageNo: 1, pageNo: 1,
pageSize: 10 pageSize: 10
}).then(res => { }).then(res => {
this.messageList = res.result.records // console.log("res.result.records", res.result.records);
}) this.messageList = res.result.records;
//
if (res.result.records.length > 0) {
this.newsStatus = res.result.records.some(item => item.isRead !== 1);
// console.log("==========================this.newsStatus=======================", this.newsStatus);
}
});
} }
} }
} };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>

View File

@ -221,7 +221,7 @@ export default {
const res = await getQualityNoticeStatusApi({ id: payLoadParams.data.id }); const res = await getQualityNoticeStatusApi({ id: payLoadParams.data.id });
if (!res.result || res.result.status == 6) { if (!res.result || res.result.status == 6) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "检查单已撤回", message: "检查单已撤回",
}); });
isBack = true; isBack = true;
@ -232,7 +232,7 @@ export default {
const res = await getNoticeStatusApi({ id: payLoadParams.data.id }); const res = await getNoticeStatusApi({ id: payLoadParams.data.id });
if (!res.result || res.result.status == 6) { if (!res.result || res.result.status == 6) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "检查单已撤回", message: "检查单已撤回",
}); });
isBack = true; isBack = true;
@ -257,7 +257,7 @@ export default {
let selectedIds = []; let selectedIds = [];
if (this.multipleSelection.length == 0) { if (this.multipleSelection.length == 0) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "请勾选表格项", message: "请勾选表格项",
}); });
return; return;
@ -302,7 +302,7 @@ export default {
let selectedIds = []; let selectedIds = [];
if (this.multipleSelection.length == 0) { if (this.multipleSelection.length == 0) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "请勾选表格项", message: "请勾选表格项",
}); });
return; return;

View File

@ -214,7 +214,7 @@ export default {
const res = await getQualityNoticeStatusApi({ id: payLoadParams.data.id }); const res = await getQualityNoticeStatusApi({ id: payLoadParams.data.id });
if (!res.result || res.result.status == 6) { if (!res.result || res.result.status == 6) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "检查单已撤回", message: "检查单已撤回",
}); });
isBack = true; isBack = true;
@ -225,7 +225,7 @@ export default {
const res = await getNoticeStatusApi({ id: payLoadParams.data.id }); const res = await getNoticeStatusApi({ id: payLoadParams.data.id });
if (!res.result || res.result.status == 6) { if (!res.result || res.result.status == 6) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "检查单已撤回", message: "检查单已撤回",
}); });
isBack = true; isBack = true;
@ -250,7 +250,7 @@ export default {
let selectedIds = []; let selectedIds = [];
if(this.multipleSelection.length == 0){ if(this.multipleSelection.length == 0){
this.$message({ this.$message({
type: "error", type: "warning",
message: "请勾选表格项", message: "请勾选表格项",
}); });
return; return;

View File

@ -216,7 +216,7 @@ export default {
const res = await getQualityNoticeStatusApi({ id: payLoadParams.data.id }); const res = await getQualityNoticeStatusApi({ id: payLoadParams.data.id });
if (!res.result || res.result.status == 6) { if (!res.result || res.result.status == 6) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "检查单已撤回", message: "检查单已撤回",
}); });
isBack = true; isBack = true;
@ -227,7 +227,7 @@ export default {
const res = await getNoticeStatusApi({ id: payLoadParams.data.id }); const res = await getNoticeStatusApi({ id: payLoadParams.data.id });
if (!res.result || res.result.status == 6) { if (!res.result || res.result.status == 6) {
this.$message({ this.$message({
type: "error", type: "warning",
message: "检查单已撤回", message: "检查单已撤回",
}); });
isBack = true; isBack = true;
@ -252,7 +252,7 @@ export default {
let selectedIds = []; let selectedIds = [];
if(this.multipleSelection.length == 0){ if(this.multipleSelection.length == 0){
this.$message({ this.$message({
type: "error", type: "warning",
message: "请勾选表格项", message: "请勾选表格项",
}); });
return; return;
@ -294,7 +294,7 @@ export default {
let selectedIds = []; let selectedIds = [];
if(this.multipleSelection.length == 0){ if(this.multipleSelection.length == 0){
this.$message({ this.$message({
type: "error", type: "warning",
message: "请勾选表格项", message: "请勾选表格项",
}); });
return; return;