perf: 优化 detail 中 component

This commit is contained in:
ibuler
2025-03-20 14:17:19 +08:00
committed by 老广
parent 1782c8af74
commit 8a5c60a9bc
2 changed files with 19 additions and 4 deletions

View File

@@ -256,19 +256,29 @@ export default {
}
},
getDetailComponent({ detailRoute }) {
const route = this.resolveRoute(detailRoute)
if (route) {
return route.components.default
if (!detailRoute) {
return this.detailDrawer
}
this.$log.debug('>>> getDetailComponent: ', detailRoute)
const route = this.resolveRoute(detailRoute)
let component = null
if (route) {
component = route.components.default
}
if (!component) {
component = this.detailDrawer
}
return component
},
getDrawerComponent(action, payload) {
this.$log.debug('>>> getDrawerComponent: ', action, payload)
switch (action) {
case 'create':
return this.createDrawer
case 'update':
return this.updateDrawer || this.createDrawer
case 'detail':
return this.detailDrawer || this.getDetailComponent(payload)
return this.getDetailComponent(payload)
case 'clone':
return this.createDrawer || this.getDefaultDrawer('create')
default:
@@ -287,6 +297,7 @@ export default {
// 3. 设置组件
this.drawerComponent = this.getDrawerComponent(action, payload)
this.$log.debug('>>> drawerComponent: ', this.drawerComponent)
this.drawerTitle = this.getActionDrawerTitle({ action, row, col, cellValue, payload })
// 4. 如果没有组件,尝试获取默认组件

View File

@@ -22,6 +22,10 @@ export default {
formatter: DetailFormatter,
formatterArgs: {
drawer: true,
getRoute: ({ row }) => ({
name: 'AssetDetail',
params: { id: row.asset.id }
}),
can: this.$hasPerm('assets.view_asset'),
getTitle: ({ row }) => row.asset.name
}