AddUser.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <a-form :form="form.fc" v-bind="formItemLayout">
  3. <a-form-item :label="$t('dictionary.user')">
  4. <domain-user-select
  5. :labelInValue="false"
  6. :form="form"
  7. :decorators="decorators"
  8. :projectDomainId="projectDomainId"
  9. @domainChange="domainChange" />
  10. </a-form-item>
  11. <a-form-item :label="`${$t('dictionary.role')}`">
  12. <base-select
  13. v-decorator="decorators.roles"
  14. version="v1"
  15. resource="roles"
  16. :params="roleParams"
  17. filterable
  18. :showSync="true"
  19. :select-props="{ mode: 'multiple', placeholder: $t('rules.role') }" />
  20. <div slot="extra">{{$t('system.text_441', [$t('dictionary.role')])}}<help-link :href="roleLink">{{$t('system.text_440')}}</help-link></div>
  21. </a-form-item>
  22. </a-form>
  23. </template>
  24. <script>
  25. import { mapGetters } from 'vuex'
  26. import DomainUserSelect from '../../components/DomainUserSelect'
  27. export default {
  28. name: 'AddUser',
  29. components: {
  30. DomainUserSelect,
  31. },
  32. props: {
  33. domainId: {
  34. type: String,
  35. default: 'default',
  36. },
  37. domainOpt: [],
  38. },
  39. data () {
  40. return {
  41. projectDomainId: this.domainId,
  42. form: {
  43. fc: this.$form.createForm(this),
  44. },
  45. formItemLayout: {
  46. wrapperCol: {
  47. span: 21,
  48. xxl: {
  49. span: 22,
  50. },
  51. },
  52. labelCol: {
  53. span: 3,
  54. xxl: {
  55. span: 2,
  56. },
  57. },
  58. },
  59. decorators: {
  60. domain: [
  61. 'domain',
  62. {
  63. initialValue: this.domainId,
  64. },
  65. ],
  66. users: [
  67. 'users',
  68. {
  69. rules: [
  70. { required: true, message: this.$t('rules.user') },
  71. ],
  72. },
  73. ],
  74. roles: [
  75. 'roles',
  76. {
  77. rules: [
  78. { required: true, message: this.$t('rules.role') },
  79. ],
  80. },
  81. ],
  82. },
  83. }
  84. },
  85. computed: {
  86. ...mapGetters(['scope', 'isAdminMode', 'userInfo', 'l3PermissionEnable']),
  87. roleParams () {
  88. const params = {
  89. scope: this.scope,
  90. limit: 0,
  91. }
  92. if (this.isAdminMode) {
  93. if (this.l3PermissionEnable) {
  94. params.domain_id = this.projectDomainId || this.userInfo.projectDomainId
  95. } else {
  96. params.domain_id = this.userInfo.projectDomainId
  97. }
  98. }
  99. return params
  100. },
  101. roleLink () {
  102. return this.$router.resolve('/role').href
  103. },
  104. },
  105. methods: {
  106. validateForm () {
  107. return this.form.fc.validateFields()
  108. },
  109. domainChange (val) {
  110. this.projectDomainId = val
  111. },
  112. },
  113. }
  114. </script>