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