whx 9 hónapja
szülő
commit
33846e1c15

+ 10 - 0
virgo.wzfrontend/console/src/httpApi/space.js

@@ -331,4 +331,14 @@ export function getBimViewToken(fileId) {
 		url: `/api/bim/viewToken/${fileId}`,
 		method: 'get',
 	});
+}
+/* 
+ * 获取项目列表
+ * 
+ */
+export function getProjectListByIdentity() {
+	return request({
+		url: `/api/project/projectListIdentity`,
+		method: 'get'
+	})
 }

+ 75 - 149
virgo.wzfrontend/console/src/layout/components/selectProject.vue

@@ -7,24 +7,14 @@
 						<div style="text-align: center;">{{scope.$index + 1}}</div>
 					</template>
 				</el-table-column>
-				<el-table-column label="项目名称" prop="projectName"></el-table-column>
+				<el-table-column label="项目名称" prop="name"></el-table-column>
 				<el-table-column label="所属企业" prop="organizationName"></el-table-column>
 				<el-table-column label="项目身份">
 					<template slot-scope="scope">
 						<div class="hui-table-tag" style="display: flex;align-items: center;">
-							<div class="hui-tag hui-tag-success" v-if="scope.row.identityId === 1">客户</div>
-							<div class="hui-tag hui-tag-success" v-else-if="scope.row.identityId === 2">中介</div>
-							<div class="hui-tag hui-tag-success" v-else-if="scope.row.identityId === 3">
-								公司成员
-							</div>
-							<div class="hui-tag hui-tag-success" v-else-if="scope.row.identityId === 4">
-								关联公司
-							</div>
-							<div class="hui-tag hui-tag-success" v-else-if="scope.row.identityId === 5">
-								经纪公司
-							</div>
-							<div class="hui-tag hui-tag-success" v-else-if="scope.row.identityId === 6">
-								所有者
+							<div class="hui-tag hui-tag-success" v-for="(node,index) in scope.row.projectListIdentity"
+								:key="index">
+								{{node.name}}
 							</div>
 						</div>
 					</template>
@@ -32,9 +22,7 @@
 				<el-table-column label="操作" width="100">
 					<template slot-scope="scope">
 						<div class="hui-table-operation">
-							<span class="table-operation"
-								v-if="$store.getters.project.id != scope.row.projectId || $store.getters.identityId != scope.row.identityId"
-								@click="changeProject(scope.row)">
+							<span class="table-operation" @click="changeProject(scope.row)">
 								切换项目
 							</span>
 						</div>
@@ -45,22 +33,34 @@
 				</template>
 			</el-table>
 		</div>
+		<el-dialog custom-class="identity" title="选择身份" :visible.sync="visible" width="300px" :append-to-body="true">
+			<div class="hui-flex hui-dialog">
+				<div class="hui-flex-box hui-dialog-content">
+					<el-radio-group v-model="indentity">
+						<div class="select-identity-item" v-for="item in  project.projectListIdentity" :key="item.id">
+							<el-radio :label="item.id">{{item.name}}</el-radio>
+						</div>
+					</el-radio-group>
+				</div>
+				<div class="hui-dialog-submit">
+					<el-button size="medium" @click="visible = false">取 消</el-button>
+					<el-button size="medium" type="primary" @click="submit">确定</el-button>
+				</div>
+			</div>
+		</el-dialog>
 	</div>
 </template>
 
 <script>
 	import {
 		selectProject,
-		getOrganizedProjectList,
 		selectOrangaized
 	} from '@/httpApi/loginRegister'
 	import {
-		bindProjectDetail,
 		getOrganizationDetailById
 	} from '@/httpApi/organization'
 	import {
-		getProjectDetailById,
-		getProjectListByPage
+		getProjectListByIdentity
 	} from '@/httpApi/space'
 	import {
 		getIdentityResource
@@ -71,103 +71,67 @@
 	export default {
 		data() {
 			return {
-				tableData: []
+				tableData: [],
+				visible: false,
+				indentity: '',
+				project: {
+					projectListIdentity: []
+				}
 			}
 		},
 		created() {
-			let user = this.$store.getters.user;
-			if (user.userId === 1) {
-				getProjectListByPage({
-					currPage: 1,
-					pageSize: 100
-				}).then(res => {
-					if (res.state) {
-						this.tableData = res.data.dataList.map(node => {
-							let organization = user.organizationList.find(item => item.id === node
-								.organizationId);
-							return {
-								projectId: node.id,
-								projectName: node.name,
-								organizationId: node.organizationId,
-								organizationName: !organization ? '' : organization.name,
-								identityId: 6
-							}
-						})
-					}
-				})
-			} else {
-				this.init();
-			}
+			this.init();
 		},
 		methods: {
 			init() {
-				bindProjectDetail({
-					userId: this.$store.getters.user.userId
-				}).then(res => {
+				getProjectListByIdentity().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;
-								if (this.$store.getters.user.phone == this.$store.getters.organization
-									.contactTel) {
-									getOrganizedProjectList(this.$store.getters.organization.id).then(
-										res => {
-											if (res.state) {
-												let data = res.data || [];
-												let obj = data.map(node => {
-													return {
-														projectId: node.id,
-														projectName: node.name,
-														organizationId: node.organizationId,
-														organizationName: node
-															.organizationName,
-														identityId: 6
-													}
-												})
-												let list = clientData.concat(organizationData,
-													obj).sort((a, b) => a.projectId - b.projectId);
-												this.tableData = list.filter((item, index) => {
-													return list.findIndex(t => t.projectId ===
-														item.projectId && t.identityId ===
-														item.identityId) === index;
-												})
-											}
-										});
-								} else {
-									this.tableData = clientData.concat(organizationData).sort((a, b) => a
-										.projectId - b.projectId);
-								}
-							}
-						})
+						this.tableData = res.data;
 					}
 				})
 			},
 			changeProject(item) {
-				if (item.identityId == 6 || item.identityId == 3) {
-					getOrganizationDetailById(item.organizationId).then(res => {
+				this.project = item;
+				this.indentity = item.projectListIdentity[0].id;
+				this.visible = true;
+			},
+			submit() {
+				if (this.indentity == 6 || this.indentity == 3) {
+					getOrganizationDetailById(this.project.organizationId).then(res => {
 						if (res.state) {
 							this.$store.dispatch('app/changeOrganization', res.data);
 							selectOrangaized(res.data)
 						}
 					})
 				}
-				getProjectDetailById(item.projectId).then(res => {
+				selectProject(this.project.id).then(res => {
 					if (res.state) {
-						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);
-								if (item.identityId === 3 || user.userId === 1) {
-									this.$store.dispatch('app/changeMenuData', user.resource ? JSON.parse(
-										user.resource) : []);
-									setComment(user.menu ? user.menu : JSON.stringify([]));
+						let user = res.data;
+						this.$store.dispatch('app/changeiIdentityId', this.indentity);
+						this.$store.dispatch('projectBase/changeProject', this.project);
+						localStorage.setItem('projectId', this.project.id);
+						this.$store.dispatch('app/changeUser', user);
+						if (this.indentity === 3 || user.userId === 1) {
+							this.$store.dispatch('app/changeMenuData', user.resource ? JSON.parse(user.resource) :
+								[]);
+							setComment(user.menu ? user.menu : JSON.stringify([]));
+							this.$emit('callback');
+							this.$router.push({
+								path: '/',
+								replace: true
+							})
+							this.$message.success('切换成功');
+						} else {
+							getIdentityResource({
+								identityId: this.indentity.identityId,
+								type: this.project.type
+							}).then(node => {
+								if (node.state) {
+									let role = node.data[0] || {};
+									this.$store.dispatch('app/changeMenuData', role
+										.resource ? JSON.parse(role.resource) : []);
+									setComment(role.menus ? role.menus : JSON.stringify(
+										[]));
 									this.$emit('callback');
 									this.$router.push({
 										path: '/',
@@ -175,64 +139,26 @@
 									})
 									this.$message.success('切换成功');
 								} else {
-									getIdentityResource({
-										identityId: item.identityId,
-										type: data.type
-									}).then(node => {
-										if (node.state) {
-											let role = node.data[0] || {};
-											this.$store.dispatch('app/changeMenuData', role
-												.resource ? JSON.parse(role.resource) : []);
-											setComment(role.menus ? role.menus : JSON.stringify(
-												[]));
-											this.$emit('callback');
-											this.$router.push({
-												path: '/',
-												replace: true
-											})
-											this.$message.success('切换成功');
-										} else {
-											this.loginLoading = false;
-										}
-									})
+									this.$message.error('切换失败');
 								}
-
-							} else {
-								this.$message.error('切换失败');
-							}
-						});
+							})
+						}
+					} else {
+						this.$message.error('切换失败');
 					}
-				})
-			},
-			submit() {
-
+				});
 			}
 		}
 	}
 </script>
 
 <style lang="scss">
-	.select-project-index {
-		.select-project-item {
-			flex: 1;
-			height: 0;
-			display: flex;
-			flex-direction: column;
-
-			.select-project-title {
-				padding: 10px 15px;
-				position: relative;
+	.identity.el-dialog {
+		height: 40vh;
+		margin-top: 30vh !important;
 
-				&::before {
-					content: '';
-					width: 4px;
-					height: 18px;
-					left: 4px;
-					top: 11px;
-					background: $--color-primary;
-					position: absolute;
-				}
-			}
+		.select-identity-item {
+			margin-bottom: 10px;
 		}
 	}
 </style>