EditAttr.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('db.text_290')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.elasticcaches')" :count="params.data.length" :action="params.title" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form
  8. class="mt-3"
  9. :form="form.fc">
  10. <a-form-item :label="$t('common.text00076')" v-bind="formItemLayout">
  11. <a-radio-group v-decorator="decorators.disable_delete">
  12. <a-radio :value="true">{{$t('db.text_146')}}</a-radio>
  13. <a-radio :value="false">{{$t('db.text_147')}}</a-radio>
  14. </a-radio-group>
  15. </a-form-item>
  16. </a-form>
  17. </div>
  18. <div slot="footer">
  19. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button>
  20. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  21. </div>
  22. </base-dialog>
  23. </template>
  24. <script>
  25. import { CreateServerForm } from '@Compute/constants'
  26. import DialogMixin from '@/mixins/dialog'
  27. import WindowsMixin from '@/mixins/windows'
  28. export default {
  29. name: 'RedisEditAttrDialog',
  30. mixins: [DialogMixin, WindowsMixin],
  31. data () {
  32. return {
  33. loading: false,
  34. form: {
  35. fc: this.$form.createForm(this, { onFieldsChange: this.onFieldsChange }),
  36. },
  37. formItemLayout: {
  38. wrapperCol: { span: CreateServerForm.wrapperCol },
  39. labelCol: { span: CreateServerForm.labelCol },
  40. },
  41. }
  42. },
  43. computed: {
  44. decorators () {
  45. const { data } = this.params
  46. let initialValueDisableDelete = true
  47. if (data && data.length === 1) {
  48. initialValueDisableDelete = data[0].disable_delete
  49. }
  50. return {
  51. disable_delete: [
  52. 'disable_delete',
  53. {
  54. initialValue: initialValueDisableDelete,
  55. },
  56. ],
  57. }
  58. },
  59. },
  60. methods: {
  61. async handleConfirm () {
  62. this.loading = true
  63. try {
  64. this.loading = false
  65. const ids = this.params.data.map(({ id }) => id)
  66. await this.params.onManager('batchUpdate', {
  67. id: ids,
  68. steadyStatus: 'running',
  69. managerArgs: {
  70. data: {
  71. disable_delete: this.form.fc.getFieldValue('disable_delete'),
  72. },
  73. },
  74. })
  75. this.cancelDialog()
  76. this.$message.success(this.$t('db.text_149'))
  77. } catch (error) {
  78. this.loading = false
  79. throw error
  80. }
  81. },
  82. },
  83. }
  84. </script>