index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div>
  3. <div class="fire-list">
  4. <!-- 火灾总数 -->
  5. <div class="fire" @click="openFire">
  6. <div>
  7. <div>
  8. <span class="fire-num">{{ tbData.hzqs }}</span>
  9. <span>起</span>
  10. </div>
  11. <div>火灾总数</div>
  12. </div>
  13. <div>
  14. <img v-if="tbData.hzqstb > 0" src="../../../../assets/images/Vector (1).png" alt="" />
  15. <img v-if="tbData.hzqstb < 0" src="../../../../assets/images/Vector (2).png" alt="" />
  16. <span class="num" :class="{
  17. up: tbData.hzqstb > 0,
  18. down: tbData.hzqstb < 0,
  19. }" >{{ tbData.hzqstb === 0 ? '-' : tbData.hzqsp }}</span>
  20. </div>
  21. </div>
  22. <!--亡人 -->
  23. <div class="fire" @click="openFire">
  24. <div>
  25. <div>
  26. <span class="fire-num">{{ tbData.wrs }}</span>
  27. <span>人</span>
  28. </div>
  29. <div>亡人</div>
  30. </div>
  31. <div>
  32. <img v-if="tbData.wrstb > 0" src="../../../../assets/images/Vector (1).png" alt="" />
  33. <img v-if="tbData.wrstb < 0" src="../../../../assets/images/Vector (2).png" alt="" />
  34. <span class="num" :class="{
  35. up: tbData.wrstb > 0,
  36. down: tbData.wrstb < 0,
  37. }">{{ tbData.wrstb === 0 ? '-' : tbData.wrsp }}</span>
  38. </div>
  39. </div>
  40. <!-- 伤人 -->
  41. <div class="fire" @click="openFire">
  42. <div>
  43. <div>
  44. <span class="fire-num">{{ tbData.srs }}</span>
  45. <span>人</span>
  46. </div>
  47. <div>伤人</div>
  48. </div>
  49. <div>
  50. <img v-if="tbData.srstb > 0" src="../../../../assets/images/Vector (1).png" alt="" />
  51. <img v-if="tbData.srstb < 0" src="../../../../assets/images/Vector (2).png" alt="" />
  52. <span class="num " :class="{
  53. up: tbData.srstb > 0,
  54. down: tbData.srstb < 0,
  55. }" >{{ tbData.srstb === 0 ? '-' : tbData.srsp }}</span>
  56. </div>
  57. </div>
  58. <!-- 直接经济损失 -->
  59. <div class="fire" @click="openFire">
  60. <div>
  61. <div>
  62. <span class="fire-num">{{ tbData.zzjjss }}</span>
  63. <span class="money">万元</span>
  64. <img v-if="tbData.zzjjsstb > 0" src="../../../../assets/images/Vector (1).png" alt="" />
  65. <img v-if="tbData.zzjjsstb < 0" src="../../../../assets/images/Vector (2).png" alt="" />
  66. <span class="num" :class="{
  67. up: tbData.zzjjsstb > 0,
  68. down: tbData.zzjjsstb < 0,
  69. }" >{{ tbData.zzjjsstb === 0 ? '-' : tbData.zzjjssp }}</span>
  70. </div>
  71. <div class="manoue">直接经济损失</div>
  72. </div>
  73. <!-- <div>
  74. <img src="../../../assets/images/Vector (1).png" alt="">
  75. <span class="num">15%</span>
  76. </div> -->
  77. </div>
  78. </div>
  79. <div class="charts">
  80. <div class="top_title">
  81. <div>{{ unitLabel }}</div>
  82. <ul class="options">
  83. <li :class="{
  84. item: true,
  85. active: activeIndexState(index)
  86. }" @click="activeIndex = index" v-for="(item, index) in activeItems" :key="index">{{ item.name }}</li>
  87. </ul>
  88. </div>
  89. <div>
  90. <Chart :items="chartData" :label="chartLabel" :type="activeIndex" :show="type" />
  91. </div>
  92. </div>
  93. <basic-modal top="120px" ref="basicInfoModal1" name="历史火灾查询">
  94. <hzfbCont :default="defaultModal" :qy="qx" />
  95. </basic-modal>
  96. </div>
  97. </template>
  98. <script>
  99. import Chart from './Chart.vue'
  100. import { getSxzbListToatl, getQhyyListToatl, getHzzbSxzbYoy } from "@/api/index.js";
  101. import hzfbCont from '../../../FireCondition/components/hzfbCont.vue';
  102. import moment from 'moment';
  103. export default {
  104. name: 'FireIndex',
  105. components: {
  106. Chart,
  107. hzfbCont
  108. },
  109. props: {
  110. qx: String,
  111. type: {
  112. type: Number,
  113. default: 0
  114. }
  115. },
  116. data() {
  117. return {
  118. activeItems: [
  119. {name: '火灾总数'},
  120. {name: '亡人'},
  121. {name: '伤人'},
  122. {name: '直接经济损失'},
  123. {name: '起火原因'}
  124. ],
  125. activeIndex: 0,
  126. unitLabels: ["起", "人", "人", "万元", "起"],
  127. data: [
  128. [],
  129. [],
  130. [],
  131. [],
  132. []
  133. ],
  134. params:{
  135. pageSize:100,
  136. pageNum:1
  137. },
  138. // 年份横坐标轴标签
  139. yearLabel: [],
  140. // 年份数据
  141. yearData: [],
  142. // 月份纵坐标轴标签
  143. monthLabel: [],
  144. // 月份数据
  145. monthData: [],
  146. modeType: 0,
  147. fireIndexLabel: [],
  148. fireIndexData: [],
  149. monthTbData: {},
  150. yearTbData: {},
  151. defaultModal: []
  152. }
  153. },
  154. watch: {
  155. type: {
  156. handler(idx){
  157. this.modeType = idx
  158. },
  159. immediate: true
  160. },
  161. qx() {
  162. this.getFrieList()
  163. }
  164. },
  165. computed: {
  166. unitLabel() {
  167. return this.unitLabels[this.activeIndex]
  168. },
  169. chartLabel() {
  170. if (this.activeIndex === 4) {
  171. return this.fireIndexLabel[this.type]
  172. }
  173. if (this.type === 0) {
  174. return this.monthLabel;
  175. } else {
  176. return this.yearLabel
  177. }
  178. },
  179. chartData() {
  180. if (this.activeIndex === 4) {
  181. return this.fireIndexData[this.type]
  182. }
  183. if (this.type === 0) {
  184. return this.monthData[this.activeIndex]
  185. } else {
  186. return this.yearData[this.activeIndex];
  187. }
  188. },
  189. tbData() {
  190. return [this.yearTbData , this.monthTbData][this.modeType]
  191. }
  192. },
  193. methods: {
  194. activeIndexState(index) {
  195. return this.activeIndex === index
  196. },
  197. getFrieList(){
  198. this.loadQhyyListToatl()
  199. this.loadSxzbChartData()
  200. this.loadHzzbSxzbYoy()
  201. },
  202. loadQhyyListToatl() {
  203. getQhyyListToatl({
  204. ...this.params,
  205. qy: this.qx === '重庆市' ? "" : this.qx
  206. }).then(res=>{
  207. const temp = res.data.data
  208. const year =temp.qhyyListByYear
  209. const month = temp.qhyyListByMonth
  210. this.fireIndexLabel = [
  211. month.map(item => item.qhyy),
  212. year.map(item => item.qhyy)
  213. ]
  214. this.fireIndexData = [
  215. month.map((item, index) => ({ name: item.qhyy, value: item.hzqs })),
  216. year.map(item => ({ name: item.qhyy, value: item.hzqs }))
  217. ]
  218. })
  219. },
  220. loadSxzbChartData() {
  221. getSxzbListToatl({
  222. ...this.params,
  223. qy: this.qx === '重庆市' ? "" : this.qx
  224. }).then(res => {
  225. const temp = res.data.data
  226. const year =temp.sxzbYear
  227. const month = temp.sxzbMonth.splice(temp.sxzbMonth.length - 12, 12)
  228. this.monthLabel = month.map(item => item.y)
  229. this.yearLabel = year.map(item => item.n)
  230. // console.log('009988--------',month);
  231. this.monthData = [
  232. month.map((item,index) => month.length - 1 === index ? ({ name: item.qhyy, value: item.hzqs, itemStyle: {
  233. color: "#cccccc89",
  234. } }) : ({ name: item.y, value: item.hzqs })),
  235. month.map(item => ({ name: item.y, value: item.wrs })),
  236. month.map(item => ({ name: item.y, value: item.srs })),
  237. month.map(item => ({ name: item.y, value: parseInt(item.zzjjss / 10000) })),
  238. []
  239. ]
  240. this.yearData = [
  241. year.map(item => ({ name: item.y, value: item.hzqs })),
  242. year.map(item => ({ name: item.y, value: item.wrs })),
  243. year.map(item => ({ name: item.y, value: item.srs })),
  244. year.map(item => ({ name: item.y, value: parseInt(item.zzjjss / 10000) })),
  245. []
  246. ]
  247. })
  248. },
  249. loadHzzbSxzbYoy() {
  250. getHzzbSxzbYoy({
  251. qy: this.qx === '重庆市' ? "" : this.qx
  252. }).then(res => {
  253. const temp = res.data.data
  254. if (temp['年同比'].length === 1) {
  255. let tempData = temp['年同比'][0]
  256. this.monthTbData = {
  257. wrs: tempData.wrs,
  258. srs: tempData.srs,
  259. zzjjss: parseInt(tempData.zzjjss / 10000),
  260. hzqs: tempData.hzqs,
  261. wrstb: tempData.wrstb,
  262. srstb: tempData.srstb,
  263. zzjjsstb: tempData.zzjjsstb,
  264. hzqstb: tempData.hzqstb,
  265. wrsp: `${Math.ceil(Math.abs(tempData.wrstb))}%`,
  266. srsp: `${Math.ceil(Math.abs(tempData.srstb))}%`,
  267. zzjjssp: `${Math.ceil(Math.abs(tempData.zzjjsstb))}%`,
  268. hzqsp: `${Math.ceil(Math.abs(tempData.hzqstb))}%`
  269. }
  270. } else {
  271. this.monthTbData = {
  272. wrs: 0,
  273. srs: 0,
  274. zzjjss: 0,
  275. hzqs: 0,
  276. wrstb: 0,
  277. srstb: 0,
  278. zzjjsstb: 0,
  279. hzqstb: 0,
  280. wrsp: `-`,
  281. srsp: `-`,
  282. zzjjssp: `-`,
  283. hzqsp: `-`
  284. }
  285. }
  286. if (temp['月同比'].length === 1) {
  287. let tempData = temp['月同比'][0]
  288. this.yearTbData = {
  289. wrs: tempData.wrs,
  290. srs: tempData.srs,
  291. zzjjss: parseInt(tempData.zzjjss / 10000),
  292. hzqs: tempData.hzqs,
  293. wrstb: tempData.wrstb,
  294. srstb: tempData.srstb,
  295. zzjjsstb: tempData.zzjjsstb,
  296. hzqstb: tempData.hzqstb,
  297. wrsp: `${Math.ceil(Math.abs(tempData.wrstb))}%`,
  298. srsp: `${Math.ceil(Math.abs(tempData.srstb))}%`,
  299. zzjjssp: `${Math.ceil(Math.abs(tempData.zzjjsstb))}%`,
  300. hzqsp: `${ Math.ceil(Math.abs(tempData.hzqstb))}%`
  301. }
  302. } else {
  303. this.yearTbData = {
  304. wrs: 0,
  305. srs: 0,
  306. zzjjss: 0,
  307. hzqs: 0,
  308. wrstb: 0,
  309. srstb: 0,
  310. zzjjsstb: 0,
  311. hzqstb: 0,
  312. wrsp: `-`,
  313. srsp: `-`,
  314. zzjjssp: `-`,
  315. hzqsp: `-`
  316. }
  317. }
  318. })
  319. },
  320. openFire(){
  321. const date = new Date();
  322. const type = ['month', 'year'][this.modeType]
  323. this.defaultModal = {
  324. queryRqTime: [moment(date).startOf(type).toDate(), moment(date).endOf(type).toDate()],
  325. }
  326. this.showModal("basicInfoModal1");
  327. }
  328. },
  329. created() {
  330. setInterval(() => {
  331. this.activeIndex = this.activeIndex + 1 >= this.activeItems.length ? 0 : this.activeIndex + 1
  332. }, 30 * 1000),
  333. this.getFrieList()
  334. }
  335. }
  336. </script>
  337. <style lang="less" scoped>
  338. .charts {
  339. .top_title {
  340. display: flex;
  341. justify-content: space-between;
  342. margin-left: 30px;
  343. }
  344. .options {
  345. list-style: none;
  346. display: flex;
  347. gap: 13px;
  348. padding: 2px 29px;
  349. justify-content: end;
  350. .item {
  351. color: #828a93;
  352. font-size: 12px;
  353. cursor: pointer;
  354. }
  355. .active {
  356. color: #00E0FF;
  357. }
  358. }
  359. }
  360. .fire-list {
  361. display: flex;
  362. justify-content: space-around;
  363. margin: 14px 2px 10px 5px;
  364. letter-spacing: 1px;
  365. }
  366. // 渐变
  367. .fire {
  368. width: 165px;
  369. height: 40px;
  370. background: #2b3739;
  371. font-size: 12px;
  372. display: flex;
  373. justify-content: space-around;
  374. align-items: center;
  375. cursor: pointer;
  376. padding: 3px 0;
  377. border-radius: 2px;
  378. .fire-num {
  379. color: #ffbf1a;
  380. font-size: 20px;
  381. }
  382. .num {
  383. font-size: 15px;
  384. }
  385. .num.up {
  386. color: #fb3636;
  387. }
  388. .num.down {
  389. color: #19f34b;
  390. }
  391. }
  392. img {
  393. display: inline-block;
  394. width: 10px;
  395. height: 20px;
  396. }
  397. .manoue {
  398. font-size: 12px !important;
  399. margin-right: 10px;
  400. }
  401. .money {
  402. margin-right: 5px;
  403. }
  404. </style>