index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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">
  53. <!-- <img src="'https://inews.gtimg.com/om_bt/OtxRSLxjDKPT0ajd72ZeQk6IrtFinjJu7g5Nb9oCkI6SoAA/641'" alt=""> -->
  54. </div>
  55. <div slot="footer" class="dialog-footer">
  56. <el-button class="cancelClose1" @click="run.dialogFormVisible = false;getList()">关闭</el-button>
  57. </div>
  58. </el-dialog>
  59. </div>
  60. </template>
  61. <script>
  62. import { GetDataByName, postJson,getJson, formatNum, checkButtons } from '@/api/common'
  63. import { parseTime} from '@/utils/index.js'
  64. import { MessageBox } from 'element-ui'
  65. import Cookies from 'js-cookie'
  66. import axios from 'axios'
  67. import { getToken } from '@/utils/auth'
  68. import { createApp } from 'vue';
  69. import AMapLoader from '@amap/amap-jsapi-loader';
  70. import vLoUrl from '../../../assets/images/logo.png';
  71. window._AMapSecurityConfig = {
  72. securityJsCode: '0133db0118e961029dc45a2d5039cbb1' // '「申请的安全密钥」',
  73. }
  74. export default {
  75. name: 'Pushingplan',
  76. data() {
  77. return {
  78. table: {
  79. name:'getTmrEqipmemtList',
  80. parammaps: {
  81. // pastureid: Cookies.get('pastureid'),
  82. tname:'',
  83. startdate:'',
  84. enddate: '',
  85. inputDatetime: null,
  86. // startdate: parseTime(new Date(), '{y}-{m}-{d}'),
  87. // enddate: parseTime(new Date(), '{y}-{m}-{d}'),
  88. // inputDatetime: [new Date(), new Date()],
  89. },
  90. },
  91. tableKey: 0,
  92. list: [],
  93. total: 0,
  94. listLoading: true,
  95. run: {
  96. dialogFormVisible: false,
  97. dialogStatus: '',
  98. temp:{}
  99. },
  100. dialogFull: false,
  101. isRoleEdit: [],
  102. isokDisable: false,
  103. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  104. cellStyle: { padding: 0 + 'px' },
  105. myHeight: document.documentElement.clientHeight - 85- 150,
  106. map: null,
  107. path:[],
  108. // path: [
  109. // [116.405285, 39.904989], // 示例轨迹点1
  110. // [116.407516, 39.904717], // 示例轨迹点2
  111. // [3118.407366, 39.91344], // 示例轨迹点3
  112. // // 添加更多轨迹点
  113. // ],
  114. index: 0,
  115. latitude: 40.878730, // 实景图所在位置的纬度
  116. longitude: 113.216553, // 实景图所在位置的经度
  117. zoom: 17, // 实景
  118. apiKey:'fb6a0e88dbad4931d96a121bcf7c4442',
  119. vLoUrl
  120. }
  121. },
  122. mounted() {
  123. // this.initMap();
  124. },
  125. created() {
  126. this.getButtons()
  127. this.getList()
  128. },
  129. methods: {
  130. getButtons() {
  131. const Edit = 'Pushingplan'
  132. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  133. this.isRoleEdit = isRoleEdit
  134. },
  135. getList() {
  136. this.listLoading = true
  137. let url = '/authdata/GetDataByName'
  138. let data = this.table
  139. if(this.table.parammaps.inputDatetime !== null){
  140. data.parammaps.startdate = parseTime(this.table.parammaps.inputDatetime[0], '{y}-{m}-{d}')
  141. data.parammaps.enddate = parseTime(this.table.parammaps.inputDatetime[1], '{y}-{m}-{d}')
  142. }else{
  143. data.parammaps.startdate = ''
  144. data.parammaps.enddate = ''
  145. }
  146. postJson(url,data).then(response => {
  147. console.log('table数据', response.data.list)
  148. if (response.data.list !== null) {
  149. this.list = response.data.list
  150. } else {
  151. this.list = []
  152. }
  153. this.total = response.data.total
  154. setTimeout(() => {
  155. this.listLoading = false
  156. }, 100)
  157. })
  158. },
  159. form_search() {
  160. console.log('点击了查询')
  161. this.getList()
  162. },
  163. handleRefresh(){
  164. this.table.parammaps.tname = ''
  165. this.table.parammaps.inputDatetime = null
  166. this.getList()
  167. },
  168. handleRunning_trajectory(row){
  169. console.log('点击了运行轨迹')
  170. this.run.dialogStatus = 'run'
  171. this.run.dialogFormVisible = true
  172. this.run.temp = Object.assign({}, row)
  173. this.getRuningList()
  174. },
  175. getRuningList(){
  176. let url = '/authdata/equipment/muster'
  177. let data = '?id='+this.run.temp.id
  178. getJson(url,data).then(response => {
  179. // path
  180. // console.log('table数据', response.data.list)
  181. if (response.data !== null) {
  182. let arrList = []
  183. for(let i=0;i<response.data.length;i++){
  184. let list = []
  185. list.push(parseFloat(response.data[i].N),parseFloat(response.data[i].A))
  186. arrList.push(list)
  187. }
  188. // console.log(JSON.stringify(arrList),'arrList')
  189. this.path = arrList
  190. this.longitude = this.path[0][0] // 实景图所在位置的经度
  191. this.latitude = this.path[0][1] // 实景图所在位置的纬度
  192. // zoom: 15, // 实景
  193. } else {
  194. this.path = []
  195. }
  196. this.initMap();
  197. })
  198. },
  199. async initMap() {
  200. await AMapLoader.load({
  201. key: 'fb6a0e88dbad4931d96a121bcf7c4442', // 替换为你的高德地图API Key
  202. version: '2.0',
  203. plugins: [],
  204. }).then(()=>{
  205. })
  206. this.map = new window.AMap.Map(this.$refs.map, {
  207. zoom: 16,
  208. center: this.path[0],
  209. // layers: [
  210. // new window.AMap.TileLayer.Satellite() // 使用卫星地图图层
  211. // ]
  212. });
  213. const startMarker = new window.AMap.Marker({
  214. position: this.path[0], // 起始点位置
  215. map: this.map,
  216. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/start.png', // 起始点图标
  217. });
  218. const endMarker = new window.AMap.Marker({
  219. position: this.path[this.path.length - 1],
  220. map: this.map,
  221. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/end.png', // 终点图标
  222. });
  223. // var imageLayer = new AMap.ImageLayer({
  224. // url: 'https://inews.gtimg.com/om_bt/OtxRSLxjDKPT0ajd72ZeQk6IrtFinjJu7g5Nb9oCkI6SoAA/641',
  225. // // bounds: new AMap.Bounds(
  226. // // [116.327911, 39.939229],
  227. // // [116.342659, 39.946275]
  228. // // ),
  229. // // zooms: [1, 50]
  230. // });
  231. // var imageLayers = new AMap.ImageLayer({
  232. // url: 'https://inews.gtimg.com/om_bt/OtxRSLxjDKPT0ajd72ZeQk6IrtFinjJu7g5Nb9oCkI6SoAA/641',
  233. // // url: this.vLoUrl,
  234. // bounds: new AMap.Bounds(
  235. // [121.97563085677434,27.92512942520125],
  236. // [131.551866454716, 36.16701972816233]
  237. // ),
  238. // zooms: [1, 50]
  239. // });
  240. // this.map.add([imageLayer,imageLayers])
  241. this.drawPath();
  242. },
  243. drawPath() {
  244. const polyline = new window.AMap.Polyline({
  245. path: this.path,
  246. strokeStyle: 'red',
  247. strokeColor: '#3366FF',
  248. strokeOpacity: 1,
  249. strokeWeight: 3,
  250. map: this.map,
  251. dirArrowStyle: true,
  252. });
  253. // 调整地图视图以适应轨迹
  254. this.map.setFitView();
  255. this.map.setZoom(16)
  256. },
  257. }
  258. }
  259. </script>
  260. <style lang="scss" scoped>
  261. .map-container {
  262. height: 400px;
  263. width: 800px;
  264. }
  265. .search {
  266. clear: both;
  267. }
  268. .table {
  269. margin-top: 10px;
  270. }
  271. .el-tag{margin-right: 5px;}
  272. </style>
  273. <style lang="scss">
  274. .red-row{
  275. background: #fde2e2 !important;
  276. }
  277. </style>