patrolrecored.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view >
  3. <view class="u-p-t-12 u-p-b-20 u-p-l-20 u-p-r-10" style="background: #FFFFFF;">
  4. <cSearch @serbtn="setbtn" :sear="'搜索巡检记录'"/>
  5. </view>
  6. <u-dropdown style="width: 100%; background: #ffffff">
  7. <u-dropdown-item @change="drowcitem1" :title="title" :options="options1">
  8. </u-dropdown-item>
  9. <u-dropdown-item @change="drowclick" :title="title1" :options="options2">
  10. </u-dropdown-item>
  11. </u-dropdown>
  12. <view class="u-flex f-d-c m-w">
  13. <scroll-view :scroll-y="true" @scrolltolower="lazyGetRooms()" class=" sc-view ">
  14. <u-cell-group v-if="cellmenu.length > 0">
  15. <navigator hover-class="none" v-for="(item,index) in cellmenu" :key="index"
  16. :url="`../patroldetail/patroldetail?taskId=${item.id}&roomId=${item.roomId}`">
  17. <u-cell-item :use-label-slot="true" :border-bottom="true" :border-top="false" :key="index"
  18. :label-style="{'fontSize':'28rpx', 'color':'rgba(80, 80, 80, 1)' ,'marginBottom':'30rpx'}"
  19. :icon-style="{'color':'#000'}"
  20. :title-style="{'color':'#000','fontSize':'32rpx','fontWeight':' blod'}" :arrow="false"
  21. :label="item.roomName" :title="item.name">
  22. <u-icon name="arrow-right" slot="right-icon" color="#B3B3B3" size="38"></u-icon>
  23. <div solt="label" class="left-boto-txt">{{item.username}}:{{item.time}}</div>
  24. </u-cell-item>
  25. <view style=" height: 3.5rpx;width: 100%; background: #FFFFFF;"></view>
  26. </navigator>
  27. <view style="overflow: hidden;">
  28. <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
  29. </view>
  30. </u-cell-group>
  31. <block v-else>
  32. <view v-if="loashow" class="u-text-center" style="margin-top: 400rpx;">
  33. <u-loading loashow color="blue" size="50"></u-loading>
  34. </view>
  35. <view v-else>
  36. <u-empty margin-top="400" text="数据为空" mode="list"></u-empty>
  37. </view>
  38. </block>
  39. </scroll-view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. partinfo1
  46. } from '@/api/index.js'
  47. import {
  48. mapState
  49. } from 'vuex'
  50. import dayjs from "dayjs";
  51. import cSearch from '@/components/c-search/index.vue'
  52. export default {
  53. components: {
  54. cSearch,
  55. },
  56. data() {
  57. return {
  58. options1: [{
  59. label: '今天',
  60. value: [dayjs(new Date(new Date(new Date().toLocaleDateString()).getTime())).format(
  61. "YYYY-MM-DD HH:mm:ss"), dayjs(new Date(new Date(new Date().toLocaleDateString())
  62. .getTime() + 24 * 60 * 60 * 1000 - 1)).format("YYYY-MM-DD HH:mm:ss")],
  63. },
  64. {
  65. label: '昨天',
  66. value: [dayjs(new Date(new Date(new Date().toLocaleDateString()).getTime() - 24 * 60 * 60 *
  67. 1000)).format("YYYY-MM-DD HH:mm:ss"), dayjs(new Date(new Date(new Date()
  68. .toLocaleDateString()).getTime() - 1)).format("YYYY-MM-DD HH:mm:ss")],
  69. },
  70. {
  71. label: '近7日',
  72. value: [dayjs(new Date(new Date(new Date().toLocaleDateString()).getTime() - (24 * 60 * 60 *
  73. 1000) * 3)).format("YYYY-MM-DD HH:mm:ss"), dayjs(new Date(new Date(new Date()
  74. .toLocaleDateString()).getTime() + (24 * 60 * 60 * 1000) * 3)).format(
  75. "YYYY-MM-DD HH:mm:ss")],
  76. }
  77. ],
  78. options2: [{
  79. label: '全部状态',
  80. value: 1,
  81. },
  82. {
  83. label: '合格',
  84. value: 2,
  85. },
  86. {
  87. label: '不合格',
  88. value: 3,
  89. },
  90. ],
  91. cellmenu: [], //数据列表
  92. queryform: {},//请求对象
  93. //下拉框标题
  94. title: "时间",
  95. title1: "状态",
  96. totalCount: -1, //总项目数
  97. curPage: 1, //当前页数
  98. loashow: false,
  99. //下拉加载配置
  100. status: 'loadmore',
  101. iconType: 'flower',
  102. loadText: {
  103. loadmore: '轻轻上拉',
  104. loading: '努力加载中',
  105. nomore: '实在没有了'
  106. }
  107. }
  108. },
  109. // 计算属性,从仓库获取timer数据
  110. computed: {
  111. ...mapState({
  112. timer: state => state.user.timer
  113. })
  114. },
  115. onLoad() {
  116. this.getlist(-1)
  117. },
  118. methods: {
  119. //关键字模糊查询
  120. setbtn(keyWord) {
  121. if(keyWord.text == 0) {
  122. this.queryform.keyword = ''
  123. this.$nextTick(() => {
  124. this.getlist(-1)
  125. })
  126. } else {
  127. this.queryform.keyword = keyWord.text
  128. this.$nextTick(() => {
  129. this.getlist(-1)
  130. })
  131. }
  132. },
  133. // 改变时间筛选数据
  134. drowcitem1(row) {
  135. let option1 = JSON.parse(JSON.stringify(this.options1))
  136. let optiontext = option1.find((index) => {
  137. if (index.value.toString() == row.toString()) {
  138. return index
  139. }
  140. })
  141. this.title = optiontext.label
  142. this.queryform.beginTimeStart = row[0]
  143. this.queryform.beginTimeEnd = row[1]
  144. this.$nextTick(() => {
  145. this.getlist(-1)
  146. })
  147. },
  148. // 改变状态筛选数据
  149. drowclick(row) {
  150. if (row == 2) {
  151. this.queryform.qualified = true
  152. this.title1 = "合格"
  153. this.$nextTick(() => {
  154. this.getlist(-1)
  155. })
  156. } else if (row == 3) {
  157. this.queryform.qualified = false
  158. this.title1 = "不合格"
  159. this.$nextTick(() => {
  160. this.getlist(-1)
  161. })
  162. } else {
  163. this.queryform.qualified = ''
  164. this.title1 = "全部状态"
  165. this.$nextTick(() => {
  166. this.getlist(-1)
  167. })
  168. }
  169. },
  170. // 获取巡检记录数据
  171. async getlist(index) {
  172. if (this.totalCount == -1 || index == -1) {
  173. this.loashow = true
  174. this.cellmenu = []
  175. let data = await partinfo1({
  176. page: 1,
  177. size: 10,
  178. ...this.queryform
  179. })
  180. this.loashow = false
  181. const {
  182. list,
  183. total,
  184. } = data.data
  185. this.totalCount = total //总个数
  186. this.cellmenu = list.map(Element => {
  187. Element.time = dayjs(Element.time).format("YYYY-MM-DD HH:mm:ss")
  188. return Element
  189. })
  190. } else {
  191. let curPage = this.curPage + 1
  192. if (this.cellmenu.length < this.totalCount) {
  193. let {
  194. data
  195. } = await partinfo1({
  196. page: curPage,
  197. size: 10,
  198. ...this.queryform
  199. })
  200. data.list.forEach(Element => {
  201. Element.time = dayjs(Element.time).format("YYYY-MM-DD HH:mm:ss")
  202. })
  203. data.list.forEach(i => {
  204. this.cellmenu.push(i)
  205. })
  206. this.curPage = this.curPage + 1
  207. } else if (this.cellmenu.length == this.totalCount) {
  208. this.$refs.sacast.show({
  209. title: '没有更多了',
  210. type: 'info',
  211. })
  212. }
  213. }
  214. },
  215. //懒加载房间数据
  216. lazyGetRooms() {
  217. var timer = null;
  218. if (this.cellmenu.length == this.totalCount) this.status = 'nomore';
  219. this.status = 'loading';
  220. clearTimeout(timer)
  221. timer = setTimeout(() => {
  222. this.getlist(1)
  223. if (this.cellmenu.length == this.totalCount) this.status = 'nomore';
  224. else this.status = 'loading';
  225. }, 2000)
  226. }
  227. }
  228. }
  229. </script>
  230. <style>
  231. page {
  232. background: #ffffff;
  233. }
  234. .sc-view {
  235. height: calc(100vh - 200rpx);
  236. width: 690rpx;
  237. box-shadow: 0px 0px 6rpx 0px rgba(6, 0, 1, 0.26);
  238. border-radius: 10rpx 10rpx 0px 0px;
  239. }
  240. .left-boto-txt {
  241. position: absolute;
  242. left: 30rpx;
  243. top: 125rpx;
  244. font-size: 28rpx;
  245. }
  246. .blo {
  247. width: 100%;
  248. margin-top: 50rpx;
  249. height: 400rpx;
  250. }
  251. </style>