index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div>
  3. <section class="mainbox">
  4. <!-- topBox start -->
  5. <div class="topBox">
  6. <div class="column statisSec">
  7. <statis-top
  8. :falarmCount="alarmCount"
  9. :fpersonalCount="personalCount"
  10. :fsiteCount="siteCount"
  11. :fepLoad="epLoad"
  12. ></statis-top>
  13. <statis-bottom :fhtAnalogData="htAnalogData"></statis-bottom>
  14. </div>
  15. <div class="column mapBox" style="position: relative">
  16. <map-static-top :fsiteCount="siteCount"></map-static-top>
  17. <div id="pickerBox">
  18. <input
  19. id="pickerInput"
  20. placeholder="输入关键字选取站点"
  21. v-model="name"
  22. @keyup.enter="siteList_api({ name: this.name })"
  23. />
  24. <i
  25. class="el-icon-search"
  26. @click="siteList_api({ name: this.name })"
  27. ></i>
  28. <div id="poiInfo"></div>
  29. </div>
  30. <div class="panel-footer"></div>
  31. <div
  32. class="map panel"
  33. id="mapF"
  34. style="height: 100%; z-index: 1; width: 100%"
  35. ></div>
  36. </div>
  37. <div class="column">
  38. <div class="panel deviceSum">
  39. <h2>设备运行状态</h2>
  40. <div class="filterSec" style="top: 0.7rem">
  41. <el-date-picker
  42. v-model="dDefaultTime"
  43. type="datetimerange"
  44. range-separator="~"
  45. start-placeholder="开始日期"
  46. end-placeholder="结束日期"
  47. @change="deviceTypeCount_api()"
  48. >
  49. </el-date-picker>
  50. </div>
  51. <pie-chart
  52. :fdeviceTypeCount="deviceTypeCount"
  53. v-if="this.deviceTypeCount"
  54. ></pie-chart>
  55. <div class="panel-footer"></div>
  56. </div>
  57. <div class="panel line1 operStatus">
  58. <h2>负载率</h2>
  59. <triangle-chart
  60. :frtAnalogData="rtAnalogData"
  61. v-if="this.rtAnalogData.heavyLoad"
  62. ></triangle-chart>
  63. <div class="panel-footer"></div>
  64. </div>
  65. </div>
  66. </div>
  67. <!-- topBox end -->
  68. <!-- bottomBox start -->
  69. <div class="bottomBox">
  70. <div class="column">
  71. <div class="panel currentUsage" style="height: 100%">
  72. <h2>总能耗</h2>
  73. <div class="filterSec">
  74. <select name="" id="" v-model="dayType">
  75. <option value="0">当日用量趋势</option>
  76. <option value="1">当月用量趋势</option>
  77. </select>
  78. <!-- <img src="../../assets/images/markIcon.png" alt=""> -->
  79. </div>
  80. <bar-chart
  81. :feptrendIco="eptrendIco"
  82. v-if="this.eptrendIco[0]"
  83. ></bar-chart>
  84. <div class="panel-footer"></div>
  85. </div>
  86. </div>
  87. <div class="column">
  88. <div class="panel currentUsage" style="height: 100%">
  89. <h2>运维管理</h2>
  90. <div class="filterSec">
  91. <el-date-picker
  92. v-model="fDefaultTime"
  93. type="datetimerange"
  94. range-separator="~"
  95. start-placeholder="开始日期"
  96. end-placeholder="结束日期"
  97. @change="trendIcoCount_api()"
  98. >
  99. </el-date-picker>
  100. </div>
  101. <line-chart
  102. :ftrendIcoCount="trendIcoCount"
  103. v-if="this.trendIcoCount[0]"
  104. ></line-chart>
  105. <div class="panel-footer"></div>
  106. </div>
  107. </div>
  108. </div>
  109. <!-- bottomBox end -->
  110. </section>
  111. </div>
  112. </template>
  113. <script>
  114. import statisTop from "./components/statisTop";
  115. import statisBottom from "./components/statisBottom";
  116. import pieChart from "./components/pieChart";
  117. import barChart from "./components/barChart";
  118. import lineChart from "./components/lineChart";
  119. import mapStaticTop from "./components/mapStaticTop";
  120. import triangleChart from "./components/triangleChart";
  121. import markIconPath from "../../assets/images/markIcon.png";
  122. // 地图
  123. import AMap from "AMap";
  124. // import AMapUI from "AMapUI";
  125. import api from "../../api/home/home.js";
  126. export default {
  127. name: "index",
  128. components: {
  129. statisTop,
  130. statisBottom,
  131. pieChart,
  132. barChart,
  133. lineChart,
  134. mapStaticTop,
  135. triangleChart,
  136. },
  137. data() {
  138. return {
  139. dDefaultTime: this.$store.state.se_defaultTime,
  140. // fDefaultTime: [
  141. // new Date("2021-6-23 00:00:00"),
  142. // new Date("2021-7-12 00:00:00"),
  143. // ],
  144. fDefaultTime:this.$store.state.th_defaultTime,
  145. map: null,
  146. alarmCount: {},
  147. personalCount: {},
  148. siteCount: {},
  149. deviceTypeCount: {},
  150. trendIcoCount: [],
  151. rtAnalogData: {},
  152. htAnalogData: {},
  153. dayType: 0,
  154. eptrendIco: {},
  155. eptrendIcoMonth: {},
  156. epLoad: "",
  157. siteOne: {},
  158. name: "",
  159. };
  160. },
  161. watch: {
  162. dayType(val) {
  163. if (val == 0) {
  164. this.eptrendIco_api();
  165. } else {
  166. this.eptrendIcoMonth_api();
  167. }
  168. },
  169. },
  170. created() {},
  171. mounted() {
  172. this.alarmCount_api();
  173. this.personalCount_api();
  174. this.epLoad_api();
  175. this.siteCount_api();
  176. this.deviceTypeCount_api();
  177. this.trendIcoCount_api();
  178. this.rtAnalogData_api();
  179. this.siteList_api();
  180. this.htAnalogData_api();
  181. this.eptrendIco_api();
  182. },
  183. methods: {
  184. // searchSite(){
  185. // this.siteList_api({"name":this.name});
  186. // },
  187. //告警总数数据对接
  188. alarmCount_api() {
  189. api.alarmCount_api().then((requset) => {
  190. this.alarmCount = requset.data;
  191. });
  192. },
  193. //运维人员
  194. personalCount_api() {
  195. api.personalCount_api().then((requset) => {
  196. this.personalCount = requset.data;
  197. });
  198. },
  199. //总实时负荷
  200. epLoad_api() {
  201. api.epLoad_api().then((requset) => {
  202. this.epLoad = requset.data;
  203. });
  204. },
  205. //站点总数
  206. siteCount_api() {
  207. api.siteCount_api().then((requset) => {
  208. this.siteCount = requset.data;
  209. });
  210. },
  211. //设备数量echarts饼图
  212. deviceTypeCount_api() {
  213. var _this = this;
  214. _this.$store.commit("TimeAll_function", this.dDefaultTime);
  215. var time = _this.$store.state.Time_Data;
  216. api
  217. .deviceTypeCount_api({
  218. startTime: time[0],
  219. endTime: time[1],
  220. })
  221. .then((requset) => {
  222. this.deviceTypeCount = requset.data;
  223. });
  224. },
  225. //故障抢修echarts折线图
  226. trendIcoCount_api() {
  227. var _this = this;
  228. _this.$store.commit("TimeAll_function", this.fDefaultTime);
  229. var time = _this.$store.state.Time_Data;
  230. api
  231. .trendIco_api({
  232. startTime: time[0],
  233. endTime: time[1],
  234. })
  235. .then((requset) => {
  236. this.$store.state.trendIcoCount = requset.data;
  237. this.trendIcoCount = requset.data;
  238. });
  239. },
  240. //重载运行echarts锥形图
  241. rtAnalogData_api() {
  242. api.rtAnalogData_api().then((requset) => {
  243. this.rtAnalogData = requset.data;
  244. });
  245. },
  246. //地图撒点
  247. siteList_api(query = {}) {
  248. api.siteList_api(query).then((requset) => {
  249. this.siteList = requset.data;
  250. this.initMap();
  251. });
  252. },
  253. //地图撒点
  254. // 日月年用电量
  255. htAnalogData_api() {
  256. api.htAnalogData_api().then((requset) => {
  257. this.htAnalogData = requset.data;
  258. });
  259. },
  260. // 今日昨日用电量趋势
  261. eptrendIco_api() {
  262. api.eptrendIco_api().then((requset) => {
  263. this.eptrendIco = requset.data;
  264. // console.log("this.eptrendIco");
  265. // console.log(this.eptrendIco[0].name);
  266. });
  267. },
  268. // 今日昨日用电量趋势
  269. eptrendIcoMonth_api() {
  270. api.eptrendIcoMonth_api().then((requset) => {
  271. this.eptrendIco = requset.data;
  272. console.log("this.eptrendIco");
  273. // console.log(this.eptrendIco);
  274. });
  275. },
  276. Overview() {
  277. // this.$router.push({ path: "/Overview" }); //, query: { title: title }
  278. },
  279. async initMap() {
  280. this.map = await new AMap.Map("mapF", {
  281. mapStyle: "amap://styles/blue", //设置地图的显示样式
  282. resizeEnable: true,
  283. zoom: 13,
  284. zooms: [3, 16],
  285. // features: [] //清空背景道路等
  286. });
  287. // this.initMapUi();
  288. var con = `<div class="siteModelBox" >
  289. <h2>
  290. {siteName}
  291. </h2>
  292. <div >
  293. <div class="siteDetailInfo" >
  294. <div class="infoLine">
  295. <span>站点状态:</span>
  296. <p>{status}</p>
  297. </div>
  298. <div class="infoLine">
  299. <span>设备总数:</span>
  300. <p>{deviceCount}</p >
  301. </div>
  302. <div class="infoLine">
  303. <span>告警数:</span>
  304. <p>{alarmPowerCount}</p >
  305. </div>
  306. <div class="infoLine">
  307. <span>监控类型:</span>
  308. <p>{deviceType}</p >
  309. </div>
  310. <div class="infoLine">
  311. <span>电话:</span>
  312. <p>{phone}</p >
  313. </div>
  314. <div class="infoLine">
  315. <span>地址:</span>
  316. <p>{siteAddress}</p >
  317. </div>
  318. </div>
  319. </div>
  320. </div>`;
  321. var dataList = this.siteList;
  322. dataList.forEach(function (item) {
  323. let conNew = con;
  324. // console.log(item.siteAddress);
  325. conNew = conNew.replace(/{siteAddress}/g, item.siteAddress);
  326. conNew = conNew.replace(/{phone}/g, item.phone);
  327. conNew = conNew.replace(/{siteName}/g, item.siteName);
  328. item.content = conNew;
  329. });
  330. this.addMarker(dataList, "water");
  331. },
  332. addMarker(lnglats) {
  333. // 创建标点和点击事件
  334. let markers = lnglats.map((val, ind) => {
  335. let marker = new AMap.Marker({
  336. position: new AMap.LngLat(val.longitude, val.latitude),
  337. icon: markIconPath,
  338. // icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/dir-via-marker.png',
  339. zIndex: 9,
  340. extData: {
  341. id: ind + 1,
  342. },
  343. });
  344. marker.on("mouseover", async () => {
  345. // console.log([val.latitude, val.longitude], null, val);
  346. await api.siteOne_api({ siteId: val.id }).then((requset) => {
  347. this.siteOne = requset.data;
  348. });
  349. if (this.siteOne) {
  350. val.content = val.content.replace(
  351. /{alarmPowerCount}/g,
  352. this.siteOne.alarmPowerCount ? this.siteOne.alarmPowerCount : "0"
  353. );
  354. val.content = val.content.replace(
  355. /{status}/g,
  356. this.siteOne.status ? this.siteOne.status : "-"
  357. );
  358. val.content = val.content.replace(
  359. /{deviceCount}/g,
  360. this.siteOne.deviceCount ? this.siteOne.deviceCount : "0"
  361. );
  362. val.content = val.content.replace(
  363. /{deviceType}/g,
  364. this.siteOne.deviceType ? this.siteOne.deviceType : "-"
  365. );
  366. }
  367. await this.addMarkerInfo(
  368. [val.longitude, val.latitude],
  369. val.content,
  370. val
  371. );
  372. });
  373. marker.on("mouseout", async () => {
  374. this.map.clearInfoWindow();
  375. });
  376. marker.on("click", async () => {
  377. localStorage.clear();
  378. this.$router.push({ path: "/Overview" });
  379. this.$store.commit("increment", val.id);
  380. localStorage.setItem("Overview", [val.id, val.siteName]);
  381. });
  382. return marker;
  383. });
  384. this.map.add(new AMap.OverlayGroup(markers));
  385. this.map.setFitView(); // 根据所有点自适应
  386. },
  387. // 添加标点
  388. addMarkerInfo(position, content, value = "") {
  389. value;
  390. // console.log("value");
  391. // console.log(value);
  392. this.map.clearInfoWindow();
  393. var infoWindow = new AMap.InfoWindow({
  394. isCustom: true, //使用自定义窗体
  395. closeWhenClickMap: true,
  396. content: content,
  397. offset: new AMap.Pixel(16, -30),
  398. });
  399. infoWindow.open(this.map, position);
  400. },
  401. poiPickerReady(poiPicker) {
  402. // console.log(poiPicker);
  403. var marker = new AMap.Marker();
  404. var infoWindow = new AMap.InfoWindow({
  405. offset: new AMap.Pixel(0, -20),
  406. });
  407. //选取了某个POI
  408. poiPicker.on("poiPicked", (poiResult) => {
  409. var source = poiResult.source,
  410. poi = poiResult.item,
  411. info = {
  412. source: source,
  413. id: poi.id,
  414. name: poi.name,
  415. location: poi.location.toString(),
  416. address: poi.address,
  417. };
  418. marker.setMap(this.map);
  419. infoWindow.setMap(this.map);
  420. marker.setPosition(poi.location);
  421. infoWindow.setPosition(poi.location);
  422. infoWindow.setContent(
  423. "POI信息: <pre>" + JSON.stringify(info, null, 2) + "</pre>"
  424. );
  425. // infoWindow.open(this.map, marker.getPosition());
  426. this.map.setCenter(marker.getPosition());
  427. });
  428. poiPicker.onCityReady(() => {
  429. // poiPicker.suggest("美食");
  430. });
  431. },
  432. // initMapUi() {
  433. // AMapUI.load(["ui/misc/PoiPicker"], (PoiPicker) => {
  434. // // console.log(PoiPicker);
  435. // let poiPickers = new PoiPicker({
  436. // input: "pickerInput",
  437. // });
  438. // this.poiPickerReady(poiPickers);
  439. // });
  440. // },
  441. },
  442. };
  443. </script>
  444. <style lang="scss">
  445. #pickerBox {
  446. position: absolute;
  447. z-index: 9;
  448. top: 0.15rem;
  449. right: 0.15rem;
  450. width: 3rem;
  451. height: 0.425rem;
  452. font-size: 0.15rem;
  453. }
  454. .el-icon-search {
  455. position: absolute;
  456. right: 0.1375rem;
  457. top: 0.1rem;
  458. font-size: 0.2125rem;
  459. color: #00f4fd;
  460. cursor: pointer;
  461. }
  462. #pickerInput {
  463. width: 3rem;
  464. line-height: 0.425rem;
  465. padding: 0 0.125rem;
  466. outline: none;
  467. border: 1px solid #00f4fd;
  468. border-radius: 18px;
  469. background: rgba(0, 0, 0, 0);
  470. color: #fff;
  471. }
  472. #poiInfo {
  473. background: #fff;
  474. }
  475. </style>