Detail.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <detail
  3. :onManager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo" />
  7. </template>
  8. <script>
  9. import {
  10. getEnabledTableColumn,
  11. } from '@/utils/common/tableColumn'
  12. import {
  13. getUserTagColumn,
  14. } from '@/utils/common/detailColumn'
  15. export default {
  16. name: 'UserDetail',
  17. props: {
  18. data: {
  19. type: Object,
  20. required: true,
  21. },
  22. onManager: {
  23. type: Function,
  24. required: true,
  25. },
  26. },
  27. data () {
  28. const driverOptions = Object.keys(this.$t('idpDrivers')).reduce((prev, current) => {
  29. prev[current.toLowerCase()] = current
  30. return prev
  31. }, {})
  32. return {
  33. configData: {},
  34. baseInfo: [
  35. {
  36. field: 'displayname',
  37. title: this.$t('scope.text_245'),
  38. slots: {
  39. default: ({ row }) => {
  40. return [<list-body-cell-wrap copy row={ row } field='displayname' title={ row.displayname || '-' } />]
  41. },
  42. },
  43. },
  44. getEnabledTableColumn(),
  45. getEnabledTableColumn({
  46. field: 'allow_web_console',
  47. title: this.$t('system.text_512'),
  48. }),
  49. getEnabledTableColumn({
  50. field: 'enable_mfa',
  51. title: 'MFA',
  52. }),
  53. getUserTagColumn({
  54. onManager: this.onManager,
  55. resource: 'users',
  56. needExt: true,
  57. columns: () => this.columns,
  58. }),
  59. {
  60. field: 'group_count',
  61. title: this.$t('system.text_514'),
  62. slots: {
  63. default: ({ row }) => {
  64. if (!row.group_count) return '0'
  65. return [<a onClick={ () => this.$emit('tab-change', 'Group') }>{row.group_count}</a>]
  66. },
  67. },
  68. },
  69. {
  70. field: 'project_count',
  71. title: this.$t('system.text_560'),
  72. slots: {
  73. default: ({ row }) => {
  74. if (!row.project_count) return '0'
  75. return [<a onClick={ () => this.$emit('tab-change', 'projects') }>{row.project_count}</a>]
  76. },
  77. },
  78. },
  79. {
  80. field: 'idps',
  81. title: this.$t('system.text_165'),
  82. slots: {
  83. default: ({ row }) => {
  84. if (row.idps && row.idps.length) {
  85. return row.idps.map(item => {
  86. return item.idp
  87. }).join('、')
  88. }
  89. return '-'
  90. },
  91. },
  92. },
  93. ],
  94. extraInfo: [
  95. {
  96. title: this.$t('system.text_515'),
  97. items: [
  98. {
  99. field: 'last_login_ip',
  100. title: this.$t('system.text_516'),
  101. },
  102. {
  103. field: 'last_login_source',
  104. title: this.$t('system.text_517'),
  105. },
  106. {
  107. field: 'last_active_at',
  108. title: this.$t('system.text_518'),
  109. slots: {
  110. default: ({ row }) => {
  111. return row.last_active_at ? this.$moment(row.last_active_at).format() : '-'
  112. },
  113. },
  114. },
  115. {
  116. field: 'password_expires_at',
  117. title: this.$t('system.text_519'),
  118. slots: {
  119. default: ({ row }) => {
  120. const expiresAt = row.password_expires_at
  121. if (expiresAt) {
  122. const days = this.$moment(expiresAt).diff(new Date(), 'days')
  123. const hours = this.$moment(expiresAt).diff(new Date(), 'hours', true)
  124. if (days > 7) {
  125. return this.$moment(expiresAt).format()
  126. }
  127. if (days <= 7 && days >= 0 && hours > 0) {
  128. if (days === 0) {
  129. return <div style="color:red">{ this.$t('system.text_520', [hours >= 1 ? parseInt(hours) : 1]) }</div>
  130. }
  131. return <div style="color:orange">{ this.$t('system.text_557', [days]) }</div>
  132. }
  133. return <div style="color:red">{ this.$t('system.text_558', [days]) }</div>
  134. }
  135. return '-'
  136. },
  137. },
  138. },
  139. ],
  140. },
  141. {
  142. field: 'idps',
  143. title: this.$t('common_460', [this.$t('dictionary.identity_provider')]),
  144. slots: {
  145. default: ({ row }) => {
  146. return [
  147. <vxe-grid
  148. data={row.idps}
  149. columns={[
  150. { title: this.$t('common_704'), field: 'idp' },
  151. {
  152. title: this.$t('system.text_204'),
  153. field: 'idp_driver',
  154. formatter: ({ cellValue }) => driverOptions[cellValue] || cellValue,
  155. },
  156. {
  157. title: this.$t('common_550'),
  158. field: 'template',
  159. formatter: ({ row }) => this.$t('idpTmplTitles')[row.template] ? this.$t(`idpTmplTitles.${row.template}`) : row.template || '-',
  160. },
  161. { title: this.$t('common_705'), field: 'idp_entity_id' },
  162. ]} />,
  163. ]
  164. },
  165. },
  166. hidden: () => !this.data.idps || this.data.idps.length === 0,
  167. },
  168. ],
  169. }
  170. },
  171. }
  172. </script>