设备刷新缓存按钮
This commit is contained in:
parent
6c1fdb7adb
commit
fa8a4c9cc7
@ -221,7 +221,8 @@
|
||||
"Timestamps": "Timestamps",
|
||||
"FormattedTimestamps": "Formatted Timestamps",
|
||||
"DevicePath": "DevicePath",
|
||||
"DeviceAddress": "Device Address"
|
||||
"DeviceAddress": "Device Address",
|
||||
"CacheRefresh": "Cache Refresh"
|
||||
},
|
||||
"CTWingLog": {
|
||||
"PlatformTenantId": "PlatformTenantId",
|
||||
|
||||
@ -63,5 +63,8 @@
|
||||
"BelongingIoTPlatform": "Belonging TPlatform",
|
||||
"AppId": "AppId",
|
||||
"AppKey": "AppKey",
|
||||
"AppSecret": "AppSecret"
|
||||
"AppSecret": "AppSecret",
|
||||
"operationSuccess": "OperationSuccess",
|
||||
"operationFailed": "OperationFailed",
|
||||
"loading": "Loading"
|
||||
}
|
||||
|
||||
@ -221,7 +221,8 @@
|
||||
"Timestamps": "UTC时标(纳秒)",
|
||||
"FormattedTimestamps": "本地时间",
|
||||
"DevicePath": "设备路径",
|
||||
"DeviceAddress": "设备地址"
|
||||
"DeviceAddress": "设备地址",
|
||||
"CacheRefresh": "缓存刷新"
|
||||
},
|
||||
"CTWingLog": {
|
||||
"PlatformTenantId": "物联网平台租户Id",
|
||||
|
||||
@ -64,5 +64,8 @@
|
||||
"BelongingIoTPlatform": "所属平台",
|
||||
"AppId": "应用Id",
|
||||
"AppKey": "应用Key",
|
||||
"AppSecret": "应用Secret"
|
||||
"AppSecret": "应用Secret",
|
||||
"operationSuccess": "操作成功",
|
||||
"operationFailed": "操作失败",
|
||||
"loading": "正在处理"
|
||||
}
|
||||
|
||||
@ -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,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',
|
||||
},
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Loading :loading="pageLoading" tip="缓存刷新中..." />
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.add'),
|
||||
type: 'primary',
|
||||
icon: 'ant-design:plus-outlined',
|
||||
onClick: openAddModal.bind(null),
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
},
|
||||
]" />
|
||||
<TableAction :actions="toolbarActions" />
|
||||
</template>
|
||||
|
||||
<template #isArchiveStatus="{ row }">
|
||||
@ -302,35 +345,35 @@ const openAddModal = async () => {
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<TableAction :actions="[
|
||||
<template #action="{ row }">
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: onEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('abp.deviceInfos.viewData'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: toStatusData.bind(null, row),
|
||||
},
|
||||
]" :drop-down-actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: onEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('abp.deviceInfos.viewData'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: toStatusData.bind(null, row),
|
||||
},
|
||||
]" :drop-down-actions="[
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
icon: 'ant-design:delete-outlined',
|
||||
type: 'primary',
|
||||
auth: ['AbpIdentity.Users.Delete'],
|
||||
popConfirm: {
|
||||
title: $t('common.askConfirmDelete'),
|
||||
confirm: onDel.bind(null, row),
|
||||
},
|
||||
label: $t('common.delete'),
|
||||
icon: 'ant-design:delete-outlined',
|
||||
type: 'primary',
|
||||
auth: ['AbpIdentity.Users.Delete'],
|
||||
popConfirm: {
|
||||
title: $t('common.askConfirmDelete'),
|
||||
confirm: onDel.bind(null, row),
|
||||
},
|
||||
]" />
|
||||
</template>
|
||||
},
|
||||
]" />
|
||||
</template>
|
||||
</Grid>
|
||||
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||
<component :is="editRow.id ? EditForm : AddForm" />
|
||||
|
||||
@ -437,6 +437,8 @@ watch(
|
||||
{ immediate: false }, // 改为false,避免立即触发
|
||||
);
|
||||
|
||||
|
||||
|
||||
// 页面初始化时,延迟初始化表格
|
||||
onMounted(async () => {
|
||||
// 延迟初始化,确保VXE表格组件已完全挂载
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user