index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. <template>
  2. <div class="app-container">
  3. <div id="data-view">
  4. <div class="main-header">
  5. <div class="mh-middle">数字健康社区定位系统</div>
  6. <div class="mh-right">
  7. <div>{{ dateTime }}</div>
  8. <div>
  9. <img
  10. src="./img/quanping.png"
  11. alt=""
  12. @click="toggleFullscreen"
  13. v-if="!isFullscreen"
  14. />
  15. <img
  16. src="./img/tuichuquanping.png"
  17. alt=""
  18. @click="toggleFullscreen"
  19. v-if="isFullscreen"
  20. />
  21. </div>
  22. </div>
  23. </div>
  24. <div class="main">
  25. <div class="left">
  26. <div class="left-top">
  27. <div class="top-left"><Left-Chart-Top /></div>
  28. <div class="top-right">
  29. <equ-map
  30. v-loading="mapLoading"
  31. @callback="initMap"
  32. height="100%"
  33. />
  34. </div>
  35. </div>
  36. <div class="left-under">
  37. <div class="under-title"><b>告警处理完成</b></div>
  38. <dv-border-box-8 class="under-box" v-if="flag">
  39. <Left-Chart-Bottom
  40. title="SOS报警处理"
  41. :value="percentData.alarmSOS"
  42. ></Left-Chart-Bottom>
  43. <Left-Chart-Bottom
  44. title="电子围栏报警"
  45. :value="percentData.alarmRail"
  46. ></Left-Chart-Bottom>
  47. <Left-Chart-Bottom
  48. title="跌倒报警"
  49. :value="percentData.alarmFall"
  50. ></Left-Chart-Bottom>
  51. <Left-Chart-Bottom
  52. title="设备在线率"
  53. :value="percentData.alarmStauts"
  54. ></Left-Chart-Bottom>
  55. <Left-Chart-Bottom
  56. title="全部报警"
  57. :value="percentData.alarmAll"
  58. ></Left-Chart-Bottom>
  59. </dv-border-box-8>
  60. </div>
  61. </div>
  62. <div class="right">
  63. <Left-Chart-Right ref="updateData" />
  64. </div>
  65. </div>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import LeftChartTop from "./LeftChartTop";
  71. import LeftChartRight from "./LeftChartRight";
  72. import LeftChartBottom from "./LeftChartBottom";
  73. import equMap from "./Map.vue";
  74. import { percent, alarmList } from "@/api/system/datav";
  75. export default {
  76. name: "DataView",
  77. components: {
  78. LeftChartTop,
  79. LeftChartRight,
  80. LeftChartBottom,
  81. equMap,
  82. },
  83. data() {
  84. return {
  85. mapLoading: false,
  86. percentData: {},
  87. flag: false,
  88. isFullscreen: false, // 初始状态为非全屏
  89. dateTime: "",
  90. };
  91. },
  92. mounted() {
  93. this.initData();
  94. this.currentTime();
  95. },
  96. methods: {
  97. currentTime() {
  98. setInterval(this.getTime, 500);
  99. },
  100. getTime() {
  101. var _this = this;
  102. let yy = new Date().getFullYear();
  103. let mm =
  104. new Date().getMonth() + 1 < 10
  105. ? "0" + (new Date().getMonth() + 1)
  106. : new Date().getMonth() + 1;
  107. let dd =
  108. new Date().getDate() < 10
  109. ? "0" + new Date().getDate()
  110. : new Date().getDate();
  111. let hh =
  112. new Date().getHours() < 10
  113. ? "0" + new Date().getHours()
  114. : new Date().getHours();
  115. let mf =
  116. new Date().getMinutes() < 10
  117. ? "0" + new Date().getMinutes()
  118. : new Date().getMinutes();
  119. let ss =
  120. new Date().getSeconds() < 10
  121. ? "0" + new Date().getSeconds()
  122. : new Date().getSeconds();
  123. _this.dateTime =
  124. yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
  125. },
  126. toggleFullscreen() {
  127. if (this.isFullscreen) {
  128. // 退出全屏模式
  129. if (document.exitFullscreen) {
  130. document.exitFullscreen();
  131. } else if (document.mozCancelFullScreen) {
  132. document.mozCancelFullScreen();
  133. } else if (document.webkitExitFullscreen) {
  134. document.webkitExitFullscreen();
  135. }
  136. this.isFullscreen = false;
  137. } else {
  138. // 进入全屏模式
  139. const content = document.querySelector("#data-view");
  140. // console.log(content,888);
  141. // return
  142. if (content.requestFullscreen) {
  143. content.requestFullscreen();
  144. } else if (content.mozRequestFullScreen) {
  145. content.mozRequestFullScreen();
  146. } else if (content.webkitRequestFullscreen) {
  147. content.webkitRequestFullscreen();
  148. }
  149. this.isFullscreen = true;
  150. }
  151. },
  152. initData() {
  153. percent().then((res) => {
  154. this.percentData = res.data;
  155. this.flag = true;
  156. console.log("我刚执行");
  157. });
  158. this.$refs.updateData.initData();
  159. },
  160. initMap(AMap) {
  161. console.log("进来了");
  162. this.AMap = AMap;
  163. this.map = new AMap.Map("map", {
  164. // 设置地图容器id
  165. // viewMode: "3D", // 是否为3D地图模式
  166. zoom: 5, // 初始化地图级别
  167. center: [105.602725, 37.076636], // 初始化地图中心点位置
  168. mapStyle: "amap://styles/darkblue", //地图样式
  169. });
  170. this.clickMarker = new this.AMap.Marker();
  171. alarmList().then((res) => {
  172. const data = res.data;
  173. // console.log(data, 777);
  174. this.addMapMarkers(this.AMap, data);
  175. });
  176. // this.addMapMarkers(this.AMap, {
  177. // equList: [
  178. // { lng: 105.602725, lat: 37.076636 },
  179. // { lng: 113.8098755478859, lat: 34.75219686835205 },
  180. // ],
  181. // });
  182. // this.getEquMap();
  183. // 暂时放这里
  184. // this.map.on("click", (e) => {
  185. // console.log(e, "e");
  186. // this.regeoCode(e.lnglat);
  187. // });
  188. },
  189. getCalss(type) {
  190. console.log(type, "111");
  191. let icon = "";
  192. switch (type) {
  193. case 16:
  194. icon = require(`./img/sos.png`);
  195. break;
  196. case 25:
  197. // 围栏
  198. icon = require(`./img/weilan.png`);
  199. break;
  200. }
  201. return icon;
  202. },
  203. // 地图覆盖物
  204. addMapMarkers(AMap, data) {
  205. console.log(data, "data");
  206. // // 项目中心点
  207. // const centerMarker = new AMap.Marker({
  208. // position: new AMap.LngLat(data.projectLng, data.projectLat),
  209. // offset: new AMap.Pixel(-20, -20),
  210. // icon: require(`@/assets/map-icon/center.png`),
  211. // });
  212. // 设备分布点
  213. this.markers = [];
  214. let icon = "";
  215. data.forEach((item) => {
  216. // icon=this.getCalss(item.alarm_type);
  217. switch (item.alarm_type) {
  218. case 16:
  219. icon = require(`./img/sos.png`);
  220. break;
  221. case 17:
  222. icon = require(`./img/didian.png`);
  223. break;
  224. case 20:
  225. icon = require(`./img/shebei.png`);
  226. break;
  227. case 21:
  228. icon = require(`./img/diedao.png`);
  229. break;
  230. case 22:
  231. icon = require(`./img/xinlv.png`);
  232. break;
  233. case 25:
  234. icon = require(`./img/weilan.png`);
  235. break;
  236. default:
  237. return null
  238. }
  239. // console.log("执行了");
  240. console.log("icon", icon);
  241. const marker = new AMap.Marker({
  242. position: new AMap.LngLat(item.gps_long, item.gps_lat),
  243. offset: new AMap.Pixel(-13, -30),
  244. // icon: require(`./img/${item.alarm_type}-${
  245. // item.online === 0 ? "GRAY" : item.flag ? "DEFAULT" : "DANGER"
  246. // }.png`),
  247. icon: icon,
  248. extData: {
  249. id: item.id,
  250. equNo: item.equNo,
  251. netCode: data.netCode,
  252. classifyCode: item.classifyCode,
  253. flag: item.flag,
  254. online: item.online,
  255. },
  256. });
  257. this.markers.push(marker);
  258. // this.map.add(marker);
  259. });
  260. const overlayGroups = new AMap.OverlayGroup(this.markers);
  261. // 比例尺
  262. const scale = new AMap.Scale();
  263. this.map.add(overlayGroups);
  264. // this.map.add(centerMarker);
  265. this.map.addControl(scale);
  266. // 鼠标点击marker弹出自定义的信息窗体
  267. overlayGroups.eachOverlay((overlay, index, collections) => {
  268. const extData = overlay.getExtData();
  269. overlay.on("click", () => {
  270. data.forEach((item) => {
  271. console.log(item, "item");
  272. const infoWindow = new AMap.InfoWindow({
  273. content: `<div class="equ-info-box">
  274. <p class="equ-info-item"><span class="label-type">【${
  275. item.alarm_msg
  276. }】</span></p>
  277. <p class="equ-info-item"><span class="label">姓名</span><span class="value tag">${
  278. item.name ? item.name : ""
  279. }</span></p>
  280. <p class="equ-info-item"><span class="label">手机号</span><span class="value">${
  281. item.telno ? item.telno : ""
  282. }</span></p>
  283. <p class="equ-info-item"><span class="label">所在位置</span><span class="value">${
  284. item.address ? item.address : ""
  285. }</span></p>
  286. <p class="equ-info-item"><span class="label">告警时间</span><span class="value">${
  287. item.createtime ? item.createtime : ""
  288. }</span></p>
  289. </div>`,
  290. anchor: "top-center",
  291. });
  292. infoWindow.open(this.map, overlay.getPosition());
  293. });
  294. // const params = {
  295. // netCode: extData.netCode,
  296. // equNo: extData.equNo,
  297. // };
  298. // getEquInfo(params).then((res) => {
  299. // const info = res.data;
  300. // const id = extData.id;
  301. // const currentMarker = this.markers.find(
  302. // (item) => item._opts.extData.id === id
  303. // );
  304. // currentMarker.setIcon(
  305. // require(`@/assets/map-icon/${extData.classifyCode}-${
  306. // info.online === 0 ? "GRAY" : extData.flag ? "DEFAULT" : "DANGER"
  307. // }.png`)
  308. // );
  309. // const onlineEnum = {
  310. // 0: "离线",
  311. // 1: "在线",
  312. // };
  313. // info.projectName = data.projectName;
  314. // });
  315. });
  316. });
  317. // // 地图的3km圆
  318. // const circle = new AMap.Circle({
  319. // center: new AMap.LngLat(data.projectLng, data.projectLat), // 圆心位置
  320. // radius: data.radius * 1000, // 半径
  321. // strokeColor: "#367EF5", // 线颜色
  322. // strokeOpacity: 0.8, // 线透明度
  323. // strokeWeight: 1, // 线粗细度
  324. // fillColor: "#18FFFC", // 填充颜色
  325. // fillOpacity: 0.1, // 填充透明度
  326. // });
  327. // this.map.add(circle);
  328. // this.map.setFitView();
  329. /* this.map.on("click", (e) => {
  330. this.regeoCode(e.lnglat);
  331. }); */
  332. },
  333. },
  334. };
  335. </script>
  336. <style lang="scss" scoped>
  337. ::v-deep .amap-maps{
  338. border:1px solid #235fa7 !important;
  339. }
  340. #data-view {
  341. color: #fff;
  342. width: 100%;
  343. // height: 100%;
  344. min-height: calc(100vh - 84px);
  345. background: url(../../assets/image/bg.png);
  346. background-size: 100% 100%;
  347. background-repeat: no-repeat;
  348. overflow: hidden;
  349. // #dv-full-screen-container {
  350. // background-image: url("./img/bg.png");
  351. // background-size: 100% 100%;
  352. // box-shadow: 0 0 3px blue;
  353. // display: flex;
  354. // flex-direction: column;
  355. // position: static;
  356. // }
  357. .main {
  358. display: flex;
  359. width: 100%;
  360. height: 90%;
  361. min-height: calc(100vh - 84px);
  362. padding-right: 10px;
  363. .left {
  364. width: 70%;
  365. .left-top {
  366. display: flex;
  367. height: 70%;
  368. .top-left {
  369. width: 30%;
  370. }
  371. .top-right {
  372. width: 70%;
  373. }
  374. }
  375. .left-under {
  376. width: 100%;
  377. height: 30%;
  378. .under-title {
  379. flex: 1;
  380. height: 10%;
  381. font-size: 14px;
  382. margin: 10px 0;
  383. background: url(../../assets/image/title_bg.png) no-repeat;
  384. // background: url(./img/title-bg.png) no-repeat;
  385. b {
  386. font-size: 20px;
  387. color: #fff;
  388. font-style: italic;
  389. margin-left: 25px;
  390. line-height: 30px;
  391. }
  392. }
  393. .under-box {
  394. height: 81%;
  395. display: flex;
  396. }
  397. }
  398. }
  399. .right {
  400. // border: 1px solid pink;
  401. width: 30%;
  402. }
  403. }
  404. .main-header {
  405. height: 8%;
  406. width: 100%;
  407. display: flex;
  408. // justify-content: center;
  409. // align-items: flex-start;
  410. .mh-left {
  411. font-size: 20px;
  412. color: rgb(1, 134, 187);
  413. a:visited {
  414. color: rgb(1, 134, 187);
  415. }
  416. }
  417. .mh-middle {
  418. color: #1ae1e6;
  419. font-size: 24px;
  420. flex: 1;
  421. margin-left: 44%;
  422. margin-top:0.5%;
  423. }
  424. .mh-right {
  425. width: 25%;
  426. margin-top: 2%;
  427. padding-right:30px;
  428. display: flex;
  429. justify-content: space-between;
  430. align-items: center;
  431. font-size: 24px;
  432. color:#00e1e1;
  433. img {
  434. width: 30px;
  435. height: 30px;
  436. }
  437. }
  438. // .mh-left,
  439. // .mh-right {
  440. // width: 450px;
  441. // }
  442. }
  443. ::v-deep.top-center {
  444. // background-color: pink;
  445. }
  446. ::v-deep.amap-info-content {
  447. // background-color: #1ae1e6;
  448. }
  449. ::v-deep.amap-info-sharp {
  450. // background-color: #1ae1e6;
  451. }
  452. ::v-deep.equ-info-box {
  453. padding: 6px 0 6px 8px;
  454. .equ-info-item {
  455. margin: 0;
  456. .label-type {
  457. color: #f00404;
  458. }
  459. &.flex {
  460. display: flex;
  461. .value {
  462. &:not(.copy) {
  463. width: 200px;
  464. }
  465. }
  466. }
  467. .label {
  468. display: inline-block;
  469. width: 60px;
  470. font-size: 13px;
  471. color: #999;
  472. }
  473. .value {
  474. color: #505050;
  475. &.link {
  476. color: #409eff;
  477. cursor: pointer;
  478. &:hover {
  479. text-decoration: underline;
  480. user-select: none;
  481. }
  482. }
  483. &.copy {
  484. padding: 0 15px;
  485. color: #409eff;
  486. cursor: pointer;
  487. }
  488. }
  489. }
  490. }
  491. // .main-container {
  492. // height: calc(~"100% - 80px");
  493. // .border-box-content {
  494. // padding: 20px;
  495. // box-sizing: border-box;
  496. // display: flex;
  497. // }
  498. // }
  499. // .left-chart-container {
  500. // width: 22%;
  501. // height: 65%;
  502. // padding: 10px;
  503. // box-sizing: border-box;
  504. // .border-box-content {
  505. // flex-direction: column;
  506. // }
  507. // }
  508. // .right-main-container {
  509. // width: 78%;
  510. // padding-left: 5px;
  511. // box-sizing: border-box;
  512. // }
  513. // .rmc-top-container {
  514. // height: 65%;
  515. // display: flex;
  516. // }
  517. // .rmctc-left-container {
  518. // width: 65%;
  519. // }
  520. // .rmctc-right-container {
  521. // width: 35%;
  522. // }
  523. // .rmc-bottom-container {
  524. // height: 35%;
  525. // }
  526. // .rmctc-chart-1,
  527. // .rmctc-chart-2 {
  528. // height: 50%;
  529. // }
  530. }
  531. </style>