list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. <u-select v-model="queryStatusBl" :default-value="queryStatusValue" value-name="value"
  14. label-name="name" @confirm="selectQueryStatusConfirm" :list="statuslist"></u-select>
  15. <u-select v-model="queryTypeBl" :default-value="queryTypeValue" value-name="value"
  16. label-name="name" @confirm="selectQueryTypeConfirm" :list="typelist"></u-select>
  17. <view class="viewTop" >
  18. <view class="select" @click="queryStatusBl=true">
  19. <view class="selectSpan">
  20. {{queryStatus==''?'全部记录':queryStatusN}}
  21. </view>
  22. <u-icon name="arrow-down" size="32" color="#AAAAAA"></u-icon>
  23. </view>
  24. <view class="select" @click="queryTypeBl=true">
  25. <view class="selectSpan">
  26. {{queryType?queryTypeN:'全部站点'}}
  27. </view>
  28. <u-icon name="arrow-down" size="32" color="#AAAAAA"></u-icon>
  29. </view>
  30. <view class="select" @click="completionTimeShow=true">
  31. <view class="selectSpan">
  32. {{completionTimeN}}
  33. </view>
  34. <u-icon name="arrow-down" size="32" color="#AAAAAA"></u-icon>
  35. </view>
  36. </view>
  37. <view class="list" >
  38. <view class="item"
  39. v-for="(item,index) in list"
  40. @click="gotoTask(item)"
  41. :key="index">
  42. <view class="body">
  43. <view class="line1">
  44. <view class="title">
  45. {{item.stationNo}}<span style="margin: 0 8rpx;color:rgba(119, 119, 119, 1);" >|</span>{{item.stationName}}
  46. </view>
  47. <view class="status " :class="'status'+item.status">
  48. {{item.statusN}}
  49. </view>
  50. </view>
  51. <view class="line2" v-if="item.status==0" >
  52. <view class="value">
  53. 上次巡检 {{item.lastInspectionTime}}
  54. </view>
  55. <view class="value">
  56. 截止时间 {{item.inspectionEndTime}}
  57. </view>
  58. <view class="value" v-if="getdaysDistance(item.inspectionEndTime)=='-'"
  59. style="color:#777777 ;" >
  60. </view>
  61. <view class="value" v-else-if="getdaysDistance(item.inspectionEndTime)>0"
  62. style="color:#FF7B00 ;" >
  63. {{getdaysDistance(item.inspectionEndTime)}}天后到期
  64. </view>
  65. <view class="value" v-else-if="getdaysDistance(item.inspectionEndTime)==0" style="color: #EE3138 ;" >
  66. 即将到期(&le;1天)
  67. </view>
  68. <view class="value" v-else style="color: #EE3138 ;" >
  69. 已逾期
  70. </view>
  71. </view>
  72. <view class="line2" v-if="item.status==1" >
  73. <view class="value">
  74. 本次巡检 {{item.inspectionTime}}
  75. </view>
  76. <view class="value">
  77. 巡检人员 {{item.inspectionUserName}}
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <u-divider :isnone="list.length==0" nonetext="没有找到相关内容" border-color="#CFD2D5">已经到底了</u-divider>
  84. </view>
  85. </template>
  86. <script>
  87. import * as API from '@/apis/pagejs/pagesInspection.js'
  88. import {
  89. currentTimeStamp,
  90. parseUnixTime,newDate,nextMonth,daysDistanceTrue
  91. } from '@/apis/utils'
  92. export default {
  93. data() {
  94. return {
  95. queryName: "",
  96. testName: "",
  97. list:[],
  98. listForm:{
  99. pageIndex: 1,
  100. pageSize: 20,
  101. recordsTotal: 1,
  102. status:""
  103. },
  104. queryStatus: "",
  105. queryStatusN: "",
  106. queryStatusBl:false,
  107. queryStatusValue: [0],
  108. queryType: "",
  109. queryTypeN: "",
  110. queryTypeBl:false,
  111. queryTypeValue: [0],
  112. completionTime: "",
  113. completionTimeShow: false,
  114. lockId:"",
  115. lockName:"",
  116. current:0,
  117. tabslist:[
  118. {
  119. name: '未完成',
  120. status:0
  121. }, {
  122. name: '已完成',
  123. status:1
  124. }, {
  125. name: '全部',
  126. status:''
  127. }
  128. ],
  129. statuslist:[
  130. {
  131. name: '全部记录',
  132. value:""
  133. },
  134. {
  135. name: '未处理',
  136. value:"0"
  137. }, {
  138. name: '已处理',
  139. value:"1"
  140. }
  141. ],
  142. typelist:[
  143. {
  144. name: '全部记录',
  145. value:""
  146. },
  147. {
  148. name: '电单车',
  149. value:"0"
  150. }, {
  151. name: '电动车',
  152. value:"1"
  153. }
  154. ]
  155. };
  156. },
  157. onLoad(op) {
  158. if(op.status){
  159. if('geterrList0'==op.status){
  160. this.current=0
  161. this.listForm.status=0
  162. }
  163. if('geterrList1'==op.status){
  164. this.current=1
  165. this.listForm.status=1
  166. }
  167. }
  168. if(op.lockId){
  169. this.lockId=op.lockId
  170. this.lockName=op.lockName
  171. this.listForm.lockId=op.lockId;
  172. }
  173. this.completionTime = parseUnixTime(currentTimeStamp(),'{y}-{m}-1')
  174. this.getList()
  175. },
  176. computed:{
  177. completionTimeN(){
  178. return parseUnixTime(newDate(this.completionTime ),'{y}年{m}月')
  179. }
  180. },
  181. onReachBottom() {
  182. if (this.list.length < this.listForm.recordsTotal) {
  183. this.myLoadmore();
  184. }
  185. },
  186. methods: {
  187. getdaysDistance( time2) {
  188. if (!time2) {
  189. return '-'
  190. }
  191. console.log( daysDistanceTrue(new Date(),time2))
  192. return daysDistanceTrue(new Date(),time2)
  193. },
  194. testBtn() {
  195. this.queryName=this.testName
  196. this.listForm.queryContent=this.queryName
  197. this.getList(1)
  198. },
  199. completionTimeConfirm(e) {
  200. console.log(e)
  201. this.completionTime = e.year+"-"+e.month+"-1"
  202. this.getList(1)
  203. },
  204. gotoSelectLock(){
  205. uni.navigateTo({
  206. url: '/pages/task/selectStation?isAll=1',
  207. events: {
  208. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  209. acceptDataFromOpenerPage: (item)=>{
  210. console.log(item)
  211. this.lockName=item.item.name
  212. this.listForm.lockId=item.item.id
  213. this.getList(1)
  214. this.$forceUpdate()
  215. },
  216. }
  217. })
  218. },
  219. customBack(){
  220. if(this.lockId){
  221. uni.switchTab({
  222. url:"/pages/index/index"
  223. })
  224. }else{
  225. uni.navigateBack()
  226. }
  227. },
  228. gotoTask(k){
  229. if(k.status==0){
  230. uni.navigateTo({
  231. url: '/pages/inspection/add?back=1&stationId='+k.stationId,
  232. events: {
  233. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  234. acceptDataFromOpenerPage: (data)=>{
  235. console.log(data)
  236. this.getList(1)
  237. },
  238. }
  239. })
  240. }else{
  241. uni.navigateTo({
  242. url: '/pages/inspection/info?id='+k.id,
  243. })
  244. }
  245. },
  246. change(e){
  247. this.current=e
  248. this.listForm.pageIndex=1
  249. this.listForm.status=this.tabslist[e].status
  250. this.list =[]
  251. this.getList()
  252. },
  253. myLoadmore(){
  254. this.listForm.pageIndex += 1;
  255. this.getList()
  256. },
  257. selectQueryStatusConfirm(e) {
  258. this.queryStatusValue=[e[0].i]
  259. this.queryStatusN = e[0].label
  260. this.queryStatus = e[0].value
  261. this.listForm.status=this.queryStatus
  262. this.getList(1)
  263. },
  264. selectQueryTypeConfirm(e) {
  265. console.log(e)
  266. this.queryTypeValue=[e[0].i]
  267. this.queryTypeN = e[0].label
  268. this.queryType = e[0].value
  269. this.listForm.chargingType=this.queryType
  270. this.getList(1)
  271. },
  272. getList(bl) {
  273. if(bl){
  274. this.listForm.pageIndex = 1
  275. }
  276. uni.showLoading({
  277. title: "加载中",
  278. mask: true,
  279. })
  280. if(this.completionTime){
  281. this.listForm.startTime=this.completionTime
  282. var sz=this.completionTime.split('-')
  283. this.listForm.endTime=nextMonth(sz[0],sz[1],sz[2])
  284. }
  285. API.recordList(this.listForm).then((res) => {
  286. var list=this.list
  287. if (this.listForm.pageIndex == 1) {
  288. list = res.data.data;
  289. } else {
  290. list = [
  291. ...list,
  292. ...res.data.data
  293. ];
  294. }
  295. this.list = list
  296. this.listForm.recordsTotal=res.data.recordsTotal
  297. uni.hideLoading();
  298. }).catch(error => {
  299. uni.hideLoading();
  300. uni.showToast({
  301. title: error,
  302. icon: "none"
  303. })
  304. })
  305. },
  306. }
  307. }
  308. </script>
  309. <style lang="scss" scoped>
  310. .list {
  311. padding: 24rpx 24rpx;
  312. .item {
  313. border-radius: 16rpx;
  314. display: flex;
  315. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  316. background-color: rgba(255,255,255,1);
  317. // padding: 12rpx 0;
  318. margin-bottom: 12rpx ;
  319. .img {
  320. width: 72rpx;
  321. height: 72rpx;
  322. }
  323. .body {
  324. //margin: 0 12rpx;
  325. width: 100%;
  326. .line1,.line2,.line3{
  327. padding: 24rpx;
  328. }
  329. .line3{
  330. text-align: end;
  331. }
  332. .line2 {
  333. color: rgba(119,119,119,1);
  334. font-size: 24rpx;
  335. //margin-top: 8rpx;
  336. border-bottom:2rpx solid rgba(232,232,232,1);
  337. .value:not(:last-child) {
  338. margin-bottom: 16rpx;
  339. }
  340. }
  341. .line1 {
  342. display: flex;
  343. justify-content: space-between;
  344. border-bottom:2rpx solid rgba(232,232,232,1);
  345. .title {
  346. color: rgba(51, 51, 51, 1);
  347. font-size: 28rpx;
  348. font-weight: bold;
  349. }
  350. .status {
  351. background-color: rgba(255, 61, 0, 1);
  352. font-size: 24rpx;
  353. color:#fff;
  354. padding: 2rpx 8rpx;
  355. //border-radius: 8rpx;
  356. white-space: pre;
  357. height: 40rpx;
  358. }
  359. .status0 {
  360. background-color: #FF7B00;
  361. }
  362. .status1 {
  363. background-color: #007aff;
  364. }
  365. .status2 {
  366. background-color: #ff9900;
  367. }
  368. .status3 {
  369. background-color: #19be6b;
  370. }
  371. .status4 {
  372. border: 2rpx solid rgba(255, 61, 0, 1);
  373. color: rgba(255, 61, 0, 1);
  374. }
  375. }
  376. }
  377. }
  378. // .item:not(:last-child) {
  379. // border-bottom:2rpx solid rgba(232,232,232,1);
  380. // }
  381. }
  382. .viewTop{
  383. padding:16rpx 0 24rpx 0;
  384. border-bottom: 2rpx solid #e8e8e8;
  385. background-color: #fff;
  386. display: flex;
  387. justify-content: space-between;
  388. align-items: center;
  389. .select{
  390. padding: 0px 30rpx;
  391. font-size: 30rpx;
  392. display: flex;
  393. .selectSpan{
  394. text-align: end;
  395. //width: 200rpx;
  396. overflow: hidden;
  397. text-overflow: ellipsis;
  398. white-space: nowrap; /* 禁止换行,强制单行 */
  399. }
  400. }
  401. }
  402. .search {
  403. padding: 16rpx 32rpx;
  404. background: #fff;
  405. .searchBox {
  406. display: flex;
  407. align-items: center;
  408. background: #F2F2F2;
  409. padding: 2rpx 16rpx;
  410. border-radius: 16rpx;
  411. justify-content: space-between;
  412. }
  413. }
  414. .floating-button {
  415. z-index: 999;
  416. position: fixed;
  417. bottom: 0;
  418. width: 100%;
  419. display: flex;
  420. height: 120rpx;
  421. justify-content: center;
  422. background-color: rgba(255,255,255,1);
  423. .button{
  424. margin-top: 24rpx;
  425. border-radius: 50px;
  426. height: 80rpx;
  427. width: 80%;
  428. display: flex;
  429. align-items: center;
  430. justify-content: center;
  431. padding:12rpx;
  432. background-color: rgba(22,119,255,1);
  433. color: rgba(255,255,255,1);
  434. font-size: 36rpx;
  435. }
  436. }
  437. </style>