|
@@ -0,0 +1,300 @@
|
|
|
+<template>
|
|
|
+ <pannel class="devc-location-container">
|
|
|
+ <template v-slot:icon>
|
|
|
+ <svg-icon icon-class="bd_location"/>
|
|
|
+ </template>
|
|
|
+ <template v-slot:title>
|
|
|
+ 轨迹查询
|
|
|
+ </template>
|
|
|
+ <template v-slot:action>
|
|
|
+ <i
|
|
|
+ class="el-icon-delete-location"
|
|
|
+ title="清空所有轨迹"
|
|
|
+ @click="clearAll"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <template v-slot:content>
|
|
|
+ <div class="header-ctrl">
|
|
|
+ <el-radio-group v-model="dateType" size="mini" @change="onDateTypeChange">
|
|
|
+ <template v-for="item in Object.keys(DateTypeRadio)">
|
|
|
+ <el-radio-button :label="item">{{ DateTypeRadio[item].name }}</el-radio-button>
|
|
|
+ </template>
|
|
|
+ </el-radio-group>
|
|
|
+ <el-date-picker
|
|
|
+ v-if="dateType === DateTypeRadio.day.key"
|
|
|
+ key="day"
|
|
|
+ v-model="selectDate"
|
|
|
+ align="right"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择日期"
|
|
|
+ :picker-options="pickerOptions"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ <el-date-picker
|
|
|
+ key="cust-day"
|
|
|
+ format="yyyy-MM-dd HH:mm"
|
|
|
+ v-if="dateType === DateTypeRadio.cust.key"
|
|
|
+ v-model="selectDate"
|
|
|
+ type="datetimerange"
|
|
|
+ range-separator="至"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束日期"
|
|
|
+ size="mini"
|
|
|
+ >
|
|
|
+ </el-date-picker>
|
|
|
+ </div>
|
|
|
+ <div class="location-list">
|
|
|
+ <div class="list-item">
|
|
|
+ <span class="over-flow-hidden" style="width: 40%">
|
|
|
+ 园区安保巡逻轨迹
|
|
|
+ </span>
|
|
|
+ <span class="over-flow-hidden" style="width: 40%">
|
|
|
+ 2024-08-21 15:30
|
|
|
+ </span>
|
|
|
+ <span class="over-flow-hidden" style="width: 20%">
|
|
|
+ <i
|
|
|
+ :class="playItem[1]&&playItem[1].play ? 'el-icon-video-pause':'el-icon-video-play'"
|
|
|
+ :title="playItem[1]&&playItem[1].play ? '暂停': '开始播放' "
|
|
|
+ @click="()=>onLocationPlay({key:1})"
|
|
|
+ />
|
|
|
+ <i class="el-icon-refresh-left" title="重播" @click="()=>replayLocation({key:1})"/>
|
|
|
+ <i class="el-icon-circle-close" title="清空轨迹" @click="()=>clearLocation({key:1})"/>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </pannel>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+
|
|
|
+import Pannel from '@/views/bd/pannel/index.vue';
|
|
|
+
|
|
|
+const DateTypeRadio = {
|
|
|
+ day: {
|
|
|
+ key: 'day',
|
|
|
+ name: '日',
|
|
|
+ },
|
|
|
+ cust: {
|
|
|
+ key: 'cust',
|
|
|
+ name: '自定义',
|
|
|
+ }
|
|
|
+}
|
|
|
+export default {
|
|
|
+ name: 'location',
|
|
|
+ components: {Pannel},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ DateTypeRadio,
|
|
|
+ playItem: {},
|
|
|
+ selectDate: new Date(),
|
|
|
+ dateType: DateTypeRadio.day.key,
|
|
|
+ pickerOptions: {
|
|
|
+ disabledDate(time) {
|
|
|
+ return time.getTime() > Date.now();
|
|
|
+ },
|
|
|
+ shortcuts: [{
|
|
|
+ text: '今天',
|
|
|
+ onClick(picker) {
|
|
|
+ picker.$emit('pick', new Date());
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ text: '昨天',
|
|
|
+ onClick(picker) {
|
|
|
+ const date = new Date();
|
|
|
+ date.setTime(date.getTime() - 3600 * 1000 * 24);
|
|
|
+ picker.$emit('pick', date);
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ text: '一周前',
|
|
|
+ onClick(picker) {
|
|
|
+ const date = new Date();
|
|
|
+ date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
|
|
+ picker.$emit('pick', date);
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ // 组件卸载前清空图层信息
|
|
|
+ beforeDestroy() {
|
|
|
+ this.clearAll();
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+ debugger
|
|
|
+
|
|
|
+ this.socket = new WebSocket(`ws://172.192.13.77:2223/socket/websocket/pollingArea`);
|
|
|
+
|
|
|
+ this.socket.onopen = () => {
|
|
|
+ this.socket.send(JSON.stringify({"register":"1731296055163","token":"9358d080-03d4-423c-91d4-d4d2a391183d"}));
|
|
|
+ console.log('连接成功:', this.socket);
|
|
|
+
|
|
|
+ };
|
|
|
+ // 监听socket错误信息
|
|
|
+ this.socket.onerror = (e) => {
|
|
|
+ console.log('%c FXY', 'color:#f6b2b1;font-size:50px', e);
|
|
|
+ console.log('socket连接失败');
|
|
|
+ };
|
|
|
+ // 监听socket关闭监听
|
|
|
+ this.socket.onclose = () => {
|
|
|
+ console.log('socket连接关闭');
|
|
|
+ };
|
|
|
+ this.socket.onmessage = (a) => {
|
|
|
+ const data = JSON.parse(a.data);
|
|
|
+ console.log(">>>>>>>>>",data);
|
|
|
+ if (data && data.message === "handshake"){
|
|
|
+ // tagId要去掉前缀0
|
|
|
+ this.socket.send(JSON.stringify({"key": "1731296055163","tagId": "847F3", "token": "9358d080-03d4-423c-91d4-d4d2a391183d"}));
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ onDateTypeChange(e, eh) {
|
|
|
+ if (e === DateTypeRadio.day.key) {
|
|
|
+ this.selectDate = new Date();
|
|
|
+ } else if (e === DateTypeRadio.cust.key) {
|
|
|
+ const date = new Date();
|
|
|
+ date.setTime(date.getTime() - 3600 * 1000 * 24);
|
|
|
+ this.selectDate = [date, new Date()];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getDevcTrail() {
|
|
|
+
|
|
|
+ },
|
|
|
+ loaded(map) {
|
|
|
+ console.log(map);
|
|
|
+ },
|
|
|
+ onLocationPlay({key}) {
|
|
|
+ if (this.playItem[key]) {
|
|
|
+ if (this.playItem[key].play) {
|
|
|
+ bdmap.comp.Trajectory.trajectoryPause(this.playItem[key].line);
|
|
|
+ } else {
|
|
|
+ bdmap.comp.Trajectory.trajectoryPlay(this.playItem[key].line);
|
|
|
+ }
|
|
|
+ this.playItem = {
|
|
|
+ [key]: {
|
|
|
+ ...this.playItem[key],
|
|
|
+ play: !this.playItem[key].play,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ this.clearAll();
|
|
|
+ this.playItem = {
|
|
|
+ [key]: {
|
|
|
+ play: true,
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ this.playItem[key].line = this.startPlay();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ startPlay() {
|
|
|
+ const coordinates = [
|
|
|
+ [118.868474555524, 32.013913750075],
|
|
|
+ [118.868459917135, 32.0138560330253],
|
|
|
+ [118.868460650064, 32.0137600494265],
|
|
|
+ [118.868469791963, 32.0135491295906],
|
|
|
+ [118.868450597046, 32.0135969285238],
|
|
|
+ [118.868451821878, 32.0134372342673],
|
|
|
+ [118.868369085172, 32.0134271059761],
|
|
|
+ [118.868229813542, 32.0134261784667],
|
|
|
+ [118.868037844538, 32.0134249000077],
|
|
|
+ [118.867988911263, 32.013424574126],
|
|
|
+ [118.867990212059, 32.0132809893746],
|
|
|
+ [118.867986825628, 32.0132395072755],
|
|
|
+ [118.867987028075, 32.0132171885197],
|
|
|
+ [118.867987432888, 32.0131725599655],
|
|
|
+ [118.867984539806, 32.0130769425047],
|
|
|
+ [118.867977454441, 32.0130291167663],
|
|
|
+ [118.86797791828, 32.0129781711549],
|
|
|
+ [118.867978150146, 32.0129527041872],
|
|
|
+ [118.867974855578, 32.0129017568948],
|
|
|
+ [118.868046176274, 32.0129117791912],
|
|
|
+ [118.868121507934, 32.0128931867922],
|
|
|
+ [118.868117943319, 32.0128708893801],
|
|
|
+ [118.868126616248, 32.012737367597],
|
|
|
+ [118.868127634971, 32.0126197858525],
|
|
|
+ [118.868127662494, 32.0126166091195],
|
|
|
+ [118.868165320753, 32.0126041528561],
|
|
|
+ [118.868173101262, 32.0125724412675],
|
|
|
+ [118.868240681514, 32.0125728913369],
|
|
|
+ [118.868308235972, 32.0125765173023],
|
|
|
+ [118.868334874981, 32.0125322352762],
|
|
|
+ [118.868324305199, 32.012446455205],
|
|
|
+ [118.868361835438, 32.0124467051483],
|
|
|
+ [118.868364679658, 32.0125610134717],
|
|
|
+ [118.868492254263, 32.0125713907483],
|
|
|
+ [118.868541014618, 32.0125780675563],
|
|
|
+ [118.868732580782, 32.012566639437],
|
|
|
+ [118.868841456955, 32.0125673645282],
|
|
|
+ [118.868976574771, 32.0125746162152],
|
|
|
+ [118.869070453844, 32.0125720654824],
|
|
|
+ [118.869096734551, 32.0125722405062],
|
|
|
+ [118.869156822422, 32.0125694647922],
|
|
|
+ [118.869179313588, 32.0125759664106],
|
|
|
+ [118.869201684821, 32.0126047016424],
|
|
|
+ [118.869186178487, 32.0126935647542],
|
|
|
+ [118.869193065594, 32.0128080658432],
|
|
|
+ [118.869192510216, 32.0129098661745],
|
|
|
+ [118.86919198924, 32.0130053604978],
|
|
|
+ [118.869179854563, 32.0131613771548],
|
|
|
+ [118.869190250492, 32.0133240705021],
|
|
|
+ [118.869185964264, 32.0134197772962],
|
|
|
+ [118.86917071489, 32.0134547924615],
|
|
|
+ [118.869159014503, 32.0135281642937],
|
|
|
+ [118.869166174307, 32.0135953030259],
|
|
|
+ [118.869165521059, 32.0137135723353],
|
|
|
+ [118.869187426642, 32.0138416759025],
|
|
|
+ [118.869153188005, 32.0138990608231],
|
|
|
+ [118.868990969654, 32.0139203908971],
|
|
|
+ [118.868768561862, 32.0139189097324],
|
|
|
+ [118.868572541435, 32.0139176042992],
|
|
|
+ [118.868557462941, 32.0139175038812],
|
|
|
+ [118.868474555524, 32.013913750075],
|
|
|
+ ];
|
|
|
+ // 19FB03
|
|
|
+ let playLine = bdmap.comp.Trajectory.loadTrajectory({
|
|
|
+ mapView: window.map,
|
|
|
+ latlons: coordinates,
|
|
|
+ unitTime: 500,
|
|
|
+ speedValue: 1,
|
|
|
+ mapToCenter: false,
|
|
|
+ });
|
|
|
+ bdmap.comp.Trajectory.trajectoryPlay(playLine);
|
|
|
+ return playLine;
|
|
|
+ },
|
|
|
+ replayLocation({key}) {
|
|
|
+ if (this.playItem[key] && this.playItem[key].line) {
|
|
|
+ bdmap.comp.Trajectory.trajectoryCancel(this.playItem[key].line);
|
|
|
+ this.playItem[key].play = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ removeLine({key}) {
|
|
|
+ if (this.playItem[key] && this.playItem[key].line) {
|
|
|
+ bdmap.comp.Trajectory.trajectoryRemove(this.playItem[key].line);
|
|
|
+ delete this.playItem[key];
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ clearAll() {
|
|
|
+ Object.keys(this.playItem).forEach(keyItem => {
|
|
|
+ if (this.playItem[keyItem] && this.playItem[keyItem].line) {
|
|
|
+ this.removeLine({key: keyItem});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.playItem = {};
|
|
|
+ },
|
|
|
+ clearLocation({key}) {
|
|
|
+ this.removeLine({key});
|
|
|
+ this.playItem = {};
|
|
|
+ },
|
|
|
+
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" src="./index.scss"/>
|