Compare commits

...

4 Commits

Author SHA1 Message Date
yangsy
bd7238a7f1 style: code state 2025-12-11 01:30:37 +08:00
yangsy
6c7897198c fix: alarm-query and secutiryBox switch states 2025-12-11 01:30:11 +08:00
yangsy
15a9f68db7 fix(device-alarm-history-diag-card): throw error if deviceId is undefined/null 2025-12-08 11:15:45 +08:00
yangsy
70f52eb3bb fix(use-device-selection): default select to Camera 2025-12-08 11:10:20 +08:00
6 changed files with 37 additions and 33 deletions

View File

@@ -17,22 +17,24 @@ const cardShow = computed(() => {
return Object.values(props).some((value) => !!value); return Object.values(props).some((value) => !!value);
}); });
// 门禁状态 (switches[0]: 0=打开/生效, 1=关闭/失效) // 门禁状态
const accessControlStatus = computed(() => { const accessControlStatus = computed(() => {
if (!switches?.value || switches.value.length === 0) return null; if (!switches?.value || switches.value.length === 0) return null;
return switches.value[0] === 0 ? '打开' : '关闭'; const status = switches.value.at(0)!;
return status === 0 ? '开门' : status === 1 ? '关门' : '-';
}); });
// 防雷状态 (switches[1]: 0=关闭/失效, 1=打开/生效) // 防雷状态
const lightningProtectionStatus = computed(() => { const lightningProtectionStatus = computed(() => {
if (!switches?.value || switches.value.length < 2) return null; if (!switches?.value || switches.value.length < 2) return null;
return switches.value[1] === 1 ? '生效' : '失效'; const status = switches.value.at(1)!;
return status === 0 ? '正常' : status === 1 ? '失效' : '-';
}); });
// 获取状态标签类型 // 获取状态标签类型
const getStatusTagType = (status: string | null) => { const getStatusTagType = (status: string | null) => {
if (['打开', '生效'].includes(status ?? '')) return 'success'; if (['正常'].includes(status ?? '')) return 'success';
if (['关闭', '失效'].includes(status ?? '')) return 'error'; if (['失效'].includes(status ?? '')) return 'error';
return 'default'; return 'default';
}; };

View File

@@ -78,6 +78,7 @@ const { mutate: getDeviceAlarmLogList, isPending } = useMutation({
if (!dateTimeRange.value) throw new Error('请选择时间范围'); if (!dateTimeRange.value) throw new Error('请选择时间范围');
const range = dateTimeRange.value as [number, number]; const range = dateTimeRange.value as [number, number];
const deviceId = ndmDevice.value.deviceId; const deviceId = ndmDevice.value.deviceId;
if (!deviceId) throw new Error('该设备未配置设备ID');
const alarmDate_ge = range[0]; const alarmDate_ge = range[0];
const alarmDate_le = range[1]; const alarmDate_le = range[1];
const restParams: Omit<PageParams<{ id: string }>, 'model' | 'extra'> = { const restParams: Omit<PageParams<{ id: string }>, 'model' | 'extra'> = {

View File

@@ -14,7 +14,7 @@ import { renderAlarmDateCell, renderDeviceTypeCell, renderAlarmTypeCell, renderF
import { downloadByData } from '@/utils'; import { downloadByData } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { NButton, NCol, NDataTable, NModal, NRow, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui'; import { NButton, NDataTable, NGrid, NGridItem, NModal, NSpace, NStatistic, NTag, type DataTableColumns, type DataTableProps, type DataTableRowData, type PaginationProps } from 'naive-ui';
import { computed, h, reactive, ref, toRefs } from 'vue'; import { computed, h, reactive, ref, toRefs } from 'vue';
interface Props { interface Props {
@@ -125,7 +125,7 @@ const resetFilterFields = () => {
filterFields.faultLevel_in = []; filterFields.faultLevel_in = [];
}; };
const tablePagination = reactive<PaginationProps>({ const pagination = reactive<PaginationProps>({
size: 'small', size: 'small',
showSizePicker: true, showSizePicker: true,
page: 1, page: 1,
@@ -135,27 +135,27 @@ const tablePagination = reactive<PaginationProps>({
return h('div', {}, { default: () => `${itemCount}` }); return h('div', {}, { default: () => `${itemCount}` });
}, },
onUpdatePage: (page: number) => { onUpdatePage: (page: number) => {
tablePagination.page = page; pagination.page = page;
getStaionAlarmList(); getTableData();
}, },
onUpdatePageSize: (pageSize: number) => { onUpdatePageSize: (pageSize: number) => {
tablePagination.pageSize = pageSize; pagination.pageSize = pageSize;
tablePagination.page = 1; pagination.page = 1;
getStaionAlarmList(); getTableData();
}, },
}); });
const tableData = ref<DataTableRowData[]>([]); const tableData = ref<DataTableRowData[]>([]);
const onAfterModalEnter = () => { const onAfterModalEnter = () => {
getStaionAlarmList(); getTableData();
}; };
const onAfterModalLeave = () => { const onAfterModalLeave = () => {
resetFilterFields(); resetFilterFields();
tablePagination.page = 1; pagination.page = 1;
tablePagination.pageSize = 10; pagination.pageSize = 10;
tablePagination.itemCount = 0; pagination.itemCount = 0;
tableData.value = []; tableData.value = [];
}; };
@@ -168,10 +168,10 @@ const onUpdateFilters: DataTableProps['onUpdateFilters'] = (filterState) => {
filterFields.alarmType_in = alarmTypeKeys; filterFields.alarmType_in = alarmTypeKeys;
const faultLevelVals = filterState['faultLevel']; const faultLevelVals = filterState['faultLevel'];
filterFields.faultLevel_in = faultLevelVals; filterFields.faultLevel_in = faultLevelVals;
getStaionAlarmList(); getTableData();
}; };
const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({ const { mutate: getTableData, isPending: loading } = useMutation({
mutationFn: async () => { mutationFn: async () => {
const now = dayjs(); const now = dayjs();
const res = await pageDeviceAlarmLogApi( const res = await pageDeviceAlarmLogApi(
@@ -188,8 +188,8 @@ const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'), createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'), createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
}, },
current: tablePagination.page ?? 1, current: pagination.page ?? 1,
size: tablePagination.pageSize ?? 10, size: pagination.pageSize ?? 10,
order: 'descending', order: 'descending',
sort: 'id', sort: 'id',
}, },
@@ -201,8 +201,8 @@ const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
}, },
onSuccess: (res) => { onSuccess: (res) => {
const { records, size, total } = res; const { records, size, total } = res;
tablePagination.pageSize = parseInt(size); pagination.pageSize = parseInt(size);
tablePagination.itemCount = parseInt(total); pagination.itemCount = parseInt(total);
tableData.value = records; tableData.value = records;
}, },
onError: (error) => { onError: (error) => {
@@ -226,8 +226,8 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'), createdTime_precisest: now.startOf('date').format('YYYY-MM-DD HH:mm:ss'),
createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'), createdTime_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
}, },
current: tablePagination.page ?? 1, current: pagination.page ?? 1,
size: tablePagination.pageSize ?? 10, size: pagination.pageSize ?? 10,
order: 'descending', order: 'descending',
sort: 'id', sort: 'id',
}, },
@@ -264,11 +264,11 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
</div> </div>
<div v-else style="height: 100%; display: flex; flex-direction: column"> <div v-else style="height: 100%; display: flex; flex-direction: column">
<div style="flex: 0 0 auto; margin-bottom: 16px"> <div style="flex: 0 0 auto; margin-bottom: 16px">
<NRow> <NGrid cols="9">
<NCol :span="3" v-for="item in classifiedAlarmCounts" :key="item.label"> <NGridItem v-for="item in classifiedAlarmCounts" :key="item.label" span="1">
<NStatistic :label="item.label + '告警'" :value="item.count" /> <NStatistic :label="item.label + '告警'" :value="item.count" />
</NCol> </NGridItem>
</NRow> </NGrid>
</div> </div>
<div style="flex: 0 0 auto; display: flex; align-items: center; padding: 8px 0"> <div style="flex: 0 0 auto; display: flex; align-items: center; padding: 8px 0">
<div style="font-size: medium">今日设备告警列表</div> <div style="font-size: medium">今日设备告警列表</div>
@@ -278,10 +278,10 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
</div> </div>
<div style="flex: 1 1 auto; min-height: 0"> <div style="flex: 1 1 auto; min-height: 0">
<NDataTable <NDataTable
:loading="tableLoading" :loading="loading"
:columns="tableColumns" :columns="tableColumns"
:data="tableData" :data="tableData"
:pagination="tablePagination" :pagination="pagination"
:single-line="false" :single-line="false"
remote remote
flex-height flex-height

View File

@@ -8,7 +8,7 @@ export function useDeviceSelection() {
const router = useRouter(); const router = useRouter();
const selectedStationCode = ref<string>(); const selectedStationCode = ref<string>();
const selectedDeviceType = ref<DeviceTypeVal>(DeviceType.AlarmHost); const selectedDeviceType = ref<DeviceTypeVal>(DeviceType.Camera);
const selectedDevice = ref<NdmDeviceResultVO>(); const selectedDevice = ref<NdmDeviceResultVO>();
const initFromRoute = (lineDevices: LineDevices) => { const initFromRoute = (lineDevices: LineDevices) => {

View File

@@ -78,7 +78,7 @@ function useStationAlarmCountsMutation() {
}, },
size: 50000, size: 50000,
current: 1, current: 1,
sort: 'id', sort: 'alarmDate',
order: 'descending', order: 'descending',
}, },
{ {

View File

@@ -342,6 +342,7 @@ const onClickQuery = () => {
tablePagination.pageSize = 10; tablePagination.pageSize = 10;
searchFieldsChanged.value = false; searchFieldsChanged.value = false;
} }
realtimeRefresh.value = false;
getTableData(); getTableData();
}; };