update 添加websocket功能推送员工报警信息
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
export function useDialog({ title }) {
|
||||
const visible = ref(false);
|
||||
|
||||
function openDialog() {
|
||||
visible.value = true;
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
return {
|
||||
visible,
|
||||
title,
|
||||
openDialog,
|
||||
closeDialog,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<Dialog :openVis="visible" width="30%" :title="title" @close="closeDialog" :maskClosable="false">
|
||||
<template #container>
|
||||
<div class="police-con">
|
||||
<div class="con-item">
|
||||
<span>姓名:</span>
|
||||
<span>{{ userInfo?.realName }}</span>
|
||||
</div>
|
||||
<div class="con-item">
|
||||
<span>二级单位:</span>
|
||||
<span>{{ userInfo?.orgName }}</span>
|
||||
</div>
|
||||
<div class="con-item">
|
||||
<span>手机号码:</span>
|
||||
<span>{{ userInfo?.phone }}</span>
|
||||
</div>
|
||||
<div class="con-item">
|
||||
<span>异常事件:</span>
|
||||
<span>{{ userInfo?.eventType_dictText }}</span>
|
||||
</div>
|
||||
<div class="con-item">
|
||||
<span>发生时间:</span>
|
||||
<span>{{ userInfo?.warnTime }}</span>
|
||||
</div>
|
||||
<div class="con-item">
|
||||
<span>发生地点:</span>
|
||||
<span>{{ userInfo?.address }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import Dialog from '/@/components/dialog/Dialog.vue';
|
||||
import { useDialog } from '/@/views/components/dialogHooks.ts';
|
||||
import { watch, ref } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
record: Object,
|
||||
});
|
||||
const userInfo = ref({});
|
||||
watch(
|
||||
() => props.record,
|
||||
(nVal) => {
|
||||
userInfo.value = nVal;
|
||||
}
|
||||
);
|
||||
const { visible, title, closeDialog, openDialog } = useDialog({ title: '健康报警员工信息' });
|
||||
|
||||
defineExpose({
|
||||
openDialog,
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
.police-con {
|
||||
color: #ffffff;
|
||||
background-color: #00152b;
|
||||
border: 1px solid #129bff;
|
||||
padding: 2% 0 2% 5%;
|
||||
|
||||
.con-item {
|
||||
padding: 1.3% 0;
|
||||
|
||||
span:nth-child(1) {
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
width: 20%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
span:nth-child(2) {
|
||||
padding-left: 2%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { get } from '/@/api/request';
|
||||
|
||||
export enum Api {
|
||||
deleteWatchNo = 'health-watch/watch/watchMonitorData/delete',
|
||||
}
|
||||
|
||||
//获取全部部门
|
||||
export const deleteWatchNo = (params: any) => get(Api.deleteWatchNo, params);
|
||||
+24
-20
@@ -23,10 +23,11 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="bottom-d"></div>
|
||||
<EmployeeDialog ref="employeeDialogRef" :record="socketData" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { onUnmounted, ref, watch, nextTick } from 'vue';
|
||||
import OneL from '../components/body-d-left/oneL.vue';
|
||||
import TwoL from '../components/body-d-left/twoL.vue';
|
||||
import ThreeL from '../components/body-d-left/threeL.vue';
|
||||
@@ -34,39 +35,42 @@
|
||||
import TwoR from '../components/body-d-right/twoR.vue';
|
||||
import ThreeR from '../components/body-d-right/threeR.vue';
|
||||
import ChinaMap from '../components/chinaMap/chinaMap.vue';
|
||||
import * as dayjs from 'dayjs';
|
||||
import EmployeeDialog from '/@/views/components/employeeDialog.vue';
|
||||
import { useTopTime } from '/@/utils/utils.ts';
|
||||
import { useSocket } from '/@/utils/socket.ts';
|
||||
|
||||
const dayTimeO = ref();
|
||||
const dayTimeT = ref();
|
||||
const interval = ref(1);
|
||||
|
||||
function init() {
|
||||
getTime();
|
||||
setInterval(() => {
|
||||
interval.value = setInterval(() => {
|
||||
getTime();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function getTime() {
|
||||
dayTimeO.value = dayjs().format('YYYY年MM月DD日 HH时mm分ss秒');
|
||||
dayTimeT.value =
|
||||
dayjs().diff(dayjs('2018-10-01'), 'day') +
|
||||
'天' +
|
||||
getZero(dayjs().diff(dayjs(dayjs().format('YYYY-MM-DD') + ' 00:00:00'), 'hours')) +
|
||||
'时' +
|
||||
getZero(dayjs().diff(dayjs(dayjs().format('YYYY-MM-DD HH') + ':00:00'), 'minutes')) +
|
||||
'分' +
|
||||
getZero(dayjs().diff(dayjs(dayjs().format('YYYY-MM-DD HH:mm') + ':00'), 'seconds')) +
|
||||
'秒';
|
||||
}
|
||||
|
||||
function getZero(num: any) {
|
||||
if (num < 10) {
|
||||
return '0' + num;
|
||||
}
|
||||
return num;
|
||||
const { timeLeft, timeRight } = useTopTime();
|
||||
dayTimeO.value = timeLeft;
|
||||
dayTimeT.value = timeRight;
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
clearInterval(interval.value);
|
||||
});
|
||||
init();
|
||||
const { socketData, setSocketData } = useSocket();
|
||||
const employeeDialogRef = ref();
|
||||
watch(socketData, (nVal) => {
|
||||
console.log('nval', nVal);
|
||||
if (nVal) {
|
||||
nextTick(() => {
|
||||
setSocketData(nVal);
|
||||
employeeDialogRef.value.openDialog();
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.outer {
|
||||
|
||||
Reference in New Issue
Block a user