fix: 修复当前用户加入组织后创建工单不显示加入的组织问题

This commit is contained in:
“huailei000”
2022-06-22 15:13:14 +08:00
committed by Jiangjie.Bai
parent f5c7abcbd8
commit 4b376b65b3
4 changed files with 53 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ import {
} from '@/utils/auth'
import { resetRouter } from '@/router'
import Vue from 'vue'
const _ = require('lodash')
const getDefaultState = () => {
return {
@@ -64,6 +65,9 @@ const mutations = {
},
SET_MFA_VERIFY(state) {
state.MFAVerifyAt = (new Date()).valueOf()
},
ADD_WORKBENCH_ORGS(state, org) {
state.workbenchOrgs.push(org)
}
}
@@ -109,6 +113,16 @@ const actions = {
setCurrentOrg({ commit }, 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 }) {
commit('SET_MFA_VERIFY')
},

View File

@@ -13,6 +13,7 @@ import Select2 from '@/components/FormFields/Select2'
import { getDaysFuture } from '@/utils/common'
import { Required } from '@/components/DataForm/rules'
import { ApplicationCascader } from '@/views/applications/const'
import { mapState, mapGetters } from 'vuex'
export default {
components: {
@@ -24,10 +25,8 @@ export default {
const now = new Date()
const date_expired = getDaysFuture(7, now).toISOString()
const date_start = now.toISOString()
// eslint-disable-next-line no-unused-vars
var org_id = ''
// eslint-disable-next-line no-unused-vars
var apply_category_type = []
let apply_category_type = []
return {
hasDetailInMsg: false,
loading: true,
@@ -129,7 +128,7 @@ export default {
component: Select2,
el: {
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 }
})
},
@@ -161,17 +160,21 @@ export default {
}
}
},
computed: {
...mapState({
workbenchOrgs: state => state.users.workbenchOrgs
}),
...mapGetters(['currentOrg'])
},
mounted() {
let userAllOrgIds = this.$store.state.users.profile['workbench_orgs']
const currentOrgId = this.$store.getters.currentOrg ? this.$store.getters.currentOrg.id : null
userAllOrgIds = userAllOrgIds ? userAllOrgIds.map(i => i.id) : []
if (userAllOrgIds.length > 0) {
const currentOrgId = this.currentOrg.id || ''
const userAllOrgIds = this.workbenchOrgs.map(i => i.id) || []
if (userAllOrgIds.includes(currentOrgId)) {
this.initial.org_id = currentOrgId
} else {
this.initial.org_id = userAllOrgIds[0]
}
}
this.loading = false
},
methods: {

View File

@@ -7,6 +7,8 @@ import { GenericCreateUpdatePage } from '@/layout/components'
import Select2 from '@/components/FormFields/Select2'
import { getDaysFuture } from '@/utils/common'
import PermissionFormActionField from '@/views/perms/components/PermissionFormActionField'
import { mapState, mapGetters } from 'vuex'
export default {
components: {
GenericCreateUpdatePage
@@ -98,7 +100,7 @@ export default {
component: Select2,
el: {
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 }
})
},
@@ -126,17 +128,21 @@ export default {
}
}
},
computed: {
...mapState({
workbenchOrgs: state => state.users.workbenchOrgs
}),
...mapGetters(['currentOrg'])
},
mounted() {
let userAllOrgIds = this.$store.state.users.profile['workbench_orgs']
const currentOrgId = this.$store.getters.currentOrg ? this.$store.getters.currentOrg.id : null
userAllOrgIds = userAllOrgIds ? userAllOrgIds.map(i => i.id) : []
if (userAllOrgIds.length > 0) {
const currentOrgId = this.currentOrg.id || ''
const userAllOrgIds = this.workbenchOrgs.map(i => i.id) || []
if (userAllOrgIds.includes(currentOrgId)) {
this.initial.org_id = currentOrgId
} else {
this.initial.org_id = userAllOrgIds[0]
}
}
this.loading = false
},
methods: {

View File

@@ -11,7 +11,10 @@
after
:destroy-on-close="true"
>
<GenericCreateUpdateForm v-bind="formConfig" @submitSuccess="onSubmitSuccess()" />
<GenericCreateUpdateForm
v-bind="formConfig"
@submitSuccess="onSubmitSuccess"
/>
</Dialog>
</template>
<script>
@@ -76,8 +79,9 @@ export default {
...mapGetters(['currentOrg', 'currentUser', 'device'])
},
methods: {
onSubmitSuccess() {
onSubmitSuccess(res) {
this.setting.InviteDialogVisible = false
this.$store.dispatch('users/currentUserJoinNewOrg', res.users)
}
}
}