设备刷新缓存按钮

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",
"FormattedTimestamps": "Formatted Timestamps",
"DevicePath": "DevicePath",
"DeviceAddress": "Device Address"
"DeviceAddress": "Device Address",
"CacheRefresh": "Cache Refresh"
},
"CTWingLog": {
"PlatformTenantId": "PlatformTenantId",

View File

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

View File

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

View File

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

View File

@ -2,18 +2,20 @@
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { h, ref } from 'vue';
import { computed, h, ref } from 'vue';
import { useRouter } from 'vue-router';
import { Page, useVbenModal } from '@vben/common-ui';
import { message as Message, Modal, Tag } from 'ant-design-vue';
import { Loading } from '#/components/Loading';
import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
postAggregationDeviceCreateAsync,
postAggregationDeviceDeleteAsync,
postDeviceInfoCacheDeviceDataToRedis,
postDeviceInfoPage,
} from '#/api-client';
import { TableAction } from '#/components/table-action';
@ -68,6 +70,8 @@ const gridOptions: VxeGridProps<any> = {
const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
const editRow: Record<string, any> = ref({});
const cacheRefreshLoading = ref(false);
const pageLoading = ref(false);
const [UserModal, userModalApi] = useVbenModal({
draggable: true,
onConfirm: submit,
@ -241,13 +245,29 @@ const openAddModal = async () => {
editRow.value = {};
userModalApi.open();
};
</script>
<template>
<Page auto-content-height>
<Grid>
<template #toolbar-actions>
<TableAction :actions="[
//
const handleCacheRefresh = async () => {
if (cacheRefreshLoading.value) return; //
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'),
type: 'primary',
@ -255,7 +275,30 @@ const openAddModal = async () => {
onClick: openAddModal.bind(null),
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 #isArchiveStatus="{ row }">

View File

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