1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-13 07:04:21 +08:00

add complete order from collection (#626)

Co-authored-by: Elsio Sanchez <elsiosanche@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-03-03 00:45:23 -04:00 committed by GitHub
parent f2614f70fc
commit a1bc8bb37b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 8 deletions

View File

@ -66,15 +66,25 @@
<el-button type="danger" icon="el-icon-close" @click="exit" /> <el-button type="danger" icon="el-icon-close" @click="exit" />
<el-button type="info" icon="el-icon-minus" @click="undoPatment" /> <el-button type="info" icon="el-icon-minus" @click="undoPatment" />
<el-button type="primary" :disabled="validPay || addPay" icon="el-icon-plus" @click="addCollectToList(paymentBox)" /> <el-button type="primary" :disabled="validPay || addPay" icon="el-icon-plus" @click="addCollectToList(paymentBox)" />
<el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" /> <el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" @click="completePreparedOrder(listPayments)" />
</samp> </samp>
</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="!updateOrderPaymentPos"
:is-add-type-pay="listPayments" :is-add-type-pay="listPayments"
:currency="currencyPoint" :currency="currencyPoint"
:list-types-payment="fieldsList[2]" :list-types-payment="fieldsList[2]"
/> />
<div
v-else
key="form-loading"
v-loading="updateOrderPaymentPos"
:element-loading-text="$t('notifications.loading')"
:element-loading-spinner="'el-icon-loading'"
element-loading-background="rgba(255, 255, 255, 0.8)"
class="view-loading"
/>
</el-main> </el-main>
<el-footer height="auto" style="padding-left: 0px; padding-right: 0px;"> <el-footer height="auto" style="padding-left: 0px; padding-right: 0px;">
@ -172,6 +182,7 @@ import fieldsListCollection from './fieldsListCollection.js'
import typeCollection from '@/components/ADempiere/Form/VPOS/Collection/typeCollection' import typeCollection from '@/components/ADempiere/Form/VPOS/Collection/typeCollection'
import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index' import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index'
import { formatDate, formatPrice } from '@/utils/ADempiere/valueFormat.js' import { formatDate, formatPrice } from '@/utils/ADempiere/valueFormat.js'
import { requestProcessOrder } from '@/api/ADempiere/form/point-of-sales.js'
export default { export default {
name: 'Collection', name: 'Collection',
@ -449,6 +460,9 @@ export default {
}, },
convert() { convert() {
return this.$store.getters.getConvertionPayment return this.$store.getters.getConvertionPayment
},
updateOrderPaymentPos() {
return this.$store.getters.getUpdatePaymentPos
} }
}, },
watch: { watch: {
@ -744,6 +758,46 @@ export default {
paymentUuid paymentUuid
}) })
}, },
completePreparedOrder(payment) {
const posUuid = this.$store.getters.getCurrentPOS.uuid
const orderUuid = this.$route.query.action
this.$store.dispatch('updateOrderPos', true)
this.$store.dispatch('updatePaymentPos', true)
this.$message({
type: 'info',
message: this.$t('notifications.processing'),
showClose: true
})
requestProcessOrder({
posUuid,
orderUuid,
createPayments: !this.isEmptyValue(payment),
payments: payment
})
.then(response => {
this.$store.dispatch('reloadOrder', response.uuid)
this.$message({
type: 'success',
message: this.$t('notifications.completed'),
showClose: true
})
})
.catch(error => {
this.$message({
type: 'error',
message: error.message,
showClose: true
})
console.log(error)
})
.finally(() => {
this.$store.dispatch('listOrdersFromServer', {
posUuid: this.$store.getters.getCurrentPOS.uuid
})
this.$store.dispatch('updateOrderPos', false)
this.$store.dispatch('updatePaymentPos', false)
})
},
subscribeChanges() { subscribeChanges() {
return this.$store.subscribe((mutation, state) => { return this.$store.subscribe((mutation, state) => {
if (mutation.type === 'updateValueOfField') { if (mutation.type === 'updateValueOfField') {

View File

@ -423,6 +423,7 @@ export default {
completePreparedOrder() { completePreparedOrder() {
const posUuid = this.currentPoint.uuid const posUuid = this.currentPoint.uuid
this.$store.dispatch('updateOrderPos', true) this.$store.dispatch('updateOrderPos', true)
this.$store.dispatch('updatePaymentPos', true)
this.$message({ this.$message({
type: 'info', type: 'info',
message: this.$t('notifications.processing'), message: this.$t('notifications.processing'),
@ -436,20 +437,26 @@ export default {
}) })
.then(response => { .then(response => {
this.$store.dispatch('reloadOrder', response.uuid) this.$store.dispatch('reloadOrder', response.uuid)
this.$message({
type: 'success',
message: this.$t('notifications.completed'),
showClose: true
})
}) })
.catch(error => { .catch(error => {
this.$message({
type: 'error',
message: error.message,
showClose: true
})
console.log(error) console.log(error)
}) })
.finally(() => { .finally(() => {
this.$store.dispatch('listOrdersFromServer', { this.$store.dispatch('listOrdersFromServer', {
posUuid: this.$store.getters.getCurrentPOS.uuid posUuid: this.$store.getters.getCurrentPOS.uuid
}) })
this.$message({
type: 'success',
message: this.$t('notifications.completed'),
showClose: true
})
this.$store.dispatch('updateOrderPos', false) this.$store.dispatch('updateOrderPos', false)
this.$store.dispatch('updatePaymentPos', false)
}) })
}, },
reverseSalesTransaction() { reverseSalesTransaction() {

View File

@ -241,7 +241,8 @@ export default {
}) })
}) })
}, },
listPayments({ commit, rootGetters }, { posUuid, orderUuid }) { listPayments({ commit, dispatch }, { posUuid, orderUuid }) {
dispatch('updatePaymentPos', true)
requestListPayments({ requestListPayments({
posUuid, posUuid,
orderUuid orderUuid
@ -252,6 +253,9 @@ export default {
.catch(error => { .catch(error => {
console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`) console.warn(`ListPaymentsFromServer: ${error.message}. Code: ${error.code}.`)
}) })
.finally(() => {
dispatch('updatePaymentPos', false)
})
}, },
tenderTypeDisplaye({ commit }, tenderType) { tenderTypeDisplaye({ commit }, tenderType) {
const displayTenderType = tenderType.map(item => { const displayTenderType = tenderType.map(item => {

View File

@ -28,7 +28,8 @@ const initStateUtils = {
splitWidthRight: 3, splitWidthRight: 3,
splitWidthLeft: 3, splitWidthLeft: 3,
parametersProcessPos: [], parametersProcessPos: [],
updateOrder: false updateOrder: false,
updatePayment: false
} }
export default { export default {
@ -97,6 +98,9 @@ export default {
}, },
setUpdateOrder(state, order) { setUpdateOrder(state, order) {
state.updateOrder = order state.updateOrder = order
},
setUpdatePayment(state, payment) {
state.updatePayment = payment
} }
}, },
actions: { actions: {
@ -160,6 +164,9 @@ export default {
}, },
updateOrderPos({ commit }, params) { updateOrderPos({ commit }, params) {
commit('setUpdateOrder', params) commit('setUpdateOrder', params)
},
updatePaymentPos({ commit }, params) {
commit('setUpdatePayment', params)
} }
}, },
getters: { getters: {
@ -229,6 +236,9 @@ export default {
}, },
getUpdateOrderPos: (state) => { getUpdateOrderPos: (state) => {
return state.updateOrder return state.updateOrder
},
getUpdatePaymentPos: (state) => {
return state.updatePayment
} }
} }
} }