feat 优化报警消息暂存
This commit is contained in:
@@ -5,6 +5,10 @@
|
|||||||
"ComputedRef": true,
|
"ComputedRef": true,
|
||||||
"DirectiveBinding": true,
|
"DirectiveBinding": true,
|
||||||
"EffectScope": true,
|
"EffectScope": true,
|
||||||
|
"ElLoading": true,
|
||||||
|
"ElMessage": true,
|
||||||
|
"ElMessageBox": true,
|
||||||
|
"ElNotification": true,
|
||||||
"ExtractDefaultPropTypes": true,
|
"ExtractDefaultPropTypes": true,
|
||||||
"ExtractPropTypes": true,
|
"ExtractPropTypes": true,
|
||||||
"ExtractPublicPropTypes": true,
|
"ExtractPublicPropTypes": true,
|
||||||
|
|||||||
@@ -24,3 +24,9 @@ export interface DemoQuery extends PageQuery {
|
|||||||
beginTime?: string;
|
beginTime?: string;
|
||||||
endTime?: string;
|
endTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 告警列表响应结构 */
|
||||||
|
export interface WarningListResult {
|
||||||
|
rows: DemoVO[];
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import { listNotice } from '@/api/system/notice';
|
|||||||
import { initHls, destroyHls } from '@/utils/video';
|
import { initHls, destroyHls } from '@/utils/video';
|
||||||
import { onBeforeRouteLeave } from 'vue-router';
|
import { onBeforeRouteLeave } from 'vue-router';
|
||||||
import { useWarningListStore } from '@/store/modules/warnningList';
|
import { useWarningListStore } from '@/store/modules/warnningList';
|
||||||
|
import type { WarningListResult } from '@/api/WarningList/types';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
|
|
||||||
@@ -61,13 +62,13 @@ const videosStore = useVideosStore();
|
|||||||
|
|
||||||
const warningListStore = useWarningListStore();
|
const warningListStore = useWarningListStore();
|
||||||
const noticeStore = useNoticeStore();
|
const noticeStore = useNoticeStore();
|
||||||
|
const { getWarningList, hanldeAction } = warningListStore;
|
||||||
|
const { warningListTotal, warningList } = storeToRefs(warningListStore);
|
||||||
|
|
||||||
const props = defineProps<{
|
// const props = defineProps<{
|
||||||
warningList: any;
|
// warningList?: WarningListResult;
|
||||||
}>();
|
// }>();
|
||||||
const { warningList } = toRefs(props);
|
|
||||||
const warningListRows = computed(() => warningList.value?.rows || []);
|
const warningListRows = computed(() => warningList.value?.rows || []);
|
||||||
// console.log('666666666666666666_warningListRows', warningListRows.value);
|
|
||||||
const { readAll } = useNoticeStore();
|
const { readAll } = useNoticeStore();
|
||||||
const monitorVideoRef = ref<HTMLVideoElement>();
|
const monitorVideoRef = ref<HTMLVideoElement>();
|
||||||
|
|
||||||
@@ -96,8 +97,8 @@ const parseNoticeItem = (notice: any) => {
|
|||||||
|
|
||||||
//查看画面
|
//查看画面
|
||||||
const handleSee = async (row: any) => {
|
const handleSee = async (row: any) => {
|
||||||
const videoId = row?.videoId;
|
const videoId = row?.deviceId;
|
||||||
console.log('查看画面', row, 'videoId', videoId);
|
console.log('查看画面', row, 'deviceId', videoId);
|
||||||
if (!videoId) {
|
if (!videoId) {
|
||||||
proxy?.$modal.msgError('视频ID不存在');
|
proxy?.$modal.msgError('视频ID不存在');
|
||||||
return;
|
return;
|
||||||
@@ -107,9 +108,10 @@ const handleSee = async (row: any) => {
|
|||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
await nextTick();
|
await nextTick();
|
||||||
initHls(monitorVideoUrl, monitorVideoRef);
|
initHls(monitorVideoUrl, monitorVideoRef);
|
||||||
|
await hanldeAction(row.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMonitorDialogClose = (done: () => void) => {
|
const handleMonitorDialogClose = async (done: () => void) => {
|
||||||
// 卸载 Hls 与清理 video
|
// 卸载 Hls 与清理 video
|
||||||
destroyHls(monitorVideoRef);
|
destroyHls(monitorVideoRef);
|
||||||
done();
|
done();
|
||||||
@@ -194,9 +196,10 @@ onBeforeRouteLeave(() => {
|
|||||||
dialog.visible = false;
|
dialog.visible = false;
|
||||||
monitorVideoUrl.value = '';
|
monitorVideoUrl.value = '';
|
||||||
});
|
});
|
||||||
// onMounted(() => {
|
onMounted(() => {
|
||||||
// warningListStore.getWarningList();
|
getWarningList();
|
||||||
// });
|
console.log('111111111111111111111_warningList.value', warningList.value);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { listDemo, updateDemo } from '@/api/WarningList/index';
|
import { listDemo, updateDemo } from '@/api/WarningList/index';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
|
import type { WarningListResult } from '@/api/WarningList/types';
|
||||||
|
|
||||||
export const useWarningListStore = defineStore('warningListStore', () => {
|
export const useWarningListStore = defineStore('warningListStore', () => {
|
||||||
// --- State (状态) ---
|
// --- State (状态) ---
|
||||||
// 相当于 Vuex 中的 state,用 ref 或 reactive 定义
|
// 相当于 Vuex 中的 state,用 ref 或 reactive 定义
|
||||||
const warningList = ref([]);
|
const warningList = ref<WarningListResult>({ rows: [], total: 0 });
|
||||||
const warningListTotal = ref(0);
|
const warningListTotal = ref(0);
|
||||||
// --- Getters (计算属性) ---
|
// --- Getters (计算属性) ---
|
||||||
// 相当于 Vuex 中的 getters,直接用 computed 定义
|
// 相当于 Vuex 中的 getters,直接用 computed 定义
|
||||||
@@ -16,21 +17,32 @@ export const useWarningListStore = defineStore('warningListStore', () => {
|
|||||||
try {
|
try {
|
||||||
const response = await listDemo({
|
const response = await listDemo({
|
||||||
deviceId,
|
deviceId,
|
||||||
|
status: 0,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10
|
pageSize: 300
|
||||||
});
|
});
|
||||||
// console.log('6666666666666666666', response);
|
// console.log('6666666666666666666', response);
|
||||||
warningList.value = response.data || [];
|
warningList.value = response.data || {};
|
||||||
warningListTotal.value = response.data.total || 0;
|
warningListTotal.value = response.data.total || 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取消息列表失败', error);
|
console.error('获取消息列表失败', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function hanldeAction(ids: string | number | Array<string | number>) {
|
||||||
|
try {
|
||||||
|
await updateDemo(ids);
|
||||||
|
await getWarningList();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('处理告警失败', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 核心点:必须把需要暴露出去的变量和方法 return 出去!
|
// 核心点:必须把需要暴露出去的变量和方法 return 出去!
|
||||||
return {
|
return {
|
||||||
warningList,
|
warningList,
|
||||||
warningListTotal,
|
warningListTotal,
|
||||||
getWarningList
|
getWarningList,
|
||||||
|
hanldeAction
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -133,6 +133,11 @@ import { listDemo, updateDemo } from '@/api/WarningList/index';
|
|||||||
//import { DemoVO, DemoQuery, DemoForm } from '@/api/WarningList/types';
|
//import { DemoVO, DemoQuery, DemoForm } from '@/api/WarningList/types';
|
||||||
import { useDeviceStore } from '@/store/modules/equipmentList';
|
import { useDeviceStore } from '@/store/modules/equipmentList';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { useWarningListStore } from '@/store/modules/warnningList';
|
||||||
|
|
||||||
|
const warningListStore = useWarningListStore();
|
||||||
|
const { getWarningList, hanldeAction } = warningListStore;
|
||||||
|
const { warningListTotal, warningList } = storeToRefs(warningListStore);
|
||||||
|
|
||||||
const deviceStore = useDeviceStore();
|
const deviceStore = useDeviceStore();
|
||||||
const { deviceList } = storeToRefs(deviceStore);
|
const { deviceList } = storeToRefs(deviceStore);
|
||||||
|
|||||||
Reference in New Issue
Block a user