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
c5768522
Commit
c5768522
authored
Apr 19, 2024
by
张海景
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:修改上下机和投料、反冲料加上半屏扫码功能
parent
c8a659d8
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
656 additions
and
99 deletions
+656
-99
AppScan.vue
components/AppScan/AppScan.vue
+166
-0
appScanMixins.js
components/AppScan/appScanMixins.js
+50
-0
index.scss
components/AppScan/lib/index.scss
+76
-0
permisionCameraAuth.js
components/AppScan/lib/permisionCameraAuth.js
+95
-0
dModelList.vue
pages/mes/prodReport/components/dModelList.vue
+17
-16
index.vue
pages/mes/prodReport/index.vue
+132
-83
scan.vue
pages/test/scan/scan.vue
+120
-0
No files found.
components/AppScan/AppScan.vue
0 → 100644
View file @
c5768522
<
template
>
<view>
<!-- 扫码页面 -->
<view
style=
"position:fixed;width: 500px; height: 100%; bottom: 0;"
></view>
</view>
</
template
>
<
script
>
export
default
{
name
:
'AppScan'
,
data
()
{
return
{
barcode
:
null
,
flash
:
false
,
tip
:
'将二维码放入框中,即可自动扫描'
,
}
},
onShow
()
{
// 页面展示时,重新启动扫描检测
if
(
this
.
barcode
)
{
console
.
log
(
'onShow'
)
// this.barcode.start()
}
},
async
mounted
()
{
try
{
// plus.navigator.setFullscreen(true); //全屏
// 创建相机
let
currentWebview
=
this
.
$mp
.
page
.
$getAppWebview
();
this
.
createBarcode
(
currentWebview
)
// this.createTipInfoView(currentWebview)
this
.
createFlashBarView
(
currentWebview
)
}
catch
(
error
){
console
.
log
(
error
)
}
},
methods
:
{
/**
* 创建二维码
* @param {Object} currentWebview
*/
createBarcode
(
currentWebview
)
{
if
(
!
this
.
barcode
)
{
//条码类型常量数组,默认情况支持QR、EAN13、EAN8类型。 通过此参数可设置扫码识别支持的条码类型(注意:设置支持的条码类型越多,扫描识别速度可能将会降低)
this
.
barcode
=
plus
.
barcode
.
create
(
'barcode'
,
[
plus
.
barcode
.
QR
,
plus
.
barcode
.
CODABAR
,
plus
.
barcode
.
UPCA
,
plus
.
barcode
.
CODE39
,
plus
.
barcode
.
CODE93
,
plus
.
barcode
.
CODE128
],
{
top
:
'38px'
,
left
:
'0px'
,
height
:
'87%'
,
width
:
'500px'
,
position
:
'absolute'
,
background
:
'#808080'
,
frameColor
:
'#fff'
,
scanbarColor
:
'#FFCC33'
,
filters
:[
0
,
7
,
5
,
8
,
9
,
10
]
});
this
.
barcode
.
onmarked
=
this
.
onmarked
;
this
.
barcode
.
setFlash
(
this
.
flash
);
//此处未演示扫码成功回调的地址设置,实际请参考HTML5Plus API自行处理
//注意扫码区域需为正方形,否则影响扫码识别率
currentWebview
.
append
(
this
.
barcode
);
}
console
.
log
(
'createBarcode'
)
this
.
barcode
.
start
()
},
closed
()
{
this
.
barcode
.
close
()
},
/**
* 创建提示信息
* @param {Object} currentWebview
*/
createTipInfoView
(
currentWebview
)
{
const
content
=
new
plus
.
nativeObj
.
View
(
'content'
,
{
top
:
'0px'
,
left
:
'0px'
,
height
:
'100%'
,
width
:
'100%'
},
[{
tag
:
'font'
,
id
:
'scanTips'
,
text
:
this
.
tip
,
textStyles
:
{
size
:
'14px'
,
color
:
'#ffffff'
,
whiteSpace
:
'normal'
},
position
:
{
top
:
'90px'
,
left
:
'10%'
,
width
:
'80%'
,
height
:
'wrap_content'
}
}]);
currentWebview
.
append
(
content
);
},
// 创建 开关灯按钮
createFlashBarView
(
currentWebview
)
{
const
openImg
=
this
.
crtFlashImg
(
'static/yellow-scanBar.png'
)
const
closeImg
=
this
.
crtFlashImg
(
'static/scanBar.png'
)
const
scanBarVew
=
new
plus
.
nativeObj
.
View
(
'scanBarVew'
,
{
top
:
'70%'
,
left
:
'15%'
,
height
:
'16%'
,
width
:
'20%'
,
},
closeImg
);
scanBarVew
.
interceptTouchEvent
(
true
);
currentWebview
.
append
(
scanBarVew
);
scanBarVew
.
addEventListener
(
"click"
,
(
e
)
=>
{
//点亮手电筒
this
.
flash
=
!
this
.
flash
;
if
(
this
.
flash
)
{
scanBarVew
.
draw
(
openImg
);
}
else
{
scanBarVew
.
draw
(
closeImg
)
}
if
(
this
.
barcode
)
{
this
.
barcode
.
setFlash
(
this
.
flash
);
}
},
false
)
},
crtFlashImg
(
imgsrc
)
{
return
[{
tag
:
'img'
,
id
:
'scanBar'
,
src
:
imgsrc
,
position
:
{
width
:
'28%'
,
left
:
'36%'
,
height
:
'30%'
}
},
{
tag
:
'font'
,
id
:
'font'
,
text
:
'轻触照亮'
,
textStyles
:
{
size
:
'12px'
,
color
:
'#ffffff'
},
position
:
{
width
:
'80%'
,
left
:
'10%'
}
}]
},
// 扫码成功回调
onmarked
(
type
,
result
)
{
this
.
barcode
.
cancel
()
this
.
$emit
(
'getCode'
,
result
)
// 3秒后再次执行扫码
setTimeout
(()
=>
{
console
.
log
(
'onmarked'
)
this
.
barcode
.
start
()
},
2000
)
}
},
}
</
script
>
<
style
scoped
lang=
"scss"
></
style
>
components/AppScan/appScanMixins.js
0 → 100644
View file @
c5768522
import
permision
from
"./lib/permisionCameraAuth.js"
;
export
default
{
data
()
{
return
{
isIos
:
false
,
}
},
onLoad
()
{
// #ifdef APP-PLUS
this
.
isIos
=
(
plus
.
os
.
name
==
"iOS"
)
// #endif
},
methods
:
{
// 查询相机权限
async
getCameraAuth
()
{
let
bol
=
false
if
(
this
.
isIos
)
{
bol
=
permision
.
judgeIosPermissionCamera
()
}
else
{
var
result
=
await
permision
.
requestAndroidPermission
(
'android.permission.CAMERA'
)
if
(
result
==
1
)
{
bol
=
true
}
}
return
bol
},
// app拒绝授权相机
refusedCameraAuth
()
{
uni
.
showModal
({
title
:
""
,
content
:
"您已禁止授权应用相机权限,如需使用请在设置中授权"
,
cancelText
:
"取消"
,
confirmText
:
"前往授权"
,
confirmColor
:
"#02A8E6"
,
showCancel
:
true
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
this
.
openCameraAuth
()
}
},
});
},
// app去授权
openCameraAuth
()
{
permision
.
gotoAppPermissionSetting
()
},
},
}
\ No newline at end of file
components/AppScan/lib/index.scss
0 → 100644
View file @
c5768522
.wx-scan-content
{
height
:
270px
;
position
:
relative
;
.cover-view-box
{
width
:
650rpx
;
height
:
150px
;
position
:
relative
;
z-index
:
5
;
margin
:
100rpx
auto
60rpx
;
// 四个角边框
.scan-border
{
background-color
:
#fff
;
position
:
absolute
;
}
.scan-verLine
{
width
:
3px
;
height
:
13px
;
}
.scan-horLine
{
width
:
13px
;
height
:
3px
;
}
// 左上角
.scan-left-top
{
left
:
0
;
top
:
0
;
}
// 左下角
.scan-left-bottom
{
left
:
0
;
bottom
:
0
;
}
// 右上角
.scan-right-top
{
right
:
0
;
top
:
0
;
}
// 右下角
.scan-right-bottom
{
right
:
0
;
bottom
:
0
;
}
// 相机中上下移动的线条
.scan-animation
{
width
:
240px
;
height
:
2px
;
margin
:
0
auto
;
background-color
:
#fff
;
border-radius
:
50%
;
}
}
.scan-cameraCon
{
position
:
absolute
;
top
:
0
;
left
:
0
;
z-index
:
3
;
width
:
100%
;
height
:
100%
;
.scan-camera
{
width
:
100%
!
important
;
height
:
100%
!
important
;
position
:
relative
;
}
}
}
\ No newline at end of file
components/AppScan/lib/permisionCameraAuth.js
0 → 100644
View file @
c5768522
/**
* 本模块封装了Android、iOS的相机权限判断、打开应用权限设置界面
*/
var
isIos
// #ifdef APP-PLUS
isIos
=
(
plus
.
os
.
name
==
"iOS"
)
// #endif
// Android权限查询
function
requestAndroidPermission
(
permissionID
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
plus
.
android
.
requestPermissions
(
[
permissionID
],
// 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
function
(
resultObj
)
{
var
result
=
0
;
for
(
var
i
=
0
;
i
<
resultObj
.
granted
.
length
;
i
++
)
{
var
grantedPermission
=
resultObj
.
granted
[
i
];
console
.
log
(
'已获取的权限:'
+
grantedPermission
);
result
=
1
}
for
(
var
i
=
0
;
i
<
resultObj
.
deniedPresent
.
length
;
i
++
)
{
var
deniedPresentPermission
=
resultObj
.
deniedPresent
[
i
];
console
.
log
(
'拒绝本次申请的权限:'
+
deniedPresentPermission
);
result
=
0
}
for
(
var
i
=
0
;
i
<
resultObj
.
deniedAlways
.
length
;
i
++
)
{
var
deniedAlwaysPermission
=
resultObj
.
deniedAlways
[
i
];
console
.
log
(
'永久拒绝申请的权限:'
+
deniedAlwaysPermission
);
result
=
-
1
}
resolve
(
result
);
},
function
(
error
)
{
console
.
log
(
'申请权限错误:'
+
error
.
code
+
" = "
+
error
.
message
);
resolve
({
code
:
error
.
code
,
message
:
error
.
message
});
}
);
});
}
// ios判断相机权限是否开启
function
judgeIosPermissionCamera
()
{
var
result
=
false
;
var
AVCaptureDevice
=
plus
.
ios
.
import
(
"AVCaptureDevice"
);
var
authStatus
=
AVCaptureDevice
.
authorizationStatusForMediaType
(
'vide'
);
console
.
log
(
"authStatus:"
+
authStatus
);
if
(
authStatus
==
3
)
{
result
=
true
;
console
.
log
(
"相机权限已经开启"
);
}
else
{
console
.
log
(
"相机权限没有开启"
);
}
plus
.
ios
.
deleteObject
(
AVCaptureDevice
);
return
result
;
}
// 跳转到应用的权限页面
function
gotoAppPermissionSetting
()
{
if
(
isIos
)
{
var
UIApplication
=
plus
.
ios
.
import
(
"UIApplication"
);
var
application2
=
UIApplication
.
sharedApplication
();
var
NSURL2
=
plus
.
ios
.
import
(
"NSURL"
);
var
setting2
=
NSURL2
.
URLWithString
(
"app-settings:"
);
application2
.
openURL
(
setting2
);
plus
.
ios
.
deleteObject
(
setting2
);
plus
.
ios
.
deleteObject
(
NSURL2
);
plus
.
ios
.
deleteObject
(
application2
);
}
else
{
// console.log(plus.device.vendor);
var
Intent
=
plus
.
android
.
importClass
(
"android.content.Intent"
);
var
Settings
=
plus
.
android
.
importClass
(
"android.provider.Settings"
);
var
Uri
=
plus
.
android
.
importClass
(
"android.net.Uri"
);
var
mainActivity
=
plus
.
android
.
runtimeMainActivity
();
var
intent
=
new
Intent
();
intent
.
setAction
(
Settings
.
ACTION_APPLICATION_DETAILS_SETTINGS
);
var
uri
=
Uri
.
fromParts
(
"package"
,
mainActivity
.
getPackageName
(),
null
);
intent
.
setData
(
uri
);
mainActivity
.
startActivity
(
intent
);
}
}
module
.
exports
=
{
requestAndroidPermission
:
requestAndroidPermission
,
judgeIosPermissionCamera
:
judgeIosPermissionCamera
,
gotoAppPermissionSetting
:
gotoAppPermissionSetting
,
}
\ No newline at end of file
pages/mes/prodReport/components/dModelList.vue
View file @
c5768522
...
...
@@ -38,28 +38,28 @@ export default {
{
name
:
'toolCode'
,
label
:
'刀模版sn码'
,
width
:
13
0
width
:
8
0
},
{
name
:
'toolName'
,
label
:
'刀模版名称'
,
width
:
13
0
width
:
8
0
},
{
name
:
'itemName'
,
label
:
'物料名称'
,
width
:
13
0
width
:
8
0
},
{
name
:
'upDate'
,
label
:
'上机时间'
,
width
:
1
4
0
width
:
1
3
0
},
{
name
:
'downDate'
,
label
:
'下机时间'
,
width
:
1
4
0
width
:
1
3
0
}
],
};
...
...
@@ -127,17 +127,18 @@ export default {
}
},
handleScancode
(
type
)
{
uni
.
scanCode
({
success
:
(
res
)
=>
{
console
.
log
(
res
,
'res7778888'
);
this
.
$u
.
api
.
dModel
.
tmToolMachinesScancode
({
type
,
sn
:
res
.
result
}).
then
((
res
)
=>
{
// console.log(res, 'res333')
if
(
res
.
code
===
200
)
{
this
.
$emit
(
'action'
);
}
});
}
});
this
.
$emit
(
'scan'
,
type
)
// uni.scanCode({
// success: (res) => {
// console.log(res, 'res7778888');
// this.$u.api.dModel.tmToolMachinesScancode({ type, sn: res.result }).then((res) => {
// // console.log(res, 'res333')
// if (res.code === 200) {
// this.$emit('action');
// }
// });
// }
// });
},
toggleAllSelection
(
checked
,
arr
)
{
this
.
tableSelectData
=
arr
;
...
...
pages/mes/prodReport/index.vue
View file @
c5768522
...
...
@@ -251,27 +251,24 @@
<u-modal
title=
"刀模版上下机"
@
confirm=
"knifeTemp()"
show-cancel-button
:show-confirm-button=
"!!knifeTempType"
@
confirm=
"handleSubmitConfirmlKnifeTemp"
@
cancel=
"handleSubmitCancelKnifeTemp"
:confirmText=
"knifeTempCancelText"
:title-style=
"
{ 'background-color': '#1E3770', color: '#FFFFFF', 'line-height': '37px', 'padding-top': '0px' }"
v-model="knifeTempVisible"
width="1600rpx"
width="100%"
:content-style="{height: '87vh'}"
>
<!--
<u-form
label-width=
"130px"
:model=
"knifeTempSearch"
:rules=
"rules"
>
<u-row>
<u-col
span=
"6"
>
<u-form-item
label=
"扫描刃模版条码"
prop=
"quantity"
>
<u-input
v-model=
"knifeTempSearch.knifeTempCode"
></u-input>
</u-form-item>
</u-col>
<u-col
span=
"6"
>
<u-form-item
label=
"扫描库位条码"
prop=
"nickName"
>
<u-input
v-model=
"knifeTempSearch.locationCode"
></u-input>
</u-form-item>
</u-col>
</u-row>
</u-form>
-->
<dModelList
:data=
"dModelData"
@
action=
"upDownGetList"
/>
<view
style=
"display: flex;"
>
<view
style=
"width:520px;"
>
<!-- #ifdef APP-PLUS -->
<app-scan
v-if=
"knifeTempAppScanVisible"
ref=
"appScan"
@
getCode=
"handleUpdateKnifeTemp"
></app-scan>
<!-- #endif -->
</view>
<dModelList
:data=
"dModelData"
@
action=
"upDownGetList"
@
scan=
"handleAppScanKnifeTemp"
/>
</view>
</u-modal>
<!-- //生产报工报工人员 -->
<u-modal
...
...
@@ -358,14 +355,21 @@
</u-modal>
<u-modal
title=
"投料校验"
@
c
onfirm=
"feedingInspectionScan()
"
@
c
ancel=
"$refs.appScan.closed() , feedingInspectionVisible = false
"
show-cancel-button
confirmText=
"继续扫码"
cancelText=
"关闭"
:show-confirm-button=
"false"
:title-style=
"
{ 'background-color': '#1E3770', color: '#FFFFFF', 'line-height': '37px', 'padding-top': '0px' }"
v-model="feedingInspectionVisible"
width="1300rpx"
width="100%"
:content-style="{height: '87vh'}"
>
<view
style=
"display: flex;"
>
<view
style=
"width:520px;"
v-if=
"feedingInspectionVisible"
>
<!-- #ifdef APP-PLUS -->
<app-scan
ref=
"appScan"
@
getCode=
"feedingInspectionScan"
></app-scan>
<!-- #endif -->
</view>
<view
class=
"list-bar"
>
<scroll-view
scroll-y=
"true"
scroll-x=
"true"
class=
"scroll-list"
:style=
"
{ height: this.screenHeight - 280 + 'px' }">
<uni-table
border
stripe
:loading=
"loading"
emptyText=
"未查询到数据"
>
...
...
@@ -392,25 +396,34 @@
</uni-table>
</scroll-view>
</view>
</view>
</u-modal>
<u-modal
title=
"反冲料登记"
@
c
onfirm=
"recoilMaterialScan()
"
@
c
ancel=
"$refs.appScan.closed() , recoilMaterialVisible = false
"
show-cancel-button
confirmText=
"继续扫码"
cancelText=
"关闭"
:show-confirm-button=
"false"
:title-style=
"
{ 'background-color': '#1E3770', color: '#FFFFFF', 'line-height': '37px', 'padding-top': '0px' }"
v-model="recoilMaterialVisible"
width="1300rpx"
width="100%"
:content-style="{height: '87vh'}"
>
<view
style=
"display: flex;"
>
<view
style=
"width:520px;"
v-if=
"recoilMaterialVisible"
>
<!-- #ifdef APP-PLUS -->
<app-scan
ref=
"appScan"
@
getCode=
"recoilMaterialScan"
></app-scan>
<!-- #endif -->
</view>
<view
class=
"list-bar"
>
<scroll-view
scroll-y=
"true"
class=
"scroll-list"
:style=
"
{ height: this.screenHeight - 280 + 'px' }">
<uni-table
ref=
"qcTable"
border
stripe
:loading=
"loading"
emptyText=
"未查询到数据"
>
<uni-tr>
<uni-th
width=
"100px"
align=
"center"
>
操作
</uni-th>
<uni-th
width=
"110px"
align=
"center"
>
产品物料编码
</uni-th>
<uni-th
width=
"
11
0px"
align=
"center"
>
产品物料名称
</uni-th>
<uni-th
width=
"
30
0px"
align=
"center"
>
产品物料名称
</uni-th>
<uni-th
width=
"110px"
align=
"center"
>
批次号
</uni-th>
</uni-tr>
<uni-tr
v-for=
"(line, index) in recoilMaterialList"
:key=
"index"
>
...
...
@@ -426,6 +439,7 @@
</uni-table>
</scroll-view>
</view>
</view>
</u-modal>
<u-modal
...
...
@@ -711,19 +725,25 @@ import userPersonnel from './components/userPersonnel.vue';
import
printTemplate
from
'./components/printTemplate.vue'
;
import
workunitList
from
'./components/workunitList.vue'
;
import
UButton
from
'../../../uview-ui/components/u-button/u-button.vue'
;
import
cameraAuthMixin
from
'@/components/AppScan/appScanMixins.js'
;
import
{
handleError
}
from
'vue'
;
import
AppScan
from
'../../../components/AppScan/AppScan.vue'
;
export
default
{
name
:
'ProdReport'
,
mixins
:
[
cameraAuthMixin
],
components
:
{
SearchInput
,
dModelList
,
userPersonnel
,
printTemplate
,
UButton
,
workunitList
workunitList
,
AppScan
},
data
()
{
return
{
knifeTempAppScanVisible
:
false
,
knifeTempType
:
null
,
workunitVisible
:
false
,
jobAssignmentVisible
:
false
,
jobAssignmentForm
:
{
...
...
@@ -765,6 +785,7 @@ export default {
form
:
{},
feedbackForm
:
{},
tableData
:
[],
knifeTempCancelText
:
'确认'
,
knifeTempVisible
:
false
,
knifeTempSearch
:
{
knifeTempCode
:
''
,
...
...
@@ -1129,6 +1150,35 @@ export default {
uni
.
$off
(
'taskStatusChanged'
);
},
methods
:
{
handleSubmitConfirmlKnifeTemp
()
{
this
.
knifeTempVisible
=
true
this
.
$refs
.
appScan
.
closed
()
this
.
knifeTempAppScanVisible
=
false
this
.
knifeTempCancelText
=
'确认'
this
.
knifeTempType
=
null
},
handleSubmitCancelKnifeTemp
()
{
this
.
knifeTempVisible
=
true
this
.
$refs
.
appScan
.
closed
()
this
.
knifeTempAppScanVisible
=
false
this
.
knifeTempCancelText
=
'取消'
},
handleAppScanKnifeTemp
(
type
)
{
this
.
knifeTempAppScanVisible
=
true
this
.
knifeTempType
=
type
this
.
knifeTempCancelText
=
type
===
'1'
?
'关闭上机扫描'
:
'关闭下机扫描'
this
.
getPemissionScan
()
},
handleUpdateKnifeTemp
(
code
)
{
console
.
log
(
this
.
knifeTempType
,
code
,
'code---handleUpdateKnifeTemp'
)
this
.
$u
.
api
.
dModel
.
tmToolMachinesScancode
({
type
:
this
.
knifeTempType
,
sn
:
code
}).
then
((
res
)
=>
{
console
.
log
(
res
,
'res333'
)
if
(
res
.
code
===
200
)
{
this
.
$u
.
toast
(
this
.
knifeTempType
===
'1'
?
'上机成功'
:
'下机成功'
)
this
.
upDownGetList
()
}
});
},
handleChangeTabPro
(
index
,
row
)
{
row
.
currentTabPro
=
index
;
},
...
...
@@ -1930,36 +1980,41 @@ export default {
},
feedingInspectionShow
()
{
this
.
feedingInspectionVisible
=
true
;
this
.
getPemissionScan
()
this
.
feedingInspectionLoadAndScan
();
},
feedingInspectionLoadAndScan
(
bool
)
{
const
t
=
this
;
const
taskInfo
=
this
.
tableSelectData
[
0
];
this
.
$u
.
api
.
listFeedingInspection
({
taskId
:
taskInfo
.
taskId
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
t
.
feedingInspectionList
=
res
.
data
;
t
his
.
feedingInspectionList
=
res
.
data
;
if
(
bool
)
{
t
.
$u
.
toast
(
'保存成功'
);
t
his
.
$u
.
toast
(
'保存成功'
);
}
let
timer
=
setTimeout
(()
=>
{
t
.
feedingInspectionScan
();
},
1000
);
}
});
},
feedingInspectionScan
()
{
cons
t
t
=
this
;
feedingInspectionScan
(
barNumber
)
{
cons
ole
.
log
(
barNumber
,
'-----barNumberfeedingInspectionScan'
)
const
taskInfo
=
this
.
tableSelectData
[
0
];
uni
.
scanCode
({
success
:
function
(
res
)
{
t
.
$u
.
api
.
validateFeedingInspection
({
plnr
:
res
.
result
,
taskId
:
taskInfo
.
taskId
}).
then
((
res2
)
=>
{
if
(
res2
.
code
===
200
)
{
t
.
feedingInspectionLoadAndScan
(
true
);
this
.
$u
.
api
.
validateFeedingInspection
({
plnr
:
barNumber
,
taskId
:
taskInfo
.
taskId
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
feedingInspectionLoadAndScan
(
true
);
}
});
},
async
getPemissionScan
()
{
/* #ifdef APP-PLUS */
if
(
!
uni
.
getStorageSync
(
'iosCameraAuth'
)
&&
this
.
isIos
)
{
uni
.
setStorageSync
(
'iosCameraAuth'
,
true
)
}
else
{
let
bol
=
await
this
.
getCameraAuth
()
if
(
!
bol
)
{
this
.
refusedCameraAuth
()
return
}
});
this
.
feedingInspectionVisible
=
true
;
}
/* #endif */
},
validateFeedingInspection
(
line
)
{
const
t
=
this
;
...
...
@@ -1976,6 +2031,7 @@ export default {
},
recoilMaterialShow
()
{
this
.
recoilMaterialVisible
=
true
;
this
.
getPemissionScan
()
this
.
recoilMaterialLoadAndScan
();
},
recoilMaterialLoadAndScan
(
bool
)
{
...
...
@@ -1987,25 +2043,18 @@ export default {
if
(
bool
)
{
t
.
$u
.
toast
(
'保存成功'
);
}
let
timer
=
setTimeout
(()
=>
{
t
.
recoilMaterialScan
();
},
1000
);
}
});
},
recoilMaterialScan
()
{
cons
t
t
=
this
;
recoilMaterialScan
(
barNumber
)
{
cons
ole
.
log
(
barNumber
,
'-----barNumberrecoilMaterialScan'
)
const
taskInfo
=
this
.
tableSelectData
[
0
];
uni
.
scanCode
({
success
:
function
(
res
)
{
t
.
$u
.
api
.
addRecoilMaterial
({
taskId
:
taskInfo
.
taskId
,
plnr
:
res
.
result
}).
then
((
res2
)
=>
{
if
(
res2
.
code
===
200
)
{
t
.
recoilMaterialLoadAndScan
(
true
);
}
});
this
.
$u
.
api
.
addRecoilMaterial
({
taskId
:
taskInfo
.
taskId
,
plnr
:
barNumber
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
recoilMaterialLoadAndScan
(
true
);
}
});
this
.
recoilMaterialVisible
=
true
;
},
recoilMaterialDelete
(
line
)
{
const
t
=
this
;
...
...
pages/test/scan/scan.vue
0 → 100644
View file @
c5768522
<
template
>
<view
class=
"page"
>
<view
class=
"title"
>
扫码结果
</view>
<view
class=
"result_list"
>
<view
v-for=
"(item, index) in list"
:key=
"index"
class=
"result_li"
>
{{
item
}}
</view>
</view>
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
webView
:
null
,
barcode
:
null
,
list
:
[]
};
},
mounted
()
{
setTimeout
(()
=>
{
this
.
createBarcode
();
},
10000
);
},
methods
:
{
// 扫码成功回调
onmarked
(
type
,
result
)
{
// 【步骤4】将扫码结果添加到 list 里
console
.
log
(
result
);
this
.
list
.
push
(
result
);
// 【步骤5】1秒后再重新开启扫码
setTimeout
(()
=>
{
this
.
barcode
.
start
();
},
1000
);
},
// 创建窗口和扫码控件
createBarcode
()
{
// 【步骤1】判断有没有创建过 webview 容器,如果没有就执行创建操作
if
(
!
this
.
webView
)
{
this
.
webView
=
plus
.
webview
.
open
(
''
,
'barCodeBox'
,
{
top
:
'60px'
,
width
:
'100%'
,
height
:
'400px'
});
}
// 【步骤2】判断有没有创建过 扫码框,如果没有就执行创建操作
if
(
!
this
.
barcode
)
{
this
.
barcode
=
plus
.
barcode
.
create
(
'barcode'
,
[
plus
.
barcode
.
QR
,
plus
.
barcode
.
EAN13
,
plus
.
barcode
.
EAN8
,
plus
.
barcode
.
AZTEC
,
plus
.
barcode
.
DATAMATRIX
,
plus
.
barcode
.
UPCA
,
plus
.
barcode
.
UPCE
,
plus
.
barcode
.
CODABAR
,
plus
.
barcode
.
CODE39
,
plus
.
barcode
.
CODE93
,
plus
.
barcode
.
CODE128
,
plus
.
barcode
.
ITF
,
plus
.
barcode
.
PDF417
],
// 只扫二维码
{
top
:
'0px'
,
left
:
'0px'
,
width
:
'100%'
,
height
:
'400px'
,
position
:
'static'
,
scanbarColor
:
'#f1c01f'
,
frameColor
:
'#c0ff01'
}
);
this
.
barcode
.
onmarked
=
this
.
onmarked
;
// 扫码结果回调函数
// 【步骤3】将扫码框添加到 webview 里
plus
.
webview
.
getWebviewById
(
'barCodeBox'
).
append
(
this
.
barcode
);
}
this
.
barcode
.
start
();
// 开始扫码
}
}
};
</
script
>
<
style
>
.page
{
height
:
100vh
;
display
:
flex
;
flex-direction
:
column
;
box-sizing
:
border-box
;
padding
:
200px
20
rpx
0
;
}
.title
{
font-size
:
50
rpx
;
color
:
#333
;
}
.result_list
{
flex
:
1
;
overflow-y
:
auto
;
box-sizing
:
border-box
;
padding-top
:
20
rpx
;
}
.result_li
{
box-sizing
:
border-box
;
margin-bottom
:
20
rpx
;
padding
:
10
rpx
20
rpx
;
border
:
1px
solid
#7298c8
;
border-radius
:
10
rpx
;
font-size
:
40
rpx
;
}
</
style
>
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