1
0

index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div>
  3. <div class="fire-list">
  4. <!-- 火灾总数 -->
  5. <div class="fire">
  6. <div>
  7. <div>
  8. <span class="fire-num">456</span>
  9. <span>起</span>
  10. </div>
  11. <div>火灾总数</div>
  12. </div>
  13. <div>
  14. <img src="../../../../assets/images/Vector (1).png" alt="" />
  15. <span class="num up">15%</span>
  16. </div>
  17. </div>
  18. <!--亡人 -->
  19. <div class="fire">
  20. <div>
  21. <div>
  22. <span class="fire-num">8</span>
  23. <span>人</span>
  24. </div>
  25. <div>亡人</div>
  26. </div>
  27. <div>
  28. <img src="../../../../assets/images/Vector (2).png" alt="" />
  29. <span class="num down">15%</span>
  30. </div>
  31. </div>
  32. <!-- 伤人 -->
  33. <div class="fire">
  34. <div>
  35. <div>
  36. <span class="fire-num">46</span>
  37. <span>人</span>
  38. </div>
  39. <div>伤人</div>
  40. </div>
  41. <div>
  42. <img src="../../../../assets/images/Vector (1).png" alt="" />
  43. <span class="num up">10%</span>
  44. </div>
  45. </div>
  46. <!-- 直接经济损失 -->
  47. <div class="fire">
  48. <div>
  49. <div>
  50. <span class="fire-num">6</span>
  51. <span class="money">万元</span>
  52. <img src="../../../../assets/images/Vector (1).png" alt="" />
  53. <span class="num up">15%</span>
  54. </div>
  55. <div class="manoue">直接经济损失</div>
  56. </div>
  57. <!-- <div>
  58. <img src="../../../assets/images/Vector (1).png" alt="">
  59. <span class="num">15%</span>
  60. </div> -->
  61. </div>
  62. </div>
  63. <div class="charts">
  64. <div class="top_title">
  65. <div>人</div>
  66. <ul class="options">
  67. <li :class="{
  68. item: true,
  69. active: activeIndexState(index)
  70. }" @click="activeIndex = index" v-for="(item, index) in activeItems" :key="index">{{ item.name }}</li>
  71. </ul>
  72. </div>
  73. <div>
  74. <Chart :items="chartData" :label="chartLabel" />
  75. </div>
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. import Chart from './Chart.vue'
  81. import { getSxzbListToatl, getQhyyListToatl } from "@/api/index.js";
  82. export default {
  83. name: 'FireIndex',
  84. components: {
  85. Chart,
  86. },
  87. props: {
  88. qx: String,
  89. type: {
  90. type: Number,
  91. default: 0
  92. }
  93. },
  94. data() {
  95. return {
  96. activeItems: [
  97. {name: '火灾总数'},
  98. {name: '亡人'},
  99. {name: '伤人'},
  100. {name: '直接经济损失'},
  101. {name: '起火原因'}
  102. ],
  103. activeIndex: 0,
  104. data: [
  105. [],
  106. [],
  107. [],
  108. [],
  109. []
  110. ],
  111. params:{
  112. pageSize:100,
  113. pageNum:1
  114. },
  115. // 年份横坐标轴标签
  116. yearLabel: [],
  117. // 年份数据
  118. yearData: [],
  119. // 月份纵坐标轴标签
  120. monthLabel: [],
  121. // 月份数据
  122. monthData: [],
  123. modeType: 0,
  124. fireIndexLabel: [],
  125. fireIndexData: [],
  126. }
  127. },
  128. watch: {
  129. type: {
  130. handler(idx){
  131. this.modeType = idx
  132. },
  133. immediate: true
  134. }
  135. },
  136. computed: {
  137. chartLabel() {
  138. if (this.activeIndex === 4) {
  139. return this.fireIndexLabel[this.type]
  140. }
  141. if (this.type === 0) {
  142. return this.monthLabel;
  143. } else {
  144. return this.yearLabel
  145. }
  146. },
  147. chartData() {
  148. if (this.activeIndex === 4) {
  149. return this.fireIndexData[this.type]
  150. }
  151. if (this.type === 0) {
  152. return this.monthData[this.activeIndex]
  153. } else {
  154. return this.yearData[this.activeIndex];
  155. }
  156. }
  157. },
  158. methods: {
  159. activeIndexState(index) {
  160. return this.activeIndex === index
  161. },
  162. getFrieList(){
  163. this.loadQhyyListToatl()
  164. this.loadSxzbChartData()
  165. },
  166. loadQhyyListToatl() {
  167. getQhyyListToatl({
  168. ...this.params,
  169. qx: this.qx === '重庆市' ? "" : this.qx
  170. }).then(res=>{
  171. const temp = res.data.data
  172. const year =temp.qhyyListByYear
  173. const month = temp.qhyyListByMonth
  174. this.fireIndexLabel = [
  175. month.map(item => item.qhyy),
  176. year.map(item => item.qhyy)
  177. ]
  178. this.fireIndexData = [
  179. month.map(item => ({ name: item.qhyy, value: item.hzqs })),
  180. year.map(item => ({ name: item.qhyy, value: item.hzqs }))
  181. ]
  182. })
  183. },
  184. loadSxzbChartData() {
  185. getSxzbListToatl({
  186. ...this.params,
  187. qx: this.qx === '重庆市' ? "" : this.qx
  188. }).then(res => {
  189. const temp = res.data.data
  190. const year =temp.sxzbYear
  191. const month = temp.sxzbMonth.splice(temp.sxzbMonth.length - 12, 12)
  192. this.monthLabel = month.map(item => item.y)
  193. this.yearLabel = year.map(item => item.n)
  194. this.monthData = [
  195. month.map(item => ({ name: item.y, value: item.hzqs })),
  196. month.map(item => ({ name: item.y, value: item.wrs })),
  197. month.map(item => ({ name: item.y, value: item.sss })),
  198. month.map(item => ({ name: item.y, value: item.zzjjss })),
  199. []
  200. ]
  201. this.yearData = [
  202. year.map(item => ({ name: item.y, value: item.hzqs })),
  203. year.map(item => ({ name: item.y, value: item.wrs })),
  204. year.map(item => ({ name: item.y, value: item.sss })),
  205. year.map(item => ({ name: item.y, value: item.zzjjss })),
  206. []
  207. ]
  208. })
  209. }
  210. },
  211. created() {
  212. setInterval(() => {
  213. this.activeIndex = this.activeIndex + 1 >= this.activeItems.length ? 0 : this.activeIndex + 1
  214. }, 10 * 1000),
  215. this.getFrieList()
  216. }
  217. }
  218. </script>
  219. <style lang="less" scoped>
  220. .charts {
  221. .top_title {
  222. display: flex;
  223. justify-content: space-between;
  224. margin-left: 30px;
  225. }
  226. .options {
  227. list-style: none;
  228. display: flex;
  229. gap: 13px;
  230. padding: 2px 4px;
  231. justify-content: end;
  232. .item {
  233. color: #828a93;
  234. font-size: 12px;
  235. cursor: pointer;
  236. }
  237. .active {
  238. color: #00E0FF;
  239. }
  240. }
  241. }
  242. .fire-list {
  243. display: flex;
  244. justify-content: space-around;
  245. margin: 14px 2px 10px 5px;
  246. letter-spacing: 1px;
  247. }
  248. // 渐变
  249. .fire {
  250. width: 105px;
  251. height: 40px;
  252. background: #2b3739;
  253. font-size: 12px;
  254. display: flex;
  255. justify-content: space-around;
  256. align-items: center;
  257. padding: 3px 0;
  258. border-radius: 2px;
  259. .fire-num {
  260. color: #ffbf1a;
  261. font-size: 20px;
  262. }
  263. .num {
  264. font-size: 16px;
  265. }
  266. .num.up {
  267. color: #fb3636;
  268. }
  269. .num.down {
  270. color: #19f34b;
  271. }
  272. }
  273. img {
  274. display: inline-block;
  275. width: 10px;
  276. height: 20px;
  277. }
  278. .manoue {
  279. font-size: 12px !important;
  280. margin-right: 10px;
  281. }
  282. .money {
  283. margin-right: 5px;
  284. }
  285. </style>