singleActions.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { mapGetters } from 'vuex'
  2. import i18n from '@/locales'
  3. import { getSetPublicAction } from '@/utils/common/tableActions'
  4. export default {
  5. created () {
  6. this.singleActions = [
  7. {
  8. label: i18n.t('network.text_130'),
  9. permission: 'loadbalanceracls_update',
  10. action: (obj) => {
  11. this.createDialog('LbaclsCreateDialog', {
  12. title: i18n.t('network.text_130'),
  13. data: [obj],
  14. columns: this.columns,
  15. onManager: this.onManager,
  16. type: 'update',
  17. })
  18. },
  19. },
  20. {
  21. label: i18n.t('network.text_129'),
  22. actions: obj => {
  23. return [
  24. {
  25. label: i18n.t('network.text_225', [i18n.t('dictionary.project')]),
  26. permission: 'loadbalanceracls_perform_change_owner',
  27. action: () => {
  28. this.createDialog('ChangeOwenrDialog', {
  29. data: [obj],
  30. columns: this.columns,
  31. name: this.$t('network.text_142'),
  32. onManager: this.onManager,
  33. resource: 'loadbalanceracls',
  34. })
  35. },
  36. meta: () => {
  37. const ret = {
  38. validate: false,
  39. tooltip: '',
  40. }
  41. if (this.isProjectMode) {
  42. ret.tooltip = i18n.t('monitor.text_9', [this.$t('dictionary.domain')])
  43. return ret
  44. }
  45. if (obj.is_public) {
  46. ret.validate = false
  47. ret.tooltip = this.$t('common_280')
  48. return ret
  49. }
  50. return {
  51. validate: this.isPower(obj),
  52. }
  53. },
  54. },
  55. getSetPublicAction(this, {
  56. name: this.$t('network.text_142'),
  57. scope: 'project',
  58. resource: 'loadbalanceracls',
  59. }, {
  60. permission: 'loadbalanceracls_perform_public',
  61. }),
  62. {
  63. label: i18n.t('network.text_131'),
  64. permission: 'loadbalanceracls_delete',
  65. action: () => {
  66. this.createDialog('DeleteResDialog', {
  67. vm: this,
  68. title: i18n.t('network.text_131'),
  69. name: this.$t('network.text_142'),
  70. alert: this.$t('network.text_767'),
  71. data: [obj],
  72. columns: this.columns,
  73. onManager: this.onManager,
  74. })
  75. },
  76. meta: () => this.$getDeleteResult(obj),
  77. },
  78. ]
  79. },
  80. },
  81. ]
  82. },
  83. computed: {
  84. ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo', 'isProjectMode']),
  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. }