SetPassword.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{$t('cloudenv.text_529')}}</div>
  4. <div slot="body">
  5. <dialog-selected-tips :name="$t('cloudenv.coludgroup_text001')" :count="params.data.length" :action="$t('cloudenv.text_529')" />
  6. <dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" />
  7. <a-form-model
  8. ref="form"
  9. :model="fd"
  10. :rules="rules"
  11. v-bind="formItemLayout">
  12. <a-form-model-item :label="$t('cloudenv.clouduser_list_t2')" prop="password">
  13. <a-input-password v-model="fd.password" :placeholder="$t('validator.password')" />
  14. </a-form-model-item>
  15. </a-form-model>
  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 DialogMixin from '@/mixins/dialog'
  25. import WindowsMixin from '@/mixins/windows'
  26. import { REGEXP } from '@/utils/validate'
  27. export default {
  28. name: 'ClouduserSetPasswordDialog',
  29. mixins: [DialogMixin, WindowsMixin],
  30. data () {
  31. return {
  32. loading: false,
  33. fd: {
  34. password: '',
  35. },
  36. rules: {
  37. password: [
  38. {
  39. required: true,
  40. validator: (rule, value, cb) => {
  41. if (!this.fd.password) {
  42. cb()
  43. } else {
  44. const { regexp, message } = REGEXP.password
  45. if (regexp.test(this.fd.password)) {
  46. cb()
  47. } else {
  48. cb(Error(message))
  49. }
  50. }
  51. },
  52. },
  53. ],
  54. },
  55. formItemLayout: {
  56. wrapperCol: {
  57. span: 21,
  58. },
  59. labelCol: {
  60. span: 3,
  61. },
  62. },
  63. }
  64. },
  65. created () {
  66. },
  67. methods: {
  68. async handleConfirm () {
  69. this.loading = true
  70. try {
  71. await this.$refs.form.validate()
  72. await this.params.onManager('performAction', {
  73. id: this.params.data[0].id,
  74. managerArgs: {
  75. action: 'reset-password',
  76. data: {
  77. password: this.fd.password,
  78. },
  79. },
  80. })
  81. this.cancelDialog()
  82. } finally {
  83. this.loading = false
  84. }
  85. },
  86. },
  87. }
  88. </script>