代码调整

This commit is contained in:
joylink_cuiweidong 2022-11-28 18:34:08 +08:00
parent fd99287e10
commit f4fb2d7cbf
3 changed files with 66 additions and 32 deletions

View File

@ -544,3 +544,11 @@ export function createSimulation(id) {
method: 'post'
});
}
/** 根据地图ID和功能ID获取仿真GroupId */
export function getGroupByMapAndFunction(mapId, functionId) {
return request({
url: `/simulation/new/map/${mapId}/function/${functionId}`,
method: 'get'
});
}

View File

@ -82,7 +82,7 @@ import md5 from 'js-md5';
import Cookies from 'js-cookie';
// getLoginWmurl, checkLoginStatus,
import { getOrgList, selectOrgnization } from '@/api/login';
import { createSimulation, getSimulationInfoNew } from '@/api/simulation';
import { createSimulation, getSimulationInfoNew, getGroupByMapAndFunction } from '@/api/simulation';
import { getBackProjectConfigByCode } from '@/api/projectConfig';
import { assignUsersPlayRoles } from '@/api/jointSimulation';
export default {
@ -144,7 +144,7 @@ export default {
return this.$route.query.projectDevice;
},
role() {
return this.$route.query.role;
return this.$route.query.roleCode;
}
},
watch: {
@ -180,7 +180,6 @@ export default {
this.checkOrgnizationInfo();
})
.catch(error => {
debugger;
console.log(error);
// if (error.code === '30001') {
// this.tipsMsg = this.$t('login.accountOrPasswordIsIncorrect');
@ -244,22 +243,37 @@ export default {
if (res.data) {
const {mapId, functionId} = res.data;
if (functionId && mapId) {
createSimulation(functionId).then(resp => {
const group = resp.data;
if (this.role) {
assignUsersPlayRoles(this.role, group).then(() => {
if (params.type == 'IM') {
createSimulation(functionId).then(resp => {
const group = resp.data;
if (this.role) {
const data = [{userId: this.$store.state.user.id, memberId:this.role}];
assignUsersPlayRoles(data, group).then(() => {
this.enterSimulation(group, mapId);
});
} else {
this.enterSimulation(group, mapId);
});
} else {
this.enterSimulation(group, mapId);
}
}).catch(error=>{
if (error.code == 10003) {
this.$messageBox(this.$t('error.createSimulationFailed') + ':您的仿真权限不足!');
} else {
this.$messageBox(this.$t('error.createSimulationFailed') + error.message);
}
});
}
}).catch(error=>{
if (error.code == 10003) {
this.$messageBox(this.$t('error.createSimulationFailed') + ':您的仿真权限不足!');
} else {
this.$messageBox(this.$t('error.createSimulationFailed') + error.message);
}
});
} else {
getGroupByMapAndFunction(mapId, functionId).then(resp => {
const group = resp.data;
if (this.role) {
const data = [{userId: this.$store.state.user.id, memberId:this.role}];
assignUsersPlayRoles(data, group).then(() => {
this.enterSimulation(group, mapId);
});
} else {
this.enterSimulation(group, mapId);
}
});
}
} else {
this.$message.error('请先配置项目信息');
}

View File

@ -11,7 +11,7 @@
</template>
<script>
import { getProjectDeviceList, deleteProjectDevice } from '@/api/project';
import { getProjectDeviceList, deleteProjectDevice, getDeviceDetail } from '@/api/project';
import DeviceAdd from './add';
import EditConfigGateway from './editConfigGateway';
import EditConfig from './editConfig';
@ -203,19 +203,31 @@ export default {
this.queryList.reload();
},
getPath(index, row) {
let url = '';
url = `${window.location.protocol}//${window.location.host}/cbtc/login?project=${row.project.toLowerCase().replace(/_/, '')}&projectDevice=${row.code}&type=${row.type}`;
this.url = url;
this.$messageBox();
this.$confirm(`登录路径:${url}`, '登录路径', {
confirmButtonText: '复制路径',
cancelButtonText: '关闭',
type: 'success'
}).then(() => {
const inputText = document.getElementById('device-manage-url');
inputText.select(); //
document.execCommand('Copy'); //
this.$message.success('登录路径已经复制到粘贴板');
getDeviceDetail(row.id).then(res=>{
if (res.data) {
let roleCode = '';
if (res.data.type == 'LW') {
const config = JSON.parse(res.data.config);
roleCode = config.roleCode;
}
let url = '';
url = `${window.location.protocol}//${window.location.host}/cbtc/login?project=${row.project.toLowerCase().replace(/_/, '')}&projectDevice=${row.code}&type=${row.type}`;
if (roleCode) {
url += '&roleCode=' + roleCode;
}
this.url = url;
this.$messageBox();
this.$confirm(`登录路径:${url}`, '登录路径', {
confirmButtonText: '复制路径',
cancelButtonText: '关闭',
type: 'success'
}).then(() => {
const inputText = document.getElementById('device-manage-url');
inputText.select(); //
document.execCommand('Copy'); //
this.$message.success('登录路径已经复制到粘贴板');
});
}
});
}
}