list.vue 9.2 KB

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