mirror of https://github.com/veops/cmdb.git
feat(ui): update
This commit is contained in:
parent
ba1064495b
commit
5cbcbaf93d
|
@ -57,7 +57,9 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['user', 'locale']),
|
...mapState(['user', 'locale']),
|
||||||
hasBackendPermission() {
|
hasBackendPermission() {
|
||||||
return this.user?.detailPermissions?.backend?.length
|
const isAdmin = this?.user?.roles?.permissions?.includes('acl_admin')
|
||||||
|
|
||||||
|
return isAdmin || this.user?.detailPermissions?.backend?.length
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -147,9 +147,9 @@
|
||||||
<a-form-model-item :required="true" :label="$t('cmdb.ciType.password')">
|
<a-form-model-item :required="true" :label="$t('cmdb.ciType.password')">
|
||||||
<a-input-password v-model="privateCloudForm.password" />
|
<a-input-password v-model="privateCloudForm.password" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
<a-form-model-item :label="$t('cmdb.ciType.insecure')">
|
<!-- <a-form-model-item :label="$t('cmdb.ciType.insecure')">
|
||||||
<a-switch v-model="privateCloudForm.insecure" />
|
<a-switch v-model="privateCloudForm.insecure" />
|
||||||
</a-form-model-item>
|
</a-form-model-item> -->
|
||||||
<a-form-model-item :label="$t('cmdb.ciType.vcenterName')">
|
<a-form-model-item :label="$t('cmdb.ciType.vcenterName')">
|
||||||
<a-input v-model="privateCloudForm.vcenterName" />
|
<a-input v-model="privateCloudForm.vcenterName" />
|
||||||
</a-form-model-item>
|
</a-form-model-item>
|
||||||
|
@ -189,6 +189,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import _ from 'lodash'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import Vcrontab from '@/components/Crontab'
|
import Vcrontab from '@/components/Crontab'
|
||||||
|
@ -260,7 +261,7 @@ export default {
|
||||||
host: '',
|
host: '',
|
||||||
account: '',
|
account: '',
|
||||||
password: '',
|
password: '',
|
||||||
insecure: false,
|
// insecure: false,
|
||||||
vcenterName: '',
|
vcenterName: '',
|
||||||
},
|
},
|
||||||
interval: 'cron', // interval cron
|
interval: 'cron', // interval cron
|
||||||
|
@ -344,7 +345,7 @@ export default {
|
||||||
host = '',
|
host = '',
|
||||||
account = '',
|
account = '',
|
||||||
password = '',
|
password = '',
|
||||||
insecure = false,
|
// insecure = false,
|
||||||
vcenterName = ''
|
vcenterName = ''
|
||||||
} = _findADT?.extra_option ?? {}
|
} = _findADT?.extra_option ?? {}
|
||||||
|
|
||||||
|
@ -357,7 +358,7 @@ export default {
|
||||||
host,
|
host,
|
||||||
account,
|
account,
|
||||||
password,
|
password,
|
||||||
insecure,
|
// insecure,
|
||||||
vcenterName,
|
vcenterName,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -524,6 +525,10 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.extra_option) {
|
||||||
|
params.extra_option = _.omit(params.extra_option, 'insecure')
|
||||||
|
}
|
||||||
|
|
||||||
if (currentAdt?.isClient) {
|
if (currentAdt?.isClient) {
|
||||||
postCITypeDiscovery(this.CITypeId, params).then((res) => {
|
postCITypeDiscovery(this.CITypeId, params).then((res) => {
|
||||||
this.$message.success(this.$t('saveSuccess'))
|
this.$message.success(this.$t('saveSuccess'))
|
||||||
|
|
|
@ -85,10 +85,10 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
transferDataSource() {
|
transferDataSource() {
|
||||||
const dataSource = this.CITypeGroups.reduce((acc, item) => {
|
const dataSource = this.CITypeGroups.reduce((acc, group) => {
|
||||||
const types = _.cloneDeep(item?.ci_types || [])
|
const types = _.cloneDeep(group?.ci_types || [])
|
||||||
types.forEach((item) => {
|
types.forEach((item) => {
|
||||||
item.key = String(item.id)
|
item.key = `${group.id}-${item.id}`
|
||||||
item.title = item?.alias || item?.name || this.$t('other')
|
item.title = item?.alias || item?.name || this.$t('other')
|
||||||
})
|
})
|
||||||
return acc.concat(types)
|
return acc.concat(types)
|
||||||
|
@ -100,7 +100,7 @@ export default {
|
||||||
let newTreeData = treeData.map((item) => {
|
let newTreeData = treeData.map((item) => {
|
||||||
const childrenKeys = []
|
const childrenKeys = []
|
||||||
const children = (item.ci_types || []).map((child) => {
|
const children = (item.ci_types || []).map((child) => {
|
||||||
const key = String(child?.id)
|
const key = `${item.id}-${child.id}`
|
||||||
const disabled = this.targetKeys.includes(key)
|
const disabled = this.targetKeys.includes(key)
|
||||||
childrenKeys.push(key)
|
childrenKeys.push(key)
|
||||||
|
|
||||||
|
@ -119,9 +119,7 @@ export default {
|
||||||
disabled: children.every((item) => item.disabled),
|
disabled: children.every((item) => item.disabled),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log('treeData', newTreeData)
|
|
||||||
newTreeData = newTreeData.filter((item) => item.children.length > 0)
|
newTreeData = newTreeData.filter((item) => item.children.length > 0)
|
||||||
|
|
||||||
return newTreeData
|
return newTreeData
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -148,7 +146,6 @@ export default {
|
||||||
const { eventKey } = e.node
|
const { eventKey } = e.node
|
||||||
const selected = checkedKeys.indexOf(eventKey) === -1
|
const selected = checkedKeys.indexOf(eventKey) === -1
|
||||||
const childrenKeys = this.treeData.find((item) => item.key === eventKey)?.childrenKeys || []
|
const childrenKeys = this.treeData.find((item) => item.key === eventKey)?.childrenKeys || []
|
||||||
|
|
||||||
// 如果当前点击是子节点,处理其联动父节点
|
// 如果当前点击是子节点,处理其联动父节点
|
||||||
this.treeData.forEach((item) => {
|
this.treeData.forEach((item) => {
|
||||||
if (item.childrenKeys.includes(eventKey)) {
|
if (item.childrenKeys.includes(eventKey)) {
|
||||||
|
@ -159,7 +156,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
itemSelectAll([eventKey, ...childrenKeys], selected)
|
itemSelectAll([eventKey, ...childrenKeys], selected)
|
||||||
},
|
},
|
||||||
handleCancel() {
|
handleCancel() {
|
||||||
|
@ -176,7 +172,7 @@ export default {
|
||||||
const hide = this.$message.loading(this.$t('loading'), 0)
|
const hide = this.$message.loading(this.$t('loading'), 0)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const typeIds = this.targetKeys.join(',')
|
const typeIds = this.getTypeIds(this.targetKeys)
|
||||||
const res = await exportCITypeGroups({
|
const res = await exportCITypeGroups({
|
||||||
type_ids: typeIds
|
type_ids: typeIds
|
||||||
})
|
})
|
||||||
|
@ -204,6 +200,13 @@ export default {
|
||||||
hide()
|
hide()
|
||||||
this.btnLoading = false
|
this.btnLoading = false
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
getTypeIds(targetKeys) {
|
||||||
|
let typeIds = targetKeys?.map((key) => {
|
||||||
|
return this?.transferDataSource?.find((node) => node?.key === key)?.id || ''
|
||||||
|
})
|
||||||
|
typeIds = typeIds.filter((id) => id)
|
||||||
|
return typeIds?.join(',')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,16 +103,20 @@
|
||||||
>
|
>
|
||||||
<template v-if="col.value_type === '6' || col.is_link || col.is_password || col.is_choice" #default="{row}">
|
<template v-if="col.value_type === '6' || col.is_link || col.is_password || col.is_choice" #default="{row}">
|
||||||
<span v-if="col.value_type === '6' && row[col.field]">{{ JSON.stringify(row[col.field]) }}</span>
|
<span v-if="col.value_type === '6' && row[col.field]">{{ JSON.stringify(row[col.field]) }}</span>
|
||||||
<a
|
<template v-else-if="col.is_link && row[col.field]">
|
||||||
v-else-if="col.is_link && row[col.field]"
|
<a
|
||||||
:href="
|
v-for="(item, linkIndex) in (col.is_list ? row[col.field] : [row[col.field]])"
|
||||||
row[col.field].startsWith('http') || row[col.field].startsWith('https')
|
:key="linkIndex"
|
||||||
? `${row[col.field]}`
|
:href="
|
||||||
: `http://${row[col.field]}`
|
item.startsWith('http') || item.startsWith('https')
|
||||||
"
|
? `${item}`
|
||||||
target="_blank"
|
: `http://${item}`
|
||||||
>{{ row[col.field] }}</a
|
"
|
||||||
>
|
target="_blank"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
<PasswordField
|
<PasswordField
|
||||||
v-else-if="col.is_password && row[col.field]"
|
v-else-if="col.is_password && row[col.field]"
|
||||||
:ci_id="row._id"
|
:ci_id="row._id"
|
||||||
|
|
|
@ -242,16 +242,20 @@
|
||||||
#default="{row}"
|
#default="{row}"
|
||||||
>
|
>
|
||||||
<span v-if="col.value_type === '6' && row[col.field]">{{ row[col.field] }}</span>
|
<span v-if="col.value_type === '6' && row[col.field]">{{ row[col.field] }}</span>
|
||||||
<a
|
<template v-else-if="col.is_link && row[col.field]">
|
||||||
v-else-if="col.is_link && row[col.field]"
|
<a
|
||||||
:href="
|
v-for="(item, linkIndex) in (col.is_list ? row[col.field] : [row[col.field]])"
|
||||||
row[col.field].startsWith('http') || row[col.field].startsWith('https')
|
:key="linkIndex"
|
||||||
? `${row[col.field]}`
|
:href="
|
||||||
: `http://${row[col.field]}`
|
item.startsWith('http') || item.startsWith('https')
|
||||||
"
|
? `${item}`
|
||||||
target="_blank"
|
: `http://${item}`
|
||||||
>{{ row[col.field] }}</a
|
"
|
||||||
>
|
target="_blank"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</a>
|
||||||
|
</template>
|
||||||
<PasswordField
|
<PasswordField
|
||||||
v-else-if="col.is_password && row[col.field]"
|
v-else-if="col.is_password && row[col.field]"
|
||||||
:ci_id="row._id"
|
:ci_id="row._id"
|
||||||
|
|
Loading…
Reference in New Issue