index.vue 15 KB

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