columns.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import i18n from '@/locales'
  2. import { getNote } from './index'
  3. export const getMobileTableColumn = () => {
  4. return {
  5. title: i18n.t('system.text_131'),
  6. field: 'international_mobile',
  7. minWidth: 120,
  8. formatter: ({ row }) => {
  9. if (row.international_mobile) {
  10. if (row.international_mobile.area_code && row.international_mobile.mobile) {
  11. return `+${row.international_mobile.area_code} ${row.international_mobile.mobile}`
  12. } else {
  13. return row.international_mobile.mobile || '-'
  14. }
  15. }
  16. return '-'
  17. },
  18. }
  19. }
  20. export const getEmailTableColumn = () => {
  21. return {
  22. title: i18n.t('system.text_146'),
  23. field: 'email',
  24. minWidth: 120,
  25. formatter: ({ row }) => {
  26. return row.email
  27. },
  28. }
  29. }
  30. export const getVerifiedContactTypesTableColumn = ({ field = 'verified_contact_types', title = i18n.t('common_599'), vm } = {}) => {
  31. return {
  32. title: i18n.t('common_599'),
  33. field: 'verified_contact_types',
  34. minWidth: 120,
  35. slots: {
  36. default: ({ row }, h) => {
  37. const color = {
  38. true: '#52c41a',
  39. false: 'rgba(0, 0, 0, 0.25)',
  40. }
  41. const enabled_contact_types = row.enabled_contact_types || []
  42. const renderComponents = []
  43. enabled_contact_types.forEach((type) => {
  44. const item = row.verified_infos.find(obj => obj.contact_type === type)
  45. const enabled = item.verified
  46. let title = ''
  47. let note = getNote(item.note)
  48. switch (item.contact_type) {
  49. case 'webconsole':
  50. note = enabled ? note : i18n.t('system.text_576')
  51. title = enabled ? i18n.t('system.webconsole', [i18n.t(`status.verified.${enabled}`)]) : note
  52. renderComponents.push(<icon type='webconsole' onClick={() => vm.verifyConcact(item, row)} style={{ color: color[enabled] }} title={title} />)
  53. break
  54. case 'email':
  55. note = enabled ? note : i18n.t('system.text_576')
  56. title = enabled ? i18n.t('system.text_148', [i18n.t(`status.verified.${enabled}`)]) : note
  57. renderComponents.push(<icon class='ml-2' type='email' onClick={() => vm.verifyConcact(item, row)} style={{ color: color[enabled] }} title={title} />)
  58. break
  59. case 'mobile':
  60. note = enabled ? note : i18n.t('system.text_576')
  61. title = enabled ? i18n.t('system.text_149', [i18n.t(`status.verified.${enabled}`)]) : note
  62. renderComponents.push(<icon class='ml-2' type='mobile' onClick={() => vm.verifyConcact(item, row)} style={{ color: color[enabled] }} title={title} />)
  63. break
  64. case 'dingtalk':
  65. title = enabled ? i18n.t('system.text_150', [i18n.t(`status.verified.${enabled}`)]) : note
  66. renderComponents.push(<icon class='ml-2' type='dingtalk' onClick={() => vm.verifyConcact(item, row)} style={{ color: color[enabled] }} title={title} />)
  67. break
  68. case 'feishu':
  69. title = enabled ? i18n.t('system.text_151', [i18n.t(`status.verified.${enabled}`)]) : note
  70. renderComponents.push(<icon class='ml-2' type='feishu' onClick={() => vm.verifyConcact(item, row)} style={{ color: color[enabled] }} title={title} />)
  71. break
  72. case 'workwx':
  73. title = enabled ? i18n.t('system.wecom', [i18n.t(`status.verified.${enabled}`)]) : note
  74. renderComponents.push(<icon class='ml-2' type='workwx' onClick={() => vm.verifyConcact(item, row)} style={{ color: color[enabled] }} title={title} />)
  75. break
  76. default:
  77. break
  78. }
  79. })
  80. return renderComponents
  81. },
  82. },
  83. }
  84. }