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
7cc15289
Commit
7cc15289
authored
Mar 18, 2024
by
张海景
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:修改pdf打印方法
parent
1e7d8f9b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
424 additions
and
381 deletions
+424
-381
http.api.js
common/http.api.js
+5
-3
index.vue
pages/index/index.vue
+269
-277
login.vue
pages/sys/login/login.vue
+7
-0
test.vue
pages/test/test.vue
+2
-25
$u.mixin.js
store/$u.mixin.js
+57
-0
index.js
store/index.js
+84
-76
No files found.
common/http.api.js
View file @
7cc15289
...
...
@@ -15,6 +15,10 @@ const install = (Vue, vm) => {
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/index'
,
params
),
getUserInfo
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/mobile/user/getUserInfo'
,
params
),
getUserPrintInfo
:
()
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/system/print/printer'
),
getPrintDown
:
(
params
)
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/common/printDown'
,
params
),
login
:
(
params
=
{})
=>
vm
.
$u
.
post
(
config
.
adminPath
+
'/mobile/login/loginByPassword'
,
params
),
sendCode
:
(
params
=
{})
=>
...
...
@@ -108,7 +112,7 @@ const install = (Vue, vm) => {
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/mes/qc/ipqc'
,
params
),
//切换检验单状态
changeState
:
(
params
=
{})
=>
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/mes/qc/ipqc/changeState'
,
params
),
vm
.
$u
.
postJson
(
config
.
adminPath
+
'/mes/qc/ipqc/changeState'
,
params
),
//根据字典类型查询字典数据信息
getDicts
:
(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/system/dict/data/type/'
+
params
),
...
...
@@ -151,8 +155,6 @@ const install = (Vue, vm) => {
config
.
adminPath
+
'/mobile/pro/taskissue/getReserveIssueList'
,
params
),
//人员绑定打印机
getUserPrint
:(
params
=
{})
=>
vm
.
$u
.
get
(
config
.
adminPath
+
'/system/printerConfig/userList'
,
params
),
...
...
pages/index/index.vue
View file @
7cc15289
...
...
@@ -2,54 +2,43 @@
<view
class=
"common-container"
>
<!--
<u-button
@
click=
"handleTest"
>
跳转测试
</u-button>
-->
<view
class=
"header"
>
<image
mode=
"widthFix"
class=
"header-logo"
style=
"width: 100px;margin: 10px auto;display: block;"
src=
"/static/logo.png"
></image>
<image
mode=
"widthFix"
class=
"header-logo"
style=
"width: 100px; margin: 10px auto; display: block"
src=
"/static/logo.png"
></image>
<TabHeader></TabHeader>
<view
class=
"setting-body"
@
click=
"handleUserTaped"
>
<view
class=
"setting-body"
@
click=
"handleUserTaped"
>
<u-icon
name=
"list"
size=
"45"
class=
"setting-icon"
></u-icon>
{{
this
.
vuex_user
.
nickName
}}
</view>
</view>
<view
class=
"common-main"
>
<ProdReport
v-if=
"tabIndex === 'PRO'"
></ProdReport>
<GxContent
v-else-if=
"tabIndex ==='GX'"
></GxContent>
<QcContent
v-else-if=
"tabIndex ==='QC'"
></QcContent>
<GxContent
v-else-if=
"tabIndex ===
'GX'"
></GxContent>
<QcContent
v-else-if=
"tabIndex ===
'QC'"
></QcContent>
<ProContent
v-if=
"tabIndex === 'DV'"
></ProContent>
</view>
<u-modal
width=
"90%"
v-model=
"showWorkstationFlag"
:showConfirmButton=
"false"
:showCancelButton=
"true"
title=
"请选择工作单元"
content=
"操作内容"
>
<u-modal
width=
"90%"
v-model=
"showWorkstationFlag"
:showConfirmButton=
"false"
:showCancelButton=
"true"
title=
"请选择工作单元"
content=
"操作内容"
>
<view
class=
"station_list"
>
<u-empty
text=
"暂无工作单元"
mode=
"list"
v-if=
"workUnitList.length==0"
style=
"margin: 0 auto;display: block;height: 360rpx;padding: 100rpx 0;"
></u-empty>
<u-empty
text=
"暂无工作单元"
mode=
"list"
v-if=
"workUnitList.length == 0"
style=
"margin: 0 auto; display: block; height: 360rpx; padding: 100rpx 0"
></u-empty>
<template
v-else
>
<u-card
class=
"station_card"
:show-foot=
"false"
:title=
"'工作单元'+card.workunitCode"
v-for=
"(card,index) in workUnitList"
>
<u-card
class=
"station_card"
:show-foot=
"false"
:title=
"'工作单元' + card.workunitCode"
v-for=
"(card, index) in workUnitList"
>
<view
class=
"station_card_text"
slot=
"body"
>
{{
'工作单元名称:'
+
card
.
workunitName
}}
<u-button
type=
"primary"
@
click=
"setWorkUnit(card)"
style=
"margin-top: 30rpx;"
>
选择
</u-button>
<u-button
type=
"primary"
@
click=
"setWorkUnit(card)"
style=
"margin-top: 30rpx"
>
选择
</u-button>
</view>
</u-card>
</
template
>
</view>
</u-modal>
<u-modal
v-model=
"showLogoutMenu"
:showConfirmButton=
false
:showCancelButton=
"true"
width=
"600px"
title=
"请选择操作"
>
<u-modal
v-model=
"showLogoutMenu"
:showConfirmButton=
"false"
:showCancelButton=
"true"
width=
"600px"
title=
"请选择操作"
>
<view
class=
"logoutmenu"
>
<u-button
shape=
"circle"
class=
"menu_button"
@
click=
""
type=
"primary"
>
更改密码
</u-button>
<u-button
shape=
"circle"
class=
"menu_button"
@
click=
"handleCommand('workunit')"
type=
"warning"
>
切换工作站
</u-button>
<u-button
shape=
"circle"
class=
"menu_button"
@
click=
"handleCommand('print')"
type=
"error"
>
默认打印机
</u-button>
<u-button
shape=
"circle"
class=
"menu_button"
@
click=
"handleCommand('workunit')"
type=
"warning"
>
切换工作站
</u-button>
<u-button
shape=
"circle"
class=
"menu_button"
@
click=
"handleCommand('print')"
type=
"error"
>
默认打印机
</u-button>
<u-button
shape=
"circle"
class=
"menu_button"
@
click=
"handleCommand('exit')"
type=
"error"
>
退出登录
</u-button>
</view>
</u-modal>
<!-- <u-modal
<!-- <u-modal
title="领料申请"
@confirm="materialRequestSave()"
show-cancel-button
...
...
@@ -92,7 +81,8 @@
<uni-td
align=
"center"
>
{{ line.connectionType }}
</uni-td>
<uni-td
align=
"center"
>
<view
class=
"uni-group"
>
<button
class=
"uni-button"
size=
"mini"
type=
"primary"
@
click=
"materialRequestFormShow(line)"
>
绑定
</button>
<button
class=
"uni-button"
v-if=
"line.userPrinterStatus == '1'"
size=
"mini"
type=
"primary"
>
已绑定
</button>
<button
class=
"uni-button"
v-else
size=
"mini"
type=
"primary"
@
click=
"materialRequestFormShow(line)"
>
绑定
</button>
</view>
</uni-td>
</uni-tr>
...
...
@@ -100,223 +90,226 @@
</scroll-view>
</view>
</u-modal>
</view>
</template>
<
script
>
import
TabHeader
from
"./TabHeader.vue"
import
ProContent
from
"../mes/pro/index.vue"
import
GxContent
from
"../mes/gx/index.vue"
import
QcContent
from
"../mes/qc/index.vue"
import
ProdReport
from
"../mes/prodReport/index.vue"
import
DictData
from
'@/components/DictData'
import
UButton
from
'../../uview-ui/components/u-button/u-button.vue'
import
TabHeader
from
'./TabHeader.vue'
;
import
ProContent
from
'../mes/pro/index.vue'
;
import
GxContent
from
'../mes/gx/index.vue'
;
import
QcContent
from
'../mes/qc/index.vue'
;
import
ProdReport
from
'../mes/prodReport/index.vue'
;
import
DictData
from
'@/components/DictData'
;
import
UButton
from
'../../uview-ui/components/u-button/u-button.vue'
;
export
default
{
name
:
'HomePage'
,
components
:
{
TabHeader
,
ProContent
,
GxContent
,
QcContent
,
ProdReport
,
UButton
},
data
()
{
return
{
tabIndex
:
'PRO'
,
showWorkstationFlag
:
false
,
showPrintFlag
:
false
,
showLogoutMenu
:
false
,
activeProcess
:
null
,
loading
:
false
,
userInfo
:
{
nickName
:
'张三'
,
avatar
:
require
(
'@/static/images/head.png'
)
},
materialRequestArrays
:
[],
processList
:
[],
//工序清单
workstationList
:
[],
//工作站清单
workUnitList
:
[],
//工作站清单
curTaskInfo
:
{},
//打印机的
screenHeight
:
768
,
currentFlag
:
0
};
},
created
()
{
uni
.
$on
(
'switchTab'
,
(
indexCode
)
=>
{
this
.
tabIndex
=
indexCode
;
});
uni
.
$on
(
'changeWorkunit'
,
(
indexCode
)
=>
{
this
.
handleCommand
(
'workunit'
);
});
export
default
{
name
:
'HomePage'
,
components
:
{
TabHeader
,
ProContent
,
GxContent
,
QcContent
,
ProdReport
,
UButton
this
.
checkWorkstation
();
this
.
getWorkUnitList
();
},
destroyed
()
{
uni
.
$off
(
'switchTab'
);
uni
.
$off
(
'changeWorkunit'
);
},
methods
:
{
handleTest
()
{
uni
.
navigateTo
({
url
:
'/pages/test/test'
});
},
data
()
{
return
{
tabIndex
:
"PRO"
,
showWorkstationFlag
:
false
,
showPrintFlag
:
false
,
showLogoutMenu
:
false
,
activeProcess
:
null
,
loading
:
false
,
userInfo
:
{
nickName
:
'张三'
,
avatar
:
require
(
"@/static/images/head.png"
),
},
materialRequestArrays
:
[],
processList
:
[],
//工序清单
workstationList
:
[],
//工作站清单
workUnitList
:[],
//工作站清单
curTaskInfo
:
{},
//打印机的
screenHeight
:
768
,
currentFlag
:
0
}
//用户部分点击
handleUserTaped
()
{
console
.
log
(
'TAPED'
);
// this.$refs.menu_dialog.open();
this
.
showLogoutMenu
=
true
;
},
created
()
{
uni
.
$on
(
'switchTab'
,
(
indexCode
)
=>
{
this
.
tabIndex
=
indexCode
;
})
uni
.
$on
(
'changeWorkunit'
,
(
indexCode
)
=>
{
this
.
handleCommand
(
'workunit'
);
})
this
.
checkWorkstation
();
this
.
getWorkUnitList
();
//检查工作站设置情况
checkWorkstation
()
{
if
(
this
.
vuex_workunit
==
null
)
{
this
.
showWorkstationFlag
=
true
;
this
.
$u
.
toast
(
'请设置当前触控屏的工作单元!'
);
}
},
destroyed
()
{
uni
.
$off
(
'switchTab'
);
uni
.
$off
(
'changeWorkunit'
);
//获取工序清单
getProcessList
()
{
this
.
$u
.
api
.
getProcessList
({}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
processList
=
res
.
data
;
this
.
activeProcess
=
res
.
data
[
0
].
processCode
;
this
.
getWorkstationList
({
index
:
0
});
}
else
{
this
.
$u
.
toast
(
'获取工序清单异常'
+
res
.
msg
);
}
});
},
methods
:
{
handleTest
()
{
uni
.
navigateTo
({
url
:
'/pages/test/test'
//获取工作站清单
getWorkstationList
(
item
)
{
this
.
currentFlag
=
item
.
index
;
this
.
activeProcess
=
this
.
processList
[
item
.
index
].
processCode
;
this
.
$u
.
api
.
getWorkstationList
({
processCode
:
this
.
activeProcess
})
},
//用户部分点击
handleUserTaped
()
{
console
.
log
(
"TAPED"
)
// this.$refs.menu_dialog.open();
this
.
showLogoutMenu
=
true
;
},
//检查工作站设置情况
checkWorkstation
()
{
if
(
this
.
vuex_workunit
==
null
)
{
this
.
showWorkstationFlag
=
true
;
this
.
$u
.
toast
(
"请设置当前触控屏的工作单元!"
);
}
},
//获取工序清单
getProcessList
()
{
this
.
$u
.
api
.
getProcessList
({}).
then
(
res
=>
{
.
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
processList
=
res
.
data
;
this
.
activeProcess
=
res
.
data
[
0
].
processCode
;
this
.
getWorkstationList
({
index
:
0
});
this
.
workstationList
=
res
.
data
;
}
else
{
this
.
$u
.
toast
(
"获取工序清单异常"
+
res
.
msg
);
this
.
$u
.
toast
(
'获取工作站清单异常'
+
res
.
msg
);
}
});
},
//获取工作站清单
getWorkstationList
(
item
)
{
this
.
currentFlag
=
item
.
index
;
this
.
activeProcess
=
this
.
processList
[
item
.
index
].
processCode
;
this
.
$u
.
api
.
getWorkstationList
({
processCode
:
this
.
activeProcess
}).
then
(
res
=>
{
},
getWorkUnitList
(
item
)
{
this
.
$u
.
api
.
getWorkUnitList
({}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
workUnitList
=
res
.
rows
;
}
else
{
this
.
$u
.
toast
(
'获取工作单元清单异常'
+
res
.
msg
);
}
});
},
//设置当前触控屏的工作站
setWorkUnit
(
station
)
{
this
.
$u
.
vuex
(
'vuex_workunit'
,
station
);
this
.
showWorkstationFlag
=
false
;
uni
.
$emit
(
'switchWorkunit'
,
station
);
},
materialRequestFormShow
(
row
)
{
this
.
$u
.
api
.
addUserPrint
({
userId
:
this
.
vuex_user
.
userId
,
userName
:
this
.
vuex_user
.
userName
,
nickName
:
this
.
vuex_user
.
nickName
,
printerId
:
row
.
printerId
,
printerName
:
row
.
printerName
,
printerIp
:
row
.
printerIp
,
printerPort
:
row
.
printerPort
,
printerType
:
row
.
printerType
,
printerPlace
:
row
.
printerPlace
,
printerModel
:
row
.
printerModel
,
printerUrl
:
row
.
printerUrl
,
printerStatus
:
row
.
status
,
brand
:
row
.
brand
,
connectionType
:
row
.
connectionType
,
enableFlag
:
row
.
enableFlag
})
.
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
workstationList
=
res
.
data
;
}
else
{
this
.
$u
.
toast
(
"获取工作站清单异常"
+
res
.
msg
);
if
(
res
.
msg
===
'操作成功'
)
{
this
.
$u
.
toast
(
'绑定成功'
);
this
.
$u
.
api
.
getUserPrintInfo
().
then
((
res
)
=>
{
// console.log(res, 'res888')
if
(
res
.
code
===
200
)
{
this
.
$u
.
vuex
(
'vuex_printerHostUrl'
,
'http://'
+
res
.
data
.
printerIp
+
':'
+
res
.
data
.
printerPort
);
this
.
$u
.
vuex
(
'vuex_printerName'
,
res
.
data
.
printerName
);
}
});
this
.
getPrint
();
}
else
{
this
.
$u
.
toast
(
res
.
msg
);
}
}
});
},
getWorkUnitList
(
item
)
{
this
.
$u
.
api
.
getWorkUnitList
({
}).
then
(
res
=>
{
},
handleCommand
(
command
)
{
if
(
command
===
'exit'
)
{
this
.
loading
=
true
;
this
.
$u
.
api
.
logout
().
then
((
res
)
=>
{
this
.
loading
=
false
;
if
(
res
.
msg
)
{
this
.
$u
.
toast
(
res
.
msg
);
}
if
(
res
.
code
===
200
)
{
this
.
workUnitList
=
res
.
rows
;
}
else
{
this
.
$u
.
toast
(
"获取工作单元清单异常"
+
res
.
msg
);
setTimeout
(()
=>
{
DictData
.
logout
();
uni
.
reLaunch
({
url
:
'/pages/sys/login/login'
});
},
500
);
}
});
},
//设置当前触控屏的工作站
setWorkUnit
(
station
)
{
this
.
$u
.
vuex
(
'vuex_workunit'
,
station
);
this
.
showWorkstationFlag
=
false
;
uni
.
$emit
(
'switchWorkunit'
,
station
);
},
materialRequestFormShow
(
row
){
this
.
$u
.
api
.
addUserPrint
({
userId
:
this
.
vuex_user
.
userId
,
userName
:
this
.
vuex_user
.
userName
,
nickName
:
this
.
vuex_user
.
nickName
,
printerId
:
row
.
printerId
,
printerName
:
row
.
printerName
,
printerIp
:
row
.
printerIp
,
printerPort
:
row
.
printerPort
,
printerType
:
row
.
printerType
,
printerPlace
:
row
.
printerPlace
,
printerModel
:
row
.
printerModel
,
printerUrl
:
row
.
printerUrl
,
printerStatus
:
row
.
status
,
brand
:
row
.
brand
,
connectionType
:
row
.
connectionType
,
enableFlag
:
row
.
enableFlag
,
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
if
(
res
.
msg
===
'操作成功'
)
{
this
.
$u
.
toast
(
'绑定成功'
);
this
.
getPrint
();
}
else
{
this
.
$u
.
toast
(
res
.
msg
);
}
}
});
},
handleCommand
(
command
)
{
if
(
command
===
'exit'
)
{
this
.
loading
=
true
;
this
.
$u
.
api
.
logout
().
then
(
res
=>
{
this
.
loading
=
false
;
if
(
res
.
msg
)
{
this
.
$u
.
toast
(
res
.
msg
);
}
if
(
res
.
code
===
200
)
{
setTimeout
(()
=>
{
DictData
.
logout
();
uni
.
reLaunch
({
url
:
'/pages/sys/login/login'
});
},
500
);
}
})
}
else
if
(
command
==
'workunit'
)
{
this
.
showLogoutMenu
=
false
;
this
.
showWorkstationFlag
=
true
;
}
else
if
(
command
==
'print'
){
this
.
showPrintFlag
=
true
;
this
.
getPrint
();
}
},
getPrint
(){
this
.
$u
.
api
.
getUserPrint
().
then
((
res
)
=>
{
if
(
res
.
code
==
200
){
this
.
materialRequestArrays
=
res
.
rows
}
});
}
},
}
else
if
(
command
==
'workunit'
)
{
this
.
showLogoutMenu
=
false
;
this
.
showWorkstationFlag
=
true
;
}
else
if
(
command
==
'print'
)
{
this
.
showPrintFlag
=
true
;
this
.
getPrint
();
}
},
getPrint
()
{
this
.
$u
.
api
.
getUserPrint
().
then
((
res
)
=>
{
if
(
res
.
code
==
200
)
{
this
.
materialRequestArrays
=
res
.
rows
;
}
});
}
}
};
</
script
>
<
style
>
.common-container
{
width
:
100vw
;
height
:
100vh
;
display
:
flex
;
}
.common-container
{
width
:
100vw
;
height
:
100vh
;
display
:
flex
;
}
.common-head
{
height
:
40px
;
background-color
:
rgb
(
3
,
26
,
60
);
display
:
flex
;
align-items
:
center
;
padding
:
0
15px
;
box-sizing
:
border-box
;
}
.common-head
{
height
:
40px
;
background-color
:
rgb
(
3
,
26
,
60
);
display
:
flex
;
align-items
:
center
;
padding
:
0
15px
;
box-sizing
:
border-box
;
}
.header
{
width
:
110px
;
background-color
:
#132138
;
color
:
aliceblue
;
font-size
:
25px
;
font-family
:
华文楷体
;
line-height
:
80
rpx
;
height
:
inherit
;
.header
{
width
:
110px
;
background-color
:
#132138
;
color
:
aliceblue
;
font-size
:
25px
;
font-family
:
华文楷体
;
line-height
:
80
rpx
;
height
:
inherit
;
.header-logo
{
width
:
200
rpx
;
...
...
@@ -324,83 +317,82 @@
margin
:
40
rpx
auto
;
display
:
block
;
}
}
}
.header
.divItem
{
height
:
100%
;
align-items
:
center
;
}
.header
.divItem
{
height
:
100%
;
align-items
:
center
;
}
.header
.workstation
{
text-align
:
center
;
flex-grow
:
1
;
}
.header
.workstation
{
text-align
:
center
;
flex-grow
:
1
;
}
.header
.user
{
width
:
30%
;
}
.header
.user
{
width
:
30%
;
}
.header
.user
.user-icon
{
float
:
right
;
}
.header
.user
.user-icon
{
float
:
right
;
}
img
{
width
:
40px
;
height
:
40px
;
border-radius
:
20px
;
margin-left
:
10px
;
}
img
{
width
:
40px
;
height
:
40px
;
border-radius
:
20px
;
margin-left
:
10px
;
}
.header
.user
.user-text
{
float
:
right
;
}
.header
.user
.user-text
{
float
:
right
;
}
.logoutmenu
{
width
:
100%
;
display
:
flex
;
justify-content
:
center
;
}
.logoutmenu
{
width
:
100%
;
display
:
flex
;
justify-content
:
center
;
}
.menu_button
{
width
:
100px
;
margin
:
10px
;
}
.menu_button
{
width
:
100px
;
margin
:
10px
;
}
.station_modal
{
}
.station_modal
{
}
.station_list
{
display
:
flex
;
flex-wrap
:
wrap
;
}
.station_list
{
display
:
fle
x
;
flex-wrap
:
wrap
;
}
.station_card
{
width
:
250p
x
;
height
:
150px
;
}
.station_card
{
width
:
250px
;
height
:
150px
;
}
.common-main
{
flex
:
1
;
height
:
100%
;
padding
:
6px
6px
6px
0
;
margin
:
0
;
width
:
100%
;
overflow
:
auto
;
background-image
:
linear-gradient
(
to
top
right
,
rgb
(
19
26
56
),
rgb
(
33
64
128
));
}
.common-main
{
flex
:
1
;
height
:
100%
;
padding
:
6px
6px
6px
0
;
margin
:
0
;
width
:
100%
;
overflow
:
auto
;
background-image
:
linear-gradient
(
to
top
right
,
rgb
(
19
26
56
),
rgb
(
33
64
128
));
}
.setting-body
{
position
:
absolute
;
bottom
:
20
rpx
;
width
:
200
rpx
;
margin
:
0
auto
;
font-size
:
36
rpx
;
font-weight
:
initial
;
text-align
:
center
;
.setting-body
{
position
:
absolute
;
bottom
:
20
rpx
;
width
:
200
rpx
;
margin
:
0
auto
;
font-size
:
36
rpx
;
font-weight
:
initial
;
text-align
:
center
;
.setting-icon
{
margin
:
10
rpx
10
rpx
;
}
}
}
</
style
>
pages/sys/login/login.vue
View file @
7cc15289
...
...
@@ -83,6 +83,13 @@
this
.
$u
.
toast
(
res
.
msg
);
}
if
(
res
.
code
==
'200'
)
{
this
.
$u
.
api
.
getUserPrintInfo
().
then
(
res
=>
{
// console.log(res, 'res888')
if
(
res
.
code
===
200
)
{
this
.
$u
.
vuex
(
'vuex_printerHostUrl'
,
'http://'
+
res
.
data
.
printerIp
+
':'
+
res
.
data
.
printerPort
);
this
.
$u
.
vuex
(
'vuex_printerName'
,
res
.
data
.
printerName
);
}
})
setTimeout
(()
=>
{
uni
.
reLaunch
({
url
:
'/pages/index/index'
...
...
pages/test/test.vue
View file @
7cc15289
<
template
>
<view>
<u-button
@
click=
"exportPDF"
>
预览pdf
</u-button>
<u-button
@
click=
"
handlePrin
t"
>
打印pdf
</u-button>
<u-button
@
click=
"
printPdfSocke
t"
>
打印pdf
</u-button>
</view>
</
template
>
<
script
>
import
io
from
'@hyoga/uni-socket.io'
;
// import { SOCKET_IO_CLIENT, OPTIONS } from '@/uni_modules/bunny-socket-io-client';
import
uButton
from
'../../uview-ui/components/u-button/u-button.vue'
;
export
default
{
components
:
{
uButton
},
data
()
{
return
{
socket
:
{},
url
:
'http://192.168.3.91:8082/static/123.pdf'
};
},
created
()
{
this
.
socket
=
io
(
'http://192.168.21.104:17521'
,
{
transports
:
[
'websocket'
],
auth
:
{
token
:
'Bearer '
+
this
.
vuex_token
// 在此处填入你 client 设置的 token,缺省可留空
}
});
this
.
socket
.
on
(
'connect'
,
()
=>
{
globalThis
.
connect
=
true
;
console
.
log
(
'连接成功444'
);
// TODO: Do something for your project
});
this
.
socket
.
on
(
'clients'
,
(
clients
)
=>
{
globalThis
.
clients
=
clients
;
console
.
log
(
clients
,
'clients'
);
});
this
.
socket
.
on
(
'printerList'
,
(
printerList
)
=>
{
globalThis
.
printerList
=
printerList
;
console
.
log
(
printerList
,
'printerList'
);
});
},
methods
:
{
handlePrint
()
{
console
.
log
(
this
.
socket
,
'this.$socket'
);
...
...
store/$u.mixin.js
View file @
7cc15289
import
{
mapState
}
from
'vuex'
import
store
from
"@/store"
import
io
from
'@hyoga/uni-socket.io'
;
// 尝试将用户在根目录中的store/index.js的vuex的state变量,全部加载到全局变量中
let
$uStoreKey
=
[];
...
...
@@ -20,8 +21,64 @@ module.exports = {
})
}
},
data
()
{
return
{
pdfSocket
:
null
}
},
computed
:
{
// 将vuex的state中的所有变量,解构到全局混入的mixin中
...
mapState
(
$uStoreKey
)
},
methods
:
{
createSocket
()
{
this
.
pdfSocket
=
io
(
this
.
vuex_printerHostUrl
,
{
transports
:
[
'websocket'
],
auth
:
{
token
:
'Bearer '
+
this
.
vuex_token
,
// 在此处填入你 client 设置的 token,缺省可留空
},
});
this
.
pdfSocket
.
on
(
'connect'
,
()
=>
{
globalThis
.
connect
=
true
;
console
.
log
(
'连接成功444'
);
// TODO: Do something for your project
});
this
.
pdfSocket
.
on
(
'clients'
,
(
clients
)
=>
{
globalThis
.
clients
=
clients
;
console
.
log
(
clients
,
'clients'
);
});
this
.
pdfSocket
.
on
(
'printerList'
,
(
printerList
)
=>
{
globalThis
.
printerList
=
printerList
;
console
.
log
(
printerList
,
'printerList'
);
});
},
printPdfSocket
()
{
console
.
log
(
this
.
pdfSocket
,
'pdfSocket'
)
if
(
!
this
.
pdfSocket
)
{
this
.
createSocket
()
}
this
.
$u
.
api
.
getPrintDown
({
reportName
:
'mysql:qrcode-100*100'
,
values
:
{
detail
:
[
{
qrcode
:
'qqq'
,
},
],
},
})
.
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
pdfSocket
.
emit
(
'news'
,
{
client
:
null
,
printer
:
this
.
vuex_printerName
,
type
:
'url_pdf'
,
// pdf_path: 'http://192.168.3.91:8082/static/123.pdf',
pdf_path
:
res
.
fileUrl
,
});
}
});
}
}
}
\ No newline at end of file
store/index.js
View file @
7cc15289
...
...
@@ -8,92 +8,100 @@ Vue.use(Vuex)
let
lifeData
=
{};
try
{
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
lifeData
=
uni
.
getStorageSync
(
'lifeData'
);
}
catch
(
e
)
{
try
{
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
lifeData
=
uni
.
getStorageSync
(
'lifeData'
);
}
catch
(
e
)
{
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let
saveStateKeys
=
[
'vuex_user'
,
'vuex_token'
,
'vuex_remember'
,
'vuex_locale'
,
'vuex_isAgent'
,
'vuex_workstation'
,
'vuex_task'
];
let
saveStateKeys
=
[
'vuex_user'
,
'vuex_token'
,
'vuex_remember'
,
'vuex_locale'
,
'vuex_isAgent'
,
'vuex_workstation'
,
'vuex_task'
,
'vuex_printerHostUrl'
,
'vuex_printerName'
];
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
){
// 判断变量名是否在需要存储的数组中
if
(
saveStateKeys
.
indexOf
(
key
)
!=
-
1
)
{
// 获取本地存储的lifeData对象,将变量添加到对象中
let
tmp
=
uni
.
getStorageSync
(
'lifeData'
);
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
tmp
=
tmp
?
tmp
:
{};
tmp
[
key
]
=
value
;
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
uni
.
setStorageSync
(
'lifeData'
,
tmp
);
}
const
saveLifeData
=
function
(
key
,
value
)
{
// 判断变量名是否在需要存储的数组中
if
(
saveStateKeys
.
indexOf
(
key
)
!=
-
1
)
{
// 获取本地存储的lifeData对象,将变量添加到对象中
let
tmp
=
uni
.
getStorageSync
(
'lifeData'
);
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
tmp
=
tmp
?
tmp
:
{};
tmp
[
key
]
=
value
;
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
uni
.
setStorageSync
(
'lifeData'
,
tmp
);
}
}
// 简化 vuex 操作,文档:https://uviewui.com/components/vuexDetail.html
const
store
=
new
Vuex
.
Store
({
state
:
{
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
vuex_user
:
lifeData
.
vuex_user
?
lifeData
.
vuex_user
:
{
userName
:
'Aidex'
},
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
vuex_remember
:
lifeData
.
vuex_remember
?
lifeData
.
vuex_remember
:
''
,
vuex_locale
:
lifeData
.
vuex_locale
?
lifeData
.
vuex_locale
:
''
,
vuex_isAgent
:
lifeData
.
vuex_isAgent
?
lifeData
.
vuex_isAgent
:
''
,
state
:
{
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然
vuex_user
:
lifeData
.
vuex_user
?
lifeData
.
vuex_user
:
{
userName
:
'Aidex'
},
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
vuex_remember
:
lifeData
.
vuex_remember
?
lifeData
.
vuex_remember
:
''
,
vuex_locale
:
lifeData
.
vuex_locale
?
lifeData
.
vuex_locale
:
''
,
vuex_isAgent
:
lifeData
.
vuex_isAgent
?
lifeData
.
vuex_isAgent
:
''
,
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
vuex_config
:
config
,
//当前设备绑定的工作站
vuex_workstation
:
null
,
vuex_workunit
:
null
,
//当前工作站正在进行的生产任务
vuex_task
:
null
,
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
vuex_config
:
config
,
//当前设备绑定的工作站
vuex_workstation
:
null
,
vuex_workunit
:
null
,
//当前工作站正在进行的生产任务
vuex_task
:
null
,
// 打印机服务器地址
vuex_printerHostUrl
:
lifeData
.
vuex_printerHostUrl
?
lifeData
.
vuex_printerHostUrl
:
''
,
// 打印机名称s
vuex_printerName
:
lifeData
.
vuex_printerName
?
lifeData
.
vuex_printerName
:
''
,
// 自定义tabbar数据
// vuex_tabbar: [{
// iconPath: "/static/uview/example/component.png",
// selectedIconPath: "/static/uview/example/component_select.png",
// text: '组件',
// pagePath: '/pages/example/components'
// },
// {
// iconPath: "/static/uview/example/js.png",
// selectedIconPath: "/static/uview/example/js_select.png",
// text: '工具',
// midButton: true,
// pagePath: '/pages/example/js'
// },
// {
// iconPath: "/static/uview/example/template.png",
// selectedIconPath: "/static/uview/example/template_select.png",
// text: '模板',
// pagePath: '/pages/example/template'
// }
// ]
},
mutations
:
{
$uStore
(
state
,
payload
)
{
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
let
nameArr
=
payload
.
name
.
split
(
'.'
);
let
saveKey
=
''
;
let
len
=
nameArr
.
length
;
if
(
len
>=
2
)
{
let
obj
=
state
[
nameArr
[
0
]];
for
(
let
i
=
1
;
i
<
len
-
1
;
i
++
)
{
obj
=
obj
[
nameArr
[
i
]];
}
obj
[
nameArr
[
len
-
1
]]
=
payload
.
value
;
saveKey
=
nameArr
[
0
];
}
else
{
// 单层级变量,在state就是一个普通变量的情况
state
[
payload
.
name
]
=
payload
.
value
;
saveKey
=
payload
.
name
;
}
// 保存变量到本地,见顶部函数定义
saveLifeData
(
saveKey
,
state
[
saveKey
])
}
}
// 自定义tabbar数据
// vuex_tabbar: [{
// iconPath: "/static/uview/example/component.png",
// selectedIconPath: "/static/uview/example/component_select.png",
// text: '组件',
// pagePath: '/pages/example/components'
// },
// {
// iconPath: "/static/uview/example/js.png",
// selectedIconPath: "/static/uview/example/js_select.png",
// text: '工具',
// midButton: true,
// pagePath: '/pages/example/js'
// },
// {
// iconPath: "/static/uview/example/template.png",
// selectedIconPath: "/static/uview/example/template_select.png",
// text: '模板',
// pagePath: '/pages/example/template'
// }
// ]
},
mutations
:
{
$uStore
(
state
,
payload
)
{
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
let
nameArr
=
payload
.
name
.
split
(
'.'
);
let
saveKey
=
''
;
let
len
=
nameArr
.
length
;
if
(
len
>=
2
)
{
let
obj
=
state
[
nameArr
[
0
]];
for
(
let
i
=
1
;
i
<
len
-
1
;
i
++
)
{
obj
=
obj
[
nameArr
[
i
]];
}
obj
[
nameArr
[
len
-
1
]]
=
payload
.
value
;
saveKey
=
nameArr
[
0
];
}
else
{
// 单层级变量,在state就是一个普通变量的情况
state
[
payload
.
name
]
=
payload
.
value
;
saveKey
=
payload
.
name
;
}
// 保存变量到本地,见顶部函数定义
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