feat 优化报警数量联动功能

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Ironsp
2026-06-11 09:54:03 +08:00
parent 89d0dd2a1d
commit 13b00ac8de
4 changed files with 45 additions and 14 deletions

View File

@@ -1,26 +1,28 @@
import { listDemo, updateDemo } from '@/api/WarningList/index';
import { defineStore } from 'pinia';
import { ref, computed } from 'vue';
import { any } from 'vue-types';
export const useWarningListStore = defineStore('warningListStore', () => {
// --- State (状态) ---
// 相当于 Vuex 中的 state用 ref 或 reactive 定义
const warningList = ref([]);
const warningList = ref();
const warningListTotal = ref(0);
// --- Getters (计算属性) ---
// 相当于 Vuex 中的 getters直接用 computed 定义
// --- Actions (动作) ---
// 相当于 Vuex 中的 actions/mutations直接写同步或异步函数
async function getWarningList(deviceId?: string | number) {
async function getWarningList(query?: any) {
try {
const response = await listDemo({
deviceId,
status: 0,
pageNum: 1,
pageSize: 300
...query
// deviceId,
// status: 0,
// pageNum: 1,
// pageSize: 10
});
warningList.value = response.data || [];
warningList.value = response.data;
warningListTotal.value = response.data.total || 0;
} catch (error) {
console.error('获取消息列表失败', error);
@@ -29,7 +31,6 @@ export const useWarningListStore = defineStore('warningListStore', () => {
async function handleAction(ids: string | number | Array<string | number>) {
try {
await updateDemo(ids);
await getWarningList();
} catch (error) {
console.error('处理告警失败', error);
}