| | |
| | | import createWs from "@/assets/js/tools/websocket/createWs"; |
| | | import {onMounted, reactive} from "vue"; |
| | | import {onMounted, ref} from "vue"; |
| | | import door from "@/assets/js/const/door"; |
| | | import getLabelByKey from "@/assets/js/tools/getLabelByKey"; |
| | | import {changeDoorState} from "@/views/accessControl/js/api"; |
| | | import {changeDoorState, searchDoorInfoApi} from "@/views/accessControl/js/api"; |
| | | import {ElLoading, ElMessage} from "element-plus"; |
| | | const lockStatusList = door.lockStatus; |
| | | const doorInfoModule = ()=>{ |
| | | const { |
| | | SOCKET |
| | | } = createWs("carCameraSocket"); |
| | | } = createWs("carCameraRtSocket"); |
| | | |
| | | const doorInfos = reactive([ |
| | | const doorInfos = ref([ |
| | | { |
| | | carcameraId: 8001, |
| | | carcameraName: "智能实验室", |
| | | ip: "192.168.0.18", |
| | | passWord: "a1234567.", |
| | | num: 1, |
| | | password: "a1234567.", |
| | | port: 8000, |
| | | userName: "admin", |
| | | status: 0, |
| | | name: "智能实验室", |
| | | statusText: "未知" |
| | | }, |
| | | { |
| | | ip: "192.168.0.19", |
| | | passWord: "a1234567.", |
| | | port: 8000, |
| | | userName: "admin", |
| | | status: 0, |
| | | name: "PCR实验室", |
| | | statusText: "未知" |
| | | }, |
| | | { |
| | | ip: "192.168.0.44", |
| | | passWord: "a1234567.", |
| | | port: 8000, |
| | | userName: "admin", |
| | | status: 0, |
| | | name: "西藏安琪", |
| | | statusText: "未知" |
| | | }, |
| | | statusText: "正常关", |
| | | userName: "admin" |
| | | } |
| | | ]); |
| | | |
| | | |
| | | const searchDoorInfo = async ()=>{ |
| | | try{ |
| | | const res = await searchDoorInfoApi(); |
| | | const rs = res.data; |
| | | if(rs.code === 1 && rs.data) { |
| | | doorInfos.value = rs.data2.map(item=>{ |
| | | item.status = -1; |
| | | item.statusText = "未知"; |
| | | return item; |
| | | }); |
| | | } |
| | | }catch (e) { |
| | | console.log(e); |
| | | } |
| | | } |
| | | const handleOpen = ()=>{ |
| | | SOCKET.value.send(JSON.stringify(doorInfos)); |
| | | SOCKET.value.send(JSON.stringify(doorInfos.value)); |
| | | } |
| | | |
| | | const handleMessage = (res)=>{ |
| | | let rs = JSON.parse(res.data); |
| | | let data = rs.data; |
| | | doorInfos.map(item=>{ |
| | | let doorInfo = data[item.ip]; |
| | | item.status = doorInfo.data2.lockStatus; |
| | | item.statusText = getLabelByKey(doorInfo.data2.lockStatus, lockStatusList, "未知"); |
| | | if(rs.code ===1 && rs.data) { |
| | | let data = rs.data2; |
| | | doorInfos.value.map(item=>{ |
| | | for(let i=0; i<data.length; i++) { |
| | | if(item.carcameraId === data[i].carcameraId) { |
| | | const lockStatus = data[i].lockStatus; |
| | | item.status = lockStatus; |
| | | item.statusText = getLabelByKey(lockStatus, lockStatusList, "未知"); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | /** |
| | | * 开启门禁 |
| | |
| | | } |
| | | |
| | | onMounted(()=>{ |
| | | searchDoorInfo(); |
| | | |
| | | SOCKET.value.addEventListener("open", handleOpen, false); |
| | | SOCKET.value.addEventListener("message", handleMessage, false); |
| | | }); |