1
0
mirror of https://github.com/jumpserver/lina.git synced 2025-05-11 09:35:34 +00:00

fixed: Fixed an issue with Select2 component and table in user list

This commit is contained in:
zhaojisen 2024-07-01 19:28:00 +08:00
parent 7c3effe1d9
commit cccec1aa1b
3 changed files with 27 additions and 13 deletions
src
components/Cards/RelationCard
views
assets/Asset/AssetDetail/components
users/Group/UserGroupDetail

View File

@ -114,15 +114,17 @@ export default {
onDeleteSuccess: {
type: Function,
default(obj, that) {
// hasObjectsobject
// hasObjects object
const theRemoveIndex = that.iHasObjects.findIndex((v) => v.value === obj.value)
that.iHasObjects.splice(theRemoveIndex, 1)
// disabled valuesvalue
// disabled values value
while (that.select2.disabledValues.indexOf(obj.value) !== -1) {
const i = that.select2.disabledValues.indexOf(obj.value)
this.$log.debug('disabled values remove index: ', i)
that.$log.debug('disabled values remove index: ', i)
that.select2.disabledValues.splice(i, 1)
}
that.$message.success(that.$t('RemoveSuccessMsg'))
}
},
@ -157,6 +159,8 @@ export default {
that.iHasObjects = [...that.iHasObjects, ...objects]
that.$refs.select2.clearSelected()
that.$message.success(that.$t('AddSuccessMsg'))
this.$refs.select2.refresh()
this.$emit('addSuccess')
}
},
getHasObjects: {
@ -291,9 +295,9 @@ export default {
}
},
removeObject(obj) {
this.performDelete(obj, this).then(
() => this.onDeleteSuccess(obj, this)
).catch(error => {
this.performDelete(obj, this).then(() => {
this.onDeleteSuccess(obj, this)
}).catch(error => {
this.onDeleteFail(error, this)
})
},
@ -303,7 +307,9 @@ export default {
return
}
this.performAdd(objects, this).then(
() => this.onAddSuccess(objects, this)
() => {
this.onAddSuccess(objects, this)
}
)
},
async selectAll() {

View File

@ -51,7 +51,7 @@ export default {
props: {
icon: {
type: String,
required: true
default: ''
},
title: {
type: String,

View File

@ -5,7 +5,7 @@
<GenericListTable ref="listTable" :header-actions="headerActions" :table-config="tableConfig" />
</el-col>
<el-col :md="9" :sm="24">
<RelationCard v-bind="relationConfig" />
<RelationCard ref="relationCard" v-bind="relationConfig" @addSuccess="addSuccess" />
</el-col>
</el-row>
</div>
@ -95,6 +95,11 @@ export default {
}
).then(res => {
this.$message.success(this.$tc('DeleteSuccessMsg'))
setTimeout(() => {
this.$refs.relationCard.$refs.select2.refresh()
}, 300)
reload()
}).catch(error => {
this.$message.error(this.$tc('DeleteErrorMsg') + ' ' + error)
@ -143,14 +148,17 @@ export default {
usergroup: groupId
}
})
this.$axios.post(relationUrl, data)
this.$message.success(this.$tc('AddSuccessMsg'))
setTimeout(() => {
window.location.reload()
}, 1000)
return this.$axios.post(relationUrl, data)
}
}
}
},
methods: {
addSuccess() {
this.$refs.listTable.reloadTable()
}
}
}
</script>