index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker v-model="table.parammaps.inputDatetime" type="daterange" class="inputDatetime filter-item" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"> </el-date-picker>
  5. <el-input v-model="table.parammaps.tname" placeholder="推料车" style="width: 180px;" class="filter-item" clearable />
  6. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  7. <el-button class="successBorder" @click="form_search">查询</el-button>
  8. </div>
  9. <div class="table">
  10. <el-table
  11. :key="tableKey"
  12. ref="table"
  13. v-loading="listLoading"
  14. element-loading-text="给我一点时间"
  15. :data="list"
  16. border
  17. fit
  18. highlight-current-row
  19. style="width: 100%;"
  20. :row-style="rowStyle"
  21. :cell-style="cellStyle"
  22. class="elTable table-fixed"
  23. :max-height="myHeight"
  24. >
  25. <el-table-column label="序号" align="center" type="index" width="50px" />
  26. <el-table-column label="推料车" min-width="100px" align="center" prop="tname" />
  27. <el-table-column label="备注" min-width="100px" align="center" prop="remark" />
  28. <el-table-column label="开始时间" min-width="100px" align="center" prop="startdate" />
  29. <el-table-column label="结束时间" min-width="100px" align="center" prop="enddate" />
  30. <el-table-column label="运行时间" min-width="100px" align="center" prop="date" />
  31. <el-table-column label="运行轨迹" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  32. <template slot-scope="{row}">
  33. <el-button v-if="isRoleEdit" class="miniSuccess" @click="handleRunning_trajectory(row)">查看</el-button>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <span v-if="listLoading == false" style="margin-right: 30px;margin-top: 10px;font-size: 14px;">共{{total }}条</span>
  38. </div>
  39. <el-dialog :visible.sync="run.dialogFormVisible" :close-on-click-modal="false" width="50%">
  40. <template slot="title">
  41. <div class="avue-crud__dialog__header">
  42. <span class="el-dialog__title">
  43. <span style="display:inline-block;width:3px;height:20px;margin-right:5px; float: left;margin-top:2px" />
  44. 运行轨迹
  45. </span>
  46. <div class="avue-crud__dialog__menu" @click="dialogFull? dialogFull=false: dialogFull=true">
  47. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  48. <svg-icon v-else icon-class="fullscreen" />
  49. </div>
  50. </div>
  51. </template>
  52. <div ref="map" class="map-container"></div>
  53. <div slot="footer" class="dialog-footer">
  54. <el-button class="cancelClose1" @click="run.dialogFormVisible = false;getList()">关闭</el-button>
  55. </div>
  56. </el-dialog>
  57. </div>
  58. </template>
  59. <script>
  60. import { GetDataByName, postJson,getJson, formatNum, checkButtons } from '@/api/common'
  61. import { parseTime} from '@/utils/index.js'
  62. import { MessageBox } from 'element-ui'
  63. import Cookies from 'js-cookie'
  64. import axios from 'axios'
  65. import { getToken } from '@/utils/auth'
  66. import { createApp } from 'vue';
  67. import AMapLoader from '@amap/amap-jsapi-loader';
  68. window._AMapSecurityConfig = {
  69. securityJsCode: '0133db0118e961029dc45a2d5039cbb1' // '「申请的安全密钥」',
  70. }
  71. export default {
  72. name: 'Pushingplan',
  73. data() {
  74. return {
  75. table: {
  76. name:'getTmrEqipmemtList',
  77. parammaps: {
  78. // pastureid: Cookies.get('pastureid'),
  79. tname:'',
  80. startdate:'',
  81. enddate: '',
  82. inputDatetime: null,
  83. // startdate: parseTime(new Date(), '{y}-{m}-{d}'),
  84. // enddate: parseTime(new Date(), '{y}-{m}-{d}'),
  85. // inputDatetime: [new Date(), new Date()],
  86. },
  87. },
  88. tableKey: 0,
  89. list: [],
  90. total: 0,
  91. listLoading: true,
  92. run: {
  93. dialogFormVisible: false,
  94. dialogStatus: '',
  95. temp:{}
  96. },
  97. dialogFull: false,
  98. isRoleEdit: [],
  99. isokDisable: false,
  100. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  101. cellStyle: { padding: 0 + 'px' },
  102. myHeight: document.documentElement.clientHeight - 85- 150,
  103. map: null,
  104. path:[],
  105. // path: [
  106. // [116.405285, 39.904989], // 示例轨迹点1
  107. // [116.407516, 39.904717], // 示例轨迹点2
  108. // [3118.407366, 39.91344], // 示例轨迹点3
  109. // // 添加更多轨迹点
  110. // ],
  111. index: 0,
  112. latitude: 40.878730, // 实景图所在位置的纬度
  113. longitude: 113.216553, // 实景图所在位置的经度
  114. zoom: 17, // 实景
  115. apiKey:'fb6a0e88dbad4931d96a121bcf7c4442'
  116. }
  117. },
  118. mounted() {
  119. // this.initMap();
  120. },
  121. created() {
  122. this.getButtons()
  123. this.getList()
  124. },
  125. methods: {
  126. getButtons() {
  127. const Edit = 'Pushingplan'
  128. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  129. this.isRoleEdit = isRoleEdit
  130. },
  131. getList() {
  132. this.listLoading = true
  133. let url = '/authdata/GetDataByName'
  134. let data = this.table
  135. if(this.table.parammaps.inputDatetime !== null){
  136. data.parammaps.startdate = parseTime(this.table.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  137. data.parammaps.enddate = parseTime(this.table.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  138. }else{
  139. data.parammaps.startdate = ''
  140. data.parammaps.enddate = ''
  141. }
  142. postJson(url,data).then(response => {
  143. console.log('table数据', response.data.list)
  144. if (response.data.list !== null) {
  145. this.list = response.data.list
  146. } else {
  147. this.list = []
  148. }
  149. this.total = response.data.total
  150. setTimeout(() => {
  151. this.listLoading = false
  152. }, 100)
  153. })
  154. },
  155. form_search() {
  156. console.log('点击了查询')
  157. this.getList()
  158. },
  159. handleRefresh(){
  160. this.table.parammaps.tname = ''
  161. this.table.parammaps.inputDatetime = null
  162. this.getList()
  163. },
  164. handleRunning_trajectory(row){
  165. console.log('点击了运行轨迹')
  166. this.run.dialogStatus = 'run'
  167. this.run.dialogFormVisible = true
  168. this.run.temp = Object.assign({}, row)
  169. this.getRuningList()
  170. },
  171. getRuningList(){
  172. let url = '/authdata/equipment/muster'
  173. let data = '?id='+this.run.temp.id
  174. getJson(url,data).then(response => {
  175. // path
  176. // console.log('table数据', response.data.list)
  177. if (response.data !== null) {
  178. let arrList = []
  179. for(let i=0;i<response.data.length;i++){
  180. let list = []
  181. list.push(parseFloat(response.data[i].N),parseFloat(response.data[i].A))
  182. arrList.push(list)
  183. }
  184. // console.log(JSON.stringify(arrList),'arrList')
  185. this.path = arrList
  186. // this.path = [ //测试数据
  187. // [116.405285, 39.904989], // 示例轨迹点1
  188. // [116.407516, 39.904987], // 示例轨迹点2
  189. // [116.407517, 39.91344] // 示例轨迹点3
  190. // // 添加更多轨迹点
  191. // ]
  192. // this.path = [
  193. // [121.461525,31.312628],
  194. // // [121.461526,31.312628],[121.461527,31.312628],[121.461527,31.312628]
  195. // ]
  196. console.log(this.path[0][0])
  197. this.longitude = this.path[0][0] // 实景图所在位置的经度
  198. this.latitude = this.path[0][1] // 实景图所在位置的纬度
  199. // zoom: 15, // 实景
  200. this.initMap();
  201. } else {
  202. this.path = []
  203. }
  204. // this.initMap();
  205. })
  206. },
  207. async initMap() {
  208. await AMapLoader.load({
  209. key: 'fb6a0e88dbad4931d96a121bcf7c4442', // 替换为你的高德地图API Key
  210. version: '2.0',
  211. plugins: [],
  212. }).then(()=>{
  213. })
  214. this.map = new window.AMap.Map(this.$refs.map, {
  215. zoom: 16,
  216. center: this.path[0],
  217. // layers: [
  218. // new window.AMap.TileLayer.Satellite() // 使用卫星地图图层
  219. // ]
  220. });
  221. const startMarker = new window.AMap.Marker({
  222. position: this.path[0], // 起始点位置
  223. map: this.map,
  224. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/start.png', // 起始点图标
  225. });
  226. const endMarker = new window.AMap.Marker({
  227. position: this.path[this.path.length - 1],
  228. map: this.map,
  229. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/end.png', // 终点图标
  230. });
  231. this.correctPath();
  232. this.drawPath();
  233. // this.addStartMarker()
  234. },
  235. correctPath() {
  236. // 调用高德地图的轨迹纠偏服务进行处理
  237. // 处理返回结果并在地图上展示纠偏后的轨迹
  238. },
  239. drawDrop(){
  240. var that = this
  241. that.path.forEach(function(coord, index) {
  242. // console.log(coord, index,'coord, index')
  243. var marker = new AMap.Marker({
  244. position: coord, // 对应点的经/纬度
  245. map: that.map, // 显示在地图上
  246. icon: new AMap.Icon({
  247. // size: new AMap.Size(36, 36), // 图标尺寸
  248. image: 'http://webapi.amap.com/theme/v1.3/markers/n/mark_b'+ (index + 1) +'.png', // 自定义图标
  249. // imageSize: new AMap.Size(36, 36), // 图标尺寸
  250. }),
  251. offset: new AMap.Pixel(-10, -30) // 调整图标的偏移,使图标中心显示在点位置
  252. });
  253. // var label = new AMap.Text({
  254. // text: (index + 1).toString(), // 显示的数字
  255. // position: coord, // 标签位置与点位置相同
  256. // offset: new AMap.Pixel(-10, -20), // 调整标签的偏移,使数字显示在点的正上方
  257. // map: that.map // 显示在地图上
  258. // });
  259. // 添加信息窗体
  260. marker.on('click', function() {
  261. var infoWindow = new AMap.InfoWindow({
  262. content: '经度:' + coord[0] + '<br>纬度:' + coord[1]
  263. });
  264. infoWindow.open(that.map, marker.getPosition());
  265. });
  266. });
  267. },
  268. drawPath() {
  269. const polyline = new window.AMap.Polyline({
  270. path: this.path,
  271. strokeStyle: 'red',
  272. strokeColor: '#3366FF',
  273. strokeOpacity: 1,
  274. strokeWeight: 3,
  275. map: this.map,
  276. dirArrowStyle: true,
  277. });
  278. // 调整地图视图以适应轨迹
  279. this.map.setFitView();
  280. this.map.setZoom(16)
  281. },
  282. }
  283. }
  284. </script>
  285. <style lang="scss" scoped>
  286. .map-container {
  287. height: 400px;
  288. width: 100%;
  289. }
  290. .search {
  291. clear: both;
  292. }
  293. .table {
  294. margin-top: 10px;
  295. }
  296. .el-tag{margin-right: 5px;}
  297. </style>
  298. <style lang="scss">
  299. .red-row{
  300. background: #fde2e2 !important;
  301. }
  302. </style>