|
@@ -0,0 +1,126 @@
|
|
|
|
+<template>
|
|
|
|
+ <ion-page class="list-page">
|
|
|
|
+ <ion-header class="header-theme2 header-theme3">
|
|
|
|
+ <ion-toolbar>
|
|
|
|
+ <ion-title>工作轨迹</ion-title>
|
|
|
|
+ </ion-toolbar>
|
|
|
|
+ </ion-header>
|
|
|
|
+ <ion-content>
|
|
|
|
+ <ion-item class="search-item">
|
|
|
|
+ <ion-input type="date" v-model="startDate"></ion-input>
|
|
|
|
+ <ion-button slot="end"
|
|
|
|
+ style="height: 33px;width: 70px;margin-left: 10px;--box-shadow: none;--border-radius: 14px;"
|
|
|
|
+ @click="search">查询
|
|
|
|
+ </ion-button>
|
|
|
|
+ </ion-item>
|
|
|
|
+ <div id='mapDiv' style='position: absolute; width: 100%; height: 100%; z-index: 100'></div>
|
|
|
|
+ </ion-content>
|
|
|
|
+
|
|
|
|
+ </ion-page>
|
|
|
|
+</template>
|
|
|
|
+<script>
|
|
|
|
+import {defineComponent, ref} from "vue";
|
|
|
|
+import {getLongitudeLatitudeList} from "../../../../api/position";
|
|
|
|
+import {alertController, onIonViewDidEnter} from "@ionic/vue";
|
|
|
|
+import {useUserStore} from "../../../../store/modules/user";
|
|
|
|
+import dayjs from 'dayjs';
|
|
|
|
+
|
|
|
|
+const presentAlert = async (header, message) => {
|
|
|
|
+ const alert = await alertController.create({
|
|
|
|
+ header: header,
|
|
|
|
+ message: message,
|
|
|
|
+ buttons: [
|
|
|
|
+ '确定'
|
|
|
|
+ ],
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ await alert.present();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export default defineComponent({
|
|
|
|
+ name: 'user_track',
|
|
|
|
+ setup() {
|
|
|
|
+ const userStore = useUserStore();
|
|
|
|
+ const user = ref(userStore.getUserInfo);
|
|
|
|
+ const startDate = ref(dayjs(new Date()).format('YYYY-MM-DD'));
|
|
|
|
+ let trackList = [];
|
|
|
|
+ const T = window.T;
|
|
|
|
+ const zoom = 14;
|
|
|
|
+ let map = null;
|
|
|
|
+ let line = null;
|
|
|
|
+
|
|
|
|
+ const getTrackList = async () => {
|
|
|
|
+ trackList = await getLongitudeLatitudeList(user.value.userID, startDate.value, startDate.value);
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const setLine = async () => {
|
|
|
|
+ //删除线
|
|
|
|
+ if (line != null)
|
|
|
|
+ map.removeOverLay(line);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ await getTrackList();
|
|
|
|
+ } catch (e) { /* empty */
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (trackList.length == 0) {
|
|
|
|
+ presentAlert('提示', '当日无轨迹');
|
|
|
|
+ //设置显示地图的中心点和级别
|
|
|
|
+ map.centerAndZoom(new T.LngLat(114.40, 23.08), zoom);//惠州市
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const center = trackList[0];
|
|
|
|
+
|
|
|
|
+ map.centerAndZoom(new T.LngLat(center.longitude, center.latitude), zoom);
|
|
|
|
+
|
|
|
|
+ const points = trackList.map(track => {
|
|
|
|
+ return new T.LngLat(track.longitude, track.latitude)
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //创建线对象
|
|
|
|
+ line = new T.Polyline(points, {
|
|
|
|
+ color: "#c00020"
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ //向地图上添加线
|
|
|
|
+ map.addOverLay(line);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const initMap = () => {
|
|
|
|
+ //初始化地图对象
|
|
|
|
+ map = new T.Map("mapDiv");
|
|
|
|
+
|
|
|
|
+ setLine();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const search = () => {
|
|
|
|
+ setLine();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ /*window.onload = initMap;*/
|
|
|
|
+
|
|
|
|
+ onIonViewDidEnter(() => {
|
|
|
|
+ initMap();
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return {
|
|
|
|
+ startDate,
|
|
|
|
+ search
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+</script>
|
|
|
|
+<style lang="less">
|
|
|
|
+.search-item {
|
|
|
|
+ ion-input {
|
|
|
|
+ border: 1px solid #f2f2f5;
|
|
|
|
+ border-radius: 14px;
|
|
|
|
+ width: 150px !important;
|
|
|
|
+ --padding-start: 10px !important;
|
|
|
|
+ --padding-top: 7px !important;
|
|
|
|
+ --padding-bottom: 5px !important;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|