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

187 lines
7.1 KiB
Vue
Raw Normal View History

2020-06-12 11:31:30 +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>
</template>
<script>
import Cookies from 'js-cookie';
import {getScriptAllAction, getScriptPlayMemberNew } from '@/api/simulation';
import CMD from '@/scripts/cmdPlugin/CommandEnum';
import CommandHandler from '@/scripts/cmdPlugin/CommandHandler';
import ConstConfig from '@/scripts/ConstConfig';
export default {
name: 'GetActionNew',
props: {
group: {
type: String,
required: true
},
size: {
type: Object,
required: true
}
},
data() {
return {
actionInfoList: [],
deviceCommandList: [],
reverse: false,
loading: true,
// behaviorName:"",
memberName: ''
};
},
computed:{
// drawWay() {
// const drawWay = this.$route.query.drawWay;
// return drawWay && JSON.parse(drawWay);
// }
},
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() {
this.loadOtherData(this.$route.query);
},
covert(data, roleTypeList) {
let lastData = data;
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.forEach(each=>{
const name = each.name == undefined ? '' : '-' + each.name;
const deviceName = each.deviceName == undefined ? '' : '-' + each.deviceName;
each.name = each.role + deviceName + name;
});
return lastData;
},
loadOtherData(obj) {
const group = obj.group;
getScriptPlayMemberNew(this.group).then(response => {
const lastData = JSON.stringify(response.data);
const memberVOList = this.covert(lastData, ConstConfig.ConstSelect.roleTypeNew);
getScriptAllAction(group).then(resp=>{
this.actionInfoList = [];
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':
{
const command = CommandHandler.getScriptDefinition(element.operationType);
let operateType = command.operate.split('_')[0];
const data = command.operate.toUpperCase();
if (operateType == 'CM') {
operateType = 'ControlConvertMenu';
}
const operateName = CMD[operateType]['CMD_' + data];
const deviceTypeList = {Section:'区段', Switch:'道岔', Signal:'信号机', Stand:'站台', Station:'车站', TrainWindow:'车次窗', ControlConvertMenu:'控制模式'};
const operateTypeName = deviceTypeList[operateType];
this.actionInfoList.push({id: element.id, isCoversition: false, memberName: memberName, command: operateTypeName + '(' + operateName.label + ')', row: element, visible: false});
break;
}
}
});
}).catch(error => {
this.$message(error.message);
});
}).catch(error => {
this.$message(error.message);
});
},
reloadTable() {
this.loadInitData();
}
// modifyAction(row) {
// this.$emit('setAction', row);
// }
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.actionTable{
width:280px;
padding: 15px 0px 10px 15px;
display: inline-block;
line-height: 200%;
}
.btnGroup{
padding: 10px 10px 10px 10px;
float: right;
vertical-align: top;
display: inline-block;
}
.el_timeline{
width: 350px;
margin-top:5px;
padding-left: 25px;
}
.el-timeline{
font-size:13px;
}
.roleClass{
color:#409EFF
}
.commandStyle{
color:#F00;
}
.scriptPane{
height: 100%;
padding-top:200px;
}
.scriptBottom{
margin-left:300px;
margin-top: 0px;
font-size:13px;
}
</style>