diff --git a/src/components/Select/SelectDeviceCapability.vue b/src/components/Select/SelectDeviceCapability.vue new file mode 100644 index 0000000..d802284 --- /dev/null +++ b/src/components/Select/SelectDeviceCapability.vue @@ -0,0 +1,98 @@ + + + diff --git a/src/components/index.ts b/src/components/index.ts index 1427835..f357aa1 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -28,6 +28,7 @@ import TagUserStatus from "/@/components/Tag/TagUserStatus.vue"; import SelectArea from "/@/components/Select/SelectArea.vue"; import SelectDevice from "/@/components/Select/SelectDevice.vue"; +import SelectDeviceCapability from "/@/components/Select/SelectDeviceCapability.vue"; import SelectDeviceGroup from "/@/components/Select/SelectDeviceGroup.vue"; import SelectDuty from "/@/components/Select/SelectDuty.vue"; import SelectDutyType from "/@/components/Select/SelectDutyType.vue"; @@ -99,6 +100,7 @@ export default { app.component("SelectArea", SelectArea); app.component("SelectDevice", SelectDevice); + app.component("SelectDeviceCapability", SelectDeviceCapability); app.component("SelectDeviceGroup", SelectDeviceGroup); app.component("SelectDuty", SelectDuty); app.component("SelectDutyType", SelectDutyType); diff --git a/src/utils/dispose.ts b/src/utils/dispose.ts index de8fa8a..3f31dbb 100644 --- a/src/utils/dispose.ts +++ b/src/utils/dispose.ts @@ -61,42 +61,43 @@ export function timeDiffBySeconds(seconds: number | string) { * 3) 十进制字符串,例如 "12345";将自动转换为二进制位图 * - 输出:返回启用能力对应的中文名称数组(仅包含位为 1 的能力) */ +export const DEVICE_CAPABILITY_LABELS: string[] = [ + "智能报警", + "鱼眼", + "电动聚焦", + "红外测温", + "热度图统计", + "过线统计", + "区域人数统计", + "人脸检测", + "人员识别", + "目标抓拍", + "主从跟踪", + "出入口抓拍", + "AR", + "多区域人数统计", + "雷球联动", + "行为分析", + "云台控制", + "保留位", + "扬声器", + "智能算法升级", + "MAC采集", + "自定义定时抓图", + "人脸开门", + "工装检测", + "人脸质量检测", + "人脸相似度比对", + "客流定时订阅", + "人脸分析", + "AR后端打标", + "AR广角180°", + "AR广角360°", + "废弃位", +]; + export function parseDeviceCapability(capability: string): string[] { if (!capability) return []; - const labels: string[] = [ - "智能报警", - "鱼眼", - "电动聚焦", - "红外测温", - "热度图统计", - "过线统计", - "区域人数统计", - "人脸检测", - "人员识别", - "目标抓拍", - "主从跟踪", - "出入口抓拍", - "AR", - "多区域人数统计", - "雷球联动", - "行为分析", - "云台控制", - "保留位", - "扬声器", - "智能算法升级", - "MAC采集", - "自定义定时抓图", - "人脸开门", - "工装检测", - "人脸质量检测", - "人脸相似度比对", - "客流定时订阅", - "人脸分析", - "AR后端打标", - "AR广角180°", - "AR广角360°", - "废弃位", - ]; const trimmed = capability.trim(); let getBitFromRight: (posFromRight: number) => number; if (trimmed.includes(",")) { @@ -123,8 +124,25 @@ export function parseDeviceCapability(capability: string): string[] { return []; } const result: string[] = []; - for (let i = 1; i <= labels.length; i++) { - if (getBitFromRight(i) === 1) result.push(labels[i - 1]); + for (let i = 1; i <= DEVICE_CAPABILITY_LABELS.length; i++) { + if (getBitFromRight(i) === 1) result.push(DEVICE_CAPABILITY_LABELS[i - 1]); } return result; } + +export function formatDeviceCapability( + labels: string[], + format: "comma" | "binary" | "decimal" = "comma" +) { + const bitList = DEVICE_CAPABILITY_LABELS.map((label) => + labels.includes(label) ? "1" : "0" + ); + if (format === "binary") { + return [...bitList].reverse().join(""); + } + if (format === "decimal") { + const binary = [...bitList].reverse().join("").replace(/^0+/, ""); + return binary ? BigInt(`0b${binary}`).toString(10) : "0"; + } + return bitList.join(","); +} diff --git a/src/views/device/detail/components/device-channer-form.vue b/src/views/device/detail/components/device-channer-form.vue index 4a81b63..6982173 100644 --- a/src/views/device/detail/components/device-channer-form.vue +++ b/src/views/device/detail/components/device-channer-form.vue @@ -36,7 +36,7 @@ - + diff --git a/src/views/sys/sysOrg/form.vue b/src/views/sys/sysOrg/form.vue index e52d3dc..2d5aa2d 100644 --- a/src/views/sys/sysOrg/form.vue +++ b/src/views/sys/sysOrg/form.vue @@ -17,26 +17,11 @@ - - - - - - - - - - - - - - -