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 => { getSimulationMemberList(this.group).then(resp => {
this.driverList = []; this.driverList = [];
this.treeData = []; this.treeData = [];
const result = covertMemberData(this.activeTrainList, resp); const result = covertMemberData(this.activeTrainList, resp.data);
this.driverList = result.driverList; this.driverList = result.driverList;
this.treeData = [{ this.treeData = [{
label: '行调', label: '行调',

View File

@ -36,6 +36,7 @@
<script> <script>
import DemonMenu from '@/views/newMap/displayNew/demonMenu'; import DemonMenu from '@/views/newMap/displayNew/demonMenu';
import { EventBus } from '@/scripts/event-bus'; import { EventBus } from '@/scripts/event-bus';
import {covertMemberData} from '@/views/newMap/displayNew/utils';
import { timeFormat } from '@/utils/date'; import { timeFormat } from '@/utils/date';
import { OperateMode } from '@/scripts/ConstDic'; import { OperateMode } from '@/scripts/ConstDic';
import { clearSimulation, getSimulationInfoNew } from '@/api/simulation'; import { clearSimulation, getSimulationInfoNew } from '@/api/simulation';
@ -74,6 +75,7 @@ export default {
faultMode: false, faultMode: false,
viewDisabled: true, viewDisabled: true,
firstLoad:true, firstLoad:true,
activeTrainList:[],
isscriptRun:false // isscriptRun:false //
}; };
}, },
@ -191,98 +193,40 @@ export default {
if (resp.code == 200) { if (resp.code == 200) {
if (resp.data.memberList && resp.data.memberList.length > 0) { if (resp.data.memberList && resp.data.memberList.length > 0) {
this.$store.dispatch('training/setMemberList', {memberList:resp.data.memberList, userId:this.$store.state.user.id}); this.$store.dispatch('training/setMemberList', {memberList:resp.data.memberList, userId:this.$store.state.user.id});
// if (this.$store.state.training.started) {
const memberList = this.$store.state.training.memberData; this.activeTrainList = this.$store.state.map.activeTrainList;
// if (data.id) { }
// memberList[data.id].userId = this.$store.state.user.id; const memberList = resp.data.memberList;
// memberList[data.id].name = this.$store.state.user.nickname; // 仿
// memberList[data.id].disabled = true; const result = covertMemberData(this.activeTrainList, memberList);
// } this.driverList = result.driverList;
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);
}
}
});
const treeData = [{ const treeData = [{
label: '行调', label: '行调',
id: 'dispatcher', id: 'dispatcher',
type: 'role', type: 'role',
children: dispatcherList children: result.deviceListData[0]
}, { }, {
label: '车站值班员', label: '车站值班员',
id: 'stationSupervisor', id: 'stationSupervisor',
type: 'role', type: 'role',
children: stationSupervisorList children: result.deviceListData[2]
}, { }, {
label: '司机', label: '司机',
id: 'driver', id: 'driver',
type: 'role', type: 'role',
children: driverList children: result.deviceListData[3]
}, { }, {
label: '通号', label: '通号',
id: 'maintainer', id: 'maintainer',
type: 'role', 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('setTreeData', treeData);
this.$emit('setMemberData', lastMemberList); this.$emit('setMemberData', lastMemberList);
} }

View File

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

View File

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

View File

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