mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-07 18:25:45 +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:
parent
aa8dbd84b6
commit
3476523568
@ -614,3 +614,26 @@ export function processOrder({
|
||||
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
|
||||
})
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
<field
|
||||
v-if="field.columnName === 'PriceEntered'"
|
||||
:key="field.columnName"
|
||||
:ref="field.columnName"
|
||||
:metadata-field="{
|
||||
...field,
|
||||
isReadOnly: !isModifyPrice
|
||||
@ -39,17 +40,17 @@
|
||||
:metadata-field="field"
|
||||
/>
|
||||
<el-popover
|
||||
v-if="columnNameVisible === field.columnName"
|
||||
v-if="columnNameVisible === field.columnName && visible"
|
||||
ref="ping"
|
||||
v-model="visible"
|
||||
placement="right"
|
||||
trigger="click"
|
||||
>
|
||||
<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
|
||||
v-model="input"
|
||||
placeholder="Ingrese Ping"
|
||||
v-model="pin"
|
||||
:placeholder="$t('form.pos.tableProduct.pin')"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
@ -63,13 +64,14 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-check"
|
||||
@click="checkclosePing"
|
||||
@click="checkclosePin(pin, field.columnName)"
|
||||
/>
|
||||
</span>
|
||||
<el-button slot="reference" type="text" disabled @click="visible = !visible" />
|
||||
<el-button slojt="reference" type="text" disabled />
|
||||
</el-popover>
|
||||
<field
|
||||
v-if="field.columnName === 'Discount'"
|
||||
:ref="field.columnName"
|
||||
:key="field.columnName"
|
||||
:metadata-field="{
|
||||
...field,
|
||||
@ -95,9 +97,9 @@
|
||||
<script>
|
||||
|
||||
import {
|
||||
// createFieldFromDefinition,
|
||||
createFieldFromDictionary
|
||||
} from '@/utils/ADempiere/lookupFactory'
|
||||
import { validatePin } from '@/api/ADempiere/form/point-of-sales.js'
|
||||
import fieldsListLine from './fieldsListLine.js'
|
||||
import Field from '@/components/ADempiere/Field'
|
||||
|
||||
@ -129,10 +131,9 @@ export default {
|
||||
panelType: 'custom',
|
||||
fieldsListLine,
|
||||
fieldsList: [],
|
||||
input: '',
|
||||
pin: '',
|
||||
visible: false,
|
||||
columnNameVisible: '',
|
||||
validatePing: false
|
||||
columnNameVisible: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -145,14 +146,21 @@ export default {
|
||||
},
|
||||
isPosRequiredPin() {
|
||||
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 false
|
||||
},
|
||||
currentPointOfSales() {
|
||||
return this.$store.getters.posAttributes.currentPointOfSales
|
||||
},
|
||||
validatePin() {
|
||||
return this.$store.state['pointOfSales/orderLine/index'].validatePin
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
showField(value) {
|
||||
this.visible = false
|
||||
if (value && this.isEmptyValue(this.metadataList) && (this.dataLine.uuid === this.$store.state['pointOfSales/orderLine/index'].line.uuid)) {
|
||||
this.metadataList = this.setFieldsList()
|
||||
this.isLoadedField = true
|
||||
@ -227,14 +235,31 @@ export default {
|
||||
},
|
||||
closePing() {
|
||||
this.$refs.ping[this.$refs.ping.length - 1].showPopper = false
|
||||
this.visible = false
|
||||
},
|
||||
checkclosePing() {
|
||||
this.validatePing = true
|
||||
checkclosePin(pin) {
|
||||
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()
|
||||
},
|
||||
subscribeChanges() {
|
||||
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.visible = true
|
||||
}
|
||||
|
@ -125,25 +125,26 @@ export default {
|
||||
},
|
||||
updateOrderLine(line) {
|
||||
let quantity, price, discountRate
|
||||
const currentLine = this.$store.state['pointOfSales/orderLine/index'].line
|
||||
switch (line.columnName) {
|
||||
case 'QtyEntered':
|
||||
quantity = line.value
|
||||
price = line.line.price
|
||||
discountRate = line.line.discountRate
|
||||
price = currentLine.price
|
||||
discountRate = currentLine.discountRate
|
||||
break
|
||||
case 'PriceEntered':
|
||||
price = line.value
|
||||
quantity = line.line.quantity
|
||||
discountRate = line.line.discountRate
|
||||
quantity = currentLine.quantity
|
||||
discountRate = currentLine.discountRate
|
||||
break
|
||||
case 'Discount':
|
||||
discountRate = line.value
|
||||
price = line.line.price
|
||||
quantity = line.line.quantity
|
||||
price = currentLine.price
|
||||
quantity = currentLine.quantity
|
||||
break
|
||||
}
|
||||
requestUpdateOrderLine({
|
||||
orderLineUuid: line.line.uuid,
|
||||
orderLineUuid: currentLine.uuid,
|
||||
quantity,
|
||||
price,
|
||||
discountRate
|
||||
@ -154,6 +155,7 @@ export default {
|
||||
quantityOrdered: response.quantity,
|
||||
discount: response.discountRate
|
||||
})
|
||||
this.$store.commit('pin', false)
|
||||
this.fillOrderLine(response)
|
||||
this.$store.dispatch('reloadOrder', { orderUuid: this.$store.getters.posAttributes.currentPointOfSales.currentOrder.uuid })
|
||||
this.$store.dispatch('currentLine', response)
|
||||
@ -209,8 +211,8 @@ export default {
|
||||
return price / discount * 100
|
||||
},
|
||||
handleCurrentLineChange(rowLine) {
|
||||
this.$store.dispatch('currentLine', rowLine)
|
||||
if (!this.isEmptyValue(rowLine)) {
|
||||
this.$store.dispatch('currentLine', rowLine)
|
||||
this.currentOrderLine = rowLine
|
||||
this.currentTable = this.listOrderLine.findIndex(item => item.uuid === rowLine.uuid)
|
||||
if (this.isEmptyValue(this.currentOrderLine) && !this.isEmptyValue(this.listOrderLine)) {
|
||||
|
@ -364,11 +364,8 @@ export default {
|
||||
case 'QtyEntered':
|
||||
case 'PriceEntered':
|
||||
case 'Discount':
|
||||
if (!this.isEmptyValue(this.currentOrderLine)) {
|
||||
this.updateOrderLine({
|
||||
...mutation.payload,
|
||||
line: this.$store.state['pointOfSales/orderLine/index'].line
|
||||
})
|
||||
if (!this.isEmptyValue(this.$store.state['pointOfSales/orderLine/index'].line)) {
|
||||
this.updateOrderLine(mutation.payload)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -438,6 +438,7 @@ export default {
|
||||
quantity: 'Quantity',
|
||||
options: 'Options',
|
||||
editQuantities: 'Edit Quantities',
|
||||
pin: 'Insert Pin',
|
||||
remove: 'Remove'
|
||||
},
|
||||
order: {
|
||||
|
@ -414,6 +414,7 @@ export default {
|
||||
quantity: 'Cantidad',
|
||||
options: 'Opciones',
|
||||
editQuantities: 'Editar Cantidades',
|
||||
pin: 'Ingrese Pin',
|
||||
remove: 'Eliminar'
|
||||
},
|
||||
order: {
|
||||
|
@ -24,5 +24,8 @@ export default {
|
||||
},
|
||||
setLine(state, line) {
|
||||
state.line = line
|
||||
},
|
||||
pin(state, pin) {
|
||||
state.validatePin = pin
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,6 @@
|
||||
|
||||
export default {
|
||||
listOrderLine: [],
|
||||
line: {}
|
||||
line: {},
|
||||
validatePin: false
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user