2020-06-11 18:32:26 +08:00
|
|
|
<template>
|
2020-06-12 11:31:30 +08:00
|
|
|
<div class="scriptRecordNew" :style="{bottom:(offsetBottom-15)+'px'}">
|
|
|
|
<div v-show="isShow" class="scriptRecordNewIn">
|
|
|
|
<el-tabs type="card">
|
|
|
|
<el-tab-pane :label="$t('scriptRecord.scriptRecordTitle')+'('+language+')'">
|
|
|
|
<div class="eachScriptPanel">
|
|
|
|
<div class="scriptPanelLeft">
|
|
|
|
<div class="panelLeftSelect">
|
|
|
|
<span style="font-size:13px;">当前剧本角色:</span>
|
2020-07-09 10:50:56 +08:00
|
|
|
<el-select v-model="memberId" filterable placeholder="请选择" :disabled="!backDisabled||isPause" @change="changeRole">
|
2020-06-12 11:31:30 +08:00
|
|
|
<el-option v-for="member in memberList" :key="member.id" :label="member.name" :value="member.id" />
|
|
|
|
</el-select>
|
|
|
|
</div>
|
|
|
|
<el-button-group class="button-group">
|
|
|
|
<el-button v-if="isPause" size="small" type="primary" :disabled="executeDisabled" @click="pauseScript">{{ $t('scriptRecord.drivingPause') }}</el-button>
|
|
|
|
<el-button v-else size="small" type="primary" :disabled="executeDisabled" @click="executePlayScript">恢复</el-button>
|
2020-07-09 15:44:12 +08:00
|
|
|
<el-button size="small" type="danger" :disabled="!backDisabled" @click="dumpScenesData">{{ $t('scriptRecord.resetScript') }}</el-button>
|
2020-06-12 11:31:30 +08:00
|
|
|
<el-button size="small" type="primary" :disabled="backDisabled" @click="saveScenesStage">{{ $t('scriptRecord.saveBackground') }}</el-button>
|
|
|
|
<el-button size="small" type="success" :loading="isSavingScript" @click="saveScenesData">{{ $t('scriptRecord.saveData') }}</el-button>
|
|
|
|
</el-button-group>
|
2020-06-11 18:32:26 +08:00
|
|
|
</div>
|
2020-06-12 11:31:30 +08:00
|
|
|
<div class="scriptPanelRight">
|
2020-07-08 13:05:09 +08:00
|
|
|
<get-action-new ref="getAction" :group="group" :size="size" :member-list="memberList" @setAction="setAction" />
|
2020-06-12 11:31:30 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
</div>
|
|
|
|
<div class="scriptRecordNewTitle" @click="minisize">
|
|
|
|
<span class="titleStyle">{{ $t('scriptRecord.scriptRecordTitle') }}</span>
|
2020-06-11 18:32:26 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2020-06-12 11:31:30 +08:00
|
|
|
import Vue from 'vue';
|
|
|
|
import GetActionNew from '../scriptRecord/getActionNew';
|
2020-07-08 09:39:25 +08:00
|
|
|
import {getSimulationMemberList, executeScriptNew, dumpScriptDataNew, saveScriptDataNew, saveScriptScenesNew, updateMapLocationNew, simulationPause} from '@/api/simulation';
|
2020-06-12 11:31:30 +08:00
|
|
|
import ConstConfig from '@/scripts/ConstConfig';
|
2020-06-12 17:44:18 +08:00
|
|
|
import {getDraftScriptByGroupNew, changeScriptRole} from '@/api/script';
|
2020-06-12 11:31:30 +08:00
|
|
|
import Cookies from 'js-cookie';
|
|
|
|
|
2020-06-11 18:32:26 +08:00
|
|
|
export default {
|
|
|
|
name:'TipScriptRecordNew',
|
|
|
|
components: {
|
2020-06-12 11:31:30 +08:00
|
|
|
GetActionNew
|
2020-06-11 18:32:26 +08:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
group: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
offsetBottom:{
|
|
|
|
type: Number,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isShow:true,
|
2020-06-12 11:31:30 +08:00
|
|
|
language:'',
|
2020-07-10 16:40:42 +08:00
|
|
|
oldMemberId:'',
|
2020-06-12 11:31:30 +08:00
|
|
|
memberId:'',
|
|
|
|
isPause:false,
|
|
|
|
executeDisabled: false,
|
|
|
|
backDisabled: false,
|
|
|
|
autoSaveScript: null,
|
|
|
|
isSavingScript: false,
|
2020-06-17 14:18:46 +08:00
|
|
|
mapLocation:null,
|
2020-07-09 15:09:18 +08:00
|
|
|
allMemberList:[],
|
2020-06-12 11:31:30 +08:00
|
|
|
memberList:[],
|
|
|
|
size: {
|
|
|
|
width: 300,
|
|
|
|
height: 300
|
|
|
|
}
|
2020-06-11 18:32:26 +08:00
|
|
|
};
|
|
|
|
},
|
2020-06-12 11:31:30 +08:00
|
|
|
watch:{
|
|
|
|
'$store.state.map.mapViewLoadedCount': function (val) {
|
|
|
|
Vue.prototype.$jlmap.setOptions(this.$store.state.scriptRecord.mapLocation);
|
|
|
|
this.isPause = !(this.$store.state.scriptRecord.simulationPause);
|
2020-06-17 14:18:46 +08:00
|
|
|
if (this.mapLocation) {
|
|
|
|
const newMapLocation = {'offsetX': this.mapLocation.x, 'offsetY': this.mapLocation.y, 'scaleRate': this.mapLocation.scale};
|
|
|
|
Vue.prototype.$jlmap.setOptions(newMapLocation);
|
|
|
|
}
|
|
|
|
if (this.$store.state.scriptRecord.bgSet) {
|
|
|
|
this.$store.dispatch('training/setPrdType', null);
|
|
|
|
}
|
2020-07-08 13:05:09 +08:00
|
|
|
this.initData();
|
2020-06-12 11:31:30 +08:00
|
|
|
},
|
|
|
|
'$store.state.scriptRecord.bgSet': function (val) {
|
|
|
|
this.backDisabled = val;
|
2020-06-12 16:12:33 +08:00
|
|
|
},
|
|
|
|
'$store.state.scriptRecord.simulationPause': function(val) {
|
|
|
|
this.isPause = !(this.$store.state.scriptRecord.simulationPause);
|
2020-06-18 14:19:13 +08:00
|
|
|
},
|
2020-07-09 15:09:18 +08:00
|
|
|
// '$store.state.map.runPlanStatus':function (val) {
|
|
|
|
// // this.$refs.getAction.loadInitData();
|
|
|
|
// this.changeRunPlanStatus();
|
|
|
|
// },
|
|
|
|
'$store.state.map.activeTrainListChange':function (val) {
|
|
|
|
this.changeRunPlanStatus();
|
2020-06-12 11:31:30 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2020-06-23 18:59:20 +08:00
|
|
|
// this.clearAutoSave();
|
2020-07-10 15:34:19 +08:00
|
|
|
this.$store.dispatch('training/setMemberList', {memberList:[], userId:this.$store.state.user.id});
|
2020-07-09 17:39:43 +08:00
|
|
|
this.$store.dispatch('map/resetActiveTrainList');
|
2020-06-12 11:31:30 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', false);
|
2020-06-22 18:37:09 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateRole', null);
|
2020-06-12 11:31:30 +08:00
|
|
|
},
|
2020-06-11 18:32:26 +08:00
|
|
|
mounted() {
|
|
|
|
this.language = this.$route.query.lang == 'en' ? this.$t('scriptRecord.english') : this.$t('scriptRecord.chinese');
|
2020-06-12 11:31:30 +08:00
|
|
|
getDraftScriptByGroupNew(this.group).then(response=>{
|
|
|
|
this.backDisabled = response.data.bgSet;
|
2020-06-17 14:18:46 +08:00
|
|
|
this.mapLocation = response.data.mapLocation;
|
2020-06-12 11:31:30 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', response.data.bgSet);
|
|
|
|
});
|
2020-06-11 18:32:26 +08:00
|
|
|
},
|
|
|
|
methods:{
|
2020-06-12 11:31:30 +08:00
|
|
|
initData() {
|
2020-07-08 09:39:25 +08:00
|
|
|
getSimulationMemberList(this.group).then(resp => {
|
2020-06-12 11:31:30 +08:00
|
|
|
const lastData = JSON.stringify(resp.data);
|
2020-07-10 15:34:19 +08:00
|
|
|
this.$store.dispatch('training/setMemberList', {memberList:resp.data, userId:this.$store.state.user.id});
|
2020-07-09 15:09:18 +08:00
|
|
|
this.allMemberList = this.covert(lastData, ConstConfig.ConstSelect.roleTypeNew);
|
|
|
|
this.changeRunPlanStatus();
|
2020-06-12 11:31:30 +08:00
|
|
|
}).catch(error => {
|
|
|
|
this.$message(error.message);
|
|
|
|
});
|
2020-06-11 18:32:26 +08:00
|
|
|
},
|
2020-07-09 15:09:18 +08:00
|
|
|
changeRunPlanStatus() {
|
|
|
|
this.memberList = [];
|
|
|
|
if (this.$store.state.map.runPlanStatus) {
|
|
|
|
const activeList = this.$store.state.map.activeTrainList;
|
|
|
|
this.allMemberList.forEach(allmember=>{
|
|
|
|
if (allmember.type == '司机') {
|
|
|
|
if (activeList.length > 0 && activeList.includes(allmember.deviceCode)) {
|
|
|
|
this.memberList.push(allmember);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.memberList.push(allmember);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.memberList = this.allMemberList.filter(member=>{
|
|
|
|
return member.type != '司机';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-06-11 18:32:26 +08:00
|
|
|
minisize() {
|
|
|
|
if (this.isShow) {
|
|
|
|
this.isShow = false;
|
|
|
|
} else {
|
|
|
|
this.isShow = true;
|
|
|
|
}
|
2020-06-12 11:31:30 +08:00
|
|
|
},
|
2020-06-12 16:12:33 +08:00
|
|
|
changeRole(member) {
|
|
|
|
if (member) {
|
|
|
|
// this.$store.dispatch('scriptRecord/updateIsScriptCommand', true);
|
|
|
|
this.switchMode(member);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
switchMode(role) {
|
2020-06-12 17:44:18 +08:00
|
|
|
changeScriptRole(this.group, role).then(res=>{
|
|
|
|
let prdType = '';
|
2020-07-14 09:24:58 +08:00
|
|
|
|
2020-06-12 17:44:18 +08:00
|
|
|
const memberInfo = this.memberList.find(member=>{
|
|
|
|
return member.id == role;
|
|
|
|
});
|
|
|
|
if (memberInfo) {
|
2020-07-08 18:35:46 +08:00
|
|
|
if (memberInfo.type == '行值') {
|
2020-06-12 17:44:18 +08:00
|
|
|
prdType = '01';
|
2020-07-08 18:35:46 +08:00
|
|
|
} else if (memberInfo.type == '行调') {
|
2020-06-12 17:44:18 +08:00
|
|
|
prdType = '02';
|
2020-07-08 18:35:46 +08:00
|
|
|
} else if (memberInfo.type == '司机') {
|
2020-06-12 17:44:18 +08:00
|
|
|
prdType = '04';
|
2020-06-17 14:18:46 +08:00
|
|
|
} else {
|
|
|
|
prdType = '';
|
2020-06-12 17:44:18 +08:00
|
|
|
}
|
2020-06-12 16:12:33 +08:00
|
|
|
}
|
2020-07-10 17:33:37 +08:00
|
|
|
this.$store.dispatch('training/updateMemberListInScript',
|
|
|
|
{
|
|
|
|
oldMemberId:this.oldMemberId,
|
|
|
|
newMemberId:role,
|
|
|
|
userId:this.$store.state.user.id,
|
|
|
|
name:this.$store.state.user.nickname
|
|
|
|
}
|
|
|
|
);
|
2020-07-10 16:40:42 +08:00
|
|
|
this.oldMemberId = role;
|
2020-06-12 17:44:18 +08:00
|
|
|
this.$store.dispatch('training/setPrdType', prdType);
|
2020-06-22 18:37:09 +08:00
|
|
|
ConstConfig.ConstSelect.roleTypeNew.forEach(each=>{
|
2020-07-08 18:35:46 +08:00
|
|
|
if (each.label == memberInfo.type) {
|
|
|
|
this.$store.dispatch('scriptRecord/updateRole', each.value + ':' + role);
|
2020-06-22 18:37:09 +08:00
|
|
|
}
|
|
|
|
});
|
2020-06-12 17:44:18 +08:00
|
|
|
}).catch(()=>{
|
|
|
|
this.$messageBox('切换角色失败');
|
|
|
|
});
|
2020-06-12 11:31:30 +08:00
|
|
|
},
|
|
|
|
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;
|
2020-07-08 13:05:09 +08:00
|
|
|
let deviceName = '';
|
|
|
|
if (each.deviceCode) {
|
|
|
|
const device = this.$store.getters['map/getDeviceByCode'](each.deviceCode);
|
|
|
|
if (device) {
|
|
|
|
if (device._type == 'Train') {
|
|
|
|
deviceName = device.groupNumber;
|
|
|
|
} else {
|
|
|
|
deviceName = device.name;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
deviceName = each.deviceCode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
each.name = each.type + deviceName + name;
|
2020-06-12 11:31:30 +08:00
|
|
|
});
|
|
|
|
return lastData;
|
|
|
|
},
|
|
|
|
setAction() {
|
|
|
|
|
|
|
|
},
|
|
|
|
pauseScript() {
|
|
|
|
simulationPause(this.group).then(resp => {
|
|
|
|
this.$store.dispatch('scriptRecord/updateSimulationPause', true);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.pauseFail'));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
saveScenesData() {
|
|
|
|
this.isSavingScript = true;
|
2020-07-03 09:46:26 +08:00
|
|
|
const data = Vue.prototype.$jlmap.$options;
|
|
|
|
const dataZoom = {scale: data.scaleRate, x: data.offsetX, y: data.offsetY};
|
|
|
|
updateMapLocationNew(this.group, dataZoom).then(response=>{
|
|
|
|
saveScriptDataNew(this.group).then(resp => {
|
|
|
|
this.$message.success(this.$t('scriptRecord.saveDataSucess'));
|
|
|
|
this.isSavingScript = false;
|
2020-06-23 18:59:20 +08:00
|
|
|
// this.initAutoSaveScript();
|
2020-07-03 09:46:26 +08:00
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.saveDataFail')}: ${error.message}`);
|
|
|
|
this.isSavingScript = false;
|
|
|
|
if (error.code === 40004 || error.code === 40005 || error.code === 40003) {
|
|
|
|
// this.clearAutoSave();
|
|
|
|
} else {
|
|
|
|
// // this.initAutoSaveScript();
|
|
|
|
}
|
|
|
|
});
|
2020-06-12 11:31:30 +08:00
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.saveDataFail')}: ${error.message}`);
|
|
|
|
this.isSavingScript = false;
|
|
|
|
if (error.code === 40004 || error.code === 40005 || error.code === 40003) {
|
2020-06-23 18:59:20 +08:00
|
|
|
// this.clearAutoSave();
|
2020-06-12 11:31:30 +08:00
|
|
|
} else {
|
2020-06-23 18:59:20 +08:00
|
|
|
// // this.initAutoSaveScript();
|
2020-06-12 11:31:30 +08:00
|
|
|
}
|
|
|
|
});
|
2020-07-03 09:46:26 +08:00
|
|
|
|
2020-06-12 11:31:30 +08:00
|
|
|
},
|
|
|
|
saveScenesStage() {
|
|
|
|
const data = Vue.prototype.$jlmap.$options;
|
|
|
|
const group = this.$route.query.group;
|
|
|
|
const dataZoom = {scale: data.scaleRate, x: data.offsetX, y: data.offsetY};
|
2020-07-03 09:46:26 +08:00
|
|
|
updateMapLocationNew(group, dataZoom).then(response=>{
|
|
|
|
saveScriptScenesNew(this.group).then(resp => {
|
2020-06-12 11:31:30 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', true);
|
2020-06-17 14:18:46 +08:00
|
|
|
this.$store.dispatch('training/setPrdType', null);
|
2020-06-12 11:31:30 +08:00
|
|
|
this.$message.success(this.$t('scriptRecord.saveBackgroundSuceess'));
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.updateLocationFail')}: ${error.message}`);
|
|
|
|
});
|
|
|
|
}).catch((error) => {
|
|
|
|
this.$messageBox(`${this.$t('scriptRecord.saveBackgroundFail')}: ${error.message}`);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
initAutoSaveScript() {
|
|
|
|
const timeout = 1000 * 20;
|
|
|
|
this.clearAutoSave(this.autoSaveScript);
|
|
|
|
this.autoSaveScript = setInterval(this.saveScenesData, timeout);
|
|
|
|
},
|
|
|
|
clearAutoSave() {
|
|
|
|
if (this.autoSaveScript) {
|
|
|
|
clearInterval(this.autoSaveScript);
|
|
|
|
this.autoSaveScript = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
executePlayScript() {
|
|
|
|
executeScriptNew(this.group).then(resp => {
|
|
|
|
this.$store.dispatch('scriptRecord/updateSimulationPause', false);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.recoverFail'));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
dumpScenesData() {
|
|
|
|
this.clearAutoSave();
|
|
|
|
const group = this.group;
|
|
|
|
this.$confirm(this.$t('scriptRecord.clearDataTip'), this.$t('global.tips'), {
|
|
|
|
confirmButtonText: this.$t('global.confirm'),
|
|
|
|
cancelButtonText: this.$t('global.cancel'),
|
|
|
|
type: 'warning'
|
|
|
|
}).then(() => {
|
|
|
|
dumpScriptDataNew(group).then(resp => {
|
|
|
|
this.$parent.resetBeginTime();
|
|
|
|
this.$refs['getAction'].loadInitData();
|
2020-07-10 16:40:42 +08:00
|
|
|
this.changeRunPlanStatus();
|
2020-06-17 14:18:46 +08:00
|
|
|
this.memberId = '';
|
2020-06-18 14:36:23 +08:00
|
|
|
this.$store.dispatch('map/setRunPlanStatus', false);
|
2020-06-17 14:18:46 +08:00
|
|
|
this.$store.dispatch('training/setPrdType', '01');
|
2020-07-09 16:54:31 +08:00
|
|
|
this.$store.dispatch('map/resetActiveTrainList');
|
2020-06-17 14:18:46 +08:00
|
|
|
// this.initAutoSaveScript();
|
2020-07-10 10:53:44 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateRole', '');
|
2020-06-12 11:31:30 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', false);
|
|
|
|
this.$message.success(this.$t('scriptRecord.resetDataSuccess'));
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.resetDataFail'));
|
|
|
|
});
|
|
|
|
});
|
2020-06-11 18:32:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.selectRolesTitle{
|
|
|
|
|
2020-06-12 11:31:30 +08:00
|
|
|
}
|
|
|
|
.button-group{
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
}
|
|
|
|
.eachScriptPanel{
|
|
|
|
height: 300px;
|
|
|
|
display: inline-block;
|
|
|
|
width:100%;
|
|
|
|
}
|
|
|
|
.scriptPanelLeft{
|
|
|
|
width: 330px;
|
|
|
|
height: 100%;
|
|
|
|
vertical-align: top;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
top: 0;
|
2020-06-12 16:12:33 +08:00
|
|
|
z-index: 2;
|
2020-06-12 11:31:30 +08:00
|
|
|
}
|
|
|
|
.scriptPanelRight{
|
|
|
|
width: 680px;
|
2020-06-11 18:32:26 +08:00
|
|
|
}
|
|
|
|
.scriptRecordNew{
|
|
|
|
position: absolute;
|
|
|
|
width: 700px;
|
|
|
|
z-index: 10;
|
|
|
|
padding-top: 28px;
|
|
|
|
left: 50%;
|
|
|
|
bottom: 0px;
|
|
|
|
transform: translateX(-50%) translateY(0);
|
|
|
|
}
|
|
|
|
.scriptRecordNewTitle{
|
|
|
|
position: absolute;
|
|
|
|
background: #fff;
|
|
|
|
border-radius: 5px 5px 0px 0px ;
|
|
|
|
padding: 5px 0px;
|
|
|
|
width: 100px;
|
|
|
|
text-align: center;
|
|
|
|
left: 50%;
|
|
|
|
transform: translateX(-50%);
|
|
|
|
cursor: pointer;
|
|
|
|
top:0;
|
|
|
|
}
|
|
|
|
.scriptRecordNewIn{
|
|
|
|
padding: 10px;
|
|
|
|
background: #fff;
|
|
|
|
border-radius: 5px 5px 0px 0px ;
|
2020-06-12 16:12:33 +08:00
|
|
|
height: 380px;
|
2020-06-11 18:32:26 +08:00
|
|
|
box-shadow: -1px -1px 3px #656565;
|
2020-06-12 11:31:30 +08:00
|
|
|
}
|
|
|
|
.scriptPanelRight{
|
|
|
|
|
2020-06-11 18:32:26 +08:00
|
|
|
}
|
|
|
|
</style>
|