| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template>
- <base-dialog @cancel="cancelDialog">
- <div slot="header">{{action}}</div>
- <div slot="body">
- <dialog-selected-tips :name="$t('compute.instance_backup')" :count="params.data.length" :action="action" />
- <dialog-table :data="params.data" :columns="columns" />
- <a-form :form="form.fc" hideRequiredMark v-bind="formItemLayout">
- <a-form-item :label="$t('compute.rollback_type')">
- <a-radio-group v-decorator="decorators.type">
- <a-radio-button value="new">
- {{ $t('compute.create_new_instance') }}
- </a-radio-button>
- </a-radio-group>
- </a-form-item>
- <a-form-item :label="$t('compute.instance_name')">
- <a-input
- v-decorator="decorators.name"
- :placeholder="$t('compute.instance_name_placeholder')" />
- </a-form-item>
- </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'
- export default {
- name: 'InstanceBackupRollbackDialog',
- mixins: [DialogMixin, WindowsMixin],
- data () {
- return {
- loading: false,
- action: this.$t('compute.text_478'),
- form: {
- fc: this.$form.createForm(this),
- },
- decorators: {
- type: [
- 'type',
- {
- initialValue: 'new',
- },
- ],
- name: [
- 'name',
- ],
- },
- formItemLayout: {
- wrapperCol: {
- span: 18,
- },
- labelCol: {
- span: 6,
- },
- },
- }
- },
- computed: {
- columns () {
- const showFields = ['name', 'brand', 'guest']
- return this.params.columns.filter((item) => { return showFields.includes(item.field) })
- },
- },
- methods: {
- async doRollbackSubmit (values) {
- const params = {
- name: values.name,
- }
- const ids = this.params.data.map(item => item.id)
- await this.params.onManager('performAction', {
- id: ids[0],
- steadyStatus: ['ready'],
- managerArgs: {
- action: 'recovery',
- data: params,
- },
- })
- },
- async handleConfirm () {
- this.loading = true
- try {
- const values = await this.form.fc.validateFields()
- await this.doRollbackSubmit(values)
- this.params.refresh()
- this.loading = false
- this.cancelDialog()
- } catch (error) {
- console.log(error)
- this.loading = false
- }
- },
- },
- }
- </script>
|