perf: update detail

This commit is contained in:
ibuler
2025-02-13 15:08:04 +08:00
parent 1bdc27ea98
commit 9740c58291
8 changed files with 54 additions and 23 deletions

View File

@@ -4,12 +4,14 @@
<template v-for="item in items"> <template v-for="item in items">
<el-form-item v-if="item.has !== false" :key="item.key" :class="item.class" :label="item.key"> <el-form-item v-if="item.has !== false" :key="item.key" :class="item.class" :label="item.key">
<span slot="label"> {{ formateLabel(item.key) }}</span> <span slot="label"> {{ formateLabel(item.key) }}</span>
<span <span class="item-value">
:is="item.component" <template
v-if="item.component" :is="item.component"
v-bind="{...item}" v-if="item.component"
/> v-bind="{...item}"
<ItemValue v-else :value="item.value" class="item-value" v-bind="item" /> />
<ItemValue v-else :value="item.value" v-bind="item" />
</span>
</el-form-item> </el-form-item>
</template> </template>
</el-form> </el-form>
@@ -44,7 +46,7 @@ export default {
}, },
labelWidth: { labelWidth: {
type: String, type: String,
default: '' default: '120px'
} }
}, },
data() { data() {
@@ -78,7 +80,7 @@ export default {
border-bottom: 1px dashed #F4F4F4; border-bottom: 1px dashed #F4F4F4;
padding: 1px 0; padding: 1px 0;
margin-bottom: 0; margin-bottom: 0;
text-align: end; //text-align: end;
line-height: 1.2; line-height: 1.2;
&:last-child { &:last-child {
@@ -131,6 +133,7 @@ export default {
word-break: break-word; word-break: break-word;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
vertical-align: middle;
} }
} }
} }

View File

@@ -16,7 +16,7 @@
v-if="formatterArgs.drawer && drawerVisible" v-if="formatterArgs.drawer && drawerVisible"
:component="drawerComponent" :component="drawerComponent"
:has-footer="false" :has-footer="false"
:title="iTitle" :title="drawerTitle"
:visible.sync="drawerVisible" :visible.sync="drawerVisible"
class="detail-drawer" class="detail-drawer"
/> />
@@ -49,9 +49,7 @@ export default {
getTitle({ row, cellValue }) { getTitle({ row, cellValue }) {
return cellValue || row.name return cellValue || row.name
}, },
getDrawerTitle({ row, cellValue }) { getDrawerTitle: null,
return cellValue || row.name
},
getIcon({ col, row, cellValue }) { getIcon({ col, row, cellValue }) {
return null return null
} }
@@ -102,7 +100,30 @@ export default {
} }
}, },
methods: { methods: {
getRouteComponent() { getResource() {
const route = this.resolveRoute()
if (!route) {
return
}
const resource = route.meta.title || route.name
return resource.replace('Detail', '').replace('详情', '')
},
getDrawerTitle() {
if (this.formatterArgs?.getDrawerTitle && typeof this.formatterArgs.getDrawerTitle === 'function') {
return this.formatterArgs.getDrawerTitle({
col: this.col,
row: this.row,
cellValue: this.cellValue
})
}
let title = this.cellValue || this.row.name
const resource = this.getResource()
if (resource) {
title = `${resource}: ${title}`
}
return title
},
resolveRoute() {
const route = this.getDetailRoute() const route = this.getDetailRoute()
const routes = this.$router.resolve(route) const routes = this.$router.resolve(route)
if (!routes) { if (!routes) {
@@ -113,7 +134,13 @@ export default {
return return
} }
if (matched[0] && matched[0].components?.default) { if (matched[0] && matched[0].components?.default) {
return matched[0].components.default return matched[0]
}
},
getRouteComponent() {
const route = this.resolveRoute()
if (route) {
return route.components.default
} }
}, },
showDrawer() { showDrawer() {
@@ -134,7 +161,7 @@ export default {
id: route.params.id || this.row.id id: route.params.id || this.row.id
} }
this.$store.dispatch('common/setDrawerActionMeta', payload).then(() => { this.$store.dispatch('common/setDrawerActionMeta', payload).then(() => {
this.drawerTitle = this.formatterArgs.getDrawerTitle(payload) this.drawerTitle = this.getDrawerTitle(payload)
this.drawerVisible = true this.drawerVisible = true
}) })
}, },

View File

@@ -298,8 +298,8 @@ export default {
.generic-detail-page { .generic-detail-page {
::v-deep { ::v-deep {
.tab-page-content { .tab-page-content {
padding-left: 15px; padding-left: 20px;
padding-right: 10px; padding-right: 15px;
} }
} }
} }

View File

@@ -39,7 +39,7 @@ export default {
}, },
single: { single: {
type: Number, type: Number,
default: 22 default: 24
} }
} }
} }

View File

@@ -36,7 +36,7 @@ export default {
name: 'PamAccounts', name: 'PamAccounts',
component: () => import('@/views/pam/Account/index.vue'), component: () => import('@/views/pam/Account/index.vue'),
meta: { meta: {
title: i18n.t('Accounts'), title: i18n.t('AccountList'),
icon: 'accounts', icon: 'accounts',
permissions: [] permissions: []
} }

View File

@@ -17,7 +17,7 @@
type="text" type="text"
@click="handleManagePlatform" @click="handleManagePlatform"
> >
<i class="fa fa-gear" /> <i class="fa fa-external-link" />
{{ $tc('ManagePlatform') }} {{ $tc('ManagePlatform') }}
</el-link> </el-link>
</div> </div>
@@ -241,6 +241,7 @@ export default {
font-size: 14px; font-size: 14px;
font-weight: 400; font-weight: 400;
margin-left: 15px; margin-left: 15px;
color: var(--color-link);
} }
} }
</style> </style>

View File

@@ -32,7 +32,7 @@ export default {
min: ['name', 'actions'], min: ['name', 'actions'],
default: [ default: [
'name', 'users_amount', 'user_groups_amount', 'assets_amount', 'name', 'users_amount', 'user_groups_amount', 'assets_amount',
'nodes_amount', 'accounts', 'is_valid', 'actions' 'nodes_amount', 'accounts', 'actions'
] ]
}, },
columnsMeta: AssetPermissionTableMeta columnsMeta: AssetPermissionTableMeta

View File

@@ -24,9 +24,9 @@ export default {
return { return {
url: `/api/v1/terminal/sessions/?user_id=${this.object.id}&order=is_finished,-date_end`, url: `/api/v1/terminal/sessions/?user_id=${this.object.id}&order=is_finished,-date_end`,
columnsShow: { columnsShow: {
min: ['id', 'user', 'asset', 'account'], min: ['id', 'asset', 'account'],
default: [ default: [
'id', 'user', 'asset', 'account', 'protocol', 'id', 'asset', 'account', 'protocol',
'date_start', 'duration' 'date_start', 'duration'
] ]
} }