ShareMode.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div v-if="shareModeShow">
  3. <!-- 共享范围选择 -->
  4. <a-form-item :label="$t('cloudenv.text_282')" :extra="extra">
  5. <a-radio-group v-decorator="decorators.share_mode">
  6. <template v-for="item of shareModeOptions">
  7. <a-radio-button :key="item.key" :value="item.key">{{ item.label }}</a-radio-button>
  8. </template>
  9. </a-radio-group>
  10. </a-form-item>
  11. </div>
  12. </template>
  13. <script>
  14. import { mapGetters } from 'vuex'
  15. export default {
  16. name: 'ShareMode',
  17. props: {
  18. fd: {
  19. type: Object,
  20. },
  21. cloneData: {
  22. type: Object,
  23. default: () => ({}),
  24. },
  25. },
  26. data () {
  27. let initialShareMode = 'account_domain'
  28. if (this.cloneData.public_scope === 'system') {
  29. initialShareMode = 'global'
  30. }
  31. return {
  32. decorators: {
  33. share_mode: [
  34. 'share_mode',
  35. {
  36. initialValue: initialShareMode,
  37. rules: [{ required: true }],
  38. },
  39. ],
  40. },
  41. shareModeOptions: [
  42. { key: 'account_domain', label: this.$t('cloudenv.text_285') },
  43. { key: 'global', label: this.$t('cloudenv.global_share') },
  44. ],
  45. }
  46. },
  47. computed: {
  48. ...mapGetters(['l3PermissionEnable', 'isAdminMode']),
  49. shareModeShow () {
  50. return this.l3PermissionEnable && this.isAdminMode
  51. },
  52. extra () {
  53. const shareModeExtra = {
  54. account_domain: this.$t('cloudenv.text_288', [this.$t('dictionary.cloudaccount'), this.$t('dictionary.domain'), this.$t('dictionary.project'), this.$t('dictionary.cloudaccount')]),
  55. global: this.$t('cloudenv.global_share_tip'),
  56. }
  57. return shareModeExtra[this.fd.share_mode]
  58. },
  59. },
  60. }
  61. </script>