perf: 优化 detail

This commit is contained in:
ibuler 2024-12-31 14:22:50 +08:00
parent 8fabd32426
commit 559177ea32
19 changed files with 93 additions and 78 deletions

View File

@ -2,7 +2,6 @@
<Dialog <Dialog
:close-on-click-modal="false" :close-on-click-modal="false"
:title="$tc('Assets')" :title="$tc('Assets')"
:disabled-status="!isLoaded"
custom-class="asset-select-dialog" custom-class="asset-select-dialog"
top="2vh" top="2vh"
v-bind="$attrs" v-bind="$attrs"
@ -23,8 +22,8 @@
:url="baseUrl" :url="baseUrl"
class="tree-table" class="tree-table"
v-bind="$attrs" v-bind="$attrs"
v-on="$listeners"
@loaded="handleTableLoaded" @loaded="handleTableLoaded"
v-on="$listeners"
/> />
</Dialog> </Dialog>
</template> </template>

View File

@ -37,7 +37,7 @@ export default {
type: Array, type: Array,
default: null default: null
}, },
showUndefine: { showUndefined: {
type: Boolean, type: Boolean,
default: true default: true
}, },
@ -225,7 +225,7 @@ export default {
value = this.parseValue(value, fieldMeta.type) value = this.parseValue(value, fieldMeta.type)
if (value === undefined) { if (value === undefined) {
if (this.showUndefine) { if (this.showUndefined) {
value = '-' value = '-'
} else { } else {
continue continue

View File

@ -75,7 +75,7 @@ export default {
line-height: 2; line-height: 2;
::v-deep .el-form-item { ::v-deep .el-form-item {
//border-bottom: 1px dashed #EBEEF5; border-bottom: 1px dashed #F4F4F4;
padding: 1px 0; padding: 1px 0;
margin-bottom: 0; margin-bottom: 0;
text-align: end; text-align: end;

View File

@ -340,13 +340,13 @@ b, strong {
} }
tr td { tr td {
line-height: 1.42857; line-height: 1.4;
padding: 8px 0; padding: 8px 0;
vertical-align: top; vertical-align: top;
} }
tr.item td { tr.item td {
border-top: 1px solid #e7eaec; border-top: 1px dashed #EBEEF5;
} }
.box-margin { .box-margin {

View File

@ -85,6 +85,12 @@ export default {
padding-bottom: 20px; padding-bottom: 20px;
} }
.page-submenu {
.el-tabs__item.is-top {
padding: 0 10px;
}
}
.el-form { .el-form {
margin-right: 30px; margin-right: 30px;
height: 100%; height: 100%;

View File

@ -21,16 +21,12 @@
@onConfirm="onConfirm" @onConfirm="onConfirm"
/> />
</template> </template>
<template #right>
<QuickActions :actions="quickActions" :title="title" type="primary" />
</template>
</TwoCol> </TwoCol>
</div> </div>
</template> </template>
<script> <script>
import { AccountListTable } from '@/components' import { AccountListTable } from '@/components'
import QuickActions from '@/components/QuickActions'
import AccountTemplateDialog from '@/views/assets/Asset/AssetCreateUpdate/components/AccountTemplateDialog' import AccountTemplateDialog from '@/views/assets/Asset/AssetCreateUpdate/components/AccountTemplateDialog'
import { openTaskPage } from '@/utils/jms' import { openTaskPage } from '@/utils/jms'
import TwoCol from '@/layout/components/Page/TwoColPage.vue' import TwoCol from '@/layout/components/Page/TwoColPage.vue'
@ -39,7 +35,6 @@ export default {
name: 'Detail', name: 'Detail',
components: { components: {
TwoCol, TwoCol,
QuickActions,
AccountListTable, AccountListTable,
AccountTemplateDialog AccountTemplateDialog
}, },

View File

@ -1,17 +1,13 @@
<template> <template>
<TwoCol>
<BaseList :asset-id="object.id" :is-page="false" /> <BaseList :asset-id="object.id" :is-page="false" />
</TwoCol>
</template> </template>
<script> <script>
import BaseList from '@/views/sessions/CommandList/index.vue' import BaseList from '@/views/sessions/CommandList/index.vue'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default { export default {
name: 'AssetCommand', name: 'AssetCommand',
components: { components: {
TwoCol,
BaseList BaseList
}, },
props: { props: {

View File

@ -204,21 +204,21 @@ export default {
url: `/api/v1/assets/assets/${this.object.id}/`, url: `/api/v1/assets/assets/${this.object.id}/`,
object: this.object, object: this.object,
nested: 'spec_info', nested: 'spec_info',
showUndefine: true showUndefined: true
}, },
customInfoConfig: { customInfoConfig: {
title: this.$t('CustomInfo'), title: this.$t('CustomInfo'),
url: `/api/v1/assets/assets/${this.object.id}/`, url: `/api/v1/assets/assets/${this.object.id}/`,
object: this.object, object: this.object,
nested: 'custom_info', nested: 'custom_info',
showUndefine: false showUndefined: false
}, },
gatheredInfoConfig: { gatheredInfoConfig: {
url: `/api/v1/assets/hosts/${this.object.id}/`, url: `/api/v1/assets/hosts/${this.object.id}/`,
title: this.$t('HardwareInfo'), title: this.$t('HardwareInfo'),
object: this.object, object: this.object,
nested: 'gathered_info', nested: 'gathered_info',
showUndefine: false showUndefined: false
} }
} }
}, },

View File

@ -1,10 +1,12 @@
<template> <template>
<div> <div>
<TwoCol> <TwoCol>
<template>
<ListTable ref="ListTable" :header-actions="headerActions" :table-config="tableConfig" /> <ListTable ref="ListTable" :header-actions="headerActions" :table-config="tableConfig" />
</TwoCol> </template>
<TwoCol> <template #right>
<PermUserGroupCard v-bind="UserGroupCardConfig" /> <PermUserGroupCard v-bind="UserGroupCardConfig" />
</template>
</TwoCol> </TwoCol>
<GenericListTableDialog <GenericListTableDialog
:visible.sync="GenericListTableDialogConfig.visible" :visible.sync="GenericListTableDialogConfig.visible"
@ -39,19 +41,12 @@ export default {
tableConfig: { tableConfig: {
url: `/api/v1/assets/assets/${this.object.id}/perm-users/`, url: `/api/v1/assets/assets/${this.object.id}/perm-users/`,
columns: [ columns: [
'name', 'username', 'email', 'phone', 'wechat', 'name', 'username', 'email',
'groups_display', 'system_roles', 'org_roles', 'source', 'comment', 'created_by'
'is_valid', 'login_blocked', 'mfa_enabled',
'mfa_force_enabled', 'is_expired',
'last_login', 'date_joined', 'date_password_last_updated',
'comment', 'created_by', 'actions'
], ],
columnsShow: { columnsShow: {
min: ['name', 'username', 'actions'], min: ['name', 'username'],
default: [ default: ['name', 'username']
'name', 'username',
'source', 'is_valid', 'actions'
]
}, },
columnsMeta: { columnsMeta: {
name: { name: {

View File

@ -86,12 +86,15 @@ export default {
extraQuery: { extraQuery: {
type: Object, type: Object,
default: () => ({}) default: () => ({})
},
defaultColumns: {
type: Array,
default: null
} }
}, },
data() { data() {
const vm = this const vm = this
const defaultConfig = getDefaultConfig(vm) const defaultConfig = getDefaultConfig(vm)
console.log('Default config: ', defaultConfig)
const recentPlatforms = [ const recentPlatforms = [
{ {
@ -113,6 +116,7 @@ export default {
type: 'primary', type: 'primary',
icon: '', icon: '',
split: true, split: true,
has: this.headerActions.hasCrate,
callback: () => { callback: () => {
this.showPlatform = false this.showPlatform = false
console.log('Create action') console.log('Create action')
@ -220,7 +224,12 @@ export default {
node: this.$route.query?.node || this.$route.query?.node_id || '' node: this.$route.query?.node || this.$route.query?.node_id || ''
} }
this.$router.push({ this.$router.push({
query: { _platform: createProps.platform, _type: createProps.type, _category: createProps.category, _node: createProps.node } query: {
_platform: createProps.platform,
_type: createProps.type,
_category: createProps.category,
_node: createProps.node
}
}) })
this.$store.dispatch('common/setDrawerActionMeta', { this.$store.dispatch('common/setDrawerActionMeta', {
action: 'create', action: 'create',

View File

@ -122,7 +122,7 @@ export function getDefaultConfig(vm) {
columnsExclude: ['spec_info', 'auto_config'], columnsExclude: ['spec_info', 'auto_config'],
columnsShow: { columnsShow: {
min: ['name', 'address', 'actions'], min: ['name', 'address', 'actions'],
default: [ default: vm.defaultColumns || [
'name', 'address', 'accounts_amount', 'platform', 'name', 'address', 'accounts_amount', 'platform',
'connectivity', 'actions' 'connectivity', 'actions'
] ]

View File

@ -1,16 +1,20 @@
<template> <template>
<div> <div>
<TwoCol>
<BaseList ref="AssetBaseList" v-bind="tableConfig" /> <BaseList ref="AssetBaseList" v-bind="tableConfig" />
<AddAssetDialog :object="object" :setting="AddAssetSetting" @close="handleAddAssetDialogClose" /> </TwoCol>
<AddAssetDialog :object="object" :setting="addAssetSetting" @close="handleAddAssetDialogClose" />
</div> </div>
</template> </template>
<script> <script>
import BaseList from '../../Asset/AssetList/components/BaseList' import BaseList from '../../Asset/AssetList/components/BaseList'
import AddAssetDialog from '@/views/assets/Domain/components/AddAssetDialog.vue' import AddAssetDialog from '@/views/assets/Domain/components/AddAssetDialog.vue'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default { export default {
components: { components: {
TwoCol,
AddAssetDialog, AddAssetDialog,
BaseList BaseList
}, },
@ -25,7 +29,7 @@ export default {
return { return {
tableConfig: { tableConfig: {
category: 'all', category: 'all',
url: `/api/v1/assets/assets/?domain=${this.$route.params.id}&exclude_platform=Gateway`, url: `/api/v1/assets/assets/?domain=${this.object.id}&exclude_platform=Gateway`,
tableConfig: { tableConfig: {
columnsMeta: { columnsMeta: {
actions: { actions: {
@ -48,7 +52,7 @@ export default {
title: this.$t('Add'), title: this.$t('Add'),
type: 'primary', type: 'primary',
callback: function() { callback: function() {
this.AddAssetSetting.AddAssetDialogVisible = true this.addAssetSetting.addAssetDialogVisible = true
}.bind(this) }.bind(this)
} }
] ]
@ -78,14 +82,14 @@ export default {
} }
] ]
}, },
AddAssetSetting: { addAssetSetting: {
AddAssetDialogVisible: false addAssetDialogVisible: false
} }
} }
}, },
methods: { methods: {
handleAddAssetDialogClose() { handleAddAssetDialogClose() {
this.AddAssetSetting.AddAssetDialogVisible = false this.addAssetSetting.addAssetDialogVisible = false
this.reloadTable() this.reloadTable()
}, },
removeAsset(rows) { removeAsset(rows) {

View File

@ -46,7 +46,7 @@ export default {
columnsShow: { columnsShow: {
min: ['name', 'actions'], min: ['name', 'actions'],
default: [ default: [
'name', 'address', 'protocols', 'name', 'address',
'connectivity', 'actions' 'connectivity', 'actions'
] ]
}, },

View File

@ -1,15 +1,16 @@
<template> <template>
<Dialog <Dialog
v-if="setting.AddAssetDialogVisible" v-if="setting.addAssetDialogVisible"
:destroy-on-close="true" :destroy-on-close="true"
:modal="false"
:show-cancel="false" :show-cancel="false"
:show-confirm="false" :show-confirm="false"
:title="$tc('AddAssetInDomain')" :title="$tc('AddAssetInDomain')"
:visible.sync="setting.AddAssetDialogVisible" :visible.sync="setting.addAssetDialogVisible"
after after
custom-class="asset-select-dialog" custom-class="asset-select-dialog"
top="15vh" top="15vh"
width="50vw" width="600px"
> >
<GenericCreateUpdateForm <GenericCreateUpdateForm
v-bind="formConfig" v-bind="formConfig"
@ -20,7 +21,7 @@
<script> <script>
import Dialog from '@/components/Dialog' import Dialog from '@/components/Dialog'
import { GenericCreateUpdateForm } from '@/layout/components' import { GenericCreateUpdateForm } from '@/layout/components'
import AssetSelect from '@/components/Apps/AssetSelect/index.vue' import { Select2 } from '@/components'
export default { export default {
components: { components: {
@ -31,7 +32,7 @@ export default {
setting: { setting: {
type: Object, type: Object,
default: () => { default: () => {
return { AddAssetDialogVisible: false } return { addAssetDialogVisible: false }
} }
}, },
object: { object: {
@ -58,12 +59,12 @@ export default {
fields: ['assets'], fields: ['assets'],
fieldsMeta: { fieldsMeta: {
assets: { assets: {
type: 'assetSelect', label: this.$t('Assets'),
component: AssetSelect, component: Select2,
label: this.$t('Asset'), type: 'select2',
el: { el: {
value: [], value: [],
baseUrl: '/api/v1/assets/assets/?domain_enabled=true', url: '/api/v1/assets/assets/?domain_enabled=true',
treeUrlQuery: { treeUrlQuery: {
domain_enabled: true domain_enabled: true
}, },
@ -86,7 +87,7 @@ export default {
}, },
methods: { methods: {
onSubmitSuccess(res) { onSubmitSuccess(res) {
this.setting.AddAssetDialogVisible = false this.setting.addAssetDialogVisible = false
this.$emit('close', res) this.$emit('close', res)
} }
} }
@ -95,7 +96,6 @@ export default {
<style lang="less" scoped> <style lang="less" scoped>
.dialog ::v-deep form { .dialog ::v-deep form {
padding: 0 40px;
} }
.dialog ::v-deep .el-dialog__footer { .dialog ::v-deep .el-dialog__footer {

View File

@ -92,7 +92,6 @@ export default {
<style lang="less" scoped> <style lang="less" scoped>
.dialog ::v-deep form { .dialog ::v-deep form {
padding: 0 40px;
} }
.dialog ::v-deep .el-dialog__footer { .dialog ::v-deep .el-dialog__footer {

View File

@ -1,13 +1,17 @@
<template> <template>
<TwoCol>
<BaseList v-bind="config" /> <BaseList v-bind="config" />
</TwoCol>
</template> </template>
<script> <script>
import BaseList from '../../Asset/AssetList/components/BaseList' import BaseList from '../../Asset/AssetList/components/BaseList'
import { DetailFormatter } from '@/components/Table/TableFormatters' import { DetailFormatter } from '@/components/Table/TableFormatters'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default { export default {
components: { components: {
TwoCol,
BaseList BaseList
}, },
props: { props: {
@ -22,7 +26,14 @@ export default {
config: { config: {
category: 'all', category: 'all',
url: `/api/v1/assets/assets/?platform=${this.object.id}`, url: `/api/v1/assets/assets/?platform=${this.object.id}`,
defaultColumns: [
'name', 'address'
],
tableConfig: { tableConfig: {
columnsShow: {
min: ['name'],
default: ['name']
},
columnsMeta: { columnsMeta: {
name: { name: {
formatter: DetailFormatter, formatter: DetailFormatter,

View File

@ -165,7 +165,7 @@ export default {
url: `/api/v1/assets/assets/${this.object.id}/`, url: `/api/v1/assets/assets/${this.object.id}/`,
object: this.object, object: this.object,
nested: 'spec_info', nested: 'spec_info',
showUndefine: false, showUndefined: false,
excludes: ['spec_info.script'] excludes: ['spec_info.script']
}, },
detailInfoConfig: { detailInfoConfig: {
@ -173,7 +173,7 @@ export default {
title: this.$t('HardwareInfo'), title: this.$t('HardwareInfo'),
object: this.object, object: this.object,
nested: 'info', nested: 'info',
showUndefine: false showUndefined: false
} }
} }
}, },

View File

@ -1,4 +1,5 @@
<template> <template>
<div>
<TwoCol> <TwoCol>
<template> <template>
<GenericListTable <GenericListTable
@ -11,6 +12,8 @@
<RelationCard :key="relationKey" v-bind="relationConfig" @addSuccess="addSuccess" /> <RelationCard :key="relationKey" v-bind="relationConfig" @addSuccess="addSuccess" />
</template> </template>
</TwoCol> </TwoCol>
<TwoCol />
</div>
</template> </template>
<script> <script>
@ -34,7 +37,6 @@ export default {
} }
}, },
data() { data() {
const vm = this
return { return {
quickActions: [ quickActions: [
{ {
@ -69,14 +71,14 @@ export default {
tableConfig: { tableConfig: {
url: `/api/v1/users/users/?group_id=${this.object.id}`, url: `/api/v1/users/users/?group_id=${this.object.id}`,
columns: [ columns: [
'name', 'username', 'is_valid', 'delete_action' 'name', 'delete_action'
], ],
columnsMeta: { columnsMeta: {
name: { name: {
formatter: DetailFormatter, formatter: DetailFormatter,
formatterArgs: { formatterArgs: {
route: 'UserDetail', can: false,
can: vm.$hasPerm('user.view_user') getTitle: ({ row }) => row.name + '(' + row.username + ')'
} }
}, },
delete_action: { delete_action: {

View File

@ -94,7 +94,6 @@ export default {
<style lang="less" scoped> <style lang="less" scoped>
.dialog ::v-deep form { .dialog ::v-deep form {
padding: 0 40px;
} }
.dialog ::v-deep .el-dialog__footer { .dialog ::v-deep .el-dialog__footer {