listTask.vue 11 KB

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