1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 20:39:48 +08:00

print label from table (#560)

* print label from table

* minimal changes

* correcting currency conversion errors

* remove switch

* minimal change
This commit is contained in:
Elsio Sanchez 2020-12-14 12:19:43 -04:00 committed by GitHub
parent d63ef5aeb6
commit 0b9e4e7df4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 479 additions and 53 deletions

View File

@ -1,6 +1,8 @@
<template>
<div>
<product-info-list />
<product-info-list
:report-asociated="process"
/>
</div>
</template>
@ -10,6 +12,7 @@
*/
import ProductInfoList from './productList'
import fieldMixin from '@/components/ADempiere/Field/mixin/mixinField.js'
import staticReportRoutes from '@/utils/ADempiere/constants/zoomReport'
import {
formatPrice,
formatQuantity
@ -25,7 +28,8 @@ export default {
],
data() {
return {
timeOut: null
timeOut: null,
process: staticReportRoutes
}
},
computed: {
@ -49,6 +53,9 @@ export default {
}
return []
},
currentPos() {
return this.$store.getters.getCurrentPOS
},
keyShortcuts() {
return {
refreshList: ['f5'],
@ -56,8 +63,16 @@ export default {
}
}
},
beforeMount() {
// beforeMount() {
// if (this.isEmptyValue(this.currentPos)) {
// this.$store.dispatch('listPointOfSalesFromServer')
// }
// },
created() {
// if (this.isEmptyValue(this.currentPos)) {
this.$store.dispatch('listPointOfSalesFromServer')
this.findProcess(this.process)
// }
},
methods: {
formatPrice,
@ -132,6 +147,13 @@ export default {
// TODO: Verify with 'value' or 'searchValue' attribute
value: valueProduct
})
},
findProcess(procces) {
// if (this.isEmptyValue(this.currentPos)) {
procces.forEach(report => {
this.$store.dispatch('getProcessFromServer', { containerUuid: report.uuid })
})
// }
}
}
}

View File

@ -15,7 +15,6 @@
:metadata-field="field"
/>
</el-form>
<el-table
ref="singleTable"
v-loading="!productPrice.isLoaded"
@ -54,7 +53,7 @@
<el-table-column
:label="$t('form.productInfo.quantityOnHand')"
align="right"
width="200"
width="100"
>
<template slot-scope="scope">
{{ formatQuantity(scope.row.quantityOnHand) }}
@ -63,7 +62,6 @@
<el-table-column
:label="$t('form.productInfo.price')"
align="right"
width="200"
>
<template slot-scope="scope">
{{ formatPrice(scope.row.priceStandard, scope.row.currency.iSOCode) }}
@ -72,7 +70,7 @@
<el-table-column
:label="$t('form.productInfo.taxAmount')"
align="right"
width="150"
width="200"
>
<template slot-scope="scope">
{{ formatPrice(getTaxAmount(scope.row.priceStandard, scope.row.taxRate.rate), scope.row.currency.iSOCode) }}
@ -87,6 +85,28 @@
{{ formatPrice(getTaxAmount(scope.row.priceStandard, scope.row.taxRate.rate) + scope.row.priceStandard, scope.row.currency.iSOCode) }}
</template>
</el-table-column>
<el-table-column
label=""
width="120"
>
<template slot-scope="scope">
<el-dropdown trigger="click">
<span class="el-dropdown-link">
{{ $t('form.pos.tableProduct.options') }}
<i class="el-icon-arrow-down el-icon--right" />
</span>
<el-dropdown-menu slot="dropdown" style="padding-bottom: 0px;">
<span v-show="!isEmptyValue(process)">
<el-dropdown-item v-for="(report, key) in process" :key="key" icon="el-icon-document">
<span @click="associatedprocesses(scope.row.product.id, report)">
{{ report.name }}
</span>
</el-dropdown-item>
</span>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<custom-pagination
:total="productPrice.recordCount"
@ -127,6 +147,12 @@ export default {
popoverName: {
type: String,
default: 'isShowPopoverField'
},
reportAsociated: {
type: Array,
default() {
return []
}
}
},
data() {
@ -135,7 +161,8 @@ export default {
resource: {},
fieldsList: fieldsListProductPrice,
isCustomForm: true,
timeOut: null
timeOut: null,
indexTable: 0
}
},
computed: {
@ -160,13 +187,38 @@ export default {
},
shortsKey() {
return {
closeProductList: ['esc'],
refreshList: ['enter']
options: ['enter'],
up: ['arrowup'],
down: ['arrowdown']
}
},
isReadyFromGetData() {
const { isLoaded, isReload } = this.productPrice
return (!isLoaded || isReload) // && this.isShowProductsPriceList
},
listPrice() {
const pos = this.$store.getters.getCurrentPOS
if (!this.isEmptyValue(pos)) {
return pos.priceList.id
}
return 0
},
process() {
if (!this.isEmptyValue(this.reportAsociated)) {
const process = this.reportAsociated.map(element => {
const findProcess = this.$store.getters.getProcess(element.uuid)
if (!this.isEmptyValue(findProcess)) {
return {
...element,
name: findProcess.name,
id: findProcess.id
}
}
return []
})
return process
}
return []
}
},
watch: {
@ -174,6 +226,9 @@ export default {
if (isToLoad) {
this.loadProductsPricesList()
}
},
indexTable(value) {
this.setCurrent(this.listWithPrice[value])
}
},
created() {
@ -206,6 +261,7 @@ export default {
},
handleCurrentChange(val) {
this.currentRow = val
this.findPosition(val)
this.setCurrent(this.currentRow)
},
keyAction(event) {
@ -224,6 +280,19 @@ export default {
isShowed: false
})
break
case 'down':
if (this.indexTable < (this.listWithPrice.length - 1)) {
this.indexTable++
}
break
case 'up':
if (this.indexTable > 0) {
this.indexTable--
}
break
case 'options':
this.$store.commit('setIsReloadProductPrice')
break
}
},
loadProductsPricesList() {
@ -259,6 +328,23 @@ export default {
}
return (basePrice * taxRate) / 100
},
associatedprocesses(product, report) {
report.parametersList.push({ columnName: 'M_Product_ID', value: product }, { columnName: 'M_PriceList_ID', value: this.listPrice })
this.$store.dispatch('processOption', {
action: report,
parametersList: report.parametersList,
reportFormat: 'pdf',
routeToDelete: this.$route
})
},
findPosition(current) {
const arrow = this.listWithPrice.findIndex(element => {
if (element.product.id === current.product.id) {
return element
}
})
this.indexTable = arrow
},
subscribeChanges() {
return this.$store.subscribe((mutation, state) => {
// if (!this.isEmptyValue(this.listWithPrice)) {
@ -270,7 +356,9 @@ export default {
clearTimeout(this.timeOut)
this.timeOut = setTimeout(() => {
this.$store.dispatch('updateSearch', mutation.payload.value)
this.$store.commit('setIsReloadProductPrice')
if (this.productPrice.isLoaded) {
this.$store.commit('setIsReloadProductPrice')
}
}, 1000)
}
})

View File

@ -414,12 +414,14 @@ export default {
})
},
currencyUuid(value) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value,
conversionDate: this.currentOrder.dateOrdered
})
if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value,
conversionDate: this.currentOrder.dateOrdered
})
}
},
convertAllPayment(value) {
if (!this.isEmptyValue(value)) {
@ -428,12 +430,16 @@ export default {
this.allPayCurrency = this.pay
},
converCurrency(value) {
this.$store.dispatch('conversionMultiplyRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value,
conversionDate: this.currentOrder.dateOrdered
})
if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value,
conversionDate: this.currentOrder.dateOrdered
})
} else {
this.$store.commit('currencyMultiplyRate', 1)
}
},
isLoaded(value) {
if (value) {

View File

@ -234,7 +234,27 @@
<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.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"><b>{{ $t('form.pos.order.total') }}:</b><b style="float: right;">{{ formatPrice(order.grandTotal, currencyPoint.iSOCode) }}</b></p>
<p class="total">
<b>
{{ $t('form.pos.order.total') }}:
</b>
<b style="float: right;">
<el-popover
placement="top-start"
trigger="click"
>
<convert-amount
:convert="multiplyRate"
:amount="order.grandTotal"
:currency="currencyPoint"
/>
<el-button slot="reference" type="text" style="color: #000000;font-weight: 604!important;font-size: 100%;">
{{ formatPrice(order.grandTotal, currencyPoint.iSOCode) }}
</el-button>
</el-popover>
<!-- {{ formatPrice(order.grandTotal, currencyPoint.iSOCode) }} -->
</b>
</p>
</span>
<span style="float: right;padding-right: 40px;">
<p class="total">{{ $t('form.pos.order.order') }}: <b class="order-info">{{ order.documentNo }}</b></p>
@ -288,12 +308,14 @@ import fieldsListOrder from './fieldsListOrder.js'
import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js'
import BusinessPartner from '@/components/ADempiere/Form/VPOS/BusinessPartner'
import ProductInfo from '@/components/ADempiere/Form/VPOS/ProductInfo'
import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index'
export default {
name: 'Order',
components: {
BusinessPartner,
ProductInfo
ProductInfo,
convertAmount
},
mixins: [
formMixin,
@ -368,6 +390,49 @@ export default {
iSOCode: '',
curSymbol: ''
}
},
multiplyRate() {
return this.$store.getters.getMultiplyRate
},
converCurrency() {
return this.$store.getters.getValueOfField({
containerUuid: 'Collection-Convert-Amount',
columnName: 'C_Currency_ID_UUID'
})
},
currencyUuid() {
return this.$store.getters.getValueOfField({
containerUuid: this.containerUuid,
columnName: 'C_Currency_ID_UUID'
})
},
displayeTypeCurrency() {
return this.$store.getters.getValueOfField({
containerUuid: this.containerUuid,
columnName: 'DisplayColumn_C_Currency_ID'
})
}
},
watch: {
currencyUuid(value) {
if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value
})
}
},
converCurrency(value) {
if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', {
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value
})
} else {
this.$store.commit('currencyMultiplyRate', 1)
}
}
},
methods: {
@ -528,7 +593,12 @@ export default {
color: #333;
line-height: 10px;
}
.el-button--text {
border-color: transparent;
color: #1890ff;
background: transparent;
padding: 0px;
}
.el-aside {
color: #333;
}

View File

@ -77,31 +77,28 @@ const collection = {
conversionMultiplyRate({ commit }, {
conversionTypeUuid,
currencyFromUuid,
currencyToUuid,
conversionDate
currencyToUuid
// conversionDate
}) {
return Promise(resolve => {
requestGetConversionRate({
conversionTypeUuid,
currencyFromUuid,
currencyToUuid,
conversionDate
})
.then(response => {
const multiplyRate = isEmptyValue(response.multiplyRate) ? 1 : response.multiplyRate
commit('currencyMultiplyRate', multiplyRate)
resolve(multiplyRate)
})
.catch(error => {
console.warn(`conversionMultiplyRate: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
showClose: true
})
})
requestGetConversionRate({
conversionTypeUuid,
currencyFromUuid,
currencyToUuid
// conversionDate
})
.then(response => {
const multiplyRate = isEmptyValue(response.multiplyRate) ? 1 : response.multiplyRate
commit('currencyMultiplyRate', multiplyRate)
})
.catch(error => {
console.warn(`conversionMultiplyRate: ${error.message}. Code: ${error.code}.`)
showMessage({
type: 'error',
message: error.message,
showClose: true
})
})
},
changeMultiplyRate({ commit }, params) {
commit('currencyMultiplyRate', params)

View File

@ -49,7 +49,6 @@ const pointOfSales = {
*/
listPointOfSalesFromServer({ commit, getters, dispatch }, posToSet = null) {
const userUuid = getters['user/getUserUuid']
requestListPointOfSales({
userUuid
})

View File

@ -114,7 +114,7 @@ const processControl = {
containerUuid,
panelType,
action,
parametersList = [],
parametersList,
reportFormat,
isProcessTableSelection,
isActionDocument,
@ -660,6 +660,236 @@ const processControl = {
}
})
},
processOption({ commit, dispatch, getters, rootGetters }, {
parentUuid,
containerUuid,
panelType,
action,
parametersList = [],
reportFormat,
menuParentUuid,
routeToDelete
}) {
return new Promise((resolve, reject) => {
// get info metadata process
const processDefinition = rootGetters.getProcess(action.uuid)
const reportType = reportFormat
const isSession = !isEmptyValue(getToken())
let procesingMessage = {
close: () => false
}
if (isSession) {
procesingMessage = showNotification({
title: language.t('notifications.processing'),
message: processDefinition.name,
summary: processDefinition.description,
type: 'info'
})
}
const timeInitialized = (new Date()).getTime()
let processResult = {
// panel attributes from where it was executed
parentUuid,
containerUuid,
panelType,
lastRun: timeInitialized,
parametersList,
logs: [],
isError: false,
isProcessing: true,
summary: '',
resultTableName: '',
output: {
uuid: '',
name: '',
description: '',
fileName: '',
output: '',
outputStream: '',
reportType: ''
}
}
// Run process on server and wait for it for notify
// uuid of process
processResult = {
...processResult,
menuParentUuid,
processIdPath: routeToDelete.path,
printFormatUuid: '',
// process attributes
action: processDefinition.name,
name: processDefinition.name,
description: processDefinition.description,
instanceUuid: '',
processUuid: processDefinition.uuid,
processId: processDefinition.id,
processName: processDefinition.processName,
parameters: parametersList,
isReport: processDefinition.isReport
}
commit('addInExecution', processResult)
requestRunProcess({
uuid: processDefinition.uuid,
id: processDefinition.id,
reportType,
parametersList
})
.then(runProcessResponse => {
const { instanceUuid, output } = runProcessResponse
let logList = []
if (!isEmptyValue(runProcessResponse.logsList)) {
logList = runProcessResponse.logsList
}
let link = {
href: undefined,
download: undefined
}
if ((runProcessResponse.isReport || processDefinition.isReport) && output.outputStream) {
const reportObject = Object.values(output.outputStream)
const blob = new Blob([Uint8Array.from(reportObject)], {
type: output.mimeType
})
link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = output.fileName
if (reportType !== 'pdf' && reportType !== 'html') {
link.click()
}
const contextMenuMetadata = rootGetters.getContextMenu(processResult.processUuid)
// Report views List to context menu
const reportViewList = {
name: language.t('views.reportView'),
type: 'summary',
action: '',
childs: [],
option: 'reportView'
}
reportViewList.childs = getters.getReportViewList(processResult.processUuid)
if (reportViewList && !reportViewList.childs.length) {
dispatch('getReportViewsFromServer', {
processUuid: processResult.processUuid,
instanceUuid,
processId: processDefinition.id,
tableName: output.tableName,
printFormatUuid: output.printFormatUuid,
reportViewUuid: output.reportViewUuid
})
.then(responseReportView => {
reportViewList.childs = responseReportView
if (reportViewList.childs.length) {
// Get contextMenu metadata and concat print report views with contextMenu actions
contextMenuMetadata.actions.push(reportViewList)
}
})
}
// Print formats to context menu
const printFormatList = {
name: language.t('views.printFormat'),
type: 'summary',
action: '',
childs: [],
option: 'printFormat'
}
printFormatList.childs = rootGetters.getPrintFormatList(processResult.processUuid)
if (printFormatList && !printFormatList.childs.length) {
dispatch('getListPrintFormats', {
processUuid: processResult.processUuid,
instanceUuid,
processId: processDefinition.id,
tableName: output.tableName,
printFormatUuid: output.printFormatUuid,
reportViewUuid: output.reportViewUuid
})
.then(printFormarResponse => {
printFormatList.childs = printFormarResponse
if (printFormatList.childs.length) {
// Get contextMenu metadata and concat print Format List with contextMenu actions
contextMenuMetadata.actions.push(printFormatList)
}
})
} else {
const index = contextMenuMetadata.actions.findIndex(action => action.option === 'printFormat')
if (index !== -1) {
contextMenuMetadata.actions[index] = printFormatList
}
}
// Drill Tables to context menu
const drillTablesList = {
name: language.t('views.drillTable'),
type: 'summary',
action: '',
childs: [],
option: 'drillTable'
}
if (!isEmptyValue(output.tableName)) {
drillTablesList.childs = rootGetters.getDrillTablesList(processResult.processUuid)
if (drillTablesList && isEmptyValue(drillTablesList.childs)) {
dispatch('getDrillTablesFromServer', {
processUuid: processResult.processUuid,
instanceUuid,
processId: processDefinition.id,
tableName: output.tableName,
printFormatUuid: output.printFormatUuid,
reportViewUuid: output.reportViewUuid
})
.then(drillTablesResponse => {
drillTablesList.childs = drillTablesResponse
if (drillTablesList.childs.length) {
// Get contextMenu metadata and concat print Format List with contextMenu actions
contextMenuMetadata.actions.push(drillTablesList)
}
})
}
}
}
// assign new attributes
Object.assign(processResult, {
...runProcessResponse,
url: link.href,
download: link.download,
logs: logList,
output
})
resolve(processResult)
if (!isEmptyValue(processResult.output)) {
dispatch('setReportTypeToShareLink', processResult.output.reportType)
}
})
.catch(error => {
Object.assign(processResult, {
isError: true,
message: error.message,
isProcessing: false
})
console.warn(`Error running the process ${error.message}. Code: ${error.code}.`)
reject(error)
})
.finally(() => {
commit('addNotificationProcess', processResult)
dispatch('finishProcess', {
processOutput: processResult,
procesingMessage
})
commit('deleteInExecution', {
containerUuid
})
dispatch('setProcessTable', {
valueRecord: 0,
tableName: '',
processTable: false
})
dispatch('setProcessSelect', {
finish: true
})
})
})
},
// Supported to process selection
selectionProcess({ commit, state, dispatch, getters, rootGetters }, {
parentUuid,
@ -946,7 +1176,7 @@ const processControl = {
}
if (processOutput.isReport && !processOutput.isError) {
// open report viewer with report response
let menuParentUuid = routeToDelete.params.menuParentUuid
let menuParentUuid = isEmptyValue(routeToDelete) ? '' : routeToDelete.params.menuParentUuid
if (isEmptyValue(menuParentUuid)) {
menuParentUuid = processOutput.menuParentUuid
}

View File

@ -0,0 +1,15 @@
const today = new Date()
export default [
{
uuid: '92b9a696-adba-4409-a200-7df0ba74cb63',
action: 'processOption',
tabChild: undefined,
parametersList: [{ columnName: 'ValidFrom', value: today }]
},
{
uuid: '78b249ee-613e-4241-a2c1-00243fa36470',
action: 'processOption',
tabChild: undefined,
parametersList: [{ columnName: 'ValidFrom', value: today }, { columnName: 'MustBeStocked', value: false }]
}
]

View File

@ -108,7 +108,6 @@ export default {
return this.formMetadata.name || this.$route.meta.title
},
fromFileName() {
console.log(this.$route)
return this.formMetadata.fileName || this.$route.meta.title
},
getterForm() {