From 1e40283c4eab47f2050cee16e56293b30edaee4d Mon Sep 17 00:00:00 2001
From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com>
Date: Tue, 1 Dec 2020 19:36:57 -0400
Subject: [PATCH] barcode Reader (#550)
---
src/api/user.js | 6 +-
.../Form/BarcodeReader/fieldsList.js | 19 --
.../Form/BarcodeReader/fieldsListBarCode.js | 41 ++++
.../ADempiere/Form/BarcodeReader/index.vue | 206 +++++++++---------
.../ADempiere/Form/PriceChecking/index.vue | 51 +++--
src/lang/ADempiere/en.js | 4 +
src/lang/ADempiere/es.js | 4 +
src/router/modules/ADempiere/staticRoutes.js | 1 +
src/store/modules/user.js | 6 +-
src/utils/ADempiere/apiConverts/core.js | 6 +
src/views/ADempiere/Form/index.vue | 2 +-
11 files changed, 210 insertions(+), 136 deletions(-)
delete mode 100644 src/components/ADempiere/Form/BarcodeReader/fieldsList.js
create mode 100644 src/components/ADempiere/Form/BarcodeReader/fieldsListBarCode.js
diff --git a/src/api/user.js b/src/api/user.js
index a45b7972..f16edf78 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -11,14 +11,16 @@ import {
*/
export function login({
userName,
- password
+ password,
+ token
}) {
return requestRest({
url: '/user/login',
method: 'post',
data: {
username: userName,
- password
+ password,
+ token
}
})
}
diff --git a/src/components/ADempiere/Form/BarcodeReader/fieldsList.js b/src/components/ADempiere/Form/BarcodeReader/fieldsList.js
deleted file mode 100644
index 9b88afe6..00000000
--- a/src/components/ADempiere/Form/BarcodeReader/fieldsList.js
+++ /dev/null
@@ -1,19 +0,0 @@
-export default [
- // Product Code
- {
- elementColumnName: 'ProductValue',
- isFromDictionary: true,
- value: '',
- overwriteDefinition: {
- size: 24,
- sequence: 10,
- cssClassName: 'price-inquiry',
- inputSize: 'large',
- handleFocusGained: true,
- handleFocusLost: true,
- handleActionKeyPerformed: true,
- isDisplayed: true,
- isReadOnly: true
- }
- }
-]
diff --git a/src/components/ADempiere/Form/BarcodeReader/fieldsListBarCode.js b/src/components/ADempiere/Form/BarcodeReader/fieldsListBarCode.js
new file mode 100644
index 00000000..9ce5b518
--- /dev/null
+++ b/src/components/ADempiere/Form/BarcodeReader/fieldsListBarCode.js
@@ -0,0 +1,41 @@
+export default [
+ // Product Code
+ {
+ elementColumnName: 'ProductValue',
+ isFromDictionary: true,
+ overwriteDefinition: {
+ size: 24,
+ sequence: 10,
+ cssClassName: 'price-inquiry',
+ inputSize: 'large',
+ handleFocusGained: true,
+ handleFocusLost: true,
+ handleActionKeyPerformed: true
+ }
+ },
+ // bar code reader
+ {
+ columnName: 'UPC',
+ tableName: 'M_Product',
+ isFromDictionary: true,
+ overwriteDefinition: {
+ size: 24,
+ sequence: 10,
+ handleActionPerformed: true,
+ handleContentSelection: true,
+ handleActionKeyPerformed: true
+ }
+ },
+ {
+ columnName: 'Value',
+ tableName: 'M_Product',
+ isFromDictionary: true,
+ overwriteDefinition: {
+ size: 24,
+ sequence: 10,
+ handleActionPerformed: true,
+ handleContentSelection: true,
+ handleActionKeyPerformed: true
+ }
+ }
+]
diff --git a/src/components/ADempiere/Form/BarcodeReader/index.vue b/src/components/ADempiere/Form/BarcodeReader/index.vue
index 06fe422a..f5842a2d 100644
--- a/src/components/ADempiere/Form/BarcodeReader/index.vue
+++ b/src/components/ADempiere/Form/BarcodeReader/index.vue
@@ -2,64 +2,63 @@
-
-
-
- ---------------------------------------------------{{ field }} {{ typeof field.values }}
+
+
-
-
+
-
-
-
-
- {{ productPrice.productName }} {{ productPrice.productDescription }}
-
-
+
+
+
+
+ {{ productPrice.productName }} {{ productPrice.productDescription }}
+
+
-
- Precio Base
-
- {{ formatPrice(productPrice.priceBase, productPrice.currency.iSOCode) }}
-
-
-
+
+ Precio Base
+
+ {{ formatPrice(productPrice.priceBase, productPrice.currency.iSOCode) }}
+
+
+
-
- {{ productPrice.taxName }}
-
- {{ formatPrice(productPrice.taxAmt, productPrice.currency.iSOCode) }}
-
-
-
+
+ {{ productPrice.taxName }}
+
+ {{ formatPrice(productPrice.taxAmt, productPrice.currency.iSOCode) }}
+
+
+
-
- {{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }}
-
-
-
-
-
+
+ {{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }}
+
+
+
+
+
import formMixin from '@/components/ADempiere/Form/formMixin.js'
-import fieldsList from './fieldsList.js'
-import { requestGetProductPrice } from '@/api/ADempiere/form/price-checking.js'
+import fieldsList from './fieldsListBarCode.js'
+// import { requestGetProductPrice } from '@/api/ADempiere/form/price-checking.js'
import { formatPercent, formatPrice } from '@/utils/ADempiere/valueFormat.js'
import { buildImageFromArrayBuffer } from '@/utils/ADempiere/resource.js'
import { requestImage } from '@/api/ADempiere/persistence.js'
@@ -86,6 +85,18 @@ export default {
mixins: [
formMixin
],
+ props: {
+ metadata: {
+ type: Object,
+ default: () => {
+ return {
+ uuid: 'Bar-code-Reader',
+ containerUuid: 'Bar-code-Reader',
+ fieldsList
+ }
+ }
+ }
+ },
data() {
return {
fieldsList,
@@ -93,7 +104,6 @@ export default {
organizationBackground: '',
currentImageOfProduct: '',
search: 'sad',
- input: '',
unsubscribe: () => {}
}
},
@@ -104,6 +114,9 @@ export default {
defaultImage() {
return require('@/image/ADempiere/priceChecking/no-image.jpg')
},
+ defaultImageLogo() {
+ return require('@/image/ADempiere/priceChecking/todoagro.png')
+ },
backgroundForm() {
if (this.isEmptyValue(this.currentImageOfProduct)) {
return this.organizationBackground
@@ -156,57 +169,57 @@ export default {
formatPrice,
subscribeChanges() {
return this.$store.subscribe((mutation, state) => {
- console.log(mutation.type)
- if ((mutation.type === 'addActionKeyPerformed') && mutation.payload.columnName === 'ProductValue') {
- // cleans all values except column name 'ProductValue'
- this.search = mutation.payload.value
- if (this.search.length) {
- requestGetProductPrice({
- searchValue: mutation.payload.value
- })
- .then(productPrice => {
- const { product, taxRate, priceStandard: priceBase } = productPrice
- const { rate } = taxRate
- const { imageURL: image } = product
+ // if ((mutation.type === 'updateValueOfField' || mutation.type === 'addActionKeyPerformed') && mutation.payload.columnName === 'ProductValue') {
+ // // cleans all values except column name 'ProductValue'
+ // this.search = mutation.payload.value
+ // if (!this.isEmptyValue(this.search) && this.search.length >= 4) {
+ // requestGetProductPrice({
+ // searchValue: mutation.payload.value
+ // })
+ // .then(productPrice => {
+ // console.log(productPrice)
+ // const { product, taxRate, priceStandard: priceBase } = productPrice
+ // const { rate } = taxRate
+ // const { imageURL: image } = product
- this.productPrice = {
- productName: product.name,
- productDescription: product.description,
- priceBase,
- priceStandard: productPrice.priceStandard,
- priceList: productPrice.priceList,
- priceLimit: productPrice.priceLimit,
- taxRate: rate,
- image,
- taxName: taxRate.name,
- taxIndicator: taxRate.taxIndicator,
- taxAmt: this.getTaxAmount(priceBase, rate),
- grandTotal: this.getGrandTotal(priceBase, rate),
- currency: productPrice.currency
- }
- })
- .catch(error => {
- this.$message({
- type: 'info',
- message: error.message,
- showClose: true
- })
- this.productPrice = {}
- })
- .finally(() => {
- this.$store.commit('updateValueOfField', {
- containerUuid: this.containerUuid,
- columnName: 'ProductValue',
- value: ''
- })
- this.search = ''
- this.currentImageOfProduct = ''
- if (this.isEmptyValue(this.productPrice.image)) {
- this.getImage(this.productPrice.image)
- }
- })
- }
- }
+ // this.productPrice = {
+ // productName: product.name,
+ // productDescription: product.description,
+ // priceBase,
+ // priceStandard: productPrice.priceStandard,
+ // priceList: productPrice.priceList,
+ // priceLimit: productPrice.priceLimit,
+ // taxRate: rate,
+ // image,
+ // taxName: taxRate.name,
+ // taxIndicator: taxRate.taxIndicator,
+ // taxAmt: this.getTaxAmount(priceBase, rate),
+ // grandTotal: this.getGrandTotal(priceBase, rate),
+ // currency: productPrice.currency
+ // }
+ // })
+ // .catch(error => {
+ // this.$message({
+ // type: 'info',
+ // message: error.message,
+ // showClose: true
+ // })
+ // this.productPrice = {}
+ // })
+ // .finally(() => {
+ // this.$store.commit('updateValueOfField', {
+ // containerUuid: this.containerUuid,
+ // columnName: 'ProductValue',
+ // value: ''
+ // })
+ // this.search = ''
+ // this.currentImageOfProduct = ''
+ // if (this.isEmptyValue(this.productPrice.image)) {
+ // this.getImage(this.productPrice.image)
+ // }
+ // })
+ // }
+ // }
})
},
getTaxAmount(basePrice, taxRate) {
@@ -230,7 +243,6 @@ export default {
width: 100%;
height: 100%;
float: inherit;
- z-index: 0;
// color: white;
// opacity: 0.5;
}
@@ -256,7 +268,7 @@ export default {
right: 5%;
width: 100%;
top: 10%;
- z-index: 1;
+ z-index: 0;
}
.inquiry-product {
position: absolute;
diff --git a/src/components/ADempiere/Form/PriceChecking/index.vue b/src/components/ADempiere/Form/PriceChecking/index.vue
index 1e3ca135..fd01ea17 100644
--- a/src/components/ADempiere/Form/PriceChecking/index.vue
+++ b/src/components/ADempiere/Form/PriceChecking/index.vue
@@ -9,6 +9,7 @@
fit="contain"
:src="defaultImage"
class="background-price-checking"
+ style="z-index: 2;"
>
-
+
@@ -37,7 +38,7 @@
- Precio Base
+ {{ $t('form.priceChecking.basePrice') }}
{{ formatPrice(productPrice.priceBase, productPrice.currency.iSOCode) }}
@@ -53,7 +54,17 @@
- {{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }}
+ {{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }}
+ {{ formatPrice(productPrice.schemaGrandTotal, productPrice.schemaCurrency.iSOCode) }}
+
+
+
+
+
+
+
+
+ {{ $t('form.priceChecking.messageError') }}
@@ -87,11 +98,14 @@ export default {
],
data() {
return {
+ messageError: true,
fieldsList,
productPrice: {},
organizationBackground: '',
currentImageOfProduct: '',
search: 'sad',
+ resul: '',
+ load: '',
unsubscribe: () => {}
}
},
@@ -154,41 +168,43 @@ export default {
formatPrice,
subscribeChanges() {
return this.$store.subscribe((mutation, state) => {
- // console.log(mutation.type.length)
if ((mutation.type === 'updateValueOfField' || mutation.type === 'addActionKeyPerformed') && mutation.payload.columnName === 'ProductValue') {
// cleans all values except column name 'ProductValue'
this.search = mutation.payload.value
- if (this.search.length >= 6) {
+ if (!this.isEmptyValue(this.search) && this.search.length >= 4) {
requestGetProductPrice({
searchValue: mutation.payload.value
})
.then(productPrice => {
+ this.messageError = true
const { product, taxRate, priceStandard: priceBase } = productPrice
const { rate } = taxRate
const { imageURL: image } = product
this.productPrice = {
+ currency: productPrice.currency,
+ image,
+ grandTotal: this.getGrandTotal(priceBase, rate),
productName: product.name,
productDescription: product.description,
priceBase,
priceStandard: productPrice.priceStandard,
priceList: productPrice.priceList,
priceLimit: productPrice.priceLimit,
+ schemaCurrency: productPrice.schemaCurrency,
+ schemaGrandTotal: this.getGrandTotal(productPrice.schemaPriceStandard, rate),
+ schemaPriceStandard: productPrice.schemaPriceStandard,
+ schemaPriceList: productPrice.schemaPriceList,
+ schemaPriceLimit: productPrice.schemaPriceLimit,
taxRate: rate,
- image,
taxName: taxRate.name,
taxIndicator: taxRate.taxIndicator,
- taxAmt: this.getTaxAmount(priceBase, rate),
- grandTotal: this.getGrandTotal(priceBase, rate),
- currency: productPrice.currency
+ taxAmt: this.getTaxAmount(priceBase, rate)
}
})
- .catch(error => {
- this.$message({
- type: 'info',
- message: error.message,
- showClose: true
- })
+ .catch(() => {
+ this.messageError = false
+ this.timeMessage()
this.productPrice = {}
})
.finally(() => {
@@ -207,6 +223,11 @@ export default {
}
})
},
+ timeMessage() {
+ setTimeout(() => {
+ this.messageError = true
+ }, 2000)
+ },
getTaxAmount(basePrice, taxRate) {
if (this.isEmptyValue(basePrice) || this.isEmptyValue(taxRate)) {
return 0
diff --git a/src/lang/ADempiere/en.js b/src/lang/ADempiere/en.js
index 3734b3a0..9419fa28 100644
--- a/src/lang/ADempiere/en.js
+++ b/src/lang/ADempiere/en.js
@@ -396,6 +396,10 @@ export default {
keyLayout: {
noProducto: 'No product available. Back to top'
}
+ },
+ priceChecking: {
+ messageError: 'This Product Not Available',
+ basePrice: 'Base price'
}
}
}
diff --git a/src/lang/ADempiere/es.js b/src/lang/ADempiere/es.js
index e0f8fcba..46c60741 100644
--- a/src/lang/ADempiere/es.js
+++ b/src/lang/ADempiere/es.js
@@ -371,6 +371,10 @@ export default {
keyLayout: {
noProducto: 'No hay producto disponible Regresar al Principio'
}
+ },
+ priceChecking: {
+ messageError: 'Este Producto No Disponible',
+ basePrice: 'Precio Base'
}
}
}
diff --git a/src/router/modules/ADempiere/staticRoutes.js b/src/router/modules/ADempiere/staticRoutes.js
index 4bd958a6..1e13a197 100644
--- a/src/router/modules/ADempiere/staticRoutes.js
+++ b/src/router/modules/ADempiere/staticRoutes.js
@@ -92,6 +92,7 @@ const staticRoutes = [
component: () => import('@/views/ADempiere/Form'),
name: 'BarcodeReader',
meta: {
+ icon: 'search',
title: 'BarcodeReader',
isIndex: true
}
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 109a39d1..821a0fd4 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -103,14 +103,16 @@ const actions = {
userName,
password,
roleUuid,
- organizationUuid
+ organizationUuid,
+ token
}) {
return new Promise((resolve, reject) => {
login({
userName,
password,
roleUuid,
- organizationUuid
+ organizationUuid,
+ token
})
.then(logInResponse => {
if ([13, 500].includes(logInResponse.code)) {
diff --git a/src/utils/ADempiere/apiConverts/core.js b/src/utils/ADempiere/apiConverts/core.js
index 9ba3b746..fc5af54a 100644
--- a/src/utils/ADempiere/apiConverts/core.js
+++ b/src/utils/ADempiere/apiConverts/core.js
@@ -265,6 +265,12 @@ export function convertProductPrice(productPriceToConvert) {
product: convertProduct(
productPriceToConvert.product
),
+ schemaCurrency: convertCurrency(
+ productPriceToConvert.schema_currency
+ ),
+ schemaPriceLimit: productPriceToConvert.schema_price_limit,
+ schemaPriceList: productPriceToConvert.schema_price_list,
+ schemaPriceStandard: productPriceToConvert.schema_price_standard,
priceList: productPriceToConvert.price_list,
priceStandard: productPriceToConvert.price_standard,
priceLimit: productPriceToConvert.price_limit,
diff --git a/src/views/ADempiere/Form/index.vue b/src/views/ADempiere/Form/index.vue
index 78aed375..80e321f7 100644
--- a/src/views/ADempiere/Form/index.vue
+++ b/src/views/ADempiere/Form/index.vue
@@ -15,7 +15,7 @@
:panel-type="panelType"
/>
-
+