sales-trend.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div class="home-container">
  3. <el-card class="home-container__card">
  4. <div>
  5. <div class="title">
  6. <span>
  7. 运行车辆
  8. </span>
  9. <span>
  10. <i
  11. class="el-icon-refresh-right"
  12. style="cursor: pointer;font-size:20px"
  13. @click="refresh"
  14. ></i>
  15. </span>
  16. </div>
  17. <div class="content" v-loading="loading">
  18. <el-table
  19. :data="tableData"
  20. stripe
  21. size="mini"
  22. height="420"
  23. style="width: 100%;">
  24. <el-table-column
  25. align="center"
  26. prop="billNo">
  27. <template slot-scope="{row}">
  28. <span class="el-button--text" style="cursor: pointer"
  29. @click="openTrack(row)">{{ row.billNo }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column
  33. width="120"
  34. align="center"
  35. prop="plateNo">
  36. <template slot-scope="{row}">
  37. <span class="el-button--text" style="cursor: pointer"
  38. @click="openTrack(row)">{{ row.plateNo }}</span>
  39. </template>
  40. </el-table-column>
  41. <el-table-column
  42. width="100"
  43. prop="status">
  44. <template slot-scope="{row}">
  45. <span v-if="row.status == 0" style="color: #E45656;">未调度</span>
  46. <span v-if="row.status == 1" style="color: #F56C6C;">未派车</span>
  47. <span v-if="row.status == 2" style="color: #F1A532;">未受理</span>
  48. <span v-if="row.status == 3" style="color: #53C21D;">未完工</span>
  49. <span v-if="row.status == 5" style="color: #F56C6C;">未到厂</span>
  50. <span v-if="row.status == 4" style="color: #3C9CFF;">工单关闭</span>
  51. <span v-if="row.status == 6" style="color: #3C9CFF;">已提箱</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column
  55. show-overflow-tooltip
  56. prop="corpName">
  57. </el-table-column>
  58. </el-table>
  59. </div>
  60. </div>
  61. </el-card>
  62. <el-dialog
  63. title="车辆轨迹"
  64. append-to-body
  65. :visible.sync="dialogVisible"
  66. fullscreen
  67. width="80%">
  68. <div id="container"></div>
  69. <div class="input-card" v-if="this.lineArr.length>0">
  70. <h4>轨迹回放控制</h4>
  71. <div class="input-item">
  72. <input type="button" class="btn" value="开始动画" id="start" @click="startAnimation()"/>
  73. <input type="button" class="btn" value="暂停动画" id="pause" @click="pauseAnimation()"/>
  74. </div>
  75. <div class="input-item">
  76. <input type="button" class="btn" value="继续动画" id="resume" @click="resumeAnimation()"/>
  77. <input type="button" class="btn" value="停止动画" id="stop" @click="stopAnimation()"/>
  78. </div>
  79. </div>
  80. <div class="input-card" v-else>
  81. <span style="color: red">暂无该车辆轨迹信息</span>
  82. </div>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script>
  87. import {active} from "@/api/wel";
  88. import {gaude} from "@/api/gaude";
  89. export default {
  90. name: "basicContainer",
  91. props: {
  92. sysType: Number
  93. },
  94. data() {
  95. return {
  96. dialogVisible: false,
  97. loading: false,
  98. tableData: [],
  99. map: null,
  100. marker: null,
  101. lineArr: []
  102. };
  103. },
  104. mounted() {
  105. this.init();
  106. },
  107. beforeDestroy() {
  108. this.map && this.map.destroy();
  109. },
  110. methods: {
  111. openTrack(row){
  112. this.dialogVisible = true
  113. gaude({itemId: row.id}).then(res => {
  114. console.log(res.data.data)
  115. this.lineArr = res.data.data
  116. this.initMap();
  117. })
  118. },
  119. initMap() {
  120. this.map = new AMap.Map("container", {
  121. resizeEnable: true,
  122. center: [116.397428, 39.90923],
  123. zoom: 17
  124. });
  125. let icon = new AMap.Icon({
  126. size: new AMap.Size(52, 26), // 图标尺寸
  127. image: 'https://webapi.amap.com/images/car.png',
  128. imageSize: new AMap.Size(52, 26), // 根据所设置的大小拉伸或压缩图片
  129. });
  130. this.marker = new AMap.Marker({
  131. map: this.map,
  132. position: this.lineArr.length >0 ?this.lineArr[this.lineArr.length - 1]:[120.382891,36.066460],
  133. // icon: "https://webapi.amap.com/images/car.png",
  134. icon: icon,
  135. markerMeta: new AMap.Size(28, 28),
  136. offset: new AMap.Pixel(-26, -15),
  137. autoRotation: true,
  138. angle: -15
  139. });
  140. // 绘制轨迹
  141. let polyline = new AMap.Polyline({
  142. map: this.map,
  143. path: this.lineArr,
  144. showDir: true,
  145. strokeColor: "#28F", //线颜色
  146. // strokeOpacity: 1, //线透明度
  147. strokeWeight: 6 //线宽
  148. // strokeStyle: "solid" //线样式
  149. });
  150. let passedPolyline = new AMap.Polyline({
  151. map: this.map,
  152. // path: this.lineArr,
  153. strokeColor: "#AF5", //线颜色
  154. // strokeOpacity: 1, //线透明度
  155. strokeWeight: 6 //线宽
  156. // strokeStyle: "solid" //线样式
  157. });
  158. this.marker.on("moving", function (e) {
  159. passedPolyline.setPath(e.passedPath);
  160. });
  161. this.map.setFitView();
  162. },
  163. startAnimation() {
  164. this.marker.moveAlong(this.lineArr, 100000);
  165. },
  166. pauseAnimation() {
  167. this.marker.pauseMove();
  168. },
  169. resumeAnimation() {
  170. this.marker.resumeMove();
  171. },
  172. stopAnimation() {
  173. this.marker.stopMove();
  174. },
  175. init() {
  176. this.getsalesTrend();
  177. },
  178. getsalesTrend() {
  179. this.loading = true;
  180. active().then(res => {
  181. this.tableData = res.data.data
  182. this.tableData = this.tableData.concat(res.data.data)
  183. this.tableData = this.tableData.concat(res.data.data)
  184. this.tableData = this.tableData.concat(res.data.data)
  185. this.tableData = this.tableData.concat(res.data.data)
  186. this.tableData = this.tableData.concat(res.data.data)
  187. this.tableData = this.tableData.concat(res.data.data)
  188. this.tableData = this.tableData.concat(res.data.data)
  189. this.loading = false;
  190. })
  191. },
  192. refresh() {
  193. this.init()
  194. }
  195. }
  196. };
  197. </script>
  198. <style scoped Lang="less">
  199. @import url('https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css');
  200. #container {
  201. height: 93vh;
  202. width: 100%;
  203. }
  204. .input-card .btn {
  205. margin-right: 1.2rem;
  206. width: 9rem;
  207. }
  208. .input-card .btn:last-child {
  209. margin-right: 0;
  210. }
  211. </style>
  212. <style lang="scss" scoped>
  213. .home-container {
  214. padding: 0px 5px 5px 0px;
  215. box-sizing: border-box;
  216. height: 100%;
  217. ::v-deep .el-card__body {
  218. padding: 10px 15px;
  219. font-size: 14px;
  220. }
  221. &__card {
  222. width: 100%;
  223. height: 100%;
  224. }
  225. .title {
  226. display: flex;
  227. justify-content: space-between;
  228. }
  229. }
  230. .content {
  231. }
  232. ::v-deep .el-dialog {
  233. margin-top: 0vh !important;
  234. }
  235. ::v-deep .el-dialog__body {
  236. padding: 0 20px 10px 20px !important;
  237. }
  238. </style>