Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mes-pad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ximai
mes-pad
Commits
a091d076
Commit
a091d076
authored
Mar 20, 2024
by
张海景
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:修改打印的方法
parent
51b1b54a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
57 deletions
+79
-57
App.vue
App.vue
+4
-0
index.vue
pages/index/index.vue
+6
-2
index.vue
pages/mes/prodReport/index.vue
+5
-1
login.vue
pages/sys/login/login.vue
+5
-2
$u.mixin.js
store/$u.mixin.js
+32
-39
index.js
store/index.js
+27
-13
No files found.
App.vue
View file @
a091d076
...
@@ -6,6 +6,10 @@ export default {
...
@@ -6,6 +6,10 @@ export default {
plus
.
screen
.
lockOrientation
(
'landscape-primary'
);
plus
.
screen
.
lockOrientation
(
'landscape-primary'
);
// #endif
// #endif
},
},
//把想要全局的数据放在globalData对象里,globalData是uniapp的不可以自定义命名。
globalData
:{
printSocket
:
null
},
onShow
:
function
()
{},
onShow
:
function
()
{},
onHide
:
function
()
{}
onHide
:
function
()
{}
};
};
...
...
pages/index/index.vue
View file @
a091d076
...
@@ -135,6 +135,7 @@ export default {
...
@@ -135,6 +135,7 @@ export default {
};
};
},
},
created
()
{
created
()
{
this
.
createSocket
()
uni
.
$on
(
'switchTab'
,
(
indexCode
)
=>
{
uni
.
$on
(
'switchTab'
,
(
indexCode
)
=>
{
this
.
tabIndex
=
indexCode
;
this
.
tabIndex
=
indexCode
;
});
});
...
@@ -238,8 +239,11 @@ export default {
...
@@ -238,8 +239,11 @@ export default {
this
.
$u
.
api
.
getUserPrintInfo
().
then
((
res
)
=>
{
this
.
$u
.
api
.
getUserPrintInfo
().
then
((
res
)
=>
{
// console.log(res, 'res888')
// console.log(res, 'res888')
if
(
res
.
code
===
200
)
{
if
(
res
.
code
===
200
)
{
this
.
$u
.
vuex
(
'vuex_printerHostUrl'
,
'http://'
+
res
.
data
.
printerIp
+
':'
+
res
.
data
.
printerPort
);
this
.
$u
.
vuex
(
'vuex_printerInfo'
,
{
this
.
$u
.
vuex
(
'vuex_printerName'
,
res
.
data
.
printerName
);
hostUrl
:
'http://'
+
res
.
data
.
printerIp
+
':'
+
res
.
data
.
printerPort
,
printerName
:
res
.
data
.
printerName
});
this
.
createSocket
()
}
}
});
});
this
.
getPrint
();
this
.
getPrint
();
...
...
pages/mes/prodReport/index.vue
View file @
a091d076
...
@@ -1534,8 +1534,12 @@ export default {
...
@@ -1534,8 +1534,12 @@ export default {
this
.
printTemplateData
.
printTemplate
=
this
.
$refs
.
printTemplateRef
.
tableSelectData
[
0
].
name
this
.
printTemplateData
.
printTemplate
=
this
.
$refs
.
printTemplateRef
.
tableSelectData
[
0
].
name
this
.
printTemplateVisible
=
false
this
.
printTemplateVisible
=
false
},
},
doFeedback
()
{
async
doFeedback
()
{
// this.reset();
// this.reset();
if
(
!
this
.
vuex_printConnect
)
{
this
.
$u
.
toast
(
'打印机连接失败'
);
return
}
this
.
feedbackForms
=
[];
this
.
feedbackForms
=
[];
this
.
tableSelectData
.
forEach
((
item
)
=>
{
this
.
tableSelectData
.
forEach
((
item
)
=>
{
let
defQualify
=
item
.
quantity
-
item
.
quantityQualify
-
item
.
quantityUnqualify
;
let
defQualify
=
item
.
quantity
-
item
.
quantityQualify
-
item
.
quantityUnqualify
;
...
...
pages/sys/login/login.vue
View file @
a091d076
...
@@ -86,8 +86,11 @@
...
@@ -86,8 +86,11 @@
this
.
$u
.
api
.
getUserPrintInfo
().
then
(
res
=>
{
this
.
$u
.
api
.
getUserPrintInfo
().
then
(
res
=>
{
// console.log(res, 'res888')
// console.log(res, 'res888')
if
(
res
.
code
===
200
)
{
if
(
res
.
code
===
200
)
{
this
.
$u
.
vuex
(
'vuex_printerHostUrl'
,
'http://'
+
res
.
data
.
printerIp
+
':'
+
res
.
data
.
printerPort
);
this
.
$u
.
vuex
(
'vuex_printerInfo'
,
{
this
.
$u
.
vuex
(
'vuex_printerName'
,
res
.
data
.
printerName
);
hostUrl
:
'http://'
+
res
.
data
.
printerIp
+
':'
+
res
.
data
.
printerPort
,
printerName
:
res
.
data
.
printerName
});
this
.
createSocket
()
}
}
})
})
setTimeout
(()
=>
{
setTimeout
(()
=>
{
...
...
store/$u.mixin.js
View file @
a091d076
...
@@ -26,8 +26,6 @@ module.exports = {
...
@@ -26,8 +26,6 @@ module.exports = {
},
},
data
()
{
data
()
{
return
{
return
{
pdfSocket
:
null
,
socketConnect
:
false
,
}
}
},
},
computed
:
{
computed
:
{
...
@@ -35,66 +33,61 @@ module.exports = {
...
@@ -35,66 +33,61 @@ module.exports = {
...
mapState
(
$uStoreKey
)
...
mapState
(
$uStoreKey
)
},
},
methods
:
{
methods
:
{
createSocket
(
params
)
{
createSocket
()
{
this
.
pdfSocket
=
io
(
this
.
vuex_printerHostUrl
,
{
this
.
$u
.
vuex
(
'vuex_printConnect'
,
false
)
let
socket
=
io
(
this
.
vuex_printerInfo
.
hostUrl
,
{
transports
:
[
'websocket'
],
transports
:
[
'websocket'
],
auth
:
{
auth
:
{
token
:
'Bearer '
+
this
.
vuex_token
,
// 在此处填入你 client 设置的 token,缺省可留空
token
:
'Bearer '
+
this
.
vuex_token
,
// 在此处填入你 client 设置的 token,缺省可留空
},
},
});
});
this
.
pdfSocket
.
on
(
'connect'
,
()
=>
{
this
.
socketConnect
=
true
;
socket
.
on
(
'connect'
,
()
=>
{
// console.log('连接成功444');
console
.
log
(
'连接成功444'
);
this
.
printPdfSocket
(
params
)
// TODO: Do something for your project
// TODO: Do something for your project
this
.
$u
.
vuex
(
'vuex_printConnect'
,
true
);
// console.log(this.vuex_printConnect, 'vuex_printConnect');
});
});
this
.
pdfSocket
.
on
(
'clients'
,
(
clients
)
=>
{
socket
.
on
(
'clients'
,
(
clients
)
=>
{
this
.
socketConnect
=
clients
;
console
.
log
(
clients
,
'clients'
);
console
.
log
(
clients
,
'clients'
);
});
});
this
.
pdfS
ocket
.
on
(
'printerList'
,
(
printerList
)
=>
{
s
ocket
.
on
(
'printerList'
,
(
printerList
)
=>
{
// globalThis.printerList = printerList;
// globalThis.printerList = printerList;
// console.log(printerList, 'printerList');
// console.log(printerList, 'printerList');
});
});
this
.
pdfSocket
.
on
(
"success"
,
(
res
)
=>
{
socket
.
on
(
'success'
,
(
res
)
=>
{
console
.
log
(
res
,
'打印成功'
)
console
.
log
(
res
,
'打印成功'
);
})
});
this
.
pdfSocket
.
on
(
"error"
,
(
res
)
=>
{
console
.
log
(
res
,
'打印失败'
)
})
this
.
pdfSocket
.
on
(
"disconnect"
,
()
=>
{
this
.
socketConnect
=
false
;
console
.
log
(
'打印机断开'
)
})
setTimeout
(()
=>
{
if
(
!
this
.
socketConnect
)
{
console
.
log
(
'连接失败'
)
this
.
$u
.
toast
(
'打印机连接失败'
)
}
},
1000
)
socket
.
on
(
'error'
,
(
res
)
=>
{
console
.
log
(
res
,
'打印失败'
);
});
socket
.
on
(
'disconnect'
,
()
=>
{
console
.
log
(
'打印机断开'
);
this
.
$u
.
vuex
(
'vuex_printConnect'
,
false
);
});
getApp
().
globalData
.
printSocket
=
socket
},
},
printPdfSocket
(
params
)
{
async
printPdfSocket
(
params
)
{
// console.log(this.pdfSocket, 'pdfSocket')
if
(
!
this
.
vuex_printerInfo
.
hostUrl
)
{
if
(
!
this
.
socketConnect
)
{
this
.
$u
.
toast
(
'请绑定打印机'
);
this
.
createSocket
(
params
)
return
;
return
}
}
this
.
$u
.
api
if
(
this
.
vuex_printConnect
)
{
.
getPrintDown
(
params
)
this
.
$u
.
api
.
getPrintDown
(
params
).
then
((
res
)
=>
{
.
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
if
(
res
.
code
===
200
)
{
this
.
pdf
Socket
.
emit
(
'news'
,
{
getApp
().
globalData
.
print
Socket
.
emit
(
'news'
,
{
client
:
null
,
client
:
null
,
printer
:
this
.
vuex_printerName
,
printer
:
this
.
vuex_printer
Info
.
printer
Name
,
type
:
'url_pdf'
,
type
:
'url_pdf'
,
// pdf_path: 'http://192.168.3.91:8082/static/123.pdf',
// pdf_path: 'http://192.168.3.91:8082/static/123.pdf',
pdf_path
:
res
.
fileUrl
,
pdf_path
:
res
.
fileUrl
,
});
});
}
}
});
});
}
else
{
this
.
$u
.
toast
(
'打印机连接失败'
);
}
}
}
}
}
}
}
\ No newline at end of file
store/index.js
View file @
a091d076
...
@@ -16,8 +16,16 @@ try {
...
@@ -16,8 +16,16 @@ try {
}
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let
saveStateKeys
=
[
'vuex_user'
,
'vuex_token'
,
'vuex_remember'
,
'vuex_locale'
,
'vuex_isAgent'
,
'vuex_workstation'
,
let
saveStateKeys
=
[
'vuex_task'
,
'vuex_printerHostUrl'
,
'vuex_printerName'
'vuex_user'
,
'vuex_token'
,
'vuex_remember'
,
'vuex_locale'
,
'vuex_isAgent'
,
'vuex_workstation'
,
'vuex_task'
,
'vuex_printerInfo'
,
'vuex_printConnect'
,
];
];
// 保存变量到本地存储中
// 保存变量到本地存储中
...
@@ -38,9 +46,11 @@ const store = new Vuex.Store({
...
@@ -38,9 +46,11 @@ const store = new Vuex.Store({
state
:
{
state
:
{
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
vuex_user
:
lifeData
.
vuex_user
?
lifeData
.
vuex_user
:
{
vuex_user
:
lifeData
.
vuex_user
userName
:
'Aidex'
?
lifeData
.
vuex_user
},
:
{
userName
:
'Aidex'
,
},
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
vuex_remember
:
lifeData
.
vuex_remember
?
lifeData
.
vuex_remember
:
''
,
vuex_remember
:
lifeData
.
vuex_remember
?
lifeData
.
vuex_remember
:
''
,
vuex_locale
:
lifeData
.
vuex_locale
?
lifeData
.
vuex_locale
:
''
,
vuex_locale
:
lifeData
.
vuex_locale
?
lifeData
.
vuex_locale
:
''
,
...
@@ -53,10 +63,14 @@ const store = new Vuex.Store({
...
@@ -53,10 +63,14 @@ const store = new Vuex.Store({
vuex_workunit
:
null
,
vuex_workunit
:
null
,
//当前工作站正在进行的生产任务
//当前工作站正在进行的生产任务
vuex_task
:
null
,
vuex_task
:
null
,
// 打印机服务器地址
// 打印机服务器信息
vuex_printerHostUrl
:
lifeData
.
vuex_printerHostUrl
?
lifeData
.
vuex_printerHostUrl
:
''
,
vuex_printerInfo
:
lifeData
.
vuex_printerInfo
// 打印机名称s
?
lifeData
.
vuex_printerInfo
vuex_printerName
:
lifeData
.
vuex_printerName
?
lifeData
.
vuex_printerName
:
''
,
:
''
,
// 存打印状态
vuex_printConnect
:
lifeData
.
vuex_printConnect
?
lifeData
.
vuex_printConnect
:
''
,
// 自定义tabbar数据
// 自定义tabbar数据
// vuex_tabbar: [{
// vuex_tabbar: [{
...
@@ -99,9 +113,9 @@ const store = new Vuex.Store({
...
@@ -99,9 +113,9 @@ const store = new Vuex.Store({
saveKey
=
payload
.
name
;
saveKey
=
payload
.
name
;
}
}
// 保存变量到本地,见顶部函数定义
// 保存变量到本地,见顶部函数定义
saveLifeData
(
saveKey
,
state
[
saveKey
])
saveLifeData
(
saveKey
,
state
[
saveKey
])
;
}
}
,
}
}
,
})
})
;
export
default
store
export
default
store
\ No newline at end of file
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