singleActions.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { mapGetters } from 'vuex'
  2. import { getDomainChangeOwnerAction, getSetPublicAction } from '@/utils/common/tableActions'
  3. import i18n from '@/locales'
  4. export default {
  5. computed: {
  6. ...mapGetters(['isAdminMode', 'isDomainMode', 'isProjectMode', 'userInfo']),
  7. },
  8. created () {
  9. this.singleActions = [
  10. {
  11. label: i18n.t('network.text_606'),
  12. permission: 'wires_update',
  13. action: obj => {
  14. this.createDialog('WireUpdateDialog', {
  15. data: [obj],
  16. columns: this.columns,
  17. onManager: this.onManager,
  18. refresh: this.refresh,
  19. })
  20. },
  21. meta: obj => {
  22. return {
  23. validate: this.isPower(obj),
  24. }
  25. },
  26. },
  27. {
  28. label: i18n.t('network.text_129'),
  29. actions: obj => {
  30. return [
  31. getDomainChangeOwnerAction(this, {
  32. name: this.$t('dictionary.wire'),
  33. resource: 'wires',
  34. }, {
  35. permission: 'wires_perform_change_owner',
  36. }),
  37. getSetPublicAction(this, {
  38. name: this.$t('dictionary.wire'),
  39. scope: 'domain',
  40. resource: 'wires',
  41. }, {
  42. permission: 'wires_perform_public',
  43. meta: () => {
  44. return {
  45. validate: this.isPower(obj),
  46. }
  47. },
  48. }),
  49. {
  50. label: i18n.t('network.text_131'),
  51. permission: 'wires_delete',
  52. action: () => {
  53. this.createDialog('DeleteResDialog', {
  54. vm: this,
  55. data: [obj],
  56. columns: this.columns,
  57. title: i18n.t('network.text_131'),
  58. name: this.$t('dictionary.hostwire'),
  59. onManager: this.onManager,
  60. })
  61. },
  62. meta: () => {
  63. if (!this.isPower(obj)) {
  64. return {
  65. validate: false,
  66. tooltip: i18n.t('network.text_627'),
  67. }
  68. }
  69. if (!this.$getDeleteResult(obj).validate) {
  70. return {
  71. validate: false,
  72. tooltip: this.$getDeleteResult(obj).tooltip,
  73. }
  74. }
  75. return {
  76. validate: true,
  77. tooltip: '',
  78. }
  79. },
  80. },
  81. ]
  82. },
  83. },
  84. ]
  85. },
  86. methods: {
  87. isPower (obj) {
  88. if (this.isAdminMode) return true
  89. if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
  90. return obj.tenant_id === this.userInfo.projectId
  91. },
  92. },
  93. }