TestMobile.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <base-dialog @cancel="cancelDialog">
  3. <div slot="header">{{ $t('common_269') }}</div>
  4. <div slot="body">
  5. <a-alert class="mb-2" :message="$t('iam.sms_mobile')" />
  6. <a-form-model
  7. ref="form"
  8. v-bind="formItemLayout"
  9. :model="form"
  10. :rules="rules">
  11. <a-form-model-item :label="$t('iam.mobile')" prop="phone_number">
  12. <a-input v-model="form.phone_number" />
  13. </a-form-model-item>
  14. </a-form-model>
  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 { validateModelForm } from '@/utils/validate'
  26. export default {
  27. name: 'NotifyTestMobileDialog',
  28. components: {
  29. },
  30. mixins: [DialogMixin, WindowsMixin],
  31. data () {
  32. return {
  33. loading: false,
  34. form: {
  35. phone_number: '',
  36. },
  37. rules: {
  38. phone_number: [
  39. { validator: this.$validate('mobile') },
  40. ],
  41. },
  42. formItemLayout: {
  43. wrapperCol: {
  44. span: 21,
  45. },
  46. labelCol: {
  47. span: 3,
  48. },
  49. },
  50. }
  51. },
  52. created () {
  53. this.manager = new this.$Manager('notifyconfigs', 'v1')
  54. },
  55. methods: {
  56. async handleConfirm () {
  57. this.loading = true
  58. try {
  59. await validateModelForm(this.$refs.form)
  60. this.loading = true
  61. const res = await this.manager.performClassAction({
  62. action: 'validate',
  63. data: {
  64. content: {
  65. ...this.params.data.content,
  66. phone_number: this.form.phone_number,
  67. },
  68. type: this.params.data.type,
  69. },
  70. })
  71. const { is_valid, message } = res.data
  72. if (is_valid) {
  73. this.$notification.success({
  74. message: this.$t('common_270'),
  75. description: this.$t('common_271'),
  76. })
  77. } else {
  78. this.$notification.error({
  79. message: message,
  80. })
  81. }
  82. this.loading = false
  83. this.cancelDialog()
  84. } catch (error) {
  85. this.loading = false
  86. }
  87. },
  88. },
  89. }
  90. </script>