index.vue 12 KB

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