index.vue 16 KB

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