refactor(device): 优化设备详情字段与心跳数据加载逻辑

- 新增设备最后心跳查询接口及类型定义
- 设备在线状态字段统一更名为 online,移除重复字段
- 设备详情首次加载时从心跳接口获取最后上线时间
- WebSocket 推送在线状态时同步更新屏幕状态和最后心跳时间
- 编辑设备弹窗精简为仅可修改昵称,其余字段改为只读展示
This commit is contained in:
TongTongStudio
2026-08-12 08:28:10 +08:00
parent aebef55e0a
commit 9bdbefcfe2
5 changed files with 84 additions and 70 deletions

View File

@@ -5,16 +5,6 @@ import type { IModalConfig } from "@/components/DeviceSn/types";
import { DeviceEnum } from "@/enums/settings";
import { useAppStore } from "@/stores";
/** 只读输入框配置(展示常用参数,不可编辑) */
const readonlyInput = (placeholder = "系统自动填充") => ({
type: "input" as const,
attrs: {
placeholder,
readonly: true,
disabled: true,
},
});
const modalConfig: IModalConfig<DeviceForm> = {
permPrefix: "sys:device",
component: "drawer",
@@ -23,11 +13,10 @@ const modalConfig: IModalConfig<DeviceForm> = {
size: useAppStore().device === DeviceEnum.MOBILE ? "80%" : 500,
},
pk: "id",
// 编辑只回传可修改字段,其余保持不变
// 编辑只回传可修改字段(仅设备昵称)
beforeSubmit(data) {
return {
id: data.id,
serialno: data.serialno,
snName: data.snName,
status: data.status,
} as DeviceForm;
@@ -43,14 +32,9 @@ const modalConfig: IModalConfig<DeviceForm> = {
attrs: {
placeholder: "设备序列号",
readonly: true,
disabled: true,
},
},
{
label: "设备型号",
prop: "snModel",
rules: [{ required: true, message: "设备型号不能为空", trigger: "blur" }],
...readonlyInput("设备型号"),
},
{
label: "设备昵称",
prop: "snName",
@@ -61,43 +45,6 @@ const modalConfig: IModalConfig<DeviceForm> = {
maxlength: 50,
},
},
{
label: "手机号码",
prop: "snMobile",
rules: [
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur",
},
],
...readonlyInput("绑定手机号"),
},
{
label: "IMEI",
prop: "snImei",
...readonlyInput("设备IMEI"),
},
{
label: "设备类型",
prop: "deviceType",
...readonlyInput("设备类型"),
},
{
label: "来源",
prop: "source",
...readonlyInput("设备来源"),
},
{
label: "激活时间",
prop: "activationTime",
...readonlyInput("激活时间"),
},
{
label: "最后上线",
prop: "lastOnline",
...readonlyInput("最后上线时间"),
},
{
label: "状态",
prop: "status",