fix: pop out the warning when scanning a undefine product
This commit is contained in:
parent
a7ce5cfd7e
commit
287d0aa41d
@ -65,13 +65,18 @@ export default {
|
|||||||
onScanSuccess(decodedText, decodedResult) {
|
onScanSuccess(decodedText, decodedResult) {
|
||||||
// handle the scanned code as you like, for example:
|
// handle the scanned code as you like, for example:
|
||||||
console.log(`Code matched = ${decodedText}`, decodedResult);
|
console.log(`Code matched = ${decodedText}`, decodedResult);
|
||||||
var product = this.products[decodedText]
|
if (decodedText in this.products){
|
||||||
this.productCar.push({
|
var product = this.products[decodedText]
|
||||||
'name': product['name'],
|
this.productCar.push({
|
||||||
'id': product['id'],
|
'name': product['name'],
|
||||||
'price': product['price'],
|
'id': product['id'],
|
||||||
'count': 1
|
'price': product['price'],
|
||||||
})
|
'count': 1
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.msg = "商品列表中沒有這項商品:"+decodedText
|
||||||
|
this.warningModalStatus = true
|
||||||
|
}
|
||||||
this.scanner.clear()
|
this.scanner.clear()
|
||||||
},
|
},
|
||||||
scan() {
|
scan() {
|
||||||
@ -130,7 +135,7 @@ export default {
|
|||||||
</div>
|
</div>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<button class="button is-success is-outlined is-large" @click="scan">掃描商品條碼</button>
|
<button class="button is-success is-outlined is-large" @click="scan">掃描商品條碼</button>
|
||||||
<div id="reader" width="300px"></div>
|
<div id="reader" width="200px"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<table class="table is-fullwidth">
|
<table class="table is-fullwidth">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user