mirror of https://github.com/veops/cmdb.git
feat: add attribute sorted tips for non-inherited attributes
This commit is contained in:
parent
e2872f041e
commit
fb7471ce04
|
@ -130,6 +130,7 @@ const cmdb_en = {
|
|||
selectAttribute: 'Select Attribute',
|
||||
groupExisted: 'Group name already exists',
|
||||
attributeSortedTips: 'Attributes in other groups cannot be sorted. If you need to sort, please drag them to a custom group first!',
|
||||
attributeSortedTips2: 'Non-inherited attributes cannot be inserted before inherited attributes!',
|
||||
buildinAttribute: 'built-in attributes',
|
||||
expr: 'Expression',
|
||||
code: 'Code',
|
||||
|
|
|
@ -130,6 +130,7 @@ const cmdb_zh = {
|
|||
selectAttribute: '添加属性',
|
||||
groupExisted: '分组名称已存在',
|
||||
attributeSortedTips: '其他分组中的属性不能进行排序,如需排序请先拖至自定义的分组!',
|
||||
attributeSortedTips2: '非继承属性不能插入到继承属性前!',
|
||||
buildinAttribute: '内置字段',
|
||||
expr: '表达式',
|
||||
code: '代码',
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<router-view :key="$route.fullPath"></router-view>
|
||||
<a-modal
|
||||
v-model="addGroupModal"
|
||||
:title="$t('cmdb.ciType.addGroup')"
|
||||
|
@ -233,6 +234,7 @@ export default {
|
|||
attrTypeFilter: [],
|
||||
unique: '',
|
||||
show_id: null,
|
||||
groupMaxCount: {},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -335,6 +337,7 @@ export default {
|
|||
})
|
||||
this.CITypeGroups = values[1]
|
||||
this.CITypeGroups.forEach((g) => {
|
||||
this.groupMaxCount[g.name] = g.attributes.filter(a => a.inherited).length
|
||||
g.attributes.forEach((a) => {
|
||||
a.is_required = (temp[a.id] && temp[a.id].is_required) || false
|
||||
a.default_show = (temp[a.id] && temp[a.id].default_show) || false
|
||||
|
@ -470,8 +473,12 @@ export default {
|
|||
handleChange(e, group) {
|
||||
console.log('changess', group)
|
||||
if (e.hasOwnProperty('moved') && e.moved.oldIndex !== e.moved.newIndex) {
|
||||
if (group === -1) {
|
||||
if (group === -1 || group === null) {
|
||||
this.$message.error(this.$t('cmdb.ciType.attributeSortedTips'))
|
||||
this.refreshPage()
|
||||
} else if (e.moved.newIndex < this.groupMaxCount[group]) {
|
||||
this.$message.error(this.$t('cmdb.ciType.attributeSortedTips2'))
|
||||
this.refreshPage()
|
||||
} else {
|
||||
transferCITypeAttrIndex(this.CITypeId, {
|
||||
from: { attr_id: e.moved.element.id, group_name: group },
|
||||
|
@ -479,7 +486,7 @@ export default {
|
|||
})
|
||||
.then((res) => this.$message.success(this.$t('updateSuccess')))
|
||||
.catch(() => {
|
||||
this.abortDraggable()
|
||||
this.refreshPage()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -490,17 +497,23 @@ export default {
|
|||
|
||||
if (e.hasOwnProperty('removed')) {
|
||||
this.$nextTick(() => {
|
||||
if (this.addRemoveGroupFlag.to.order < this.groupMaxCount[this.addRemoveGroupFlag.to.group_name]) {
|
||||
this.$message.error(this.$t('cmdb.ciType.attributeSortedTips2'))
|
||||
this.refreshPage()
|
||||
this.addRemoveGroupFlag = {}
|
||||
} else {
|
||||
transferCITypeAttrIndex(this.CITypeId, {
|
||||
from: { attr_id: e.removed.element.id, group_name: group },
|
||||
to: { group_name: this.addRemoveGroupFlag.to.group_name, order: this.addRemoveGroupFlag.to.order },
|
||||
})
|
||||
.then((res) => this.$message.success(this.$t('saveSuccess')))
|
||||
.catch(() => {
|
||||
this.abortDraggable()
|
||||
this.refreshPage()
|
||||
})
|
||||
.finally(() => {
|
||||
this.addRemoveGroupFlag = {}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
@ -605,6 +618,13 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
refreshPage() {
|
||||
const path = this.$route.path
|
||||
const query = { ...this.$route.query, refresh: new Date().getTime() }
|
||||
this.$router.replace({ path: '/cmdb/dashboard' }).then(() => {
|
||||
this.$router.replace({ path, query })
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue