columns.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import i18n from '@/locales'
  2. import { getCopyWithContentTableColumn } from '@/utils/common/tableColumn'
  3. export const getImageTableColumn = () => {
  4. return getCopyWithContentTableColumn({
  5. title: i18n.t('compute.pod-image'),
  6. field: 'image',
  7. hideField: true,
  8. message: row => row.spec?.image,
  9. slotCallback: (row) => {
  10. return row.spec?.image || '-'
  11. },
  12. })
  13. }
  14. export const getEnvTableColumn = () => {
  15. return {
  16. field: 'env',
  17. title: i18n.t('compute.repo.env_variables'),
  18. minWidth: 200,
  19. slots: {
  20. default: ({ row }, h) => {
  21. if (!row.spec || !row.spec.envs || !row.spec.envs.length) return '-'
  22. return [<list-body-cell-popover text={i18n.t('cloudenv.text_245', [(row.spec.envs && row.spec.envs.length) || 0])} min-width="500px">
  23. <vxe-grid
  24. showOverflow={false}
  25. row-config={{ isHover: true }}
  26. column-config={{ resizable: false }}
  27. data={row.spec.envs}
  28. columns={[
  29. {
  30. field: 'key',
  31. title: i18n.t('common.name'),
  32. slots: {
  33. default: ({ row }, h) => {
  34. return row.key || '-'
  35. },
  36. },
  37. },
  38. {
  39. field: 'value',
  40. title: i18n.t('compute.repo.value'),
  41. slots: {
  42. default: ({ row }, h) => {
  43. return row.value || '-'
  44. },
  45. },
  46. },
  47. ]} />
  48. </list-body-cell-popover>]
  49. },
  50. },
  51. formatter: ({ row }) => {
  52. if (!row.spec || !row.spec.envs || !row.spec.envs.length) return '-'
  53. return row.spec.envs.map(v => {
  54. return `${v.key}: ${v.value || ''}`
  55. }).join(', ')
  56. },
  57. }
  58. }
  59. export const getCommandTableColumn = () => {
  60. return getCopyWithContentTableColumn({
  61. title: i18n.t('compute.repo.command'),
  62. field: 'command',
  63. hideField: true,
  64. message: row => {
  65. const command = row.spec?.command || []
  66. return command.join(' ') || ''
  67. },
  68. slotCallback: (row) => {
  69. const command = row.spec?.command || []
  70. return command.join(' ') || '-'
  71. },
  72. })
  73. }
  74. export const getArgsTableColumn = () => {
  75. return getCopyWithContentTableColumn({
  76. title: i18n.t('compute.repo.command.params'),
  77. field: 'args',
  78. hideField: true,
  79. message: row => {
  80. const args = row.spec?.args
  81. return args?.length ? `[${args}]` : ''
  82. },
  83. slotCallback: (row) => {
  84. const args = row.spec?.args
  85. return args?.length ? `[${args}]` : '-'
  86. },
  87. })
  88. }