rt-sim-training-client/src/views/scriptManage/scriptRecord/getAction.vue

237 lines
10 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<el-scrollbar ref="elActionScrollbar" wrap-class="scrollbar-wrapper" class="scriptBottom" :style="{width:370+'px',height:size.height+'px'}">
<el-timeline :reverse="reverse" class="el_timeline">
<el-timeline-item v-for="(actionInfo,index) in actionInfoList" :key="index">
<el-card>
<div class="actionTable">
<span class="detail" v-html="actionInfo.detail" />
<span class="otherInfo" v-html="actionInfo.otherInfo" />
<span v-if="actionInfo.isCoversition">
<span class="roleClass">{{ actionInfo.memberName }}</span>
<span>{{ $t('scriptRecord.speakTo') }}</span>
<span class="roleClass">{{ actionInfo.targetName }}</span>
<span>: </span>
<span>{{ actionInfo.reply }}</span>
</span>
<span v-else>
<span class="roleClass">{{ actionInfo.memberName }}</span>
<span>{{ $t('scriptRecord.executeCommandTips') }}</span>
<span class="commandStyle">{{ actionInfo.command }}</span>
</span>
</div>
<div class="btnGroup">
<el-button v-if="actionInfo.visible" type="primary" size="mini" style="margin-left:10px;" @click="modifyAction(actionInfo.row)">{{ $t('scriptRecord.modifyConversitionButton') }}</el-button>
<!-- <el-button type="danger" size="mini" @click="deleteAction(actionInfo.id)">删除</el-button> -->
</div>
</el-card>
</el-timeline-item>
</el-timeline>
</el-scrollbar>
2019-07-26 13:32:43 +08:00
</template>
<script>
2020-03-30 16:56:38 +08:00
import {deleteScriptAction, getAvailableDeviceCommand, getScriptRecord, getScriptAllAction, getScriptPlayMemberNew } from '@/api/simulation';
import CMD from '@/scripts/cmdPlugin/CommandEnum';
2020-05-11 11:31:55 +08:00
import CommandHandler from '@/scripts/cmdPlugin/CommandHandler';
import ConstConfig from '@/scripts/ConstConfig';
export default {
2019-10-31 13:56:42 +08:00
name: 'GetAction',
props: {
group: {
type: String,
required: true
},
size: {
type: Object,
required: true
}
},
data() {
return {
actionInfoList: [],
deviceCommandList: [],
reverse: true,
loading: true,
// behaviorName:"",
memberName: ''
};
},
computed:{
drawWay() {
const drawWay = this.$route.query.drawWay;
return drawWay && JSON.parse(drawWay);
}
},
2019-10-31 13:56:42 +08:00
watch: {
actionInfoList: function(val) {
this.$nextTick(function() {
var div = this.$refs['elActionScrollbar'].$refs['wrap'];
div.scrollTop = this.$refs['elActionScrollbar'].wrap.scrollHeight;
});
}
},
mounted() {
this.loadInitData();
},
methods: {
loadInitData() {
// const group=this.$route.query.group;
const data = {role: 'Driver'};
if (!this.drawWay) {
2020-03-30 16:56:38 +08:00
getAvailableDeviceCommand(data).then(response=>{
this.deviceCommandList = response.data;
this.loadOtherData(this.$route.query);
});
} else {
2019-10-31 13:56:42 +08:00
this.loadOtherData(this.$route.query);
2020-03-30 16:56:38 +08:00
}
2019-10-31 13:56:42 +08:00
},
loadOtherData(obj) {
const group = obj.group;
if (this.drawWay) {
2020-03-30 16:56:38 +08:00
getScriptPlayMemberNew(this.group).then(response => {
const memberVOList = response.data;
getScriptAllAction(group).then(resp=>{
this.actionInfoList = [];
2020-03-30 16:56:38 +08:00
const actionList = resp.data;
actionList.forEach(element => {
const member = memberVOList.find(elem=>{ return elem.id == element.memberId; });
const memberName = member.name;
switch (element.type) {
case 'Conversation':
{
const target = memberVOList.find(elem=>{ return elem.id == element.targetId; });
const targetName = target.name;
this.actionInfoList.push({id: element.id, isCoversition: true, memberName: memberName, targetName: targetName, reply: element.reply, row: element, visible: true});
break;
}
case 'Command':
{
2020-05-11 11:31:55 +08:00
const command = CommandHandler.getScriptDefinition(element.operationId);
const operateType = command.operate.split('_')[0];
const data = command.operate.toUpperCase();
const operateName = CMD[operateType]['CMD_' + data];
const deviceTypeList = {Section:'区段', Switch:'道岔', Signal:'信号机', Stand:'站台', Station:'车站', TrainWindow:'车次窗'};
const operateTypeName = deviceTypeList[operateType];
this.actionInfoList.push({id: element.id, isCoversition: false, memberName: memberName, command: operateTypeName + '(' + operateName.label + ')', row: element, visible: false});
break;
}
2020-03-30 16:56:38 +08:00
}
});
}).catch(error => {
this.$message(error.message);
});
}).catch(error => {
this.$message(error.message);
});
} else {
getScriptRecord(group).then(response=>{
this.$store.dispatch('scriptRecord/updateBgSet', response.data.bgSet);
this.actionInfoList = [];
const roleTypeList = ConstConfig.ConstSelect.roleType;
2020-03-30 16:56:38 +08:00
let memberVOList = JSON.stringify(response.data.memberVOList);
roleTypeList.forEach(function(element) {
const rolename = element.value;
memberVOList = memberVOList.replace(new RegExp(rolename, 'g'), element.label);
});
memberVOList = JSON.parse(memberVOList);
const actionList = response.data.actionVOList;
2020-03-30 16:56:38 +08:00
actionList.forEach(element => {
2020-03-30 16:56:38 +08:00
const member = memberVOList.find(elem=>{ return elem.id == element.memberId; });
2020-03-30 16:56:38 +08:00
const memberName = member.name ? ' - ' + member.name : '';
switch (element.type) {
case 'Conversation':
{
const target = memberVOList.find(elem=>{ return elem.id == element.targetId; });
const targetName = target.name ? ' - ' + target.name : '';
this.actionInfoList.push({id: element.id, isCoversition: true, memberName: member.role + memberName, targetName: target.role + targetName, reply: element.reply, row: element, visible: true});
break;
}
case 'Command':
{
const deviceCommand = this.deviceCommandList.find(elem=>{ return elem.deviceCommand == element.deviceCommand; });
this.actionInfoList.push({id: element.id, isCoversition: false, memberName: member.role + memberName, command: deviceCommand.label, row: element, visible: false});
// switch (element.deviceCommand) {
// case 'Train_Manual_Route_Blocking_Drive':
// {
// this.actionInfoList.push({id: element.id, isCoversition: false, memberName: member.role + memberName, command: deviceCommand.label, row: element, visible: false});
// break;
// }
// case 'Train_Manual_Limit_Drive':
// {
// this.actionInfoList.push({id: element.id, isCoversition: false, memberName: member.role + memberName, command: deviceCommand.label, row: element, visible: false});
// break;
// }
// }
}
}
});
if (response.data.mapLocation) {
const mapLocation = {'offsetX': response.data.mapLocation.x, 'offsetY': response.data.mapLocation.y, 'scaleRate': response.data.mapLocation.scale};
this.$store.dispatch('scriptRecord/updateMapLocation', mapLocation);
}
this.loading = false;
});
}
2019-10-31 13:56:42 +08:00
},
deleteAction(row) {
const group = this.$props.group;
if (!this.drawWay) {
2020-03-30 16:56:38 +08:00
deleteScriptAction(group, row).then(resp => {
this.reloadTable();
this.$message.success('删除行为动作成功');
}).catch(error => {
this.$messageBox(`删除行为动作失败: ${error.message}`);
});
}
2019-10-31 13:56:42 +08:00
},
reloadTable() {
this.loadInitData();
},
modifyAction(row) {
if (!this.drawWay) {
2020-03-30 16:56:38 +08:00
this.$emit('setAction', row);
}
2019-10-31 13:56:42 +08:00
}
}
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
2019-08-16 19:33:40 +08:00
.actionTable{
2019-08-21 10:24:55 +08:00
width:280px;
padding: 15px 0px 10px 15px;
2019-08-16 20:06:14 +08:00
display: inline-block;
line-height: 200%;
2019-08-16 19:33:40 +08:00
}
.btnGroup{
2019-08-16 20:06:14 +08:00
padding: 10px 10px 10px 10px;
float: right;
2019-08-16 20:06:14 +08:00
vertical-align: top;
display: inline-block;
2019-08-16 19:33:40 +08:00
}
2019-08-20 13:21:38 +08:00
.el_timeline{
2019-08-22 18:13:55 +08:00
width: 350px;
margin-top:20px;
padding-left: 25px;
2019-08-20 15:41:54 +08:00
}
.roleClass{
color:#409EFF
}
.commandStyle{
color:#F00;
}
2019-08-21 18:45:16 +08:00
.scriptPane{
height: 100%;
2019-08-21 20:16:47 +08:00
padding-top:200px;
2019-08-21 18:45:16 +08:00
}
.scriptBottom{
2019-08-22 18:13:55 +08:00
margin-left:360px;
margin-top: 20px;
2019-08-21 18:45:16 +08:00
}
2019-07-26 13:32:43 +08:00
</style>