diff --git a/apps/web-antd/src/locales/langs/en-US/abp.json b/apps/web-antd/src/locales/langs/en-US/abp.json index 082e88f..8ca9223 100644 --- a/apps/web-antd/src/locales/langs/en-US/abp.json +++ b/apps/web-antd/src/locales/langs/en-US/abp.json @@ -221,7 +221,8 @@ "Timestamps": "Timestamps", "FormattedTimestamps": "Formatted Timestamps", "DevicePath": "DevicePath", - "DeviceAddress": "Device Address" + "DeviceAddress": "Device Address", + "CacheRefresh": "Cache Refresh" }, "CTWingLog": { "PlatformTenantId": "PlatformTenantId", diff --git a/apps/web-antd/src/locales/langs/en-US/common.json b/apps/web-antd/src/locales/langs/en-US/common.json index 517bf0f..0150e08 100644 --- a/apps/web-antd/src/locales/langs/en-US/common.json +++ b/apps/web-antd/src/locales/langs/en-US/common.json @@ -63,5 +63,8 @@ "BelongingIoTPlatform": "Belonging TPlatform", "AppId": "AppId", "AppKey": "AppKey", - "AppSecret": "AppSecret" + "AppSecret": "AppSecret", + "operationSuccess": "OperationSuccess", + "operationFailed": "OperationFailed", + "loading": "Loading" } diff --git a/apps/web-antd/src/locales/langs/zh-CN/abp.json b/apps/web-antd/src/locales/langs/zh-CN/abp.json index f18d048..e7ba1e1 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/abp.json +++ b/apps/web-antd/src/locales/langs/zh-CN/abp.json @@ -221,7 +221,8 @@ "Timestamps": "UTC时标(纳秒)", "FormattedTimestamps": "本地时间", "DevicePath": "设备路径", - "DeviceAddress": "设备地址" + "DeviceAddress": "设备地址", + "CacheRefresh": "缓存刷新" }, "CTWingLog": { "PlatformTenantId": "物联网平台租户Id", diff --git a/apps/web-antd/src/locales/langs/zh-CN/common.json b/apps/web-antd/src/locales/langs/zh-CN/common.json index d657f96..eab53b3 100644 --- a/apps/web-antd/src/locales/langs/zh-CN/common.json +++ b/apps/web-antd/src/locales/langs/zh-CN/common.json @@ -64,5 +64,8 @@ "BelongingIoTPlatform": "所属平台", "AppId": "应用Id", "AppKey": "应用Key", - "AppSecret": "应用Secret" + "AppSecret": "应用Secret", + "operationSuccess": "操作成功", + "operationFailed": "操作失败", + "loading": "正在处理" } diff --git a/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue b/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue index 7b18342..56f5d59 100644 --- a/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue +++ b/apps/web-antd/src/views/devicemanagement/deviceinfo/index.vue @@ -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 = { const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions }); const editRow: Record = ref({}); +const cacheRefreshLoading = ref(false); +const pageLoading = ref(false); const [UserModal, userModalApi] = useVbenModal({ draggable: true, onConfirm: submit, @@ -241,21 +245,60 @@ const openAddModal = async () => { editRow.value = {}; userModalApi.open(); }; + +// 缓存刷新按钮处理函数 +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', + icon: 'ant-design:plus-outlined', + 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', + }, + }, +]); diff --git a/apps/web-antd/src/views/iotdbdatamanagement/deviceData/index.vue b/apps/web-antd/src/views/iotdbdatamanagement/deviceData/index.vue index 5c97079..0fcb5ac 100644 --- a/apps/web-antd/src/views/iotdbdatamanagement/deviceData/index.vue +++ b/apps/web-antd/src/views/iotdbdatamanagement/deviceData/index.vue @@ -437,6 +437,8 @@ watch( { immediate: false }, // 改为false,避免立即触发 ); + + // 页面初始化时,延迟初始化表格 onMounted(async () => { // 延迟初始化,确保VXE表格组件已完全挂载