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

Feature/rename pos objects (#922)

* Rename POS attributres and mutations to set

* Add list warehouse from cache
This commit is contained in:
Yamel Senih 2021-06-15 10:07:06 -04:00 committed by GitHub
parent 5211bc3ef5
commit 64d38b59a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 56 additions and 55 deletions

View File

@ -317,7 +317,7 @@ export default {
return this.$store.state['pointOfSales/point/index'].listCurrency
},
convertionList() {
return this.$store.state['pointOfSales/point/index'].conversionList
return this.$store.state['pointOfSales/point/index'].conversionsList
},
validateCompleteCollection() {
let collection

View File

@ -218,14 +218,14 @@
</el-dropdown>
<br>
<el-dropdown
v-if="!isEmptyValue(curretnWarehouse)"
v-if="!isEmptyValue(currentWarehouse)"
trigger="click"
class="info-pos"
@command="changeWarehouse"
>
<span>
<svg-icon icon-class="tree" />
{{ $t('route.warehouse') }}: <b style="cursor: pointer"> {{ curretnWarehouse.name }} </b>
{{ $t('route.warehouse') }}: <b style="cursor: pointer"> {{ currentWarehouse.name }} </b>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
@ -239,14 +239,14 @@
</el-dropdown>
<br>
<el-dropdown
v-if="!isEmptyValue(curretnPriceList)"
v-if="!isEmptyValue(currentPriceList)"
trigger="click"
class="info-pos"
@command="changePriceList"
>
<span>
<svg-icon icon-class="tree-table" />
{{ $t('form.pos.priceList') }}: <b style="cursor: pointer"> {{ curretnPriceList.name }} </b>
{{ $t('form.pos.priceList') }}: <b style="cursor: pointer"> {{ currentPriceList.name }} </b>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
@ -523,7 +523,7 @@ export default {
}
},
listPointOfSales() {
return this.$store.getters.posAttributes.listPointOfSales
return this.$store.getters.posAttributes.pointOfSalesList
},
ordersList() {
if (this.isEmptyValue(this.currentPointOfSales)) {
@ -562,28 +562,28 @@ export default {
const line = this.$store.state['pointOfSales/orderLine/index'].line
return line
},
curretnPriceList() {
currentPriceList() {
if (!this.isEmptyValue(this.$store.getters.currentPriceList)) {
return this.$store.getters.currentPriceList
}
return {}
},
pointPriceList() {
const list = this.$store.getters.posAttributes.currentPointOfSales.listPrices
const list = this.$store.getters.posAttributes.currentPointOfSales.pricesList
if (this.isEmptyValue(list)) {
return []
}
return list
},
curretnWarehouse() {
currentWarehouse() {
if (!this.isEmptyValue(this.$store.getters['user/getWarehouse'])) {
return this.$store.getters['user/getWarehouse']
}
return {}
},
listWarehouse() {
if (!this.isEmptyValue(this.$store.getters.currentWarehouse)) {
return this.$store.getters.currentWarehouse
if (!this.isEmptyValue(this.$store.getters.posAttributes.currentPointOfSales.warehousesList)) {
return this.$store.getters.posAttributes.currentPointOfSales.warehousesList
}
return []
}
@ -667,15 +667,15 @@ export default {
this.$store.dispatch('listOrderLine', [])
})
},
changePos(posElement) {
this.$store.dispatch('setCurrentPOS', posElement)
changePos(pointOfSales) {
this.$store.dispatch('setCurrentPOS', pointOfSales)
this.newOrder()
},
changeWarehouse(warehouse) {
this.$store.commit('currentWarehouse', warehouse)
this.$store.commit('setCurrentWarehouse', warehouse)
},
changePriceList(priceList) {
this.$store.commit('currentPriceList', priceList)
this.$store.commit('setCurrentPriceList', priceList)
},
arrowTop() {
if (this.currentTable > 0) {

View File

@ -86,7 +86,7 @@ export default {
}
},
listPointOfSales() {
return this.$store.getters.posAttributes.listPointOfSales
return this.$store.getters.posAttributes.pointOfSalesList
},
curretnPriceList() {
if (!this.isEmptyValue(this.$store.getters.currentPriceList)) {
@ -95,14 +95,14 @@ export default {
return {}
},
priceListPointOfSales() {
const list = this.$store.getters.posAttributes.currentPointOfSales.listPrices
const list = this.$store.getters.posAttributes.currentPointOfSales.pricesList
if (this.isEmptyValue(list)) {
return []
}
return list
},
warehousesListPointOfSales() {
const list = this.$store.getters.posAttributes.currentPointOfSales.listWarehouses
const list = this.$store.getters.posAttributes.currentPointOfSales.warehousesList
if (this.isEmptyValue(list)) {
return []
}

View File

@ -111,7 +111,7 @@ export default {
return this.$store.getters.getShowCollectionPos
},
listPointOfSales() {
return this.$store.getters.posAttributes.listPointOfSales
return this.$store.getters.posAttributes.pointOfSalesList
}
},
watch: {

View File

@ -125,7 +125,7 @@ export default {
return this.$store.getters.getShowCollectionPos
},
listPointOfSales() {
return this.$store.getters.posAttributes.listPointOfSales
return this.$store.getters.posAttributes.pointOfSalesList
}
},
watch: {

View File

@ -50,12 +50,13 @@ export default {
*/
posAttributes: (state) => {
return {
listPointOfSales: state.listPointOfSales,
pointOfSalesList: state.pointOfSalesList,
currentPointOfSales: {
...state.currentPointOfSales,
listOrder: state.listOrder,
listWarehouses: state.listWarehouses,
listPrices: state.listPrices,
warehousesList: state.warehousesList,
pricesList: state.pricesList,
currentPriceList: state.currentPriceList,
currentOrder: {
...state.order,
lineOrder: state.listOrderLine,

View File

@ -119,7 +119,7 @@ export default {
conversionDate: params.conversionDate
})
.then(response => {
commit('conversionList', response)
commit('addConversionToList', response)
})
.catch(error => {
console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`)

View File

@ -34,22 +34,22 @@ export default {
*/
listPointOfSalesFromServer({ commit, getters, dispatch }, posToSet = null) {
const userUuid = getters['user/getUserUuid']
let pos, listPos
let pos, pontOfSalesList
listPointOfSales({
userUuid
})
.then(response => {
listPos = response.sellingPointsList
pontOfSalesList = response.sellingPointsList
if (!isEmptyValue(posToSet)) {
pos = listPos.find(itemPOS => itemPOS.id === parseInt(posToSet))
pos = pontOfSalesList.find(itemPOS => itemPOS.id === parseInt(posToSet))
}
if (isEmptyValue(pos) && isEmptyValue(posToSet)) {
pos = listPos.find(itemPOS => itemPOS.salesRepresentative.uuid === userUuid)
pos = pontOfSalesList.find(itemPOS => itemPOS.salesRepresentative.uuid === userUuid)
}
if (isEmptyValue(pos)) {
pos = listPos[0]
pos = pontOfSalesList[0]
}
commit('listPointOfSales', listPos)
commit('setPointOfSalesList', pontOfSalesList)
dispatch('setCurrentPOS', pos)
})
.catch(error => {
@ -66,7 +66,7 @@ export default {
posUuid
})
.then(response => {
commit('listWarehouses', response.records)
commit('setWarehousesList', response.records)
})
.catch(error => {
console.warn(`listWarehouseFromServer: ${error.message}. Code: ${error.code}.`)
@ -82,7 +82,7 @@ export default {
posUuid: point.uuid
})
.then(response => {
commit('listPrices', response.records)
commit('setPricesList', response.records)
})
.catch(error => {
console.warn(`listPricesFromServer: ${error.message}. Code: ${error.code}.`)
@ -98,7 +98,7 @@ export default {
posUuid
})
.then(response => {
commit('listCurrencies', response.records)
commit('setCurrenciesList', response.records)
})
.catch(error => {
console.warn(`listPricesFromServer: ${error.message}. Code: ${error.code}.`)
@ -110,7 +110,7 @@ export default {
})
},
setCurrentPOS({ commit, dispatch, rootGetters }, posToSet) {
commit('currentPointOfSales', posToSet)
commit('setCurrentPointOfSales', posToSet)
const oldRoute = router.app._route
router.push({
name: oldRoute.name,
@ -125,8 +125,8 @@ export default {
dispatch('listWarehouseFromServer', posToSet.uuid)
dispatch('listCurrenciesFromServer', posToSet.uuid)
dispatch('listPricesFromServer', posToSet)
commit('currentPriceList', posToSet.priceList)
commit('currentWarehouse', rootGetters['user/getWarehouse'])
commit('setCurrentPriceList', posToSet.priceList)
commit('setCurrentWarehouse', rootGetters['user/getWarehouse'])
commit('resetConversionRate', [])
commit('setIsReloadKeyLayout')
commit('setIsReloadProductPrice')

View File

@ -16,31 +16,31 @@
/**
* Pos Mutations
* @author Elsio Sanchez <elsiosanches@gmail.com>
* All related to global store of Point of Sales
*/
export default {
listPointOfSales(state, listPointOfSales) {
state.listPointOfSales = listPointOfSales
setPointOfSalesList(state, pointOfSalesList) {
state.pointOfSalesList = pointOfSalesList
},
listWarehouses(state, listWarehouses) {
state.listWarehouses = listWarehouses
setWarehousesList(state, warehousesList) {
state.warehousesList = warehousesList
},
currentPriceList(state, priceList) {
state.currentPriceList = priceList
setCurrentPriceList(state, currentPriceList) {
state.currentPriceList = currentPriceList
},
currentWarehouse(state, warehouse) {
setCurrentWarehouse(state, warehouse) {
state.currentWarehouse = warehouse
},
listPrices(state, listPrices) {
state.listPrices = listPrices
setPricesList(state, pricesList) {
state.pricesList = pricesList
},
listCurrencies(state, listCurrency) {
state.listCurrency = listCurrency
setCurrenciesList(state, currenciesList) {
state.currenciesList = currenciesList
},
conversionList(state, conversion) {
state.conversionList.push(conversion)
addConversionToList(state, conversion) {
state.conversionsList.push(conversion)
},
currentPointOfSales(state, currentPointOfSales) {
setCurrentPointOfSales(state, currentPointOfSales) {
state.currentPointOfSales = currentPointOfSales
},
setShowPOSOptions(state, isShowedOptions) {

View File

@ -27,13 +27,13 @@ export default {
pointOfSales: {
...withoutResponse
},
listPointOfSales: {},
listWarehouses: {},
listPrices: {},
pointOfSalesList: {},
warehousesList: {},
pricesList: {},
currentPriceList: {},
currentWarehouse: {},
listCurrency: [],
conversionList: [],
conversionsList: [],
currentPointOfSales: {},
showPOSOptions: false,
showPOSKeyLayout: false,