risk_precontrol.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <view class="top">
  4. <image src="./img/top.jpg" mode=""></image>
  5. </view>
  6. <view class="content">
  7. <view class="list">
  8. <view class="item" v-for="(item,index) in list" :key="index"
  9. @click="open_draw(item.mine_id,item.mine_name)">
  10. <view class="inner" :style="{borderLeftColor: bgColor[index]}">
  11. <view class="left">
  12. <view class="name">{{item.mine_name}}</view>
  13. <view class="text">{{item.danger_num}} 条隐患信息</view>
  14. </view>
  15. <view class="right">
  16. <view class="num">{{item.score}} 分</view>
  17. <view class="icon">
  18. <uni-icons type="arrowright"></uni-icons>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 弹出层 -->
  25. <uni-drawer ref="draw" mode="right" :width="300">
  26. <view class="drawer">
  27. <view class="title">{{mine_name}}</view>
  28. <view class="container">
  29. <view class="item" v-for="(item,index) in depart_list" :key="index"
  30. @click="go_detail(item.depart_id)">
  31. <view class="inner" :style="{borderLeftColor: bgColor[index]}">
  32. <view class="left">
  33. <view class="name">{{item.depart_name}}</view>
  34. <view class="text">{{item.danger_num}} 条隐患信息</view>
  35. </view>
  36. <view class="right">
  37. <view class="num">{{item.score}} 分</view>
  38. <view class="icon">
  39. <uni-icons type="arrowright"></uni-icons>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </uni-drawer>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import time from "@/common/time.js"
  52. export default {
  53. data() {
  54. return {
  55. start_time: "",
  56. end_time: "",
  57. list: [],
  58. bgColor: [],
  59. depart_list: [],
  60. mine_name: ""
  61. };
  62. },
  63. onLoad() {
  64. // 初始化时间
  65. this.start_time = new Date().format("yyyy-MM-01")
  66. this.end_time = new Date().format("yyyy-MM-dd")
  67. console.log(this.start_time, this.end_time)
  68. // 设置头像
  69. for (let i = 0; i < 100; i++) {
  70. // 获取随机色
  71. let r = parseInt(Math.random() * 256)
  72. let g = parseInt(Math.random() * 256)
  73. let b = parseInt(Math.random() * 256)
  74. // ES6 字符串拼接
  75. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  76. let color = "rgba(" + r + "," + g + "," + b + "," + 0.8 + ")"
  77. // console.log(color)
  78. this.bgColor.push(color)
  79. }
  80. this.get_list()
  81. },
  82. methods: {
  83. open_draw(mine_id, mine_name) {
  84. this.mine_name = mine_name
  85. this.depart_list = []
  86. this.$refs.draw.open()
  87. this.$p_api.danger_depart({
  88. mine_id: mine_id,
  89. start_time: this.start_time,
  90. end_time: this.end_time
  91. }).then((res) => {
  92. // console.log(res.data.data)
  93. this.depart_list = res.data.data
  94. })
  95. },
  96. go_detail(depart_id) {
  97. uni.navigateTo({
  98. url: "detail/detail?depart_id=" + depart_id
  99. })
  100. },
  101. get_list() {
  102. this.$p_api.danger_mine({
  103. start_time: this.start_time,
  104. end_time: this.end_time
  105. }).then((res) => {
  106. // console.log(res.data.data)
  107. this.list = res.data.data
  108. })
  109. },
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. .top {
  115. image {
  116. width: 750rpx;
  117. height: 360rpx;
  118. }
  119. }
  120. .content {
  121. width: 749rpx;
  122. }
  123. .list {
  124. .item {
  125. box-sizing: border-box;
  126. padding: 20rpx 0;
  127. padding-right: 30rpx;
  128. border-bottom: 1px solid #eee;
  129. .inner {
  130. border-left: 12rpx solid #8BDAFF;
  131. display: flex;
  132. justify-content: space-between;
  133. align-items: center;
  134. .left {
  135. box-sizing: border-box;
  136. padding-left: 30rpx;
  137. line-height: 45rpx;
  138. .name {}
  139. .text {
  140. font-size: 26rpx;
  141. color: #999999;
  142. }
  143. }
  144. .right {
  145. display: flex;
  146. align-items: center;
  147. .num {
  148. font-size: 26rpx;
  149. color: #AC5158;
  150. }
  151. .icon {
  152. margin-left: 4rpx;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. .drawer {
  159. width: 600rpx;
  160. .title {
  161. line-height: 87rpx;
  162. box-sizing: border-box;
  163. padding: 0 30rpx;
  164. border-bottom: 1px solid #2E8EAA;
  165. }
  166. .container {
  167. width: 600rpx;
  168. .item {
  169. box-sizing: border-box;
  170. padding: 20rpx 0;
  171. padding-right: 30rpx;
  172. border-bottom: 1px solid #eee;
  173. .inner {
  174. border-left: 12rpx solid #8BDAFF;
  175. display: flex;
  176. justify-content: space-between;
  177. align-items: center;
  178. .left {
  179. box-sizing: border-box;
  180. padding-left: 30rpx;
  181. line-height: 45rpx;
  182. width: 390rpx;
  183. .name {
  184. width: 390rpx;
  185. white-space: nowrap;
  186. overflow: hidden;
  187. text-overflow: ellipsis;
  188. }
  189. .text {
  190. font-size: 26rpx;
  191. color: #999999;
  192. }
  193. }
  194. .right {
  195. display: flex;
  196. align-items: center;
  197. .num {
  198. font-size: 26rpx;
  199. color: #AC5158;
  200. }
  201. .icon {
  202. margin-left: 4rpx;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. </style>