| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <template>
- <base-dialog @cancel="cancelDialog">
- <div slot="header">{{$t('compute.add_to_bastion')}}</div>
- <div slot="body">
- <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="$t('compute.add_to_bastion')" />
- <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
- <a-form :form="form.fc" v-bind="formItemLayout">
- <bastion-host :decorator="decorators.bastion_host" :form="form" inDialog />
- </a-form>
- </div>
- <div slot="footer">
- <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
- <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
- </div>
- </base-dialog>
- </template>
- <script>
- import DialogMixin from '@/mixins/dialog'
- import WindowsMixin from '@/mixins/windows'
- import { getInitialValue } from '@/utils/common/ant'
- import { Decorator } from '@Compute/utils/createServer'
- import { SERVER_TYPE } from '@Compute/constants'
- import BastionHost from '../create/components/BastionHost'
- export default {
- name: 'VmAddToBastionDialog',
- components: {
- BastionHost,
- },
- mixins: [DialogMixin, WindowsMixin],
- data () {
- const decorators = new Decorator(SERVER_TYPE.idc).createDecorators()
- const initFd = getInitialValue(decorators)
- return {
- loading: false,
- form: {
- fc: this.$form.createForm(this),
- fd: {
- ...initFd,
- },
- },
- formItemLayout: {
- wrapperCol: {
- span: 18,
- },
- labelCol: {
- span: 6,
- },
- },
- decorators,
- }
- },
- computed: {
- },
- methods: {
- async handleConfirm () {
- this.loading = true
- try {
- const values = await this.form.fc.validateFields()
- values.accounts = [values.privileged_accounts].concat(values.accounts)
- delete values.privileged_accounts
- for (const item of this.params.data) {
- await new this.$Manager('bastion_servers').create({
- data: {
- ...values,
- server_id: item.id,
- generate_name: item.name,
- },
- })
- }
- this.params.refresh()
- this.cancelDialog()
- } finally {
- this.loading = false
- }
- },
- },
- }
- </script>
|