queryTrace.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div id="queryTrace" >
  3. <el-dialog
  4. title="查询轨迹"
  5. width="40%"
  6. top="2rem"
  7. :close-on-click-modal="false"
  8. :visible.sync="showDialog"
  9. :destroy-on-close="true"
  10. @close="close()"
  11. >
  12. <div v-loading="isLoging">
  13. <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>
  14. <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>
  15. <el-button icon="el-icon-search" size="mini" type="primary" @click="onSubmit">查询</el-button>
  16. </div>
  17. </el-dialog>
  18. </div>
  19. </template>
  20. <script>
  21. import DeviceService from '../service/DeviceService'
  22. export default {
  23. name: "deviceEdit",
  24. props: [],
  25. computed: {},
  26. created() {},
  27. data() {
  28. return {
  29. deviceService: new DeviceService(),
  30. pickerOptions: {
  31. shortcuts: [{
  32. text: '今天',
  33. onClick(picker) {
  34. picker.$emit('pick', new Date());
  35. }
  36. }, {
  37. text: '昨天',
  38. onClick(picker) {
  39. const date = new Date();
  40. date.setTime(date.getTime() - 3600 * 1000 * 24);
  41. picker.$emit('pick', date);
  42. }
  43. }, {
  44. text: '一周前',
  45. onClick(picker) {
  46. const date = new Date();
  47. date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
  48. picker.$emit('pick', date);
  49. }
  50. }]
  51. },
  52. searchFrom: null,
  53. searchTo: null,
  54. listChangeCallback: null,
  55. showDialog: false,
  56. isLoging: false,
  57. channel: null,
  58. callback: null,
  59. };
  60. },
  61. methods: {
  62. openDialog: function (channel, callback) {
  63. console.log(channel)
  64. this.showDialog = true;
  65. this.callback = callback;
  66. this.channel = channel;
  67. },
  68. onSubmit: function () {
  69. console.log("onSubmit");
  70. this.isLoging = true;
  71. let url = `/api/position/history/${this.channel.deviceId}?start=${this.searchFrom}&end=${this.searchTo}`;
  72. if (this.channel.channelId) {
  73. url+="&channelId=${this.channel.channelId}"
  74. }
  75. this.$axios.get(url, {
  76. }).then((res)=> {
  77. this.isLoging = false;
  78. if (typeof this.callback == "function") {
  79. if (res.data.code == 0) {
  80. this.callback(res.data.data)
  81. this.close()
  82. }else {
  83. this.$message.error(res.data.msg);
  84. }
  85. }
  86. }).catch(function (error) {
  87. this.isLoging = false;
  88. console.error(error);
  89. })
  90. },
  91. close: function () {
  92. this.showDialog = false;
  93. this.isLoging = false;
  94. this.callback = null;
  95. this.channel = null;
  96. },
  97. },
  98. };
  99. </script>