Feishu.vue 3.0 KB

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