2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
2019-09-02 15:37:57 +08:00
|
|
|
<div class="reminder-drag">
|
2019-11-01 15:19:15 +08:00
|
|
|
<div ref="drapBox" class="reminder-box" :style="{width: width + 'px'}">
|
2019-09-02 15:37:57 +08:00
|
|
|
<el-container class="actionPane">
|
2019-11-01 15:19:15 +08:00
|
|
|
<el-header style="height: 50px;">
|
2019-09-02 15:37:57 +08:00
|
|
|
<el-row class="actionList">
|
2019-09-10 17:32:41 +08:00
|
|
|
<span class="titleStyle">{{ $t('scriptRecord.scriptRecordTitle') }}</span>
|
2019-10-31 13:56:42 +08:00
|
|
|
<span class="titleStyle">( {{ $t('scriptRecord.language') }}: {{ $route.query.lang=="en"?$t('scriptRecord.english'):$t('scriptRecord.chinese') }} )</span>
|
2019-09-02 15:37:57 +08:00
|
|
|
</el-row>
|
|
|
|
</el-header>
|
|
|
|
<el-main style="padding-top:10px;padding-bottom:10px;">
|
|
|
|
<add-role ref="addRole" :group="group" @refresh="refresh" />
|
|
|
|
<add-action ref="addAction" :group="group" :size="size" @create="create" @setDisabled="setDisabled" />
|
|
|
|
<get-action ref="getAction" :group="group" :size="size" @setAction="setAction" />
|
|
|
|
</el-main>
|
2019-10-15 15:24:41 +08:00
|
|
|
<el-card class="scriptFooter">
|
2019-09-02 15:37:57 +08:00
|
|
|
<el-button-group class="button-group">
|
2019-09-10 17:32:41 +08:00
|
|
|
<el-button v-if="isPause" type="primary" :disabled="executeDisabled" @click="pauseScript">{{ $t('scriptRecord.drivingPause') }}</el-button>
|
|
|
|
<el-button v-else type="primary" :disabled="executeDisabled" @click="executePlayScript">{{ $t('scriptRecord.recoverAndExecute') }}</el-button>
|
|
|
|
<el-button type="danger" @click="dumpScenesData">{{ $t('scriptRecord.resetScript') }}</el-button>
|
2019-09-02 15:37:57 +08:00
|
|
|
<el-button type="primary" :disabled="backDisabled" @click="saveScenesStage">{{ $t('scriptRecord.saveBackground') }}</el-button>
|
|
|
|
<el-button type="success" :loading="isSavingScript" @click="saveScenesData">{{ $t('scriptRecord.saveData') }}</el-button>
|
|
|
|
</el-button-group>
|
2019-10-15 15:24:41 +08:00
|
|
|
</el-card>
|
2019-09-02 15:37:57 +08:00
|
|
|
</el-container>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-07-26 13:32:43 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
2019-08-20 12:47:39 +08:00
|
|
|
import Vue from 'vue';
|
2019-08-22 18:13:55 +08:00
|
|
|
import AddAction from '../scriptRecord/addAction';
|
2019-08-20 15:41:54 +08:00
|
|
|
import GetAction from '../scriptRecord/getAction';
|
2019-08-22 18:13:55 +08:00
|
|
|
import AddRole from '../scriptRecord/addRole';
|
2020-05-19 09:45:15 +08:00
|
|
|
import {getDraftScriptByGroupNew} from '@/api/script';
|
2020-05-11 11:31:55 +08:00
|
|
|
import {saveScriptScenes, saveScriptScenesNew, saveScriptData, saveScriptDataNew, dumpScriptData, dumpScriptDataNew, updateMapLocation, updateMapLocationNew, scriptPause, simulationPause, executeScript, executeScriptNew} from '@/api/simulation';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-09-02 15:37:57 +08:00
|
|
|
export default {
|
2019-10-31 13:56:42 +08:00
|
|
|
name: 'TipScriptRecord',
|
|
|
|
components: {
|
|
|
|
GetAction,
|
|
|
|
AddRole,
|
|
|
|
AddAction
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
group: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
width: {
|
|
|
|
type: Number || String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
title: this.$t('scriptRecord.scriptRecordTitle'),
|
|
|
|
isShrink: false,
|
|
|
|
mapLocation: {},
|
|
|
|
autoSaveScript: null,
|
|
|
|
isSavingScript: false,
|
|
|
|
isPause: true,
|
|
|
|
executeDisabled: false,
|
|
|
|
backDisabled: false,
|
|
|
|
size: {
|
|
|
|
width: 350,
|
|
|
|
height: window.innerHeight - 342
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
2020-05-14 14:36:15 +08:00
|
|
|
computed:{
|
|
|
|
drawWay() {
|
|
|
|
const drawWay = this.$route.query.drawWay;
|
|
|
|
return drawWay && JSON.parse(drawWay);
|
|
|
|
}
|
|
|
|
},
|
2019-10-31 13:56:42 +08:00
|
|
|
watch: {
|
|
|
|
'$store.state.scriptRecord.bgSet': function (val) {
|
|
|
|
this.backDisabled = val;
|
|
|
|
},
|
|
|
|
'$store.state.app.windowSizeCount': function() {
|
|
|
|
this.size = { width: 350, height: window.innerHeight - 342};
|
|
|
|
},
|
|
|
|
width: function(val) {
|
|
|
|
this.size = { width: val / 2 - 20, height: window.innerHeight - 342};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-03-30 16:16:11 +08:00
|
|
|
// this.initAutoSaveScript();
|
2020-05-19 09:45:15 +08:00
|
|
|
if (this.drawWay) {
|
|
|
|
getDraftScriptByGroupNew(this.group).then(response=>{
|
|
|
|
this.backDisabled = response.data.bgSet;
|
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', response.data.bgSet);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.backDisabled = this.$store.state.scriptRecord.bgSet;
|
|
|
|
}
|
|
|
|
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.clearAutoSave();
|
2020-05-19 14:01:23 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', false);
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setIsParse(isPause) {
|
|
|
|
this.isPause = isPause;
|
|
|
|
},
|
|
|
|
setDisabled(data) {
|
|
|
|
this.executeDisabled = !data;
|
|
|
|
},
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pauseScript() {
|
2020-05-14 14:36:15 +08:00
|
|
|
if (this.drawWay) {
|
2020-05-11 11:31:55 +08:00
|
|
|
simulationPause(this.group).then(resp => {
|
|
|
|
this.$store.dispatch('scriptRecord/updateSimulationPause', true);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.pauseFail'));
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
scriptPause(this.group).then(resp => {
|
|
|
|
this.$store.dispatch('scriptRecord/updateSimulationPause', true);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.pauseFail'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
executePlayScript() {
|
2020-05-14 14:36:15 +08:00
|
|
|
if (this.drawWay) {
|
2020-05-11 11:31:55 +08:00
|
|
|
executeScriptNew(this.group).then(resp => {
|
|
|
|
this.$store.dispatch('scriptRecord/updateSimulationPause', false);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.recoverFail'));
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
executeScript(this.group).then(resp => {
|
|
|
|
this.$store.dispatch('scriptRecord/updateSimulationPause', false);
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.recoverFail'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-31 13:56:42 +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-05-14 14:36:15 +08:00
|
|
|
if (this.drawWay) {
|
2020-05-11 10:44:00 +08:00
|
|
|
saveScriptScenesNew(this.group).then(resp => {
|
2020-05-11 11:31:55 +08:00
|
|
|
updateMapLocationNew(group, dataZoom).then(response=>{
|
2020-05-11 10:44:00 +08:00
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', true);
|
|
|
|
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}`);
|
2019-10-31 13:56:42 +08:00
|
|
|
});
|
2020-05-11 10:44:00 +08:00
|
|
|
} else {
|
|
|
|
saveScriptScenes(this.group).then(resp => {
|
|
|
|
updateMapLocation(group, dataZoom).then(response=>{
|
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', true);
|
|
|
|
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}`);
|
|
|
|
});
|
|
|
|
}
|
2019-08-20 13:21:38 +08:00
|
|
|
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
saveScenesData() {
|
|
|
|
this.isSavingScript = true;
|
2020-05-14 14:36:15 +08:00
|
|
|
if (this.drawWay) {
|
2020-03-27 17:29:01 +08:00
|
|
|
saveScriptDataNew(this.group).then(resp => {
|
|
|
|
this.$message.success(this.$t('scriptRecord.saveDataSucess'));
|
|
|
|
this.isSavingScript = false;
|
2020-03-30 16:56:38 +08:00
|
|
|
// this.initAutoSaveScript();
|
2020-03-27 17:29:01 +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 {
|
2020-03-30 16:56:38 +08:00
|
|
|
// this.initAutoSaveScript();
|
2020-03-27 17:29:01 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
saveScriptData(this.group).then(resp => {
|
|
|
|
this.$message.success(this.$t('scriptRecord.saveDataSucess'));
|
|
|
|
this.isSavingScript = false;
|
2020-03-30 16:56:38 +08:00
|
|
|
// this.initAutoSaveScript();
|
2020-03-27 17:29:01 +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 {
|
2020-03-30 16:56:38 +08:00
|
|
|
// this.initAutoSaveScript();
|
2020-03-27 17:29:01 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-10-31 13:56:42 +08:00
|
|
|
},
|
|
|
|
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(() => {
|
2020-05-14 14:36:15 +08:00
|
|
|
if (this.drawWay) {
|
2020-03-30 16:56:38 +08:00
|
|
|
dumpScriptDataNew(group).then(resp => {
|
|
|
|
this.$parent.$refs['display'].$refs['menuScript'].resetBeginTime();
|
|
|
|
this.$refs['getAction'].loadInitData();
|
|
|
|
this.$refs['addRole'].initData();
|
|
|
|
this.$refs['addAction'].initData();
|
|
|
|
this.$refs['addAction'].resetData();
|
|
|
|
// this.initAutoSaveScript();
|
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', false);
|
|
|
|
this.$message.success(this.$t('scriptRecord.resetDataSuccess'));
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.resetDataFail'));
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
dumpScriptData(group).then(resp => {
|
|
|
|
this.$parent.$refs['display'].$refs['menuScript'].resetBeginTime();
|
|
|
|
this.$refs['getAction'].loadInitData();
|
|
|
|
this.$refs['addRole'].initData();
|
|
|
|
this.$refs['addAction'].initData();
|
|
|
|
this.$refs['addAction'].resetData();
|
|
|
|
// this.initAutoSaveScript();
|
|
|
|
this.$store.dispatch('scriptRecord/updateBgSet', false);
|
|
|
|
this.$message.success(this.$t('scriptRecord.resetDataSuccess'));
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('scriptRecord.resetDataFail'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-31 13:56:42 +08:00
|
|
|
}).catch(() => {
|
2020-03-30 16:56:38 +08:00
|
|
|
// this.initAutoSaveScript();
|
2019-10-31 13:56:42 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
refresh() {
|
|
|
|
this.$refs['addAction'].initData();
|
|
|
|
},
|
|
|
|
create() {
|
|
|
|
this.$refs['getAction'].loadInitData();
|
|
|
|
},
|
|
|
|
setAction(row) {
|
|
|
|
this.$refs['addAction'].doShow(row);
|
|
|
|
}
|
|
|
|
}
|
2019-09-02 15:37:57 +08:00
|
|
|
};
|
2019-07-26 13:32:43 +08:00
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
2019-10-15 15:24:41 +08:00
|
|
|
.reminder-drag{
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
|
|
|
|
.reminder-box {
|
|
|
|
position: absolute;
|
|
|
|
float: left;
|
2019-08-20 13:21:38 +08:00
|
|
|
left: 0px;
|
|
|
|
top:0px;
|
2019-11-01 15:19:15 +08:00
|
|
|
height: 100%;
|
2019-07-26 13:32:43 +08:00
|
|
|
background-color: #fff;
|
|
|
|
overflow: hidden;
|
|
|
|
z-index: 10;
|
|
|
|
font-size: 18px;
|
|
|
|
|
2019-08-20 13:21:38 +08:00
|
|
|
.actionPane{
|
|
|
|
height: 100%;
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
2019-09-02 15:37:57 +08:00
|
|
|
|
2019-08-20 13:21:38 +08:00
|
|
|
.button-group{
|
2019-10-15 15:24:41 +08:00
|
|
|
margin: 8px;
|
2019-08-22 18:13:55 +08:00
|
|
|
float: right;
|
2019-08-20 13:21:38 +08:00
|
|
|
}
|
2019-08-22 18:13:55 +08:00
|
|
|
|
2019-08-20 13:21:38 +08:00
|
|
|
.actionList{
|
|
|
|
margin-top: 10px;
|
|
|
|
font-size: 15px;
|
2019-08-22 18:13:55 +08:00
|
|
|
padding-top: 5px;
|
|
|
|
border-bottom: 1px #ccc solid;
|
|
|
|
height: 35px;
|
2019-08-20 13:21:38 +08:00
|
|
|
}
|
|
|
|
.titleStyle{
|
2019-08-22 18:13:55 +08:00
|
|
|
margin-left:5px;
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
float: right;
|
|
|
|
margin-right: 10px;
|
|
|
|
cursor: pointer;
|
|
|
|
background-color: #f3f3f3;
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
|
|
|
|
/deep/ {
|
|
|
|
.el-tree-node__content {
|
|
|
|
margin-bottom: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
|
|
|
|
background-color: #d6e5f7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-20 12:47:39 +08:00
|
|
|
</style>
|