Workwx.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <a-form
  3. :form="form.fc"
  4. v-bind="formItemLayout"
  5. hideRequiredMark>
  6. <a-form-item :label="$t('system.wecom.corp_id')">
  7. <template v-slot:extra>
  8. <div>{{ $t('system.for_example') }}: ww2c41e47d2d3b13cb
  9. ,{{ $t('iam.help') }} <help-link :href="docUrl">{{ $t('common_386') }}</help-link>
  10. </div>
  11. <div class="mb-0">{{ $t('system.wecom.where_to_find_corp_id') }}</div>
  12. </template>
  13. <a-input v-decorator="decorators.corp_id" />
  14. </a-form-item>
  15. <a-form-item label="AgentId">
  16. <template v-slot:extra>
  17. <div>{{ $t('system.for_example') }}: 1000002</div>
  18. <div class="mb-0">{{ $t('system.wecom.where_to_find_agent_id') }}</div>
  19. </template>
  20. <a-input v-decorator="decorators.agent_id" />
  21. </a-form-item>
  22. <a-form-item label="Secret">
  23. <template v-slot:extra>
  24. <div>{{ $t('system.for_example') }}: ZgyVyfr2Mvd0zzy6bE5prfKX25k4Wrgn4-1DSVDYXVo</div>
  25. <div class="mb-0">{{ $t('system.wecom.where_to_find_secret') }}</div>
  26. </template>
  27. <a-input-password v-decorator="decorators.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: 'EnterpriseWeChat',
  40. components: {
  41. TestButton,
  42. },
  43. props: {
  44. formItemLayout: {
  45. required: true,
  46. type: Object,
  47. },
  48. offsetWrapperCol: {
  49. required: true,
  50. type: Object,
  51. },
  52. loading: Boolean,
  53. docUrl: String,
  54. },
  55. data () {
  56. return {
  57. submiting: false,
  58. testLoding: false,
  59. form: {
  60. fc: this.$form.createForm(this),
  61. },
  62. decorators: {
  63. corp_id: [
  64. 'corp_id',
  65. {
  66. rules: [
  67. { required: true, message: this.$t('system.corp_id_require_msg') },
  68. ],
  69. },
  70. ],
  71. agent_id: [
  72. 'agent_id',
  73. {
  74. rules: [
  75. { required: true, message: this.$t('system.agent_id_require_msg') },
  76. ],
  77. },
  78. ],
  79. secret: [
  80. 'secret',
  81. {
  82. rules: [
  83. { required: true, message: this.$t('system.secret_require_msg') },
  84. ],
  85. },
  86. ],
  87. },
  88. contactData: null,
  89. href: DOCS_MAP.mailConfig('workwx'),
  90. }
  91. },
  92. destroyed () {
  93. this.manager = null
  94. },
  95. created () {
  96. this.manager = new this.$Manager('notifyconfigs', 'v1')
  97. },
  98. methods: {
  99. async handleSubmit () {
  100. const values = await this.form.fc.validateFields()
  101. try {
  102. this.submiting = true
  103. await this.manager.create({
  104. data: {
  105. content: values,
  106. type: 'workwx',
  107. },
  108. })
  109. this.$message.success(this.$t('system.text_124', [this.$t('system.wecom.1')]))
  110. } catch (error) {
  111. this.$message.error(this.$t('common_622', [this.$t('system.wecom.1')]))
  112. throw error
  113. } finally {
  114. this.submiting = false
  115. }
  116. },
  117. async testPost () {
  118. try {
  119. const values = await this.form.fc.validateFields()
  120. await new this.$Manager('notifyconfigs', 'v1').performClassAction({
  121. action: 'validate',
  122. data: {
  123. content: values,
  124. type: 'workwx',
  125. },
  126. })
  127. } catch (error) {
  128. this.$message.error(this.$t('common_623', [this.$t('common_269')]))
  129. throw error
  130. }
  131. },
  132. },
  133. }
  134. </script>