index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div class="layout-padding">
  3. <div class="layout-padding-auto layout-padding-view to-flex" style="background-color:#e9e9e9">
  4. <el-row class="to-flex">
  5. <el-card class='to-card' shadow="hover">
  6. <!-- 标题 -->
  7. <div class="to-title">
  8. <img :src="url[0]" class="to-img" />
  9. <el-text tag="b" class="to-Atext">加油站</el-text>
  10. <el-text tag="b" class="to-Btext">176</el-text>
  11. <el-text class="to-Ctext">座</el-text>
  12. </div>
  13. <div class="to-content">
  14. <el-table :data="tableData[0]" style="" :cell-style="cellStyle" :show-header="false"
  15. :row-style="{ height: '10px' }">
  16. <el-table-column prop="a" width="90" />
  17. <el-table-column prop="b" width="50" />
  18. <el-table-column prop="c" width="80" />
  19. </el-table>
  20. </div>
  21. </el-card>
  22. <el-card class='to-card' shadow="hover">
  23. <!-- 标题 -->
  24. <div class="to-title">
  25. <img :src="url[1]" class="to-img" />
  26. <el-text tag="b" class="to-Atext">加油机</el-text>
  27. <el-text class="to-Btext">532</el-text>
  28. <el-text class="to-Ctext">台</el-text>
  29. </div>
  30. <div class="to-content">
  31. <el-table :data="tableData[1]" style="" :cell-style="cellStyle" :show-header="false"
  32. :row-style="{ height: '10px' }">
  33. <el-table-column prop="a" width="90" :cell-style="{ color: 'red' }" />
  34. <el-table-column prop="b" width="50" />
  35. <el-table-column prop="c" width="80" />
  36. </el-table>
  37. </div>
  38. </el-card>
  39. <el-card class='to-card' shadow="hover">
  40. <!-- 标题 -->
  41. <div class="to-title">
  42. <img :src="url[2]" class="to-img" />
  43. <el-text tag="b" class="to-Atext">加油枪</el-text>
  44. <el-text class="to-Btext">1822</el-text>
  45. <el-text class="to-Ctext">条</el-text>
  46. </div>
  47. <div class="to-content">
  48. <el-table :data="tableData[2]" style="" :cell-style="cellStyle" :show-header="false"
  49. :row-style="{ height: '10px' }">
  50. <el-table-column prop="a" width="90" />
  51. <el-table-column prop="b" width="60" />
  52. <el-table-column prop="c" width="80" />
  53. </el-table>
  54. </div>
  55. </el-card>
  56. </el-row>
  57. <!-- 地图 -->
  58. <el-card style="height: 100vh;width: 100vw; margin-top: 5px;" shadow="hover">
  59. <div ref="echartsMapRef" style="height: 65vh;width: 85vw; text-align: center;"></div>
  60. <div class="to-right">
  61. <h3>国内销售排名Top&nbsp;&nbsp;5</h3>
  62. <div class="item" v-for="(item, index) in topData" :key="index">
  63. {{ item.name }}:&nbsp;&nbsp;{{ item.value }}
  64. </div>
  65. </div>
  66. <div class="to-left">
  67. <div class="range">全国</div>
  68. <div class="title">油站、油机、油枪综合分布</div>
  69. </div>
  70. </el-card>
  71. </div>
  72. </div>
  73. </template>
  74. <script setup lang="ts">
  75. import echartsMapList from "./mockData/mock.json"
  76. import { onMounted, reactive, ref } from "vue";
  77. import * as echarts from "echarts";
  78. import { allCity } from "/@/views/admin/visualization/digitalMap/mockData/allCity";
  79. import router from "/@/router";
  80. // 定义变量内容
  81. const echartsMapRef = ref<RefType>('')
  82. // -----------
  83. const url = [
  84. '/src/assets/map/address.PNG',
  85. '/src/assets/map/oilEngine.PNG',
  86. '/src/assets/map/oilGun.PNG'
  87. ]
  88. const tableData = reactive([[{
  89. a: '校验失败',
  90. b: '33',
  91. c: '18.75%'
  92. }, {
  93. a: '离线',
  94. b: '5',
  95. c: '2.84%'
  96. }],
  97. [{
  98. a: '校验失败',
  99. b: '50',
  100. c: '9.40%'
  101. }, {
  102. a: '离线',
  103. b: '21',
  104. c: '3.95%'
  105. }],
  106. [{
  107. a: '校验失败',
  108. b: '183',
  109. c: '10.04%'
  110. }, {
  111. a: '离线',
  112. b: '72',
  113. c: '3.95%'
  114. }]
  115. ])
  116. // 表格样式设置
  117. const cellStyle = ((data: any) => {
  118. if (data.row.a === '校验失败' && data.columnIndex == 0) {
  119. return { 'text-align': 'right', 'padding': 0, 'font-size': '16px', 'color': 'green' }
  120. } else if (data.row.a === '离线' && data.columnIndex == 0) {
  121. return { 'text-align': 'right', 'padding': 0, 'font-size': '16px', 'color': 'red' }
  122. }
  123. else {
  124. return { 'text-align': 'right', 'padding': 0, 'font-size': '16px' }
  125. }
  126. })
  127. const mapData = allCity.sort((a, b) => {
  128. return b.value - a.value
  129. })
  130. const topData = mapData.slice(0, 5)
  131. // 注册中国地图
  132. echarts.registerMap('echartsMapList', echartsMapList)
  133. // 初始化
  134. // option配置
  135. const initEchartsMap = () => {
  136. const myChart = echarts.init(echartsMapRef.value)
  137. const option = {
  138. backgroundColor: 'transparent',
  139. // title: {
  140. // text: '国内销售数量',
  141. // left: 'center',
  142. // textStyle: {
  143. // color: '#000'
  144. // }
  145. // },
  146. // layoutCenter: ['40%', '60%'],//位置
  147. // layoutSize: '65%',//大小
  148. tooltip: {
  149. trigger: 'item',
  150. formatter: (params) => params.name
  151. },
  152. visualMap: {
  153. min: 0,
  154. max: 300,
  155. text: ['High', 'Low'],
  156. realtime: false,
  157. calculable: true,
  158. inRange: {
  159. color: ['lightskyblue', 'yellow', 'orangered']
  160. // color: ['#aacff9', '#75c7f6', '#33a9d6']
  161. }
  162. },
  163. series: [
  164. {
  165. name: '国内销售数量',
  166. type: 'map',
  167. map: 'echartsMapList',
  168. label: {
  169. show: true,
  170. fontSize: 12,
  171. formatter: (params) => {
  172. if (params.value) {
  173. return params.name + ':' + params.value
  174. }
  175. return params.name + ':0'
  176. },
  177. },
  178. top: '30%',
  179. roam: true,
  180. zoom: 1.6,
  181. scaleLimit: {
  182. //滚轮缩放的极限控制
  183. min: 1, //缩放最小大小
  184. },
  185. data: mapData,
  186. }
  187. ]
  188. }
  189. myChart.setOption(option)
  190. myChart.on('georoam', (params) => {
  191. if ('dy' in params || 'dx' in params) return
  192. const myOption = myChart.getOption()
  193. const myZoom = myOption.series[0].zoom
  194. if (myZoom > 1.5) {
  195. myOption.series[0].label.fontSize = 20
  196. } else if (myZoom > 1.1) {
  197. myOption.series[0].label.fontSize = 12
  198. } else {
  199. myOption.series[0].label.fontSize = 10
  200. }
  201. delete myOption.series[0].top
  202. delete myOption.series[0].zoom
  203. myChart.setOption(myOption)
  204. })
  205. myChart.on('click', (e) => {
  206. router.push({ path: `/admin/visualization/cityLevelMap/${e.data.code}/${e.data.name}` })
  207. });
  208. window.addEventListener('resize', () => {
  209. myChart.resize()
  210. })
  211. }
  212. onMounted(() => {
  213. initEchartsMap()
  214. })
  215. </script>
  216. <style scoped lang="scss">
  217. .to-flex {
  218. position: relative;
  219. .to-right {
  220. position: absolute;
  221. display: flex;
  222. flex-direction: column;
  223. justify-content: space-around;
  224. z-index: 999;
  225. bottom: 0;
  226. right: 0;
  227. width: 10%;
  228. max-width: 300px;
  229. height: 25%;
  230. background-color: rgba(0, 234, 255, 0.5);
  231. color: #000;
  232. /* 文本颜色为黑色 */
  233. h3 {
  234. text-align: center;
  235. font-size: 14px;
  236. }
  237. .item {
  238. text-align: center;
  239. font-size: 12px;
  240. }
  241. }
  242. .to-left {
  243. width: 15%;
  244. // max-width: 500px;
  245. height: 25%;
  246. position: absolute;
  247. z-index: 999;
  248. top: 40%;
  249. left: 10%;
  250. font-size: 18px;
  251. .range {
  252. border: {
  253. top: 1px solid black;
  254. bottom: 1px solid black
  255. }
  256. text-align: center;
  257. width: 50px;
  258. color: rgb(12, 169, 231);
  259. font-weight: 600;
  260. transform: skew(-10deg);
  261. margin-bottom: 5%;
  262. }
  263. .title {
  264. color: #8d8b8b;
  265. }
  266. }
  267. }
  268. /** ----- 顶部信息框样式 ----- */
  269. // 去除边框线
  270. ::v-deep .el-table--border th.el-table__cell,
  271. ::v-deep .el-table td.el-table__cell {
  272. border-bottom: none !important;
  273. }
  274. ::v-deep .el-table--border .el-table__cell {
  275. border-right: none !important;
  276. }
  277. ::v-deep .el-table--group,
  278. .el-table--border {
  279. border: none !important;
  280. }
  281. ::v-deep .el-table .cell {
  282. padding: 0;
  283. }
  284. .el-table {
  285. --el-table-border-color: none;
  286. }
  287. .to-card {
  288. flex: 1;
  289. text-align: center;
  290. margin-right: 7px;
  291. .to-title {
  292. // width: 85%;
  293. margin-bottom: 20px
  294. }
  295. .to-img {
  296. width: 50px;
  297. position: relative;
  298. top: 15px;
  299. }
  300. .to-Atext {
  301. color: black;
  302. margin-left: 10px;
  303. font-size: 18px;
  304. }
  305. .to-Btext {
  306. color: blue;
  307. margin-left: 10px;
  308. font-size: 16px;
  309. }
  310. .to-Ctext {
  311. color: #000;
  312. margin-left: 5px;
  313. font-size: 16px;
  314. }
  315. .to-content {
  316. margin: auto;
  317. width: 100%;
  318. }
  319. }
  320. </style>