index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="homeContainer">
  3. <div class="add-edit-dialog-container">
  4. <div class="search-container TableSelectMain">
  5. <el-form class="table-select-main" :model="searchForm" label-position="left">
  6. <el-row :gutter="15">
  7. <el-col :span="4" style="margin-top:6px">
  8. <el-select placeholder="请选择人员" v-model="searchForm.userId" filterable>
  9. <el-option
  10. :label="item.name"
  11. :value="item.userId"
  12. v-for="(item, i) in userList"
  13. :key="i"
  14. ></el-option>
  15. </el-select>
  16. </el-col>
  17. <el-col :span="4">
  18. <el-form-item>
  19. <el-date-picker v-model="searchForm.createTime" type="datetime" placeholder="请选择日期"></el-date-picker>
  20. </el-form-item>
  21. </el-col>
  22. <el-col :span="4">
  23. <el-form-item>
  24. <el-button type="primary" plain round @click="query">查询</el-button>
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. </el-form>
  29. </div>
  30. </div>
  31. <div class="amap-wrapper">
  32. <el-amap vid="amapDemo" :zoom="zoom" :center="center" class="amap-demo">
  33. <el-amap-polyline :path="polyline.path" :strokeOpacity="polyline.strokeOpacity"
  34. :strokeColor="polyline.strokeColor" :strokeWeight="polyline.strokeWeight"></el-amap-polyline>
  35. <el-amap-marker v-for="text in texts" :position="text.position"></el-amap-marker>
  36. <el-amap-text v-for="text in texts" :text="text.text" :position="text.position" :offset="text.offset"></el-amap-text>
  37. </el-amap>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. // 引入高德使用高德
  43. import aMap from "vue-amap";
  44. import { getUserByCompanyId, queryTrail } from '@/apps/mobile/api/monitoring-center/index';
  45. // 初始化高德
  46. aMap.initAMapApiLoader({
  47. key: "937eb4405db2a8895695506871c3a1d5",
  48. plugin: [
  49. "AMap.Autocomplete",
  50. "AMap.PlaceSearch",
  51. "AMap.Scale",
  52. "AMap.OverView",
  53. "AMap.ToolBar",
  54. "AMap.MapType",
  55. "AMap.PolyEditor",
  56. "AMap.CircleEditor"
  57. ],
  58. v: "1.4.4",
  59. uiVersion: "1.0.11"
  60. });
  61. export default {
  62. data() {
  63. return {
  64. searchForm: {},
  65. zoom: 11,
  66. center: [114.407749, 30.455714],
  67. userList: [],
  68. polyline: {
  69. path: [],
  70. strokeOpacity: 1,
  71. strokeColor: "#FF9900",
  72. strokeWeight: 6,
  73. },
  74. texts: []
  75. };
  76. },
  77. created() {
  78. },
  79. mounted() {
  80. let companyData = JSON.parse(sessionStorage.getItem('companyID'));
  81. let companyId = companyData.id;
  82. getUserByCompanyId(companyId)
  83. .then(res => {
  84. for (let i = 0; i < res.data.length; i++) {
  85. this.userList.push(res.data[i]);
  86. }
  87. this.center = [this.userList[0].lon, this.userList[0].lat]
  88. })
  89. .catch(err => err);
  90. },
  91. methods: {
  92. query(){
  93. let obj = {
  94. userId: this.searchForm.userId,
  95. createTime: this.searchForm.createTime
  96. };
  97. console.warn(obj);
  98. queryTrail(obj)
  99. .then(res => {
  100. this.polyline.path = [];
  101. this.texts = [];
  102. this.polyline.path = res.data.polylines;
  103. this.texts = res.data.texts;
  104. this.texts.forEach(tem => {
  105. tem.offset = [0,-50];
  106. })
  107. })
  108. .catch(() => {
  109. });
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="stylus">
  115. .homeContainer {
  116. display: inline-block;
  117. height:700px;
  118. width: 100%;
  119. margin-top: 15px;
  120. padding: 0 15px;
  121. .amap-wrapper {
  122. width: 100%;
  123. height: 700px;
  124. font-size: 18px;
  125. vertical-align: 10px;
  126. el-amap-text{
  127. top:10px;
  128. }
  129. }
  130. .add-edit-dialog-container {
  131. ::v-deep .el-input {
  132. width: auto;
  133. }
  134. }
  135. }
  136. </style>