FireDistribution.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template >
  2. <div style="padding: 6px;">
  3. <div>
  4. <button-group @change="changeHandler">
  5. <button-group-item> <span style="color: #79e7ff;"> 火灾起数</span> </button-group-item>
  6. <button-group-item> <span style="color: #79e7ff;"> 死亡人数 </span> </button-group-item>
  7. </button-group>
  8. </div>
  9. <div>
  10. <div class="row header">
  11. <span class="type">序号</span>
  12. <span class="count">区县</span>
  13. <span class="time">{{ ['火灾总数', '死亡人数'][idx]}}</span>
  14. <span class="unit">同比</span>
  15. </div>
  16. <VueSeamlessScroll v-if="reload" :data="list" :class-option="classOption" class="warp">
  17. <ul class="item">
  18. <li class="row" :class="{
  19. active: item.isActive
  20. }" v-for="(item, index) in list" :key="index">
  21. <span class="type">{{ index + 1 }}</span>
  22. <span class="count">{{ item.qx }}</span>
  23. <span class="time">{{ [item.bnhzqs, item.bnwrs ][idx] }}</span>
  24. <span class="unit">{{ [item.hzPercent, item.wrPercent ][idx] }}
  25. <img v-if="[item.hzIcon, item.wrIcon ][idx]" :src="[item.hzIcon, item.wrIcon ][idx]" alt="" />
  26. </span>
  27. </li>
  28. </ul>
  29. </VueSeamlessScroll>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import VueSeamlessScroll from "vue-seamless-scroll";
  35. import upIcon from '../../../assets/images/up-icon.svg';
  36. import downIcon from '../../../assets/images/down-icon.svg';
  37. import { fireDistribution } from '@/api/hzfx'
  38. import { toFirst } from '@/utils'
  39. export default {
  40. name: 'FireDistribution',
  41. components: {
  42. VueSeamlessScroll
  43. },
  44. props: {
  45. qx: String
  46. },
  47. data() {
  48. return {
  49. idx: 0,
  50. list: [],
  51. reload: true
  52. };
  53. },
  54. created() {
  55. this.loadData()
  56. },
  57. watch: {
  58. qx() {
  59. this.loadData();
  60. }
  61. },
  62. methods: {
  63. changeHandler(idx) {
  64. this.idx = idx;
  65. },
  66. getPercent(bn, tq) {
  67. if (bn - tq === 0) {
  68. return '0%'
  69. }
  70. if (tq === 0) {
  71. return '100%'
  72. }
  73. return `${(parseInt((Math.abs(bn - tq) / tq).toFixed(2) * 100 ))}%`
  74. },
  75. getIcon(bn, tq) {
  76. if (bn -tq > 0) {
  77. return upIcon;
  78. } else if (bn - tq < 0){
  79. return downIcon;
  80. } else {
  81. return null;
  82. }
  83. },
  84. loadData() {
  85. this.reload = false
  86. fireDistribution({
  87. pageSize: 100,
  88. pageNum: 1,
  89. // qx: this.qx
  90. }).then(res => {
  91. let tempData = res.data.rows.map(item => ({...item,
  92. hzPercent: this.getPercent(item.bnhzqs, item.tqhzqs),
  93. wrPercent: this.getPercent(item.bnwrs, item.tqwrs),
  94. hzIcon: this.getIcon(item.bnhzqs, item.tqhzqs),
  95. wrIcon: this.getIcon(item.bnwrs, item.tqwrs),
  96. isActive: item.qx === this.qx
  97. }))
  98. this.list = toFirst(tempData, this.qx, 'qx')
  99. this.reload = true
  100. })
  101. }
  102. },
  103. computed: {
  104. classOption() {
  105. return {
  106. singleHeight: 51,
  107. autoPlay: this.qx === ""
  108. };
  109. },
  110. },
  111. }
  112. </script>
  113. <style scoped lang='less'>
  114. .warp {
  115. height: 521px;
  116. margin: 0 auto;
  117. overflow: hidden;
  118. .item {
  119. list-style: none;
  120. padding: 0;
  121. margin: 0 auto;
  122. cursor: pointer;
  123. }
  124. }
  125. .header {
  126. color: #61DBFF !important;
  127. height: 38px !important;
  128. background-color: rgba(0, 163, 255, 0.3) !important;
  129. margin-top: 2px;
  130. letter-spacing: 1px;
  131. .is_notice {
  132. line-height: 19px;
  133. font-size: 10px;
  134. }
  135. }
  136. li.row > span {
  137. text-align: center;
  138. font-size: 14x;
  139. position: relative;
  140. display: inline-block;
  141. }
  142. li.row.active {
  143. background-color: rgba(0, 213, 255, 0.2);
  144. }
  145. li.row {
  146. box-sizing: border-box;
  147. }
  148. .row,
  149. li,
  150. a {
  151. display: block;
  152. height: 46px;
  153. line-height: 46px;
  154. display: flex;
  155. justify-content: space-between;
  156. align-items: center;
  157. font-size: 14px;
  158. background-color: rgba(0, 0, 0, 0.2);
  159. color: #fff;
  160. margin-top: 5px;
  161. .time,
  162. .type,
  163. .count,
  164. .unit{
  165. display: flex;
  166. justify-content: center;
  167. align-items: center;
  168. flex: 0.25;
  169. img {
  170. display: inline-block;
  171. width: 11px;
  172. height: 16px;
  173. margin-left: 5px;
  174. }
  175. }
  176. .time {
  177. color: #61DBFF;
  178. }
  179. }
  180. </style>