listTask.vue 13 KB

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