From d6e672270cb642d2267d6eb29c28fb47534e7450 Mon Sep 17 00:00:00 2001 From: joylink_cuiweidong <364937672@qq.com> Date: Fri, 2 Dec 2022 14:00:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/login/index.vue | 120 +++++++++++++++- src/views/system/deviceManage/editConfig.vue | 11 ++ .../system/deviceManage/editConfigScreen.vue | 134 ++++++++++++++++-- 3 files changed, 249 insertions(+), 16 deletions(-) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index a72e3b9eb..ef0443dc3 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -58,6 +58,9 @@ import bgIscsImg from '@/assets/bg_iscs.jpg'; import bgCctvImg from '@/assets/bg_cctv.jpg'; import bgLswImg from '@/assets/bg_lsw.jpg'; import bgPsdImg from '@/assets/bg_psd.png'; +import { getLoginWmurl, checkLoginStatus, getOrgList, selectOrgnization } from '@/api/login'; +import { getBackProjectConfigByCode } from '@/api/projectConfig'; +import { getGroupByMapAndFunction, getSimulationInfoNew } from '@/api/simulation'; export default { name:'LoginNew', // components: { Register }, @@ -79,7 +82,9 @@ export default { loginProLogo:'', aboutSystem:'', loadingText:'', - deviceImg:'' + deviceImg:'', + checkLogin: null, + sessionId:'' }; }, computed: { @@ -125,7 +130,6 @@ export default { this.$store.dispatch('setLoginProLogo', this.loginProLogo); this.$store.dispatch('setHomeTitle', homeTitle); this.$store.dispatch('setCaseShow', caseShow); - // this.$store.dispatch('setCaseShow', caseShow); this.loadedConfig = true; // helpShow // 登录页 是否显示联系方式 loginContectInformation false @@ -167,6 +171,117 @@ export default { }; this.loadingText = deviceMap[this.type].text; this.deviceImg = deviceMap[this.type].Img; + this.loginRefresh(); + }, + loginRefresh() { + const self = this; + const params = { clientId: '1', secret: 'joylink' }; + params.project = this.project; + if (this.$route.query.projectDevice) { + params.deviceCode = this.$route.query.projectDevice; + } + getLoginWmurl(params) + .then(response => { + this.sessionId = response.data.sessionId; + this.checkLoginStatus(); + }) + .catch(() => { + if (this.syncLogin) { + setTimeout(() => { + self.loginRefresh(); + }, 3000); + } else { + this.$messageBox(this.$t('login.getLoginQrCode')); + } + }); + }, + clearTimer(timer) { + if (timer) { + clearTimeout(timer); + timer = null; + } + }, + checkLoginStatus() { + const self = this; + // 销毁则不再定时 + if (this && this._isDestroyed) { + return; + } + // 清空已存在的定时器 + // 设置定时器检测 + this.clearTimer(this.checkLogin); + this.checkLogin = setTimeout(() => { + checkLoginStatus(self.sessionId) + .then(response => { + + // 设置扫码登录 + self.$store + .dispatch('QrLoginSetting', { key: 'SET_TOKEN', value: response.data.token, type: 'class' }) + .then(() => { + // 清除定时器,设置路由 + self.clearTimer(self.checkLogin); + this.checkOrgnizationInfo(); + }); + + }).catch(error => { + if ((error.data && error.data.status === 'EXPIRE') || error.code != 200) { + self.loginRefresh(); + } else { + self.checkLoginStatus(); + } + }); + }, 3000); + }, + // 获取组织列表 + checkOrgnizationInfo() { + this.handleLoginSucessRoute(); + // getOrgList().then(resp => { + // const orgList = resp.data; + // let orgId = ''; + // if (orgList.length < 2) { + // if (orgList.length === 1) { + // orgId = orgList[0].orgId; + // selectOrgnization(orgId); + // } + // this.handleLoginSucessRoute(); + // } else { + // this.showOrgList(orgList); + // } + // }).catch((error)=>{ + // this.$message.error(error.message); + // }); + }, + // 跳转路由 + handleLoginSucessRoute() { + getBackProjectConfigByCode(this.project).then(res=>{ + if (res.data) { + const {mapId, functionId} = res.data; + if (functionId && mapId) { + getGroupByMapAndFunction(mapId, functionId).then(resp => { + const group = resp.data; + this.enterSimulation(group, mapId); + }); + } else { + this.$message.error('请先配置项目信息'); + } + } + }); + }, + enterSimulation(group, mapId) { + getSimulationInfoNew(group).then(response=>{ + const paramVO = response.data.paramVO; + const query = { + lineCode: response.data.map.lineCode, + group: group, + mapId: mapId, + projectDevice:this.$route.query.projectDevice, + simType:paramVO.type, + project: this.project, + singleClient:true, + client:this.$route.query.client + }; + this.$router.push({ path: `/display/demon`, query: query }); + }); } } }; @@ -231,6 +346,7 @@ export default { } .loadingText{ font-size: 36px; + color: #fff; } diff --git a/src/views/system/deviceManage/editConfig.vue b/src/views/system/deviceManage/editConfig.vue index d7ef35d02..09b0157b4 100644 --- a/src/views/system/deviceManage/editConfig.vue +++ b/src/views/system/deviceManage/editConfig.vue @@ -23,6 +23,16 @@ + + + + + import { getDevicesByType, getDeviceDetail, setDeviceConfig } from '@/api/project'; -import { getAllMapOnline, getStationListNeedAttendant, getPsdListByStandCode, getStandListByStationCode } from '@/api/jmap/map'; +// getStationListNeedAttendant +import { getAllMapOnline, querySimulationStationsByMapId, getPsdListByStandCode, getStandListByStationCode, querySimulationMemberByMapId} from '@/api/jmap/map'; import ConstConfig from '@/scripts/ConstConfig'; +import { getBackProjectConfigByCode } from '@/api/projectConfig'; +import { getMapFunctioById } from '@/api/trainingPlatform'; export default { name: 'EditConfigScreen', data() { @@ -104,6 +107,7 @@ export default { labelWidth: '150px', items: [ { prop: 'deviceCode', label: '教研机:', type: 'select', options: this.deviceList, optionLabel: 'code', optionValue: 'code' }, + { prop: 'mapId', label: '关联地图:', type: 'select', options: this.mapList, optionLabel: 'name', optionValue: 'id', deviceChange: this.mapIdChange}, { prop: 'quadrant', label: '屏幕配置:', type: 'select', options: this.screenList, optionLabel: 'label', optionValue: 'value'}, { prop: 'roleCode', label: '关联角色:', type: 'select', options: this.roleList, optionLabel: 'label', optionValue: 'value' }, { prop: 'client', label: '关联客户端:', type: 'select', options: this.clientList, optionLabel: 'label', optionValue: 'value' } @@ -114,6 +118,7 @@ export default { labelWidth: '150px', items: [ { prop: 'deviceCode', label: '教研机:', type: 'select', options: this.deviceList, optionLabel: 'code', optionValue: 'code' }, + { prop: 'mapId', label: '关联地图:', type: 'select', options: this.mapList, optionLabel: 'name', optionValue: 'id', deviceChange: this.mapIdChange}, { prop: 'roleCode', label: '关联角色:', type: 'select', options: this.roleList, optionLabel: 'label', optionValue: 'value' }, { prop: 'client', label: '关联客户端:', type: 'select', options: this.clientList, optionLabel: 'label', optionValue: 'value' } ] @@ -123,6 +128,7 @@ export default { labelWidth: '150px', items: [ { prop: 'deviceCode', label: '教研机', type: 'select', options: this.deviceList, optionLabel: 'code', optionValue: 'code'}, + { prop: 'mapId', label: '关联地图:', type: 'select', options: this.mapList, optionLabel: 'name', optionValue: 'id', deviceChange: this.mapIdChange}, { prop: 'roleCode', label: '关联角色:', type: 'select', options: this.roleList, optionLabel: 'label', optionValue: 'value' }, { prop: 'client', label: '关联客户端:', type: 'select', options: this.clientList, optionLabel: 'label', optionValue: 'value' } ] @@ -156,34 +162,130 @@ export default { quadrant: data.quadrant, deviceCode: data.deviceCode, psdCode: data.psdCode, + mapId:data.mapId, + roleCode:data.roleCode, + client:data.client, addr: data.addr, quantity: data.quantity }; + if (['VR_PSD', 'LSW', 'CCTV'].includes(row.type)) { + getAllMapOnline().then(resp => { + if (resp.data && resp.data.length) { + this.mapList = resp.data; + if (this.formData.mapId) { this.mapIdChange(this.formData.mapId); } + } + }).catch(() => { + this.$message.error('获取地图列表失败'); + }); + } }); - if (row.type === 'VR_PSD') { - getAllMapOnline().then(resp => { - if (resp.data && resp.data.length) { - this.mapList = resp.data; - this.formData.mapId = this.mapList[0].id; - this.mapIdChange(this.mapList[0].id); - } - }).catch(() => { - this.$message.error('获取地图列表失败'); - }); - } }, mapIdChange(mapId) { this.stationList = []; if (mapId) { - getStationListNeedAttendant(mapId).then(resp => { + querySimulationStationsByMapId(mapId).then(resp => { if (resp.data && resp.data.length) { this.stationList = resp.data; } + const self = this; + querySimulationMemberByMapId(mapId).then(resp => { + if (resp.data) { + getBackProjectConfigByCode(self.data.project).then(res=>{ + if (res.data) { + const functionId = res.data.functionId; + if (functionId) { + getMapFunctioById(functionId).then(response=>{ + if (resp.data) { + const roleList = resp.data[response.data.simType]; + const covertRoleList = []; + roleList.forEach(member => { + const data = self.handleMember(member, self.stationList); + covertRoleList.push(data); + }); + self.roleList = covertRoleList; + } + }); + } else { + self.$message.error('请先配置项目信息'); + } + } + }); + } + }).catch(() => { + this.$message.error('获取角色列表失败'); + }); }).catch(() => { this.$message.error('获取车站列表失败'); }); } }, + handleMember(member, stationList) { + const data = { value: member.id, label: '', memberType: member.type }; + const device = stationList.find(station => station.code === member.deviceCode) || {}; + switch (member.type) { + case 'DISPATCHER': + data.label = '行调' + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_SUPERVISOR': + data.label = '行值-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'DRIVER': + data.label = '司机-' + member.deviceCode; + break; + case 'MAINTAINER': + data.label = '通号' + (member.name ? `-${member.name }` : ''); + break; + case 'DEPOT_DISPATCHER': + data.label = '调度-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'SIGNAL_BUILDING': + data.label = '信号楼-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_ASSISTANT': + data.label = '助理-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_MASTER': + data.label = '站长-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_SIGNALER': + data.label = '信号员-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_PASSENGER': + data.label = '客运员-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_SWITCH_MAN': + data.label = '扳道员-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_FACILITATOR': + data.label = '引导员-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'STATION_WORKER': + data.label = '工务工-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'DEVICE_MANAGER': + data.label = '设备管理员-' + device.name + (member.name ? `-${member.name }` : ''); + break; + case 'TRAIN_MASTER': + data.label = '车务段段长' + (member.name ? `-${member.name }` : ''); + break; + case 'ELECTRIC_DISPATCHER': + data.label = '工电调度' + (member.name ? `-${member.name }` : ''); + break; + case 'PARENT_DEPARTMENT': + data.label = '上级部分' + (member.name ? `-${member.name }` : ''); + break; + case 'SCHEDULING': + data.label = '派班员' + (member.name ? `-${member.name }` : ''); + break; + case 'SHIFT_MANAGER': + data.label = '值班主任' + (member.name ? `-${member.name }` : ''); + break; + case 'ENVIRONMENT_DISPATCHER': + data.label = '环控调度' + (member.name ? `-${member.name}` : ''); + break; + } + return data; + }, stationCodeChange(stationCode) { this.standList = []; if (stationCode) { @@ -216,6 +318,7 @@ export default { deviceCode: this.formData.deviceCode, quadrant: this.formData.quadrant, roleCode: this.formData.roleCode, + mapId:this.formData.mapId, client: this.formData.client }; const data = {id: this.data.id, project: this.data.project, code: this.data.code, type: this.data.type, config: JSON.stringify(param) }; @@ -232,6 +335,7 @@ export default { const param = { deviceCode: this.formData.deviceCode, roleCode: this.formData.roleCode, + mapId:this.formData.mapId, client: this.formData.client }; const data = {id: this.data.id, project: this.data.project, code: this.data.code, type: this.data.type, config: JSON.stringify(param) }; @@ -248,6 +352,7 @@ export default { const param = { deviceCode: this.formData.deviceCode, psdCode: this.formData.psdCode, + mapId:this.formData.mapId, roleCode: this.formData.roleCode, client: this.formData.client }; @@ -280,6 +385,7 @@ export default { const param = { deviceCode: this.formData.deviceCode, roleCode: this.formData.roleCode, + mapId:this.formData.mapId, client: this.formData.client }; const data = {id: this.data.id, project: this.data.project, code: this.data.code, type: this.data.type, config: JSON.stringify(param) }; @@ -314,7 +420,7 @@ export default { this.stationList = []; this.standList = []; this.psdList = []; - this.mapId = ''; + // this.mapId = ''; this.roleList = []; this.stationCode = ''; this.standCode = '';