mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-17 23:59:02 +00:00
fix: 修复当前用户加入组织后创建工单不显示加入的组织问题
This commit is contained in:
committed by
Jiangjie.Bai
parent
f5c7abcbd8
commit
4b376b65b3
@@ -6,6 +6,7 @@ import {
|
|||||||
} from '@/utils/auth'
|
} from '@/utils/auth'
|
||||||
import { resetRouter } from '@/router'
|
import { resetRouter } from '@/router'
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
const getDefaultState = () => {
|
const getDefaultState = () => {
|
||||||
return {
|
return {
|
||||||
@@ -64,6 +65,9 @@ const mutations = {
|
|||||||
},
|
},
|
||||||
SET_MFA_VERIFY(state) {
|
SET_MFA_VERIFY(state) {
|
||||||
state.MFAVerifyAt = (new Date()).valueOf()
|
state.MFAVerifyAt = (new Date()).valueOf()
|
||||||
|
},
|
||||||
|
ADD_WORKBENCH_ORGS(state, org) {
|
||||||
|
state.workbenchOrgs.push(org)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +113,16 @@ const actions = {
|
|||||||
setCurrentOrg({ commit }, data) {
|
setCurrentOrg({ commit }, data) {
|
||||||
commit('SET_CURRENT_ORG', data)
|
commit('SET_CURRENT_ORG', data)
|
||||||
},
|
},
|
||||||
|
currentUserJoinNewOrg({ state, commit }, users) {
|
||||||
|
const { profile, currentOrg, workbenchOrgs } = state
|
||||||
|
if (users.includes(profile.id)) {
|
||||||
|
const currentOrgInfo = { id: currentOrg.id, name: currentOrg.name }
|
||||||
|
const notExistInWorkbenchOrgs = _.find(workbenchOrgs, currentOrgInfo)
|
||||||
|
if (!notExistInWorkbenchOrgs) {
|
||||||
|
commit('ADD_WORKBENCH_ORGS', currentOrg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
setMFAVerify({ commit }) {
|
setMFAVerify({ commit }) {
|
||||||
commit('SET_MFA_VERIFY')
|
commit('SET_MFA_VERIFY')
|
||||||
},
|
},
|
||||||
|
@@ -13,6 +13,7 @@ import Select2 from '@/components/FormFields/Select2'
|
|||||||
import { getDaysFuture } from '@/utils/common'
|
import { getDaysFuture } from '@/utils/common'
|
||||||
import { Required } from '@/components/DataForm/rules'
|
import { Required } from '@/components/DataForm/rules'
|
||||||
import { ApplicationCascader } from '@/views/applications/const'
|
import { ApplicationCascader } from '@/views/applications/const'
|
||||||
|
import { mapState, mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -24,10 +25,8 @@ export default {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
const date_expired = getDaysFuture(7, now).toISOString()
|
const date_expired = getDaysFuture(7, now).toISOString()
|
||||||
const date_start = now.toISOString()
|
const date_start = now.toISOString()
|
||||||
// eslint-disable-next-line no-unused-vars
|
let apply_category_type = []
|
||||||
var org_id = ''
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
|
||||||
var apply_category_type = []
|
|
||||||
return {
|
return {
|
||||||
hasDetailInMsg: false,
|
hasDetailInMsg: false,
|
||||||
loading: true,
|
loading: true,
|
||||||
@@ -129,7 +128,7 @@ export default {
|
|||||||
component: Select2,
|
component: Select2,
|
||||||
el: {
|
el: {
|
||||||
multiple: false,
|
multiple: false,
|
||||||
options: this.$store.state.users.profile.workbench_orgs?.map((item) => {
|
options: this.$store.state.users.workbenchOrgs?.map((item) => {
|
||||||
return { label: item.name, value: item.id }
|
return { label: item.name, value: item.id }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -161,17 +160,21 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
workbenchOrgs: state => state.users.workbenchOrgs
|
||||||
|
}),
|
||||||
|
...mapGetters(['currentOrg'])
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
let userAllOrgIds = this.$store.state.users.profile['workbench_orgs']
|
const currentOrgId = this.currentOrg.id || ''
|
||||||
const currentOrgId = this.$store.getters.currentOrg ? this.$store.getters.currentOrg.id : null
|
const userAllOrgIds = this.workbenchOrgs.map(i => i.id) || []
|
||||||
userAllOrgIds = userAllOrgIds ? userAllOrgIds.map(i => i.id) : []
|
if (userAllOrgIds.includes(currentOrgId)) {
|
||||||
if (userAllOrgIds.length > 0) {
|
this.initial.org_id = currentOrgId
|
||||||
if (userAllOrgIds.includes(currentOrgId)) {
|
} else {
|
||||||
this.initial.org_id = currentOrgId
|
this.initial.org_id = userAllOrgIds[0]
|
||||||
} else {
|
|
||||||
this.initial.org_id = userAllOrgIds[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@@ -7,6 +7,8 @@ import { GenericCreateUpdatePage } from '@/layout/components'
|
|||||||
import Select2 from '@/components/FormFields/Select2'
|
import Select2 from '@/components/FormFields/Select2'
|
||||||
import { getDaysFuture } from '@/utils/common'
|
import { getDaysFuture } from '@/utils/common'
|
||||||
import PermissionFormActionField from '@/views/perms/components/PermissionFormActionField'
|
import PermissionFormActionField from '@/views/perms/components/PermissionFormActionField'
|
||||||
|
import { mapState, mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
GenericCreateUpdatePage
|
GenericCreateUpdatePage
|
||||||
@@ -98,7 +100,7 @@ export default {
|
|||||||
component: Select2,
|
component: Select2,
|
||||||
el: {
|
el: {
|
||||||
multiple: false,
|
multiple: false,
|
||||||
options: this.$store.state.users.profile['workbench_orgs']?.map((item) => {
|
options: this.$store.state.users.workbenchOrgs?.map((item) => {
|
||||||
return { label: item.name, value: item.id }
|
return { label: item.name, value: item.id }
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -126,17 +128,21 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
workbenchOrgs: state => state.users.workbenchOrgs
|
||||||
|
}),
|
||||||
|
...mapGetters(['currentOrg'])
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
let userAllOrgIds = this.$store.state.users.profile['workbench_orgs']
|
const currentOrgId = this.currentOrg.id || ''
|
||||||
const currentOrgId = this.$store.getters.currentOrg ? this.$store.getters.currentOrg.id : null
|
const userAllOrgIds = this.workbenchOrgs.map(i => i.id) || []
|
||||||
userAllOrgIds = userAllOrgIds ? userAllOrgIds.map(i => i.id) : []
|
if (userAllOrgIds.includes(currentOrgId)) {
|
||||||
if (userAllOrgIds.length > 0) {
|
this.initial.org_id = currentOrgId
|
||||||
if (userAllOrgIds.includes(currentOrgId)) {
|
} else {
|
||||||
this.initial.org_id = currentOrgId
|
this.initial.org_id = userAllOrgIds[0]
|
||||||
} else {
|
|
||||||
this.initial.org_id = userAllOrgIds[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@@ -11,7 +11,10 @@
|
|||||||
after
|
after
|
||||||
:destroy-on-close="true"
|
:destroy-on-close="true"
|
||||||
>
|
>
|
||||||
<GenericCreateUpdateForm v-bind="formConfig" @submitSuccess="onSubmitSuccess()" />
|
<GenericCreateUpdateForm
|
||||||
|
v-bind="formConfig"
|
||||||
|
@submitSuccess="onSubmitSuccess"
|
||||||
|
/>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@@ -76,8 +79,9 @@ export default {
|
|||||||
...mapGetters(['currentOrg', 'currentUser', 'device'])
|
...mapGetters(['currentOrg', 'currentUser', 'device'])
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onSubmitSuccess() {
|
onSubmitSuccess(res) {
|
||||||
this.setting.InviteDialogVisible = false
|
this.setting.InviteDialogVisible = false
|
||||||
|
this.$store.dispatch('users/currentUserJoinNewOrg', res.users)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user