index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. <template>
  2. <div id="data-view-container">
  3. <top-header />
  4. <div class="main">
  5. <div class="left">
  6. <div class="left-top">
  7. <dv-border-box-13>
  8. <Border-Item title="设备总览">
  9. <equTotal v-if="equDataFlag" :data="equTotalData" />
  10. </Border-Item>
  11. </dv-border-box-13>
  12. </div>
  13. <div class="left-content">
  14. <dv-border-box-13>
  15. <Border-Item title="设备型号总览"
  16. ><Left-Chart-1 v-if="deviceTypeflag" :datalist="deviceTypeList"
  17. /></Border-Item>
  18. </dv-border-box-13>
  19. </div>
  20. <div class="left-under">
  21. <dv-border-box-13>
  22. <Border-Item title="用户年龄总览"
  23. ><Left-chart-under v-if="userAgeFlag" :dataList="userAgeList"
  24. /></Border-Item>
  25. </dv-border-box-13>
  26. </div>
  27. </div>
  28. <div class="content">
  29. <!-- 22 -->
  30. <equ-map v-loading="mapLoading" @callback="initMap" />
  31. <div class="left-under">
  32. <dv-border-box-13>
  33. <Border-Item title="报警列表"
  34. ><Right-Bottom v-if="alarmListFlag" :data="alarmList"
  35. /></Border-Item>
  36. </dv-border-box-13>
  37. </div>
  38. </div>
  39. <div class="right">
  40. <div class="left-top">
  41. <dv-border-box-13>
  42. <Border-Item title="设备总览">
  43. <bbb
  44. v-if="userTotalFlag && userDataFlag"
  45. :number="userTotalData"
  46. :data="userData"
  47. /></Border-Item>
  48. </dv-border-box-13>
  49. </div>
  50. <div class="left-content">
  51. <dv-border-box-13>
  52. <Border-Item title="月新增设备"
  53. ><Left-Chart-2
  54. v-if="xylistFlag"
  55. :xlist="xDataList"
  56. :ylist="yDataList"
  57. /></Border-Item>
  58. </dv-border-box-13>
  59. </div>
  60. <div class="left-under">
  61. <dv-border-box-13>
  62. <Border-Item title="月新增用户">
  63. <Middle-Chart
  64. v-if="xyUserFlag"
  65. :xlist="xUserList"
  66. :ylist="yUserList"
  67. /></Border-Item>
  68. </dv-border-box-13>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import topHeader from "./topHeader";
  76. import LeftChart1 from "./LeftChart1";
  77. import LeftChart2 from "./LeftChart2";
  78. import LeftChartUnder from "./LeftChartUnder";
  79. import equMap from "./Maps";
  80. import BorderItem from "./BottomCharts";
  81. import equTotal from "./equTotal";
  82. import bbb from "./bbb";
  83. import RightBottom from "./RightBottom";
  84. import MiddleChart from "./MiddleChart";
  85. import {
  86. deviceView,
  87. userAgeAll,
  88. count,
  89. deviceOver,
  90. alarmStatusList,
  91. addDevice,
  92. addUser,
  93. mapGpsView,
  94. deviceType,
  95. } from "@/api/system/equdata";
  96. export default {
  97. name: "DataView",
  98. components: {
  99. topHeader,
  100. LeftChart1,
  101. LeftChart2,
  102. BorderItem,
  103. equMap,
  104. equTotal,
  105. bbb,
  106. RightBottom,
  107. LeftChartUnder,
  108. MiddleChart,
  109. },
  110. data() {
  111. return {
  112. mapLoading: false,
  113. equTotalData: {},
  114. equDataFlag: false,
  115. userAgeFlag: false,
  116. userTotalFlag: false,
  117. userDataFlag: false,
  118. alarmListFlag: false,
  119. xylistFlag: false,
  120. xyUserFlag: false,
  121. deviceTypeflag: false,
  122. userAgeList: [],
  123. alarmList: [],
  124. xDataList: [],
  125. yDataList: [],
  126. xUserList: [],
  127. yUserList: [],
  128. userTotalData: 0,
  129. };
  130. },
  131. mounted() {
  132. this.deviceView();
  133. this.userAgeAll();
  134. this.userTotal();
  135. this.getUserData();
  136. this.getAlarmStatusList();
  137. this.getEquData();
  138. this.getAddUser();
  139. this.getDeviceType();
  140. },
  141. methods: {
  142. toggleFullscreen() {
  143. if (this.isFullscreen) {
  144. // 退出全屏模式
  145. if (document.exitFullscreen) {
  146. document.exitFullscreen();
  147. } else if (document.mozCancelFullScreen) {
  148. document.mozCancelFullScreen();
  149. } else if (document.webkitExitFullscreen) {
  150. document.webkitExitFullscreen();
  151. }
  152. this.isFullscreen = false;
  153. } else {
  154. // 进入全屏模式
  155. const content = document.querySelector("#data-view-container");
  156. // console.log(content,888);
  157. // return
  158. if (content.requestFullscreen) {
  159. content.requestFullscreen();
  160. } else if (content.mozRequestFullScreen) {
  161. content.mozRequestFullScreen();
  162. } else if (content.webkitRequestFullscreen) {
  163. content.webkitRequestFullscreen();
  164. }
  165. this.isFullscreen = true;
  166. }
  167. },
  168. getDeviceType() {
  169. deviceType().then((res) => {
  170. this.deviceTypeList = res.data.list;
  171. this.deviceTypeflag = true;
  172. });
  173. },
  174. getAddUser() {
  175. addUser().then((res) => {
  176. let xlist = res.data.map((item) => item.month);
  177. let ylist = res.data.map((item) => item.count);
  178. this.xUserList = xlist;
  179. this.yUserList = ylist;
  180. this.xyUserFlag = true;
  181. });
  182. },
  183. getEquData() {
  184. addDevice().then((res) => {
  185. let xlist = res.data.map((item) => item.month);
  186. let ylist = res.data.map((item) => item.count);
  187. this.xDataList = xlist;
  188. this.yDataList = ylist;
  189. this.xylistFlag = true;
  190. });
  191. },
  192. deviceView() {
  193. deviceView().then((res) => {
  194. this.equTotalData = res.data;
  195. this.equDataFlag = true;
  196. });
  197. },
  198. userTotal() {
  199. count().then((res) => {
  200. this.userTotalData = res.data;
  201. this.userTotalFlag = true;
  202. });
  203. },
  204. getUserData() {
  205. deviceOver().then((res) => {
  206. this.userData = res.data;
  207. this.userDataFlag = true;
  208. });
  209. },
  210. userAgeAll() {
  211. userAgeAll().then((res) => {
  212. this.userAgeList = res.data.list;
  213. this.userAgeFlag = true;
  214. });
  215. },
  216. getAlarmStatusList() {
  217. alarmStatusList().then((res) => {
  218. this.alarmList = res.data
  219. // .map((item) => {
  220. // let hideName = "";
  221. // if (item.name.length >= 2) {
  222. // hideName = item.name[0] + "*" + item.name.substring(2);
  223. // }
  224. // return {
  225. // ...item,
  226. // name: hideName,
  227. // };
  228. // });
  229. this.alarmListFlag = true;
  230. });
  231. },
  232. initMap(AMap) {
  233. this.AMap = AMap;
  234. this.map = new AMap.Map("map", {
  235. resizeEnable: true,
  236. // viewMode: "3D", // 是否为3D地图模式
  237. zoom: 3.85, // 初始化地图级别
  238. center: [101.835078, 42.90488], // 初始化地图中心点位置
  239. mapStyle: "amap://styles/darkblue", //地图样式
  240. });
  241. var cluster;
  242. const gridSize = 60;
  243. // 数据中需包含经纬度信息字段 lnglat
  244. var points = [
  245. // { lnglat: ["116.86846822500229", "33.904682432073166"] },
  246. // { lnglat: ["116.85693472623825", "33.88754011287255"] },
  247. // { lnglat: ["116.85693472623825", "33.88754011287255"] },
  248. // { lnglat: ["116.85668259859085", "33.88756039064183"] },
  249. // { lnglat: ["116.8569615483284", "33.887618689228496"] },
  250. // { lnglat: ["116.85713320970535", "33.887466605958934"] },
  251. // { lnglat: ["116.85698837041855", "33.88756546008415"] },
  252. // { lnglat: ["116.85688644647598", "33.88763389755545"] },
  253. // { lnglat: ["108.7104383111", "34.03344626696758"] },
  254. // { lnglat: ["108.70837301015854", "34.03073918476941"] },
  255. // { lnglat: ["108.70164602994919", "34.00430204307751"] },
  256. // { lnglat: ["108.70918840169907", "34.02465331926583"] },
  257. // { lnglat: ["108.70991796255112", "34.02430859718817"] },
  258. // { lnglat: ["108.70207518339157", "34.00304228666131"] },
  259. // { lnglat: ["108.70090574026108", "34.00421586255809"] },
  260. // { lnglat: ["108.70879143476486", "34.0323538021479"] },
  261. ];
  262. mapGpsView().then((res) => {
  263. points = res.data;
  264. if (cluster) {
  265. cluster.setMap(null);
  266. }
  267. //默认样式
  268. cluster = new AMap.MarkerCluster(this.map, points, {
  269. gridSize: gridSize,
  270. });
  271. });
  272. // this.mapLoading = false;
  273. // this.secherPlace(AMap);
  274. // this.districtSearch(AMap);
  275. // this.ruler(AMap);
  276. // this.mapZoomChange();
  277. // this.aaa();
  278. },
  279. // initMap(AMap) {
  280. // this.AMap = AMap;
  281. // this.map = new AMap.Map("map", {
  282. // resizeEnable: true,
  283. // // viewMode: "3D", // 是否为3D地图模式
  284. // zoom: 3.85, // 初始化地图级别
  285. // center: [101.835078, 42.90488], // 初始化地图中心点位置
  286. // });
  287. // // this.mapLoading = false;
  288. // // this.secherPlace(AMap);
  289. // // this.districtSearch(AMap);
  290. // // this.ruler(AMap);
  291. // this.mapZoomChange();
  292. // this.aaa();
  293. // },
  294. // 索引点聚合
  295. // drawCluster(isCheck, isCheck2) {
  296. // // console.log(this.$refs.tree.getCheckedKeys(true));
  297. // if (this.cluster) {
  298. // this.cluster.setMap(null);
  299. // }
  300. // let points = [
  301. // {
  302. // code: 862607059021807,
  303. // equNo: "SHX-JG05276GS1932",
  304. // onlineState: 0,
  305. // storeName: "第1营业店(上海嘉定)",
  306. // storeErpCode: "03-01-01",
  307. // deptName: "通用设备二部",
  308. // lnglat: ["121.81513906780002", "30.89272014115498"],
  309. // },
  310. // {
  311. // code: 866041042138963,
  312. // equNo: "SHX-SG01142860SJ",
  313. // onlineState: 0,
  314. // storeName: "上海维修组",
  315. // storeErpCode: "08-01-01",
  316. // deptName: "资产中心",
  317. // lnglat: ["120.61801385657444", "31.977446558941004"],
  318. // },
  319. // {
  320. // code: 867383057214142,
  321. // equNo: "SHX-SG08898S-65XC",
  322. // onlineState: 0,
  323. // storeName: "第1营业店(上海嘉定)",
  324. // storeErpCode: "03-01-01",
  325. // deptName: "通用设备二部",
  326. // lnglat: ["121.03558147655212", "31.126224206828198"],
  327. // },
  328. // {
  329. // code: 864513041445245,
  330. // equNo: "SHX-JG37778JCPT1412DC",
  331. // onlineState: 0,
  332. // storeName: "第5营业店(上海闵行)",
  333. // storeErpCode: "03-03-08",
  334. // deptName: "通用设备二部",
  335. // lnglat: ["121.82208391421668", "30.85699004008208"],
  336. // },
  337. // {
  338. // code: 867032059016076,
  339. // equNo: "SHX-SG07695BT28ERT",
  340. // onlineState: 0,
  341. // storeName: "第3营业店(上海浦东)",
  342. // storeErpCode: "03-01-40",
  343. // deptName: "通用设备二部",
  344. // lnglat: ["121.5704633089994", "29.894328624226418"],
  345. // },
  346. // {
  347. // code: 868142047179180,
  348. // equNo: "SHX-JG46091S0812E",
  349. // onlineState: 0,
  350. // storeName: "第1营业店(上海嘉定)",
  351. // storeErpCode: "03-01-01",
  352. // deptName: "通用设备二部",
  353. // lnglat: ["121.31930274336634", "31.245171826552806"],
  354. // },
  355. // {
  356. // code: 867383057182588,
  357. // equNo: "SHX-JG55617S0607",
  358. // onlineState: 0,
  359. // storeName: "第1营业店(上海嘉定)",
  360. // storeErpCode: "03-01-01",
  361. // deptName: "通用设备二部",
  362. // lnglat: ["121.02616661110348", "31.22516500695246"],
  363. // },
  364. // ];;
  365. // // this.mapLoading = true;
  366. // // 写接口
  367. // // const equInfo2 = await this.getMapInfo(checkNodeKey, 0);
  368. // // const equInfo1 = await this.getMapInfo(checkNodeKey, 1);
  369. // // const { terminalList, data } = equInfo1.data;
  370. // this.map.setZoomAndCenter(3.85, [101.835078, 42.90488]);
  371. // const getNodes = (context) => {
  372. // console.log('context',context);
  373. // const clusterData = context.clusterData; // 聚合中包含数据
  374. // console.log('clusterData',clusterData);
  375. // const index = context.index; // 聚合的条件
  376. // console.log("index:", index);
  377. // const indexs = ["deptName", "storeErpCode", "equNo"];
  378. // const i = indexs.indexOf(index.mainKey);
  379. // let text =
  380. // i === 0 ? clusterData[0][index.mainKey] : clusterData[0].storeName;
  381. // if (i <= 1) {
  382. // const extra = '<p class="showCount">' + context.count + "</p>";
  383. // text = '<p class="showName">' + text + "</p>";
  384. // text += extra;
  385. // }
  386. // const style = {
  387. // index: i,
  388. // text,
  389. // };
  390. // return style;
  391. // };
  392. // const getPosition = (context) => {
  393. // console.log(context);
  394. // const key = context.index.mainKey;
  395. // const dataItem = context.clusterData && context.clusterData[0];
  396. // const clusterName = dataItem[key];
  397. // if (!clusterObj[clusterName]) {
  398. // return null;
  399. // }
  400. // const point = clusterObj[clusterName].point;
  401. // const centerLnglat = new this.AMap.LngLat(point[0], point[1]);
  402. // return centerLnglat;
  403. // };
  404. // // 自定义聚合点样式
  405. // const renderClusterMarker = (context) => {
  406. // const marker = context.marker; // 聚合点标记对象
  407. // const nodesObj = getNodes(context);
  408. // // 自定义点标记样式
  409. // const div = document.createElement("div");
  410. // if (nodesObj.index === 0) {
  411. // div.className = "amap-cluster amap-cluster-dep";
  412. // }
  413. // if (nodesObj.index === 1) {
  414. // div.className = "amap-cluster amap-cluster-shop";
  415. // }
  416. // if (nodesObj.index <= 1) {
  417. // // 聚合点自定义点击事件
  418. // marker.on("click", (e) => {
  419. // // console.log(e);
  420. // /* let curZoom = this.map.getZoom();
  421. // if (curZoom < 12) {
  422. // curZoom += 1;
  423. // } */
  424. // let curZoom = this.map.getZoom();
  425. // if (nodesObj.index === 0) {
  426. // curZoom = 4.9;
  427. // } else {
  428. // curZoom += 1;
  429. // }
  430. // this.map.setZoomAndCenter(curZoom, e.lnglat);
  431. // });
  432. // div.innerHTML = nodesObj.text;
  433. // marker.setContent(div);
  434. // } else {
  435. // // 非聚合点
  436. // const dataItem = context.clusterData[0];
  437. // marker.setIcon(require(`./img/online-${dataItem.onlineState}.png`));
  438. // }
  439. // // 自定义聚合点标记显示位置
  440. // const position = getPosition(context);
  441. // if (position) {
  442. // marker.setPosition(position);
  443. // }
  444. // marker.setAnchor("center");
  445. // };
  446. // const clusterIndexSet = {
  447. // equNo: {
  448. // minZoom: 9,
  449. // maxZoom: 22,
  450. // },
  451. // };
  452. // /* eslint-disable no-new */
  453. // this.cluster = new this.AMap.IndexCluster(this.map, points, {
  454. // renderClusterMarker,
  455. // clusterIndexSet,
  456. // });
  457. // this.mapLoading = false;
  458. // },
  459. // 监听地图缩放
  460. mapZoomChange() {
  461. this.map.on("zoomchange", () => {
  462. const curZoom = this.map.getZoom();
  463. console.log(curZoom);
  464. if (curZoom < 12) {
  465. this.map.clearInfoWindow();
  466. }
  467. });
  468. },
  469. aaa(data, isCheck, isCheck2) {
  470. if (this.cluster) {
  471. this.cluster.setMap(null);
  472. }
  473. let points = [];
  474. let clusterObj = {};
  475. points = [
  476. {
  477. code: 862607059021807,
  478. equNo: "SHX-JG05276GS1932",
  479. onlineState: 0,
  480. storeName: "第1营业店(上海嘉定)",
  481. storeErpCode: "03-01-01",
  482. deptName: "通用设备二部",
  483. lnglat: ["121.81513906780002", "30.89272014115498"],
  484. },
  485. {
  486. code: 866041042138963,
  487. equNo: "SHX-SG01142860SJ",
  488. onlineState: 0,
  489. storeName: "上海维修组",
  490. storeErpCode: "08-01-01",
  491. deptName: "资产中心",
  492. lnglat: ["120.61801385657444", "31.977446558941004"],
  493. },
  494. {
  495. code: 867383057214142,
  496. equNo: "SHX-SG08898S-65XC",
  497. onlineState: 0,
  498. storeName: "第1营业店(上海嘉定)",
  499. storeErpCode: "03-01-01",
  500. deptName: "通用设备二部",
  501. lnglat: ["121.03558147655212", "31.126224206828198"],
  502. },
  503. {
  504. code: 864513041445245,
  505. equNo: "SHX-JG37778JCPT1412DC",
  506. onlineState: 0,
  507. storeName: "第5营业店(上海闵行)",
  508. storeErpCode: "03-03-08",
  509. deptName: "通用设备二部",
  510. lnglat: ["121.82208391421668", "30.85699004008208"],
  511. },
  512. {
  513. code: 867032059016076,
  514. equNo: "SHX-SG07695BT28ERT",
  515. onlineState: 0,
  516. storeName: "第3营业店(上海浦东)",
  517. storeErpCode: "03-01-40",
  518. deptName: "通用设备二部",
  519. lnglat: ["121.5704633089994", "29.894328624226418"],
  520. },
  521. {
  522. code: 868142047179180,
  523. equNo: "SHX-JG46091S0812E",
  524. onlineState: 0,
  525. storeName: "第1营业店(上海嘉定)",
  526. storeErpCode: "03-01-01",
  527. deptName: "通用设备二部",
  528. lnglat: ["121.31930274336634", "31.245171826552806"],
  529. },
  530. {
  531. code: 867383057182588,
  532. equNo: "SHX-JG55617S0607",
  533. onlineState: 0,
  534. storeName: "第1营业店(上海嘉定)",
  535. storeErpCode: "03-01-01",
  536. deptName: "通用设备二部",
  537. lnglat: ["121.02616661110348", "31.22516500695246"],
  538. },
  539. ];
  540. clusterObj = {
  541. "03-04-40": {
  542. nodeId: 200408003032,
  543. nodeName: "第12营业店(苏州昆山)",
  544. nodeErpCode: "03-04-40",
  545. point: ["121.01714", "31.35137"],
  546. },
  547. };
  548. console.log(clusterObj, "clusterObj");
  549. this.map.setZoomAndCenter(3.85, [101.835078, 42.90488]);
  550. const getNodes = (context) => {
  551. console.log("context", context);
  552. const clusterData = context.clusterData; // 聚合中包含数据
  553. const index = context.index; // 聚合的条件
  554. console.log("index:", index);
  555. const indexs = ["deptName", "storeErpCode", "equNo"];
  556. const i = indexs.indexOf(index.mainKey);
  557. let text =
  558. i === 0 ? clusterData[0][index.mainKey] : clusterData[0].storeName;
  559. if (i <= 1) {
  560. const extra = '<p class="showCount">' + context.count + "</p>";
  561. text = '<p class="showName">' + text + "</p>";
  562. text += extra;
  563. }
  564. const style = {
  565. index: i,
  566. text,
  567. };
  568. return style;
  569. };
  570. const getPosition = (context) => {
  571. console.log(context, "121212");
  572. const key = context.index.mainKey;
  573. const dataItem = context.clusterData && context.clusterData[0];
  574. const clusterName = dataItem[key];
  575. if (!clusterObj[clusterName]) {
  576. return null;
  577. }
  578. const point = clusterObj[clusterName].point;
  579. const centerLnglat = new this.AMap.LngLat(point[0], point[1]);
  580. return centerLnglat;
  581. };
  582. // 自定义聚合点样式
  583. const renderClusterMarker = (context) => {
  584. const marker = context.marker; // 聚合点标记对象
  585. console.log(marker, "45566");
  586. const nodesObj = getNodes(context);
  587. console.log(nodesObj, "nodesObj");
  588. // 自定义点标记样式
  589. const div = document.createElement("div");
  590. if (nodesObj.index === 0) {
  591. div.className = "amap-cluster amap-cluster-dep";
  592. }
  593. if (nodesObj.index === 1) {
  594. div.className = "amap-cluster amap-cluster-shop";
  595. }
  596. if (nodesObj.index <= 1) {
  597. // 聚合点自定义点击事件
  598. marker.on("click", (e) => {
  599. // console.log(e);
  600. /* let curZoom = this.map.getZoom();
  601. if (curZoom < 12) {
  602. curZoom += 1;
  603. } */
  604. let curZoom = this.map.getZoom();
  605. if (nodesObj.index === 0) {
  606. curZoom = 4.9;
  607. } else {
  608. curZoom += 1;
  609. }
  610. this.map.setZoomAndCenter(curZoom, e.lnglat);
  611. });
  612. if (nodesObj.index === 1) {
  613. marker.on("mouseover", () => {
  614. this.marker = marker;
  615. const key = context.index.mainKey;
  616. const dataItem = context.clusterData && context.clusterData[0];
  617. const clusterName = dataItem[key];
  618. if (!clusterObj[clusterName]) {
  619. return null;
  620. }
  621. const nodeId = clusterObj[clusterName].nodeId;
  622. let showStatus = false;
  623. if (this.shopInfoWindow) {
  624. showStatus = this.shopInfoWindow.getIsOpen();
  625. }
  626. if (!showStatus) {
  627. // 请求数据
  628. getMapStoreInfo({ nodeId }).then((res) => {
  629. if (res) {
  630. const data = res.data;
  631. this.openShopInfoWindow(data);
  632. }
  633. });
  634. }
  635. });
  636. }
  637. div.innerHTML = nodesObj.text;
  638. marker.setContent(div);
  639. } else {
  640. // 非聚合点
  641. const dataItem = context.clusterData[0];
  642. console.log(dataItem, "2323");
  643. marker.setIcon(require(`./img/online-${dataItem.onlineState}.png`));
  644. // 自定义点击事件
  645. marker.on("click", (e) => {
  646. this.marker = marker;
  647. const dataItem = context.clusterData[0];
  648. const code = context.clusterData[0].code;
  649. // 数据请求
  650. getEquInfo(code).then(async (res) => {
  651. if (res) {
  652. this.equData = res.data;
  653. this.equAddress = "根据经纬度查询地址失败";
  654. this.equAddress = await this.getAddress(dataItem.lnglat);
  655. this.openEquInfoWindow(this.equData, this.equAddress);
  656. }
  657. });
  658. });
  659. }
  660. // 自定义聚合点标记显示位置
  661. const position = getPosition(context);
  662. if (position) {
  663. marker.setPosition(position);
  664. }
  665. marker.setAnchor("center");
  666. };
  667. const clusterIndexSet = {
  668. deptName: {
  669. minZoom: 2,
  670. maxZoom: 4.8,
  671. },
  672. storeErpCode: {
  673. minZoom: 4.8,
  674. maxZoom: 9,
  675. },
  676. equNo: {
  677. minZoom: 9,
  678. maxZoom: 22,
  679. },
  680. };
  681. /* eslint-disable no-new */
  682. this.cluster = new this.AMap.IndexCluster(this.map, points, {
  683. renderClusterMarker,
  684. clusterIndexSet,
  685. });
  686. this.mapLoading = false;
  687. console.log(this.cluster, 777777);
  688. },
  689. // initMap(AMap) {
  690. // this.AMap = AMap;
  691. // this.map = new AMap.Map("map", {
  692. // // 设置地图容器id
  693. // // viewMode: "3D", // 是否为3D地图模式
  694. // zoom: 5, // 初始化地图级别
  695. // center: [105.602725, 37.076636], // 初始化地图中心点位置
  696. // mapStyle: "amap://styles/darkblue",
  697. // });
  698. // this.clickMarker = new this.AMap.Marker();
  699. // this.addMapMarkers(this.AMap, {
  700. // equList: [
  701. // { lng: 105.602725, lat: 37.076636 },
  702. // { lng: 105.622725, lat: 37.75219686835205 },
  703. // // { lng: 154.8098755478859, lat: 18.75219686835205 },
  704. // // { lng: 183.8098755478859, lat: 34.75219686835205 },
  705. // // { lng: 178.8098755478859, lat: 3.75219686835205 },
  706. // ],
  707. // });
  708. // // this.getEquMap();
  709. // // 暂时放这里
  710. // this.map.on("click", (e) => {
  711. // console.log(e, "e");
  712. // this.regeoCode(e.lnglat);
  713. // });
  714. // },
  715. // // 地图覆盖物
  716. // addMapMarkers(AMap, data) {
  717. // // console.log(data,'data');
  718. // // // 项目中心点
  719. // // const centerMarker = new AMap.Marker({
  720. // // position: new AMap.LngLat(data.projectLng, data.projectLat),
  721. // // offset: new AMap.Pixel(-20, -20),
  722. // // icon: require(`@/assets/map-icon/center.png`),
  723. // // });
  724. // // 设备分布点
  725. // this.markers = [];
  726. // data.equList.forEach((item) => {
  727. // const marker = new AMap.Marker({
  728. // position: new AMap.LngLat(item.lng, item.lat),
  729. // offset: new AMap.Pixel(-13, -30),
  730. // // icon: require(`@/assets/map-icon/${item.classifyCode}-${
  731. // // item.online === 0 ? "GRAY" : item.flag ? "DEFAULT" : "DANGER"
  732. // // }.png`),
  733. // icon: "https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
  734. // anchor: "bottom-center",
  735. // extData: {
  736. // id: item.id,
  737. // equNo: item.equNo,
  738. // netCode: data.netCode,
  739. // classifyCode: item.classifyCode,
  740. // flag: item.flag,
  741. // online: item.online,
  742. // },
  743. // });
  744. // this.markers.push(marker);
  745. // this.map.add(marker);
  746. // });
  747. // // console.log('this.markers',this.markers);
  748. // // const overlayGroups = new AMap.OverlayGroup(this.markers);
  749. // // // 比例尺
  750. // // // const scale = new AMap.Scale();
  751. // // this.map.add(overlayGroups);
  752. // // this.map.add(centerMarker);
  753. // // this.map.addControl(scale);
  754. // // // 鼠标点击marker弹出自定义的信息窗体
  755. // // overlayGroups.eachOverlay((overlay, index, collections) => {
  756. // // const extData = overlay.getExtData();
  757. // // overlay.on("click", () => {
  758. // // const params = {
  759. // // netCode: extData.netCode,
  760. // // equNo: extData.equNo,
  761. // // };
  762. // // getEquInfo(params).then((res) => {
  763. // // const info = res.data;
  764. // // const id = extData.id;
  765. // // const currentMarker = this.markers.find(
  766. // // (item) => item._opts.extData.id === id
  767. // // );
  768. // // currentMarker.setIcon(
  769. // // require(`@/assets/map-icon/${extData.classifyCode}-${
  770. // // info.online === 0 ? "GRAY" : extData.flag ? "DEFAULT" : "DANGER"
  771. // // }.png`)
  772. // // );
  773. // // const onlineEnum = {
  774. // // 0: "离线",
  775. // // 1: "在线",
  776. // // };
  777. // // info.projectName = data.projectName;
  778. // // const infoWindow = new AMap.InfoWindow({
  779. // // content: `<div class="equ-info-box">
  780. // // <p class="equ-info-item"><span class="label">设备编号</span><span class="value" id="equNo">${
  781. // // info.equNo
  782. // // }</span></p>
  783. // // <p class="equ-info-item"><span class="label">当前设备状态</span><span class="value tag">${
  784. // // onlineEnum[info.online]
  785. // // }</span></p>
  786. // // <p class="equ-info-item"><span class="label">累计报警次数</span><span class="value link" onclick="goNextPage(this, 'alarmStat')" data-equNo="${
  787. // // info.equNo
  788. // // }" data-name="${info.projectName}">${
  789. // // info.alarmTotal
  790. // // }</span></p>
  791. // // <p class="equ-info-item"><span class="label">最近定位时间</span><span class="value">${
  792. // // info.positionTime
  793. // // }</span></p>
  794. // // <p class="equ-info-item"><span class="label">TBox品牌</span><span class="value">${
  795. // // info.brand
  796. // // }</span></p>
  797. // // <p class="equ-info-item"><span class="label">TBox编号</span><span class="value">${
  798. // // info.gpsId
  799. // // }</span></p>
  800. // // </div>`,
  801. // // anchor: "top-center",
  802. // // });
  803. // // infoWindow.open(this.map, overlay.getPosition());
  804. // // });
  805. // // });
  806. // // });
  807. // // // 地图的3km圆
  808. // // const circle = new AMap.Circle({
  809. // // center: new AMap.LngLat(data.projectLng, data.projectLat), // 圆心位置
  810. // // radius: data.radius * 1000, // 半径
  811. // // strokeColor: "#367EF5", // 线颜色
  812. // // strokeOpacity: 0.8, // 线透明度
  813. // // strokeWeight: 1, // 线粗细度
  814. // // fillColor: "#18FFFC", // 填充颜色
  815. // // fillOpacity: 0.1, // 填充透明度
  816. // // });
  817. // // this.map.add(circle);
  818. // // this.map.setFitView();
  819. // /* this.map.on("click", (e) => {
  820. // this.regeoCode(e.lnglat);
  821. // }); */
  822. // },
  823. },
  824. };
  825. </script>
  826. <style lang="scss">
  827. #data-view-container {
  828. width: 100%;
  829. // height: 100%;
  830. min-height: calc(100vh - 84px);
  831. background-color: #030409;
  832. color: #fff;
  833. overflow: hidden;
  834. background-image: url("./img/bg.png");
  835. background-size: 100%;
  836. background-repeat: no-repeat;
  837. .main {
  838. display: flex;
  839. padding: 0 10px 10px 10px;
  840. box-sizing: border-box;
  841. min-height: 85vh;
  842. .left {
  843. width: 30%;
  844. // box-sizing: border-box;
  845. .left-top {
  846. height: 30%;
  847. margin-top: 10px;
  848. }
  849. .left-content {
  850. height: 30%;
  851. margin-top: 10px;
  852. .left-border {
  853. }
  854. }
  855. .left-under {
  856. margin-top: 10px;
  857. height: 30%;
  858. .left-border {
  859. }
  860. }
  861. }
  862. // .content {
  863. // flex: 1;
  864. // }
  865. .content {
  866. // width: 30%;
  867. flex: 1;
  868. // box-sizing: border-box;
  869. .left-under {
  870. height: 40%;
  871. // margin-top: 10px;
  872. }
  873. }
  874. .right {
  875. width: 30%;
  876. // box-sizing: border-box;
  877. .left-top {
  878. height: 30%;
  879. margin-top: 10px;
  880. }
  881. .left-content {
  882. height: 30%;
  883. margin-top: 10px;
  884. .left-border {
  885. }
  886. }
  887. .left-under {
  888. margin-top: 10px;
  889. height: 30%;
  890. .left-border {
  891. }
  892. }
  893. }
  894. }
  895. ::v-deep.amap-cluster {
  896. position: relative;
  897. color: #fff;
  898. box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
  899. border-radius: 4px;
  900. text-align: center;
  901. &::after {
  902. content: "";
  903. position: absolute;
  904. display: block;
  905. width: 0;
  906. height: 0;
  907. border-color: transparent;
  908. border-style: solid;
  909. border-width: 6px;
  910. border-bottom-width: 0;
  911. left: 50%;
  912. bottom: -6px;
  913. transform: translate(-50%, 0);
  914. }
  915. }
  916. ::v-deep.amap-cluster-dep {
  917. width: 140px;
  918. background: #d11128;
  919. &::after {
  920. border-top-color: #d11128;
  921. }
  922. }
  923. ::v-deep.amap-cluster-shop {
  924. width: 170px;
  925. background: #f25668;
  926. &::after {
  927. border-top-color: #f25668;
  928. }
  929. }
  930. }
  931. </style>