- 新增设备最后心跳查询接口及类型定义 - 设备在线状态字段统一更名为 online,移除重复字段 - 设备详情首次加载时从心跳接口获取最后上线时间 - WebSocket 推送在线状态时同步更新屏幕状态和最后心跳时间 - 编辑设备弹窗精简为仅可修改昵称,其余字段改为只读展示
64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { reactive } from "vue";
|
|
import DeviceAPI from "@/api/system/device";
|
|
import type { DeviceForm } from "@/api/system/device/types";
|
|
import type { IModalConfig } from "@/components/DeviceSn/types";
|
|
import { DeviceEnum } from "@/enums/settings";
|
|
import { useAppStore } from "@/stores";
|
|
|
|
const modalConfig: IModalConfig<DeviceForm> = {
|
|
permPrefix: "sys:device",
|
|
component: "drawer",
|
|
drawer: {
|
|
title: "修改设备",
|
|
size: useAppStore().device === DeviceEnum.MOBILE ? "80%" : 500,
|
|
},
|
|
pk: "id",
|
|
// 编辑只回传可修改字段(仅设备昵称)
|
|
beforeSubmit(data) {
|
|
return {
|
|
id: data.id,
|
|
snName: data.snName,
|
|
status: data.status,
|
|
} as DeviceForm;
|
|
},
|
|
formAction(data) {
|
|
return DeviceAPI.update(data.id as string, data);
|
|
},
|
|
formItems: [
|
|
{
|
|
label: "设备SN",
|
|
prop: "serialno",
|
|
type: "input",
|
|
attrs: {
|
|
placeholder: "设备序列号",
|
|
readonly: true,
|
|
disabled: true,
|
|
},
|
|
},
|
|
{
|
|
label: "设备昵称",
|
|
prop: "snName",
|
|
rules: [{ required: true, message: "设备昵称不能为空", trigger: "blur" }],
|
|
type: "input",
|
|
attrs: {
|
|
placeholder: "请输入设备昵称",
|
|
maxlength: 50,
|
|
},
|
|
},
|
|
{
|
|
label: "状态",
|
|
prop: "status",
|
|
type: "switch",
|
|
attrs: {
|
|
inlinePrompt: true,
|
|
activeText: "启用",
|
|
inactiveText: "禁用",
|
|
activeValue: 1,
|
|
inactiveValue: 0,
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
export default reactive(modalConfig);
|