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

Add Export to Smart Browser (#159)

This commit is contained in:
elsiosanchez 2019-11-20 17:45:01 -04:00 committed by Yamel Senih
parent 3edd9c0fa6
commit 4a4872e11e

View File

@ -102,6 +102,35 @@ export const contextMixin = {
isAdvancedQuery: this.$route.query.action === 'advancedQuery' isAdvancedQuery: this.$route.query.action === 'advancedQuery'
}) })
}, },
getterFieldList() {
return this.$store.getters.getFieldsListFromPanel(this.containerUuid)
},
getterFieldListHeader() {
var header = this.getterFieldList.filter(fieldItem => {
const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic
if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) {
return fieldItem.name
}
})
return header.map(fieldItem => {
return fieldItem.name
})
},
getterFieldListValue() {
var value = this.getterFieldList.filter(fieldItem => {
const isDisplayed = fieldItem.isDisplayed || fieldItem.isDisplayedFromLogic
if (fieldItem.isActive && isDisplayed && !fieldItem.isKey) {
return fieldItem
}
})
return value.map(fieldItem => {
if (fieldItem.componentPath === 'FieldSelect') {
return 'DisplayColumn_' + fieldItem.columnName
} else {
return fieldItem.columnName
}
})
},
getterDataLog() { getterDataLog() {
if (this.panelType === 'window') { if (this.panelType === 'window') {
return this.$store.getters.getDataLog(this.containerUuid, this.recordUuid) return this.$store.getters.getDataLog(this.containerUuid, this.recordUuid)
@ -194,16 +223,21 @@ export const contextMixin = {
} }
}, },
exporBrowser() { exporBrowser() {
this.$store.dispatch('startProcess', { import('@/vendor/Export2Excel').then(excel => {
parentUuid: this.parentUuid, const tHeader = this.getterFieldListHeader
containerUuid: this.containerUuid, const filterVal = this.getterFieldListValue
panelType: this.panelType, // determinate if get table name and record id (window) or selection (browser) const list = this.getDataSelection
reportFormat: this.exportDefault const data = this.formatJson(filterVal, list)
}) excel.export_json_to_excel({
.catch(error => { header: tHeader,
console.warn(error) data,
filename: ''
})
}) })
}, },
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
},
generateContextMenu() { generateContextMenu() {
this.metadataMenu = this.getterContextMenu this.metadataMenu = this.getterContextMenu
this.actions = this.metadataMenu.actions this.actions = this.metadataMenu.actions