diff --git a/apps/web-antd/src/router/routes/modules/iot.ts b/apps/web-antd/src/router/routes/modules/iot.ts index 3e7f87caf..2bc6d32b2 100644 --- a/apps/web-antd/src/router/routes/modules/iot.ts +++ b/apps/web-antd/src/router/routes/modules/iot.ts @@ -18,8 +18,7 @@ const routes: RouteRecordRaw[] = [ title: '产品详情', activePath: '/iot/device/product', }, - component: () => - import('#/views/iot/product/product/modules/detail/index.vue'), + component: () => import('#/views/iot/product/product/detail/index.vue'), }, { path: 'device/detail/:id', @@ -28,8 +27,7 @@ const routes: RouteRecordRaw[] = [ title: '设备详情', activePath: '/iot/device/device', }, - component: () => - import('#/views/iot/device/device/modules/detail/index.vue'), + component: () => import('#/views/iot/device/device/detail/index.vue'), }, { path: 'ota/firmware/detail/:id', diff --git a/apps/web-antd/src/views/iot/device/device/modules/detail/index.vue b/apps/web-antd/src/views/iot/device/device/detail/index.vue similarity index 98% rename from apps/web-antd/src/views/iot/device/device/modules/detail/index.vue rename to apps/web-antd/src/views/iot/device/device/detail/index.vue index ac1ede8cd..adc7ea4b1 100644 --- a/apps/web-antd/src/views/iot/device/device/modules/detail/index.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/index.vue @@ -35,8 +35,6 @@ const device = ref({} as IotDeviceApi.Device); const activeTab = ref('info'); const thingModelList = ref([]); -// TODO @haohao:类似 device/detail/index.vue 挪出去哈。 - /** 获取设备详情 */ async function getDeviceData(deviceId: number) { loading.value = true; diff --git a/apps/web-antd/src/views/iot/device/device/modules/detail/modules/config.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/config.vue similarity index 89% rename from apps/web-antd/src/views/iot/device/device/modules/detail/modules/config.vue rename to apps/web-antd/src/views/iot/device/device/detail/modules/config.vue index f24fc0627..3fef66a05 100644 --- a/apps/web-antd/src/views/iot/device/device/modules/detail/modules/config.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/config.vue @@ -21,6 +21,7 @@ const emit = defineEmits<{ const loading = ref(false); // 加载中 const pushLoading = ref(false); // 推送加载中 +const saveLoading = ref(false); // 保存加载中 const config = ref({}); // 只存储 config 字段 const configString = ref(''); // 用于编辑器的字符串格式 @@ -50,11 +51,6 @@ const formattedConfig = computed(() => { } }); -/** 判断配置是否有数据 */ -const hasConfigData = computed(() => { - return config.value && Object.keys(config.value).length > 0; -}); - /** 启用编辑模式的函数 */ function handleEdit() { isEditing.value = true; @@ -84,9 +80,13 @@ async function saveConfig() { message.error({ content: 'JSON格式错误,请修正后再提交!' }); return; } - // TODO @haohao:这里要不要做个类似下面的 pushLoading 避免重复提交; - await updateDeviceConfig(); - isEditing.value = false; + saveLoading.value = true; + try { + await updateDeviceConfig(); + isEditing.value = false; + } finally { + saveLoading.value = false; + } } /** 配置推送处理函数 */ @@ -126,36 +126,14 @@ async function updateDeviceConfig() { diff --git a/apps/web-antd/src/views/iot/device/device/modules/detail/modules/header.vue b/apps/web-antd/src/views/iot/device/device/detail/modules/header.vue similarity index 96% rename from apps/web-antd/src/views/iot/device/device/modules/detail/modules/header.vue rename to apps/web-antd/src/views/iot/device/device/detail/modules/header.vue index 493d2ed76..efffe07b9 100644 --- a/apps/web-antd/src/views/iot/device/device/modules/detail/modules/header.vue +++ b/apps/web-antd/src/views/iot/device/device/detail/modules/header.vue @@ -8,7 +8,7 @@ import { useVbenModal } from '@vben/common-ui'; import { Button, Card, Descriptions, message } from 'ant-design-vue'; -import DeviceForm from '../../form.vue'; +import DeviceForm from '../../modules/form.vue'; interface Props { product: IotProductApi.Product; @@ -74,7 +74,7 @@ function openEditForm(row: IotDeviceApi.Device) { - + + + + {{ props.device.deviceName }} @@ -105,16 +111,16 @@ function handleAuthInfoDialogClose() { /> - {{ formatDate(props.device.createTime) }} + {{ formatDateTime(props.device.createTime) }} - {{ formatDate(props.device.activeTime) }} + {{ formatDateTime(props.device.activeTime) }} - {{ formatDate(props.device.onlineTime) }} + {{ formatDateTime(props.device.onlineTime) }} - {{ formatDate(props.device.offlineTime) }} + {{ formatDateTime(props.device.offlineTime) }}