spring
2025-11-24 099353bbe598d3df2279ced1a5a43ae883886d8c
fix: 巡检扫码bug
已修改3个文件
60 ■■■■ 文件已修改
src/pages/routingInspection/detail/indexJX.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/routingInspection/detail/indexLS.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/routingInspection/index.vue 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/routingInspection/detail/indexJX.vue
@@ -328,6 +328,8 @@
      </div>
    </wd-popup>
    <wd-toast />
    <!-- 扫码组件 -->
    <Scan ref="scanRef" emit-name="scanJX" />
  </view>
</template>
@@ -339,6 +341,7 @@
import AttachmentUpload from "../upload.vue";
import { useUserStore } from "@/store/modules/user";
import { useScanCode } from "@/composables/useScanCode";
import Scan from "@/components/scan/index.vue";
const paramsType = ref("");
const paramsId = ref("");
@@ -351,6 +354,7 @@
const attachmentRef = ref<any>(null);
const detailData = reactive<any>({});
const detailDataLoaded = ref(false);
const scanRef = ref(); // 扫码组件引用
// 获取当前登录用户信息
const userStore = useUserStore();
@@ -689,12 +693,16 @@
};
const openScan = () => {
  console.log("indexJX - 点击扫码按钮(全局扫码模式,无需手动触发)");
  // 全局扫码模式下,硬件扫码会自动触发,无需手动调用
  uni.showToast({
    title: "请使用扫码枪扫描",
    icon: "none",
  });
  console.log("indexJX - 点击扫码按钮,触发扫码");
  // 触发扫码
  if (scanRef.value) {
    scanRef.value.triggerScan();
  } else {
    uni.showToast({
      title: "扫码组件未初始化",
      icon: "none",
    });
  }
};
// 页面显示时的处理
src/pages/routingInspection/detail/indexLS.vue
@@ -303,6 +303,8 @@
      </div>
    </wd-popup>
    <wd-toast />
    <!-- 扫码组件 -->
    <Scan ref="scanRef" emit-name="scanLS" />
  </view>
</template>
@@ -314,6 +316,7 @@
import AttachmentUpload from "../upload.vue";
import { useUserStore } from "@/store/modules/user";
import { useScanCode } from "@/composables/useScanCode";
import Scan from "@/components/scan/index.vue";
// 核心状态
const paramsId = ref("");
@@ -325,6 +328,7 @@
const tempFiles = ref<any[]>([]);
const toast = useToast();
const attachmentRef = ref<any>(null);
const scanRef = ref(); // 扫码组件引用
// 获取当前登录用户信息
const userStore = useUserStore();
@@ -594,12 +598,16 @@
};
const openScan = () => {
  console.log("indexLS - 点击扫码按钮(全局扫码模式,无需手动触发)");
  // 全局扫码模式下,硬件扫码会自动触发,无需手动调用
  uni.showToast({
    title: "请使用扫码枪扫描",
    icon: "none",
  });
  console.log("indexLS - 点击扫码按钮,触发扫码");
  // 触发扫码
  if (scanRef.value) {
    scanRef.value.triggerScan();
  } else {
    uni.showToast({
      title: "扫码组件未初始化",
      icon: "none",
    });
  }
};
// 页面显示时的处理
src/pages/routingInspection/index.vue
@@ -32,6 +32,8 @@
      </wd-tab>
    </wd-tabs>
    <wd-toast />
    <!-- 扫码组件 -->
    <Scan ref="scanRef" emit-name="scanIndex" />
  </view>
</template>
@@ -44,6 +46,7 @@
import { useToast } from "wot-design-uni";
import RoutingInspectionApi from "@/api/routingInspection/routingInspection";
import { useScanCode } from "@/composables/useScanCode";
import Scan from "@/components/scan/index.vue";
const userStore = useUserStore();
const userInfo: any = computed(() => userStore.userInfo);
@@ -52,6 +55,7 @@
const patrolList = ref<any[]>([]); // 巡检设备列表数据
const searchKeyword = ref<string>(""); // 搜索关键词(班组名称)
const searchKey = ref<number>(0); // 用于强制刷新列表
const scanRef = ref(); // 扫码组件引用
// 使用扫码管理 composable(全局监听器,不随页面切换关闭)
const { deviceUid, deviceModel, hasScanned, displayText, loadFromCache, enableListener } =
@@ -76,12 +80,16 @@
};
const openScan = () => {
  console.log("index.vue - 点击扫码按钮(全局扫码模式,无需手动触发)");
  // 全局扫码模式下,硬件扫码会自动触发,无需手动调用
  uni.showToast({
    title: "请使用扫码枪扫描",
    icon: "none",
  });
  console.log("index.vue - 点击扫码按钮,触发扫码");
  // 触发扫码
  if (scanRef.value) {
    scanRef.value.triggerScan();
  } else {
    uni.showToast({
      title: "扫码组件未初始化",
      icon: "none",
    });
  }
};
// 获取巡检设备列表