listTask.vue 13 KB

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