refactor: reorganize files

This commit is contained in:
yangsy
2025-11-22 01:46:16 +08:00
parent 00a961c346
commit a486f76aaf
148 changed files with 1440 additions and 1170 deletions

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { getRecordCheckByParentId, reloadAllRecordCheck, type NdmNvrResultVO, type NdmRecordCheck, type RecordInfo, type RecordItem } from '@/apis';
import { getRecordCheckApi, reloadAllRecordCheckApi, type NdmNvrResultVO, type NdmRecordCheck, type RecordInfo, type RecordItem } from '@/apis';
import { useStationStore } from '@/stores';
import { downloadByData, formatDuration } from '@/utils';
import { useMutation } from '@tanstack/vue-query';
@@ -118,7 +118,7 @@ const recordDiagStatistics = computed(() => {
const { mutate: getRecordChecks, isPending: loading } = useMutation({
mutationFn: async () => {
const recordCheckList = await getRecordCheckByParentId(stationCode.value, ndmNvr.value, 90);
const recordCheckList = await getRecordCheckApi(ndmNvr.value, 90, [], { stationCode: stationCode.value });
return recordCheckList;
},
onSuccess: (checkList) => {
@@ -132,7 +132,7 @@ const { mutate: getRecordChecks, isPending: loading } = useMutation({
const { mutate: reloadAllRecordChecks, isPending: reloading } = useMutation({
mutationFn: async () => {
await reloadAllRecordCheck(stationCode.value, 90);
await reloadAllRecordCheckApi(90, { stationCode: stationCode.value });
},
onSuccess: () => {
window.$message.success('正在逐步刷新中,请稍后点击刷新按钮查看');

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { getDeviceDetailApi, probeDeviceApi, type NdmDeviceResultVO } from '@/apis';
import { detailDeviceApi, probeDeviceApi, type NdmDeviceResultVO } from '@/apis';
import { DeviceType, DeviceTypeName, tryGetDeviceTypeVal, type DeviceTypeVal } from '@/enums';
import { useLineDevicesStore } from '@/stores';
import { useMutation } from '@tanstack/vue-query';
@@ -48,7 +48,7 @@ const canProbe = computed(() => device.value.snmpEnabled);
const { mutate: probeDevice, isPending: probing } = useMutation({
mutationFn: async () => {
await probeDeviceApi(stationCode.value, device.value);
await probeDeviceApi(device.value, { stationCode: stationCode.value });
},
onError: (error) => {
console.error(error);
@@ -58,8 +58,7 @@ const { mutate: probeDevice, isPending: probing } = useMutation({
const { mutate: getDeviceDetail, isPending: loading } = useMutation({
mutationFn: async () => {
const { id, deviceType } = device.value;
return await getDeviceDetailApi(stationCode.value, id, tryGetDeviceTypeVal(deviceType));
return await detailDeviceApi(device.value, { stationCode: stationCode.value });
},
onSuccess: (device) => {
if (device) {

View File

@@ -1,11 +1,6 @@
<script setup lang="ts">
import type { NdmNvrResultVO, NdmRecordCheck, RecordInfo, RecordItem, Station } from '@/apis';
import {
getChannelList,
getRecordCheckByParentId as getRecordCheckByParentIdApi,
reloadAllRecordCheck as reloadAllRecordCheckApi,
reloadRecordCheckByGbId as reloadRecordCheckByGbIdApi,
} from '@/apis';
import { getChannelListApi, getRecordCheckApi as getRecordCheckByParentIdApi, reloadAllRecordCheckApi as reloadAllRecordCheckApi, reloadRecordCheckApi as reloadRecordCheckByGbIdApi } from '@/apis';
import { useStationStore } from '@/stores';
import { downloadByData, formatDuration } from '@/utils';
import { useMutation } from '@tanstack/vue-query';
@@ -107,7 +102,7 @@ const recordDiags = computed(() => {
const { mutate: getRecordCheckByParentId, isPending: loading } = useMutation({
mutationFn: async () => {
const checks = await getRecordCheckByParentIdApi(stationCode.value, ndmNvr.value, 90);
const checks = await getRecordCheckByParentIdApi(ndmNvr.value, 90, [], { stationCode: stationCode.value });
return checks;
},
onSuccess: (checks) => {
@@ -121,7 +116,7 @@ const { mutate: getRecordCheckByParentId, isPending: loading } = useMutation({
const { mutate: reloadAllRecordCheck, isPending: reloading } = useMutation({
mutationFn: async () => {
await reloadAllRecordCheckApi(stationCode.value, 90);
await reloadAllRecordCheckApi(90, { stationCode: stationCode.value });
},
onSuccess: () => {
window.$message.success('正在逐步刷新中,请稍后点击刷新按钮查看');
@@ -177,13 +172,13 @@ const getLostChunkDOMStyle = (lostChunk: RecordItem, duration: RecordItem) => {
const { mutate: reloadRecordCheckByGbId } = useMutation({
mutationFn: async (params: { gbCode: string }) => {
const channelList = await getChannelList(stationCode.value, ndmNvr.value);
const channelList = await getChannelListApi(ndmNvr.value, { stationCode: stationCode.value });
const channel = channelList.find((channel) => channel.code === params.gbCode);
if (!channel) throw new Error('通道不存在');
window.$message.loading('刷新耗时较长, 请不要多次刷新, 并耐心等待...', {
duration: 1000 * 60 * 60 * 24 * 300,
});
const isSuccess = await reloadRecordCheckByGbIdApi(stationCode.value, channel, 90);
const isSuccess = await reloadRecordCheckByGbIdApi(channel, 90, { stationCode: stationCode.value });
window.$message.destroyAll();
if (isSuccess) {
window.$message.success('刷新成功');

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { probeDeviceApi, rebootSecurityBox as rebootSecurityBoxApi, turnStatus as turnStatusApi, type NdmSecurityBoxCircuit, type NdmSecurityBoxResultVO } from '@/apis';
import { probeDeviceApi, rebootSecurityBoxApi as rebootSecurityBoxApi, turnCircuitStatusApi as turnStatusApi, type NdmSecurityBoxCircuit, type NdmSecurityBoxResultVO } from '@/apis';
import { useMutation } from '@tanstack/vue-query';
import { PowerOutline, FlashOutline } from '@vicons/ionicons5';
import { NCard, NGrid, NGridItem, NPopover, NSwitch, NIcon, NFlex, NPopconfirm, NButton } from 'naive-ui';
@@ -59,8 +59,8 @@ const { mutate: turnStatus, isPending: turning } = useMutation({
throw new Error('设备IP地址不存在');
}
const status = newStatus ? 1 : 0;
await turnStatusApi(stationCode.value, ndmSecurityBox.value.ipAddress, circuitIndex, status);
await probeDeviceApi(stationCode.value, ndmSecurityBox.value);
await turnStatusApi(ndmSecurityBox.value.ipAddress, circuitIndex, status, { stationCode: stationCode.value });
await probeDeviceApi(ndmSecurityBox.value, { stationCode: stationCode.value });
return status;
},
onSuccess: (status, params) => {
@@ -83,7 +83,7 @@ const { mutate: rebootSecurityBox, isPending: rebooting } = useMutation({
if (!ndmSecurityBox.value.ipAddress) {
throw new Error('设备IP地址不存在');
}
await rebootSecurityBoxApi(stationCode.value, ndmSecurityBox.value.ipAddress);
await rebootSecurityBoxApi(ndmSecurityBox.value.ipAddress, { stationCode: stationCode.value });
},
onSuccess: () => {
window.$message.success('设备重启成功');

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { NdmCameraResultVO } from '@/apis/models';
import type { NdmCameraResultVO } from '@/apis';
import { DeviceAlarmHistoryDiagCard, DeviceStatusHistoryDiagCard } from '@/components';
import dayjs from 'dayjs';
import { NButton, NCard, NDatePicker, NFlex, NGi, NGrid, NSelect, type DatePickerProps, type SelectOption } from 'naive-ui';

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { postNdmDeviceAlarmLogPage, type NdmDeviceAlarmLogResultVO, type NdmDeviceResultVO, type PageParams } from '@/apis';
import { pageDeviceAlarmLogApi, type NdmDeviceAlarmLogResultVO, type NdmDeviceResultVO, type PageParams } from '@/apis';
import { renderAlarmDateCell, renderAlarmTypeCell, renderFaultDescriptionCell, renderFaultLevelCell } from '@/components';
import { useMutation } from '@tanstack/vue-query';
import { NCard, NDataTable, type DataTableColumns, type DataTableRowData, type DatePickerProps, type PaginationProps } from 'naive-ui';
@@ -86,11 +86,16 @@ const { mutate: getDeviceAlarmLogList, isPending } = useMutation({
sort: 'id',
order: 'descending',
};
const res = await postNdmDeviceAlarmLogPage(stationCode.value, {
model: { deviceId },
extra: { alarmDate_ge, alarmDate_le },
...restParams,
});
const res = await pageDeviceAlarmLogApi(
{
model: { deviceId },
extra: { alarmDate_ge, alarmDate_le },
...restParams,
},
{
stationCode: stationCode.value,
},
);
return res;
},
onSuccess: ({ records, size, total }) => {

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { postIcmpLogPage, type NdmDeviceResultVO, type NdmIcmpLogResultVO, type NdmIcmpLogVO, type PageParams, type PageResult } from '@/apis';
import { pageIcmpLogApi, type NdmDeviceResultVO, type NdmIcmpLogResultVO, type NdmIcmpLog, type PageParams, type PageResult } from '@/apis';
import { formatDuration } from '@/utils';
import { useMutation } from '@tanstack/vue-query';
import dayjs from 'dayjs';
@@ -52,19 +52,29 @@ const { mutate: getDeviceIcmpLogList, isPending } = useMutation({
sort: 'id',
order: 'descending',
};
const currentPageRes = await postIcmpLogPage(stationCode.value, {
model: { deviceId: id },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
});
let previousPageRes: PageResult<Partial<NdmIcmpLogVO>> | undefined = undefined;
if ((pagination.page ?? 1) > 1) {
previousPageRes = await postIcmpLogPage(stationCode.value, {
const currentPageRes = await pageIcmpLogApi(
{
model: { deviceId: id },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
current: (pagination.page ?? 1) - 1,
});
},
{
stationCode: stationCode.value,
},
);
let previousPageRes: PageResult<Partial<NdmIcmpLog>> | undefined = undefined;
if ((pagination.page ?? 1) > 1) {
previousPageRes = await pageIcmpLogApi(
{
model: { deviceId: id },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
current: (pagination.page ?? 1) - 1,
},
{
stationCode: stationCode.value,
},
);
}
return { currentPageRes, previousPageRes };
},

View File

@@ -7,7 +7,7 @@ function getValueByFieldPath(record: Record<string, any>, fieldPath?: string) {
<script setup lang="ts">
import type { NdmDeviceResultVO, NdmSnmpLogResultVO, PageParams } from '@/apis';
import { postSnmpLogPage } from '@/apis';
import { pageSnmpLogApi } from '@/apis';
import { useMutation } from '@tanstack/vue-query';
import dayjs from 'dayjs';
import { destr } from 'destr';
@@ -75,11 +75,16 @@ const { mutate: getDeviceSnmpLogList, isPending } = useMutation({
sort: 'id',
order: 'descending',
};
const respData = await postSnmpLogPage(stationCode.value, {
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
});
const respData = await pageSnmpLogApi(
{
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
},
{
stationCode: stationCode.value,
},
);
return respData;
},
onSuccess: ({ records, size, total }) => {

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { postSnmpLogPage, type NdmNvrDiagInfo, type NdmNvrResultVO, type PageParams } from '@/apis';
import { pageSnmpLogApi, type NdmNvrDiagInfo, type NdmNvrResultVO, type PageParams } from '@/apis';
import { useMutation } from '@tanstack/vue-query';
import dayjs from 'dayjs';
import { destr } from 'destr';
@@ -73,11 +73,16 @@ const { mutate: getDeviceSnmpLogList, isPending } = useMutation({
sort: 'id',
order: 'descending',
};
const respData = await postSnmpLogPage(stationCode.value, {
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
});
const respData = await pageSnmpLogApi(
{
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
},
{
stationCode: stationCode.value,
},
);
return respData;
},
onSuccess: ({ records, size, total }) => {

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { postSnmpLogPage, type NdmSecurityBoxCircuit, type NdmSecurityBoxDiagInfo, type NdmSecurityBoxResultVO, type PageParams } from '@/apis';
import { pageSnmpLogApi, type NdmSecurityBoxCircuit, type NdmSecurityBoxDiagInfo, type NdmSecurityBoxResultVO, type PageParams } from '@/apis';
import { useMutation } from '@tanstack/vue-query';
import dayjs from 'dayjs';
import destr from 'destr';
@@ -149,11 +149,16 @@ const { mutate: getDeviceSnmpLogList, isPending } = useMutation({
sort: 'id',
order: 'descending',
};
const respData = await postSnmpLogPage(stationCode.value, {
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
});
const respData = await pageSnmpLogApi(
{
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
},
{
stationCode: stationCode.value,
},
);
return respData;
},
onSuccess: ({ records, size, total }) => {

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { postSnmpLogPage, type NdmSwitchDiagInfo, type NdmSwitchPortInfo, type NdmSwitchResultVO, type PageParams } from '@/apis';
import { pageSnmpLogApi, type NdmSwitchDiagInfo, type NdmSwitchPortInfo, type NdmSwitchResultVO, type PageParams } from '@/apis';
import { getPortStatusVal, transformPortSpeed } from '@/components';
import { useMutation } from '@tanstack/vue-query';
import dayjs from 'dayjs';
@@ -127,11 +127,16 @@ const { mutate: getDeviceSnmpLogList, isPending } = useMutation({
sort: 'id',
order: 'descending',
};
const respData = await postSnmpLogPage(stationCode.value, {
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
});
const respData = await pageSnmpLogApi(
{
model: { deviceId },
extra: { createdTime_precisest, createdTime_preciseed },
...restParams,
},
{
stationCode: stationCode.value,
},
);
return respData;
},
onSuccess: ({ records, size, total }) => {