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