Dingtalk.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <a-form
  3. :form="form.fc"
  4. v-bind="formItemLayout"
  5. hideRequiredMark>
  6. <a-form-item label="AgentId">
  7. <template v-slot:extra>
  8. <div>{{$t('system.text_257')}}
  9. ,{{ $t('iam.help') }} <help-link :href="docUrl">{{ $t('common_386') }}</help-link>
  10. </div>
  11. <div class="mb-0">{{$t('system.text_568')}}</div>
  12. </template>
  13. <a-input v-decorator="decorators.agent_id" />
  14. </a-form-item>
  15. <a-form-item label="AppKey">
  16. <template v-slot:extra>
  17. <div>{{$t('system.text_259')}}</div>
  18. <div class="mb-0">{{$t('system.text_569')}}</div>
  19. </template>
  20. <a-input v-decorator="decorators.app_key" />
  21. </a-form-item>
  22. <a-form-item label="AppSecret">
  23. <template v-slot:extra>
  24. <div>{{$t('system.text_260')}}</div>
  25. <div class="mb-0">{{$t('system.text_569')}}</div>
  26. </template>
  27. <a-input-password v-decorator="decorators.app_secret" />
  28. </a-form-item>
  29. <a-form-item v-if="false">
  30. <a-button type="primary" @click="handleSubmit" :loading="submiting">{{ $t('common.ok') }}</a-button>
  31. <test-button v-if="false" class="ml-3" :post="testPost" />
  32. </a-form-item>
  33. </a-form>
  34. </template>
  35. <script>
  36. import TestButton from '@/sections/TestButton'
  37. import { DOCS_MAP } from '@/constants/docs'
  38. export default {
  39. name: 'DingtalkConfig',
  40. components: {
  41. TestButton,
  42. },
  43. props: {
  44. formItemLayout: {
  45. required: true,
  46. type: Object,
  47. },
  48. loading: Boolean,
  49. docUrl: String,
  50. },
  51. data () {
  52. return {
  53. submiting: false,
  54. form: {
  55. fc: this.$form.createForm(this),
  56. },
  57. decorators: {
  58. agent_id: [
  59. 'agent_id',
  60. {
  61. rules: [
  62. { required: true, message: this.$t('system.text_261') },
  63. ],
  64. },
  65. ],
  66. app_key: [
  67. 'app_key',
  68. {
  69. rules: [
  70. { required: true, message: this.$t('system.text_262') },
  71. ],
  72. },
  73. ],
  74. app_secret: [
  75. 'app_secret',
  76. {
  77. rules: [
  78. { required: true, message: this.$t('system.text_263') },
  79. ],
  80. },
  81. ],
  82. },
  83. contactData: null,
  84. href: DOCS_MAP.mailConfig('dingtalk'),
  85. }
  86. },
  87. destroyed () {
  88. this.manager = null
  89. },
  90. created () {
  91. this.manager = new this.$Manager('notifyconfigs', 'v1')
  92. },
  93. methods: {
  94. async handleSubmit () {
  95. this.submiting = true
  96. try {
  97. const values = await this.form.fc.validateFields()
  98. await this.manager.create({
  99. data: {
  100. content: values,
  101. type: 'dingtalk',
  102. },
  103. })
  104. this.$message.success(this.$t('system.text_264'))
  105. } catch (error) {
  106. this.$message.error(this.$t('common_622', [this.$t('system.text_136')]))
  107. throw error
  108. } finally {
  109. this.submiting = false
  110. }
  111. },
  112. async testPost () {
  113. try {
  114. const values = await this.form.fc.validateFields()
  115. await new this.$Manager('notifyconfigs', 'v1').performClassAction({
  116. action: 'validate',
  117. data: {
  118. content: values,
  119. type: 'dingtalk',
  120. },
  121. })
  122. } catch (error) {
  123. this.$message.error(this.$t('common_623', [this.$t('common_269')]))
  124. throw error
  125. }
  126. },
  127. },
  128. }
  129. </script>