From 08fcc710d0a2acb185b3477d72fe32aff6f2e29a Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Mon, 01 Dec 2025 16:23:03 +0800
Subject: [PATCH] feat:增加ws连接状态

---
 src/subPackages/taskDetail/execution/index.vue |   60 ++++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/src/subPackages/taskDetail/execution/index.vue b/src/subPackages/taskDetail/execution/index.vue
index 034aa96..41d5b69 100644
--- a/src/subPackages/taskDetail/execution/index.vue
+++ b/src/subPackages/taskDetail/execution/index.vue
@@ -1,34 +1,54 @@
 <!-- 已执行 -->
 <template>
-  <web-view ref="sWebViewRef" :src="`${viewUrl}`" @message="onPostMessage" @onPostMessage="onPostMessage" />
+  <WebViewPlus v-if="isApp" :src="`${viewUrl}`" @webMessage="onPostMessage"/>
 </template>
 
 <script setup>
-import {onLoad} from "@dcloudio/uni-app";
-import {useUserStore} from "@/store/index.js";
+import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
+import WebViewPlus from "@/components/WebViewPlus.vue";
+import {getWebViewUrl} from "@/utils/index.js";
 
-const sWebViewRef = ref(null);
-const userStore = useUserStore();
-let viewUrl = ''
+const wayLineJodInfoId = ref(null)
+const viewUrl = ref('')
+// const viewUrl = ref(getWebViewUrl('/execution'))
 
-function onPostMessage(event) {
-  if (event.detail.data[0].type === 'back') {
-    // active.value = null
+// function onPostMessage(data) {
+//   console.log(data, '9999')
+//   if (data.type === 'taskDetails'){
+//     console.log('4444')
+//     uni.switchTab({
+//       url: '/subPackages/taskDetail/execution/index'
+//     });
+//   }
+// }
+function onPostMessage(data) {
+  if (data.type === 'back') {
+    uni.switchTab({
+      url: '/pages/inspectionTask/index'
+    });
+  } else if (data.type === 'control') {
+    uni.redirectTo({
+      url: `/pages/inspectionTask/execution/index?wayLineJodInfoId=${wayLineJodInfoId.value}`
+    });
+  } else if(data.type === 'workid') {
+    uni.navigateTo({
+      url: `/subPackages/workDetail/index?eventNum=${data.eventNum}&wLJobInfoId=${data.wLJobInfoId}`
+    });
   }
 }
 
-// onLoad(() => {
-//   window.addEventListener('message', function (e) {
-//     if (e.data.data.type === 'back') {
-//       // active.value = null
-//     }
-//   });
-// })
-
 onLoad((options) => {
-  // console.log('options1111111', JSON.parse(decodeURIComponent(options)));
-  const id=3333
-  viewUrl = `http://192.168.1.178:5173/drone-app-web-view/#/webViewWrapper/execution?rowItem=${id}`;
+  wayLineJodInfoId.value = options.wayLineJodInfoId
+  viewUrl.value = getWebViewUrl('/execution', {wayLineJodInfoId: wayLineJodInfoId.value, waylineJobId: options.waylineJobId, batch_no: options.batch_no})
+})
+const isApp = ref(false)
+onShow(() => {
+  isApp.value = true
+});
+
+onHide(() => {
+  // 如果工单详情返回任务详情,那么tab栏对应的是关联事件一项
+  // isApp.value = false
 });
 </script>
 

--
Gitblit v1.9.3