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
03336ad7
Commit
03336ad7
authored
May 23, 2025
by
qinjianhui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改Promise连接时间
parent
616078f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
61 deletions
+66
-61
src/utils/websocket.ts
+21
-10
src/views/Home.vue
+0
-46
src/views/order/podUs/PodMakeOrder.vue
+45
-5
No files found.
src/utils/websocket.ts
View file @
03336ad7
...
@@ -195,19 +195,30 @@ class Im {
...
@@ -195,19 +195,30 @@ class Im {
options
:
InitOptions
,
options
:
InitOptions
,
msgfunc
?:
MessageCallback
,
msgfunc
?:
MessageCallback
,
openfunc
?:
OpenCallback
,
openfunc
?:
OpenCallback
,
):
void
{
):
Promise
<
void
>
{
const
{
account
,
factoryNo
}
=
options
return
new
Promise
((
resolve
,
reject
)
=>
{
const
socket_connect
=
localStorage
.
getItem
(
'socket_connect'
)
const
{
account
,
factoryNo
}
=
options
if
(
socket_connect
===
'online'
)
return
const
socket_connect
=
localStorage
.
getItem
(
'socket_connect'
)
if
(
socket_connect
===
'online'
)
{
resolve
()
return
}
if
(
!
window
.
WebSocket
)
return
if
(
!
window
.
WebSocket
)
{
reject
(
new
Error
(
'WebSocket is not supported'
))
return
}
this
.
_onMessageCallback
=
msgfunc
this
.
_onMessageCallback
=
msgfunc
this
.
_onOpenCallback
=
openfunc
this
.
_onOpenCallback
=
()
=>
{
openfunc
?.()
resolve
()
}
this
.
_destroyWebSocket
()
this
.
_destroyWebSocket
()
this
.
_wsUrl
=
`
${
getWsUrl
()}
/ws/websocket/
${
factoryNo
}
/
${
account
}
`
this
.
_wsUrl
=
`
${
getWsUrl
()}
/ws/websocket/
${
factoryNo
}
/
${
account
}
`
this
.
_createWebSocket
()
this
.
_createWebSocket
()
})
}
}
send
(
options
:
WebSocketMessage
):
void
{
send
(
options
:
WebSocketMessage
):
void
{
...
...
src/views/Home.vue
View file @
03336ad7
...
@@ -9,52 +9,6 @@
...
@@ -9,52 +9,6 @@
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
NavMenu
from
'@/components/NavMenu.vue'
import
NavMenu
from
'@/components/NavMenu.vue'
import
{
onMounted
}
from
'vue'
import
socket
from
'@/utils/websocket'
import
{
ElMessageBox
}
from
'element-plus'
import
useUserStore
from
'@/store/user'
import
useOrderStore
from
'@/store/order'
import
type
{
WebSocketMessage
}
from
'@/utils/websocket'
onMounted
(()
=>
{
console
.
log
(
'onMounted'
)
const
user
=
useUserStore
().
user
if
(
!
user
)
{
ElMessageBox
.
alert
(
'请先登录'
)
return
}
socket
.
init
(
{
account
:
user
.
account
.
toString
(),
factoryNo
:
user
.
factoryId
.
toString
()
},
messageChange
,
)
})
const
messageChange
=
(
data
:
WebSocketMessage
)
=>
{
if
(
!
data
)
return
const
{
code
,
...
more
}
=
data
if
(
code
===
'POD_PRINT_ORDER'
)
{
try
{
if
(
typeof
more
.
txt
===
'string'
)
{
console
.
log
(
'%conWebSocketMessage'
,
'font-size: 20px; color: red;'
,
JSON
.
parse
(
more
.
txt
),
)
}
}
catch
(
e
)
{
console
.
error
(
e
)
}
setPodBoxList
(
more
)
}
}
const
setPodBoxList
=
(
data
:
WebSocketMessage
)
=>
{
const
obj
=
data
.
txt
if
(
obj
&&
typeof
obj
===
'string'
)
{
console
.
log
(
'obj'
,
obj
)
const
parsedData
=
JSON
.
parse
(
obj
)
console
.
log
(
'parsedData'
,
parsedData
)
useOrderStore
().
setPodBoxList
(
parsedData
)
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.home
{
.home
{
...
...
src/views/order/podUs/PodMakeOrder.vue
View file @
03336ad7
...
@@ -190,6 +190,7 @@
...
@@ -190,6 +190,7 @@
import
{
computed
,
nextTick
,
ref
,
watch
}
from
'vue'
import
{
computed
,
nextTick
,
ref
,
watch
}
from
'vue'
import
useLodop
from
'@/utils/hooks/useLodop'
import
useLodop
from
'@/utils/hooks/useLodop'
import
TableView
from
'@/components/TableView.vue'
import
TableView
from
'@/components/TableView.vue'
import
type
{
WebSocketMessage
}
from
'@/utils/websocket'
import
{
import
{
OrderData
,
OrderData
,
PodMakeOrderData
,
PodMakeOrderData
,
...
@@ -289,15 +290,26 @@ const podBoxList = computed(() => orderStore.podBoxList)
...
@@ -289,15 +290,26 @@ const podBoxList = computed(() => orderStore.podBoxList)
const
coverImage
=
ref
<
string
>
(
''
)
const
coverImage
=
ref
<
string
>
(
''
)
let
currentCode
=
''
let
currentCode
=
''
const
tableRef
=
ref
()
const
tableRef
=
ref
()
watch
(
visible
,
(
value
:
boolean
)
=>
{
watch
(
visible
,
async
(
value
:
boolean
)
=>
{
if
(
value
)
{
if
(
value
)
{
podOrderDetailsData
.
value
=
{}
podOrderDetailsData
.
value
=
{}
currentCode
=
''
currentCode
=
''
if
(
userStore
.
user
?.
factory
.
id
)
{
if
(
userStore
.
user
?.
factory
.
id
)
{
socket
.
send
({
try
{
code
:
'STARTORDER'
,
await
socket
.
init
(
factoryNo
:
userStore
.
user
?.
factory
.
id
,
{
})
account
:
userStore
.
user
?.
account
.
toString
(),
factoryNo
:
userStore
.
user
?.
factory
.
id
.
toString
(),
},
messageChange
,
)
socket
.
send
({
code
:
'STARTORDER'
,
factoryNo
:
userStore
.
user
?.
factory
.
id
,
})
}
catch
(
error
)
{
console
.
error
(
error
)
}
}
}
initOrderDetailBox
()
initOrderDetailBox
()
initPrintDevice
()
initPrintDevice
()
...
@@ -307,6 +319,7 @@ watch(visible, (value: boolean) => {
...
@@ -307,6 +319,7 @@ watch(visible, (value: boolean) => {
code
:
'ENDORDER'
,
code
:
'ENDORDER'
,
factoryNo
:
userStore
.
user
?.
factory
.
id
,
factoryNo
:
userStore
.
user
?.
factory
.
id
,
})
})
socket
.
close
()
}
}
}
}
})
})
...
@@ -385,7 +398,34 @@ const renderItemBox = (bool: boolean) => {
...
@@ -385,7 +398,34 @@ const renderItemBox = (bool: boolean) => {
}
}
renderLock
.
value
=
false
renderLock
.
value
=
false
}
}
const
messageChange
=
(
data
:
WebSocketMessage
)
=>
{
if
(
!
data
)
return
const
{
code
,
...
more
}
=
data
if
(
code
===
'POD_PRINT_ORDER'
)
{
try
{
if
(
typeof
more
.
txt
===
'string'
)
{
console
.
log
(
'%conWebSocketMessage'
,
'font-size: 20px; color: red;'
,
JSON
.
parse
(
more
.
txt
),
)
}
}
catch
(
e
)
{
console
.
error
(
e
)
}
setPodBoxList
(
more
)
}
}
const
setPodBoxList
=
(
data
:
WebSocketMessage
)
=>
{
const
obj
=
data
.
txt
if
(
obj
&&
typeof
obj
===
'string'
)
{
console
.
log
(
'obj'
,
obj
)
const
parsedData
=
JSON
.
parse
(
obj
)
console
.
log
(
'parsedData'
,
parsedData
)
useOrderStore
().
setPodBoxList
(
parsedData
)
}
}
const
initPrintDevice
=
()
=>
{
const
initPrintDevice
=
()
=>
{
const
lodop
=
getCLodop
(
null
,
null
)
const
lodop
=
getCLodop
(
null
,
null
)
if
(
!
lodop
)
return
if
(
!
lodop
)
return
...
...
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