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

support to pin the pos (#865)

* support to pin the pos

* close popover the ping

Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
This commit is contained in:
Elsio Sanchez 2021-05-21 19:52:00 -04:00 committed by GitHub
parent aa8dbd84b6
commit 3476523568
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 81 additions and 28 deletions

View File

@ -614,3 +614,26 @@ export function processOrder({
return processOrderResponse return processOrderResponse
}) })
} }
/**
* Validate Ping
* @param {string} posUuidd - POS UUID reference
* @param {string} pin - User PIN
* @returns {string}
*/
export function validatePin({
posUuid,
pin
}) {
return request({
url: '/form/addons/point-of-sales/validate-pin',
method: 'post',
data: {
pos_uuid: posUuid,
pin: pin
}
})
.then(pinResponse => {
return pinResponse
})
}

View File

@ -28,6 +28,7 @@
<field <field
v-if="field.columnName === 'PriceEntered'" v-if="field.columnName === 'PriceEntered'"
:key="field.columnName" :key="field.columnName"
:ref="field.columnName"
:metadata-field="{ :metadata-field="{
...field, ...field,
isReadOnly: !isModifyPrice isReadOnly: !isModifyPrice
@ -39,17 +40,17 @@
:metadata-field="field" :metadata-field="field"
/> />
<el-popover <el-popover
v-if="columnNameVisible === field.columnName" v-if="columnNameVisible === field.columnName && visible"
ref="ping" ref="ping"
v-model="visible" v-model="visible"
placement="right" placement="right"
trigger="click" trigger="click"
> >
<el-form label-position="top" label-width="10px" @submit.native.prevent="notSubmitForm"> <el-form label-position="top" label-width="10px" @submit.native.prevent="notSubmitForm">
<el-form-item label="Ingrese Ping"> <el-form-item :label="$t('form.pos.tableProduct.pin')">
<el-input <el-input
v-model="input" v-model="pin"
placeholder="Ingrese Ping" :placeholder="$t('form.pos.tableProduct.pin')"
clearable clearable
/> />
</el-form-item> </el-form-item>
@ -63,13 +64,14 @@
<el-button <el-button
type="primary" type="primary"
icon="el-icon-check" icon="el-icon-check"
@click="checkclosePing" @click="checkclosePin(pin, field.columnName)"
/> />
</span> </span>
<el-button slot="reference" type="text" disabled @click="visible = !visible" /> <el-button slojt="reference" type="text" disabled />
</el-popover> </el-popover>
<field <field
v-if="field.columnName === 'Discount'" v-if="field.columnName === 'Discount'"
:ref="field.columnName"
:key="field.columnName" :key="field.columnName"
:metadata-field="{ :metadata-field="{
...field, ...field,
@ -95,9 +97,9 @@
<script> <script>
import { import {
// createFieldFromDefinition,
createFieldFromDictionary createFieldFromDictionary
} from '@/utils/ADempiere/lookupFactory' } from '@/utils/ADempiere/lookupFactory'
import { validatePin } from '@/api/ADempiere/form/point-of-sales.js'
import fieldsListLine from './fieldsListLine.js' import fieldsListLine from './fieldsListLine.js'
import Field from '@/components/ADempiere/Field' import Field from '@/components/ADempiere/Field'
@ -129,10 +131,9 @@ export default {
panelType: 'custom', panelType: 'custom',
fieldsListLine, fieldsListLine,
fieldsList: [], fieldsList: [],
input: '', pin: '',
visible: false, visible: false,
columnNameVisible: '', columnNameVisible: ''
validatePing: false
} }
}, },
computed: { computed: {
@ -145,14 +146,21 @@ export default {
}, },
isPosRequiredPin() { isPosRequiredPin() {
const pos = this.$store.getters.posAttributes.currentPointOfSales const pos = this.$store.getters.posAttributes.currentPointOfSales
if (!this.isEmptyValue(pos.isPosRequiredPin) && !this.validatePing) { if (!this.isEmptyValue(pos.isPosRequiredPin) && !this.validatePin) {
return pos.isPosRequiredPin return pos.isPosRequiredPin
} }
return false return false
},
currentPointOfSales() {
return this.$store.getters.posAttributes.currentPointOfSales
},
validatePin() {
return this.$store.state['pointOfSales/orderLine/index'].validatePin
} }
}, },
watch: { watch: {
showField(value) { showField(value) {
this.visible = false
if (value && this.isEmptyValue(this.metadataList) && (this.dataLine.uuid === this.$store.state['pointOfSales/orderLine/index'].line.uuid)) { if (value && this.isEmptyValue(this.metadataList) && (this.dataLine.uuid === this.$store.state['pointOfSales/orderLine/index'].line.uuid)) {
this.metadataList = this.setFieldsList() this.metadataList = this.setFieldsList()
this.isLoadedField = true this.isLoadedField = true
@ -227,14 +235,31 @@ export default {
}, },
closePing() { closePing() {
this.$refs.ping[this.$refs.ping.length - 1].showPopper = false this.$refs.ping[this.$refs.ping.length - 1].showPopper = false
this.visible = false
}, },
checkclosePing() { checkclosePin(pin) {
this.validatePing = true validatePin({
posUuid: this.currentPointOfSales.uuid,
pin
})
.then(response => {
this.$store.commit('pin', true)
this.pin = ''
})
.catch(error => {
console.error(error.message)
this.$message({
type: 'error',
message: error.message,
showClose: true
})
this.pin = ''
})
this.closePing() this.closePing()
}, },
subscribeChanges() { subscribeChanges() {
return this.$store.subscribe((mutation, state) => { return this.$store.subscribe((mutation, state) => {
if (mutation.type === 'addFocusGained' && this.isPosRequiredPin) { if (mutation.type === 'addFocusGained' && this.isPosRequiredPin && (mutation.payload.columnName === 'PriceEntered' || mutation.payload.columnName === 'Discount')) {
this.columnNameVisible = mutation.payload.columnName this.columnNameVisible = mutation.payload.columnName
this.visible = true this.visible = true
} }

View File

@ -125,25 +125,26 @@ export default {
}, },
updateOrderLine(line) { updateOrderLine(line) {
let quantity, price, discountRate let quantity, price, discountRate
const currentLine = this.$store.state['pointOfSales/orderLine/index'].line
switch (line.columnName) { switch (line.columnName) {
case 'QtyEntered': case 'QtyEntered':
quantity = line.value quantity = line.value
price = line.line.price price = currentLine.price
discountRate = line.line.discountRate discountRate = currentLine.discountRate
break break
case 'PriceEntered': case 'PriceEntered':
price = line.value price = line.value
quantity = line.line.quantity quantity = currentLine.quantity
discountRate = line.line.discountRate discountRate = currentLine.discountRate
break break
case 'Discount': case 'Discount':
discountRate = line.value discountRate = line.value
price = line.line.price price = currentLine.price
quantity = line.line.quantity quantity = currentLine.quantity
break break
} }
requestUpdateOrderLine({ requestUpdateOrderLine({
orderLineUuid: line.line.uuid, orderLineUuid: currentLine.uuid,
quantity, quantity,
price, price,
discountRate discountRate
@ -154,6 +155,7 @@ export default {
quantityOrdered: response.quantity, quantityOrdered: response.quantity,
discount: response.discountRate discount: response.discountRate
}) })
this.$store.commit('pin', false)
this.fillOrderLine(response) this.fillOrderLine(response)
this.$store.dispatch('reloadOrder', { orderUuid: this.$store.getters.posAttributes.currentPointOfSales.currentOrder.uuid }) this.$store.dispatch('reloadOrder', { orderUuid: this.$store.getters.posAttributes.currentPointOfSales.currentOrder.uuid })
this.$store.dispatch('currentLine', response) this.$store.dispatch('currentLine', response)
@ -209,8 +211,8 @@ export default {
return price / discount * 100 return price / discount * 100
}, },
handleCurrentLineChange(rowLine) { handleCurrentLineChange(rowLine) {
this.$store.dispatch('currentLine', rowLine)
if (!this.isEmptyValue(rowLine)) { if (!this.isEmptyValue(rowLine)) {
this.$store.dispatch('currentLine', rowLine)
this.currentOrderLine = rowLine this.currentOrderLine = rowLine
this.currentTable = this.listOrderLine.findIndex(item => item.uuid === rowLine.uuid) this.currentTable = this.listOrderLine.findIndex(item => item.uuid === rowLine.uuid)
if (this.isEmptyValue(this.currentOrderLine) && !this.isEmptyValue(this.listOrderLine)) { if (this.isEmptyValue(this.currentOrderLine) && !this.isEmptyValue(this.listOrderLine)) {

View File

@ -364,11 +364,8 @@ export default {
case 'QtyEntered': case 'QtyEntered':
case 'PriceEntered': case 'PriceEntered':
case 'Discount': case 'Discount':
if (!this.isEmptyValue(this.currentOrderLine)) { if (!this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) {
this.updateOrderLine({ this.updateOrderLine(mutation.payload)
...mutation.payload,
line: this.$store.state['pointOfSales/orderLine/index'].line
})
} }
break break
} }

View File

@ -438,6 +438,7 @@ export default {
quantity: 'Quantity', quantity: 'Quantity',
options: 'Options', options: 'Options',
editQuantities: 'Edit Quantities', editQuantities: 'Edit Quantities',
pin: 'Insert Pin',
remove: 'Remove' remove: 'Remove'
}, },
order: { order: {

View File

@ -414,6 +414,7 @@ export default {
quantity: 'Cantidad', quantity: 'Cantidad',
options: 'Opciones', options: 'Opciones',
editQuantities: 'Editar Cantidades', editQuantities: 'Editar Cantidades',
pin: 'Ingrese Pin',
remove: 'Eliminar' remove: 'Eliminar'
}, },
order: { order: {

View File

@ -24,5 +24,8 @@ export default {
}, },
setLine(state, line) { setLine(state, line) {
state.line = line state.line = line
},
pin(state, pin) {
state.validatePin = pin
} }
} }

View File

@ -20,5 +20,6 @@
export default { export default {
listOrderLine: [], listOrderLine: [],
line: {} line: {},
validatePin: false
} }