Add UPC quick lookup for View Product page

and fix expand/collapse icons
This commit is contained in:
Lance Edgar 2023-08-07 17:54:05 -05:00
parent abd92f503f
commit 4879a8e46c
3 changed files with 53 additions and 4 deletions

View file

@ -321,6 +321,11 @@ export default {
methods: { methods: {
clear() {
this.record = {}
this.$emit('refresh', this.record)
},
getModelSlug() { getModelSlug() {
if (this.modelSlug) { if (this.modelSlug) {
return this.modelSlug return this.modelSlug

View file

@ -1,9 +1,14 @@
<template> <template>
<byjove-model-crud model-name="Product" <div>
<byjove-model-crud ref="modelCrud"
model-name="Product"
:label-renderer="renderLabel" :label-renderer="renderLabel"
:allow-edit="allowEdit" :allow-edit="allowEdit"
:mode="mode" :mode="mode"
@refresh="record => { product = record }"> @refresh="record => { product = record }"
v-show="!scannerSubmitting"
class="block">
<div style="display: flex; justify-content: space-between; margin-bottom: 0.5rem;"> <div style="display: flex; justify-content: space-between; margin-bottom: 0.5rem;">
@ -40,7 +45,7 @@
</p> </p>
<a class="card-header-icon"> <a class="card-header-icon">
<b-icon pack="fas" <b-icon pack="fas"
:icon="props.open ? 'angle-down' : 'angle-up'"> :icon="props.open ? 'angle-up' : 'angle-down'">
</b-icon> </b-icon>
</a> </a>
</div> </div>
@ -85,7 +90,7 @@
</p> </p>
<a class="card-header-icon"> <a class="card-header-icon">
<b-icon pack="fas" <b-icon pack="fas"
:icon="props.open ? 'angle-down' : 'angle-up'"> :icon="props.open ? 'angle-up' : 'angle-down'">
</b-icon> </b-icon>
</a> </a>
</div> </div>
@ -125,10 +130,17 @@
<slot name="extra-panels" :product="product"></slot> <slot name="extra-panels" :product="product"></slot>
</byjove-model-crud> </byjove-model-crud>
<byjove-scanner-input ref="scannerInput"
class="block"
@submit="scannerSubmit">
</byjove-scanner-input>
</div>
</template> </template>
<script> <script>
import ByjoveModelCrud from '../model-crud' import ByjoveModelCrud from '../model-crud'
import ByjoveScannerInput from '../scanner-input'
export default { export default {
name: 'Product', name: 'Product',
@ -141,16 +153,44 @@ export default {
}, },
components: { components: {
ByjoveModelCrud, ByjoveModelCrud,
ByjoveScannerInput,
}, },
data: function() { data: function() {
return { return {
product: {}, product: {},
scannerSubmitting: false,
} }
}, },
methods: { methods: {
renderLabel(product) { renderLabel(product) {
return product.product_key return product.product_key
}, },
scannerSubmit(entry) {
this.scannerSubmitting = true
let url = '/api/products/quick-lookup'
let params = {entry: entry}
this.$http.get(url, {params: params}).then(response => {
if (response.data.error) {
this.$buefy.toast.open({
message: response.data.error,
type: 'is-danger',
})
} else {
this.$refs.scannerInput.clear()
this.$refs.modelCrud.clear()
this.$router.push(`/products/${response.data.product.uuid}`)
}
this.scannerSubmitting = false
}, response => {
this.$buefy.toast.open({
message: "Unknown error!",
type: 'is-danger',
})
this.scannerSubmitting = false
})
},
}, },
} }
</script> </script>

View file

@ -25,6 +25,10 @@ export default {
methods: { methods: {
clear() {
this.quickEntry = ''
},
globalKey(event) { globalKey(event) {
if (event.target.tagName == 'BODY') { if (event.target.tagName == 'BODY') {