list.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view class="content">
  3. <view class="topbar" v-show="isIphone">
  4. </view>
  5. <!-- #ifdef MP-WEIXIN -->
  6. <view class="topbar">
  7. </view>
  8. <!-- #endif -->
  9. <view class="status_bar">
  10. <view class="left" @click="goBack()"><u-icon name="arrow-left"></u-icon>返回</view>
  11. <span style="font-size: 36rpx;">上报记录</span>
  12. <view class="right">
  13. <span @click="filterShow = true">筛选</span>
  14. </view>
  15. </view>
  16. <view class="status_tabs">
  17. <u-tabs bg-color="#5976ba" active-color="#fff" inactive-color="#fff" :list="tabList" :is-scroll="false"
  18. :current="current" @change="tabChange"></u-tabs>
  19. </view>
  20. <view class="search_bar">
  21. <u-search @custom="clearSearch" @search="onRefresh" action-text="清除" placeholder="请输入位置/内容模糊搜索"
  22. v-model="keyword">
  23. </u-search>
  24. </view>
  25. <scroll-view @scroll="scroll" :refresher-enabled="scroll_refresher_enabled"
  26. :style="{paddingBottom: current == 1 ? '10px' : '10px'}" scroll-y class="scroll-box mainCont"
  27. @scrolltolower="handleLoadMore" :refresher-triggered="triggered" :refresher-threshold="100"
  28. refresher-background="white" @refresherrefresh="onRefresh" @refresherrestore="onRestore">
  29. <view class="card" @click="goInfo(item.id)" v-for="(item, index) in tableList" :key="index">
  30. <view class="top">
  31. <view class="left">{{ item.troubleCode }}</view>
  32. <view class="right" v-show="current == 0" style="color: #33CC00">待处理</view>
  33. <view class="right" v-show="current == 1" style="color: #33CC00;">处理中</view>
  34. <view class="right" v-show="current == 2" style="color: #CCCCCC">已关闭</view>
  35. </view>
  36. <view class="bottom">
  37. <view>隐患位置:{{ item.location }}</view>
  38. <view>内容描述:{{ item.description }}</view>
  39. <view>提交时间:{{ item.createDate }}</view>
  40. </view>
  41. </view>
  42. <view style="margin-top: 100px;text-align: center;" v-show="!tableList.length">暂无数据</view>
  43. </scroll-view>
  44. <u-picker :default-time="time" @confirm="fliterConfirm" @cancel="fliterCancel" mode="time" v-model="filterShow"
  45. :params="params">
  46. </u-picker>
  47. <u-toast ref="uToast" />
  48. </view>
  49. </template>
  50. <script>
  51. const NET = require('@/utils/request')
  52. const API = require('@/config/api')
  53. export default {
  54. data() {
  55. return {
  56. isIphone: false,
  57. current: 0,
  58. tabList: [{
  59. name: '待处理'
  60. }, {
  61. name: '处理中'
  62. }, {
  63. name: '已关闭'
  64. }],
  65. scroll_refresher_enabled: true,
  66. pageIndex: 1,
  67. triggered: false,
  68. isOver: false,
  69. keyword: "",
  70. tableList: [],
  71. loading: false,
  72. filterShow: false,
  73. params: {
  74. year: true,
  75. month: true,
  76. day: true,
  77. hour: false,
  78. minute: false,
  79. second: false
  80. },
  81. time: "",
  82. }
  83. },
  84. onLoad() {
  85. uni.getSystemInfo({
  86. success: (res) => {
  87. console.log(res)
  88. if (res.model == 'iPhone') {
  89. this.isIphone = true;
  90. }
  91. },
  92. fail: (err) => {
  93. console.log(err)
  94. }
  95. })
  96. },
  97. onReady() {
  98. if (this.isIphone) {
  99. document.getElementsByClassName('mainCont')[0].style.height = document.getElementsByClassName('mainCont')[
  100. 0].clientHeight - 25 + 'px'
  101. }
  102. },
  103. onShow() {
  104. let date = new Date;
  105. //获取年份
  106. let yy = date.getFullYear();
  107. //获取月份
  108. let mm = date.getMonth() + 1;
  109. //如果月份小于10 前面加0
  110. mm = (mm < 10 ? "0" + mm : mm);
  111. let dd = date.getDate();
  112. dd = (dd < 10 ? "0" + dd : dd);
  113. //返回日期
  114. this.time = `${yy}-${mm}-${dd}`
  115. this.tabList[0].name = '待处理(0)'
  116. this.tabList[1].name = '处理中(0)'
  117. this.tabList[2].name = '已完成(0)'
  118. this.getTabNum();
  119. this.getTableList();
  120. },
  121. methods: {
  122. goBack() {
  123. uni.navigateBack({
  124. delta: 1
  125. });
  126. },
  127. tabChange(index) {
  128. console.log(123123)
  129. this.current = index;
  130. this.onRefresh();
  131. },
  132. scroll(e) {
  133. if (e.detail.scrollTop === 0) {
  134. this.scroll_refresher_enabled = true
  135. } else {
  136. this.scroll_refresher_enabled = false
  137. }
  138. },
  139. clearSearch() {
  140. this.keyword = "";
  141. },
  142. getTabNum() {
  143. let postData = {
  144. endTime: this.time + ' 23:59:59',
  145. locations: this.keyword,
  146. pageIndex: this.pageIndex,
  147. pageSize: 10,
  148. startTime: this.time + ' 00:00:00',
  149. troubleState: this.current + 1,
  150. // userId: 0
  151. }
  152. NET.request(API.htroubleCount, postData, 'POST').then(res => {
  153. this.tabList[0].name = `待处理(${res.data.filter(a => a.key == 1)[0].count})`
  154. this.tabList[1].name = `处理中(${res.data.filter(a => a.key == 2)[0].count})`
  155. this.tabList[2].name = `已完成(${res.data.filter(a => a.key == 3)[0].count})`
  156. }).catch(error => {
  157. this.$refs.uToast.show({
  158. title: error.msg,
  159. type: 'warning',
  160. })
  161. })
  162. },
  163. getTableList() {
  164. if (this.loading || this.isOver) {
  165. return false;
  166. }
  167. this.loading = true;
  168. let postData = {
  169. endTime: this.time + ' 23:59:59',
  170. locations: this.keyword,
  171. pageIndex: this.pageIndex,
  172. pageSize: 10,
  173. startTime: this.time + ' 00:00:00',
  174. troubleState: this.current + 1,
  175. // userId: 0
  176. }
  177. NET.request(API.htroubleList, postData, 'POST').then(res => {
  178. this.triggered = false;
  179. this.loading = false;
  180. if (res.data.records.length < 10) {
  181. this.isOver = true
  182. }
  183. for (let i in res.data.records) {
  184. this.tableList.push(res.data.records[i])
  185. }
  186. }).catch(error => {
  187. this.$refs.uToast.show({
  188. title: error.msg,
  189. type: 'warning',
  190. })
  191. })
  192. },
  193. // 下拉刷新
  194. onRefresh() {
  195. this.triggered = true
  196. this.isOver = false
  197. this.pageIndex = 1
  198. this.tableList = []
  199. this.getTableList()
  200. this.getTabNum()
  201. },
  202. // 重置下拉刷新状态
  203. onRestore() {
  204. this.triggered = 'restore'
  205. this.triggered = false
  206. },
  207. //获取更多数据
  208. handleLoadMore() {
  209. if (this.isOver) {
  210. } else if (this.loading) {
  211. } else {
  212. this.pageIndex++;
  213. this.getTableList()
  214. }
  215. },
  216. fliterConfirm(val) {
  217. let time = `${val.year}-${val.month}-${val.day}`
  218. console.log(time)
  219. this.time = time
  220. this.onRefresh()
  221. },
  222. filterCancel(val) {
  223. console.log(val)
  224. },
  225. doCollect() {},
  226. goInfo(id) {
  227. uni.navigateTo({
  228. url: `/report/infor?id=${id}`
  229. });
  230. },
  231. }
  232. }
  233. </script>
  234. <style lang="scss">
  235. .search_bar {
  236. padding: 0 10px;
  237. height: 100rpx;
  238. background: #fff;
  239. line-height: 100rpx;
  240. }
  241. .mainCont {
  242. height: calc(100% - 80rpx - 80rpx - 100rpx);
  243. padding: 10px 0 10px 0;
  244. box-sizing: border-box;
  245. }
  246. .pcTop {
  247. width: calc(100% - 20px);
  248. padding: 0 10px;
  249. height: 20px;
  250. line-height: 20px;
  251. margin: 0 auto;
  252. margin-bottom: 10px;
  253. position: relative;
  254. &:after {
  255. content: '';
  256. position: absolute;
  257. height: 20px;
  258. top: 0;
  259. left: 0;
  260. width: 2px;
  261. background-color: #6aa0f7;
  262. }
  263. }
  264. .bottomButtons {
  265. box-shadow: 0px -5px 5px #d0cece;
  266. position: fixed;
  267. display: flex;
  268. justify-content: space-between;
  269. width: 100%;
  270. height: 40px;
  271. line-height: 40px;
  272. bottom: 0;
  273. left: 0;
  274. view {
  275. width: 50%;
  276. height: 40px;
  277. line-height: 40px;
  278. text-align: center;
  279. }
  280. }
  281. .filterCont {
  282. height: calc(100% - 80rpx);
  283. display: flex;
  284. justify-content: space-between;
  285. .left {
  286. height: 100%;
  287. overflow-y: auto;
  288. width: 35%;
  289. background-color: #fafafa;
  290. view {
  291. height: 40px;
  292. line-height: 40px;
  293. text-align: center;
  294. &.active {
  295. background-color: #fff;
  296. }
  297. }
  298. }
  299. .right {
  300. height: 100%;
  301. overflow-y: auto;
  302. width: 65%;
  303. view {
  304. width: calc(100% - 20px);
  305. margin: 0 auto;
  306. padding: 0 20px;
  307. height: 39px;
  308. line-height: 39px;
  309. border-bottom: 1px solid #f2f2f2;
  310. }
  311. }
  312. }
  313. /deep/ .uni-scroll-view-refresher {
  314. background-color: #f5f5f9 !important;
  315. }
  316. </style>