report.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <!-- -->
  2. <template>
  3. <div class="chart-template">
  4. <div id="map_Chart" style="height: 100%"></div>
  5. </div>
  6. </template>
  7. <script>
  8. import "./../../board.scss";
  9. import * as echarts from "echarts";
  10. import { getMap } from "@/api/board/cockpit.js";
  11. import {
  12. findMaxIndex,
  13. getChartDOMSize,
  14. getNextPeriod,
  15. getPeriodText,
  16. } from "../../utils.js";
  17. export default {
  18. props: ["orgId", "orgName"],
  19. data() {
  20. return {
  21. map: {},
  22. coordinates: [],
  23. icon: "image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAUCAYAAABvVQZ0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAF3SURBVDhPvZTBK4RBGIe/z56UklDay+6JkhM3RYo/wVlOrg4uTtyc3JSrg6Lc2CQHp5U7RyVylBBJXD7PO/PO7M43Y3OQp57mfd/fzOz6dlf2LxRFMYLr2hro63io7e/gQI53uKwjA303Cr06CujStcwV1rCHg3Kpgf4E1/CBtsraGTbN4wv24Q0K2/hsy2IFN/FJj6Rhw4zshg2ctGVxodkcfmET+/EVd8zBFISXKH+O1HtSQ92EQD2Bo1rfSggLJmyHoQvNZYK27nKXm3fDGu030I/ZsecDh/DIdCHy9Ti1peceK+6yFGeaLaE8q1UcxllMYR8HxYHtI4IHTO8+oDJvOOA2VfFTpgm2zCagfrejiIZuaaFBhGb+gZfYNYfLEKQeuFDBny7zX50IwvIn1emdTZlDSuq3ua+r41rX8jzL87ypZQyvVLMvGDCoseTuV+EI/kUFEB7bPZ5FjTw6b2dcoxYMGzbznGsUwHzaxp5Hjf6SLPsG2jnZyz2k38wAAAAASUVORK5CYII=",
  24. };
  25. },
  26. components: {},
  27. computed: {},
  28. watch: {
  29. orgId: {
  30. deep: true,
  31. handler(val) {
  32. // this.resetTimer();
  33. this.getData();
  34. },
  35. },
  36. // map: {
  37. // deep: true,
  38. // handler() {
  39. // this.$nextTick(() => {
  40. // this.initMap();
  41. // });
  42. // },
  43. // },
  44. },
  45. created() {
  46. // this.types = types;
  47. // this.maxDisplay = 16;
  48. // this.refreshTime = 1 * 10 * 1000;
  49. this.isMouseOver = false;
  50. },
  51. async mounted() {
  52. // console.info(this.fjMap)
  53. window.addEventListener("resize", this.windowResize);
  54. },
  55. beforeDestroy() {
  56. this.timer && clearInterval(this.timer);
  57. this.timer = null;
  58. window.removeEventListener("resize", this.windowResize);
  59. },
  60. methods: {
  61. // handleClick() {
  62. // this.resetTimer();
  63. // this.getData();
  64. // },
  65. handleMouseEnter() {
  66. this.isMouseOver = true;
  67. },
  68. handleMouseLeave() {
  69. this.isMouseOver = false;
  70. },
  71. async getData() {
  72. let map = window.boardMap.getMap(this.orgName);
  73. let coordinates = window.boardMap.getCoord(this.orgName);
  74. this.map = map;
  75. this.coordinates = coordinates;
  76. this.$nextTick(() => {
  77. this.initMap();
  78. });
  79. },
  80. initMap() {
  81. this.myChart && this.myChart.dispose();
  82. // 基于准备好的dom,初始化echarts实例
  83. this.myChart = echarts.init(document.getElementById("map_Chart"));
  84. let t = this;
  85. getMap(this.map).then((data) => {
  86. echarts.registerMap("map", data);
  87. let option = {
  88. tooltip: {
  89. trigger: "item",
  90. },
  91. geo: {
  92. show: true,
  93. map: "map",
  94. zoom: 1.25,
  95. showLegendSymbol: false, // 存在legend时显示
  96. label: {
  97. normal: {
  98. show: false,
  99. color: "#c1b496", //控制地图省市文字颜色
  100. fontSize: 14,
  101. },
  102. emphasis: {
  103. show: false,
  104. color: "#fff", //悬浮字体颜色
  105. },
  106. },
  107. roam: true,
  108. selectedMode: "single", //选择模式,单选,只能选中一个地市
  109. select: {
  110. //这个就是鼠标点击后,地图想要展示的配置
  111. disabled: false, //可以被选中
  112. itemStyle: {
  113. //相关配置项很多,可以参考echarts官网
  114. borderWidth: 1, //区域边框宽度
  115. borderColor: "#2B91B7ff", //区域边框颜色
  116. areaColor: "#2B91B730", //选中
  117. },
  118. label: {
  119. show: false,
  120. color: "#fff", //悬浮字体颜色
  121. },
  122. },
  123. itemStyle: {
  124. normal: {
  125. borderWidth: 1, //区域边框宽度
  126. borderColor: "#3fdaffff", //区域边框颜色
  127. areaColor: "#3fdaff55", //区域颜色"rgba(23,107,221,0.7)",//
  128. },
  129. emphasis: {
  130. borderWidth: 1,
  131. borderColor: "#fff",
  132. areaColor: "#2B91B7",
  133. },
  134. },
  135. },
  136. legend: [
  137. {
  138. selectedMode: true, //取消图例上的点击事件
  139. },
  140. ],
  141. series: [
  142. {
  143. map: "map",
  144. type: "effectScatter",
  145. // silent: true,
  146. coordinateSystem: "geo",
  147. // datasetIndex: 0,
  148. // geoIndex: 0,
  149. // selectedMode: false,
  150. // focusNodeAdjacency: false,
  151. // label: {
  152. // show: true,
  153. // width: 13,
  154. // height: 15,
  155. // fontSize: 0,
  156. // color: "#1DF9FC",
  157. // backgroundColor: {
  158. // image: iconRQ
  159. // },
  160. // },
  161. label: {
  162. formatter: (param) => {
  163. return param.name;
  164. },
  165. position: "top",
  166. fontSize: "10",
  167. color: "#fff",
  168. show: true,
  169. },
  170. tooltip: {
  171. show: false,
  172. },
  173. // tooltip:{
  174. // position: "right",
  175. // textStyle:{
  176. // // color:'#fff',
  177. // },
  178. // // backgroundColor:'rgba(184,189,192,1)',
  179. // formatter:function(param){
  180. // return `<div >
  181. // <div> ${param.data.name} </div>
  182. // <div>履职总数:85 </div>
  183. // <div> 已完成:67 </div>
  184. // </div>`
  185. // }
  186. // },
  187. itemStyle: {
  188. color: "#ddb926",
  189. },
  190. symbol: this.icon, //自定义图标
  191. symbolSize: [10, 10],
  192. // encode: {
  193. // value: 2,
  194. // },
  195. // showEffectOn: "emphasis", //关闭涟漪
  196. // hoverEffectOn: true,
  197. rippleEffect: {
  198. brushType: "fill",
  199. period: 0,
  200. number: 0,
  201. },
  202. data: this.coordinates,
  203. },
  204. ],
  205. };
  206. if (option && typeof option === "object") {
  207. this.myChart.setOption(option);
  208. }
  209. });
  210. },
  211. windowResize() {
  212. this.myChart && this.myChart.resize();
  213. },
  214. resetTimer() {
  215. this.timer && clearInterval(this.timer);
  216. this.timer = setInterval(() => {
  217. if (this.isMouseOver) {
  218. return;
  219. }
  220. this.activeName = getNextPeriod(this.types, this.activeName);
  221. this.getData();
  222. }, this.refreshTime);
  223. },
  224. },
  225. };
  226. </script>
  227. <style lang="scss" scoped>
  228. .content {
  229. display: flex;
  230. margin-bottom: 20px;
  231. margin-left: 5px;
  232. margin-right: 5px;
  233. border: solid 1px #b8bdc088;
  234. & > span {
  235. margin-right: 10px;
  236. padding-top: 5px;
  237. padding-bottom: 5px;
  238. height: 30px;
  239. color: rgb(245, 245, 245);
  240. font-size: 14px;
  241. }
  242. & > span:first-child {
  243. width: 100px;
  244. background-color: #b8bdc088;
  245. text-align: center;
  246. }
  247. }
  248. </style>