mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-04 16:30:42 +00:00
feat: 同步删除远程机器账号
This commit is contained in:
112
src/components/Apps/AccountListTable/RemoveAccount.vue
Normal file
112
src/components/Apps/AccountListTable/RemoveAccount.vue
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<template>
|
||||||
|
<Dialog
|
||||||
|
:destroy-on-close="true"
|
||||||
|
:show-cancel="false"
|
||||||
|
:visible.sync="show"
|
||||||
|
:width="'50'"
|
||||||
|
v-bind="$attrs"
|
||||||
|
@confirm="accountConfirmHandle"
|
||||||
|
v-on="$listeners"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Dialog from '@/components/Dialog/index.vue'
|
||||||
|
import { openTaskPage } from '@/utils/jms'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'RemoveAccount',
|
||||||
|
components: {
|
||||||
|
Dialog
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
accounts: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
visible: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
show: false,
|
||||||
|
mfaDialogVisible: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
mounted() {
|
||||||
|
const url = `/api/v1/accounts/accounts/tasks/`
|
||||||
|
this.$axios.post(
|
||||||
|
url, { disableFlashErrorMsg: true, action: 'remove' }
|
||||||
|
).then(resp => {
|
||||||
|
this.$axios.post(
|
||||||
|
`/api/v1/accounts/accounts/tasks/`,
|
||||||
|
{
|
||||||
|
action: 'remove',
|
||||||
|
gather_accounts: this.accounts.map(account => account.id)
|
||||||
|
}
|
||||||
|
).then(res => {
|
||||||
|
openTaskPage(res['task'])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
accountConfirmHandle() {
|
||||||
|
this.show = false
|
||||||
|
this.mfaDialogVisible = false
|
||||||
|
},
|
||||||
|
exit() {
|
||||||
|
this.$emit('update:visible', false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.item-textarea > > > .el-textarea__inner {
|
||||||
|
height: 110px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-form-item {
|
||||||
|
border-bottom: 1px solid #EBEEF5;
|
||||||
|
padding: 5px 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
> > > .el-form-item__label {
|
||||||
|
padding-right: 20px;
|
||||||
|
line-height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
> > > .el-form-item__content {
|
||||||
|
line-height: 30px;
|
||||||
|
|
||||||
|
pre {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
display: block;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
color: #303133;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@@ -118,6 +118,8 @@
|
|||||||
"TaskID": "Task ID",
|
"TaskID": "Task ID",
|
||||||
"AccountTemplate": "Account template",
|
"AccountTemplate": "Account template",
|
||||||
"Sync": "Sync",
|
"Sync": "Sync",
|
||||||
|
"SyncDelete": "Sync delete",
|
||||||
|
"BulkSyncDelete": "Bulk sync delete",
|
||||||
"SyncUpdateAccountInfo": "Sync update account info",
|
"SyncUpdateAccountInfo": "Sync update account info",
|
||||||
"AddAccountResult": "Add account result",
|
"AddAccountResult": "Add account result",
|
||||||
"AutoPush": "Auto Push",
|
"AutoPush": "Auto Push",
|
||||||
|
@@ -118,6 +118,8 @@
|
|||||||
"TaskID": "タスク ID",
|
"TaskID": "タスク ID",
|
||||||
"AccountTemplate": "账号模版",
|
"AccountTemplate": "账号模版",
|
||||||
"Sync": "同期",
|
"Sync": "同期",
|
||||||
|
"SyncDelete": "同期削除",
|
||||||
|
"BulkSyncDelete": "一括同期削除",
|
||||||
"SyncUpdateAccountInfo": "アカウント情報の同期更新",
|
"SyncUpdateAccountInfo": "アカウント情報の同期更新",
|
||||||
"AddAccountResult": "账号批量添加结果",
|
"AddAccountResult": "账号批量添加结果",
|
||||||
"AutoPush": "自動プッシュ",
|
"AutoPush": "自動プッシュ",
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
"GenerateAccounts": "重新生成账号",
|
"GenerateAccounts": "重新生成账号",
|
||||||
"UpdateSecret": "更新密文",
|
"UpdateSecret": "更新密文",
|
||||||
"Sync": "同步",
|
"Sync": "同步",
|
||||||
|
"SyncDelete": "同步删除",
|
||||||
|
"BulkSyncDelete": "批量同步删除",
|
||||||
"SyncUpdateAccountInfo": "同步更新账号信息",
|
"SyncUpdateAccountInfo": "同步更新账号信息",
|
||||||
"AddAccountResult": "账号批量添加结果",
|
"AddAccountResult": "账号批量添加结果",
|
||||||
"AccountPolicy": "账号策略",
|
"AccountPolicy": "账号策略",
|
||||||
|
@@ -1,19 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<TreeTable :header-actions="headerActions" :table-config="tableConfig" :tree-setting="treeSetting" />
|
<div>
|
||||||
|
<RemoveAccount
|
||||||
|
v-if="showDeleteAccountDialog"
|
||||||
|
:accounts="gatherAccounts"
|
||||||
|
:visible.sync="showDeleteAccountDialog"
|
||||||
|
/>
|
||||||
|
<TreeTable
|
||||||
|
:header-actions="headerActions"
|
||||||
|
:table-config="tableConfig"
|
||||||
|
:tree-setting="treeSetting"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TreeTable from '@/components/Table/TreeTable'
|
import TreeTable from '@/components/Table/TreeTable'
|
||||||
import { toSafeLocalDateStr } from '@/utils/common'
|
import { toSafeLocalDateStr } from '@/utils/common'
|
||||||
import { ActionsFormatter } from '@/components/Table/TableFormatters'
|
import { ActionsFormatter } from '@/components/Table/TableFormatters'
|
||||||
|
import RemoveAccount from '@/components/Apps/AccountListTable/RemoveAccount.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
TreeTable
|
TreeTable,
|
||||||
|
RemoveAccount
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const vm = this
|
const vm = this
|
||||||
return {
|
return {
|
||||||
|
showDeleteAccountDialog: false,
|
||||||
|
gatherAccounts: {},
|
||||||
treeSetting: {
|
treeSetting: {
|
||||||
showMenu: false,
|
showMenu: false,
|
||||||
showRefresh: true,
|
showRefresh: true,
|
||||||
@@ -66,8 +81,8 @@ export default {
|
|||||||
moreActionsTitle: this.$t('common.More'),
|
moreActionsTitle: this.$t('common.More'),
|
||||||
extraActions: [
|
extraActions: [
|
||||||
{
|
{
|
||||||
name: 'View',
|
name: 'Sync',
|
||||||
title: this.$t('common.Sync'),
|
title: this.$t('accounts.Sync'),
|
||||||
can: this.$hasPerm('accounts.add_gatheredaccount') && !this.$store.getters.currentOrgIsRoot,
|
can: this.$hasPerm('accounts.add_gatheredaccount') && !this.$store.getters.currentOrgIsRoot,
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
callback: ({ row }) => {
|
callback: ({ row }) => {
|
||||||
@@ -79,6 +94,19 @@ export default {
|
|||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'SyncDelete',
|
||||||
|
title: this.$t('accounts.SyncDelete'),
|
||||||
|
can: this.$hasPerm('accounts.remove_account') && !this.$store.getters.currentOrgIsRoot,
|
||||||
|
type: 'danger',
|
||||||
|
callback: ({ row }) => {
|
||||||
|
vm.gatherAccounts = [row]
|
||||||
|
vm.showDeleteAccountDialog = false
|
||||||
|
setTimeout(() => {
|
||||||
|
vm.showDeleteAccountDialog = true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -103,7 +131,9 @@ export default {
|
|||||||
return selectedRows.length > 0 && vm.$hasPerm('accounts.add_gatheredaccount')
|
return selectedRows.length > 0 && vm.$hasPerm('accounts.add_gatheredaccount')
|
||||||
},
|
},
|
||||||
callback: function({ selectedRows }) {
|
callback: function({ selectedRows }) {
|
||||||
const ids = selectedRows.map(v => { return v.id })
|
const ids = selectedRows.map(v => {
|
||||||
|
return v.id
|
||||||
|
})
|
||||||
this.$axios.post(
|
this.$axios.post(
|
||||||
`/api/v1/accounts/gathered-accounts/sync-accounts/`,
|
`/api/v1/accounts/gathered-accounts/sync-accounts/`,
|
||||||
{ gathered_account_ids: ids }
|
{ gathered_account_ids: ids }
|
||||||
@@ -113,6 +143,22 @@ export default {
|
|||||||
this.$message.error(this.$tc('common.bulkSyncErrorMsg' + ' ' + err))
|
this.$message.error(this.$tc('common.bulkSyncErrorMsg' + ' ' + err))
|
||||||
})
|
})
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'BulkSyncDelete',
|
||||||
|
title: this.$t('common.BulkSyncDelete'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: 'fa fa-exchange',
|
||||||
|
can: ({ selectedRows }) => {
|
||||||
|
return selectedRows.length > 0 && vm.$hasPerm('accounts.remove_account')
|
||||||
|
},
|
||||||
|
callback: function({ selectedRows }) {
|
||||||
|
vm.gatherAccounts = selectedRows
|
||||||
|
vm.showDeleteAccountDialog = false
|
||||||
|
setTimeout(() => {
|
||||||
|
vm.showDeleteAccountDialog = true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user