This commit is contained in:
fan 2020-09-02 10:18:06 +08:00
commit c9bab84c50
5 changed files with 28 additions and 83 deletions

View File

@ -72,7 +72,7 @@ export default {
getSimulationMemberList(this.group).then(resp => {
this.driverList = [];
this.treeData = [];
const result = covertMemberData(this.activeTrainList, resp);
const result = covertMemberData(this.activeTrainList, resp.data);
this.driverList = result.driverList;
this.treeData = [{
label: '行调',

View File

@ -36,6 +36,7 @@
<script>
import DemonMenu from '@/views/newMap/displayNew/demonMenu';
import { EventBus } from '@/scripts/event-bus';
import {covertMemberData} from '@/views/newMap/displayNew/utils';
import { timeFormat } from '@/utils/date';
import { OperateMode } from '@/scripts/ConstDic';
import { clearSimulation, getSimulationInfoNew } from '@/api/simulation';
@ -74,6 +75,7 @@ export default {
faultMode: false,
viewDisabled: true,
firstLoad:true,
activeTrainList:[],
isscriptRun:false //
};
},
@ -191,98 +193,40 @@ export default {
if (resp.code == 200) {
if (resp.data.memberList && resp.data.memberList.length > 0) {
this.$store.dispatch('training/setMemberList', {memberList:resp.data.memberList, userId:this.$store.state.user.id});
//
const memberList = this.$store.state.training.memberData;
// if (data.id) {
// memberList[data.id].userId = this.$store.state.user.id;
// memberList[data.id].name = this.$store.state.user.nickname;
// memberList[data.id].disabled = true;
// }
let lastData = JSON.stringify(memberList);
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) {
const rolename = element.value;
if (Cookies.get('user_lang') == 'en') {
lastData = lastData.replace(new RegExp(rolename, 'g'), element.enLabel);
} else {
lastData = lastData.replace(new RegExp(rolename, 'g'), element.label);
}
});
lastData = JSON.parse(lastData);
lastData = Object.values(lastData);
const lastMemberList = [];
const dispatcherList = [];
// const electricDispatcherList = [];
// const depotDispatcherList = [];
const stationSupervisorList = [];
const driverList = [];
const maintainerList = [];
this.treeData = [];
lastData.forEach((member, index)=>{
if (!member.userId) {
member.userId = '';
member.disabled = false;
} else {
member.disabled = true;
member.userName = this.$store.state.user.nickname;
}
if (member.type != '观众') {
const userName = member.userName ? '-' + member.userName : '';
const name = member.name == undefined ? '' : '-' + member.name;
if (member.deviceCode) {
const device = this.$store.getters['map/getDeviceByCode'](member.deviceCode);
if (device) {
if (device._type == 'Train') {
member.deviceName = device.groupNumber;
member.label = member.type + device.groupNumber + name + userName;
lastMemberList.push(member);
driverList.push(member);
} else {
member.deviceName = device.name;
member.label = member.type + device.name + name + userName;
lastMemberList.push(member);
if (device._type == 'Station') {
stationSupervisorList.push(member);
}
}
} else {
member.deviceName = member.deviceCode;
member.label = member.type + member.deviceCode + name + userName;
lastMemberList.push(member);
}
} else {
member.label = member.type + name + userName;
member.deviceName = '';
if (member.type == '行调') {
dispatcherList.push(member);
} else if (member.type == '通号') {
maintainerList.push(member);
}
lastMemberList.push(member);
}
}
});
if (this.$store.state.training.started) {
this.activeTrainList = this.$store.state.map.activeTrainList;
}
const memberList = resp.data.memberList;
// 仿
const result = covertMemberData(this.activeTrainList, memberList);
this.driverList = result.driverList;
const treeData = [{
label: '行调',
id: 'dispatcher',
type: 'role',
children: dispatcherList
children: result.deviceListData[0]
}, {
label: '车站值班员',
id: 'stationSupervisor',
type: 'role',
children: stationSupervisorList
children: result.deviceListData[2]
}, {
label: '司机',
id: 'driver',
type: 'role',
children: driverList
children: result.deviceListData[3]
}, {
label: '通号',
id: 'maintainer',
type: 'role',
children: maintainerList
children: result.deviceListData[1]
}, {
label: '车辆段',
id: 'depotDispatcher',
type: 'role',
children: result.deviceListData[4]
}];
const lastMemberList = result.lastMemberList;
this.$emit('setTreeData', treeData);
this.$emit('setMemberData', lastMemberList);
}

View File

@ -137,6 +137,7 @@ export default {
},
// ()
'$store.state.map.activeTrainListChange': function (val) {
// driverList
const activeTrainList = this.$store.state.map.activeTrainList;
if (this.driverList.length > 0) {
const driverList = [];
@ -148,6 +149,7 @@ export default {
});
if (drivers) {
driverList.push(drivers);
this.memberData.push(drivers);
}
});
}
@ -165,7 +167,7 @@ export default {
this.activeTrainList = this.$store.state.map.activeTrainList;
}
// 仿
const result = covertMemberData(this.activeTrainList, resp);
const result = covertMemberData(this.activeTrainList, resp.data);
this.driverList = result.driverList;
this.treeData = [{
label: '行调',

View File

@ -15,9 +15,7 @@
</template>
<script>
import ChatBox from '@/views/newMap/chatView/chatBox.vue';
import {covertMemberData} from '@/views/newMap/displayNew/utils';
import {getAllConversition} from '@/api/chat';
import { getSimulationMemberList} from '@/api/simulation';
export default {
name:'ScriptChat',
components:{

View File

@ -2,7 +2,7 @@ import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
import store from '@/store/index_APP_TARGET';
export function covertMemberData (activeTrainList, resp) {
let lastData = JSON.stringify(resp.data);
let lastData = JSON.stringify(resp);
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) {
const rolename = element.value;
@ -37,7 +37,7 @@ export function covertMemberData (activeTrainList, resp) {
member.label = member.type + name + userName;
member.normalName = member.type + name;
}
lastMemberList.push(member);
const deviceType = ['行调', '通号', '行值', '司机', '车辆段调度'];
const deviceTypeIndex = deviceType.indexOf(member.type);
if (deviceTypeIndex >= 0) {
@ -45,12 +45,13 @@ export function covertMemberData (activeTrainList, resp) {
if (activeTrainList.length > 0) {
if (activeTrainList.includes(member.deviceCode)) {
deviceListData[deviceTypeIndex].push(member);
lastMemberList.push(member);
}
} else {
driverList.push(member);
}
driverList.push(member);
} else {
deviceListData[deviceTypeIndex].push(member);
lastMemberList.push(member);
}
}
});