EditAttr.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{params.title}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('dictionary.dbinstances')" :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: 'RDSEditAttrDialog',
  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. const ids = this.params.data.map(({ id }) => id)
  65. await this.params.list.batchUpdate(ids, {
  66. disable_delete: this.form.fc.getFieldValue('disable_delete'),
  67. })
  68. this.cancelDialog()
  69. } finally {
  70. this.loading = false
  71. }
  72. },
  73. },
  74. }
  75. </script>