ClearData.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{this.params.title}}</div>
  4. <div slot="body">
  5. <a-alert class="mb-2" type="warning">
  6. <div slot="message">{{$t('db.text_392')}}</div>
  7. </a-alert>
  8. <dialog-selected-tips :name="$t('dictionary.elasticcaches')" :count="params.data.length" :action="this.params.title" />
  9. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  10. <a-form :form="form.fc" class="mt-3">
  11. <a-form-item v-if="params.data[0].provider === 'Qcloud' && params.data[0].auth_mode === 'on'" :label="$t('db.text_195')" v-bind="formItemLayout">
  12. <a-input-password v-decorator="decorators.password" :plcaeholder="$t('db.text_360')" />
  13. </a-form-item>
  14. </a-form>
  15. </div>
  16. <div slot="footer">
  17. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button>
  18. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  19. </div>
  20. </base-dialog>
  21. </template>
  22. <script>
  23. import DialogMixin from '@/mixins/dialog'
  24. import WindowsMixin from '@/mixins/windows'
  25. import { passwordValidator } from '@/utils/validate'
  26. export default {
  27. name: 'RedisClearDataDialog',
  28. mixins: [DialogMixin, WindowsMixin],
  29. data () {
  30. return {
  31. form: {
  32. fc: this.$form.createForm(this),
  33. },
  34. formItemLayout: {
  35. wrapperCol: { span: 20 },
  36. labelCol: { span: 4 },
  37. },
  38. loading: false,
  39. decorators: {
  40. password: [
  41. 'password',
  42. {
  43. validateFirst: true,
  44. rules: [
  45. { required: true, message: this.$t('db.text_360') },
  46. { validator: passwordValidator },
  47. ],
  48. },
  49. ],
  50. },
  51. }
  52. },
  53. methods: {
  54. async handleConfirm () {
  55. this.loading = true
  56. try {
  57. this.loading = false
  58. const values = await this.form.fc.validateFields()
  59. if (this.params.data && this.params.data.length > 1) {
  60. await this.params.onManager('batchPerformAction', {
  61. id: this.params.data.map(({ id }) => id),
  62. steadyStatus: 'running',
  63. managerArgs: {
  64. action: 'flush-instance',
  65. },
  66. })
  67. } else {
  68. await this.params.onManager('performAction', {
  69. id: this.params.data[0].id,
  70. steadyStatus: 'running',
  71. managerArgs: {
  72. action: 'flush-instance',
  73. data: values,
  74. },
  75. })
  76. }
  77. this.cancelDialog()
  78. this.params.refresh()
  79. this.$message.success(this.$t('db.text_149'))
  80. } catch (error) {
  81. this.loading = false
  82. throw error
  83. }
  84. },
  85. },
  86. }
  87. </script>