ScopeSelect.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <a-radio-group :defaultValue="value" @change="handleChange">
  3. <template v-for="item of scopesMap">
  4. <a-radio-button
  5. v-if="showScope(item)"
  6. :key="item.key"
  7. :value="item.key">{{ $t(`policyScopeLabel.${item.key}`) }}</a-radio-button>
  8. </template>
  9. </a-radio-group>
  10. </template>
  11. <script>
  12. import { mapGetters } from 'vuex'
  13. import { SCOPES_MAP } from '@/constants'
  14. export default {
  15. name: 'PolicyScopeSelect',
  16. props: {
  17. value: String,
  18. },
  19. computed: {
  20. ...mapGetters(['l3PermissionEnable', 'scope']),
  21. scopesMap () {
  22. const ret = { ...SCOPES_MAP }
  23. if (!this.l3PermissionEnable) {
  24. delete ret[SCOPES_MAP.domain.key]
  25. }
  26. return ret
  27. },
  28. },
  29. methods: {
  30. handleChange (e) {
  31. this.$emit('input', e.target.value)
  32. },
  33. showScope (item) {
  34. if (item.key === this.scopesMap.system.key) {
  35. if (this.scope !== this.scopesMap.system.key) {
  36. return false
  37. }
  38. }
  39. return true
  40. },
  41. },
  42. }
  43. </script>