1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 12:01:57 +08:00

Fix Price Checking (#854)

* Fix Price Checking

* Update request.js

* valide search value

* minimal changes

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
Co-authored-by: Edwin Betancourt <EdwinBetanc0urt@outlook.com>
This commit is contained in:
Elsio Sanchez 2021-05-18 17:16:52 -04:00 committed by GitHub
parent 467a948d09
commit 4766b1164a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 12 deletions

View File

@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
// Get Instance for connectionimport { // Get Instance for connectionimport {
import { isEmptyValue } from '@/utils/ADempiere'
import { request } from '@/utils/ADempiere/request' import { request } from '@/utils/ADempiere/request'
// List Point of sales // List Point of sales
@ -44,7 +45,9 @@ export function requestGetProductPrice({
}) })
.then(productPriceResponse => { .then(productPriceResponse => {
const { convertProductPrice } = require('@/utils/ADempiere/apiConverts/core.js') const { convertProductPrice } = require('@/utils/ADempiere/apiConverts/core.js')
if (isEmptyValue(productPriceResponse)) {
return productPriceResponse
}
return convertProductPrice(productPriceResponse) return convertProductPrice(productPriceResponse)
}) })
} }

View File

@ -18,6 +18,7 @@ export default [
// Product Code // Product Code
{ {
elementColumnName: 'ProductValue', elementColumnName: 'ProductValue',
columnName: 'ProductValue',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {
size: 24, size: 24,

View File

@ -152,9 +152,6 @@ export default {
}, },
mounted() { mounted() {
this.getImage() this.getImage()
setTimeout(() => {
this.focusProductValue()
}, 1000)
}, },
beforeDestroy() { beforeDestroy() {
this.unsubscribe() this.unsubscribe()
@ -197,7 +194,10 @@ export default {
formatPrice, formatPrice,
subscribeChanges() { subscribeChanges() {
return this.$store.subscribe((mutation, state) => { return this.$store.subscribe((mutation, state) => {
if ((mutation.type === 'addActionKeyPerformed') && mutation.payload.columnName === 'ProductValue') { if ((mutation.type === 'currentPointOfSales') || (mutation.type === 'setListProductPrice') || (mutation.type === 'addFocusLost')) {
this.focusProductValue()
}
if ((mutation.type === 'addActionKeyPerformed') && mutation.payload.columnName === 'ProductValue' && (this.productPrice.upc !== mutation.payload.value)) {
// cleans all values except column name 'ProductValue' // cleans all values except column name 'ProductValue'
this.search = mutation.payload.value this.search = mutation.payload.value
if (!this.isEmptyValue(this.search) && this.search.length >= 4) { if (!this.isEmptyValue(this.search) && this.search.length >= 4) {
@ -229,7 +229,8 @@ export default {
taxRate: rate, taxRate: rate,
taxName: taxRate.name, taxName: taxRate.name,
taxIndicator: taxRate.taxIndicator, taxIndicator: taxRate.taxIndicator,
taxAmt: this.getTaxAmount(priceBase, rate) taxAmt: this.getTaxAmount(priceBase, rate),
upc: product.upc
} }
}) })
.catch(() => { .catch(() => {
@ -250,9 +251,13 @@ export default {
} }
}) })
} }
} else if ((mutation.type === 'updateValueOfField') && (mutation.payload.columnName === 'ProductValue') && !this.isEmptyValue(mutation.payload.value)) { } else if ((mutation.type === 'updateValueOfField') && (mutation.payload.columnName === 'ProductValue') && !this.isEmptyValue(mutation.payload.value) && (this.productPrice.upc !== mutation.payload.value)) {
clearTimeout(this.timeOut) clearTimeout(this.timeOut)
this.timeOut = setTimeout(() => { this.timeOut = setTimeout(() => {
let value = mutation.payload.value
if (typeof value[value.length - 1] === 'string') {
value = mutation.payload.value.slice(0, -1)
}
requestGetProductPrice({ requestGetProductPrice({
searchValue: mutation.payload.value, searchValue: mutation.payload.value,
priceListUuid: this.currentPoint.priceList.uuid priceListUuid: this.currentPoint.priceList.uuid
@ -262,7 +267,6 @@ export default {
const { product, taxRate, priceStandard: priceBase } = productPrice const { product, taxRate, priceStandard: priceBase } = productPrice
const { rate } = taxRate const { rate } = taxRate
const { imageURL: image } = product const { imageURL: image } = product
this.productPrice = { this.productPrice = {
currency: productPrice.currency, currency: productPrice.currency,
image, image,

View File

@ -37,9 +37,13 @@ export function request(requestValues) {
} }
requestValues.params.token = getToken() requestValues.params.token = getToken()
requestValues.params.language = getLanguage() || 'en_US' requestValues.params.language = getLanguage() || 'en_US'
return new Promise(resolve => { return new Promise((resolve, reject) => {
requestAPI(requestValues).then(response => { requestAPI(requestValues)
resolve(response.result) .then(response => {
}) resolve(response.result)
})
.catch(response => {
reject(response)
})
}) })
} }