mirror of https://github.com/veops/cmdb.git
Merge pull request #596 from thexqn/fix_order_bug
修复在继承模型的情况下,非继承属性与继承属性的排序以及其他分组的排序提示问题Fix order bug
This commit is contained in:
commit
55ab04dd28
|
@ -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: '代码',
|
||||
|
|
|
@ -233,6 +233,7 @@ export default {
|
|||
attrTypeFilter: [],
|
||||
unique: '',
|
||||
show_id: null,
|
||||
groupMaxCount: {},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -340,6 +341,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
|
||||
|
@ -475,44 +477,43 @@ export default {
|
|||
handleChange(e, group) {
|
||||
console.log('changess', group)
|
||||
if (e.hasOwnProperty('moved') && e.moved.oldIndex !== e.moved.newIndex) {
|
||||
if (group === -1) {
|
||||
this.$message.error(this.$t('cmdb.ciType.attributeSortedTips'))
|
||||
if (group === -1 || group === null) {
|
||||
this.refreshPage(this.$t('cmdb.ciType.attributeSortedTips'))
|
||||
} else if (e.moved.newIndex < this.groupMaxCount[group]) {
|
||||
this.refreshPage(this.$t('cmdb.ciType.attributeSortedTips2'))
|
||||
} else {
|
||||
transferCITypeAttrIndex(this.CITypeId, {
|
||||
from: { attr_id: e.moved.element.id, group_name: group },
|
||||
to: { order: e.moved.newIndex, group_name: group },
|
||||
to: { order: e.moved.newIndex, group_name: group }
|
||||
})
|
||||
.then((res) => this.$message.success(this.$t('updateSuccess')))
|
||||
.catch(() => {
|
||||
this.abortDraggable()
|
||||
})
|
||||
.then(() => this.$message.success(this.$t('updateSuccess')))
|
||||
.catch(() => this.init())
|
||||
}
|
||||
}
|
||||
|
||||
if (e.hasOwnProperty('added')) {
|
||||
this.addRemoveGroupFlag = { to: { group_name: group, order: e.added.newIndex }, inited: true }
|
||||
}
|
||||
|
||||
if (e.hasOwnProperty('removed')) {
|
||||
this.$nextTick(() => {
|
||||
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()
|
||||
})
|
||||
.finally(() => {
|
||||
this.addRemoveGroupFlag = {}
|
||||
if (this.addRemoveGroupFlag.to.order < this.groupMaxCount[this.addRemoveGroupFlag.to.group_name]) {
|
||||
this.refreshPage(this.$t('cmdb.ciType.attributeSortedTips2'))
|
||||
} 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(() => this.$message.success(this.$t('saveSuccess')))
|
||||
.catch(() => this.init())
|
||||
.finally(() => {
|
||||
this.addRemoveGroupFlag = {}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
abortDraggable() {
|
||||
this.$nextTick(() => {
|
||||
this.$router.push({ name: 'ci_type' })
|
||||
})
|
||||
refreshPage(errorMessage) {
|
||||
this.$message.error(errorMessage)
|
||||
this.init()
|
||||
},
|
||||
updatePropertyIndex() {
|
||||
const attributes = [] // All attributes
|
||||
|
@ -594,7 +595,7 @@ export default {
|
|||
return attrTypeFilter.includes(valueType)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue