Commit e70097de authored by caicaicai's avatar caicaicai

修改

parent 6f25f3bf
......@@ -2,10 +2,10 @@ ENV = 'development'
# 接口地址
#VUE_APP_BASE_API = 'http://localhost:8000'
VUE_APP_BASE_API = 'http://192.168.0.110:8001'
VUE_APP_BASE_API = 'http://8.143.203.103:9090'
VUE_APP_WS_API = 'ws://192.168.0.111:8001/webSocket'
VUE_APP_LOCAL_API = 'http://192.168.0.110:8001'
VUE_APP_LOCAL_API2 = 'http://192.168.0.110:8001'
VUE_APP_LOCAL_API = 'http://8.143.203.103:9090'
VUE_APP_LOCAL_API2 = 'http://8.143.203.103:9090'
# 是否启用 babel-plugin-dynamic-import-node插件
VUE_CLI_BABEL_TRANSPILE_MODULES = true
......@@ -2,13 +2,6 @@
<div style="wight:100%;height:100%;">
<div :id="`mars3d-container${mapKey}`"
:class="['mars3d-container', customClass, { 'mars3d-container-compare-rh' : compare }]"></div>
<!-- <div class="infoview">
<el-button type="primary" @click="btnStartDraw()">设置围栏</el-button>
<el-button type="primary" @click="uploaded()">上传围栏</el-button>
<div style="display: inline-block;color:red;font-weight:bolder;">每次只允许上传一个围栏,并且围栏必须是封闭图形</div>
</div> -->
</div>
</template>
......@@ -157,35 +150,6 @@ export default {
that.zuobianData = data1
//console.log("zuobianData",that.zuobianData);
//console.log("weilanName",that.weilanName);
//后台获取数据——获取历史轨迹
this.getlishiguijiFn();
}
})
},
//后台获取数据——获取历史轨迹
getlishiguijiFn() {
let that = this;
HttpReq.truckDispatching.getAllHistroyCarTrajectoryQuery({name:that.deviceId}).then((res) => {
//console.log('获取历史轨迹',res);
if(res.code == 200){
let obj1 = {};
let array1 = [];
res.data.line.forEach((item,index)=>{
let array2 = [];
array2.push(item.location.x);
array2.push(item.location.y);
array2.push('500');
array1.push(array2);
})
obj1.name = res.data.name;
obj1.arrays = array1;
let hisCenterData = [...that.historyTrajectoryData];
hisCenterData.push(obj1);
that.historyTrajectoryData = [...hisCenterData];
this.$nextTick(()=>{
if (this.appendToBody) {
document.body.appendChild(this.$el)
......@@ -198,60 +162,21 @@ export default {
})
}
})
}
}
})
},
//上传围栏数据
uploaded(){
let newData = [...this.toJavaCoordinates];
newData.pop();
if(this.toJavaCoordinates.length == 0){
this.$message({
type: 'warning',
message: '请绘制电子围栏'
});
}else{
this.$prompt('电子围栏名称不得为空且不能与之前围栏名称重复', '请输入电子围栏名称', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputErrorMessage: '输入不能为空',
inputValidator: (value) => { // 点击按钮时,对文本框里面的值进行验证
if(!value) {
return '输入不能为空';
}
},
}).then(({ value }) => {
let allObj = {};
allObj.name = value;
allObj.zuobiao = newData;
this.toJavaCoordinates = [];
console.log(allObj);
//发送添加电子围栏请求
HttpReq.truckDispatching.screenMapSetUpAdd(allObj).then((res) => {
if(res.code == 200){
this.$notify({
title: '上传电子围栏成功!',
type: 'success',
duration: 2500
});
}else{
this.$notify({
title: res.msg,
type: 'error',
duration: 2500
})
}
}).catch(function(error) { });
}).catch(() => {
this.$message({
type: 'info',
message: '取消输入'
});
});
}
//后台获取数据——获取实时位置
getlishiguijiFn() {
let that = this;
HttpReq.truckDispatching.getCarTrajectoryQuery().then((res) => {
if(res.code == 200){
that.historyTrajectoryData = res.data;
}
})
},
//创建地图
initMars3d(options) {
let that = this;
......@@ -271,81 +196,22 @@ export default {
//围栏回显
that.zuobianData.forEach(function(item,index){
console.log(item);
//console.log(item);
var graphicLayer = new mars3d.layer.GraphicLayer();
map.addLayer(graphicLayer);
initLayerManager(graphicLayer,that.weilanName[index]);
that.addGraphic_01(graphicLayer,item,that.weilanName[index]);
})
//历史轨迹回放
// that.historyTrajectoryData.forEach(function(item,index){
// var graphicLayer2 = new mars3d.layer.GraphicLayer();
// map.addLayer(graphicLayer2);
// var itemText = `<table style="width: auto;">
// <tr>
// <th scope="col" colspan="2" style="text-align:center;font-size:15px;">卡车号码:${item.name}</th>
// </tr>
// <tr>
// <td>名称:卡车二</td>
// </tr>
// </table>`;
// initGraphicManager(graphicLayer2,itemText);
// that.addGraphic_02(graphicLayer2,item.arrays,item.name);
// })
//创建矢量数据图层2
var graphicLayer1 = new mars3d.layer.GraphicLayer();
map.addLayer(graphicLayer1);
var itemText = `<table style="width: auto;">
<tr>
<th scope="col" colspan="2" style="text-align:center;font-size:15px;">卡车号码:鲁K12345</th>
</tr>
<tr>
<td>名称:卡车一</td>
</tr>
</table>`;
initGraphicManager(graphicLayer1,itemText);
//that.addGraphic_02(graphicLayer1,this.persons,'卡车一');
//创建矢量数据图层4
//实时位置
var graphicLayer4 = new mars3d.layer.GraphicLayer();
map.addLayer(graphicLayer4)
that.addDemoGraphics(graphicLayer4);
//that.addDemoGraphics(graphicLayer4);
// 抛出事件
this.$emit('onload', map)
},
//围栏设置
btnStartDraw(){
this.toJavaCoordinates = [];
let that = this;
var graphicLayer3 = new mars3d.layer.GraphicLayer();
graphicLayer3.on(mars3d.EventType.click, function (event) {
var mpt = mars3d.LatLngPoint.fromCartesian(event.cartesian);
that.toJavaCoordinates.push(mpt.toString().split(','));
console.log(that.toJavaCoordinates);
});
map.addLayer(graphicLayer3);
initLayerManager(graphicLayer3);
graphicLayer3.startDraw({
type: "polyline",
style: {
color: "red",
width: 5,
clampToGround: false,
label: {
text: "围栏区域",
font_size: 18,
color: "#ffffff",
distanceDisplayCondition: true,
distanceDisplayCondition_far: 500000,
distanceDisplayCondition_near: 0,
},
},
});
},
//围栏回显
addGraphic_01(graphicLayer,positions,weilanName){
let graphic = new mars3d.graphic.PolygonEntity({
......@@ -368,54 +234,6 @@ export default {
});
graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
},
//车辆轨迹
addGraphic_02(graphicLayer1,positions,truckName) {
var property = new Cesium.SampledPositionProperty();
var tempTime;
//起点
tempTime = map.clock.currentTime; //开始时间
property.addSample(tempTime, Cesium.Cartesian3.fromDegrees(positions[0][0],positions[0][1],positions[0][2]));
for(let i = 1;i < positions.length;i++){
tempTime = Cesium.JulianDate.addSeconds(tempTime, 120, new Cesium.JulianDate());
property.addSample(tempTime, Cesium.Cartesian3.fromDegrees(positions[i][0],positions[i][1],positions[i][2],));
}
var graphic = new mars3d.graphic.PathEntity({
position: property,
style: {
width: 3,
color: "#8a2e3b",
opacity: 1.0,
leadTime: 0, // 前方的路线不显示
//高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
highlight: {
type: mars3d.EventType.click,
color: "#ff0000",
},
},
label: {
text: truckName,
font_size: 19,
font_family: "楷体",
color: Cesium.Color.AZURE,
outline: true,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 2,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
pixelOffset: new Cesium.Cartesian2(10, -25), //偏移量
},
model: {
url: "//data.mars3d.cn/gltf/mars/car/tufangche.glb",
scale: 0.1,
minimumPixelSize: 50,
},
});
graphicLayer1.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
},
getSampledPositionProperty(points){
let property = new Cesium.SampledPositionProperty();
let start = this.map.clock.currentTime;
......@@ -427,8 +245,10 @@ export default {
}
return property;
},
//实时位置
addDemoGraphics(graphicLayer4) {
let that = this;
for (let i = 0; i < 1; i++) {
const graphic = new mars3d.graphic.ModelPrimitive({
style: {
......@@ -478,11 +298,12 @@ export default {
},
// 取区域内的随机点
randomPoint() {
const jd = this.random(117.130666 * 1000, 117.130241 * 1000) / 1000
const wd = this.random(36.655207 * 1000, 36.665207 * 1000) / 1000
console.log("jd",jd);
console.log("wd",wd);
return Cesium.Cartesian3.fromDegrees(jd, wd, 500)
this.getlishiguijiFn()
// const jd = this.random(117.130666 * 1000, 117.130241 * 1000) / 1000
// const wd = this.random(36.655207 * 1000, 36.665207 * 1000) / 1000
// console.log("jd",jd);
// console.log("wd",wd);
// return Cesium.Cartesian3.fromDegrees(jd, wd, 500)
},
random(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
......
......@@ -21,8 +21,8 @@
<div class="content">
<el-table :data="tableData" v-loading="loading" border style="width:auto" :row-class-name="tableRowClassName">
<el-table-column prop="banci" label="班次" align="center"></el-table-column>
<el-table-column prop="startTime" label="开始时间" align="center"></el-table-column>
<el-table-column prop="endTime" label="结束时间" align="center"></el-table-column>
<el-table-column prop="startTime" label="开始时间" align="center" :formatter="currentTime1"></el-table-column>
<el-table-column prop="endTime" label="结束时间" align="center" :formatter="currentTime2"></el-table-column>
<el-table-column label="操作" align="center" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="primary" icon="el-icon-edit" @click="toEdit(scope.row)"></el-button>
......@@ -45,10 +45,10 @@
<el-input v-model="form.item.banci" style="width:220px;" placeholder="请输入班次"/>
</el-form-item>
<el-form-item label="开始时间" prop="startTime">
<el-time-picker v-model="form.item.startTime" placeholder="任意时间点"></el-time-picker>
<el-date-picker type="datetime" v-model="form.item.startTime" placeholder="任意时间点"></el-date-picker>
</el-form-item>
<el-form-item label="结束时间" prop="endTime">
<el-time-picker v-model="form.item.endTime" placeholder="任意时间点"></el-time-picker>
<el-date-picker type="datetime" v-model="form.item.endTime" placeholder="任意时间点"></el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
......@@ -77,8 +77,8 @@ export default {
tableData: [],
form: {
title:'新增班次',
visible:false,
reqType:'add',
visible:false,
reqType:'add',
status:{cu:0},
item:{},
},
......@@ -158,8 +158,8 @@ export default {
this.form.status.cu = 0;
this.form.visible = true;
this.form.item = {...item};
this.form.item.startTime = '';
this.form.item.endTime = '';
this.form.item.startTime = '';
this.form.item.endTime = '';
this.form.reqType = 'edit';
this.ShiftId = this.form.item.id;
},
......@@ -202,8 +202,8 @@ export default {
//新增班次
reqAddItem(form, item){
let lastData = {...item};
lastData.startTime = this.currentTime(lastData.startTime);
lastData.endTime = this.currentTime(lastData.endTime);
lastData.startTime = lastData.startTime;
lastData.endTime = lastData.endTime;
HttpReq.truckDispatching.shiftAdd(lastData).then((res) => {
form.visible = false;
if(res.code == 200){
......@@ -227,8 +227,8 @@ export default {
//修改班次
reqUpdateItem(form, item){
let lastData = {...item};
lastData.startTime = this.currentTime(lastData.startTime);
lastData.endTime = this.currentTime(lastData.endTime);
lastData.startTime = lastData.startTime;
lastData.endTime = lastData.endTime;
lastData.id = this.ShiftId;
HttpReq.truckDispatching.shiftUpdate(lastData).then((res) => {
form.visible = false;
......@@ -269,27 +269,73 @@ export default {
this.loadData();
})
},
//转换时间
currentTime(time){
var date = new Date(time);
var hours = date.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
var minutes = date.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
var seconds = date.getSeconds(); //秒 ,返回 Date 对象的秒数 (0 ~ 59)
//修改小时格式
if (hours >= 0 && hours <= 9) {
hours = "0" + hours;
}
//修改分钟格式
if (minutes >= 0 && minutes <= 9) {
minutes = "0" + minutes;
}
//修改秒格式
if (seconds >= 0 && seconds <= 9) {
seconds = "0" + seconds;
}
let currentFormatDate = hours + ":" + minutes + ":" + seconds;
return currentFormatDate;
},
//转换时间
currentTime1(row){
var date = new Date(row.startTime);
var year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
var month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
var day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
var hours = date.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
var minutes = date.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
var seconds = date.getSeconds(); //秒 ,返回 Date 对象的秒数 (0 ~ 59)
//修改月份格式
if (month >= 1 && month <= 9) {
month = "0" + month;
}
//修改日期格式
if (day >= 0 && day <= 9) {
day = "0" + day;
}
//修改小时格式
if (hours >= 0 && hours <= 9) {
hours = "0" + hours;
}
//修改分钟格式
if (minutes >= 0 && minutes <= 9) {
minutes = "0" + minutes;
}
//修改秒格式
if (seconds >= 0 && seconds <= 9) {
seconds = "0" + seconds;
}
//获取当前系统时间 格式(yyyy-mm-dd hh:mm:ss)
let currentFormatDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
//console.log(currentFormatDate);
return currentFormatDate;
},
currentTime2(row){
var date = new Date(row.endTime);
var year = date.getFullYear(); //年 ,从 Date 对象以四位数字返回年份
var month = date.getMonth() + 1; //月 ,从 Date 对象返回月份 (0 ~ 11) ,date.getMonth()比实际月份少 1 个月
var day = date.getDate(); //日 ,从 Date 对象返回一个月中的某一天 (1 ~ 31)
var hours = date.getHours(); //小时 ,返回 Date 对象的小时 (0 ~ 23)
var minutes = date.getMinutes(); //分钟 ,返回 Date 对象的分钟 (0 ~ 59)
var seconds = date.getSeconds(); //秒 ,返回 Date 对象的秒数 (0 ~ 59)
//修改月份格式
if (month >= 1 && month <= 9) {
month = "0" + month;
}
//修改日期格式
if (day >= 0 && day <= 9) {
day = "0" + day;
}
//修改小时格式
if (hours >= 0 && hours <= 9) {
hours = "0" + hours;
}
//修改分钟格式
if (minutes >= 0 && minutes <= 9) {
minutes = "0" + minutes;
}
//修改秒格式
if (seconds >= 0 && seconds <= 9) {
seconds = "0" + seconds;
}
//获取当前系统时间 格式(yyyy-mm-dd hh:mm:ss)
let currentFormatDate = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
//console.log(currentFormatDate);
return currentFormatDate;
},
}
}
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment