cz 10 сар өмнө
parent
commit
62a41c243c

+ 1 - 1
src/router/index.js

@@ -485,7 +485,7 @@ const routes = [{
 			},
 			{
 				path: 'employeePerformance',
-				name: '生产绩效',
+				name: '员工绩效',
 				component: () => import('../views/MES/employeePerformance/index.vue')
 			},
 			// {

+ 18 - 1
src/views/MES/reportDetail/index.vue

@@ -4,7 +4,7 @@
       <!-- <template #right> 扫码 </template> -->
     </van-nav-bar>
     <van-search v-model="req.keyword" :placeholder="$t('common.pleaseEnterKeywords')" @search="onRefresh" />
-
+    <!-- <van-button @click="handleSend">发送</van-button> -->
     <van-pull-refresh v-model="loading" @refresh="onRefresh">
       <div class="list">
         <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="onLoad" style="margin-bottom: 60px">
@@ -179,6 +179,23 @@ const handleScanCode = () => {
 //     };
 //   });
 // });
+
+const handleSend = () => {
+  // uni.postMessage({
+  //   data: {
+  //     type: "push",
+  //     content: "推送测试",
+  //   },
+  // });
+  setInterval(() => {
+    uni.postMessage({
+      data: {
+        type: "message",
+        count: 10,
+      },
+    });
+  }, 1000 * 10);
+};
 </script>
 
 <style lang="scss" scoped>

+ 50 - 6
src/views/main.vue

@@ -52,8 +52,11 @@ const tenantId = getUserInfo().tenantId;
 const proxy = getCurrentInstance().proxy;
 const tabType = ref("home");
 const msgCount = ref(0);
+const socket = ref(null);
+const intervalId = ref(null);
+
 const socketInit = () => {
-  window.ws = new WebSocket(
+  socket.value = new WebSocket(
     "ws://" +
       process.env.VUE_APP_IP +
       process.env.VUE_APP_WS_API +
@@ -62,11 +65,16 @@ const socketInit = () => {
     // 'ws://192.168.1.97:8300/webStock/' + window.localStorage.getItem('token')
   );
   //申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
-  window.ws.onopen = function () {
+  socket.value.onopen = function () {
     //当WebSocket创建成功时,触发onopen事件
     console.log("open");
+
+    //立马发送一次心跳
+    sendSocketMsg();
+    // 设置定时器,每30秒执行一次myFunction
+    intervalId.value = setInterval(sendSocketMsg, 1000 * 30);
   };
-  window.ws.onmessage = function (e) {
+  socket.value.onmessage = function (e) {
     //当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
     //在data.value前面插入
     const res = JSON.parse(e.data);
@@ -88,8 +96,16 @@ const socketInit = () => {
         });
       }
     }
-    if (res.type == 2) {
+    if (res.type == 2 && res.count != "0") {
       msgCount.value = res.count * 1;
+      if (res.title) {
+        uni.postMessage({
+          data: {
+            type: "push",
+            content: res.title,
+          },
+        });
+      }
     }
     if (res.type == 3) {
       // ElNotification({
@@ -100,17 +116,45 @@ const socketInit = () => {
       // })
     }
   };
-  window.ws.onclose = function (e) {
+  socket.value.onclose = function (e) {
     //当客户端收到服务端发送的关闭连接请求时,触发onclose事件
     console.log("close");
   };
-  window.ws.onerror = function (e) {
+  socket.value.onerror = function (e) {
     //如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
     console.log(e);
   };
 };
+
+const sendSocketMsg = () => {
+  let jsonData = {
+    cmd: "heartbeat",
+  };
+  socket.value.send(JSON.stringify(jsonData));
+  console.log("Timer executed!");
+};
+
 socketInit();
 
+const getSubscriptCount = () => {
+  setInterval(() => {
+    proxy
+      .post("/flowExample/getToBeProcessedPage", { pageNum: 1, pageSize: 999 })
+      .then((res) => {
+        if (res.data) {
+          let count = res.data.total || -1;
+          uni.postMessage({
+            data: {
+              type: "message",
+              count: count,
+            },
+          });
+        }
+      })
+      .catch((err) => {});
+  }, 1000 * 30);
+};
+getSubscriptCount();
 //判断是否是ios系统
 const isIos = () => {
   const u = navigator.userAgent;

+ 1 - 1
src/views/message/historyMessage.vue

@@ -6,7 +6,7 @@
   <van-pull-refresh v-model="loading" @refresh="onRefresh">
     <div class="list">
       <van-list v-model:loading="loading" :finished="finished" :finished-text="$t('common.noMore')" @load="getList" style="margin-bottom: 60px">
-        <commonList :data="listData" @onClick="toDtl" :config="listConfig">
+        <commonList :data="listData" @onClick="toDtl" :config="listConfig" :showMore="false">
           <template #typeName="{ row }">
             <div>消息通知</div>
           </template>

+ 4 - 1
src/views/message/index.vue

@@ -142,7 +142,10 @@ proxy
   })
   .then((res) => {
     announcementData.value = res.data;
-    announcementTime = timesFun(res.data.rows[0].createTime).timesString;
+    announcementTime =
+      res.data.rows.length > 0
+        ? timesFun(res.data.rows[0].createTime).timesString
+        : "";
     //计算a距离现在的时间
   });
 

+ 0 - 1
src/views/processApproval/index.vue

@@ -21,7 +21,6 @@ const route = useRoute();
 const req = ref({
   pageNum: 1,
   keyword: null,
-  definition: "1",
   tenantId: getUserInfo().tenantId,
 });
 const finished = ref(false);