| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <template>
- <a-form
- :form="form.fc"
- v-bind="formItemLayout"
- hideRequiredMark>
- <a-form-item :label="$t('system.text_269')">
- <a-input v-decorator="decorators.hostname" />
- </a-form-item>
- <a-form-item label="SSL">
- <a-switch :checkedChildren="$t('system.text_134')" :unCheckedChildren="$t('system.text_135')" v-decorator="decorators.ssl_global" />
- </a-form-item>
- <a-form-item :label="$t('system.text_270')">
- <a-input-number v-decorator="decorators.hostport" :min="1" :max="65535" />
- </a-form-item>
- <a-form-item :label="$t('system.text_126')">
- <a-input v-decorator="decorators.username" />
- </a-form-item>
- <a-form-item :label="$t('system.text_221')">
- <a-input-password v-decorator="decorators.password" />
- </a-form-item>
- <a-form-item :label="$t('iam.sender_address')">
- <div slot="extra">
- {{ $t('iam.notifyconfig.sender_address_extra') }}
- </div>
- <a-input v-decorator="decorators.sender_address" />
- </a-form-item>
- <a-form-item v-if="false">
- <a-button type="primary" @click="handleSubmit" :loading="submiting">{{ $t('common.ok') }}</a-button>
- <test-button v-if="false" class="ml-3" :post="testPost" />
- </a-form-item>
- </a-form>
- </template>
- <script>
- import TestButton from '@/sections/TestButton'
- export default {
- name: 'EmailConfig',
- components: {
- TestButton,
- },
- props: {
- formItemLayout: {
- required: true,
- type: Object,
- },
- offsetWrapperCol: {
- required: true,
- type: Object,
- },
- loading: Boolean,
- },
- data () {
- return {
- submiting: false,
- form: {
- fc: this.$form.createForm(this),
- },
- decorators: {
- hostname: [
- 'hostname',
- {
- rules: [
- { required: true, message: this.$t('system.text_271') },
- ],
- },
- ],
- ssl_global: [
- 'ssl_global',
- {
- initialValue: false,
- valuePropName: 'checked',
- },
- ],
- hostport: [
- 'hostport',
- {
- initialValue: '465',
- rules: [
- { required: true, message: this.$t('system.text_272') },
- ],
- },
- ],
- username: [
- 'username',
- {
- rules: [
- { required: true, message: this.$t('system.text_238') },
- ],
- },
- ],
- password: [
- 'password',
- {
- rules: [
- { required: true, message: this.$t('system.text_239') },
- ],
- },
- ],
- sender_address: [
- 'sender_address',
- {
- validateFirst: true,
- rules: [
- { required: true, message: this.$t('common.field_required_placeholder', [this.$t('iam.sender_address')]) },
- { validator: this.$validate('email') },
- ],
- },
- ],
- },
- contactData: null,
- }
- },
- destroyed () {
- this.manager = null
- },
- created () {
- this.manager = new this.$Manager('notifyconfigs', 'v1')
- },
- methods: {
- async handleSubmit () {
- const values = await this.form.fc.validateFields()
- try {
- this.submiting = true
- await this.manager.create({
- data: {
- content: values,
- type: 'email',
- },
- })
- this.$message.success(this.$t('system.text_124', [this.$t('system.text_302')]))
- } catch (error) {
- this.$message.error(this.$t('common_622', [this.$t('system.text_302')]))
- throw error
- } finally {
- this.submiting = false
- }
- },
- async testPost () {
- try {
- const values = await this.form.fc.validateFields()
- await new this.$Manager('notifyconfigs', 'v1').performClassAction({
- action: 'validate',
- data: {
- content: values,
- type: 'email',
- },
- })
- } catch (error) {
- this.$message.error(this.$t('common_623', [this.$t('common_269')]))
- throw error
- }
- },
- },
- }
- </script>
|