Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
factory_front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinjianhui
factory_front
Commits
057619e3
Commit
057619e3
authored
Sep 03, 2025
by
wusiyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增超级播种墙配货
parent
2f701631
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
242 additions
and
8 deletions
+242
-8
src/store/cnSuperOrder.ts
+0
-2
src/utils/cnSuperWebsocket.ts
+233
-0
src/views/order/podCN/SuperPodMakeOrder.vue
+5
-4
src/views/order/podCN/index.vue
+4
-2
No files found.
src/store/cnSuperOrder.ts
View file @
057619e3
...
...
@@ -25,8 +25,6 @@ const useOrderStore = defineStore('cnSuperOrder', {
box
?:
number
data
?:
OrderData
})
{
console
.
log
(
'???????????????????'
)
const
{
factoryNo
,
boxList
,
box
,
data
}
=
content
if
(
Array
.
isArray
(
boxList
))
{
...
...
src/utils/cnSuperWebsocket.ts
0 → 100644
View file @
057619e3
import
{
getWsUrl
}
from
'../api/axios'
import
useOrderStore
from
'../store/cnSuperOrder'
interface
NotificationOptions
{
body
:
string
icon
:
string
data
:
string
requireInteraction
:
boolean
}
export
interface
WebSocketMessage
{
code
?:
string
content
?:
string
type
?:
string
data
?:
unknown
[
key
:
string
]:
string
|
unknown
|
undefined
}
interface
InitOptions
{
account
:
string
factoryNo
:
string
}
type
MessageCallback
=
(
data
:
WebSocketMessage
,
sendSystemMessage
:
(
msg
:
string
)
=>
void
,
)
=>
void
type
OpenCallback
=
()
=>
void
function
sendSystemMessage
(
msg
:
string
):
void
{
if
(
window
.
Notification
&&
Notification
.
permission
===
'granted'
)
{
const
notificationOptions
:
NotificationOptions
=
{
body
:
msg
,
icon
:
'./favicon.ico'
,
data
:
'I like peas.'
,
requireInteraction
:
true
,
}
const
n
=
new
Notification
(
'消息通知'
,
notificationOptions
)
n
.
onclick
=
(
event
:
Event
)
=>
{
event
.
preventDefault
()
window
.
open
(
'/home'
,
'_blank'
)
}
setTimeout
(()
=>
{
n
.
close
()
},
10000
)
}
}
const
showReconnectingMsg
=
():
void
=>
{
ElMessageBox
.
alert
(
'消息服务已断开,正在重新连接,请稍候'
,
{
showClose
:
true
,
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
,
})
}
class
Im
{
private
socket
:
WebSocket
|
null
=
null
private
_wsUrl
:
string
=
''
// private userId: string = ''
private
_onMessageCallback
?:
MessageCallback
private
_onOpenCallback
?:
OpenCallback
private
_heartbeatTimer
:
number
|
null
=
null
private
_heartbeatTimeoutTimer
:
number
|
null
=
null
private
_reconnectingTimer
:
number
|
null
=
null
private
num
:
number
=
0
constructor
()
{
this
.
_onWsOpen
=
this
.
_onWsOpen
.
bind
(
this
)
this
.
_onWsMessage
=
this
.
_onWsMessage
.
bind
(
this
)
this
.
_onWsClose
=
this
.
_onWsClose
.
bind
(
this
)
this
.
_onWsError
=
this
.
_onWsError
.
bind
(
this
)
}
private
_onWsOpen
():
void
{
console
.
log
(
'服务器连接成功'
)
localStorage
.
setItem
(
'socket_connect'
,
'online'
)
this
.
_onOpenCallback
?.()
this
.
_startHeartbeat
()
}
private
_onWsMessage
(
event
:
MessageEvent
):
void
{
let
data
:
WebSocketMessage
=
{}
if
(
typeof
event
.
data
===
'string'
)
{
try
{
data
=
JSON
.
parse
(
event
.
data
)
}
catch
(
error
)
{
data
=
{}
}
}
this
.
_onHeartbeatMessage
()
this
.
_onMessageCallback
?.(
data
,
sendSystemMessage
)
}
private
_onWsClose
():
void
{
console
.
log
(
'服务器关闭'
)
this
.
_destroyWebSocket
(
true
)
}
private
_onWsError
():
void
{
console
.
log
(
'连接出错'
)
this
.
_destroyWebSocket
(
true
)
}
private
_sendHeartbeat
():
void
{
if
(
!
this
.
socket
)
return
this
.
send
({
code
:
'HEALTH'
})
if
(
this
.
_heartbeatTimeoutTimer
)
{
window
.
clearTimeout
(
this
.
_heartbeatTimeoutTimer
)
}
this
.
_heartbeatTimeoutTimer
=
window
.
setTimeout
(()
=>
{
this
.
_destroyWebSocket
(
true
)
},
5
*
1000
)
}
private
_onHeartbeatMessage
():
void
{
console
.
log
(
'心跳'
)
useOrderStore
().
setSocketConnect
(
'online'
)
if
(
this
.
_heartbeatTimeoutTimer
)
{
window
.
clearTimeout
(
this
.
_heartbeatTimeoutTimer
)
}
}
private
_startHeartbeat
():
void
{
this
.
_stopHeartbeat
()
this
.
_sendHeartbeat
()
this
.
_heartbeatTimer
=
window
.
setInterval
(
()
=>
this
.
_sendHeartbeat
(),
10
*
1000
,
)
}
private
_stopHeartbeat
():
void
{
if
(
this
.
_heartbeatTimer
)
{
window
.
clearInterval
(
this
.
_heartbeatTimer
)
}
if
(
this
.
_heartbeatTimeoutTimer
)
{
window
.
clearTimeout
(
this
.
_heartbeatTimeoutTimer
)
}
}
private
_scheduleReconnect
():
void
{
if
(
!
this
.
num
)
this
.
num
=
0
this
.
num
++
if
(
this
.
num
>
5
)
{
ElMessageBox
.
alert
(
'尝试重连消息服务失败,请刷新重试'
)
return
}
showReconnectingMsg
()
this
.
_reconnectingTimer
=
window
.
setTimeout
(()
=>
{
this
.
_createWebSocket
()
},
2000
)
}
private
_destroyWebSocket
(
reconnect
?:
boolean
):
void
{
if
(
!
this
.
socket
)
return
this
.
_stopHeartbeat
()
if
(
this
.
_reconnectingTimer
)
{
window
.
clearTimeout
(
this
.
_reconnectingTimer
)
}
this
.
socket
.
removeEventListener
(
'open'
,
this
.
_onWsOpen
)
this
.
socket
.
removeEventListener
(
'message'
,
this
.
_onWsMessage
)
this
.
socket
.
removeEventListener
(
'close'
,
this
.
_onWsClose
)
this
.
socket
.
removeEventListener
(
'error'
,
this
.
_onWsError
)
this
.
socket
.
close
(
1000
)
this
.
socket
=
null
localStorage
.
removeItem
(
'socket_connect'
)
useOrderStore
().
setSocketConnect
(
'offline'
)
if
(
reconnect
)
this
.
_scheduleReconnect
()
}
private
_createWebSocket
():
void
{
if
(
!
this
.
_wsUrl
)
return
const
socket
=
new
WebSocket
(
this
.
_wsUrl
)
socket
.
addEventListener
(
'open'
,
this
.
_onWsOpen
)
socket
.
addEventListener
(
'message'
,
this
.
_onWsMessage
)
socket
.
addEventListener
(
'close'
,
this
.
_onWsClose
)
socket
.
addEventListener
(
'error'
,
this
.
_onWsError
)
this
.
socket
=
socket
}
init
(
options
:
InitOptions
,
msgfunc
?:
MessageCallback
,
openfunc
?:
OpenCallback
,
):
Promise
<
void
>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
{
account
,
factoryNo
}
=
options
const
socket_connect
=
localStorage
.
getItem
(
'socket_connect'
)
if
(
socket_connect
===
'online'
)
{
resolve
()
return
}
if
(
!
window
.
WebSocket
)
{
reject
(
new
Error
(
'WebSocket is not supported'
))
return
}
this
.
_onMessageCallback
=
msgfunc
this
.
_onOpenCallback
=
()
=>
{
openfunc
?.()
resolve
()
}
this
.
_destroyWebSocket
()
this
.
_wsUrl
=
`
${
getWsUrl
()}
/ws/websocket/
${
factoryNo
}
/
${
account
}
`
this
.
_createWebSocket
()
})
}
send
(
options
:
WebSocketMessage
):
void
{
this
.
socket
?.
send
(
JSON
.
stringify
(
options
))
}
close
():
void
{
this
.
_destroyWebSocket
()
}
}
export
default
new
Im
()
src/views/order/podCN/SuperPodMakeOrder.vue
View file @
057619e3
...
...
@@ -206,7 +206,7 @@
import
{
computed
,
nextTick
,
ref
,
watch
}
from
'vue'
import
useLodop
from
'@/utils/hooks/useLodop'
import
TableView
from
'@/components/TableView.vue'
import
type
{
WebSocketMessage
}
from
'@/utils/
w
ebsocket'
import
type
{
WebSocketMessage
}
from
'@/utils/
cnSuperW
ebsocket'
import
{
OrderData
,
PodMakeOrderData
,
...
...
@@ -223,9 +223,10 @@ import {
}
from
'@/api/podCnOrder'
import
useUserStore
from
'@/store/user'
import
{
Check
}
from
'@element-plus/icons-vue'
import
socket
from
'@/utils/cnWebsocket'
import
socket
from
'@/utils/cn
Super
Websocket'
const
{
getCLodop
}
=
useLodop
()
const
userStore
=
useUserStore
()
const
props
=
defineProps
<
{
modelValue
:
boolean
...
...
@@ -451,7 +452,7 @@ const messageChange = (data: WebSocketMessage) => {
if
(
!
data
)
return
const
{
code
,
...
more
}
=
data
if
(
code
===
'FACTORY_POD_CN_PRINT_ORDER'
)
{
if
(
code
===
'
SUPER_
FACTORY_POD_CN_PRINT_ORDER'
)
{
try
{
if
(
typeof
more
.
txt
===
'string'
)
{
console
.
log
(
...
...
@@ -534,7 +535,7 @@ const handleSearch = () => {
getPackingData
(
code
)
}
}
const
userStore
=
useUserStore
()
const
getPackingData
=
async
(
code
:
string
)
=>
{
const
loading
=
ElLoading
.
service
({
fullscreen
:
true
,
...
...
src/views/order/podCN/index.vue
View file @
057619e3
...
...
@@ -2351,6 +2351,7 @@ import RightClickMenu from '@/components/RightClickMenu.vue'
import
ResultInfo
from
'./components/ResultInfo.vue'
import
{
isArray
,
isString
}
from
'@/utils/validate'
import
platformJson
from
'../../../json/platform.json'
import
useUserStore
from
'@/store/user'
import
BigNumber
from
'bignumber.js'
import
{
useRouter
,
...
...
@@ -2372,8 +2373,9 @@ declare global {
}
}
const
isSuperFactory
:
boolean
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
||
'{
}
'
)
.
factory
.
dropShipping
const
userStore
=
useUserStore
()
const
isSuperFactory
:
boolean
=
userStore
.
user
?.
factory
.
dropShipping
||
false
const
tabsNav
=
ref
<
Tab
[]
>
()
const
isAuto
=
ref
(
true
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment