| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <template>
- <base-dialog @cancel="cancelDialog">
- <div slot="header">{{$t('compute.text_1209')}}</div>
- <div slot="body">
- <dialog-selected-tips :name="$t('dictionary.server')" :count="params.data.length" :action="$t('compute.text_1209')" />
- <dialog-table :data="params.data" :columns="columns" />
- <a-form :form="form.fc" hideRequiredMark>
- <a-form-item :label="$t('compute.text_1210')" v-bind="formItemLayout" :extra="$t('compute.text_1211')">
- <a-switch :checkedChildren="$t('compute.text_115')" :unCheckedChildren="$t('compute.text_116')" :disabled="disableAutoPurge" v-decorator="decorators.purge" />
- </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: 'VmDeleteBackupDialog',
- mixins: [DialogMixin, WindowsMixin],
- data () {
- return {
- loading: false,
- form: {
- fc: this.$form.createForm(this),
- },
- decorators: {
- purge: [
- 'purge',
- {
- initialValue: false,
- valuePropName: 'checked',
- },
- ],
- },
- formItemLayout: {
- wrapperCol: {
- span: 21,
- },
- labelCol: {
- span: 3,
- },
- },
- }
- },
- computed: {
- columns () {
- const col = this.params.columns.slice(0, 3)
- col.push({
- field: 'backup_host_status',
- title: this.$t('compute.text_1163'),
- width: 120,
- showOverflow: 'ellipsis',
- slots: {
- default: ({ row }) => {
- return [<status status={ row.backup_host_status } statusModule='host_status'/>]
- },
- },
- })
- return col
- },
- disableAutoPurge () {
- return this.params.data.some((obj) => { return obj.backup_host_status === 'online' })
- },
- },
- mounted () {
- const isOnline = this.params.data.some((obj) => { return obj.backup_host_status === 'online' })
- if (!isOnline) {
- this.form.fc.setFieldsValue({
- purge: true,
- })
- }
- },
- methods: {
- async handleConfirm () {
- this.loading = true
- try {
- const values = await this.form.fc.validateFields()
- const ids = this.params.data.map(item => item.id)
- await this.params.onManager('batchPerformAction', {
- id: ids,
- steadyStatus: ['running', 'ready'],
- managerArgs: {
- action: 'delete-backup',
- data: values,
- },
- })
- this.cancelDialog()
- } finally {
- this.loading = false
- }
- },
- },
- }
- </script>
|