lanjianrong преди 4 години
родител
ревизия
e69509c12e
променени са 3 файла, в които са добавени 27 реда и са изтрити 16 реда
  1. 12 2
      src/pages/Product/Cloud/index.jsx
  2. 0 1
      src/pages/Product/Lock/LockStore/index.jsx
  3. 15 13
      src/utils/ws.ts

+ 12 - 2
src/pages/Product/Cloud/index.jsx

@@ -52,6 +52,14 @@ const Cloud = () => {
         }
       })
     }
+    if (!province?.length) {
+      dispatch({
+        type: 'cloud/fetchProvince',
+        payload: {
+          projectPype: roadpricingEnum[columnStateType]
+        }
+      })
+    }
   }, [])
 
   // 展示DrawerClient
@@ -78,7 +86,8 @@ const Cloud = () => {
       render: (text, record) => (
         <span
           onClick={() => showDrawerRoadpricing(record.ssoId)}
-          className="text-primary cursor-pointer hover:text-[#967bbd]">
+          className="text-primary cursor-pointer hover:text-[#967bbd]"
+        >
           {text}
         </span>
       )
@@ -185,7 +194,8 @@ const Cloud = () => {
                       )
                   )}
                 </div>
-              }>
+              }
+            >
               {record.all_online_times}
             </Tooltip>
           )

+ 0 - 1
src/pages/Product/Lock/LockStore/index.jsx

@@ -260,7 +260,6 @@ const LockStore = ({ prodList = [], dispatch, shouldUpdate }) => {
     {
       title: '销售时间',
       dataIndex: 'sellTime',
-      valueType: 'date',
       key: 'sellTime',
       width: 90
     },

+ 15 - 13
src/utils/ws.ts

@@ -20,7 +20,9 @@ export enum CmdType {
   /** @name 在线员工列表 */
   OnlineBook = 12,
   /** @name 员工工作状态 */
-  WorkStatus = 14
+  WorkStatus = 14,
+  /** @name 强制退出 */
+  OutLine = 15
 }
 
 interface Options {
@@ -103,7 +105,7 @@ class Ws {
 
       // 监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
       window.addEventListener('beforeunload', () => {
-        this.wsIns?.close()
+        this.disconnect()
       })
     } catch (error) {
       if (isDevMode()) {
@@ -120,11 +122,12 @@ class Ws {
     }
   }
 
-  /** 断线重连 */
+  /** 断开连接 */
   public disconnect() {
     if (this.wsIns?.readyState === ReadyState.Open) {
       this.isLock = true
-      this.wsIns.close()
+      // this.wsIns.close()
+      this.sendMessage({ cmd: CmdType.OutLine, userid: this.uid })
     }
   }
 
@@ -146,17 +149,16 @@ class Ws {
   // 重连
   private reconnect(): void {
     if (
-      this.isLock ||
-      (this.opts?.reconnectLimit && this.reconnectLimit > this.opts?.reconnectLimit)
+      !this.isLock &&
+      !(this.opts?.reconnectLimit && this.reconnectLimit > this.opts?.reconnectLimit)
     ) {
-      return
+      this.reconnectLimit += 1
+      this.timer && clearTimeout(this.timer)
+      this.timer = setTimeout(() => {
+        this.connectWs()
+        this.isLock = false
+      }, 4000)
     }
-    this.reconnectLimit += 1
-    this.timer && clearTimeout(this.timer)
-    this.timer = setTimeout(() => {
-      this.connectWs()
-      this.isLock = false
-    }, 4000)
   }
 }
 export function onMessage(msg: MessageType) {