list.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view>
  3. <u-navbar title="巡检记录" title-color="#101010" :customBack="customBack" ></u-navbar>
  4. <view class="top">
  5. <view class="search">
  6. <view class="searchBox">
  7. <u-search shape="square" placeholder="使用停车场名称/地锁编号搜索" maxlength="12" v-model="testName" :show-action="false"
  8. :animation="true"></u-search>
  9. <u-button type="primary" size="mini" @click="testBtn">搜素</u-button>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="viewTop" >
  14. <u-tabs :list="tabslist"
  15. style=" width: 70%;"
  16. :current="current" @change="change"></u-tabs>
  17. <view class="select" @click="completionTimeShow=true">
  18. <view class="selectSpan">
  19. {{completionTimeN}}
  20. </view>
  21. <u-icon name="arrow-down" size="32" color="#AAAAAA"></u-icon>
  22. </view>
  23. </view>
  24. <view class="list" >
  25. <view class="item"
  26. v-for="(item,index) in list"
  27. @click="gotoTask(item)"
  28. :key="index">
  29. <view class="body">
  30. <view class="line1">
  31. <view class="title">
  32. {{item.stationName}}
  33. </view>
  34. <view class="status " :class="'status'+item.status">
  35. {{item.statusN}}
  36. </view>
  37. </view>
  38. <view class="line2">
  39. <view class="value">
  40. 上次巡检 {{item.lastInspectionTime}}
  41. </view>
  42. <view class="value">
  43. 截止时间 {{item.inspectionEndTime}}
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <u-divider :isnone="list.length==0" nonetext="没有找到相关内容" border-color="#CFD2D5">已经到底了</u-divider>
  50. </view>
  51. </template>
  52. <script>
  53. import * as API from '@/apis/pagejs/pagesInspection.js'
  54. import {
  55. currentTimeStamp,
  56. parseUnixTime,newDate,nextMonth
  57. } from '@/apis/utils'
  58. export default {
  59. data() {
  60. return {
  61. queryName: "",
  62. testName: "",
  63. list:[],
  64. listForm:{
  65. pageIndex: 1,
  66. pageSize: 20,
  67. recordsTotal: 1,
  68. status:0
  69. },
  70. completionTime: "",
  71. completionTimeShow: false,
  72. lockId:"",
  73. lockName:"",
  74. current:0,
  75. tabslist:[
  76. {
  77. name: '未完成',
  78. status:0
  79. }, {
  80. name: '已完成',
  81. status:1
  82. }, {
  83. name: '全部',
  84. status:''
  85. }
  86. ]
  87. };
  88. },
  89. onLoad(op) {
  90. if(op.status){
  91. if('geterrList0'==op.status){
  92. this.current=0
  93. this.listForm.status=0
  94. }
  95. if('geterrList1'==op.status){
  96. this.current=1
  97. this.listForm.status=1
  98. }
  99. }
  100. if(op.lockId){
  101. this.lockId=op.lockId
  102. this.lockName=op.lockName
  103. this.listForm.lockId=op.lockId;
  104. }
  105. this.completionTime = parseUnixTime(currentTimeStamp(),'{y}-{m}-1')
  106. this.getList()
  107. },
  108. computed:{
  109. completionTimeN(){
  110. return parseUnixTime(newDate(this.completionTime ),'{y}年{m}月')
  111. }
  112. },
  113. onReachBottom() {
  114. if (this.list.length < this.listForm.recordsTotal) {
  115. this.myLoadmore();
  116. }
  117. },
  118. methods: {
  119. testBtn() {
  120. this.queryName=this.testName
  121. this.listForm.queryContent=this.queryName
  122. this.getList(1)
  123. },
  124. completionTimeConfirm(e) {
  125. console.log(e)
  126. this.completionTime = e.year+"-"+e.month+"-1"
  127. this.getList(1)
  128. },
  129. gotoSelectLock(){
  130. uni.navigateTo({
  131. url: '/pages/task/selectStation?isAll=1',
  132. events: {
  133. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  134. acceptDataFromOpenerPage: (item)=>{
  135. console.log(item)
  136. this.lockName=item.item.name
  137. this.listForm.lockId=item.item.id
  138. this.getList(1)
  139. this.$forceUpdate()
  140. },
  141. }
  142. })
  143. },
  144. customBack(){
  145. if(this.lockId){
  146. uni.switchTab({
  147. url:"/pages/index/index"
  148. })
  149. }else{
  150. uni.navigateBack()
  151. }
  152. },
  153. gotoTask(k){
  154. if(k.status==0){
  155. uni.navigateTo({
  156. url: '/pages/inspection/add?stationId='+k.stationId,
  157. events: {
  158. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  159. acceptDataFromOpenerPage: (data)=>{
  160. console.log(data)
  161. this.getList(1)
  162. },
  163. }
  164. })
  165. }else{
  166. uni.navigateTo({
  167. url: '/pages/inspection/info?id='+k.id,
  168. })
  169. }
  170. },
  171. change(e){
  172. this.current=e
  173. this.listForm.pageIndex=1
  174. this.listForm.status=this.tabslist[e].status
  175. this.list =[]
  176. this.getList()
  177. },
  178. myLoadmore(){
  179. this.listForm.pageIndex += 1;
  180. this.getList()
  181. },
  182. getList(bl) {
  183. if(bl){
  184. this.listForm.pageIndex = 1
  185. }
  186. uni.showLoading({
  187. title: "加载中",
  188. mask: true,
  189. })
  190. if(this.completionTime){
  191. this.listForm.startTime=this.completionTime
  192. var sz=this.completionTime.split('-')
  193. this.listForm.endTime=nextMonth(sz[0],sz[1],sz[2])
  194. }
  195. API.recordList(this.listForm).then((res) => {
  196. var list=this.list
  197. if (this.listForm.pageIndex == 1) {
  198. list = res.data.data;
  199. } else {
  200. list = [
  201. ...list,
  202. ...res.data.data
  203. ];
  204. }
  205. this.list = res.data.data
  206. uni.hideLoading();
  207. }).catch(error => {
  208. uni.hideLoading();
  209. uni.showToast({
  210. title: error,
  211. icon: "none"
  212. })
  213. })
  214. },
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .list {
  220. padding: 24rpx 24rpx;
  221. .item {
  222. border-radius: 16rpx;
  223. display: flex;
  224. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  225. background-color: rgba(255,255,255,1);
  226. // padding: 12rpx 0;
  227. margin-bottom: 12rpx ;
  228. .img {
  229. width: 72rpx;
  230. height: 72rpx;
  231. }
  232. .body {
  233. //margin: 0 12rpx;
  234. width: 100%;
  235. .line1,.line2,.line3{
  236. padding: 24rpx;
  237. }
  238. .line3{
  239. text-align: end;
  240. }
  241. .line2 {
  242. color: rgba(119,119,119,1);
  243. font-size: 24rpx;
  244. //margin-top: 8rpx;
  245. border-bottom:2rpx solid rgba(232,232,232,1);
  246. .value:not(:last-child) {
  247. margin-bottom: 16rpx;
  248. }
  249. }
  250. .line1 {
  251. display: flex;
  252. justify-content: space-between;
  253. border-bottom:2rpx solid rgba(232,232,232,1);
  254. .title {
  255. color: rgba(51, 51, 51, 1);
  256. font-size: 28rpx;
  257. font-weight: bold;
  258. }
  259. .status {
  260. background-color: rgba(255, 61, 0, 1);
  261. font-size: 24rpx;
  262. color:#fff;
  263. padding: 2rpx 8rpx;
  264. //border-radius: 8rpx;
  265. }
  266. .status0 {
  267. background-color: #FF7B00;
  268. }
  269. .status1 {
  270. background-color: #007aff;
  271. }
  272. .status2 {
  273. background-color: #ff9900;
  274. }
  275. .status3 {
  276. background-color: #19be6b;
  277. }
  278. .status4 {
  279. border: 2rpx solid rgba(255, 61, 0, 1);
  280. color: rgba(255, 61, 0, 1);
  281. }
  282. }
  283. }
  284. }
  285. // .item:not(:last-child) {
  286. // border-bottom:2rpx solid rgba(232,232,232,1);
  287. // }
  288. }
  289. .viewTop{
  290. border-bottom: 2rpx solid #e8e8e8;
  291. background-color: #fff;
  292. display: flex;
  293. justify-content: space-between;
  294. align-items: center;
  295. .select{
  296. padding: 0px 30rpx;
  297. font-size: 30rpx;
  298. display: flex;
  299. .selectSpan{
  300. text-align: end;
  301. width: 200rpx;
  302. overflow: hidden;
  303. text-overflow: ellipsis;
  304. white-space: nowrap; /* 禁止换行,强制单行 */
  305. }
  306. }
  307. }
  308. .search {
  309. padding: 16rpx 32rpx;
  310. background: #fff;
  311. .searchBox {
  312. display: flex;
  313. align-items: center;
  314. background: #F2F2F2;
  315. padding: 2rpx 16rpx;
  316. border-radius: 16rpx;
  317. justify-content: space-between;
  318. }
  319. }
  320. .floating-button {
  321. z-index: 999;
  322. position: fixed;
  323. bottom: 0;
  324. width: 100%;
  325. display: flex;
  326. height: 120rpx;
  327. justify-content: center;
  328. background-color: rgba(255,255,255,1);
  329. .button{
  330. margin-top: 24rpx;
  331. border-radius: 50px;
  332. height: 80rpx;
  333. width: 80%;
  334. display: flex;
  335. align-items: center;
  336. justify-content: center;
  337. padding:12rpx;
  338. background-color: rgba(22,119,255,1);
  339. color: rgba(255,255,255,1);
  340. font-size: 36rpx;
  341. }
  342. }
  343. </style>