center.map.ts 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import { getImageUrl } from "@/utils/tools";
  2. import { useThemeConfig } from "@/stores/themeConfig";
  3. import { storeToRefs } from "pinia";
  4. import { computed } from "vue";
  5. const arrow = new Image();
  6. arrow.src = getImageUrl("home/map_select.png");
  7. const storesThemeConfig = useThemeConfig();
  8. const { themeConfig } = storeToRefs(storesThemeConfig);
  9. const layoutSize = computed(() => {
  10. switch (themeConfig.value.appScope) {
  11. case "YiBin":
  12. return "118%";
  13. case "ZiGong":
  14. return "140%";
  15. case "LuZhou":
  16. return "120%";
  17. }
  18. });
  19. export const optionHandle = (regionCode: string, list: object[]) => {
  20. return {
  21. backgroundColor: "rgba(0,0,0,0)",
  22. tooltip: {
  23. trigger: "item",
  24. position: function (
  25. point: any[],
  26. params: any,
  27. dom: any,
  28. rect: any,
  29. size: any
  30. ) {
  31. let x = 0; // x坐标位置
  32. let y = 0; // y坐标位置
  33. // 当前鼠标位置
  34. const pointX = point[0];
  35. const pointY = point[1];
  36. // 提示框大小
  37. const boxWidth = size.contentSize[0];
  38. const boxHeight = size.contentSize[1];
  39. // boxWidth > pointX 说明鼠标左边放不下提示框
  40. if (boxWidth > pointX) {
  41. x = pointX + 10;
  42. } else {
  43. // 左边放的下
  44. x = pointX - boxWidth - 10;
  45. }
  46. // boxHeight > pointY 说明鼠标上边放不下提示框
  47. if (boxHeight > pointY) {
  48. y = 5;
  49. } else {
  50. // 上边放得下
  51. y = pointY - boxHeight;
  52. }
  53. return [x, y];
  54. },
  55. show: true,
  56. textStyle: {
  57. fontSize: 14,
  58. color: "#fff",
  59. },
  60. className: "custom-tooltip-box",
  61. rich: {
  62. arrow: {
  63. backgroundColor: {
  64. image: getImageUrl("home/tool_tip_arrow.png"),
  65. },
  66. },
  67. },
  68. formatter: function (params: any) {
  69. let tipHtml = "";
  70. tipHtml = `
  71. <div class="custom-tooltip-style">
  72. <div class='custom-tooltip-name'> <span class="custom-tooltip-arrow"></span> ${
  73. params.name
  74. }</div>
  75. <div class='custom-tooltip-style-box'>
  76. <div class="ball">
  77. <div class="ball-value">${
  78. params.data.satisfiedRate
  79. }<span>%</span></div>
  80. <div class="ball-text">满意率</div>
  81. </div>
  82. <div class="custom-tooltip-style-box-text">
  83. <div class="custom-tooltip-style-box-text-item">在办工单:<span>${
  84. params.data.handlingCount
  85. }</span> <b> 件</b></div>
  86. <div class="custom-tooltip-style-box-text-item">已办工单:<span>${
  87. params.data.filedCount
  88. }</span> <b> 件</b></div>
  89. <div class="custom-tooltip-style-box-text-item">超期工单:<span>${
  90. params.data.overTimeCount
  91. }</span> <b> 件</b></div>
  92. <div class="custom-tooltip-style-box-text-item">高频热点:<span class="last">${
  93. params.data.hotspotName
  94. ? params.data.hotspotName
  95. : "-"
  96. }</span></div>
  97. </div>
  98. </div>
  99. </div>
  100. `;
  101. return tipHtml;
  102. },
  103. },
  104. geo: [
  105. {
  106. layoutCenter: ["50%", "50%"], //位置
  107. layoutSize: layoutSize, //大小
  108. show: true,
  109. map: regionCode,
  110. roam: false,
  111. zoom: 1,
  112. aspectScale: 1,
  113. label: {
  114. show: false,
  115. },
  116. itemStyle: {
  117. areaColor: {
  118. type: "linear",
  119. x: 1200,
  120. y: 0,
  121. x2: 0,
  122. y2: 0,
  123. colorStops: [
  124. {
  125. offset: 0,
  126. color: "rgba(38,134,132,0.35)", // 0% 处的颜色
  127. },
  128. {
  129. offset: 1,
  130. color: "rgba(38,134,132,0.75)", // 50% 处的颜色
  131. },
  132. ],
  133. global: true, // 缺省为 false
  134. },
  135. borderColor: "#c0f3fb",
  136. borderWidth: 1,
  137. shadowColor: "#8cd3ef",
  138. shadowOffsetY: 10,
  139. shadowBlur: 120,
  140. },
  141. },
  142. {
  143. type: "map",
  144. map: regionCode,
  145. aspectScale: 1,
  146. zoom: 1,
  147. layoutCenter: ["50%", "54%"],
  148. layoutSize: layoutSize,
  149. roam: false,
  150. silent: true,
  151. itemStyle: {
  152. borderWidth: 2,
  153. borderColor: "rgba( 38,134,132,0.8)",
  154. shadowColor: "rgba(29, 111, 165,0.8)",
  155. shadowOffsetY: 10,
  156. shadowBlur: 2,
  157. areaColor: "rgba(5,21,35,0.2)",
  158. borderType: "dashed",
  159. },
  160. },
  161. ],
  162. geo3D: [
  163. {
  164. show: false,
  165. map: regionCode,
  166. aspectScale: 1,
  167. },
  168. ],
  169. series: [
  170. {
  171. type: "map",
  172. map: regionCode, // 自定义扩展图表类型
  173. aspectScale: 1,
  174. zoom: 1,
  175. showLegendSymbol: true,
  176. boxDepth: 120, //地图倾斜度
  177. regionHeight: 3, //地图厚度
  178. label: {
  179. show: false,
  180. },
  181. itemStyle: {
  182. color: "rgba( 73,122,105,.3)",
  183. borderColor: "#3CFFFD",
  184. borderWidth: 1,
  185. areaColor: {
  186. color: "rgba( 73,122,105,.3)",
  187. },
  188. },
  189. emphasis: {
  190. // 选中的样式
  191. label: {
  192. formatter: ["{b|}"].join("\n"),
  193. rich: {
  194. b: {
  195. backgroundColor: {
  196. image: arrow,
  197. },
  198. height: 60,
  199. },
  200. },
  201. },
  202. itemStyle: {
  203. borderColor: "rgba( 62, 254, 254,.3)",
  204. borderWidth: 2,
  205. areaColor: "rgba( 62, 254, 254,.3)",
  206. },
  207. },
  208. layoutCenter: ["50%", "50%"],
  209. layoutSize: layoutSize,
  210. data: list,
  211. select: {
  212. disabled: true,
  213. },
  214. },
  215. ],
  216. };
  217. };