Commit 03291bc1 by jack

1.3.0

1 parent c44c4bac
This diff could not be displayed because it is too large.
......@@ -101,8 +101,9 @@ export default {
addPOI(request = {}) {
return api.post('vepoi/add', request)
},
getPOI(request = {}) {
return api.get('vepoi/getVehiclePoi', request)
getPOI(params = {}) {
//return api.get('vepoi/getVehiclePoi', request)
return request(params, '/vepoi/getVehiclePoi', 'get')
},
deletePOI(request = {}) {
return api.get('vepoi/del/'+request.id)
......
......@@ -52,6 +52,13 @@ export default {
getOrgTree(params) {
return request(params, '/usercenter/organization/orgtree')
},
// 根据sn 获取围栏信息接口
getFenceInfo(params) {
return request(params, '/trialdrive/fence/getBySn')
},
// 旧虎哥
/*车辆监控*/
// getCriteriaTreeList (request = {}) {
......
.icon {display: inline-block;background-image: url(~sprite.png);background-size: 119px 97px; vertical-align: middle;}
.icon-battery_empty { width: 42px; height: 20px; background-position: 0px 0px; }
.icon-battery_enough { width: 42px; height: 20px; background-position: 0px -20px; }
.icon-fullsize.active { width: 18px; height: 18px; background-position: -18px -79px; }
.icon-fullsize:active { width: 18px; height: 18px; background-position: -18px -79px; }
.icon-fullsize:hover { background-position: -18px -79px; }
.icon-fullsize { width: 18px; height: 18px; background-position: 0px -79px; }
.icon-icon_zoom_out.active { width: 18px; height: 18px; background-position: -72px -79px; }
.icon-icon_zoom_out:active { width: 18px; height: 18px; background-position: -72px -79px; }
.icon-icon_zoom_out:hover { background-position: -72px -79px; }
.icon-fullsize.active { width: 18px; height: 18px; background-position: 0px -79px; }
.icon-fullsize:active { width: 18px; height: 18px; background-position: 0px -79px; }
.icon-fullsize:hover { background-position: 0px -79px; }
.icon-fullsize { width: 18px; height: 18px; background-position: -18px -79px; }
.icon-icon_zoom_out.active { width: 18px; height: 18px; background-position: -36px -79px; }
.icon-icon_zoom_out:active { width: 18px; height: 18px; background-position: -36px -79px; }
.icon-icon_zoom_out:hover { background-position: -36px -79px; }
.icon-icon_zoom_out { width: 18px; height: 18px; background-position: -54px -79px; }
.icon-info_copy.active { width: 16px; height: 16px; background-position: -101px -36px; }
.icon-info_copy:active { width: 16px; height: 16px; background-position: -101px -36px; }
.icon-info_copy:hover { background-position: -101px -36px; }
.icon-info_copy { width: 16px; height: 16px; background-position: -101px -52px; }
.icon-info_device_alarm { width: 20px; height: 20px; background-position: -62px -20px; }
.icon-info_device_status { width: 20px; height: 20px; background-position: -62px 0px; }
.icon-info_device { width: 20px; height: 20px; background-position: -40px -40px; }
.icon-info_device_alarm { width: 20px; height: 20px; background-position: -42px 0px; }
.icon-info_device_status { width: 20px; height: 20px; background-position: -42px -20px; }
.icon-info_device { width: 20px; height: 20px; background-position: 0px -40px; }
.icon-info_location { width: 20px; height: 20px; background-position: -20px -40px; }
.icon-info_stop { width: 20px; height: 20px; background-position: 0px -40px; }
.icon-info_time { width: 20px; height: 20px; background-position: -42px -20px; }
.icon-info_type { width: 20px; height: 20px; background-position: -42px 0px; }
.icon-locate.active { width: 19px; height: 19px; background-position: 0px -60px; }
.icon-locate:active { width: 19px; height: 19px; background-position: 0px -60px; }
.icon-locate:hover { background-position: 0px -60px; }
.icon-locate { width: 19px; height: 19px; background-position: -19px -60px; }
.icon-info_stop { width: 20px; height: 20px; background-position: -40px -40px; }
.icon-info_time { width: 20px; height: 20px; background-position: -62px 0px; }
.icon-info_type { width: 20px; height: 20px; background-position: -62px -20px; }
.icon-locate.active { width: 19px; height: 19px; background-position: -62px -40px; }
.icon-locate:active { width: 19px; height: 19px; background-position: -62px -40px; }
.icon-locate:hover { background-position: -62px -40px; }
.icon-locate { width: 19px; height: 19px; background-position: 0px -60px; }
.icon-minisize.active { width: 18px; height: 19px; background-position: -82px -19px; }
.icon-minisize:active { width: 18px; height: 19px; background-position: -82px -19px; }
.icon-minisize:hover { background-position: -82px -19px; }
.icon-minisize { width: 18px; height: 18px; background-position: -36px -79px; }
.icon-minisize { width: 18px; height: 18px; background-position: -72px -79px; }
.icon-refresh.active { width: 18px; height: 19px; background-position: -82px -38px; }
.icon-refresh:active { width: 18px; height: 19px; background-position: -82px -38px; }
.icon-refresh:hover { background-position: -82px -38px; }
.icon-refresh { width: 18px; height: 19px; background-position: -82px -57px; }
.icon-ruler.active { width: 19px; height: 19px; background-position: -57px -60px; }
.icon-ruler:active { width: 19px; height: 19px; background-position: -57px -60px; }
.icon-ruler:hover { background-position: -57px -60px; }
.icon-ruler { width: 19px; height: 19px; background-position: -82px 0px; }
.icon-ruler.active { width: 19px; height: 19px; background-position: -19px -60px; }
.icon-ruler:active { width: 19px; height: 19px; background-position: -19px -60px; }
.icon-ruler:hover { background-position: -19px -60px; }
.icon-ruler { width: 19px; height: 19px; background-position: -38px -60px; }
.icon-satellite.active { width: 18px; height: 18px; background-position: -101px 0px; }
.icon-satellite:active { width: 18px; height: 18px; background-position: -101px 0px; }
.icon-satellite:hover { background-position: -101px 0px; }
.icon-satellite { width: 18px; height: 18px; background-position: -101px -18px; }
.icon-zoom_in.active { width: 19px; height: 19px; background-position: -38px -60px; }
.icon-zoom_in:active { width: 19px; height: 19px; background-position: -38px -60px; }
.icon-zoom_in:hover { background-position: -38px -60px; }
.icon-zoom_in { width: 19px; height: 19px; background-position: -62px -40px; }
\ No newline at end of file
.icon-zoom_in.active { width: 19px; height: 19px; background-position: -57px -60px; }
.icon-zoom_in:active { width: 19px; height: 19px; background-position: -57px -60px; }
.icon-zoom_in:hover { background-position: -57px -60px; }
.icon-zoom_in { width: 19px; height: 19px; background-position: -82px 0px; }
\ No newline at end of file

8.81 KB | W: | H:

8.86 KB | W: | H:

src/assets/spritesmith-generated/sprite.png
src/assets/spritesmith-generated/sprite.png
src/assets/spritesmith-generated/sprite.png
src/assets/spritesmith-generated/sprite.png
  • 2-up
  • Swipe
  • Onion skin
<template>
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>车辆监控</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap" >
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<div class="search-box" :class="resultBoxHidden?'active':''">
<h3>轨迹回放</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="查询范围" prop="daterange">
<el-date-picker
class="pull-left"
style="width: 100%;"
v-model="form.dateRange"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
format="yyyy-MM-dd HH:mm"
:clearable="false"
:editable="false"
:picker-options="{
<v-full-layout>
<template slot="breadcrumb">
<el-breadcrumb-item>车辆监控</el-breadcrumb-item>
</template>
<template slot="main">
<div class="map-wrap">
<div id="map" class="map-container" v-loading="mapLoading"></div>
<map-controll></map-controll>
<div class="controll-wrap">
<div class="search-box" :class="resultBoxHidden?'active':''">
<h3>轨迹回放</h3>
<p class="info">{{name}}/{{standno}}/{{sn}}</p>
<el-form ref="form" :model="form" :rules="rules" :inline="false" size="mini" class="form">
<el-form-item label="查询范围" prop="daterange">
<el-date-picker class="pull-left" style="width: 100%;" v-model="form.dateRange" type="datetimerange" range-separator="至" start-placeholder="开始日期" format="yyyy-MM-dd HH:mm" :clearable="false" :editable="false" :picker-options="{
disabledDate(time){
return time.getTime() > (new Date()).getTime()
}
}"
end-placeholder="结束日期">
</el-date-picker>
<div class="pull-left">
<el-button size="mini" type="text" @click="pickDate(-6)">近6小时</el-button>
<el-button size="mini" type="text" @click="pickDate(3)">近3天</el-button>
<el-button size="mini" type="text" @click="pickDate(90)">近90天</el-button>
</div>
</el-form-item>
<el-form-item label="播放速度">
<el-select v-model="form.replaySpeed" placeholder="请选择" style="width: 80px">
<el-option
v-for="item in form.speedOpts"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="定位类型">
<el-select v-model="form.replayType" placeholder="请选择" style="width: 80px">
<el-option
v-for="item in form.replayTypeOpts"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
<p>
<el-button size="mini"
type="primary"
v-show="!replayIng"
@click="replayStart"
:loading="replayIniting">播放 <i class="fa fa-play"></i>
</el-button>
<el-button
size="mini"
type="primary"
@click="replayPause"
v-show="replayIng"
class="clearMargin">暂停 <i class="fa fa-pause"></i>
</el-button>
<el-button
size="mini"
@click="replayReresh"
type="primary" ><i class="fa fa-refresh"></i>
</el-button>
</p>
<p>
<el-button size="mini" type="primary" plain @click="exportReplay" :loading="exporting">导出轨迹(.csv) <i class="fa fa-download"></i></el-button>
<el-button size="mini" type="primary" plain @click="resultBoxHidden=false">停留点</el-button>
</p>
<p class="replay-addr" v-show="replayAddr">暂停地址:<span>{{replayAddr}}</span></p>
</div>
<div class="result-box" :class="resultBoxHidden?'':'active'">
<div class="result-box-head">
<el-button class="pull-left" size="mini" type="text" @click="resultBoxHidden=true;">返回“查询”</el-button>
<el-button class="pull-right" size="mini" type="text" @click="exportExcel" :loading="exportLocationIng">导出Excel</el-button>
<span>停留点</span>
</div>
<div class="result-box-filter text-center">
<el-button class="" size="mini" type="text" @click="sortByTime">停留时间<i class="fa fa-sort"></i></el-button>
<el-button class="" size="mini" type="text" @click="sortByStay">停留时长<i class="fa fa-sort"></i></el-button>
</div>
<ul class="stay-list">
<li class="stay-list-item" v-for="item in resultList" @click="openMapInfoWindow(item.idx)">
<p class="addr">{{item.transferAddress}}</p>
<p class="datetime"><span>{{item.begintime}}</span><span class="pull-right">{{item.duration}}</span></p>
</li>
<li v-show="!resultList.length">
<p class="text-center">无数据</p>
</li>
<infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading">
<span slot="no-more">没有更多数据了</span>
<span slot="no-results">无结果</span>
</infinite-loading>
</ul>
</div>
</div>
</div>
</template>
</v-full-layout>
}" end-placeholder="结束日期">
</el-date-picker>
<div class="pull-left">
<el-button size="mini" type="text" @click="pickDate(-6)">近6小时</el-button>
<el-button size="mini" type="text" @click="pickDate(3)">近3天</el-button>
<el-button size="mini" type="text" @click="pickDate(90)">近90天</el-button>
</div>
</el-form-item>
<el-form-item label="播放速度">
<el-select v-model="form.replaySpeed" placeholder="请选择" style="width: 80px">
<el-option v-for="item in form.speedOpts" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="定位类型">
<el-select v-model="form.replayType" placeholder="请选择" style="width: 80px">
<el-option v-for="item in form.replayTypeOpts" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
<p>
<el-button size="mini" type="primary" v-show="!replayIng" @click="replayStart" :loading="replayIniting">播放 <i class="fa fa-play"></i>
</el-button>
<el-button size="mini" type="primary" @click="replayPause" v-show="replayIng" class="clearMargin">暂停 <i class="fa fa-pause"></i>
</el-button>
<el-button size="mini" @click="replayReresh" type="primary"><i class="fa fa-refresh"></i>
</el-button>
</p>
<p>
<el-button size="mini" type="primary" plain @click="exportReplay" :loading="exporting">导出轨迹(.csv) <i class="fa fa-download"></i></el-button>
<el-button size="mini" type="primary" plain @click="resultBoxHidden=false">停留点</el-button>
</p>
<p class="replay-addr" v-show="replayAddr">暂停地址:<span>{{replayAddr}}</span></p>
</div>
<div class="result-box" :class="resultBoxHidden?'':'active'">
<div class="result-box-head">
<el-button class="pull-left" size="mini" type="text" @click="resultBoxHidden=true;">返回“查询”</el-button>
<el-button class="pull-right" size="mini" type="text" @click="exportExcel" :loading="exportLocationIng">导出Excel</el-button>
<span>停留点</span>
</div>
<div class="result-box-filter text-center">
<el-button class="" size="mini" type="text" @click="sortByTime">停留时间<i class="fa fa-sort"></i></el-button>
<el-button class="" size="mini" type="text" @click="sortByStay">停留时长<i class="fa fa-sort"></i></el-button>
</div>
<ul class="stay-list">
<li class="stay-list-item" v-for="item in resultList" @click="openMapInfoWindow(item.idx)" :key="item.idx">
<p class="addr">{{item.transferAddress}}</p>
<p class="datetime"><span>{{item.begintime}}</span><span class="pull-right">{{item.duration}}</span></p>
</li>
<li v-show="!resultList.length">
<p class="text-center">无数据</p>
</li>
<infinite-loading v-if="needInfinite" @infinite="infiniteHandler" ref="infiniteLoading">
<span slot="no-more">没有更多数据了</span>
<span slot="no-results">无结果</span>
</infinite-loading>
</ul>
</div>
</div>
</div>
</template>
</v-full-layout>
</template>
<script>
import store from '../../vuex/store.js'
import remoteLoad from 'utils/remoteLoad.js'
import mapService from 'utils/mapService.js'
import 'utils/mapEvent.js'
import EventBus from '../../event-bus'
import {services} from '../../api'
import mock from '../../mock'
const MONITOR_SERVICE = services.monitor;
const BUSINESS_SERVICE = services.business;
import {exportExcel} from 'utils'
import store from "../../vuex/store.js";
import remoteLoad from "utils/remoteLoad.js";
import mapService from "utils/mapService.js";
import "utils/mapEvent.js";
import EventBus from "../../event-bus";
import { services } from "../../api";
import mock from "../../mock";
const MONITOR_SERVICE = services.monitor;
const BUSINESS_SERVICE = services.business;
import { exportExcel } from "utils";
import { CONSTANT } from "../../constant";
import InfiniteLoading from "vue-infinite-loading";
import MapControll from "./MapControll.vue";
export default {
data() {
let checkDaterange = (rule, vaule, cb) => {
const dateRange = this.form.dateRange;
if (!dateRange || !dateRange.length) {
cb(new Error("请选择日期"));
} else {
let min = dateRange[0];
let max = dateRange[1];
if (!moment.isMoment(min)) {
min = moment(min);
}
if (!moment.isMoment(max)) {
max = moment(max);
}
import {CONSTANT} from '../../constant'
import InfiniteLoading from 'vue-infinite-loading';
import MapControll from './MapControll.vue'
if (min.isBefore(moment(max).subtract(90, "days"), "minute")) {
cb(new Error("日期范围不能超过90天"));
}
}
cb();
};
export default{
data(){
let checkDaterange = (rule, vaule, cb)=>{
return {
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: "",
searchType: "sn",
isSearching: false,
resultBoxHidden: true,
form: {
dateRange: [this.$route.query.startTime||moment().subtract(6, "hours"), this.$route.query.endTime||moment()],
timerange: "1",
replaySpeed: 1,
speedOpts: [
{
value: 0,
label: "慢",
},
{
value: 1,
label: "正常",
},
{
value: 2,
label: "快",
},
{
value: 3,
label: "很快",
},
],
replayType: "RtTrack",
replayTypeOpts: [
{
value: "RtTrack",
label: "GPS",
},
{
value: "MobileBase",
label: "基站",
},
],
},
replayData: [],
replayIniting: false,
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
replayIng: false,
replayBeginDate: "",
replayEndDate: "",
replayAddr: "",
lastReplayBeginDate: "",
lastReplayEndDate: "",
exporting: false,
rules: {
daterange: [{ validator: checkDaterange }],
},
currentPage: 1,
pageSize: 10,
total: 100,
maxPage: 10,
resultList: [],
sortByTimeIsPositive: true,
sortByStayIsPositive: true,
isInitFence: this.$route.query.isInitFence === "1" ? true : false,
fenceId: this.$route.query.fenceId,
};
},
mounted() {
store.dispatch("setFullsize", true);
if (this.$route.query.begintime && this.$route.query.endtime) {
this.form.dateRange = [
moment(this.$route.query.begintime),
moment(this.$route.query.endtime),
];
}
},
watch: {
"form.replaySpeed"(newVal) {
EventBus.$emit("uiMap.replay.speedChange", newVal);
},
"form.replayType"(newVal) {
if (!this.isReplayParamsSame()) {
this.replayIng = false;
EventBus.$emit("uiMap.replay.pause");
}
},
"form.dateRange"(newVal) {
if (!this.isReplayParamsSame()) {
this.replayIng = false;
EventBus.$emit("uiMap.replay.pause");
}
},
},
methods: {
initMap() {
let _this = this;
let check = () => {
_this.checkMapLoaded && window.clearTimeout(_this.checkMapLoaded);
const dateRange = this.form.dateRange;
if(!dateRange || !dateRange.length){
cb(new Error('请选择日期'))
}else{
let min = dateRange[0];
let max = dateRange[1];
if(!moment.isMoment(min)){
min = moment(min)
}
if(!moment.isMoment(max)){
max = moment(max)
}
if(min.isBefore( moment(max).subtract(90, 'days'), 'minute')){
cb(new Error('日期范围不能超过90天'))
}
}
cb()
}
return {
AMap: null,
mapObj: null,
mapLoading: false,
isInitMap: false,
searchText: '',
searchType: 'sn',
isSearching: false,
resultBoxHidden: true,
form: {
dateRange: [moment().subtract(6, 'hours'), moment()],
timerange: '1',
replaySpeed: 1,
speedOpts: [{
value: 0,
label: '慢'
},{
value: 1,
label: '正常'
},{
value: 2,
label: '快'
},{
value: 3,
label: '很快'
}],
replayType: 'RtTrack',
replayTypeOpts: [{
value: 'RtTrack',
label: 'GPS'
},{
value: 'MobileBase',
label: '基站'
}],
},
replayData: [],
replayIniting: false,
sn: this.$route.query.sn,
name: this.$route.query.name,
standno: this.$route.query.standno,
replayIng: false,
replayBeginDate: '',
replayEndDate: '',
replayAddr: '',
lastReplayBeginDate: '',
lastReplayEndDate: '',
exporting: false,
rules: {
daterange: [{validator: checkDaterange}]
},
currentPage: 1,
pageSize: 10,
total: 100,
maxPage: 10,
resultList: [],
sortByTimeIsPositive: true,
sortByStayIsPositive: true,
isInitFence: this.$route.query.isInitFence === '1'?true:false,
fenceId: this.$route.query.fenceId
}
},
mounted(){
store.dispatch('setFullsize', true);console.log(typeof this.$route.query.endtime)
if(this.$route.query.begintime && this.$route.query.endtime){
this.form.dateRange = [moment(this.$route.query.begintime), moment(this.$route.query.endtime)]
}
},
watch: {
'form.replaySpeed'(newVal){
EventBus.$emit('uiMap.replay.speedChange', newVal)
},
'form.replayType'(newVal){
if(!this.isReplayParamsSame()){
this.replayIng = false;
EventBus.$emit('uiMap.replay.pause')
}
},
'form.dateRange'(newVal){
if(!this.isReplayParamsSame()){
this.replayIng = false;
EventBus.$emit('uiMap.replay.pause')
}
},
},
methods: {
initMap(){
let check = ()=>{
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
!_this.mapObj
) {
window.AMap = AMap;
_this.mapObj = mapService.init("map");
return setTimeout(()=>{
if('AMap' in window && typeof AMap.Map == 'function' && !this.mapObj){
window.AMap = AMap;
this.mapObj = mapService.init('map');
//this.bindEvent();
this.isInitMap = true;
this.drawPoi()
if(this.isInitFence){
this.drawFence()
}
}else{
this.checkMapLoaded = check()
}
}, 100)
}
this.checkMapLoaded = check();
},
pickDate(recentHoursOrDays){
let unit = 'days';
if(/^\-\d+$/.test(recentHoursOrDays)){
unit = 'hours';
recentHoursOrDays = -recentHoursOrDays;
}
this.form.dateRange = [moment().subtract(recentHoursOrDays, unit), moment()]
},
replayStart(){
this.$refs.form.validate((valid, field)=>{
if(valid){
if(this.isReplayParamsSame()){
if(this.replayData.length){
this.replayIng = true;
EventBus.$emit('uiMap.replay.play');
}else{
this.$confirm('<p>暂无轨迹数据!</p>', '提示', {
confirmButtonText: '确定',
showCancelButton: false,
dangerouslyUseHTMLString: true
});
}
}else{
this.replayIniting = true;
//this.replayData = mock.getTrackHistory.data;
//EventBus.$emit('uiMap.replay.init', this.replayData);
this.getReplay();
this.getHistoryLocation();
this.lastReplayBeginDate = this.form.dateRange[0];
this.lastReplayEndDate = this.form.dateRange[1];
this.lastReplayType = this.form.replayType;
}
}else{
return false;
}
});
},
isReplayParamsSame(){
if(moment(this.form.dateRange[0]).format('YYYY-MM-DD HH:mm:ss') === moment(this.lastReplayBeginDate).format('YYYY-MM-DD HH:mm:ss')
&& moment(this.form.dateRange[1]).format('YYYY-MM-DD HH:mm:ss') === moment(this.lastReplayEndDate).format('YYYY-MM-DD HH:mm:ss')
&& this.form.replayType === this.lastReplayType){
return true
}
return false;
},
replayPause(){
EventBus.$emit('uiMap.replay.pause', true);
this.replayIng = false;
},
replayReresh(){
if(this.replayData.length && !this.replayIniting){
EventBus.$emit('uiMap.replay.refresh');
this.replayIng = true;
}
},
getReplay(){
if(!this.sn) return;
const params = {};
params.sn = this.sn;
params.startTime = moment(this.form.dateRange[0]).format('YYYY-MM-DD HH:mm:ss');
params.endTime = moment(this.form.dateRange[1]).format('YYYY-MM-DD HH:mm:ss');
//this.bindEvent();
_this.isInitMap = true;
//_this.drawPoi();
if (_this.isInitFence) {
//_this.drawFence();
console.log("666666666666666666666");
_this.getFence();
}
} else {
_this.checkMapLoaded = check();
}
}, 100);
};
_this.checkMapLoaded = check();
},
pickDate(recentHoursOrDays) {
let unit = "days";
if (/^\-\d+$/.test(recentHoursOrDays)) {
unit = "hours";
recentHoursOrDays = -recentHoursOrDays;
}
this.form.dateRange = [
moment().subtract(recentHoursOrDays, unit),
moment(),
];
},
replayStart() {
this.$refs.form.validate((valid, field) => {
if (valid) {
if (this.isReplayParamsSame()) {
if (this.replayData.length) {
this.replayIng = true;
EventBus.$emit("uiMap.replay.play");
} else {
this.$confirm("<p>暂无轨迹数据!</p>", "提示", {
confirmButtonText: "确定",
showCancelButton: false,
dangerouslyUseHTMLString: true,
});
}
} else {
this.replayIniting = true;
//this.replayData = mock.getTrackHistory.data;
//EventBus.$emit('uiMap.replay.init', this.replayData);
this.getReplay();
this.getHistoryLocation();
this.lastReplayBeginDate = this.form.dateRange[0];
this.lastReplayEndDate = this.form.dateRange[1];
this.lastReplayType = this.form.replayType;
}
} else {
return false;
}
});
},
isReplayParamsSame() {
if (
moment(this.form.dateRange[0]).format("YYYY-MM-DD HH:mm:ss") ===
moment(this.lastReplayBeginDate).format("YYYY-MM-DD HH:mm:ss") &&
moment(this.form.dateRange[1]).format("YYYY-MM-DD HH:mm:ss") ===
moment(this.lastReplayEndDate).format("YYYY-MM-DD HH:mm:ss") &&
this.form.replayType === this.lastReplayType
) {
return true;
}
return false;
},
replayPause() {
EventBus.$emit("uiMap.replay.pause", true);
this.replayIng = false;
},
replayReresh() {
if (this.replayData.length && !this.replayIniting) {
EventBus.$emit("uiMap.replay.refresh");
this.replayIng = true;
}
},
getReplay() {
if (!this.sn) return;
const params = {};
params.sn = this.sn;
params.startTime = moment(this.form.dateRange[0]).format(
"YYYY-MM-DD HH:mm:ss"
);
params.endTime = moment(this.form.dateRange[1]).format(
"YYYY-MM-DD HH:mm:ss"
);
this.replayIniting = true;
//const resource = this.form.replayType == 'RtTrack'?MONITOR_SERVICE.getTrackHistory:MONITOR_SERVICE.getBaseStationHistory;
params.locationType = this.form.replayType == 'RtTrack' ? 0 : 1
MONITOR_SERVICE.getTrackHistory(params).then((result)=>{
//result = mock.getTrackHistory
console.log(result)
if(result.code == '200'){
let data = result.data;
this.replayData = data;
if(data&&data.length){
EventBus.$emit('uiMap.replay.init', data, this.form.replaySpeed);
}else{
EventBus.$emit('uiMap.replay.destroy');
this.$confirm(`<p>${'暂无轨迹数据!'}</p>`, '提示', {
confirmButtonText: '确定',
showCancelButton: false,
dangerouslyUseHTMLString: true
});
this.replayIniting = false;
}
}
});
},
infiniteHandler($state){return;
if(this.currentPage> this.maxPage){
$state.complete();
return;
}
this.replayIniting = true;
//const resource = this.form.replayType == 'RtTrack'?MONITOR_SERVICE.getTrackHistory:MONITOR_SERVICE.getBaseStationHistory;
params.locationType = this.form.replayType == "RtTrack" ? 0 : 1;
MONITOR_SERVICE.getTrackHistory(params).then((result) => {
//result = mock.getTrackHistory
console.log(result);
if (result.code == "200") {
let data = result.data;
this.replayData = data;
if (data && data.length) {
EventBus.$emit("uiMap.replay.init", data, this.form.replaySpeed);
} else {
EventBus.$emit("uiMap.replay.destroy");
this.$confirm(`<p>${"暂无轨迹数据!"}</p>`, "提示", {
confirmButtonText: "确定",
showCancelButton: false,
dangerouslyUseHTMLString: true,
});
this.replayIniting = false;
}
}
});
},
infiniteHandler($state) {
return;
if (this.currentPage > this.maxPage) {
$state.complete();
return;
}
this.currentPage++;
$state.loaded();
setTimeout(()=>{
this.resultList = this.resultList.concat([{
addr: '甘肃省酒泉市肃州区海马福仕达中瑞汽车',
date: '2018-11-20 15:19:21',
restTime: '25小时26分钟25秒'
}])
},10000)
return;
DEVICE_SERVICE.getDeviceList(this.params).then((res)=>{
const data = res.data;
if(data && data.length){
const arr = []
data.forEach((item) => {
arr.push({
label: item.name,
value: item.id
})
})
if(this.options[0] && 'label' in this.options[0]){
this.options = this.options.concat(arr);
}else{
this.options = arr
}
this.total = res.recordsTotal;
this.maxPage = Math.ceil(this.total/this.pageSize);
this.currentPage++;
this.$refs.infiniteLoading.$emit('$InfiniteLoading:loaded');
}else{
this.$refs.infiniteLoading.$emit('$InfiniteLoading:complete');
this.options = []
}
})
},
exportReplay(){
if(this.exporting) return;
this.currentPage++;
$state.loaded();
setTimeout(() => {
this.resultList = this.resultList.concat([
{
addr: "甘肃省酒泉市肃州区海马福仕达中瑞汽车",
date: "2018-11-20 15:19:21",
restTime: "25小时26分钟25秒",
},
]);
}, 10000);
if(this.replayData.length && !this.replayIniting){
this.exporting = true;
if(!this.replayData[0].transferAddress){
EventBus.$emit('uiMap.replay.transferAdr', this.replayData);
return;
}
this.exportCsv();
}else{
this.$message({
type: 'info',
message: '数据为空,不能下载'
});
}
},
exportCsv(){
let paramArr = [];
return;
DEVICE_SERVICE.getDeviceList(this.params).then((res) => {
const data = res.data;
if (data && data.length) {
const arr = [];
data.forEach((item) => {
arr.push({
label: item.name,
value: item.id,
});
});
if (this.options[0] && "label" in this.options[0]) {
this.options = this.options.concat(arr);
} else {
this.options = arr;
}
this.replayData.forEach((dataItem)=>{
let paramItem = {};
this.total = res.recordsTotal;
this.maxPage = Math.ceil(this.total / this.pageSize);
this.currentPage++;
this.$refs.infiniteLoading.$emit("$InfiniteLoading:loaded");
} else {
this.$refs.infiniteLoading.$emit("$InfiniteLoading:complete");
this.options = [];
}
});
},
exportReplay() {
if (this.exporting) return;
for(let key in dataItem){
switch(key){
case 'carName':
case 'standNo':
case 'sn':
case 'dateTime':
case 'speed':
case 'userTel':
case 'activeTime':
paramItem[key] = dataItem[key]?dataItem[key]:'';
break;
if (this.replayData.length && !this.replayIniting) {
this.exporting = true;
if (!this.replayData[0].transferAddress) {
EventBus.$emit("uiMap.replay.transferAdr", this.replayData);
case 'transferAddress':
paramItem.address = dataItem.transferAddress?dataItem.transferAddress:'';
break;
return;
}
this.exportCsv();
} else {
this.$message({
type: "info",
message: "数据为空,不能下载",
});
}
},
exportCsv() {
let paramArr = [];
case 'status':
paramItem.status = dataItem.speed>0?'行驶':'停驶';
break;
this.replayData.forEach((dataItem) => {
let paramItem = {};
}
for (let key in dataItem) {
switch (key) {
case "carName":
case "standNo":
case "sn":
case "dateTime":
case "speed":
case "userTel":
case "activeTime":
paramItem[key] = dataItem[key] ? dataItem[key] : "";
break;
}
paramItem.lnglat = `${dataItem.elng},${dataItem.elat}`;
paramItem.locateMode = this.form.replayType == 'RtTrack'?'GPS':'基站';
paramArr.push(paramItem);
});
case "transferAddress":
paramItem.address = dataItem.transferAddress
? dataItem.transferAddress
: "";
break;
exportExcel('/devicemonitor/monitor/exporttrackpoint', {
expData: encodeURI(JSON.stringify(paramArr)),
startTime: moment(this.form.dateRange[0]).format('YYYY-MM-DD HH:mm:ss'),
endTime: moment(this.form.dateRange[1]).format('YYYY-MM-DD HH:mm:ss'),
locationType: this.form.replayType == 'RtTrack' ? 0 : 1,
sn: this.sn
}, 'post', ()=>{
this.exporting = false;
case "status":
paramItem.status = dataItem.speed > 0 ? "行驶" : "停驶";
break;
}
}
paramItem.lnglat = `${dataItem.elng},${dataItem.elat}`;
paramItem.locateMode =
this.form.replayType == "RtTrack" ? "GPS" : "基站";
paramArr.push(paramItem);
});
exportExcel(
"/devicemonitor/monitor/exporttrackpoint",
{
expData: encodeURI(JSON.stringify(paramArr)),
startTime: moment(this.form.dateRange[0]).format(
"YYYY-MM-DD HH:mm:ss"
),
endTime: moment(this.form.dateRange[1]).format("YYYY-MM-DD HH:mm:ss"),
locationType: this.form.replayType == "RtTrack" ? 0 : 1,
sn: this.sn,
},
"post",
() => {
this.exporting = false;
}
);
},
getHistoryLocation() {
this.resultList = [];
MONITOR_SERVICE.getHistoryLocation({
sn: this.sn, //'90903010001',
startTime: moment(this.form.dateRange[0])
.startOf("day")
.format("YYYY-MM-DD HH:mm:ss"), //'2018-03-22 09:47:43',//
endTime: moment(this.form.dateRange[1])
.endOf("day")
.format("YYYY-MM-DD HH:mm:ss"), //'2019-10-27 09:56:45',//
times: "0",
locationType: this.form.replayType == "RtTrack" ? 0 : 1,
}).then((res) => {
console.log(res);
if (res.code == 200) {
const data = res.data;
if (data.length) {
data.forEach((item, idx) => {
item.idx = idx;
});
this.resultList = data;
}
EventBus.$emit("uiMap.replay.drawLocation", data);
this.isSearching = false;
}
});
},
exportExcel() {
if (!this.resultList.length) {
this.$message({
type: "info",
message: "数据为空,不能下载",
});
} else {
let arr = [];
this.resultList.forEach((item) => {
item.address = item.transferAddress;
arr.push(item);
});
exportExcel(
"/devicemonitor/monitor/exportstaypoint",
{
sn: this.sn,
vin: this.standno,
name: this.name,
locationType: this.form.replayType == "RtTrack" ? 0 : 1,
expData: encodeURI(JSON.stringify(arr)),
},
"post"
);
}
},
sortByTime() {
let sortArr = this.resultList.sort((a, b) => {
return moment(a.begintime).isBefore(moment(b.begintime))
? this.sortByTimeIsPositive
? -1
: 1
: this.sortByTimeIsPositive
? 1
: -1;
});
this.sortByTimeIsPositive = !this.sortByTimeIsPositive;
this.resultList = [].concat(sortArr);
},
sortByStay() {
let sortArr = this.resultList.sort((a, b) => {
let aTime =
new Date(a.endtime).getTime() - new Date(a.begintime).getTime();
let bTime =
new Date(b.endtime).getTime() - new Date(b.begintime).getTime();
return aTime > bTime
? this.sortByStayIsPositive
? -1
: 1
: this.sortByStayIsPositive
? 1
: -1;
});
this.sortByStayIsPositive = !this.sortByStayIsPositive;
this.resultList = [].concat(sortArr);
},
openMapInfoWindow(idx) {
EventBus.$emit("uiMap.replay.openInfoWindow", idx);
},
drawPoi() {
let _this = this;
BUSINESS_SERVICE.getPOI({ sn: _this.sn }).then((res) => {
console.log("666666666666");
console.log(res);
if (res.returnCode === "0") {
if (res.data && res.data.length) {
res.data.forEach((item) => {
let marker = mapService.createPOIMarker(
mapService.getLngLat(item.lng, item.lat),
this.mapObj
);
let infoWindow = mapService.bindPOIInfoWindow(
marker,
this.mapObj,
item
);
});
}
}
});
},
drawFence() {
MONITOR_SERVICE.getSingleFence({
sn: this.sn,
fenceId: parseInt(this.fenceId),
}).then((res) => {
if (res.returnCode == 0) {
const data = res.data;
if (data) {
if (data.shapeType === 2) {
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: data.lng,
lat: data.lat,
radius: data.radius,
isEdit: false,
});
} else if (data.shapeType === 3) {
this.drawDistrict(data.areaCode);
} else if (data.shapeType === 5) {
if (data.lnglat) {
let polygonPath = data.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
},
getHistoryLocation(){
this.resultList = [];
MONITOR_SERVICE.getHistoryLocation({
sn: this.sn,//'90903010001',
startTime: moment(this.form.dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss'),//'2018-03-22 09:47:43',//
endTime: moment(this.form.dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss'),//'2019-10-27 09:56:45',//
times: '0',
locationType: this.form.replayType == 'RtTrack' ? 0 : 1
}).then((res)=>{
console.log(res)
if(res.code == 200){
const data = res.data;
if(data.length){
data.forEach((item, idx)=>{
item.idx = idx;
});
this.resultList = data;
}
EventBus.$emit('uiMap.replay.drawLocation', data);
this.isSearching = false;
}
});
},
exportExcel(){
if(!this.resultList.length){
this.$message({
type: 'info',
message: '数据为空,不能下载'
});
}else{
let arr = [];
this.resultList.forEach((item)=>{
item.address = item.transferAddress;
arr.push(item);
});
exportExcel('/devicemonitor/monitor/exportstaypoint', {
sn: this.sn,
vin: this.standno,
name: this.name,
locationType: this.form.replayType == 'RtTrack' ? 0 : 1,
expData: encodeURI(JSON.stringify(arr))
}, 'post');
}
},
sortByTime(){
let sortArr = this.resultList.sort((a,b)=>{
return moment(a.begintime).isBefore(moment(b.begintime))?(this.sortByTimeIsPositive?-1:1):(this.sortByTimeIsPositive?1:-1);
});
this.sortByTimeIsPositive = !this.sortByTimeIsPositive;
this.resultList = [].concat(sortArr);
},
sortByStay(){
let sortArr = this.resultList.sort((a,b)=>{
let aTime = (new Date(a.endtime)).getTime() - (new Date(a.begintime)).getTime();
let bTime = (new Date(b.endtime)).getTime() - (new Date(b.begintime)).getTime();
return aTime>bTime?(this.sortByStayIsPositive?-1:1):(this.sortByStayIsPositive?1:-1);
});
this.sortByStayIsPositive = !this.sortByStayIsPositive;
this.resultList = [].concat(sortArr);
},
openMapInfoWindow(idx){
EventBus.$emit('uiMap.replay.openInfoWindow', idx)
},
drawPoi(){
BUSINESS_SERVICE.getPOI({
sn: this.sn
}).then((res)=>{
if(res.returnCode === '0'){
if(res.data && res.data.length){
res.data.forEach((item)=>{
let marker = mapService.createPOIMarker(mapService.getLngLat(item.lng, item.lat), this.mapObj)
let infoWindow = mapService.bindPOIInfoWindow(marker, this.mapObj, item)
})
}
}
})
},
drawFence(){
MONITOR_SERVICE.getSingleFence({
sn: this.sn,
fenceId: parseInt(this.fenceId)
}).then((res)=>{
if(res.returnCode == 0){
const data = res.data;
if(data){
if(data.shapeType === 2){
EventBus.$emit('uiMap.fence.createFenceCircle', {
lng: data.lng,
lat: data.lat,
radius: data.radius,
isEdit: false
});
}else if(data.shapeType === 3){
this.drawDistrict(data.areaCode)
}else if(data.shapeType === 5){
if(data.lnglat){
let polygonPath = data.lnglat.split('|').map((item)=>{
return [item.split(',')[0], item.split(',')[1]]
})
this.drawPolygon(polygonPath)
}
}
}
}
});
},
drawDistrict(areaCode){
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this.drawPolygon(polygonPath);
}
}
}
}
});
},
drawDistrict(areaCode) {
this._drawDistrictTimeoutId && clearTimeout(this._drawDistrictTimeoutId);
this._drawDistrictTimeoutId = setTimeout(() => {
EventBus.$emit("uiMap.fence.drawDistrict", areaCode);
}, 500);
},
drawPolygon(path) {
EventBus.$emit("uiMap.fence.drawPolygon", {
path,
isEdit: false,
});
},
// 获取围栏信息-并画围栏
getFence() {
MONITOR_SERVICE.getFenceInfo({
sn: this.sn,
}).then((res) => {
console.log(res);
let list = res.data || [];
if (res.code != 200) {
return false;
// const data = res.data || [];
// if (data) {
// if (data.shapeType === 2) {
// EventBus.$emit("uiMap.fence.createFenceCircle", {
// lng: data.lng,
// lat: data.lat,
// radius: data.radius,
// isEdit: false,
// });
// } else if (data.shapeType === 3) {
// this.drawDistrict(data.areaCode);
// } else if (data.shapeType === 5) {
// if (data.lnglat) {
// let polygonPath = data.lnglat.split("|").map((item) => {
// return [item.split(",")[0], item.split(",")[1]];
// });
// this.drawPolygon(polygonPath);
// }
// }
// }
}
this._drawDistrictTimeoutId = setTimeout(()=>{
EventBus.$emit('uiMap.fence.drawDistrict', areaCode);
}, 500);
},
drawPolygon(path){
EventBus.$emit('uiMap.fence.drawPolygon', {
path,
isEdit: false
})
}
},
created () {
if(window.AMap){
this.initMap();
}else{
remoteLoad(`${CONSTANT.AMAP_URL}`).then(()=>{
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(()=>{
this.initMap();
})
})
}
// 循环画围栏
list.map((k) => {
// 圆形围栏
if (k.shapeType == 1) {
EventBus.$emit("uiMap.fence.createFenceCircle", {
lng: k.lnglat.split(",")[0],
lat: k.lnglat.split(",")[1],
radius: k.radius,
isEdit: false,
});
}
//轨迹播放当前位置地址显示
EventBus.$on('uiMap.replay.currAddress', (adr)=>{
this.replayAddr = adr;
});
// 多边形围栏
if (k.shapeType == 3) {
let polygonPath = k.lnglat.split("|").map((item) => {
return [item.split(",")[0], item.split(",")[1]];
});
this.drawPolygon(polygonPath);
}
});
});
},
},
created() {
if (window.AMap) {
this.initMap();
} else {
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
() => {
this.initMap();
}
);
});
}
//轨迹初始化完成
EventBus.$on('uiMap.replay.initDone', ()=>{
this.replayIniting = false;
this.replayIng = true;
});
//轨迹播放当前位置地址显示
EventBus.$on("uiMap.replay.currAddress", (adr) => {
this.replayAddr = adr;
});
//轨迹播放结束
EventBus.$on('uiMap.replay.done', ()=>{
this.replayIng = false;
this.$alert(`<p>开始时间: ${this.replayData[0].dateTime}</p><p>结束时间: ${this.replayData[this.replayData.length-1].dateTime}</p>`, '轨迹播放完成', {
type: 'success',
confirmButtonText: '确定',
dangerouslyUseHTMLString: true
});
});
//轨迹初始化完成
EventBus.$on("uiMap.replay.initDone", () => {
this.replayIniting = false;
this.replayIng = true;
});
//轨迹解析结束
EventBus.$on('uiMap.replay.transferAdrDone', ()=>{
if(this.exporting){
this.exportCsv();
}
});
//轨迹播放结束
EventBus.$on("uiMap.replay.done", () => {
this.replayIng = false;
this.$alert(
`<p>开始时间: ${this.replayData[0].dateTime}</p><p>结束时间: ${
this.replayData[this.replayData.length - 1].dateTime
}</p>`,
"轨迹播放完成",
{
type: "success",
confirmButtonText: "确定",
dangerouslyUseHTMLString: true,
}
);
});
EventBus.$on('uiMap.historyLocation.transferSuccess', (data)=>{
this.resultList = [].concat(data);
});
//轨迹解析结束
EventBus.$on("uiMap.replay.transferAdrDone", () => {
if (this.exporting) {
this.exportCsv();
}
});
EventBus.$on('uiMap.replay.replayIng', (data)=>{
this.replayIng = data;
});
},
beforeDestroy(){
EventBus.$on("uiMap.historyLocation.transferSuccess", (data) => {
this.resultList = [].concat(data);
});
},
components: {
MapControll
}
}
EventBus.$on("uiMap.replay.replayIng", (data) => {
this.replayIng = data;
});
},
beforeDestroy() {},
components: {
MapControll,
},
};
</script>
<style scoped>
/*样式写在 scss/monitor.scss*/
.clearMargin{
margin-left: 0px;
}
/*样式写在 scss/monitor.scss*/
.clearMargin {
margin-left: 0px;
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!