index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-date-picker
  5. v-model="table.parammaps.inputDatetime"
  6. type="daterange"
  7. class="inputDatetime filter-item"
  8. range-separator="至"
  9. start-placeholder="开始日期"
  10. end-placeholder="结束日期"
  11. >
  12. </el-date-picker>
  13. <el-input
  14. v-model="table.parammaps.tname"
  15. placeholder="推料车"
  16. style="width: 180px"
  17. class="filter-item"
  18. clearable
  19. />
  20. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  21. <el-button class="successBorder" @click="form_search">查询</el-button>
  22. </div>
  23. <div class="table">
  24. <el-table
  25. :key="tableKey"
  26. ref="table"
  27. v-loading="listLoading"
  28. element-loading-text="给我一点时间"
  29. :data="list"
  30. border
  31. fit
  32. highlight-current-row
  33. style="width: 100%"
  34. :row-style="rowStyle"
  35. :cell-style="cellStyle"
  36. class="elTable table-fixed"
  37. :max-height="myHeight"
  38. >
  39. <el-table-column
  40. label="序号"
  41. align="center"
  42. type="index"
  43. width="50px"
  44. />
  45. <el-table-column
  46. label="推料车"
  47. min-width="100px"
  48. align="center"
  49. prop="tname"
  50. />
  51. <el-table-column
  52. label="备注"
  53. min-width="100px"
  54. align="center"
  55. prop="remark"
  56. />
  57. <el-table-column
  58. label="开始时间"
  59. min-width="100px"
  60. align="center"
  61. prop="startdate"
  62. />
  63. <el-table-column
  64. label="结束时间"
  65. min-width="100px"
  66. align="center"
  67. prop="enddate"
  68. />
  69. <el-table-column
  70. label="运行时间"
  71. min-width="100px"
  72. align="center"
  73. prop="date"
  74. />
  75. <el-table-column
  76. label="运行轨迹"
  77. align="center"
  78. width="80"
  79. class-name="small-padding fixed-width"
  80. fixed="right"
  81. >
  82. <template slot-scope="{ row }">
  83. <el-button
  84. v-if="isRoleEdit"
  85. class="miniSuccess"
  86. @click="handleRunning_trajectory(row)"
  87. >查看</el-button
  88. >
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <!-- <span
  93. v-if="listLoading == false"
  94. style="margin-right: 30px; margin-top: 10px; font-size: 14px"
  95. >共{{ total }}条</span
  96. > -->
  97. </div>
  98. <!-- 分页 start-->
  99. <el-pagination
  100. class="pages"
  101. v-if="listLoading == false"
  102. @size-change="handleSizeChange"
  103. @current-change="handleCurrentChange"
  104. :current-page="currentPage"
  105. :page-sizes="[50, 100, 150, 200]"
  106. :page-size="table.pagecount"
  107. layout="total, sizes, prev, pager, next, jumper"
  108. :total="total"
  109. >
  110. </el-pagination>
  111. <!-- 分页 end -->
  112. <el-dialog
  113. :visible.sync="run.dialogFormVisible"
  114. :close-on-click-modal="false"
  115. width="80%"
  116. >
  117. <template slot="title">
  118. <div class="avue-crud__dialog__header">
  119. <span class="el-dialog__title">
  120. <span
  121. style="
  122. display: inline-block;
  123. width: 3px;
  124. height: 20px;
  125. margin-right: 5px;
  126. float: left;
  127. margin-top: 2px;
  128. "
  129. />
  130. 运行轨迹
  131. </span>
  132. <div
  133. class="avue-crud__dialog__menu"
  134. @click="dialogFull ? (dialogFull = false) : (dialogFull = true)"
  135. >
  136. <svg-icon v-if="dialogFull" icon-class="exit-fullscreen" />
  137. <svg-icon v-else icon-class="fullscreen" />
  138. </div>
  139. </div>
  140. </template>
  141. <!-- <div style="margin-bottom: 20px;background-image: url('http://niu305.cn:8091/uploads/image/headphoto1.png');background-position: top right;"> -->
  142. <div class="run-box">
  143. <div ref="map" class="map-container"></div>
  144. <div class="run-box-rg">
  145. <h3>运动轨迹详情</h3>
  146. <div>
  147. <span>推料车:</span>{{1}}
  148. </div>
  149. <div>
  150. <span>推料车:</span>{{1}}
  151. </div>
  152. <div>
  153. <span>计划开始时间:</span>{{1}}
  154. </div>
  155. <div>
  156. <span>实际开始时间:</span>{{1}}
  157. </div>
  158. <div>
  159. <span>实际结束时间:</span>{{1}}
  160. </div>
  161. <div>
  162. <span>实际时长:</span>{{1}}
  163. </div>
  164. <div>
  165. <span>偏差分钟数:</span>{{1}}
  166. </div>
  167. <div>
  168. <span>备注:</span>{{1}}
  169. </div>
  170. <div>
  171. <span>计划推料顺序(栏舍):</span>{{1}}
  172. </div>
  173. </div>
  174. </div>
  175. <!-- </div> -->
  176. <div slot="footer" class="dialog-footer">
  177. <el-button
  178. class="cancelClose1"
  179. @click="
  180. run.dialogFormVisible = false
  181. getList()
  182. "
  183. >关闭</el-button
  184. >
  185. </div>
  186. </el-dialog>
  187. </div>
  188. </template>
  189. <script>
  190. import {
  191. GetDataByName,
  192. postJson,
  193. getJson,
  194. formatNum,
  195. checkButtons
  196. } from '@/api/common'
  197. import { parseTime } from '@/utils/index.js'
  198. import { MessageBox } from 'element-ui'
  199. import Cookies from 'js-cookie'
  200. import axios from 'axios'
  201. import { getToken } from '@/utils/auth'
  202. import { createApp } from 'vue'
  203. import AMapLoader from '@amap/amap-jsapi-loader'
  204. // import vLoUrl from '../../../assets/images/tet.png'
  205. import vLoUrl from '../../../assets/images/guiji2.jpeg'
  206. window._AMapSecurityConfig = {
  207. securityJsCode: '0133db0118e961029dc45a2d5039cbb1' // '「申请的安全密钥」',
  208. }
  209. export default {
  210. name: 'Pushingplan',
  211. data() {
  212. return {
  213. currentPage: 1,
  214. table: {
  215. offset: 1,
  216. name: 'getTmrEqipmemtList',
  217. pagecount: 50,
  218. parammaps: {
  219. // pastureid: Cookies.get('pastureid'),
  220. tname: '',
  221. startdate: '',
  222. enddate: '',
  223. inputDatetime: null
  224. // startdate: parseTime(new Date(), '{y}-{m}-{d}'),
  225. // enddate: parseTime(new Date(), '{y}-{m}-{d}'),
  226. // inputDatetime: [new Date(), new Date()],
  227. }
  228. },
  229. tableKey: 0,
  230. list: [],
  231. total: 0,
  232. listLoading: true,
  233. run: {
  234. dialogFormVisible: false,
  235. dialogStatus: '',
  236. temp: {}
  237. },
  238. dialogFull: false,
  239. isRoleEdit: [],
  240. isokDisable: false,
  241. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  242. cellStyle: { padding: 0 + 'px' },
  243. myHeight: document.documentElement.clientHeight - 85 - 150,
  244. map: null,
  245. path: [],
  246. // path: [
  247. // [116.405285, 39.904989], // 示例轨迹点1
  248. // [116.407516, 39.904717], // 示例轨迹点2
  249. // [3118.407366, 39.91344], // 示例轨迹点3
  250. // // 添加更多轨迹点
  251. // ],
  252. index: 0,
  253. latitude: 40.87873, // 实景图所在位置的纬度
  254. longitude: 113.216553, // 实景图所在位置的经度
  255. zoom: 17, // 实景
  256. apiKey: 'fb6a0e88dbad4931d96a121bcf7c4442',
  257. vLoUrl
  258. }
  259. },
  260. mounted() {
  261. // this.initMap();
  262. },
  263. created() {
  264. this.getButtons()
  265. this.getList()
  266. },
  267. methods: {
  268. // 分页
  269. handleSizeChange(val) {
  270. console.log(`每页 ${val} 条`)
  271. this.table.pagecount = val
  272. this.table.offset = 1
  273. this.currentPage = 1
  274. this.getList()
  275. },
  276. handleCurrentChange(val) {
  277. console.log(`当前页: ${val}`)
  278. this.currentPage = val
  279. this.table.offset = val
  280. this.getList()
  281. },
  282. getButtons() {
  283. const Edit = 'Pushingplan'
  284. const isRoleEdit = checkButtons(
  285. JSON.parse(sessionStorage.getItem('buttons')),
  286. Edit
  287. )
  288. this.isRoleEdit = isRoleEdit
  289. },
  290. getList() {
  291. this.listLoading = true
  292. let url = '/authdata/GetDataByName'
  293. let data = this.table
  294. if (this.table.parammaps.inputDatetime !== null) {
  295. data.parammaps.startdate = parseTime(
  296. this.table.parammaps.inputDatetime[0],
  297. '{y}-{m}-{d}'
  298. )
  299. data.parammaps.enddate = parseTime(
  300. this.table.parammaps.inputDatetime[1],
  301. '{y}-{m}-{d}'
  302. )
  303. } else {
  304. data.parammaps.startdate = ''
  305. data.parammaps.enddate = ''
  306. }
  307. postJson(url, data).then((response) => {
  308. console.log('table数据', response.data.list)
  309. if (response.data.list !== null) {
  310. this.list = response.data.list
  311. } else {
  312. this.list = []
  313. }
  314. this.total = response.data.total
  315. setTimeout(() => {
  316. this.listLoading = false
  317. }, 100)
  318. })
  319. },
  320. form_search() {
  321. console.log('点击了查询')
  322. this.getList()
  323. },
  324. handleRefresh() {
  325. this.table.parammaps.tname = ''
  326. this.table.parammaps.inputDatetime = null
  327. this.getList()
  328. },
  329. handleRunning_trajectory(row) {
  330. console.log('点击了运行轨迹')
  331. this.run.dialogStatus = 'run'
  332. this.run.dialogFormVisible = true
  333. this.run.temp = Object.assign({}, row)
  334. this.getRuningList()
  335. },
  336. getRuningList() {
  337. let url = '/authdata/equipment/muster'
  338. let data = '?id=' + this.run.temp.id
  339. getJson(url, data).then((response) => {
  340. // path
  341. // console.log('table数据', response.data.list)
  342. if (response.data !== null) {
  343. let arrList = []
  344. for (let i = 0; i < response.data.length; i++) {
  345. let list = []
  346. // let str= `${parseFloat(response.data[i].N)} ${parseFloat(response.data[i].A)} `
  347. list.push(
  348. parseFloat(response.data[i].N),
  349. parseFloat(response.data[i].A)
  350. )
  351. arrList.push(list)
  352. ////////
  353. // let testArr =[];
  354. // testArr.push(parseFloat(response.data[i].A),parseFloat(response.data[i].N));
  355. // arrList.push(testArr);
  356. //////
  357. }
  358. this.path = arrList //真实数据
  359. // console.log(JSON.stringify(arrList),'arrList')
  360. // console.log(arrList.join('\n'),'9999999');
  361. // 测试数据
  362. // this.path = [
  363. // // [116.317911, 39.939229], // 示例轨迹点1
  364. // // [116.327911, 39.939229], // 示例轨迹点1
  365. // // [116.328911, 39.939329], // 示例轨迹点1
  366. // // [116.338911, 39.939429], // 示例轨迹点1
  367. // // [116.342659, 39.946275]
  368. // // [113.2268105910612,40.88140752472374],
  369. // // [113.210637000,40.8765545]
  370. // [113.210637000,40.8765548] ,// 左下
  371. // // [113.210637002,40.8765551],
  372. // // [113.210637012,40.8765561],
  373. // // [113.210637015,40.8765562],
  374. // // [113.210637020,40.8765564],
  375. // // [113.210637021,40.8765568],
  376. // // [113.213728833,40.8798781621],
  377. // // [113.214728833,40.8798781624],
  378. // // [113.215728833,40.8798781342],
  379. // // [113.216728833,40.8798781664],
  380. // [113.210637000,40.8798781666], //左上
  381. // [113.219728833,40.8798781666],//// 右上
  382. // ]
  383. // this.longitude = this.path[0][0] // 实景图所在位置的经度
  384. // this.latitude = this.path[0][1] // 实景图所在位置的纬度
  385. // zoom: 15, // 实景
  386. } else {
  387. this.path = []
  388. }
  389. this.initMap()
  390. })
  391. },
  392. async initMap() {
  393. await AMapLoader.load({
  394. key: 'fb6a0e88dbad4931d96a121bcf7c4442', // 替换为你的高德地图API Key
  395. version: '2.0',
  396. plugins: []
  397. }).then(() => {})
  398. // 后续牧场栏舍图
  399. var backgroundImageUrl = this.vLoUrl // 示例图片链接
  400. var imageLayer = new AMap.ImageLayer({
  401. url: backgroundImageUrl,
  402. bounds: new AMap.Bounds(
  403. // this.path[0],
  404. // this.path[this.path.length - 1]
  405. // [113.20750428,40.87528624] ,// 左下
  406. // [113.22348518,40.88395588], // 右上
  407. [113.21478078, 40.87649131], //左下角;
  408. [113.23067741, 40.88588863] // 右上角
  409. ), //图片范围大小的经纬度,传入西南和东北的经纬度坐标
  410. zooms: [15, 20]
  411. })
  412. this.map = new window.AMap.Map(this.$refs.map, {
  413. zoom: 18,
  414. // zIndex:2,
  415. center: [113.21549472999999, 40.879621060000005],
  416. layers: [AMap.createDefaultLayer(), imageLayer]
  417. })
  418. const startMarker = new window.AMap.Marker({
  419. position: this.path[this.path.length - 1], // 起始点位置
  420. map: this.map,
  421. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/start.png' // 起始点图标
  422. })
  423. const endMarker = new window.AMap.Marker({
  424. position: this.path[0],
  425. map: this.map,
  426. icon: 'https://webapi.amap.com/theme/v1.3/markers/n/end.png' // 终点图标
  427. })
  428. this.drawPath()
  429. },
  430. drawPath() {
  431. const polyline = new window.AMap.Polyline({
  432. path: this.path,
  433. strokeStyle: 'red',
  434. strokeColor: '#F9423A',
  435. strokeOpacity: 1,
  436. strokeWeight: 3,
  437. map: this.map,
  438. dirArrowStyle: true
  439. })
  440. // 调整地图视图以适应轨迹
  441. this.map.setFitView()
  442. this.map.setZoom(18)
  443. }
  444. }
  445. }
  446. </script>
  447. <style lang="scss" scoped>
  448. .run-box{
  449. border:1px solid red;
  450. display: flex;
  451. justify-content: space-between;
  452. height: 600px;
  453. }
  454. .run-box-rg{
  455. flex: 1;
  456. border:1px solid green;
  457. padding-left: 20px;
  458. min-width:300px;
  459. font-size:16px;
  460. .run-box-rg span{
  461. font-size: 16px!important;
  462. }
  463. .run-box-rg>div{
  464. margin: 15px 0;
  465. }
  466. }
  467. .map-container {
  468. height: 600px;
  469. width: 840px;
  470. }
  471. .search {
  472. clear: both;
  473. }
  474. .table {
  475. margin-top: 10px;
  476. }
  477. .el-tag {
  478. margin-right: 5px;
  479. }
  480. .pages {
  481. margin-top: 12px;
  482. }
  483. </style>
  484. <style lang="scss">
  485. .red-row {
  486. background: #fde2e2 !important;
  487. }
  488. </style>