mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-18 08:12:33 +00:00
fix: 主机硬件信息 多次请求及warning
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
<template>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
open-delay="500"
|
||||
:open-delay="parseInt('500')"
|
||||
:title="title"
|
||||
width="400"
|
||||
trigger="hover"
|
||||
>
|
||||
<el-row v-for="(item, key) of items" :key="key" class="detail-item">
|
||||
<el-col :span="12">{{ info[key] }}</el-col>
|
||||
<el-col :span="12">{{ formatterArgs.info[key] }}</el-col>
|
||||
<el-col :span="12">{{ item }}</el-col>
|
||||
</el-row>
|
||||
<span slot="reference">{{ viewText }}</span>
|
||||
@@ -66,23 +66,6 @@ export default {
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.info = await this.optionAndGenFields()
|
||||
},
|
||||
methods: {
|
||||
async optionAndGenFields() {
|
||||
const data = await this.$store.dispatch('common/getUrlMeta', { url: this.url })
|
||||
const remoteMeta = data.actions['GET'] || {}
|
||||
const fieldName = this.formatterArgs?.fieldName || ''
|
||||
const remoteMetaFields = remoteMeta[fieldName]?.children || {}
|
||||
const fields = Object.keys(remoteMetaFields)
|
||||
const info = {}
|
||||
for (const name of fields) {
|
||||
info[name] = remoteMetaFields[name].label
|
||||
}
|
||||
return info
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@@ -29,6 +29,7 @@ export default {
|
||||
config: {
|
||||
url: '/api/v1/assets/hosts/',
|
||||
category: 'host',
|
||||
optionInfo: {},
|
||||
headerActions: {
|
||||
createRoute: 'HostCreate',
|
||||
extraActions: [
|
||||
@@ -85,7 +86,22 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.config.optionInfo = await this.optionAndGenFields()
|
||||
},
|
||||
methods: {
|
||||
async optionAndGenFields() {
|
||||
const data = await this.$store.dispatch('common/getUrlMeta', { url: this.config.url })
|
||||
const remoteMeta = data.actions['GET'] || {}
|
||||
const remoteMetaFields = remoteMeta['info']?.children || {}
|
||||
const fields = Object.keys(remoteMetaFields)
|
||||
const info = {}
|
||||
for (const name of fields) {
|
||||
info[name] = remoteMetaFields[name].label
|
||||
}
|
||||
return info
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -60,6 +60,10 @@ export default {
|
||||
helpMessage: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
optionInfo: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
@@ -129,7 +133,7 @@ export default {
|
||||
label: this.$t('assets.HardwareInfo'),
|
||||
formatter: HostInfoFormatter,
|
||||
formatterArgs: {
|
||||
fieldName: 'info',
|
||||
info: vm?.optionInfo,
|
||||
can: vm.$hasPerm('assets.refresh_assethardwareinfo'),
|
||||
getRoute({ row }) {
|
||||
return {
|
||||
@@ -269,6 +273,11 @@ export default {
|
||||
}
|
||||
return actions
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
optionInfo(iNew) {
|
||||
this.$set(this.defaultConfig.columnsMeta.info.formatterArgs, 'info', iNew)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user