From 3f85e5410dda49e7e6a6292859649513f3644cb2 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 28 八月 2026 14:44:12 +0800
Subject: [PATCH] 天津豹鸣app 1.添加扫码查看设备变更记录功能
---
src/pages/works.vue | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/src/pages/works.vue b/src/pages/works.vue
index 9e89ddf..3b7ffa7 100644
--- a/src/pages/works.vue
+++ b/src/pages/works.vue
@@ -656,6 +656,10 @@
// label: '璁惧鍙拌处',
// },
{
+ icon: "/static/images/icon/saomashebei.svg",
+ label: "鎵爜鏌ヨ澶�",
+ },
+ {
icon: "/static/images/icon/yunxingguanli.svg",
label: "杩愯绠$悊",
},
@@ -672,6 +676,42 @@
label: "璁惧宸℃",
},
]);
+
+ // 鎵爜鏌ヨ澶囷細瑙f瀽 deviceId 鍚庤烦杞埌璁惧淇℃伅椤�
+ const getDeviceIdFromScan = scanResult => {
+ if (!scanResult) return null;
+ const match = scanResult.match(/deviceId=(\d+)/);
+ if (match && match[1]) return match[1];
+ if (/^\d+$/.test(scanResult.trim())) return scanResult.trim();
+ try {
+ const obj = JSON.parse(scanResult);
+ if (obj.deviceId) return String(obj.deviceId);
+ } catch (e) {
+ // 蹇界暐闈� JSON 鍐呭
+ }
+ return null;
+ };
+
+ const startScanDevice = () => {
+ uni.scanCode({
+ scanType: ["qrCode", "barCode"],
+ success: res => {
+ console.log("鎵爜缁撴灉:", res.result);
+ const deviceId = getDeviceIdFromScan(res.result);
+ if (!deviceId) {
+ uni.showToast({ title: "鏈瘑鍒埌璁惧ID", icon: "none" });
+ return;
+ }
+ uni.navigateTo({
+ url: `/pages/equipmentManagement/deviceInfo/index?deviceId=${deviceId}`,
+ });
+ },
+ fail: err => {
+ console.error("鎵爜澶辫触:", err);
+ uni.showToast({ title: "鎵爜澶辫触锛岃閲嶈瘯", icon: "none" });
+ },
+ });
+ };
// 澶勭悊甯哥敤鍔熻兘鐐瑰嚮
const handleCommonItemClick = item => {
@@ -938,6 +978,9 @@
uni.navigateTo({
url: "/pages/equipmentManagement/ledger/index",
});
+ break;
+ case "鎵爜鏌ヨ澶�":
+ startScanDevice();
break;
case "杩愯绠$悊":
uni.navigateTo({
@@ -1258,7 +1301,7 @@
// 鏀堕泦鎵�鏈夋湁鏉冮檺鐨勮彍鍗曟爣棰橈紙鏍规嵁 meta.title锛�
const allowedMenuTitles = new Set();
- const alwaysShowTitles = new Set(["閲囪喘閫�璐у崟", "渚涘簲鍟嗙鐞�"]);
+ const alwaysShowTitles = new Set(["閲囪喘閫�璐у崟", "渚涘簲鍟嗙鐞�", "鎵爜鏌ヨ澶�"]);
const collectMenuTitles = routes => {
if (!Array.isArray(routes)) return;
routes.forEach(route => {
@@ -1284,6 +1327,7 @@
// 閫氱敤杩囨护鍑芥暟
const filterArray = (targetArray, specialMapping) => {
const filtered = targetArray.filter(item => {
+ if (alwaysShowTitles.has(item.label)) return true;
let matched = allowedMenuTitles.has(item.label);
if (specialMapping && !matched && specialMapping[item.label]) {
matched = allowedMenuTitles.has(specialMapping[item.label]);
--
Gitblit v1.9.3