singleActions.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { mapGetters } from 'vuex'
  2. import { getEnabledSwitchActions, getSetPublicAction } from '@/utils/common/tableActions'
  3. import i18n from '@/locales'
  4. export default {
  5. computed: {
  6. ...mapGetters(['isAdminMode', 'scope', 'isDomainMode', 'userInfo', 'l3PermissionEnable']),
  7. },
  8. created () {
  9. this.singleActions = [
  10. {
  11. label: i18n.t('cloudenv.text_590'),
  12. action: (row) => {
  13. this.openSidePageRuleList(row)
  14. },
  15. meta: (row) => {
  16. const ret = {
  17. validate: !!row.can_update,
  18. }
  19. if (!(this.isAdminMode || row.domain_id === this.userInfo.projectDomainId)) {
  20. ret.validate = false
  21. ret.tooltip = this.$t('cloudenv.text_597')
  22. }
  23. return ret
  24. },
  25. },
  26. {
  27. label: i18n.t('cloudenv.text_311'),
  28. actions: obj => {
  29. return [
  30. // 启用禁用
  31. ...getEnabledSwitchActions(this, obj, ['projectmappings_perform_enable', 'projectmappings_perform_disable'], {
  32. resourceName: this.$t('cloudenv.text_580'),
  33. metas: [
  34. () => {
  35. const ret = {
  36. validate: !obj.enabled,
  37. }
  38. return ret
  39. },
  40. () => {
  41. const ret = {
  42. validate: obj.enabled,
  43. }
  44. return ret
  45. },
  46. ],
  47. }),
  48. getSetPublicAction(this, {
  49. name: this.$t('cloudenv.text_580'),
  50. scope: 'domain',
  51. resource: 'project_mappings',
  52. }, {
  53. permission: 'project_mappings_perform_public',
  54. }),
  55. // 删除
  56. {
  57. label: i18n.t('cloudenv.text_108'),
  58. permission: 'projectmappings_delete',
  59. action: () => {
  60. this.createDialog('DeleteResDialog', {
  61. data: [obj],
  62. columns: this.columns,
  63. title: this.$t('resourceowner_delete'),
  64. name: this.$t('cloudenv.text_580'),
  65. onManager: this.onManager,
  66. })
  67. },
  68. meta: (row) => {
  69. const ret = {
  70. validate: true,
  71. }
  72. if (!row.can_delete) {
  73. ret.validate = false
  74. ret.tooltip = i18n.t('cloudenv.text_596')
  75. }
  76. return ret
  77. },
  78. },
  79. ]
  80. },
  81. meta: (row) => {
  82. const ownerDomain = this.isAdminMode || row.domain_id === this.userInfo.projectDomainId
  83. const ret = {
  84. validate: true,
  85. }
  86. if (!ownerDomain) {
  87. ret.validate = false
  88. ret.tooltip = this.$t('cloudenv.text_597')
  89. }
  90. return ret
  91. },
  92. },
  93. ]
  94. },
  95. }