|
@@ -41,6 +41,12 @@
|
|
|
getImgCode,
|
|
|
sendPhoneCode
|
|
|
} from '@/httpApi/loginRegister';
|
|
|
+ import {
|
|
|
+ bindProjectDetail
|
|
|
+ } from '@/httpApi/organization'
|
|
|
+ import {
|
|
|
+ getProjectDetailById
|
|
|
+ } from '@/httpApi/space'
|
|
|
import {
|
|
|
setToken,
|
|
|
setComment
|
|
@@ -149,23 +155,78 @@
|
|
|
setToken(res.data.token);
|
|
|
getUserInfo().then(res => {
|
|
|
if (res.state) {
|
|
|
- let organized = this.testOrganized(res.data);
|
|
|
- if (!organized) return this.loginLoading = false;
|
|
|
+ let user = res.data;
|
|
|
+ let organized = this.testOrganized(user);
|
|
|
this.selectOrganized(organized);
|
|
|
this.$store.dispatch('app/changeOrganization', organized);
|
|
|
- //vuex仓库存储user基本信息
|
|
|
- let user = res.data;
|
|
|
- getOrganizedProjectList(organized.id).then(res => {
|
|
|
+ this.$store.dispatch('app/changeUser', user);
|
|
|
+ if (user.projectId === -1) {
|
|
|
+ this.getUserProjectList();
|
|
|
+ } else {
|
|
|
+ this.selectProject({
|
|
|
+ projectId: user.projectId,
|
|
|
+ identityId: 6
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.loginLoading = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.loginLoading = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ testOrganized(data) {
|
|
|
+ let organized = !data.organization ? data.organizationList[0] : data.organization;
|
|
|
+ return organized;
|
|
|
+ },
|
|
|
+ getUserProjectList() {
|
|
|
+ bindProjectDetail({
|
|
|
+ userId: this.$store.getters.user.userId
|
|
|
+ }).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ let clientData = res.data;
|
|
|
+ bindProjectDetail({
|
|
|
+ bindOrganizationId: this.$store.getters.organization.id
|
|
|
+ }).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ let organizationData = res.data;
|
|
|
+ getOrganizedProjectList(this.$store.getters.organization.id).then(res => {
|
|
|
if (res.state) {
|
|
|
- if (!res.data || res.data.length == 0) {
|
|
|
+ let data = res.data || [];
|
|
|
+ let obj = []
|
|
|
+ if (this.$store.getters.user.phone == this.$store.getters
|
|
|
+ .organization.contactTel) {
|
|
|
+ obj = data.map(node => {
|
|
|
+ return {
|
|
|
+ projectId: node.id,
|
|
|
+ projectName: node.name,
|
|
|
+ organizationId: node.organizationId,
|
|
|
+ organizationName: this.$store.getters
|
|
|
+ .user.organizationList.find(item =>
|
|
|
+ item.id === node.organizationId
|
|
|
+ ).name,
|
|
|
+ identityId: 6
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ let projectList = clientData.concat(organizationData, obj)
|
|
|
+ .sort((a, b) => a.projectId - b.projectId);
|
|
|
+ if (projectList.length === 0) {
|
|
|
+ this.loginLoading = false;
|
|
|
+ this.$store.dispatch('app/changeMenuData', []);
|
|
|
+ setComment(JSON.stringify([]));
|
|
|
this.$store.dispatch('projectBase/changeProject', {});
|
|
|
- this.$store.dispatch('app/changeUser', user);
|
|
|
localStorage.setItem('projectId', 0);
|
|
|
+ this.$store.dispatch('app/changeiIdentityId', 6);
|
|
|
+ this.$message.success('登录成功');
|
|
|
return this.$router.push('/space/project');
|
|
|
+ } else {
|
|
|
+ this.selectProject(projectList[0])
|
|
|
}
|
|
|
- let project = user.projectId === -1 ? res.data[0] : res
|
|
|
- .data.filter(node => node.id == user.projectId)[0];
|
|
|
- this.selectProject(project)
|
|
|
+ } else {
|
|
|
+ this.loginLoading = false;
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
@@ -177,38 +238,31 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- testOrganized(data) {
|
|
|
- if (data.operateOrganizationList == 0) {
|
|
|
- this.$message.warning('您暂未有组织,请联系组织管理员添加');
|
|
|
- return false;
|
|
|
- }
|
|
|
- let organized = !data.organization ? data.organizationList[0] : data.organization;
|
|
|
- if (organized.status === 0) {
|
|
|
- this.$message.warning('您所属的组织信息暂未审核通过');
|
|
|
- return false;
|
|
|
- }
|
|
|
- return organized;
|
|
|
- },
|
|
|
- selectProject(data) {
|
|
|
- data.projectItemList = data.projectItemList || [];
|
|
|
- data.projectItemList.sort((a, b) => {
|
|
|
- return a.id - b.id;
|
|
|
- });
|
|
|
- this.project = data;
|
|
|
- this.$store.dispatch('projectBase/changeProject', data);
|
|
|
- localStorage.setItem('projectId', data.id);
|
|
|
- selectProject(data.id).then(res => {
|
|
|
- this.loginLoading = false;
|
|
|
+ selectProject(item) {
|
|
|
+ getProjectDetailById(item.projectId).then(res => {
|
|
|
if (res.state) {
|
|
|
- let user = res.data;
|
|
|
- if (!user.operateUserInfo) user['operateUserInfo'] = {};
|
|
|
- this.$store.dispatch('app/changeUser', user);
|
|
|
- this.$store.dispatch('app/changeMenuData', user.resource ? JSON.parse(user.resource) : []);
|
|
|
- setComment(user.menu ? user.menu : JSON.stringify([]));
|
|
|
- this.$router.push('/');
|
|
|
- this.$message.success('登录成功');
|
|
|
+ let data = res.data;
|
|
|
+ selectProject(data.id).then(res => {
|
|
|
+ if (res.state) {
|
|
|
+ let user = res.data;
|
|
|
+ this.$store.dispatch('app/changeiIdentityId', item.identityId);
|
|
|
+ this.$store.dispatch('projectBase/changeProject', data);
|
|
|
+ localStorage.setItem('projectId', data.id);
|
|
|
+ this.$store.dispatch('app/changeUser', user);
|
|
|
+ this.$store.dispatch('app/changeMenuData', user.resource ? JSON.parse(user
|
|
|
+ .resource) : []);
|
|
|
+ setComment(user.menu ? user.menu : JSON.stringify([]));
|
|
|
+ this.loginLoading = false;
|
|
|
+ this.$router.push('/');
|
|
|
+ this.$message.success('登录成功');
|
|
|
+ } else {
|
|
|
+ this.loginLoading = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.loginLoading = false;
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
selectOrganized(data) {
|
|
|
selectOrangaized(data)
|