rt-sim-training-client/src/views/jlmap3d/edit/jlmap3dedit.vue

248 lines
6.5 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div id="editdiv" class="editdiv">
<div id="testdraw" class="testdraw">
</div>
2020-07-10 09:17:00 +08:00
<Edit-Action ref="action" @saction="saction" @actionevent="actionevent">
2019-07-26 13:32:43 +08:00
</Edit-Action>
<Edit-Property ref="property" :selectmodel='selectmodel'>
</Edit-Property>
<Edit-Assets ref="assets" @smodel="smodel" @stexture="stexture">
</Edit-Assets>
2019-09-25 14:49:25 +08:00
<Edit-Menu ref="menu" @transpos="transpos" @transrota="transrota" @transscal="transscal" @vexscal= "vexscal" @testrail="testrail" @autoss="autoss" @expo="expo" @save="save"
@savetest="savetest" @back="back">
2019-07-26 13:32:43 +08:00
</Edit-Menu>
<canvas id="canvastexture" width="128px" height="64px"></canvas>
</div>
</template>
<script>
import Vue from 'vue';
import localStore from 'storejs';
import { mapGetters } from 'vuex';
import SetTime from '@/views/display/demon/setTime';
import { getTrainingCbtcDemon, setTrainingCbtcInitTime } from '@/api/simulation';
import { UrlConfig } from '@/scripts/ConstDic';
2019-07-26 13:32:43 +08:00
2019-08-13 16:23:46 +08:00
import { JLmap3dEdit } from '@/jlmap3d/edit/jlmap3dedit';
2019-07-26 13:32:43 +08:00
import axios from 'axios';
import { update3dMapData } from '@/api/jlmap3d/load3ddata'
import { getmodels } from '@/jlmap3d/edit/connect/newgetmodels';
2020-07-10 09:17:00 +08:00
import { testgetmodels } from '@/jlmap3d/edit/connect/testgetmodels';
2019-07-26 13:32:43 +08:00
//components
2019-08-12 18:37:43 +08:00
import EditProperty from '@/views/jlmap3d/edit/component/property';
import EditAction from '@/views/jlmap3d/edit/component/action';
import EditAssets from '@/views/jlmap3d/edit/component/assets';
import EditMenu from '@/views/jlmap3d/edit/component/menu';
2019-07-26 13:32:43 +08:00
var train;
export default {
name: 'EditTest',
components: {
EditProperty,
EditAction,
EditAssets,
EditMenu
},
data() {
return {
mapid: this.$route.query.mapid,
isDisable: false,
tryTime: 0, // 进入页面多少秒
timeNow: 0, // 进入页面 相对时间
time: null, // 定时器
countTime: 0, // 显示 倒计时
remainingTime: 0,
goodsId: this.$route.query.goodsId,
try: this.$route.query.try, // 是否是试用权限
training: {
id: '',
name: '',
remarks: ''
},
offset: 15,
mapdata: null,
jlmap3dedit: null,
selectmodel: null
}
},
computed: {
},
watch: {
'jlmap3dedit.selectmodel.code': {
deep: true,
handler: function (newVal, oldVal) {
if (newVal != oldVal) {
this.selectmodel = this.jlmap3dedit.selectmodel;
this.$refs.property.switchproperty();
//console.log(this.jlmap3dedit.selectmodel);
}
}
},
'jlmap3dedit.selectmodel.position': {
deep: true,
handler: function (newVal, oldVal) {
//console.log(this.jlmap3dedit.selectmodel);
if (this.jlmap3dedit.selectmodel) {
this.selectmodel = this.jlmap3dedit.selectmodel;
if (this.selectmodel.name == "linehelper") {
this.selectmodel.parent.geometry.vertices[this.selectmodel.num].x = this.selectmodel.position.x;
this.selectmodel.parent.geometry.vertices[this.selectmodel.num].z = this.selectmodel.position.z;
this.selectmodel.parent.geometry.verticesNeedUpdate = true;
}
}
}
}
},
2020-07-10 09:17:00 +08:00
mounted() {
this.init();
window.changeEditAssetList = this.changeEditAssetList;
},
2019-07-26 13:32:43 +08:00
beforeDestroy() {
if (this.jlmap3dedit) {
this.jlmap3dedit = null;
}
},
methods: {
2020-07-10 09:17:00 +08:00
changeEditAssetList(newList){
this.jlmap3dedit.assetManager = newList;
},
2019-07-26 13:32:43 +08:00
show: function () {
},
init: function () {
//console.log(this.mapid);
let mapdata = this.$store.getters['map/map'];
console.log(mapdata);
2019-07-26 13:32:43 +08:00
let dom = document.getElementById('testdraw');
this.jlmap3dedit = new JLmap3dEdit(dom, mapdata, this.mapid);
//this.jlmap3dedit.eventon();
},
saction(editmode) {
//console.log(editmode);
this.jlmap3dedit.transcontrol.detach();
this.jlmap3dedit.editmode = editmode;
this.jlmap3dedit.actionmode = editmode;
//this.jlmap3dedit.actionmode();
this.$refs.assets.toggleList(editmode);
2019-07-26 13:32:43 +08:00
},
actionevent(eventname) {
//console.log(eventname);
this.jlmap3dedit.actionmode = eventname;
this.jlmap3dedit.actiommode(eventname);
},
smodel(changedata) {
console.log(changedata);
this.jlmap3dedit.actiommode(changedata);
},
stexture(textureurl) {
//console.log(modelurl);
},
transpos() {
this.jlmap3dedit.transcontrol.setMode('translate');
2019-09-25 14:49:25 +08:00
this.jlmap3dedit.vexscaloff();
2019-07-26 13:32:43 +08:00
},
transrota() {
this.jlmap3dedit.transcontrol.setMode('rotate');
2019-09-25 14:49:25 +08:00
this.jlmap3dedit.vexscaloff();
2019-07-26 13:32:43 +08:00
},
transscal() {
this.jlmap3dedit.transcontrol.setMode('scale');
2019-09-25 14:49:25 +08:00
this.jlmap3dedit.vexscaloff();
},
vexscal(){
this.jlmap3dedit.transcontrol.detach();
this.jlmap3dedit.vexscal();
console.log("vexscal");
},
testrail(){
this.jlmap3dedit.testrail();
},
autoss(){
this.jlmap3dedit.autoss();
2019-07-26 13:32:43 +08:00
},
expo() {
this.jlmap3dedit.export();
},
save() {
//console.log("save");
2020-07-10 09:17:00 +08:00
console.log(this.jlmap3dedit.assetManager);
2019-07-26 13:32:43 +08:00
let param = getmodels(this.jlmap3dedit);
update3dMapData(param).then(data => {
//console.log(data);
if (data.code == "200") {
alert("保存成功");
}
}).catch(error => {
console.log(error);
});
},
savetest(){
2020-07-10 09:17:00 +08:00
console.log(this.jlmap3dedit.assetManager);
let param = testgetmodels(this.jlmap3dedit);
2020-07-10 18:13:09 +08:00
update3dMapData(param).then(data => {
//console.log(data);
if (data.code == "200") {
alert("保存成功");
}
}).catch(error => {
console.log(error);
});
},
2019-07-26 13:32:43 +08:00
back() {
//console.log("back");
history.go(-1);
}
},
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
* {
touch-action: none;
}
.editdiv {
width: 100%;
height: 100%;
}
.testdraw {
float: left;
//left:20%;
position: absolute;
width: 100%;
height: 100%;
z-inde: -1;
}
</style>