feat: 修改detail formatter

This commit is contained in:
ibuler
2020-06-11 11:11:06 +08:00
parent 840c0ed8b8
commit 14aacdd55b
2 changed files with 26 additions and 4 deletions

View File

@@ -95,7 +95,8 @@
},
"browserslist": [
"> 1%",
"last 2 versions"
"last 4 versions",
"ie 11"
],
"husky": {
"hooks": {

View File

@@ -13,6 +13,7 @@ export default {
default() {
return {
route: this.$route.name.replace('List', 'Detail'),
getRoute: null,
routeQuery: {},
getTitle({ col, row, cellValue }) {
return cellValue
@@ -31,10 +32,30 @@ export default {
methods: {
goDetail() {
// const defaultRoute = this.$route.name.replace('List', 'Detail')
const routeName = this.formatterArgs.route
let route = this.formatterArgs.route
if (this.getRoute && typeof this.getRoute === 'function') {
route = this.getRoute({ row: this.row, col: this.col, cellValue: this.cellValue })
}
if (!route) {
console.error('No route found')
return
}
let detailRoute = {}
if (typeof route === 'string') {
detailRoute.name = route
detailRoute.params = { id: this.row.id }
} else {
detailRoute = route
}
const routeQuery = this.formatterArgs.routeQuery
this.$log.debug('Will go to detail route: ', routeName)
this.$router.push({ name: routeName, params: { id: this.row.id }, query: routeQuery })
if (routeQuery && typeof routeQuery === 'object') {
detailRoute.query = this.formatterArgs.routeQuery
}
this.route.push(detailRoute)
// const routeName = this.formatterArgs.route
// this.$log.debug('Will go to detail route: ', routeName)
// this.$router.push({ name: routeName, params: { id: this.row.id }, query: routeQuery })
}
}
}