SetAutoResetDialog.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('compute.disk_set_auto_reset')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :count="params.data.length" :name="$t('dictionary.disk')" :action="$t('compute.disk_set_auto_reset')" />
  6. <dialog-table v-if="params.columns && params.columns.length" :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form
  8. :form="form.fc">
  9. <a-form-item :label="$t('compute.shutdown_auto_reset')" v-bind="formItemLayout">
  10. <a-switch :checkedChildren="$t('cloudenv.text_84')" :unCheckedChildren="$t('cloudenv.text_85')" v-decorator="decorators.auto_reset" />
  11. </a-form-item>
  12. </a-form>
  13. </div>
  14. <div slot="footer">
  15. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  16. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  17. </div>
  18. </base-dialog>
  19. </template>
  20. <script>
  21. import DialogMixin from '@/mixins/dialog'
  22. import WindowsMixin from '@/mixins/windows'
  23. export default {
  24. name: 'DiskSetAutoResetDialog',
  25. mixins: [DialogMixin, WindowsMixin],
  26. data () {
  27. return {
  28. loading: false,
  29. scope: this.$store.getters.scope,
  30. form: {
  31. fc: this.$form.createForm(this),
  32. },
  33. decorators: {
  34. auto_reset: [
  35. 'auto_reset',
  36. {
  37. valuePropName: 'checked',
  38. initialValue: this.params.data[0].auto_reset || false,
  39. },
  40. ],
  41. },
  42. formItemLayout: {
  43. labelCol: {
  44. sm: { span: 3 },
  45. },
  46. wrapperCol: {
  47. sm: { span: 21 },
  48. },
  49. },
  50. }
  51. },
  52. computed: {
  53. domain () {
  54. return this.params.data[0].domain_id
  55. },
  56. tenant () {
  57. return this.params.data[0].tenant_id
  58. },
  59. },
  60. created () {
  61. },
  62. methods: {
  63. async handleConfirm () {
  64. this.loading = true
  65. try {
  66. const values = await this.form.fc.validateFields()
  67. this.loading = true
  68. await this.params.onManager('update', {
  69. id: this.params.data[0].id,
  70. managerArgs: {
  71. data: {
  72. auto_reset: values.auto_reset,
  73. },
  74. },
  75. })
  76. this.loading = false
  77. this.params.refresh()
  78. this.cancelDialog()
  79. } catch (error) {
  80. this.loading = false
  81. throw error
  82. }
  83. },
  84. },
  85. }
  86. </script>