设备刷新缓存按钮

This commit is contained in:
ChenYi 2025-08-01 14:58:48 +08:00
parent 6c1fdb7adb
commit fa8a4c9cc7
6 changed files with 94 additions and 41 deletions

View File

@ -221,7 +221,8 @@
"Timestamps": "Timestamps", "Timestamps": "Timestamps",
"FormattedTimestamps": "Formatted Timestamps", "FormattedTimestamps": "Formatted Timestamps",
"DevicePath": "DevicePath", "DevicePath": "DevicePath",
"DeviceAddress": "Device Address" "DeviceAddress": "Device Address",
"CacheRefresh": "Cache Refresh"
}, },
"CTWingLog": { "CTWingLog": {
"PlatformTenantId": "PlatformTenantId", "PlatformTenantId": "PlatformTenantId",

View File

@ -63,5 +63,8 @@
"BelongingIoTPlatform": "Belonging TPlatform", "BelongingIoTPlatform": "Belonging TPlatform",
"AppId": "AppId", "AppId": "AppId",
"AppKey": "AppKey", "AppKey": "AppKey",
"AppSecret": "AppSecret" "AppSecret": "AppSecret",
"operationSuccess": "OperationSuccess",
"operationFailed": "OperationFailed",
"loading": "Loading"
} }

View File

@ -221,7 +221,8 @@
"Timestamps": "UTC时标(纳秒)", "Timestamps": "UTC时标(纳秒)",
"FormattedTimestamps": "本地时间", "FormattedTimestamps": "本地时间",
"DevicePath": "设备路径", "DevicePath": "设备路径",
"DeviceAddress": "设备地址" "DeviceAddress": "设备地址",
"CacheRefresh": "缓存刷新"
}, },
"CTWingLog": { "CTWingLog": {
"PlatformTenantId": "物联网平台租户Id", "PlatformTenantId": "物联网平台租户Id",

View File

@ -64,5 +64,8 @@
"BelongingIoTPlatform": "所属平台", "BelongingIoTPlatform": "所属平台",
"AppId": "应用Id", "AppId": "应用Id",
"AppKey": "应用Key", "AppKey": "应用Key",
"AppSecret": "应用Secret" "AppSecret": "应用Secret",
"operationSuccess": "操作成功",
"operationFailed": "操作失败",
"loading": "正在处理"
} }

View File

@ -2,18 +2,20 @@
import type { VbenFormProps } from '#/adapter/form'; import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table'; import type { VxeGridProps } from '#/adapter/vxe-table';
import { h, ref } from 'vue'; import { computed, h, ref } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui'; import { Page, useVbenModal } from '@vben/common-ui';
import { message as Message, Modal, Tag } from 'ant-design-vue'; import { message as Message, Modal, Tag } from 'ant-design-vue';
import { Loading } from '#/components/Loading';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
postAggregationDeviceCreateAsync, postAggregationDeviceCreateAsync,
postAggregationDeviceDeleteAsync, postAggregationDeviceDeleteAsync,
postDeviceInfoCacheDeviceDataToRedis,
postDeviceInfoPage, postDeviceInfoPage,
} from '#/api-client'; } from '#/api-client';
import { TableAction } from '#/components/table-action'; import { TableAction } from '#/components/table-action';
@ -68,6 +70,8 @@ const gridOptions: VxeGridProps<any> = {
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions }); const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
const editRow: Record<string, any> = ref({}); const editRow: Record<string, any> = ref({});
const cacheRefreshLoading = ref(false);
const pageLoading = ref(false);
const [UserModal, userModalApi] = useVbenModal({ const [UserModal, userModalApi] = useVbenModal({
draggable: true, draggable: true,
onConfirm: submit, onConfirm: submit,
@ -241,13 +245,29 @@ const openAddModal = async () => {
editRow.value = {}; editRow.value = {};
userModalApi.open(); userModalApi.open();
}; };
</script>
<template> //
<Page auto-content-height> const handleCacheRefresh = async () => {
<Grid> if (cacheRefreshLoading.value) return; //
<template #toolbar-actions>
<TableAction :actions="[ cacheRefreshLoading.value = true;
pageLoading.value = true;
try {
await postDeviceInfoCacheDeviceDataToRedis({
body: {},
});
Message.success($t('common.operationSuccess'));
} catch (error) {
console.error('缓存刷新失败:', error);
Message.error($t('common.operationFailed'));
} finally {
cacheRefreshLoading.value = false;
pageLoading.value = false;
}
};
//
const toolbarActions = computed(() => [
{ {
label: $t('common.add'), label: $t('common.add'),
type: 'primary', type: 'primary',
@ -255,7 +275,30 @@ const openAddModal = async () => {
onClick: openAddModal.bind(null), onClick: openAddModal.bind(null),
auth: ['AbpIdentity.Users.Create'], auth: ['AbpIdentity.Users.Create'],
}, },
]" /> {
label: cacheRefreshLoading.value
? $t('common.loading')
: $t('abp.IoTDBBase.CacheRefresh'),
type: 'primary',
icon: cacheRefreshLoading.value
? 'ant-design:loading-outlined'
: 'ant-design:reload-outlined',
onClick: handleCacheRefresh,
disabled: cacheRefreshLoading.value,
style: {
backgroundColor: '#52c41a',
borderColor: '#52c41a',
},
},
]);
</script>
<template>
<Page auto-content-height>
<Loading :loading="pageLoading" tip="缓存刷新中..." />
<Grid>
<template #toolbar-actions>
<TableAction :actions="toolbarActions" />
</template> </template>
<template #isArchiveStatus="{ row }"> <template #isArchiveStatus="{ row }">

View File

@ -437,6 +437,8 @@ watch(
{ immediate: false }, // false { immediate: false }, // false
); );
// //
onMounted(async () => { onMounted(async () => {
// VXE // VXE