From a9561a3189d50f0e33d693b5226ea56adda06a08 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期四, 30 十月 2025 23:07:25 +0800
Subject: [PATCH] 巡检编辑和扫码
---
 src/pages/routingInspection/index.vue |  149 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 149 insertions(+), 0 deletions(-)
diff --git a/src/pages/routingInspection/index.vue b/src/pages/routingInspection/index.vue
new file mode 100644
index 0000000..7979244
--- /dev/null
+++ b/src/pages/routingInspection/index.vue
@@ -0,0 +1,149 @@
+<template>
+  <view>
+    <wd-row>
+      <wd-col :span="21">
+        <wd-search placeholder-left hide-cancel></wd-search>
+      </wd-col>
+      <wd-col :span="3">
+        <view class="scan_box" @click="openScan">
+          <wd-icon name="scan" size="24px" color="#0D867F"></wd-icon>
+        </view>
+      </wd-col>
+    </wd-row>
+    <wd-tabs v-model="tab" auto-line-width slidable="always" :map-num="patrolList.length">
+      <wd-tab
+        v-for="(item, index) in patrolList"
+        :key="index"
+        :title="`${item.deviceModel}锛堝緟妫�鏌�${item.pendingNum}鏉★級`"
+        class="tab_bg"
+      >
+        <ProductList :api="RoutingInspectionApi.getInspectListByPatrol" :ProList="item" />
+      </wd-tab>
+    </wd-tabs>
+    <Scan ref="scanRef" emitName="scan" />
+    <wd-toast />
+  </view>
+</template>
+
+<script lang="ts" setup>
+import { ref, reactive, computed, onMounted, onUnmounted } from "vue";
+import ProductList from "./list/index.vue";
+import Scan from "@/components/scan/index.vue";
+import { useUserStore } from "@/store/modules/user";
+import reportApi from "@/api/work/report";
+import { useToast } from "wot-design-uni";
+import RoutingInspectionApi from "@/api/routingInspection/routingInspection";
+
+const scanRef = ref();
+const userStore = useUserStore();
+const userInfo: any = computed(() => userStore.userInfo);
+const toast = useToast();
+const tab = ref<number>(0);
+const patrolList = ref<any[]>([]); // 宸℃璁惧鍒楄〃鏁版嵁
+
+const handlePatrolData = (index: number, count: number) => {
+  // 鍙互鍦ㄨ繖閲屾洿鏂扮壒瀹氬贰妫�璁惧鐨勫緟妫�鏌ユ暟閲�
+  // 渚嬪锛歱atrolList.value[index].pendingNum = count;
+};
+
+const openScan = () => {
+  scanRef.value.triggerScan();
+};
+
+const getScanCode = async () => {
+  const { code } = await reportApi.sendWorkTime({
+    userName: userInfo.value.userName,
+  });
+  if (code == 200) {
+    toast.success("鎵爜鎴愬姛");
+  }
+};
+
+// 鑾峰彇鐗瑰畾宸℃璁惧鐨勬暟鎹�
+const getPatrolData = (item: any) => {
+  return async (params: any) => {
+    // 杩欓噷鍙互鏍规嵁item涓殑淇℃伅璋冪敤鐩稿簲鐨勬帴鍙h幏鍙栬鎯�
+    // 杩斿洖鐨勬暟鎹牸寮忛渶瑕佷笌ProductList缁勪欢鏈熸湜鐨勬牸寮忎竴鑷�
+    return {
+      code: 200,
+      data: {
+        type: "宸℃",
+        data: {
+          total: 0,
+          records: [],
+        },
+      },
+    };
+  };
+};
+
+// 鑾峰彇宸℃璁惧鍒楄〃
+const loadPatrolList = async () => {
+  try {
+    const { data } = await RoutingInspectionApi.getDeviceInspectListByPatrol({});
+    if (data) {
+      patrolList.value = data;
+    }
+  } catch (error) {
+    toast.error("鑾峰彇宸℃璁惧鍒楄〃澶辫触");
+  }
+};
+
+// 纭繚鍏堢Щ闄ゅ啀娣诲姞鐩戝惉
+const setupScanListener = () => {
+  uni.$off("scan", getScanCode); // 鍏堢Щ闄ゆ棫鐨�
+  uni.$on("scan", getScanCode); // 鍐嶆坊鍔犳柊鐨�
+};
+
+onMounted(() => {
+  // 寮�鍚箍鎾洃鍚簨浠�
+  setupScanListener();
+  console.log("鏄剧ず1");
+  // 椤甸潰鍔犺浇鏃惰幏鍙栧贰妫�璁惧鍒楄〃
+  loadPatrolList();
+});
+
+onUnmounted(() => {
+  // 寮�鍚箍鎾洃鍚簨浠�
+  uni.$off("scan", getScanCode);
+  console.log("绂诲紑1");
+});
+</script>
+
+<style lang="scss" scoped>
+::v-deep .wd-search__block {
+  border-radius: unset;
+}
+.scan_box {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 38px;
+  height: 38px;
+  padding: 6px;
+  background: #fff;
+}
+::v-deep .wd-tabs__line {
+  background: #0d867f;
+}
+::v-deep .wd-tabs__nav {
+  border-bottom: 1px #dddddd solid;
+}
+.tab_bg {
+  background: #f3f9f8;
+}
+
+.icon_box {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 20px;
+  height: 20px;
+  background: #e7f4ec99;
+  border-radius: 50%;
+}
+
+.statistics_box {
+  margin: 15px;
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3