648540858
2023-02-10 f2c6210539cfc5f423a773b4d897c37a9066f821
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<template>
  <div id="queryTrace" >
    <el-dialog
      title="查询轨迹"
      width="40%"
      top="2rem"
      :close-on-click-modal="false"
      :visible.sync="showDialog"
      :destroy-on-close="true"
      @close="close()"
    >
      <div v-loading="isLoging">
        <el-date-picker v-model="searchFrom" type="datetime" placeholder="选择开始日期时间" default-time="00:00:00" value-format="yyyy-MM-dd HH:mm:ss" size="mini" style="width: 11rem;" align="right" :picker-options="pickerOptions"></el-date-picker>
        <el-date-picker v-model="searchTo" type="datetime" placeholder="选择结束日期时间" default-time="00:00:00" value-format="yyyy-MM-dd HH:mm:ss" size="mini" style="width: 11rem;" align="right" :picker-options="pickerOptions"></el-date-picker>
        <el-button icon="el-icon-search" size="mini" type="primary" @click="onSubmit">查询</el-button>
      </div>
 
    </el-dialog>
  </div>
</template>
 
<script>
import DeviceService from '../service/DeviceService'
 
export default {
  name: "deviceEdit",
  props: [],
  computed: {},
  created() {},
  data() {
    return {
      deviceService: new DeviceService(),
      pickerOptions: {
        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);
          }
        }]
      },
      searchFrom: null,
      searchTo: null,
      listChangeCallback: null,
      showDialog: false,
      isLoging: false,
      channel: null,
      callback: null,
    };
  },
  methods: {
    openDialog: function (channel, callback) {
      console.log(channel)
      this.showDialog = true;
      this.callback = callback;
      this.channel = channel;
    },
 
    onSubmit: function () {
      console.log("onSubmit");
      this.isLoging = true;
      let url = `./api/position/history/${this.channel.deviceId}?start=${this.searchFrom}&end=${this.searchTo}`;
      if (this.channel.channelId) {
        url+="&channelId=${this.channel.channelId}"
      }
      this.$axios.get(url, {
      }).then((res)=> {
        this.isLoging = false;
        if (typeof this.callback == "function") {
          if (res.data.code == 0) {
            this.callback(res.data.data)
            this.close()
          }else {
            this.$message.error(res.data.msg);
          }
 
        }
      }).catch(function (error) {
          this.isLoging = false;
          console.error(error);
        })
    },
    close: function () {
      this.showDialog = false;
      this.isLoging = false;
      this.callback = null;
      this.channel = null;
    },
  },
};
</script>