Email.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <a-form
  3. :form="form.fc"
  4. v-bind="formItemLayout"
  5. hideRequiredMark>
  6. <a-form-item :label="$t('system.text_269')">
  7. <a-input v-decorator="decorators.hostname" />
  8. </a-form-item>
  9. <a-form-item label="SSL">
  10. <a-switch :checkedChildren="$t('system.text_134')" :unCheckedChildren="$t('system.text_135')" v-decorator="decorators.ssl_global" />
  11. </a-form-item>
  12. <a-form-item :label="$t('system.text_270')">
  13. <a-input-number v-decorator="decorators.hostport" :min="1" :max="65535" />
  14. </a-form-item>
  15. <a-form-item :label="$t('system.text_126')">
  16. <a-input v-decorator="decorators.username" />
  17. </a-form-item>
  18. <a-form-item :label="$t('system.text_221')">
  19. <a-input-password v-decorator="decorators.password" />
  20. </a-form-item>
  21. <a-form-item :label="$t('iam.sender_address')">
  22. <div slot="extra">
  23. {{ $t('iam.notifyconfig.sender_address_extra') }}
  24. </div>
  25. <a-input v-decorator="decorators.sender_address" />
  26. </a-form-item>
  27. <a-form-item v-if="false">
  28. <a-button type="primary" @click="handleSubmit" :loading="submiting">{{ $t('common.ok') }}</a-button>
  29. <test-button v-if="false" class="ml-3" :post="testPost" />
  30. </a-form-item>
  31. </a-form>
  32. </template>
  33. <script>
  34. import TestButton from '@/sections/TestButton'
  35. export default {
  36. name: 'EmailConfig',
  37. components: {
  38. TestButton,
  39. },
  40. props: {
  41. formItemLayout: {
  42. required: true,
  43. type: Object,
  44. },
  45. offsetWrapperCol: {
  46. required: true,
  47. type: Object,
  48. },
  49. loading: Boolean,
  50. },
  51. data () {
  52. return {
  53. submiting: false,
  54. form: {
  55. fc: this.$form.createForm(this),
  56. },
  57. decorators: {
  58. hostname: [
  59. 'hostname',
  60. {
  61. rules: [
  62. { required: true, message: this.$t('system.text_271') },
  63. ],
  64. },
  65. ],
  66. ssl_global: [
  67. 'ssl_global',
  68. {
  69. initialValue: false,
  70. valuePropName: 'checked',
  71. },
  72. ],
  73. hostport: [
  74. 'hostport',
  75. {
  76. initialValue: '465',
  77. rules: [
  78. { required: true, message: this.$t('system.text_272') },
  79. ],
  80. },
  81. ],
  82. username: [
  83. 'username',
  84. {
  85. rules: [
  86. { required: true, message: this.$t('system.text_238') },
  87. ],
  88. },
  89. ],
  90. password: [
  91. 'password',
  92. {
  93. rules: [
  94. { required: true, message: this.$t('system.text_239') },
  95. ],
  96. },
  97. ],
  98. sender_address: [
  99. 'sender_address',
  100. {
  101. validateFirst: true,
  102. rules: [
  103. { required: true, message: this.$t('common.field_required_placeholder', [this.$t('iam.sender_address')]) },
  104. { validator: this.$validate('email') },
  105. ],
  106. },
  107. ],
  108. },
  109. contactData: null,
  110. }
  111. },
  112. destroyed () {
  113. this.manager = null
  114. },
  115. created () {
  116. this.manager = new this.$Manager('notifyconfigs', 'v1')
  117. },
  118. methods: {
  119. async handleSubmit () {
  120. const values = await this.form.fc.validateFields()
  121. try {
  122. this.submiting = true
  123. await this.manager.create({
  124. data: {
  125. content: values,
  126. type: 'email',
  127. },
  128. })
  129. this.$message.success(this.$t('system.text_124', [this.$t('system.text_302')]))
  130. } catch (error) {
  131. this.$message.error(this.$t('common_622', [this.$t('system.text_302')]))
  132. throw error
  133. } finally {
  134. this.submiting = false
  135. }
  136. },
  137. async testPost () {
  138. try {
  139. const values = await this.form.fc.validateFields()
  140. await new this.$Manager('notifyconfigs', 'v1').performClassAction({
  141. action: 'validate',
  142. data: {
  143. content: values,
  144. type: 'email',
  145. },
  146. })
  147. } catch (error) {
  148. this.$message.error(this.$t('common_623', [this.$t('common_269')]))
  149. throw error
  150. }
  151. },
  152. },
  153. }
  154. </script>