Compare commits
4 Commits
c189f79aa4
...
bd7238a7f1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd7238a7f1 | ||
|
|
6c7897198c | ||
|
|
15a9f68db7 | ||
|
|
70f52eb3bb |
@@ -17,22 +17,24 @@ const cardShow = computed(() => {
|
||||
return Object.values(props).some((value) => !!value);
|
||||
});
|
||||
|
||||
// 门禁状态 (switches[0]: 0=打开/生效, 1=关闭/失效)
|
||||
// 门禁状态
|
||||
const accessControlStatus = computed(() => {
|
||||
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(() => {
|
||||
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) => {
|
||||
if (['打开', '生效'].includes(status ?? '')) return 'success';
|
||||
if (['关闭', '失效'].includes(status ?? '')) return 'error';
|
||||
if (['正常'].includes(status ?? '')) return 'success';
|
||||
if (['失效'].includes(status ?? '')) return 'error';
|
||||
return 'default';
|
||||
};
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ const { mutate: getDeviceAlarmLogList, isPending } = useMutation({
|
||||
if (!dateTimeRange.value) throw new Error('请选择时间范围');
|
||||
const range = dateTimeRange.value as [number, number];
|
||||
const deviceId = ndmDevice.value.deviceId;
|
||||
if (!deviceId) throw new Error('该设备未配置设备ID');
|
||||
const alarmDate_ge = range[0];
|
||||
const alarmDate_le = range[1];
|
||||
const restParams: Omit<PageParams<{ id: string }>, 'model' | 'extra'> = {
|
||||
|
||||
@@ -14,7 +14,7 @@ import { renderAlarmDateCell, renderDeviceTypeCell, renderAlarmTypeCell, renderF
|
||||
import { downloadByData } from '@/utils';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
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';
|
||||
|
||||
interface Props {
|
||||
@@ -125,7 +125,7 @@ const resetFilterFields = () => {
|
||||
filterFields.faultLevel_in = [];
|
||||
};
|
||||
|
||||
const tablePagination = reactive<PaginationProps>({
|
||||
const pagination = reactive<PaginationProps>({
|
||||
size: 'small',
|
||||
showSizePicker: true,
|
||||
page: 1,
|
||||
@@ -135,27 +135,27 @@ const tablePagination = reactive<PaginationProps>({
|
||||
return h('div', {}, { default: () => `共${itemCount}条` });
|
||||
},
|
||||
onUpdatePage: (page: number) => {
|
||||
tablePagination.page = page;
|
||||
getStaionAlarmList();
|
||||
pagination.page = page;
|
||||
getTableData();
|
||||
},
|
||||
onUpdatePageSize: (pageSize: number) => {
|
||||
tablePagination.pageSize = pageSize;
|
||||
tablePagination.page = 1;
|
||||
getStaionAlarmList();
|
||||
pagination.pageSize = pageSize;
|
||||
pagination.page = 1;
|
||||
getTableData();
|
||||
},
|
||||
});
|
||||
|
||||
const tableData = ref<DataTableRowData[]>([]);
|
||||
|
||||
const onAfterModalEnter = () => {
|
||||
getStaionAlarmList();
|
||||
getTableData();
|
||||
};
|
||||
|
||||
const onAfterModalLeave = () => {
|
||||
resetFilterFields();
|
||||
tablePagination.page = 1;
|
||||
tablePagination.pageSize = 10;
|
||||
tablePagination.itemCount = 0;
|
||||
pagination.page = 1;
|
||||
pagination.pageSize = 10;
|
||||
pagination.itemCount = 0;
|
||||
tableData.value = [];
|
||||
};
|
||||
|
||||
@@ -168,10 +168,10 @@ const onUpdateFilters: DataTableProps['onUpdateFilters'] = (filterState) => {
|
||||
filterFields.alarmType_in = alarmTypeKeys;
|
||||
const faultLevelVals = filterState['faultLevel'];
|
||||
filterFields.faultLevel_in = faultLevelVals;
|
||||
getStaionAlarmList();
|
||||
getTableData();
|
||||
};
|
||||
|
||||
const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
||||
const { mutate: getTableData, isPending: loading } = useMutation({
|
||||
mutationFn: async () => {
|
||||
const now = dayjs();
|
||||
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_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||
},
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
current: pagination.page ?? 1,
|
||||
size: pagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
},
|
||||
@@ -201,8 +201,8 @@ const { mutate: getStaionAlarmList, isPending: tableLoading } = useMutation({
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
const { records, size, total } = res;
|
||||
tablePagination.pageSize = parseInt(size);
|
||||
tablePagination.itemCount = parseInt(total);
|
||||
pagination.pageSize = parseInt(size);
|
||||
pagination.itemCount = parseInt(total);
|
||||
tableData.value = records;
|
||||
},
|
||||
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_preciseed: now.endOf('date').format('YYYY-MM-DD HH:mm:ss'),
|
||||
},
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
current: pagination.page ?? 1,
|
||||
size: pagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
},
|
||||
@@ -264,11 +264,11 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
||||
</div>
|
||||
<div v-else style="height: 100%; display: flex; flex-direction: column">
|
||||
<div style="flex: 0 0 auto; margin-bottom: 16px">
|
||||
<NRow>
|
||||
<NCol :span="3" v-for="item in classifiedAlarmCounts" :key="item.label">
|
||||
<NGrid cols="9">
|
||||
<NGridItem v-for="item in classifiedAlarmCounts" :key="item.label" span="1">
|
||||
<NStatistic :label="item.label + '告警'" :value="item.count" />
|
||||
</NCol>
|
||||
</NRow>
|
||||
</NGridItem>
|
||||
</NGrid>
|
||||
</div>
|
||||
<div style="flex: 0 0 auto; display: flex; align-items: center; padding: 8px 0">
|
||||
<div style="font-size: medium">今日设备告警列表</div>
|
||||
@@ -278,10 +278,10 @@ const { mutate: exportTableData, isPending: exporting } = useMutation({
|
||||
</div>
|
||||
<div style="flex: 1 1 auto; min-height: 0">
|
||||
<NDataTable
|
||||
:loading="tableLoading"
|
||||
:loading="loading"
|
||||
:columns="tableColumns"
|
||||
:data="tableData"
|
||||
:pagination="tablePagination"
|
||||
:pagination="pagination"
|
||||
:single-line="false"
|
||||
remote
|
||||
flex-height
|
||||
|
||||
@@ -8,7 +8,7 @@ export function useDeviceSelection() {
|
||||
const router = useRouter();
|
||||
|
||||
const selectedStationCode = ref<string>();
|
||||
const selectedDeviceType = ref<DeviceTypeVal>(DeviceType.AlarmHost);
|
||||
const selectedDeviceType = ref<DeviceTypeVal>(DeviceType.Camera);
|
||||
const selectedDevice = ref<NdmDeviceResultVO>();
|
||||
|
||||
const initFromRoute = (lineDevices: LineDevices) => {
|
||||
|
||||
@@ -78,7 +78,7 @@ function useStationAlarmCountsMutation() {
|
||||
},
|
||||
size: 50000,
|
||||
current: 1,
|
||||
sort: 'id',
|
||||
sort: 'alarmDate',
|
||||
order: 'descending',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -342,6 +342,7 @@ const onClickQuery = () => {
|
||||
tablePagination.pageSize = 10;
|
||||
searchFieldsChanged.value = false;
|
||||
}
|
||||
realtimeRefresh.value = false;
|
||||
getTableData();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user