Skip to content

Commit

Permalink
feat(ui): update
Browse files Browse the repository at this point in the history
  • Loading branch information
LHRUN committed Jul 10, 2024
1 parent daf0254 commit ff78fac
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 35 deletions.
4 changes: 3 additions & 1 deletion cmdb-ui/src/components/tools/UserMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export default {
computed: {
...mapState(['user', 'locale']),
hasBackendPermission() {
return this.user?.detailPermissions?.backend?.length
const isAdmin = this?.user?.roles?.permissions?.includes('acl_admin')

return isAdmin || this.user?.detailPermissions?.backend?.length
},
},
methods: {
Expand Down
15 changes: 10 additions & 5 deletions cmdb-ui/src/modules/cmdb/views/ci_types/attrADTabpane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@
<a-form-model-item :required="true" :label="$t('cmdb.ciType.password')">
<a-input-password v-model="privateCloudForm.password" />
</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-form-model-item>
</a-form-model-item> -->
<a-form-model-item :label="$t('cmdb.ciType.vcenterName')">
<a-input v-model="privateCloudForm.vcenterName" />
</a-form-model-item>
Expand Down Expand Up @@ -189,6 +189,7 @@
</template>

<script>
import _ from 'lodash'
import { v4 as uuidv4 } from 'uuid'
import { mapState } from 'vuex'
import Vcrontab from '@/components/Crontab'
Expand Down Expand Up @@ -260,7 +261,7 @@ export default {
host: '',
account: '',
password: '',
insecure: false,
// insecure: false,
vcenterName: '',
},
interval: 'cron', // interval cron
Expand Down Expand Up @@ -344,7 +345,7 @@ export default {
host = '',
account = '',
password = '',
insecure = false,
// insecure = false,
vcenterName = ''
} = _findADT?.extra_option ?? {}

Expand All @@ -357,7 +358,7 @@ export default {
host,
account,
password,
insecure,
// insecure,
vcenterName,
}
}
Expand Down Expand Up @@ -524,6 +525,10 @@ export default {
}
}

if (params.extra_option) {
params.extra_option = _.omit(params.extra_option, 'insecure')
}

if (currentAdt?.isClient) {
postCITypeDiscovery(this.CITypeId, params).then((res) => {
this.$message.success(this.$t('saveSuccess'))
Expand Down
21 changes: 12 additions & 9 deletions cmdb-ui/src/modules/cmdb/views/ci_types/modelExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export default {
},
computed: {
transferDataSource() {
const dataSource = this.CITypeGroups.reduce((acc, item) => {
const types = _.cloneDeep(item?.ci_types || [])
const dataSource = this.CITypeGroups.reduce((acc, group) => {
const types = _.cloneDeep(group?.ci_types || [])
types.forEach((item) => {
item.key = String(item.id)
item.key = `${group.id}-${item.id}`
item.title = item?.alias || item?.name || this.$t('other')
})
return acc.concat(types)
Expand All @@ -100,7 +100,7 @@ export default {
let newTreeData = treeData.map((item) => {
const childrenKeys = []
const children = (item.ci_types || []).map((child) => {
const key = String(child?.id)
const key = `${item.id}-${child.id}`
const disabled = this.targetKeys.includes(key)
childrenKeys.push(key)

Expand All @@ -119,9 +119,7 @@ export default {
disabled: children.every((item) => item.disabled),
}
})
console.log('treeData', newTreeData)
newTreeData = newTreeData.filter((item) => item.children.length > 0)

return newTreeData
}
},
Expand All @@ -148,7 +146,6 @@ export default {
const { eventKey } = e.node
const selected = checkedKeys.indexOf(eventKey) === -1
const childrenKeys = this.treeData.find((item) => item.key === eventKey)?.childrenKeys || []

// 如果当前点击是子节点处理其联动父节点
this.treeData.forEach((item) => {
if (item.childrenKeys.includes(eventKey)) {
Expand All @@ -159,7 +156,6 @@ export default {
}
}
})

itemSelectAll([eventKey, ...childrenKeys], selected)
},
handleCancel() {
Expand All @@ -176,7 +172,7 @@ export default {
const hide = this.$message.loading(this.$t('loading'), 0)

try {
const typeIds = this.targetKeys.join(',')
const typeIds = this.getTypeIds(this.targetKeys)
const res = await exportCITypeGroups({
type_ids: typeIds
})
Expand Down Expand Up @@ -204,6 +200,13 @@ export default {
hide()
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(',')
}
}
}
Expand Down
24 changes: 14 additions & 10 deletions cmdb-ui/src/modules/cmdb/views/resource_search/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,20 @@
>
<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>
<a
v-else-if="col.is_link && row[col.field]"
:href="
row[col.field].startsWith('http') || row[col.field].startsWith('https')
? `${row[col.field]}`
: `http://${row[col.field]}`
"
target="_blank"
>{{ row[col.field] }}</a
>
<template v-else-if="col.is_link && row[col.field]">
<a
v-for="(item, linkIndex) in (col.is_list ? row[col.field] : [row[col.field]])"
:key="linkIndex"
:href="
item.startsWith('http') || item.startsWith('https')
? `${item}`
: `http://${item}`
"
target="_blank"
>
{{ item }}
</a>
</template>
<PasswordField
v-else-if="col.is_password && row[col.field]"
:ci_id="row._id"
Expand Down
24 changes: 14 additions & 10 deletions cmdb-ui/src/modules/cmdb/views/tree_views/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,20 @@
#default="{row}"
>
<span v-if="col.value_type === '6' && row[col.field]">{{ row[col.field] }}</span>
<a
v-else-if="col.is_link && row[col.field]"
:href="
row[col.field].startsWith('http') || row[col.field].startsWith('https')
? `${row[col.field]}`
: `http://${row[col.field]}`
"
target="_blank"
>{{ row[col.field] }}</a
>
<template v-else-if="col.is_link && row[col.field]">
<a
v-for="(item, linkIndex) in (col.is_list ? row[col.field] : [row[col.field]])"
:key="linkIndex"
:href="
item.startsWith('http') || item.startsWith('https')
? `${item}`
: `http://${item}`
"
target="_blank"
>
{{ item }}
</a>
</template>
<PasswordField
v-else-if="col.is_password && row[col.field]"
:ci_id="row._id"
Expand Down

0 comments on commit ff78fac

Please sign in to comment.