checkpoint.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="u-flex f-d-c m-w" style="border-top: 1px solid #CCCCCC;">
  3. <!-- <view style="background: #FFFFFF;" class="m-w u-p-l-20 u-p-r-20 u-p-t-24 u-p-b-24 ">
  4. <cSearch placeholder="查询" @serbtn="setrch()" ></cSearch>
  5. </view> -->
  6. <view class="m-w">
  7. <cDropdow :options="options1" title="全部巡检路线" @getroomList="getCheckRooms"></cDropdow>
  8. </view>
  9. <!-- <u-dropdown style="width: 50%;">
  10. <u-dropdown-item v-model="value1" title="全部巡检路线" :options="options1"></u-dropdown-item>
  11. </u-dropdown> -->
  12. <scroll-view @scrolltolower="lazyGetRooms()" :scroll-y="true" class="sc-view u-p-l-10 u-p-r-10">
  13. <u-cell-group style="width: 100%;">
  14. <navigator class="u-border-bottom" style="border: solid 3rpx #FFFFFF;" hover-class="none" :url="`../checkdetail/checkdetail?id=${item.id}&routeId=${item.routeId}`"
  15. v-for="(item,index) in cellmenu" :key="item.number">
  16. <u-cell-item :border-top="false" :border-bottom="false" bg-color="#ffffff" :key="index"
  17. :label-style="{'fontSize':'28rpx', 'color':'rgba(80, 80, 80, 1)'}"
  18. :icon-style="{'color':'#B3B3B3'}"
  19. :title-style="{'color':'#000','fontSize':'32rpx','fontWeight':' blod'}" :arrow="false"
  20. :label="item.name" :title="item.number">
  21. <u-icon name="arrow-right" slot="right-icon" color="#B3B3B3" size="38"></u-icon>
  22. </u-cell-item>
  23. <!-- <view style=" height: 3rpx;width: 100%; background: #FFFFFF;"></view> -->
  24. </navigator>
  25. </u-cell-group>
  26. <view style="overflow: hidden;">
  27. <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
  28. </view>
  29. </scroll-view>
  30. <u-toast ref="chckToast"></u-toast>
  31. </view>
  32. </template>
  33. <script>
  34. import cSearch from '@/components/c-search/index'
  35. import cDropdow from '../components/c-dropdown/index'
  36. import debounce from '@/util/debounce/debounce.js'
  37. import {
  38. checkOption,
  39. checkRooms
  40. } from '@/api/index.js'
  41. export default {
  42. name: "checkpoint",
  43. components: {
  44. cSearch,
  45. cDropdow
  46. },
  47. data() {
  48. return {
  49. option_name: '',//子组件传的路线选项值
  50. options1: [], //路线选项数组
  51. cellmenu: [], //房间数组
  52. //请求数据
  53. queryform: {
  54. pageSize: 10,
  55. currPage: 1,
  56. pointName: ""
  57. },
  58. currentPage: 0,//当前页
  59. totalCount: -1,//总个数
  60. //下拉加载配置
  61. status: 'loadmore',
  62. iconType: 'flower',
  63. loadText: {
  64. loadmore: '轻轻上拉',
  65. loading: '努力加载中',
  66. nomore: '实在没有了'
  67. }
  68. }
  69. },
  70. onLoad() {
  71. this.getCheckOption()
  72. this.getCheckRooms(null, -1)
  73. },
  74. methods: {
  75. //获取巡检路线选项
  76. async getCheckOption() {
  77. let {
  78. data
  79. } = await checkOption()
  80. this.options1.length = 0;
  81. data.forEach(i => {
  82. let obj = new Object;
  83. obj.label = i.name;
  84. obj.value = i.id;
  85. this.options1.push(obj)
  86. })
  87. this.options1.push({
  88. label: '全部巡检路线',
  89. value: null
  90. })
  91. },
  92. //获取路线所有房间
  93. async getCheckRooms(option_name, index) {
  94. this.option_name = option_name
  95. if (index == -1 || this.totalCount == -1) {
  96. this.cellmenu = []
  97. this.currentPage = 1
  98. if (option_name) {
  99. let {
  100. data
  101. } = await checkRooms({
  102. id: option_name,
  103. page: 1,
  104. size: 10,
  105. })
  106. this.cellmenu = data.list
  107. this.totalCount = data.total
  108. } else {
  109. let {
  110. data
  111. } = await checkRooms({
  112. page: 1,
  113. size: 10,
  114. })
  115. this.cellmenu = data.list
  116. this.totalCount = data.total
  117. }
  118. } else {
  119. let curPage = this.currentPage + 1
  120. if (this.cellmenu.length < this.totalCount) {
  121. if (option_name) {
  122. let {
  123. data
  124. } = await checkRooms({
  125. id: option_name,
  126. page: curPage,
  127. size: 10,
  128. })
  129. data.list.forEach(i => {
  130. this.cellmenu.push(i)
  131. })
  132. this.currentPage = this.currentPage + 1
  133. } else {
  134. let {
  135. data
  136. } = await checkRooms({
  137. page: curPage,
  138. size: 10,
  139. })
  140. data.list.forEach(i => {
  141. this.cellmenu.push(i)
  142. })
  143. this.currentPage = this.currentPage + 1
  144. }
  145. } else if (this.cellmenu.length = this.totalCount) {
  146. this.$refs.chckToast.show({
  147. title: '没有更多了',
  148. type: 'info',
  149. })
  150. }
  151. }
  152. },
  153. //懒加载房间数据
  154. lazyGetRooms() {
  155. let timer = null
  156. return (() => {
  157. if (this.cellmenu.length == this.totalCount) this.status = 'nomore';
  158. this.status = 'loading';
  159. if(timer) {
  160. clearTimeout(timer)
  161. }
  162. timer = setTimeout(() => {
  163. this.getCheckRooms(this.option_name,1)
  164. if (this.cellmenu.length == this.totalCount) this.status = 'nomore';
  165. else this.status = 'loading';
  166. }, 2000)
  167. })()
  168. }
  169. }
  170. }
  171. </script>
  172. <style>
  173. page {
  174. background: #ffffff;
  175. }
  176. .sc-view {
  177. height: calc(100vh - 84rpx);
  178. width: 690rpx;
  179. background: #FFFFFF;
  180. box-shadow: 0px 0px 6rpx 0px rgba(6, 0, 1, 0.26);
  181. border-radius: 10rpx 10rpx 0px 0px;
  182. }
  183. </style>