singleActions.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_225', [i18n.t('dictionary.project')]),
  9. permission: 'lb_loadbalancercertificates_change_owner',
  10. action: (obj) => {
  11. this.createDialog('ChangeOwenrDialog', {
  12. data: [obj],
  13. columns: this.columns,
  14. name: this.$t('network.text_142'),
  15. onManager: this.onManager,
  16. resource: 'loadbalancercertificates',
  17. })
  18. },
  19. meta: (obj) => {
  20. const ret = {
  21. validate: false,
  22. tooltip: '',
  23. }
  24. if (this.isProjectMode) {
  25. ret.tooltip = i18n.t('monitor.text_9', [this.$t('dictionary.domain')])
  26. return ret
  27. }
  28. if (obj.is_public) {
  29. ret.validate = false
  30. ret.tooltip = this.$t('common_280')
  31. return ret
  32. }
  33. return {
  34. validate: this.isPower(obj),
  35. }
  36. },
  37. },
  38. getSetPublicAction(this, {
  39. name: this.$t('network.text_142'),
  40. scope: 'project',
  41. resource: 'loadbalancercertificates',
  42. }, {
  43. permission: 'lb_loadbalancercertificates_perform_public',
  44. }),
  45. {
  46. label: i18n.t('network.text_131'),
  47. permission: 'lb_loadbalancercertificates_delete',
  48. action: (obj) => {
  49. this.createDialog('DeleteResDialog', {
  50. vm: this,
  51. title: i18n.t('network.text_131'),
  52. alert: this.$t('network.text_768'),
  53. data: [obj],
  54. columns: this.columns,
  55. onManager: this.onManager,
  56. name: this.$t('network.text_143'),
  57. })
  58. },
  59. meta: (obj) => this.$getDeleteResult(obj),
  60. },
  61. ]
  62. },
  63. computed: {
  64. ...mapGetters(['isAdminMode', 'isDomainMode', 'userInfo', 'isProjectMode']),
  65. },
  66. methods: {
  67. isPower (obj) {
  68. if (this.isAdminMode) return true
  69. if (this.isDomainMode) return obj.domain_id === this.userInfo.projectDomainId
  70. return obj.tenant_id === this.userInfo.projectId
  71. },
  72. },
  73. }