mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-07 18:25:45 +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:
parent
467a948d09
commit
4766b1164a
@ -15,6 +15,7 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// Get Instance for connectionimport {
|
||||
import { isEmptyValue } from '@/utils/ADempiere'
|
||||
import { request } from '@/utils/ADempiere/request'
|
||||
|
||||
// List Point of sales
|
||||
@ -44,7 +45,9 @@ export function requestGetProductPrice({
|
||||
})
|
||||
.then(productPriceResponse => {
|
||||
const { convertProductPrice } = require('@/utils/ADempiere/apiConverts/core.js')
|
||||
|
||||
if (isEmptyValue(productPriceResponse)) {
|
||||
return productPriceResponse
|
||||
}
|
||||
return convertProductPrice(productPriceResponse)
|
||||
})
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ export default [
|
||||
// Product Code
|
||||
{
|
||||
elementColumnName: 'ProductValue',
|
||||
columnName: 'ProductValue',
|
||||
isFromDictionary: true,
|
||||
overwriteDefinition: {
|
||||
size: 24,
|
||||
|
@ -152,9 +152,6 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
this.getImage()
|
||||
setTimeout(() => {
|
||||
this.focusProductValue()
|
||||
}, 1000)
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.unsubscribe()
|
||||
@ -197,7 +194,10 @@ export default {
|
||||
formatPrice,
|
||||
subscribeChanges() {
|
||||
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'
|
||||
this.search = mutation.payload.value
|
||||
if (!this.isEmptyValue(this.search) && this.search.length >= 4) {
|
||||
@ -229,7 +229,8 @@ export default {
|
||||
taxRate: rate,
|
||||
taxName: taxRate.name,
|
||||
taxIndicator: taxRate.taxIndicator,
|
||||
taxAmt: this.getTaxAmount(priceBase, rate)
|
||||
taxAmt: this.getTaxAmount(priceBase, rate),
|
||||
upc: product.upc
|
||||
}
|
||||
})
|
||||
.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)
|
||||
this.timeOut = setTimeout(() => {
|
||||
let value = mutation.payload.value
|
||||
if (typeof value[value.length - 1] === 'string') {
|
||||
value = mutation.payload.value.slice(0, -1)
|
||||
}
|
||||
requestGetProductPrice({
|
||||
searchValue: mutation.payload.value,
|
||||
priceListUuid: this.currentPoint.priceList.uuid
|
||||
@ -262,7 +267,6 @@ export default {
|
||||
const { product, taxRate, priceStandard: priceBase } = productPrice
|
||||
const { rate } = taxRate
|
||||
const { imageURL: image } = product
|
||||
|
||||
this.productPrice = {
|
||||
currency: productPrice.currency,
|
||||
image,
|
||||
|
@ -37,9 +37,13 @@ export function request(requestValues) {
|
||||
}
|
||||
requestValues.params.token = getToken()
|
||||
requestValues.params.language = getLanguage() || 'en_US'
|
||||
return new Promise(resolve => {
|
||||
requestAPI(requestValues).then(response => {
|
||||
resolve(response.result)
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
requestAPI(requestValues)
|
||||
.then(response => {
|
||||
resolve(response.result)
|
||||
})
|
||||
.catch(response => {
|
||||
reject(response)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user