mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-11 21:53:24 +08:00
Add Export to Smart Browser (#159)
This commit is contained in:
parent
3edd9c0fa6
commit
4a4872e11e
@ -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({
|
||||||
|
header: tHeader,
|
||||||
|
data,
|
||||||
|
filename: ''
|
||||||
})
|
})
|
||||||
.catch(error => {
|
|
||||||
console.warn(error)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user