feat: 修复在继承模型的情况下,非继承属性与继承属性的排序以及其他分组的排序的问题

This commit is contained in:
thexqn 2024-08-23 16:29:29 +08:00
parent de51cb3e21
commit 8f62227adb
1 changed files with 17 additions and 28 deletions

View File

@ -479,53 +479,42 @@ export default {
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 || group === null) { if (group === -1 || group === null) {
this.$message.error(this.$t('cmdb.ciType.attributeSortedTips')) this.refreshPage(this.$t('cmdb.ciType.attributeSortedTips'))
this.refreshPage()
} else if (e.moved.newIndex < this.groupMaxCount[group]) { } else if (e.moved.newIndex < this.groupMaxCount[group]) {
this.$message.error(this.$t('cmdb.ciType.attributeSortedTips2')) this.refreshPage(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 },
to: { order: e.moved.newIndex, group_name: group }, to: { order: e.moved.newIndex, group_name: group }
}) })
.then((res) => this.$message.success(this.$t('updateSuccess'))) .then(() => this.$message.success(this.$t('updateSuccess')))
.catch(() => { .catch(() => this.init())
this.refreshPage()
})
} }
} }
if (e.hasOwnProperty('added')) { if (e.hasOwnProperty('added')) {
this.addRemoveGroupFlag = { to: { group_name: group, order: e.added.newIndex }, inited: true } this.addRemoveGroupFlag = { to: { group_name: group, order: e.added.newIndex }, inited: true }
} }
if (e.hasOwnProperty('removed')) { if (e.hasOwnProperty('removed')) {
this.$nextTick(() => { this.$nextTick(() => {
if (this.addRemoveGroupFlag.to.order < this.groupMaxCount[this.addRemoveGroupFlag.to.group_name]) { if (this.addRemoveGroupFlag.to.order < this.groupMaxCount[this.addRemoveGroupFlag.to.group_name]) {
this.$message.error(this.$t('cmdb.ciType.attributeSortedTips2')) this.refreshPage(this.$t('cmdb.ciType.attributeSortedTips2'))
this.refreshPage()
this.addRemoveGroupFlag = {}
} else { } 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')))
.catch(() => {
this.refreshPage()
})
.finally(() => {
this.addRemoveGroupFlag = {}
}) })
.then(() => this.$message.success(this.$t('saveSuccess')))
.catch(() => this.init())
.finally(() => {
this.addRemoveGroupFlag = {}
})
} }
}) })
} }
}, },
abortDraggable() { refreshPage(errorMessage) {
this.$nextTick(() => { this.$message.error(errorMessage)
this.$router.push({ name: 'ci_type' }) this.init()
})
}, },
updatePropertyIndex() { updatePropertyIndex() {
const attributes = [] // All attributes const attributes = [] // All attributes