Renew.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 :form="form.fc">
  8. <clearing-radios v-bind="formItemLayout" />
  9. </a-form>
  10. </div>
  11. <div slot="footer">
  12. <a-button :loading="loading" @click="handleConfirm" type="primary">{{ $t('dialog.ok') }}</a-button>
  13. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  14. </div>
  15. </base-dialog>
  16. </template>
  17. <script>
  18. import { CreateServerForm } from '@Compute/constants'
  19. import DialogMixin from '@/mixins/dialog'
  20. import WindowsMixin from '@/mixins/windows'
  21. export default {
  22. name: 'RdsRenewDialog',
  23. mixins: [DialogMixin, WindowsMixin],
  24. provide () {
  25. return {
  26. form: this.form,
  27. }
  28. },
  29. data () {
  30. return {
  31. loading: false,
  32. form: {
  33. fc: this.$form.createForm(this),
  34. },
  35. formItemLayout: {
  36. wrapperCol: { span: CreateServerForm.wrapperCol },
  37. labelCol: { span: CreateServerForm.labelCol },
  38. },
  39. }
  40. },
  41. methods: {
  42. validateForm () {
  43. return new Promise((resolve, reject) => {
  44. this.form.fc.validateFields((err, values) => {
  45. if (!err) {
  46. resolve(values)
  47. } else {
  48. reject(err)
  49. }
  50. })
  51. })
  52. },
  53. async handleConfirm () {
  54. this.loading = true
  55. try {
  56. const values = await this.validateForm()
  57. const ids = this.params.data.map(item => item.id)
  58. await this.params.onManager('batchUpdate', {
  59. id: ids,
  60. steadyStatus: ['running'],
  61. managerArgs: {
  62. data: values,
  63. },
  64. })
  65. this.loading = false
  66. this.$message.success(this.$t('db.text_149'))
  67. this.cancelDialog()
  68. this.params.refresh()
  69. } catch (error) {
  70. this.loading = false
  71. }
  72. },
  73. },
  74. }
  75. </script>