Detail.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <detail
  3. :onManager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extraInfo="extraInfo"
  7. :hiddenKeys="['project_domain', 'tenant', 'status']"
  8. :show-desc="false"
  9. :is-edit-name="false" />
  10. </template>
  11. <script>
  12. import {
  13. getConfigTypeTableColumn,
  14. getAttirubuteTableColumn,
  15. } from '../utils/columns'
  16. import {
  17. getEnabledTableColumn,
  18. // getSwitchTableColumn
  19. } from '@/utils/common/tableColumn'
  20. export default {
  21. name: 'NotifyConfigDetail',
  22. props: {
  23. data: {
  24. type: Object,
  25. required: true,
  26. },
  27. onManager: {
  28. type: Function,
  29. required: true,
  30. },
  31. },
  32. data () {
  33. return {
  34. baseInfo: [
  35. getConfigTypeTableColumn(),
  36. getAttirubuteTableColumn(),
  37. ],
  38. configInfo: {
  39. email: [
  40. {
  41. title: this.$t('system.text_255'),
  42. items: [
  43. {
  44. field: 'hostname',
  45. title: this.$t('system.text_269'),
  46. formatter: ({ row }) => {
  47. return row.content?.hostname || '-'
  48. },
  49. },
  50. {
  51. field: 'hostport',
  52. title: this.$t('system.text_270'),
  53. formatter: ({ row }) => {
  54. return row.content?.hostport || '-'
  55. },
  56. },
  57. {
  58. field: 'username',
  59. title: this.$t('system.text_126'),
  60. formatter: ({ row }) => {
  61. return row.content?.username || '-'
  62. },
  63. },
  64. getEnabledTableColumn({ title: 'SSL', field: 'content.ssl_global' }),
  65. {
  66. field: 'sender_address',
  67. title: this.$t('iam.sender_address'),
  68. formatter: ({ row }) => {
  69. return row.content?.sender_address || '-'
  70. },
  71. },
  72. // getSwitchTableColumn({
  73. // field: 'content.ssl_global',
  74. // title: 'SSL',
  75. // change: val => {
  76. // this.onManager('update', {
  77. // id: this.data.id,
  78. // managerArgs: {
  79. // data: { content: { ...this.data.content, ssl_global: val } },
  80. // },
  81. // })
  82. // },
  83. // }),
  84. ],
  85. },
  86. ],
  87. mobile: [
  88. {
  89. title: this.$t('system.text_255'),
  90. items: [
  91. {
  92. field: 'sms_driver',
  93. title: this.$t('notify.configs.sms_driver'),
  94. formatter: ({ row }) => {
  95. if (row.content && row.content.sms_driver) {
  96. if (row.content.sms_driver === 'smsaliyun') {
  97. return this.$t('providers.aliyun')
  98. } else if (row.content.sms_driver === 'smshuawei') {
  99. return this.$t('providers.huawei')
  100. }
  101. }
  102. return '-'
  103. },
  104. },
  105. {
  106. field: 'access_key_id',
  107. title: 'Access Key ID',
  108. formatter: ({ row }) => {
  109. return row.content?.access_key_id || '-'
  110. },
  111. },
  112. {
  113. field: 'signature',
  114. title: this.$t('system.text_288'),
  115. formatter: ({ row }) => {
  116. return row.content?.signature || '-'
  117. },
  118. },
  119. ],
  120. },
  121. {
  122. title: this.$t('system.mobile_cn_tpl'),
  123. items: [
  124. {
  125. field: 'verifiyCode',
  126. title: this.$t('system.text_295'),
  127. formatter: ({ row }) => {
  128. return this.smsTplInfo?.verifiyCode || '-'
  129. },
  130. },
  131. {
  132. field: 'alertsCode',
  133. title: this.$t('system.alert_tpl'),
  134. formatter: ({ row }) => {
  135. return this.smsTplInfo?.alertsCode || '-'
  136. },
  137. },
  138. {
  139. field: 'errorCode',
  140. title: this.$t('system.error_login_tpl'),
  141. formatter: ({ row }) => {
  142. return this.smsTplInfo?.errorCode || '-'
  143. },
  144. },
  145. ],
  146. },
  147. {
  148. title: this.$t('system.mobile_en_tpl'),
  149. items: [
  150. {
  151. field: 'verifiyCodeUn',
  152. title: this.$t('system.text_295'),
  153. formatter: ({ row }) => {
  154. return this.smsTplInfo?.verifiyCodeUn || '-'
  155. },
  156. },
  157. {
  158. field: 'alertsCode',
  159. title: this.$t('system.alert_tpl'),
  160. formatter: ({ row }) => {
  161. return this.smsTplInfo?.alertsCodeUn || '-'
  162. },
  163. },
  164. {
  165. field: 'errorCode',
  166. title: this.$t('system.error_login_tpl'),
  167. formatter: ({ row }) => {
  168. return this.smsTplInfo?.errorCodeUn || '-'
  169. },
  170. },
  171. ],
  172. },
  173. ],
  174. feishu: [
  175. {
  176. title: this.$t('system.text_255'),
  177. items: [
  178. {
  179. field: 'app_id',
  180. title: 'AppID',
  181. formatter: ({ row }) => {
  182. return row.content?.app_id || '-'
  183. },
  184. },
  185. ],
  186. },
  187. ],
  188. dingtalk: [
  189. {
  190. title: this.$t('system.text_255'),
  191. items: [
  192. {
  193. field: 'agent_id',
  194. title: 'AgentId',
  195. formatter: ({ row }) => {
  196. return row.content?.agent_id || '-'
  197. },
  198. },
  199. {
  200. field: 'app_key',
  201. title: 'AppKey',
  202. formatter: ({ row }) => {
  203. return row.content?.app_key || '-'
  204. },
  205. },
  206. ],
  207. },
  208. ],
  209. workwx: [
  210. {
  211. title: this.$t('system.text_255'),
  212. items: [
  213. {
  214. field: 'corp_id',
  215. title: this.$t('system.wecom.corp_id'),
  216. formatter: ({ row }) => {
  217. return row.content?.corp_id || '-'
  218. },
  219. },
  220. {
  221. field: 'agent_id',
  222. title: 'AgentId',
  223. formatter: ({ row }) => {
  224. return row.content?.agent_id || '-'
  225. },
  226. },
  227. ],
  228. },
  229. ],
  230. },
  231. smsTplInfo: {},
  232. }
  233. },
  234. computed: {
  235. extraInfo () {
  236. return this.configInfo[this.data.type] || []
  237. },
  238. },
  239. created () {
  240. this.notifytemplatesManager = new this.$Manager('notifytemplates', 'v1')
  241. this.fetchNotifyTpl()
  242. },
  243. destroyed () {
  244. this.notifytemplatesManager = null
  245. },
  246. methods: {
  247. fetchNotifyTpl () {
  248. const { type } = this.data
  249. if (type !== 'mobile') return
  250. this.notifytemplatesManager.list({ params: { contact_type: type } })
  251. .then(res => {
  252. const { data: { data } } = res
  253. data.forEach(v => {
  254. if (v.lang === 'cn') {
  255. switch (v.topic) {
  256. case 'VERIFY':
  257. this.$set(this.smsTplInfo, 'verifiyCode', v.content)
  258. break
  259. case 'MONITOR':
  260. this.$set(this.smsTplInfo, 'alertsCode', v.content)
  261. break
  262. case 'USER_LOGIN_EXCEPTION':
  263. this.$set(this.smsTplInfo, 'errorCode', v.content)
  264. break
  265. }
  266. }
  267. if (v.lang === 'en') {
  268. switch (v.topic) {
  269. case 'VERIFY':
  270. this.$set(this.smsTplInfo, 'verifiyCodeUn', v.content)
  271. break
  272. case 'MONITOR':
  273. this.$set(this.smsTplInfo, 'alertsCodeUn', v.content)
  274. break
  275. case 'USER_LOGIN_EXCEPTION':
  276. this.$set(this.smsTplInfo, 'errorCodeUn', v.content)
  277. break
  278. }
  279. }
  280. })
  281. })
  282. .catch(err => {
  283. console.error(err)
  284. })
  285. },
  286. },
  287. }
  288. </script>