AccountListSetPrivilege.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.elasticcaches')" :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" class="mt-5">
  8. <a-form-item :label="$t('db.text_284')" v-bind="formItemLayout">
  9. <a-radio-group v-decorator="decorators.account_privilege">
  10. <a-radio v-for="k in Object.keys(privileges)" :key="k" :value="k">
  11. {{privileges[k]}}
  12. </a-radio>
  13. </a-radio-group>
  14. </a-form-item>
  15. </a-form>
  16. </div>
  17. <div slot="footer">
  18. <a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t('dialog.ok') }}</a-button>
  19. <a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button>
  20. </div>
  21. </base-dialog>
  22. </template>
  23. <script>
  24. import { ACCOUNT_PRIVILEGES } from '../constants'
  25. import { CreateServerForm } from '@Compute/constants'
  26. import DialogMixin from '@/mixins/dialog'
  27. import WindowsMixin from '@/mixins/windows'
  28. export default {
  29. name: 'RedisAccountListSetPrivilegeDialog',
  30. mixins: [DialogMixin, WindowsMixin],
  31. data () {
  32. return {
  33. loading: false,
  34. form: {
  35. fc: this.$form.createForm(this),
  36. },
  37. formItemLayout: {
  38. wrapperCol: { span: CreateServerForm.wrapperCol },
  39. labelCol: { span: CreateServerForm.labelCol },
  40. },
  41. }
  42. },
  43. computed: {
  44. privileges () {
  45. const ret = ACCOUNT_PRIVILEGES
  46. if (this.params.redisItem.brand === 'Qcloud') {
  47. delete ret.repl
  48. }
  49. return ret
  50. },
  51. decorators () {
  52. const { initialValues = {} } = this.params
  53. const decorators = {
  54. account_privilege: [
  55. 'account_privilege',
  56. {
  57. initialValue: initialValues.account_privilege,
  58. },
  59. ],
  60. }
  61. return decorators
  62. },
  63. },
  64. methods: {
  65. async handleConfirm () {
  66. this.loading = true
  67. try {
  68. const params = {
  69. account_privilege: this.form.fc.getFieldValue('account_privilege'),
  70. elasticcache: this.params.redisItem.id,
  71. }
  72. await this.params.list.onManager('performAction', {
  73. id: this.params.data[0].id,
  74. steadyStatus: this.params.steadyStatus,
  75. managerArgs: {
  76. action: 'reset-password',
  77. data: params,
  78. },
  79. })
  80. this.loading = false
  81. this.cancelDialog()
  82. } catch (error) {
  83. this.loading = false
  84. }
  85. },
  86. },
  87. }
  88. </script>