Merge pull request #3291 from jumpserver/pr@dev@asset_perm_account

perf: 修改AccountFormatter 请求方法为post
This commit is contained in:
feng626
2023-07-27 14:04:14 +08:00
committed by GitHub
2 changed files with 22 additions and 11 deletions

View File

@@ -18,6 +18,8 @@
<AccountFormatter
class="checkbox-accounts"
:value="object['accounts']"
:assets="assetIds"
:nodes="nodeIds"
@change="updateAccount"
/>
</IBox>
@@ -54,6 +56,14 @@ export default {
}
}
},
computed: {
assetIds() {
return this.object.assets.map(asset => asset.id)
},
nodeIds() {
return this.object.nodes.map(node => node.id)
}
},
methods: {
async updateAccount(accounts) {
const url = `/api/v1/perms/asset-permissions/${this.object.id}/`

View File

@@ -180,16 +180,17 @@ export default {
}
},
autocomplete: (query, cb) => {
this.$axios.get('/api/v1/accounts/accounts/username-suggestions/', {
params: {
username: query,
assets: this.assets.slice(0, 20).join(','),
nodes: this.nodes.slice(0, 20).map(item => {
return typeof item === 'object' ? item.pk : item
}).join(','),
oid: this.oid
}
}).then(res => {
const data = {
username: query,
assets: this.assets.slice(0, 20),
nodes: this.nodes.slice(0, 20).map(item => {
return typeof item === 'object' ? item.pk : item
})
}
this.$axios.post(
'/api/v1/accounts/accounts/username-suggestions/',
data, { params: { oid: this.oid }}
).then(res => {
if (!res) res = []
const data = res
.filter(item => vm.value.indexOf(item) === -1)
@@ -270,7 +271,7 @@ export default {
}
</script>
<style lang='scss' scoped>
<style lang="scss" scoped>
.select >>> .el-input.el-input--suffix {
width: 100px
}