mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-12 22:29:59 +08:00
Feat: Refactor Order Vuex Module (#589)
* decrease calls and pass actions to the store * Refactor Order Vuex Module * remove comment * minimal changes * point of sales * fix collection * minimal change
This commit is contained in:
parent
b41ec22883
commit
5c25117c4d
@ -14,11 +14,11 @@
|
|||||||
>
|
>
|
||||||
<convert-amount
|
<convert-amount
|
||||||
:convert="multiplyRate"
|
:convert="multiplyRate"
|
||||||
:amount="order.grandTotal"
|
:amount="currentOrder.grandTotal"
|
||||||
:currency="currencyPoint"
|
:currency="currencyPoint"
|
||||||
/>
|
/>
|
||||||
<el-button slot="reference" type="text" style="color: #000000;font-weight: 604!important;font-size: 100%;">
|
<el-button slot="reference" type="text" style="color: #000000;font-weight: 604!important;font-size: 100%;">
|
||||||
{{ formatPrice(order.grandTotal, currencyPoint.iSOCode) }}
|
{{ formatPrice(currentOrder.grandTotal, currencyPoint.iSOCode) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</b>
|
</b>
|
||||||
@ -71,18 +71,9 @@
|
|||||||
</el-header>
|
</el-header>
|
||||||
<el-main style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">
|
<el-main style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px;">
|
||||||
<type-collection
|
<type-collection
|
||||||
v-if="isLoaded"
|
|
||||||
:is-add-type-pay="listPayments"
|
:is-add-type-pay="listPayments"
|
||||||
:currency="currencyPoint"
|
:currency="currencyPoint"
|
||||||
/>
|
:list-types-payment="fieldsList[2]"
|
||||||
<div
|
|
||||||
v-else
|
|
||||||
key="form-loading"
|
|
||||||
v-loading="!isLoaded"
|
|
||||||
:element-loading-text="$t('notifications.loading')"
|
|
||||||
element-loading-spinner="el-icon-loading"
|
|
||||||
element-loading-background="rgba(0, 0, 0, 0.8)"
|
|
||||||
class="loading-panel"
|
|
||||||
/>
|
/>
|
||||||
</el-main>
|
</el-main>
|
||||||
|
|
||||||
@ -101,11 +92,11 @@
|
|||||||
>
|
>
|
||||||
<convert-amount
|
<convert-amount
|
||||||
:convert="multiplyRate"
|
:convert="multiplyRate"
|
||||||
:amount="order.grandTotal"
|
:amount="currentOrder.grandTotal"
|
||||||
:currency="currencyPoint"
|
:currency="currencyPoint"
|
||||||
/>
|
/>
|
||||||
<el-button slot="reference" type="text" style="color: #000000;font-weight: 604!important;font-size: 100%;">
|
<el-button slot="reference" type="text" style="color: #000000;font-weight: 604!important;font-size: 100%;">
|
||||||
{{ formatPrice(order.grandTotal, currencyPoint.iSOCode) }}
|
{{ formatPrice(currentOrder.grandTotal, currencyPoint.iSOCode) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</b>
|
</b>
|
||||||
@ -227,19 +218,20 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
validateCompleteCollection() {
|
validateCompleteCollection() {
|
||||||
let collection
|
let collection
|
||||||
if (this.pay === this.order.grandTotal) {
|
if (this.pay === this.currentOrder.grandTotal) {
|
||||||
collection = false
|
collection = false
|
||||||
} else {
|
} else {
|
||||||
if (this.pay >= this.order.grandTotal && (this.isCashAmt >= this.change) || this.checked) {
|
if (this.pay >= this.currentOrder.grandTotal && (this.isCashAmt >= this.change) || this.checked) {
|
||||||
collection = false
|
collection = false
|
||||||
} else {
|
} else {
|
||||||
collection = true
|
collection = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return collection
|
return collection
|
||||||
|
// return false
|
||||||
},
|
},
|
||||||
fullCopper() {
|
fullCopper() {
|
||||||
if ((this.change > this.isCashAmt) && this.pay > this.order.grandTotal) {
|
if ((this.change > this.isCashAmt) && this.pay > this.currentOrder.grandTotal) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -312,7 +304,7 @@ export default {
|
|||||||
})
|
})
|
||||||
const allPay = this.cashPayment + amount
|
const allPay = this.cashPayment + amount
|
||||||
if (typePay !== 'X') {
|
if (typePay !== 'X') {
|
||||||
if (allPay <= this.order.grandTotal) {
|
if (allPay <= this.currentOrder.grandTotal) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -347,11 +339,11 @@ export default {
|
|||||||
return this.sumCash(this.listPayments)
|
return this.sumCash(this.listPayments)
|
||||||
},
|
},
|
||||||
pending() {
|
pending() {
|
||||||
const missing = this.order.grandTotal - this.pay
|
const missing = this.currentOrder.grandTotal - this.pay
|
||||||
if (this.pay > 0 && this.pay < this.order.grandTotal) {
|
if (this.pay > 0 && this.pay < this.currentOrder.grandTotal) {
|
||||||
return missing
|
return missing
|
||||||
}
|
}
|
||||||
const pending = this.order.grandTotal <= this.pay ? 0 : this.order.grandTotal
|
const pending = this.currentOrder.grandTotal <= this.pay ? 0 : this.currentOrder.grandTotal
|
||||||
return pending
|
return pending
|
||||||
},
|
},
|
||||||
isMandatory() {
|
isMandatory() {
|
||||||
@ -378,15 +370,12 @@ export default {
|
|||||||
return !this.isEmptyValue(fieldsEmpty)
|
return !this.isEmptyValue(fieldsEmpty)
|
||||||
},
|
},
|
||||||
change() {
|
change() {
|
||||||
const missing = this.pay - this.order.grandTotal
|
const missing = this.pay - this.currentOrder.grandTotal
|
||||||
if (this.pay > 0 && this.pay > this.order.grandTotal) {
|
if (this.pay > 0 && this.pay > this.currentOrder.grandTotal) {
|
||||||
return missing
|
return missing
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
order() {
|
|
||||||
return this.$store.getters.getFindOrder
|
|
||||||
},
|
|
||||||
currencyPoint() {
|
currencyPoint() {
|
||||||
const currency = this.$store.getters.getCurrentPOS
|
const currency = this.$store.getters.getCurrentPOS
|
||||||
if (!this.isEmptyValue(currency)) {
|
if (!this.isEmptyValue(currency)) {
|
||||||
@ -400,7 +389,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
currentOrder() {
|
currentOrder() {
|
||||||
return this.$store.getters.getFindOrder
|
return this.$store.getters.getOrder
|
||||||
},
|
},
|
||||||
typeCurrency() {
|
typeCurrency() {
|
||||||
return this.$store.getters.getValueOfField({
|
return this.$store.getters.getValueOfField({
|
||||||
|
@ -110,6 +110,10 @@ export default {
|
|||||||
currency: {
|
currency: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: undefined
|
default: undefined
|
||||||
|
},
|
||||||
|
listTypesPayment: {
|
||||||
|
type: Object,
|
||||||
|
default: undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -119,6 +123,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
typesPayment() {
|
typesPayment() {
|
||||||
|
console.log(this.$store.getters.getListsPaymentTypes)
|
||||||
return this.$store.getters.getListsPaymentTypes
|
return this.$store.getters.getListsPaymentTypes
|
||||||
},
|
},
|
||||||
listCurrency() {
|
listCurrency() {
|
||||||
@ -128,6 +133,13 @@ export default {
|
|||||||
return this.$store.getters.getConvertionPayment
|
return this.$store.getters.getConvertionPayment
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
listTypesPayment(value) {
|
||||||
|
if (!this.isEmptyValue(value) && this.typesPayment.length <= 1) {
|
||||||
|
this.tenderTypeDisplaye(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
formatDate,
|
formatDate,
|
||||||
formatPrice,
|
formatPrice,
|
||||||
@ -183,6 +195,21 @@ export default {
|
|||||||
},
|
},
|
||||||
amountConvertion(payment) {
|
amountConvertion(payment) {
|
||||||
return payment.amount * this.conevertionAmount.multiplyRate
|
return payment.amount * this.conevertionAmount.multiplyRate
|
||||||
|
},
|
||||||
|
tenderTypeDisplaye(value) {
|
||||||
|
if (!this.isEmptyValue(value.reference)) {
|
||||||
|
const tenderType = value.reference
|
||||||
|
if (!this.isEmptyValue(tenderType)) {
|
||||||
|
this.$store.dispatch('getLookupListFromServer', {
|
||||||
|
tableName: tenderType.tableName,
|
||||||
|
query: tenderType.query,
|
||||||
|
filters: []
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
this.$store.dispatch('tenderTypeDisplaye', response)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,8 +354,6 @@ export default {
|
|||||||
this.newOrder()
|
this.newOrder()
|
||||||
},
|
},
|
||||||
newOrder() {
|
newOrder() {
|
||||||
this.$store.dispatch('findOrderServer', {})
|
|
||||||
|
|
||||||
const pos = this.pointOfSalesId || this.$route.query.pos
|
const pos = this.pointOfSalesId || this.$route.query.pos
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
params: {
|
params: {
|
||||||
@ -367,7 +365,24 @@ export default {
|
|||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.info(`VPOS/Options component (New Order): ${error.message}`)
|
console.info(`VPOS/Options component (New Order): ${error.message}`)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
// const { templateBusinessPartner } = this.currentPOS
|
const { templateBusinessPartner } = this.$store.getters.getCurrentPOS
|
||||||
|
// TODO: Set order with POS Terminal default values
|
||||||
|
this.$store.commit('setListPayments', [])
|
||||||
|
this.$store.dispatch('setOrder', {
|
||||||
|
documentType: {},
|
||||||
|
documentStatus: {
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
totalLines: 0,
|
||||||
|
grandTotal: 0,
|
||||||
|
salesRepresentative: {},
|
||||||
|
businessPartner: {
|
||||||
|
value: '',
|
||||||
|
uuid: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.$store.dispatch('listOrderLine', [])
|
||||||
|
this.$store.commit('setShowPOSCollection', false)
|
||||||
this.$store.commit('updateValuesOfContainer', {
|
this.$store.commit('updateValuesOfContainer', {
|
||||||
containerUuid: this.metadata.containerUuid,
|
containerUuid: this.metadata.containerUuid,
|
||||||
attributes: [{
|
attributes: [{
|
||||||
@ -380,27 +395,17 @@ export default {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
columnName: 'C_BPartner_ID',
|
columnName: 'C_BPartner_ID',
|
||||||
value: 1000006
|
value: templateBusinessPartner.id
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
columnName: 'DisplayColumn_C_BPartner_ID',
|
columnName: 'DisplayColumn_C_BPartner_ID',
|
||||||
value: 'Cliente Unico'
|
value: templateBusinessPartner.name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
columnName: ' C_BPartner_ID_UUID',
|
columnName: ' C_BPartner_ID_UUID',
|
||||||
value: '9f6cf428-9209-11e9-8046-0242ac140002'
|
value: this.$store.getters['user/getUserUuid']
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO: Set order with POS Terminal default values
|
|
||||||
// this.order = {
|
|
||||||
// documentType: {},
|
|
||||||
// documentStatus: {},
|
|
||||||
// salesRepresentative: this.currentPOS.salesRepresentative
|
|
||||||
//
|
|
||||||
this.$store.commit('setListPayments', [])
|
|
||||||
this.$store.dispatch('listOrderLine', [])
|
|
||||||
this.$store.commit('setShowPOSCollection', false)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
printOrder() {
|
printOrder() {
|
||||||
|
@ -34,12 +34,12 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="2" :style="styleTab">
|
<el-col :span="2" :style="styleTab">
|
||||||
<el-tag
|
<el-tag
|
||||||
:type="tagStatus(order.documentStatus.value)"
|
:type="tagStatus(getOrder.documentStatus.value)"
|
||||||
>
|
>
|
||||||
<span v-if="isEmptyValue(order.documentStatus.value)">
|
<span v-if="isEmptyValue(getOrder.documentStatus.value)">
|
||||||
Borrador
|
Borrador
|
||||||
</span>
|
</span>
|
||||||
{{ order.documentStatus.name }}
|
{{ getOrder.documentStatus.name }}
|
||||||
</el-tag>
|
</el-tag>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -232,9 +232,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<span style="float: right;">
|
<span style="float: right;">
|
||||||
<p class="total">{{ $t('form.pos.order.seller') }}:<b style="float: right;">
|
<p class="total">{{ $t('form.pos.order.seller') }}:<b style="float: right;">
|
||||||
{{ order.salesRepresentative.name }}
|
{{ getOrder.salesRepresentative.name }}
|
||||||
</b></p>
|
</b></p>
|
||||||
<p class="total"> {{ $t('form.pos.order.subTotal') }}:<b class="order-info">{{ formatPrice(order.totalLines, currencyPoint.iSOCode) }}</b></p>
|
<p class="total"> {{ $t('form.pos.order.subTotal') }}:<b class="order-info">{{ formatPrice(getOrder.totalLines, currencyPoint.iSOCode) }}</b></p>
|
||||||
<p class="total"> {{ $t('form.pos.order.discount') }}:<b class="order-info">{{ formatPrice(0, currencyPoint.iSOCode) }}</b> </p>
|
<p class="total"> {{ $t('form.pos.order.discount') }}:<b class="order-info">{{ formatPrice(0, currencyPoint.iSOCode) }}</b> </p>
|
||||||
<p class="total"> {{ $t('form.pos.order.tax') }}:<b style="float: right;">{{ getOrderTax(currencyPoint.iSOCode) }}</b> </p>
|
<p class="total"> {{ $t('form.pos.order.tax') }}:<b style="float: right;">{{ getOrderTax(currencyPoint.iSOCode) }}</b> </p>
|
||||||
<p class="total">
|
<p class="total">
|
||||||
@ -249,25 +249,25 @@
|
|||||||
<convert-amount
|
<convert-amount
|
||||||
v-show="seeConversion"
|
v-show="seeConversion"
|
||||||
:convert="multiplyRate"
|
:convert="multiplyRate"
|
||||||
:amount="order.grandTotal"
|
:amount="getOrder.grandTotal"
|
||||||
:currency="currencyPoint"
|
:currency="currencyPoint"
|
||||||
/>
|
/>
|
||||||
<el-button slot="reference" type="text" style="color: #000000;font-weight: 604!important;font-size: 100%;" @click="seeConversion = !seeConversion">
|
<el-button slot="reference" type="text" style="color: #000000;font-weight: 604!important;font-size: 100%;" @click="seeConversion = !seeConversion">
|
||||||
{{ formatPrice(order.grandTotal, currencyPoint.iSOCode) }}
|
{{ formatPrice(getOrder.grandTotal, currencyPoint.iSOCode) }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</b>
|
</b>
|
||||||
</p>
|
</p>
|
||||||
</span>
|
</span>
|
||||||
<span style="float: right;padding-right: 40px;">
|
<span style="float: right;padding-right: 40px;">
|
||||||
<p class="total">{{ $t('form.pos.order.order') }}: <b class="order-info">{{ order.documentNo }}</b></p>
|
<p class="total">{{ $t('form.pos.order.order') }}: <b class="order-info">{{ getOrder.documentNo }}</b></p>
|
||||||
<p class="total">
|
<p class="total">
|
||||||
{{ $t('form.pos.order.date') }}:
|
{{ $t('form.pos.order.date') }}:
|
||||||
<b class="order-info">
|
<b class="order-info">
|
||||||
{{ orderDate }}
|
{{ orderDate }}
|
||||||
</b>
|
</b>
|
||||||
</p>
|
</p>
|
||||||
<p class="total">{{ $t('form.pos.order.type') }}:<b class="order-info">{{ order.documentType.name }}</b></p>
|
<p class="total">{{ $t('form.pos.order.type') }}:<b class="order-info">{{ getOrder.documentType.name }}</b></p>
|
||||||
<p class="total">
|
<p class="total">
|
||||||
{{ $t('form.pos.order.itemQuantity') }}
|
{{ $t('form.pos.order.itemQuantity') }}
|
||||||
<b class="order-info">
|
<b class="order-info">
|
||||||
@ -357,19 +357,22 @@ export default {
|
|||||||
if (currentPOS && !this.isEmptyValue(currentPOS.name)) {
|
if (currentPOS && !this.isEmptyValue(currentPOS.name)) {
|
||||||
return currentPOS
|
return currentPOS
|
||||||
}
|
}
|
||||||
return undefined
|
return {
|
||||||
|
name: '',
|
||||||
|
uuid: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
sellingPointsList() {
|
sellingPointsList() {
|
||||||
return this.$store.getters.getSellingPointsList
|
return this.$store.getters.getSellingPointsList
|
||||||
},
|
},
|
||||||
orderDate() {
|
orderDate() {
|
||||||
if (this.isEmptyValue(this.order) || this.isEmptyValue(this.order.dateOrdered)) {
|
if (this.isEmptyValue(this.getOrder) || this.isEmptyValue(this.getOrder.dateOrdered)) {
|
||||||
return this.formatDate(new Date())
|
return this.formatDate(new Date())
|
||||||
}
|
}
|
||||||
return this.formatDate(this.order.dateOrdered)
|
return this.formatDate(this.getOrder.dateOrdered)
|
||||||
},
|
},
|
||||||
getItemQuantity() {
|
getItemQuantity() {
|
||||||
if (this.isEmptyValue(this.currentOrder)) {
|
if (this.isEmptyValue(this.getOrder)) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
const result = this.allOrderLines.map(order => {
|
const result = this.allOrderLines.map(order => {
|
||||||
@ -384,7 +387,7 @@ export default {
|
|||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
numberOfLines() {
|
numberOfLines() {
|
||||||
if (this.isEmptyValue(this.currentOrder)) {
|
if (this.isEmptyValue(this.getOrder)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return this.allOrderLines.length
|
return this.allOrderLines.length
|
||||||
@ -456,7 +459,6 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.tenderTypeDisplaye()
|
|
||||||
this.currencyDisplaye()
|
this.currencyDisplaye()
|
||||||
}, 1500)
|
}, 1500)
|
||||||
},
|
},
|
||||||
@ -468,14 +470,12 @@ export default {
|
|||||||
openCollectionPanel() {
|
openCollectionPanel() {
|
||||||
this.isShowedPOSKeyLayout = !this.isShowedPOSKeyLayout
|
this.isShowedPOSKeyLayout = !this.isShowedPOSKeyLayout
|
||||||
this.$store.commit('setShowPOSCollection', true)
|
this.$store.commit('setShowPOSCollection', true)
|
||||||
// this.isShowedPOSKeyLayout = true
|
|
||||||
const orderUuid = this.$route.query.action
|
const orderUuid = this.$route.query.action
|
||||||
this.$store.dispatch('listPayments', { orderUuid })
|
this.$store.dispatch('listPayments', { orderUuid })
|
||||||
this.isShowedPOSKeyLaout = !this.isShowedPOSKeyLaout
|
this.isShowedPOSKeyLaout = !this.isShowedPOSKeyLaout
|
||||||
this.$store.commit('setShowPOSOptions', false)
|
this.$store.commit('setShowPOSOptions', false)
|
||||||
},
|
},
|
||||||
newOrder() {
|
newOrder() {
|
||||||
this.$store.dispatch('findOrderServer', {})
|
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
params: {
|
params: {
|
||||||
...this.$route.params
|
...this.$route.params
|
||||||
@ -486,7 +486,6 @@ export default {
|
|||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
const { templateBusinessPartner } = this.currentPoint
|
const { templateBusinessPartner } = this.currentPoint
|
||||||
|
|
||||||
this.$store.commit('updateValuesOfContainer', {
|
this.$store.commit('updateValuesOfContainer', {
|
||||||
containerUuid: this.metadata.containerUuid,
|
containerUuid: this.metadata.containerUuid,
|
||||||
attributes: [{
|
attributes: [{
|
||||||
@ -510,7 +509,19 @@ export default {
|
|||||||
value: templateBusinessPartner.uuid
|
value: templateBusinessPartner.uuid
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
this.$store.dispatch('setOrder', {
|
||||||
|
documentType: {},
|
||||||
|
documentStatus: {
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
totalLines: 0,
|
||||||
|
grandTotal: 0,
|
||||||
|
salesRepresentative: {},
|
||||||
|
businessPartner: {
|
||||||
|
value: '',
|
||||||
|
uuid: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
this.$store.dispatch('listOrderLine', [])
|
this.$store.dispatch('listOrderLine', [])
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -522,6 +533,7 @@ export default {
|
|||||||
tenderTypeDisplaye() {
|
tenderTypeDisplaye() {
|
||||||
if (!this.isEmptyValue(this.fieldsList)) {
|
if (!this.isEmptyValue(this.fieldsList)) {
|
||||||
const tenderType = this.fieldsList[5].reference
|
const tenderType = this.fieldsList[5].reference
|
||||||
|
if (!this.isEmptyValue(tenderType)) {
|
||||||
this.$store.dispatch('getLookupListFromServer', {
|
this.$store.dispatch('getLookupListFromServer', {
|
||||||
tableName: tenderType.tableName,
|
tableName: tenderType.tableName,
|
||||||
query: tenderType.query
|
query: tenderType.query
|
||||||
@ -530,10 +542,12 @@ export default {
|
|||||||
this.$store.dispatch('tenderTypeDisplaye', response)
|
this.$store.dispatch('tenderTypeDisplaye', response)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
currencyDisplaye() {
|
currencyDisplaye() {
|
||||||
if (!this.isEmptyValue(this.fieldsList)) {
|
if (!this.isEmptyValue(this.fieldsList)) {
|
||||||
const currency = this.fieldsList[4].reference
|
const currency = this.fieldsList[4].reference
|
||||||
|
if (!this.isEmptyValue(currency)) {
|
||||||
this.$store.dispatch('getLookupListFromServer', {
|
this.$store.dispatch('getLookupListFromServer', {
|
||||||
tableName: currency.tableName,
|
tableName: currency.tableName,
|
||||||
query: currency.query
|
query: currency.query
|
||||||
@ -545,6 +559,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -174,7 +174,6 @@ export default {
|
|||||||
if (!this.isEmptyValue(order)) {
|
if (!this.isEmptyValue(order)) {
|
||||||
return order
|
return order
|
||||||
}
|
}
|
||||||
this.$store.dispatch('listOrderLine', [])
|
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
isReadyFromGetData() {
|
isReadyFromGetData() {
|
||||||
@ -201,14 +200,6 @@ export default {
|
|||||||
this.loadOrdersList()
|
this.loadOrdersList()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
const listOrder = this.$store.getters.getListOrderLine
|
|
||||||
if (this.isEmptyValue(listOrder) && !this.isEmptyValue(this.$store.getters.getCurrentPOS.uuid)) {
|
|
||||||
this.$store.dispatch('listOrdersFromServer', {
|
|
||||||
posUuid: this.$store.getters.getCurrentPOS.uuid
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.unsubscribe()
|
this.unsubscribe()
|
||||||
},
|
},
|
||||||
|
@ -123,9 +123,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.unsubscribePOSList = this.posListWithOrganization()
|
this.unsubscribePOSList = this.posListWithOrganization()
|
||||||
if (!this.isEmptyValue(this.$route.query.action)) {
|
|
||||||
this.$store.dispatch('findOrderServer', this.$route.query.action)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.isEmptyValue(this.$route.query) || this.isEmptyValue(this.$route.query.pos)) {
|
if (this.isEmptyValue(this.$route.query) || this.isEmptyValue(this.$route.query.pos)) {
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
findProduct,
|
findProduct,
|
||||||
requestCreateOrder,
|
|
||||||
requestGetOrder,
|
|
||||||
requestUpdateOrder,
|
|
||||||
requestUpdateOrderLine
|
requestUpdateOrderLine
|
||||||
} from '@/api/ADempiere/form/point-of-sales.js'
|
} from '@/api/ADempiere/form/point-of-sales.js'
|
||||||
import {
|
import {
|
||||||
@ -10,7 +7,6 @@ import {
|
|||||||
formatPrice,
|
formatPrice,
|
||||||
formatQuantity
|
formatQuantity
|
||||||
} from '@/utils/ADempiere/valueFormat.js'
|
} from '@/utils/ADempiere/valueFormat.js'
|
||||||
// import posProcess from '@/utils/ADempiere/constants/posProcess'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'POSMixin',
|
name: 'POSMixin',
|
||||||
@ -23,18 +19,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
product: {},
|
product: {},
|
||||||
order: {
|
|
||||||
documentType: {},
|
|
||||||
documentStatus: {
|
|
||||||
value: ''
|
|
||||||
},
|
|
||||||
totalLines: 0,
|
|
||||||
grandTotal: 0,
|
|
||||||
salesRepresentative: {},
|
|
||||||
businessPartner: {
|
|
||||||
value: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
currentTable: 0,
|
currentTable: 0,
|
||||||
currentOrderLine: {
|
currentOrderLine: {
|
||||||
product: {
|
product: {
|
||||||
@ -57,9 +41,6 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
allOrderLines() {
|
allOrderLines() {
|
||||||
if (this.isEmptyValue(this.listOrderLine)) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
return this.listOrderLine
|
return this.listOrderLine
|
||||||
},
|
},
|
||||||
listOrderLine() {
|
listOrderLine() {
|
||||||
@ -75,10 +56,7 @@ export default {
|
|||||||
currentOrder() {
|
currentOrder() {
|
||||||
const action = this.$route.query.action
|
const action = this.$route.query.action
|
||||||
if (!this.isEmptyValue(action)) {
|
if (!this.isEmptyValue(action)) {
|
||||||
const order = this.ordersList.find(item => item.uuid === action)
|
return this.$store.getters.getOrder
|
||||||
if (!this.isEmptyValue(order)) {
|
|
||||||
return order
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -90,7 +68,8 @@ export default {
|
|||||||
grandTotal: 0,
|
grandTotal: 0,
|
||||||
salesRepresentative: {},
|
salesRepresentative: {},
|
||||||
businessPartner: {
|
businessPartner: {
|
||||||
value: ''
|
value: '',
|
||||||
|
uuid: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -118,21 +97,39 @@ export default {
|
|||||||
},
|
},
|
||||||
updateOrderProcessPos() {
|
updateOrderProcessPos() {
|
||||||
return this.$store.getters.getUpdateOrderPos
|
return this.$store.getters.getUpdateOrderPos
|
||||||
|
},
|
||||||
|
getOrder() {
|
||||||
|
return this.$store.getters.getOrder
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
getOrder(value) {
|
||||||
|
if (!this.isEmptyValue(value)) {
|
||||||
|
// this.order = value
|
||||||
|
this.$store.commit('updateValuesOfContainer', {
|
||||||
|
parentUuid: this.parentUuid,
|
||||||
|
containerUuid: this.containerUuid,
|
||||||
|
attributes: [{
|
||||||
|
columnName: 'C_BPartner_ID',
|
||||||
|
value: value.businessPartner.id
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnName: 'DisplayColumn_C_BPartner_ID',
|
||||||
|
value: value.businessPartner.name
|
||||||
|
},
|
||||||
|
{
|
||||||
|
columnName: ' C_BPartner_ID_UUID',
|
||||||
|
value: value.businessPartner.uuid
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
currentOrder(value) {
|
currentOrder(value) {
|
||||||
if (this.isEmptyValue(value)) {
|
if (this.isEmptyValue(value)) {
|
||||||
this.orderLines = []
|
this.orderLines = []
|
||||||
this.order = {
|
|
||||||
documentType: {},
|
|
||||||
documentStatus: {},
|
|
||||||
salesRepresentative: {}
|
|
||||||
}
|
|
||||||
this.$store.dispatch('listOrderLine', [])
|
this.$store.dispatch('listOrderLine', [])
|
||||||
this.listOrderLines({})
|
this.listOrderLines({})
|
||||||
} else {
|
} else {
|
||||||
this.fillOrder(value)
|
|
||||||
this.listOrderLines(value)
|
this.listOrderLines(value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -157,7 +154,6 @@ export default {
|
|||||||
beforeMount() {
|
beforeMount() {
|
||||||
if (!this.isEmptyValue(this.currentPoint)) {
|
if (!this.isEmptyValue(this.currentPoint)) {
|
||||||
if (!this.isEmptyValue(this.currentOrder)) {
|
if (!this.isEmptyValue(this.currentOrder)) {
|
||||||
this.fillOrder(this.currentOrder)
|
|
||||||
this.listOrderLines(this.currentOrder)
|
this.listOrderLines(this.currentOrder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +163,6 @@ export default {
|
|||||||
this.unsubscribe()
|
this.unsubscribe()
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
// this.findProcess()
|
|
||||||
if (!this.isEmptyValue(this.$route.query)) {
|
if (!this.isEmptyValue(this.$route.query)) {
|
||||||
this.reloadOrder(true, this.$route.query.action)
|
this.reloadOrder(true, this.$route.query.action)
|
||||||
}
|
}
|
||||||
@ -203,41 +198,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateOrder(update) {
|
updateOrder(update) {
|
||||||
if (this.withoutPOSTerminal()) {
|
// user session
|
||||||
return
|
if (update.value !== this.getOrder.businessPartner.uuid) {
|
||||||
}
|
this.$store.dispatch('updateOrder', {
|
||||||
if (!this.$route.query || this.isEmptyValue(this.$route.query.action)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const { uuid: posUuid } = this.currentPoint
|
|
||||||
|
|
||||||
let customerUuid
|
|
||||||
if (update.columnName === 'C_BPartner_ID_UUID') {
|
|
||||||
customerUuid = update.value
|
|
||||||
if (this.isEmptyValue(customerUuid) && !this.isEmptyValue(this.currentPoint)) {
|
|
||||||
customerUuid = this.currentPoint.templateBusinessPartner.uuid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
requestUpdateOrder({
|
|
||||||
orderUuid: this.$route.query.action,
|
orderUuid: this.$route.query.action,
|
||||||
posUuid,
|
posUuid: this.currentPoint.uuid,
|
||||||
customerUuid
|
customerUuid: update.value
|
||||||
// documentTypeUuid: value.value,
|
|
||||||
// description
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
// this.reloadOrder(true)
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error.message)
|
|
||||||
this.$message({
|
|
||||||
type: 'error',
|
|
||||||
message: error.message,
|
|
||||||
showClose: true
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setBusinessPartner({ name, id, uuid }) {
|
setBusinessPartner({ name, id, uuid }) {
|
||||||
// Use update values of container (without subscription)
|
// Use update values of container (without subscription)
|
||||||
@ -309,50 +277,43 @@ export default {
|
|||||||
const orderUuid = this.$route.query.action
|
const orderUuid = this.$route.query.action
|
||||||
if (this.isEmptyValue(orderUuid)) {
|
if (this.isEmptyValue(orderUuid)) {
|
||||||
const posUuid = this.currentPoint.uuid
|
const posUuid = this.currentPoint.uuid
|
||||||
|
|
||||||
let customerUuid = this.$store.getters.getValueOfField({
|
let customerUuid = this.$store.getters.getValueOfField({
|
||||||
containerUuid: this.containerUuid,
|
containerUuid: this.containerUuid,
|
||||||
columnName: 'C_BPartner_ID_UUID'
|
columnName: 'C_BPartner_ID_UUID'
|
||||||
})
|
})
|
||||||
if (this.isEmptyValue(customerUuid)) {
|
const id = this.$store.getters.getValueOfField({
|
||||||
|
containerUuid: this.containerUuid,
|
||||||
|
columnName: 'C_BPartner_ID'
|
||||||
|
})
|
||||||
|
if (this.isEmptyValue(customerUuid) || id === 1000006) {
|
||||||
customerUuid = this.currentPoint.templateBusinessPartner.uuid
|
customerUuid = this.currentPoint.templateBusinessPartner.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
// user session
|
// user session
|
||||||
const salesRepresentativeUuid = this.$store.getters['user/getUserUuid']
|
// alert(name)
|
||||||
requestCreateOrder({
|
this.$store.dispatch('createOrder', {
|
||||||
posUuid,
|
posUuid,
|
||||||
customerUuid,
|
customerUuid,
|
||||||
salesRepresentativeUuid
|
salesRepresentativeUuid: this.currentPoint.templateBusinessPartner.uuid
|
||||||
})
|
})
|
||||||
.then(order => {
|
.then(response => {
|
||||||
this.$store.dispatch('currentOrder', order)
|
// this.order = response
|
||||||
this.fillOrder(order)
|
this.reloadOrder(true, response.uuid)
|
||||||
|
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
params: {
|
params: {
|
||||||
...this.$route.params
|
...this.$route.params
|
||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
...this.$route.query,
|
...this.$route.query,
|
||||||
action: order.uuid
|
action: response.uuid
|
||||||
}
|
}
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (withLine) {
|
if (withLine) {
|
||||||
this.createOrderLine(order.uuid)
|
this.createOrderLine(response.uuid)
|
||||||
}
|
}
|
||||||
|
this.$store.dispatch('listOrdersFromServer', {
|
||||||
|
posUuid: this.$store.getters.getCurrentPOS.uuid
|
||||||
|
})
|
||||||
}).catch(() => {})
|
}).catch(() => {})
|
||||||
|
|
||||||
// update orders list
|
|
||||||
this.$store.commit('setIsReloadListOrders')
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error(error.message)
|
|
||||||
this.$message({
|
|
||||||
type: 'error',
|
|
||||||
message: error.message,
|
|
||||||
showClose: true
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.createOrderLine(orderUuid)
|
this.createOrderLine(orderUuid)
|
||||||
@ -367,22 +328,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.isEmptyValue(orderUuid)) {
|
if (!this.isEmptyValue(orderUuid)) {
|
||||||
requestGetOrder(orderUuid)
|
this.$store.dispatch('reloadOrder', { orderUuid })
|
||||||
.then(orderResponse => {
|
|
||||||
this.$store.dispatch('currentOrder', orderResponse)
|
|
||||||
this.fillOrder(orderResponse)
|
|
||||||
this.listOrderLines(orderResponse)
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
this.$message({
|
|
||||||
type: 'error',
|
|
||||||
message: error.message,
|
|
||||||
showClose: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.fillOrder(this.currentOrder, false)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fillOrder(order, setToStore = true) {
|
fillOrder(order, setToStore = true) {
|
||||||
@ -407,7 +354,7 @@ export default {
|
|||||||
const { businessPartner } = order
|
const { businessPartner } = order
|
||||||
this.setBusinessPartner(businessPartner)
|
this.setBusinessPartner(businessPartner)
|
||||||
}
|
}
|
||||||
this.order = orderToPush
|
// this.order = orderToPush
|
||||||
},
|
},
|
||||||
getOrderTax(currency) {
|
getOrderTax(currency) {
|
||||||
if (this.isEmptyValue(this.order)) {
|
if (this.isEmptyValue(this.order)) {
|
||||||
@ -433,16 +380,8 @@ export default {
|
|||||||
this.updateOrderLine(mutation.payload)
|
this.updateOrderLine(mutation.payload)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
//
|
|
||||||
case 'C_DocType_ID':
|
|
||||||
this.updateOrder(mutation.payload)
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
} else if (mutation.type === 'updateValueOfField') {
|
} else if (mutation.type === 'updateValueOfField') {
|
||||||
// if (this.metadata.containerUuid === mutation.payload.containerUuid &&
|
|
||||||
// mutation.payload.columnName === 'ProductValue') {
|
|
||||||
// this.findProduct(mutation.payload.value)
|
|
||||||
// }
|
|
||||||
switch (mutation.payload.columnName) {
|
switch (mutation.payload.columnName) {
|
||||||
case 'DisplayColumn_TenderType':
|
case 'DisplayColumn_TenderType':
|
||||||
this.displayType = mutation.payload.value
|
this.displayType = mutation.payload.value
|
||||||
|
@ -1,169 +0,0 @@
|
|||||||
import {
|
|
||||||
requestGetOrder,
|
|
||||||
requestListOrders
|
|
||||||
} from '@/api/ADempiere/form/point-of-sales.js'
|
|
||||||
import { isEmptyValue, extractPagingToken } from '@/utils/ADempiere/valueUtils.js'
|
|
||||||
import { showMessage } from '@/utils/ADempiere/notification.js'
|
|
||||||
|
|
||||||
const withoutResponse = {
|
|
||||||
isLoaded: false,
|
|
||||||
isReload: true,
|
|
||||||
recordCount: 0,
|
|
||||||
nextPageToken: undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
const ordes = {
|
|
||||||
state: {
|
|
||||||
order: {},
|
|
||||||
findOrder: {},
|
|
||||||
listOrder: {
|
|
||||||
...withoutResponse,
|
|
||||||
isShowPopover: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
setOrder(state, order) {
|
|
||||||
state.order = order
|
|
||||||
},
|
|
||||||
setListOrder(state, listOrder) {
|
|
||||||
state.listOrder = {
|
|
||||||
...state.listOrder,
|
|
||||||
...listOrder
|
|
||||||
}
|
|
||||||
},
|
|
||||||
setOrdersListPageNumber(state, pageNumber) {
|
|
||||||
state.listOrder.pageNumber = pageNumber
|
|
||||||
},
|
|
||||||
showListOrders(state, isShow) {
|
|
||||||
state.listOrder.isShowPopover = isShow
|
|
||||||
},
|
|
||||||
setIsReloadListOrders(state) {
|
|
||||||
state.listOrder.isReload = true
|
|
||||||
},
|
|
||||||
currentOrder(state, currentOrder) {
|
|
||||||
state.currentOrder = currentOrder
|
|
||||||
},
|
|
||||||
findOrder(state, findOrder) {
|
|
||||||
state.findOrder = findOrder
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
/**
|
|
||||||
* Set page number of pagination list
|
|
||||||
* @param {number} pageNumber
|
|
||||||
*/
|
|
||||||
setOrdersListPageNumber({ commit, dispatch }, pageNumber) {
|
|
||||||
commit('setOrdersListPageNumber', pageNumber)
|
|
||||||
dispatch('listOrdersFromServer', {})
|
|
||||||
},
|
|
||||||
listOrdersFromServer({ state, commit, getters }, {
|
|
||||||
posUuid,
|
|
||||||
documentNo,
|
|
||||||
businessPartnerUuid,
|
|
||||||
grandTotal,
|
|
||||||
openAmount,
|
|
||||||
isPaid,
|
|
||||||
isProcessed,
|
|
||||||
isAisleSeller,
|
|
||||||
isInvoiced,
|
|
||||||
dateOrderedFrom,
|
|
||||||
dateOrderedTo,
|
|
||||||
salesRepresentativeUuid
|
|
||||||
}) {
|
|
||||||
if (isEmptyValue(posUuid)) {
|
|
||||||
posUuid = getters.getPointOfSalesUuid
|
|
||||||
}
|
|
||||||
|
|
||||||
let { pageNumber, token } = state.listOrder
|
|
||||||
if (isEmptyValue(pageNumber)) {
|
|
||||||
pageNumber = 1
|
|
||||||
}
|
|
||||||
let pageToken
|
|
||||||
if (!isEmptyValue(token)) {
|
|
||||||
pageToken = token + '-' + pageNumber
|
|
||||||
}
|
|
||||||
requestListOrders({
|
|
||||||
posUuid,
|
|
||||||
documentNo,
|
|
||||||
businessPartnerUuid,
|
|
||||||
grandTotal,
|
|
||||||
openAmount,
|
|
||||||
isPaid,
|
|
||||||
isProcessed,
|
|
||||||
isAisleSeller,
|
|
||||||
isInvoiced,
|
|
||||||
dateOrderedFrom,
|
|
||||||
dateOrderedTo,
|
|
||||||
salesRepresentativeUuid,
|
|
||||||
pageToken
|
|
||||||
})
|
|
||||||
.then(responseOrdersList => {
|
|
||||||
if (isEmptyValue(token) || isEmptyValue(pageToken)) {
|
|
||||||
token = extractPagingToken(responseOrdersList.nextPageToken)
|
|
||||||
}
|
|
||||||
|
|
||||||
commit('setListOrder', {
|
|
||||||
...responseOrdersList,
|
|
||||||
isLoaded: true,
|
|
||||||
isReload: false,
|
|
||||||
posUuid,
|
|
||||||
token,
|
|
||||||
pageNumber
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.warn(`listOrdersFromServer: ${error.message}. Code: ${error.code}.`)
|
|
||||||
// showMessage({
|
|
||||||
// type: 'info',
|
|
||||||
// message: error.message,
|
|
||||||
// showClose: true
|
|
||||||
// })
|
|
||||||
})
|
|
||||||
},
|
|
||||||
setOrder({ commit }, order) {
|
|
||||||
commit('setOrder', order)
|
|
||||||
},
|
|
||||||
currentOrder({ commit }, findOrder) {
|
|
||||||
commit('findOrder', findOrder)
|
|
||||||
},
|
|
||||||
findOrderServer({ commit }, orderUuid) {
|
|
||||||
if (typeof orderUuid === 'string' && !isEmptyValue(orderUuid)) {
|
|
||||||
requestGetOrder(orderUuid)
|
|
||||||
.then(responseOrder => {
|
|
||||||
commit('findOrder', responseOrder)
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.warn(`findOrderServer: ${error.message}. Code: ${error.code}.`)
|
|
||||||
showMessage({
|
|
||||||
type: 'info',
|
|
||||||
message: error.message,
|
|
||||||
showClose: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
commit('findOrder', {})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getters: {
|
|
||||||
getOrder: (state) => {
|
|
||||||
return state.order
|
|
||||||
},
|
|
||||||
getListOrder: (state) => {
|
|
||||||
if (isEmptyValue(state.listOrder)) {
|
|
||||||
return {
|
|
||||||
...withoutResponse,
|
|
||||||
ordersList: []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return state.listOrder
|
|
||||||
},
|
|
||||||
getCurrentOrder: (state) => {
|
|
||||||
return state.currentOrder
|
|
||||||
},
|
|
||||||
getFindOrder: (state) => {
|
|
||||||
return state.findOrder
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ordes
|
|
263
src/store/modules/ADempiere/pointOfSales/order/actions.js
Normal file
263
src/store/modules/ADempiere/pointOfSales/order/actions.js
Normal file
@ -0,0 +1,263 @@
|
|||||||
|
import {
|
||||||
|
requestCreateOrder,
|
||||||
|
requestGetOrder,
|
||||||
|
requestUpdateOrder,
|
||||||
|
requestCreateOrderLine,
|
||||||
|
requestListOrders
|
||||||
|
} from '@/api/ADempiere/form/point-of-sales.js'
|
||||||
|
import { isEmptyValue, extractPagingToken } from '@/utils/ADempiere/valueUtils.js'
|
||||||
|
import { showMessage } from '@/utils/ADempiere/notification.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Actions
|
||||||
|
* @author Elsio Sanchez <elsiosanches@gmail.com>
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* Create Sales Order
|
||||||
|
* @param {string} posUuid Current POS Uuid
|
||||||
|
* @param {string} customerUuid Customer Uuid
|
||||||
|
* @param {string} salesRepresentativeUuid Sales Representative Uuid
|
||||||
|
*/
|
||||||
|
createOrder({ commit, dispatch }, {
|
||||||
|
posUuid,
|
||||||
|
customerUuid,
|
||||||
|
salesRepresentativeUuid
|
||||||
|
}) {
|
||||||
|
return requestCreateOrder({
|
||||||
|
posUuid,
|
||||||
|
customerUuid,
|
||||||
|
salesRepresentativeUuid
|
||||||
|
})
|
||||||
|
.then(order => {
|
||||||
|
commit('setOrder', order)
|
||||||
|
dispatch('fillOrde', { attribute: order })
|
||||||
|
|
||||||
|
commit('setIsReloadListOrders')
|
||||||
|
return order
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error.message)
|
||||||
|
showMessage({
|
||||||
|
type: 'error',
|
||||||
|
message: error.message,
|
||||||
|
showClose: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Update Sales Order
|
||||||
|
* @param {string} posUuid Current POS Uuid
|
||||||
|
* @param {string} posUuid Order Uuid
|
||||||
|
* @param {string} customerUuid Customer Uuid
|
||||||
|
*/
|
||||||
|
updateOrder({ commit, dispatch }, {
|
||||||
|
orderUuid,
|
||||||
|
posUuid,
|
||||||
|
customerUuid
|
||||||
|
}) {
|
||||||
|
requestUpdateOrder({
|
||||||
|
orderUuid,
|
||||||
|
posUuid,
|
||||||
|
customerUuid
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
dispatch('reloadOrder', { orderUuid: response.uuid })
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error.message)
|
||||||
|
this.$message({
|
||||||
|
type: 'error',
|
||||||
|
message: error.message,
|
||||||
|
showClose: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create order line from order uuid and product
|
||||||
|
* @param {string} orderUuid Order Uuid
|
||||||
|
* @param {string} productUuid Product Uuid
|
||||||
|
* @param {string} description Product description
|
||||||
|
* @param {number} quantity Quantity Producto
|
||||||
|
* @param {number} price Price Producto
|
||||||
|
* @param {number} discountRate DiscountRate Producto
|
||||||
|
*/
|
||||||
|
createOrderLine({ commit, dispatch }, {
|
||||||
|
orderUuid,
|
||||||
|
warehouseUuid,
|
||||||
|
productUuid,
|
||||||
|
chargeUuid,
|
||||||
|
description,
|
||||||
|
quantity,
|
||||||
|
price,
|
||||||
|
discountRate
|
||||||
|
}) {
|
||||||
|
requestCreateOrderLine({
|
||||||
|
orderUuid,
|
||||||
|
productUuid
|
||||||
|
})
|
||||||
|
.then(orderLine => {
|
||||||
|
dispatch('updateOrderLines', orderLine)
|
||||||
|
// this.fillOrderLine(orderLine)
|
||||||
|
this.reloadOrder(true, orderUuid)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(error.message)
|
||||||
|
showMessage({
|
||||||
|
type: 'error',
|
||||||
|
message: error.message,
|
||||||
|
showClose: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Reload Order
|
||||||
|
* @param {string} orderUuid Order Uuid
|
||||||
|
*/
|
||||||
|
reloadOrder({ commit, dispatch, rootGetters }, { orderUuid }) {
|
||||||
|
if (isEmptyValue(orderUuid)) {
|
||||||
|
orderUuid = rootGetters.getOrder.uuid // this.currentOrder.uuid
|
||||||
|
}
|
||||||
|
if (!isEmptyValue(orderUuid)) {
|
||||||
|
requestGetOrder(orderUuid)
|
||||||
|
.then(orderResponse => {
|
||||||
|
dispatch('fillOrde', {
|
||||||
|
attribute: orderResponse,
|
||||||
|
setToStore: false
|
||||||
|
})
|
||||||
|
dispatch('currentOrder', orderResponse)
|
||||||
|
// dispatch('listOrderLinesFromServer', orderResponse.uuid)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
showMessage({
|
||||||
|
type: 'error',
|
||||||
|
message: error.message,
|
||||||
|
showClose: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Fill Order
|
||||||
|
* @param {object} attribute Attributes of the Order
|
||||||
|
* @param {boolean} setToStore set To Store
|
||||||
|
*/
|
||||||
|
fillOrde({ commit, dispatch }, {
|
||||||
|
attribute,
|
||||||
|
setToStore = true
|
||||||
|
}) {
|
||||||
|
const orderToPush = {
|
||||||
|
uuid: attribute.uuid,
|
||||||
|
id: attribute.id,
|
||||||
|
businessPartner: attribute.businessPartner, // description, duns, id, lastName, naics, name, taxId, uuid, value
|
||||||
|
documentNo: attribute.documentNo,
|
||||||
|
dateOrdered: attribute.dateOrdered,
|
||||||
|
documentStatus: attribute.documentStatus, // value, name, description
|
||||||
|
documentType: attribute.documentType, // name, printName
|
||||||
|
salesRepresentative: attribute.salesRepresentative, // id, uuid, name, description,
|
||||||
|
totalLines: attribute.totalLines,
|
||||||
|
grandTotal: attribute.grandTotal
|
||||||
|
}
|
||||||
|
// if (setToStore) {
|
||||||
|
dispatch('setOrder', {
|
||||||
|
...orderToPush
|
||||||
|
})
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Set page number of pagination list
|
||||||
|
* @param {number} pageNumber
|
||||||
|
*/
|
||||||
|
setOrdersListPageNumber({ commit, dispatch }, pageNumber) {
|
||||||
|
commit('setOrdersListPageNumber', pageNumber)
|
||||||
|
dispatch('listOrdersFromServer', {})
|
||||||
|
},
|
||||||
|
listOrdersFromServer({ state, commit, getters }, {
|
||||||
|
posUuid,
|
||||||
|
documentNo,
|
||||||
|
businessPartnerUuid,
|
||||||
|
grandTotal,
|
||||||
|
openAmount,
|
||||||
|
isPaid,
|
||||||
|
isProcessed,
|
||||||
|
isAisleSeller,
|
||||||
|
isInvoiced,
|
||||||
|
dateOrderedFrom,
|
||||||
|
dateOrderedTo,
|
||||||
|
salesRepresentativeUuid
|
||||||
|
}) {
|
||||||
|
if (isEmptyValue(posUuid)) {
|
||||||
|
posUuid = getters.getPointOfSalesUuid
|
||||||
|
}
|
||||||
|
|
||||||
|
let { pageNumber, token } = state.listOrder
|
||||||
|
if (isEmptyValue(pageNumber)) {
|
||||||
|
pageNumber = 1
|
||||||
|
}
|
||||||
|
let pageToken
|
||||||
|
if (!isEmptyValue(token)) {
|
||||||
|
pageToken = token + '-' + pageNumber
|
||||||
|
}
|
||||||
|
requestListOrders({
|
||||||
|
posUuid,
|
||||||
|
documentNo,
|
||||||
|
businessPartnerUuid,
|
||||||
|
grandTotal,
|
||||||
|
openAmount,
|
||||||
|
isPaid,
|
||||||
|
isProcessed,
|
||||||
|
isAisleSeller,
|
||||||
|
isInvoiced,
|
||||||
|
dateOrderedFrom,
|
||||||
|
dateOrderedTo,
|
||||||
|
salesRepresentativeUuid,
|
||||||
|
pageToken
|
||||||
|
})
|
||||||
|
.then(responseOrdersList => {
|
||||||
|
if (isEmptyValue(token) || isEmptyValue(pageToken)) {
|
||||||
|
token = extractPagingToken(responseOrdersList.nextPageToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
commit('setListOrder', {
|
||||||
|
...responseOrdersList,
|
||||||
|
isLoaded: true,
|
||||||
|
isReload: false,
|
||||||
|
posUuid,
|
||||||
|
token,
|
||||||
|
pageNumber
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`listOrdersFromServer: ${error.message}. Code: ${error.code}.`)
|
||||||
|
// showMessage({
|
||||||
|
// type: 'info',
|
||||||
|
// message: error.message,
|
||||||
|
// showClose: true
|
||||||
|
// })
|
||||||
|
})
|
||||||
|
},
|
||||||
|
setOrder({ commit }, order) {
|
||||||
|
commit('setOrder', order)
|
||||||
|
},
|
||||||
|
currentOrder({ commit }, findOrder) {
|
||||||
|
commit('findOrder', findOrder)
|
||||||
|
},
|
||||||
|
findOrderServer({ commit }, orderUuid) {
|
||||||
|
if (typeof orderUuid === 'string' && !isEmptyValue(orderUuid)) {
|
||||||
|
requestGetOrder(orderUuid)
|
||||||
|
.then(responseOrder => {
|
||||||
|
commit('findOrder', responseOrder)
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn(`findOrderServer: ${error.message}. Code: ${error.code}.`)
|
||||||
|
showMessage({
|
||||||
|
type: 'info',
|
||||||
|
message: error.message,
|
||||||
|
showClose: true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
commit('findOrder', {})
|
||||||
|
}
|
||||||
|
}
|
33
src/store/modules/ADempiere/pointOfSales/order/getters.js
Normal file
33
src/store/modules/ADempiere/pointOfSales/order/getters.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Order Getters
|
||||||
|
* @author Elsio Sanchez <elsiosanches@gmail.com>
|
||||||
|
*/
|
||||||
|
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
|
||||||
|
|
||||||
|
const withoutResponse = {
|
||||||
|
isLoaded: false,
|
||||||
|
isReload: true,
|
||||||
|
recordCount: 0,
|
||||||
|
nextPageToken: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getOrder: (state) => {
|
||||||
|
return state.order
|
||||||
|
},
|
||||||
|
getListOrder: (state) => {
|
||||||
|
if (isEmptyValue(state.listOrder)) {
|
||||||
|
return {
|
||||||
|
...withoutResponse,
|
||||||
|
ordersList: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return state.listOrder
|
||||||
|
},
|
||||||
|
getCurrentOrder: (state) => {
|
||||||
|
return state.currentOrder
|
||||||
|
},
|
||||||
|
getFindOrder: (state) => {
|
||||||
|
return state.findOrder
|
||||||
|
}
|
||||||
|
}
|
23
src/store/modules/ADempiere/pointOfSales/order/index.js
Normal file
23
src/store/modules/ADempiere/pointOfSales/order/index.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
import state from './state.js'
|
||||||
|
import mutations from './mutations.js'
|
||||||
|
import actions from './actions.js'
|
||||||
|
import getters from './getters.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order Vuex Module
|
||||||
|
* Create Order
|
||||||
|
* Update Order
|
||||||
|
* List Order
|
||||||
|
* Delete Order
|
||||||
|
* Reload Order
|
||||||
|
* @author Elsio Sanchez <elsiosanches@gmail.com>
|
||||||
|
*/
|
||||||
|
const ordes = {
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ordes
|
31
src/store/modules/ADempiere/pointOfSales/order/mutations.js
Normal file
31
src/store/modules/ADempiere/pointOfSales/order/mutations.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Order Mutations
|
||||||
|
* @author Elsio Sanchez <elsiosanches@gmail.com>
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
setOrder(state, order) {
|
||||||
|
state.order = order
|
||||||
|
},
|
||||||
|
setListOrder(state, listOrder) {
|
||||||
|
state.listOrder = {
|
||||||
|
...state.listOrder,
|
||||||
|
...listOrder
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setOrdersListPageNumber(state, pageNumber) {
|
||||||
|
state.listOrder.pageNumber = pageNumber
|
||||||
|
},
|
||||||
|
showListOrders(state, isShow) {
|
||||||
|
state.listOrder.isShowPopover = isShow
|
||||||
|
},
|
||||||
|
setIsReloadListOrders(state) {
|
||||||
|
state.listOrder.isReload = true
|
||||||
|
},
|
||||||
|
currentOrder(state, currentOrder) {
|
||||||
|
state.currentOrder = currentOrder
|
||||||
|
},
|
||||||
|
findOrder(state, findOrder) {
|
||||||
|
state.findOrder = findOrder
|
||||||
|
}
|
||||||
|
}
|
30
src/store/modules/ADempiere/pointOfSales/order/state.js
Normal file
30
src/store/modules/ADempiere/pointOfSales/order/state.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Order State
|
||||||
|
* @author Elsio Sanchez <elsiosanches@gmail.com>
|
||||||
|
*/
|
||||||
|
const withoutResponse = {
|
||||||
|
isLoaded: false,
|
||||||
|
isReload: true,
|
||||||
|
recordCount: 0,
|
||||||
|
nextPageToken: undefined
|
||||||
|
}
|
||||||
|
export default {
|
||||||
|
order: {
|
||||||
|
documentType: {},
|
||||||
|
documentStatus: {
|
||||||
|
value: ''
|
||||||
|
},
|
||||||
|
totalLines: 0,
|
||||||
|
grandTotal: 0,
|
||||||
|
salesRepresentative: {},
|
||||||
|
businessPartner: {
|
||||||
|
value: '',
|
||||||
|
uuid: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
findOrder: {},
|
||||||
|
listOrder: {
|
||||||
|
...withoutResponse,
|
||||||
|
isShowPopover: false
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
getPaymentBox: (state) => {
|
getPaymentBox: (state) => {
|
||||||
console.log({ state })
|
|
||||||
return state
|
return state
|
||||||
},
|
},
|
||||||
getMultiplyRate: (state) => {
|
getMultiplyRate: (state) => {
|
||||||
@ -21,7 +20,6 @@ export default {
|
|||||||
return state.divideRateCollection
|
return state.divideRateCollection
|
||||||
},
|
},
|
||||||
getListPayments: (state) => {
|
getListPayments: (state) => {
|
||||||
console.log({ state }, 1)
|
|
||||||
return state.listPayments
|
return state.listPayments
|
||||||
},
|
},
|
||||||
getListsPaymentTypes: (state) => {
|
getListsPaymentTypes: (state) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user