grid_query.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view>
  3. <view class="section">
  4. <view class="title">检查情况</view>
  5. <view class="input_box">
  6. <view class="box">
  7. <uni-datetime-picker v-model="range" type="daterange" rangeSeparator="至" />
  8. </view>
  9. </view>
  10. <view class="btn" @click="get_trouble_grid_list()">查询</view>
  11. </view>
  12. <view class="content">
  13. <view class="list">
  14. <view class="item" v-for="(item,index) in grid_list" :key="index">
  15. <view class="name" @click="change_active(index)">
  16. <view class="left">
  17. <view class="text">{{item.gridName}}</view>
  18. <view class="tip">{{item.detailsGrid}}</view>
  19. </view>
  20. <view class="right">
  21. <uni-icons type="arrowright" v-if="active == index"></uni-icons>
  22. <uni-icons type="arrowdown" v-if="active != index"></uni-icons>
  23. </view>
  24. </view>
  25. <view class="box" v-if="active == index">
  26. <view class="box_item" v-for="(item_2,index_2) in item.gridList" :key="index_2">
  27. <view class="text">{{item_2.name}}</view>
  28. <view @click="go_detail(item_2.check_id)" v-if="item_2.status == 2" class="btn">已巡检</view>
  29. <view v-if="!item_2.status"class="btn" style="background-color: #E74C3C;">未巡检</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. Date.prototype.format = function(fmt){
  39. var o = {
  40. "M+" : this.getMonth()+1, //月份
  41. "d+" : this.getDate(), //日
  42. "h+" : this.getHours(), //小时
  43. "m+" : this.getMinutes(), //分
  44. "s+" : this.getSeconds(), //秒
  45. "q+" : Math.floor((this.getMonth()+3)/3), //季度
  46. "S" : this.getMilliseconds() //毫秒
  47. };
  48. if(/(y+)/.test(fmt)){
  49. fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
  50. }
  51. for(var k in o){
  52. if(new RegExp("("+ k +")").test(fmt)){
  53. fmt = fmt.replace(
  54. RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
  55. }
  56. }
  57. return fmt;
  58. }
  59. export default {
  60. data() {
  61. return {
  62. active:9999,
  63. // 时间范围
  64. range: [],
  65. // 网格数据
  66. grid_list:[]
  67. };
  68. },
  69. watch: {
  70. range(newval) {
  71. console.log("范围选:", this.range);
  72. },
  73. },
  74. onLoad() {
  75. // 初始化时间
  76. this.range[0] = new Date().format("yyyy-MM-01")
  77. this.range[1] = new Date().format("yyyy-MM-dd")
  78. this.get_trouble_grid_list()
  79. },
  80. methods:{
  81. change_active(index){
  82. if(this.active == index){
  83. // 关闭当前项
  84. this.active = 9999
  85. }else{
  86. // 展开当前项
  87. this.active = index
  88. }
  89. },
  90. get_trouble_grid_list(){
  91. uni.showLoading({
  92. mask: true
  93. })
  94. this.$api.trouble_grid_list({
  95. type:1,
  96. start_time:this.range[0],
  97. end_time:this.range[1]
  98. }).then((res)=>{
  99. uni.hideLoading()
  100. console.log(res.data.data)
  101. this.grid_list = res.data.data
  102. })
  103. },
  104. go_detail(id){
  105. uni.navigateTo({
  106. url:"./detail/detail?id="+id
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. .section {
  114. box-sizing: border-box;
  115. padding: 25rpx;
  116. .title {
  117. line-height: 60rpx;
  118. border-left: 8rpx solid #009FE8;
  119. box-sizing: border-box;
  120. padding-left: 20rpx;
  121. margin-bottom: 20rpx;
  122. }
  123. .input_box {
  124. margin-bottom: 20rpx;
  125. font-size: 32rpx;
  126. .box {
  127. width: 700rpx;
  128. min-height: 90rpx;
  129. line-height: 90rpx;
  130. background: #FFFFFF;
  131. border-radius: 8rpx;
  132. border: 2rpx solid #E9EBF2;
  133. box-sizing: border-box;
  134. padding: 0 25rpx;
  135. /deep/.uni-date-editor--x {
  136. .uniui-clear {
  137. display: none;
  138. }
  139. }
  140. /deep/.uni-date-x--border {
  141. box-sizing: border-box;
  142. border-radius: 4px;
  143. border: none;
  144. }
  145. /deep/.uni-date-x {
  146. padding: 0;
  147. }
  148. }
  149. }
  150. .btn {
  151. background-color: #009FE8;
  152. padding: 25rpx 50rpx;
  153. color: #FFFFFF;
  154. text-align: center;
  155. }
  156. }
  157. .content {
  158. box-sizing: border-box;
  159. padding: 25rpx;
  160. .list {
  161. .item {
  162. margin-bottom: 30rpx;
  163. box-sizing: border-box;
  164. padding: 25rpx;
  165. border: 1rpx solid #E9EBF2;
  166. border-radius: 4rpx;
  167. .name {
  168. display: flex;
  169. justify-content: space-between;
  170. align-items: center;
  171. border-left: 6rpx solid #009FE8;
  172. padding-left: 10rpx;
  173. .left {
  174. .text {
  175. line-height: 50rpx;
  176. font-size: 30rpx;
  177. }
  178. .tip {
  179. line-height: 40rpx;
  180. font-size: 28rpx;
  181. color: #999;
  182. }
  183. }
  184. .right {}
  185. }
  186. .box {
  187. margin-top: 10rpx;
  188. .box_item {
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. box-sizing: border-box;
  193. padding: 20rpx 0;
  194. border-bottom: 1rpx solid #E9EBF2;
  195. .text {
  196. width: 450rpx;
  197. line-height: 40rpx;
  198. font-size: 30rpx;
  199. }
  200. .btn {
  201. padding: 10rpx 20rpx;
  202. background-color: #2ECC71;
  203. color: #FFFFFF;
  204. font-size: 26rpx;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. </style>