1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-07 18:25:45 +08:00

support price checking (#930)

* support price checking

* correcting comments

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-06-21 19:50:56 -04:00 committed by GitHub
parent 9b64e66722
commit 587e8cb9c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,7 +73,7 @@
<div class="product-price amount">
<span style="float: right;"> {{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }} </span> <br>
{{ formatPrice(productPrice.schemaGrandTotal, productPrice.schemaCurrency.iSOCode) }}
<span v-if="!isEmptyValue(currentPointOfSales.displayCurrency)"> {{ formatPrice(productPrice.grandTotalConverted, currentPointOfSales.displayCurrency.iSOCode) }}</span>
</div>
</el-col>
</el-row>
@ -133,8 +133,17 @@ export default {
defaultImage() {
return require('@/image/ADempiere/priceChecking/no-image.jpg')
},
currentPoint() {
currentPointOfSales() {
return this.$store.getters.posAttributes.currentPointOfSales
},
pointOfSalesList() {
return this.$store.getters.posAttributes.pointOfSalesList
},
convertionsList() {
return this.$store.state['pointOfSales/point/index'].conversionsList
},
currentConvertion() {
return this.convertionsList.find(convert => convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id)
}
},
created() {
@ -143,12 +152,23 @@ export default {
mounted() {
this.backgroundForm = this.defaultImage
this.getImageFromSource(this.organizationImagePath)
this.$store.dispatch('listPointOfSalesFromServer')
if (this.isEmptyValue(this.pointOfSalesList)) {
this.$store.dispatch('listPointOfSalesFromServer')
}
if (!this.isEmptyValue(this.pointOfSalesList) && this.isEmptyValue(this.currentConvertion)) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid,
currencyToUuid: this.currentPointOfSales.displayCurrency.uuid
})
}
},
beforeDestroy() {
this.unsubscribe()
},
methods: {
formatPercent,
formatPrice,
focusProductValue() {
if (!this.isEmptyValue(this.$refs.ProductValue[0])) {
this.$refs.ProductValue[0].$children[0].$children[0].$children[1].$children[0].focus()
@ -165,8 +185,10 @@ export default {
})
this.backgroundForm = image.uri
},
formatPercent,
formatPrice,
amountConvert(price, currency) {
const convertion = this.convertionsList.find(convert => convert.currencyTo.id === currency.id)
return price / convertion.divideRate
},
subscribeChanges() {
return this.$store.subscribe((mutation, state) => {
if ((mutation.type === 'currentPointOfSales') || (mutation.type === 'setListProductPrice') || (mutation.type === 'addFocusLost')) {
@ -178,7 +200,7 @@ export default {
if (!this.isEmptyValue(this.search) && this.search.length >= 4) {
getProductPrice({
searchValue: mutation.payload.value,
priceListUuid: this.currentPoint.priceList.uuid
posUuid: this.currentPointOfSales.uuid
})
.then(productPrice => {
this.messageError = true
@ -191,16 +213,12 @@ export default {
image,
grandTotal: this.getGrandTotal(priceBase, rate),
productName: product.name,
productDescription: product.description,
productDescription: product.help,
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,
grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency),
taxRate: rate,
taxName: taxRate.name,
taxIndicator: taxRate.taxIndicator,
@ -235,7 +253,7 @@ export default {
}
getProductPrice({
searchValue: mutation.payload.value,
priceListUuid: this.currentPoint.priceList.uuid
posUuid: this.currentPointOfSales.uuid
})
.then(productPrice => {
this.messageError = true
@ -253,7 +271,7 @@ export default {
priceList: productPrice.priceList,
priceLimit: productPrice.priceLimit,
schemaCurrency: productPrice.schemaCurrency,
schemaGrandTotal: this.getGrandTotal(productPrice.schemaPriceStandard, rate),
grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency),
schemaPriceStandard: productPrice.schemaPriceStandard,
schemaPriceList: productPrice.schemaPriceList,
schemaPriceLimit: productPrice.schemaPriceLimit,