mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-25 14:34:46 +00:00
perf: 优化 detail 中 component
This commit is contained in:
@@ -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. 如果没有组件,尝试获取默认组件
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user