columns.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {
  2. getNameDescriptionTableColumn,
  3. getStatusTableColumn,
  4. getTimeTableColumn,
  5. getPublicScopeTableColumn,
  6. getProjectDomainTableColumn,
  7. getRegionTableColumn,
  8. getBrandTableColumn,
  9. getAccountTableColumn,
  10. } from '@/utils/common/tableColumn'
  11. import i18n from '@/locales'
  12. export const getRwAccessTypeColumn = ({
  13. field = 'rw_access_type',
  14. title = i18n.t('storage.access.group.rule.rw.access_type'),
  15. } = {}) => {
  16. return {
  17. field,
  18. title,
  19. formatter: ({ row }) => {
  20. switch (row.rw_access_type) {
  21. case 'RW':
  22. return i18n.t('storage.access.group.rule.rw.access_type.rw')
  23. case 'R':
  24. return i18n.t('storage.access.group.rule.rw.access_type.r')
  25. default:
  26. return row.rw_access_type
  27. }
  28. },
  29. }
  30. }
  31. export const getUserAccessTypeColumn = ({
  32. field = 'user_access_type',
  33. title = i18n.t('storage.access.group.rule.user.access_type'),
  34. } = {}) => {
  35. return {
  36. field,
  37. title,
  38. formatter: ({ row }) => {
  39. switch (row.user_access_type) {
  40. case 'no_root_squash':
  41. return i18n.t('storage.access.group.rule.user.access_type.no_root_squash')
  42. case 'root_squash':
  43. return i18n.t('storage.access.group.rule.user.access_type.root_squash')
  44. case 'all_squash':
  45. return i18n.t('storage.access.group.rule.user.access_type.all_squash')
  46. default:
  47. return row.user_access_type
  48. }
  49. },
  50. }
  51. }
  52. export default {
  53. created () {
  54. this.columns = [
  55. getNameDescriptionTableColumn({
  56. onManager: this.onManager,
  57. hideField: true,
  58. slotCallback: row => {
  59. return (
  60. <side-page-trigger onTrigger={ () => this.handleOpenSidepage(row) }>{ row.name }</side-page-trigger>
  61. )
  62. },
  63. }),
  64. {
  65. field: 'mount_target_count',
  66. title: this.$t('storage.mount.target.count'),
  67. formatter: ({ cellValue }) => {
  68. if (cellValue) {
  69. return cellValue
  70. }
  71. return 0
  72. },
  73. },
  74. getStatusTableColumn({ statusModule: 'accessGroup', vm: this }),
  75. getBrandTableColumn(),
  76. getAccountTableColumn(),
  77. getRegionTableColumn(),
  78. getPublicScopeTableColumn({ vm: this, resource: 'access_groups' }),
  79. getProjectDomainTableColumn(),
  80. getTimeTableColumn(),
  81. ]
  82. },
  83. }