2025年04月24日10:12:01

This commit is contained in:
luojiayi 2025-04-24 10:12:03 +08:00
parent b76ec6d7fc
commit c67954eec2
6 changed files with 72 additions and 40 deletions

View File

@ -20,9 +20,9 @@
<div class="alarmTable-item" v-for="(item, index) in warningList" :key="index"> <div class="alarmTable-item" v-for="(item, index) in warningList" :key="index">
<div class="alarmTable-item-text">{{ item.deviceId }}</div> <div class="alarmTable-item-text">{{ item.deviceId }}</div>
<div class="alarmTable-item-text">{{ warnTypeEnum[item.type] }}</div> <div class="alarmTable-item-text">{{ warnTypeEnum[item.type] }}</div>
<div class="alarmTable-item-text">{{ item.useName }}</div> <div class="alarmTable-item-text">{{ item.user }}</div>
<div class="alarmTable-item-text">{{ item.createTime }}</div> <div class="alarmTable-item-text">{{ item.createTime }}</div>
<div class="alarmTable-item-text" @click="toIncidentDispose(item.deviceId)">去处理</div> <div class="alarmTable-item-text" @click="toIncidentDispose(item.warnId)">去处理</div>
</div> </div>
</div> </div>
</div> </div>
@ -41,6 +41,7 @@ interface TWarning {
useName: string; useName: string;
createTime: string; createTime: string;
type: number; type: number;
warnId: number;
} }
enum warnTypeEnum { enum warnTypeEnum {

View File

@ -12,7 +12,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm(ruleFormRef)" class="btn" size="large"> </el-button> <el-button type="primary" :disabled="disabled" @click="submitForm(ruleFormRef)" class="btn" size="large"> </el-button>
</el-form-item> </el-form-item>
<div class="hint"> <div class="hint">
如遇到账号问题请联系管理员<br /> 如遇到账号问题请联系管理员<br />
@ -39,6 +39,7 @@ const validatePass = (rule: any, value: any, callback: any) => {
if (rule.field == "password" && !ruleForm.password) return callback(new Error("请输入密码")); if (rule.field == "password" && !ruleForm.password) return callback(new Error("请输入密码"));
callback(); callback();
}; };
const disabled = ref(false);
const ruleForm = reactive({ const ruleForm = reactive({
username: "", username: "",
password: "", password: "",
@ -53,8 +54,10 @@ const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return; if (!formEl) return;
await formEl.validate((valid, fields) => { await formEl.validate((valid, fields) => {
if (valid) { if (valid) {
disabled.value = true;
localStorage.setItem("isReload", "true"); localStorage.setItem("isReload", "true");
fetchLogin(ruleForm).then((res) => { fetchLogin(ruleForm)
.then((res) => {
comm.setUser(res); comm.setUser(res);
comm.getRoleList(); comm.getRoleList();
ElMessage({ ElMessage({
@ -64,6 +67,9 @@ const submitForm = async (formEl: FormInstance | undefined) => {
setTimeout(() => { setTimeout(() => {
router.push("/"); router.push("/");
}, 1000); }, 1000);
})
.finally(() => {
disabled.value = false;
}); });
} }
}); });

View File

@ -16,6 +16,7 @@ import { ref } from "vue";
const radio = ref("1"); const radio = ref("1");
const emit = defineEmits(["change"]); const emit = defineEmits(["change"]);
defineExpose({ radio });
const change = (e) => { const change = (e) => {
emit("change", e); emit("change", e);

View File

@ -2,7 +2,7 @@
<div class="device"> <div class="device">
<div class="device-head"> <div class="device-head">
<div class="title">设备列表</div> <div class="title">设备列表</div>
<el-select class="select" v-model="props.paging.mode" @change="handelMode"> <el-select class="select" v-model="mode" @change="props.handelMode">
<el-option label="全部" value="" /> <el-option label="全部" value="" />
<el-option label="常规模式" value="0" /> <el-option label="常规模式" value="0" />
<el-option label="审讯模式" value="1" /> <el-option label="审讯模式" value="1" />
@ -10,7 +10,7 @@
</el-select> </el-select>
</div> </div>
<template v-if="props.list.length"> <template v-if="props.list.length">
<div v-infinite-scroll="load" :infinite-scroll-immediate="false" class="device-list noScrollbar infinite-list" style="overflow: auto"> <div v-infinite-scroll="props.load" :infinite-scroll-immediate="false" class="device-list noScrollbar infinite-list" style="overflow: auto">
<el-popover :width="350" class="box-item" placement="right" v-for="item in props.list" :key="item.id"> <el-popover :width="350" class="box-item" placement="right" v-for="item in props.list" :key="item.id">
<template #reference> <template #reference>
<div class="item" :class="{ active: props.deviceInfo?.deviceId === item.deviceId }" @click="emit('click', item)"> <div class="item" :class="{ active: props.deviceInfo?.deviceId === item.deviceId }" @click="emit('click', item)">
@ -66,6 +66,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { TDevice } from "@/api/index.d"; import { TDevice } from "@/api/index.d";
import { ref, watch } from "vue";
const statusColor = ["danger", "success", "warning"]; const statusColor = ["danger", "success", "warning"];
const modeColor = ["primary", "danger", "warning"]; const modeColor = ["primary", "danger", "warning"];
@ -80,14 +81,18 @@ enum modeEnum {
"户外押送", "户外押送",
} }
const emit = defineEmits(["click"]); const emit = defineEmits(["click"]);
// const { list, paging, api, deviceInfo } const mode = ref("");
const props = defineProps({ const props = defineProps({
list: { list: {
type: Array<TDevice.IListRes>, type: Array<TDevice.IListRes>,
default: () => [], default: () => [],
}, },
api: { handelMode: {
type: Function,
default: () => {},
},
load: {
type: Function, type: Function,
default: () => {}, default: () => {},
}, },
@ -100,15 +105,13 @@ const props = defineProps({
default: undefined, default: undefined,
}, },
}); });
watch(
const handelMode = () => { () => props.paging,
props.paging.page += 1; (newValue) => {
props.api(); mode.value = newValue.mode;
}; },
const load = () => { { deep: true }
props.paging.page += 1; );
props.api();
};
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.device { .device {

View File

@ -2,7 +2,7 @@
<div class="container"> <div class="container">
<el-row class="el-row" :gutter="20"> <el-row class="el-row" :gutter="20">
<el-col :span="6" class="el-row-left" <el-col :span="6" class="el-row-left"
><DeviceInfo :deviceInfo="deviceInfo" :paging="devicePaging" :api="getdeviceList" :list="deviceData" @click="handelClickDevice" ><DeviceInfo :deviceInfo="deviceInfo" :paging="devicePaging" :list="deviceData" :handelMode="handelMode" :load="handelLoad" @click="handelClickDevice"
/></el-col> /></el-col>
<el-col :span="18" class="el-row-right scrollbar"> <el-col :span="18" class="el-row-right scrollbar">
<MonitoringTop :funcList="funcList" /> <MonitoringTop :funcList="funcList" />
@ -10,7 +10,7 @@
<div class="monitoringMap" id="mapcontainer"></div> <div class="monitoringMap" id="mapcontainer"></div>
<el-row :gutter="20" style="margin-top: 20px"> <el-row :gutter="20" style="margin-top: 20px">
<el-col :span="12"> <el-col :span="12">
<DeviceHistory @change="handelRadio"> <DeviceHistory @change="handelRadio" ref="devHisRef">
<template #chart> <template #chart>
<div ref="chartRef" style="width: 100%; height: 100%"></div> <div ref="chartRef" style="width: 100%; height: 100%"></div>
</template> </template>
@ -24,7 +24,7 @@
<div v-else> <div v-else>
<el-row :gutter="20" style="margin-top: 20px"> <el-row :gutter="20" style="margin-top: 20px">
<el-col :span="24" style="height: 400px"> <el-col :span="24" style="height: 400px">
<DeviceHistory @change="handelRadio"> <DeviceHistory @change="handelRadio" ref="devHisRef">
<template #chart> <template #chart>
<div ref="chartRef" style="width: 100%; height: 100%"></div> <div ref="chartRef" style="width: 100%; height: 100%"></div>
</template> </template>
@ -56,6 +56,8 @@ import blood from "@/assets/img/blood.png";
import location from "@/assets/img/location.png"; import location from "@/assets/img/location.png";
const chartRef = ref(null); const chartRef = ref(null);
const devHisRef = ref(null);
const loadFlag = ref(false);
let myChart = null; let myChart = null;
let newMap = null; let newMap = null;
let Interval = null; let Interval = null;
@ -117,7 +119,10 @@ const deviceData = ref<TDevice.IListRes[]>([]);
const getdeviceList = async () => { const getdeviceList = async () => {
const res = await deviceList(devicePaging); const res = await deviceList(devicePaging);
deviceData.value = res.records; deviceData.value = [...deviceData.value, ...res.records];
if (deviceData.value.length >= res.total) {
loadFlag.value = true;
}
if (res.records.length > 0) { if (res.records.length > 0) {
deviceInfo.value = res.records[0]; deviceInfo.value = res.records[0];
getHealthLatestData(); getHealthLatestData();
@ -189,7 +194,19 @@ const IntervalFn = () => {
getLocateRecord(); getLocateRecord();
}, 60000); }, 60000);
}; };
const handelMode = (e) => {
devicePaging.mode = e;
devicePaging.page = 1;
deviceData.value = [];
getdeviceList();
};
const handelLoad = () => {
if (loadFlag.value) return;
devicePaging.page += 1;
getdeviceList();
};
const handelClickDevice = (val: TDevice.IListRes) => { const handelClickDevice = (val: TDevice.IListRes) => {
devHisRef.value.radio = "1";
deviceInfo.value = val; deviceInfo.value = val;
getHealthLatestData(); getHealthLatestData();
getLocateRecord(); getLocateRecord();

View File

@ -126,9 +126,9 @@ let option2 = ref({
}); });
const paging = reactive({ const paging = reactive({
page: 1, page: 1,
size: 10, size: 5,
total: 0, total: 0,
deviceId: "", deviceId: null,
startDate: `${format(d, "YYYY-MM-DD")} 00:00:00`, startDate: `${format(d, "YYYY-MM-DD")} 00:00:00`,
endDate: `${format(d, "YYYY-MM-DD")} 23:59:59`, endDate: `${format(d, "YYYY-MM-DD")} 23:59:59`,
}); });
@ -167,8 +167,8 @@ const getStatisticsUseCount = () => {
myChart1.setOption(option1.value); myChart1.setOption(option1.value);
}); });
}; };
const getStatisticsContent = (res) => { const getStatisticsContent = (req) => {
statisticsContent(res).then((res) => { statisticsContent(req).then((res) => {
option.value.xAxis.data = res?.times; option.value.xAxis.data = res?.times;
option.value.series = [ option.value.series = [
{ {
@ -196,8 +196,8 @@ const getStatisticsContent = (res) => {
type: "line", type: "line",
}, },
]; ];
});
myChart.setOption(option.value); myChart.setOption(option.value);
});
}; };
const getStatisticsCount = () => { const getStatisticsCount = () => {
statisticsCount().then((res) => { statisticsCount().then((res) => {
@ -220,11 +220,6 @@ const handleResize = debounce(() => {
}, 200); }, 200);
onMounted(() => { onMounted(() => {
getData();
getStatisticsCount();
getStatisticsWarningApi();
getStatisticsUseCount();
try { try {
new MapCustom({ dom: "mapcontainer" }); new MapCustom({ dom: "mapcontainer" });
} catch (error) {} } catch (error) {}
@ -241,6 +236,15 @@ onMounted(() => {
window.addEventListener("resize", handleResize); window.addEventListener("resize", handleResize);
} }
getData();
getStatisticsCount();
getStatisticsWarningApi();
getStatisticsUseCount();
getStatisticsContent({
startDate: `${format(d, "YYYY-MM-DD")} 00:00:00`,
endDate: `${format(d, "YYYY-MM-DD")} 23:59:59`,
type: "hour",
});
}); });
onUnmounted(() => { onUnmounted(() => {
window.removeEventListener("resize", handleResize); window.removeEventListener("resize", handleResize);