index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. <template>
  2. <view>
  3. <u-navbar v-show="false" title="首页" title-color="#101010"></u-navbar>
  4. <view class="back-blue">
  5. <view class="back-color">
  6. </view>
  7. </view>
  8. <view class="main_top">
  9. <view class="main_top1">
  10. <view class="logo_img">
  11. <image class="img" src="@/assets/img/logo/logo.png" mode=""></image>
  12. </view>
  13. <view class="logo_text">
  14. <view class="logo_text1">
  15. 优电联盟
  16. </view>
  17. <view class="logo_text2">
  18. 巡检端
  19. </view>
  20. </view>
  21. </view>
  22. <view class="main_top2">
  23. <!-- 消息提醒位置 -->
  24. </view>
  25. </view>
  26. <view class="main_navigation panel">
  27. <view class="item-na end" @click="gotoUrl('/pages/task/addTask')">
  28. <view class="na-img">
  29. <image class="img" src="@/assets/img/index/na-1.png" mode=""></image>
  30. </view>
  31. <view class="na-text ">
  32. 故障上报
  33. </view>
  34. </view>
  35. <view class="item-na-b" v-if="isAdmin">
  36. </view>
  37. <view class="item-na end" @click="gotoUrl('/pages/team/teamList')" v-if="isAdmin">
  38. <view class="na-img">
  39. <image class="img" src="@/assets/img/index/na-3.png" mode=""></image>
  40. </view>
  41. <view class="na-text">
  42. 团队管理
  43. </view>
  44. </view>
  45. <view class="item-na-b">
  46. </view>
  47. <view class="item-na end" @click="gotoUrl('/pages/inspection/list')">
  48. <view class="na-img">
  49. <image class="img" src="@/assets/img/index/na-2.png" mode=""></image>
  50. </view>
  51. <view class="na-text">
  52. 巡检记录
  53. </view>
  54. </view>
  55. </view>
  56. <view class="main_statuspanel panel">
  57. <view class="top-main">
  58. <view class="title-main">
  59. 充电枪状态
  60. </view>
  61. <view class="goto-main" @click="gotoUrl('/pages/station/stationList')">
  62. 查看详情
  63. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  64. </view>
  65. </view>
  66. <view class="body">
  67. <view class="pie">
  68. <view id="body1pie1" class="body1pie">
  69. </view>
  70. <view class="body2pie" v-if="datafloorStatus.gunNum">
  71. <view class="v1">{{datafloorStatus.gunNum}}</view>
  72. <view class="v2">单位:把</view>
  73. </view>
  74. </view>
  75. <view class="item-list">
  76. <view class="item-status">
  77. <view class="num">
  78. {{datafloorStatus.gunWorkNum}}
  79. </view>
  80. <view class="statusN">
  81. <view class="statusC status1">
  82. </view>
  83. <view class="statusT">
  84. 在用
  85. </view>
  86. </view>
  87. </view>
  88. <view class="item-status">
  89. <view class="num">
  90. {{datafloorStatus.gunFaultNum}}
  91. </view>
  92. <view class="statusN">
  93. <view class="statusC status2">
  94. </view>
  95. <view class="statusT">
  96. 故障
  97. </view>
  98. </view>
  99. </view>
  100. <view class="item-status">
  101. <view class="num">
  102. {{datafloorStatus.gunFreeNum}}
  103. </view>
  104. <view class="statusN">
  105. <view class="statusC status4">
  106. </view>
  107. <view class="statusT">
  108. 空闲
  109. </view>
  110. </view>
  111. </view>
  112. <view class="item-status">
  113. <view class="num">
  114. {{datafloorStatus.gunOfflineNum}}
  115. </view>
  116. <view class="statusN">
  117. <view class="statusC status3">
  118. </view>
  119. <view class="statusT">
  120. 离线
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <view class="main_list1 panel ">
  128. <view class="top-main">
  129. <view class="title-main">
  130. 故障未处理记录
  131. </view>
  132. <view class="goto-main" @click="gotoUrl('/pages/task/listTask')">
  133. 全部故障记录
  134. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  135. </view>
  136. </view>
  137. <view class="top-main">
  138. <u-tabs :list="tabslist" v-if="0" :current="current" @change="change"></u-tabs>
  139. </view>
  140. <view class="list">
  141. <view class="item" v-for="(item,index) in dataerrList"
  142. @click="gotoUrl('/pages/task/maintenanceTaks?id='+item.id)" :key="index">
  143. <view class="body">
  144. <view class="line1">
  145. <view class="title">
  146. {{item.stationName}}
  147. </view>
  148. <view class="value">
  149. {{item.errorCodeText}}
  150. </view>
  151. </view>
  152. <view class="line2">
  153. <view v-if="getHourDistanceArr(item.errorReportTime)==0" :class="{
  154. getHourDistanceArrNum10:true,
  155. }">
  156. </view>
  157. <view v-else :class="{
  158. getHourDistanceArrNum10:true,
  159. getHourDistanceArrNum12:getHourDistanceArr(item.errorReportTime)>12,
  160. getHourDistanceArrNum24:getHourDistanceArr(item.errorReportTime)>24,
  161. }">
  162. 超{{getHourDistanceArr(item.errorReportTime) }}小时未处理</view>
  163. <view class="value" style=" white-space: pre;">
  164. {{item.errorReportTime}}
  165. </view>
  166. </view>
  167. </view>
  168. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  169. </view>
  170. <u-divider color="#F44336" :isnone="dataerrRecordsTotal==0" nonetext="暂无数据"
  171. v-if="dataerrRecordsTotal==0"></u-divider>
  172. </view>
  173. </view>
  174. <view class="main_list1 panel ">
  175. <view class="top-main">
  176. <view class="title-main">
  177. 未巡检记录
  178. </view>
  179. <view class="goto-main" @click="gotoUrl('/pages/inspection/list')">
  180. 全部巡检记录
  181. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  182. </view>
  183. </view>
  184. <view class="top-main">
  185. <u-tabs :list="tabslist" v-if="0" :current="current" @change="change"></u-tabs>
  186. </view>
  187. <view class="list-body">
  188. <view class="item" v-for="(item,index) in datainsList"
  189. @click="gotoUrl('/pages/inspection/add?back=1&stationId='+item.stationId)" :key="index">
  190. <view class="line1">
  191. <view class="title">
  192. {{item.stationName}}
  193. </view>
  194. <view class="value">
  195. 上次巡检时间:{{lastChargeTime(item.lastInspectionTime)}}
  196. </view>
  197. </view>
  198. <view class="line2">
  199. <view v-if="getdaysDistance(item.lastInspectionTime,item.inspectionEndTime)=='-'"
  200. style="color:#777777 ;" >
  201. 未初始化
  202. </view>
  203. <view v-else-if="getdaysDistance(item.lastInspectionTime,item.inspectionEndTime)<5"
  204. style="color:#FF7B00 ;" >
  205. {{getdaysDistance(item.lastInspectionTime,item.inspectionEndTime)}}天后到期
  206. </view>
  207. <view v-else style="color: #EE3138 ;" >
  208. 已逾期
  209. </view>
  210. <u-icon name="arrow-right" size="24" color="#BBBBBB"></u-icon>
  211. </view>
  212. </view>
  213. <u-divider color="#F44336" :isnone="datainsRecordsTotal==0" nonetext="暂无数据"
  214. v-if="datainsRecordsTotal==0"></u-divider>
  215. </view>
  216. </view>
  217. <tabbar :current="0"></tabbar>
  218. </view>
  219. </template>
  220. <script>
  221. import * as API from '@/apis/pagejs/pagejsIndex.js'
  222. import * as echarts from 'echarts';
  223. import Tabbar from '@/components/Tabbar.vue'
  224. import {
  225. newDate,
  226. hourDistanceArr,
  227. daysDistance
  228. } from '@/apis/utils'
  229. export default {
  230. components: {
  231. Tabbar,
  232. },
  233. data() {
  234. return {
  235. echartsList: {},
  236. isReadyfloorStatus: false,
  237. datafloorStatus: {},
  238. roleList: [],
  239. isReadyerrList: false,
  240. isReadyinsList: false,
  241. dataerrList: [],
  242. dataerrRecordsTotal: 0,
  243. datainsList: [],
  244. datainsRecordsTotal: 0,
  245. tabslist: [{
  246. name: '电动车充电站',
  247. code: "geterrList0"
  248. }, {
  249. name: '电单车充电站',
  250. code: "geterrList1"
  251. }],
  252. current: 0,
  253. };
  254. },
  255. onLoad() {
  256. // this.roleList=
  257. },
  258. onShow() {
  259. // this.roleList=this.jphelp.getPersonInfoPlus().roleList
  260. if (this.isReadyfloorStatus) {
  261. this.getfloorStatus()
  262. }
  263. if (this.isReadyerrList) {
  264. this.geterrList()
  265. }
  266. if (this.isReadyinsList) {
  267. this.getinsList()
  268. }
  269. },
  270. computed: {
  271. isAdmin() {
  272. console.log(this.jphelp.getPersonInfo().role)
  273. if (this.jphelp.getPersonInfo().role == '1') {
  274. return true
  275. }
  276. return false
  277. }
  278. },
  279. onReady() {
  280. this.geterrList()
  281. this.getfloorStatus()
  282. this.getinsList()
  283. //this.getbody1pie1()
  284. this.query()
  285. },
  286. methods: {
  287. lastChargeTime(time) {
  288. if (time) {
  289. return time.split(" ")[0]
  290. } else {
  291. return ''
  292. }
  293. },
  294. getinsList() {
  295. var status = 0
  296. var code = this.tabslist[this.current].code
  297. if (code == "geterrList0") {
  298. status = 0
  299. }
  300. if (code == "geterrList1") {
  301. status = 1
  302. }
  303. API.recordList({
  304. pageIndex: 1,
  305. pageSize: 20,
  306. status: 0,
  307. }).then((response) => {
  308. this.datainsList = response.data.data
  309. this.datainsRecordsTotal = response.data.recordsTotal
  310. this.isReadyinsList = true
  311. }).catch(error => {
  312. uni.showToast({
  313. title: error,
  314. icon: "none"
  315. })
  316. })
  317. },
  318. getdaysDistance(time1, time2) {
  319. if (!time1) {
  320. return '-'
  321. }
  322. return daysDistance(time1, time2)
  323. },
  324. getHourDistanceArr(time) {
  325. if (!time) {
  326. return '-'
  327. }
  328. return hourDistanceArr(time, new Date())[0]
  329. },
  330. change(e) {
  331. this.current = e
  332. this.dataerrList = []
  333. this.geterrList()
  334. },
  335. isToday(dateStr) {
  336. if (!dateStr) {
  337. return false
  338. }
  339. // 将传入的日期字符串转换为Date对象
  340. const targetDate = newDate(dateStr);
  341. // 获取当前日期
  342. const today = new Date();
  343. // 比较年份、月份和日期是否相等
  344. return (
  345. targetDate.getFullYear() === today.getFullYear() &&
  346. targetDate.getMonth() === today.getMonth() &&
  347. targetDate.getDate() === today.getDate()
  348. );
  349. },
  350. query() {
  351. uni.showLoading({
  352. title: "加载中",
  353. mask: true,
  354. })
  355. API.findByOpenId({
  356. noerror: true,
  357. openId: this.jphelp.getOpenId(),
  358. }).then((response) => {
  359. uni.hideLoading();
  360. if (response.message) {
  361. uni.hideLoading();
  362. } else {
  363. this.loginset(response)
  364. }
  365. this.roleList = this.jphelp.getPersonInfoPlus().roleList
  366. }).catch(error => {
  367. uni.hideLoading();
  368. })
  369. },
  370. geterrList() {
  371. var status = 0
  372. var code = this.tabslist[this.current].code
  373. if (code == "geterrList0") {
  374. status = 0
  375. }
  376. if (code == "geterrList1") {
  377. status = 1
  378. }
  379. API.errList({
  380. pageIndex: 1,
  381. pageSize: 5,
  382. status: 0,
  383. }).then((response) => {
  384. this.dataerrList = response.data.data
  385. this.dataerrRecordsTotal = response.data.recordsTotal
  386. this.isReadyerrList = true
  387. }).catch(error => {
  388. uni.showToast({
  389. title: error,
  390. icon: "none"
  391. })
  392. })
  393. },
  394. getfloorStatus() {
  395. API.floorStatus().then((response) => {
  396. var obj = response.data;
  397. var sz = ['gunFaultNum', 'gunFreeNum', 'gunOfflineNum', 'gunWorkNum']
  398. var bl = false
  399. for (var i in sz) {
  400. if (obj[sz[i]] != this.datafloorStatus[sz[i]]) {
  401. bl = true
  402. this.datafloorStatus = obj
  403. }
  404. }
  405. this.isReadyfloorStatus = true
  406. if (bl) {
  407. this.getbody1pie1()
  408. }
  409. }).catch(error => {
  410. uni.showToast({
  411. title: error,
  412. icon: "none"
  413. })
  414. })
  415. },
  416. getbody1pie1() {
  417. var key = "body1pie1"
  418. var myChart = this.echartsList[key];
  419. if (!myChart) {
  420. myChart = echarts.init(document.getElementById(key), null, {
  421. width: uni.upx2px(88 * 2),
  422. height: uni.upx2px(88 * 2)
  423. })
  424. }
  425. myChart.clear()
  426. var option = {
  427. series: [{
  428. silent: true,
  429. type: 'pie',
  430. radius: ['80%', '100%'],
  431. label: {
  432. show: false,
  433. },
  434. data: [{
  435. value: this.datafloorStatus.gunWorkNum,
  436. itemStyle: {
  437. color: 'rgba(0, 185, 98, 1)'
  438. }
  439. },
  440. {
  441. value: this.datafloorStatus.gunFreeNum,
  442. itemStyle: {
  443. color: '#999999'
  444. }
  445. },
  446. {
  447. value: this.datafloorStatus.gunOfflineNum,
  448. itemStyle: {
  449. color: '#FF9600'
  450. }
  451. },
  452. {
  453. value: this.datafloorStatus.gunFaultNum,
  454. itemStyle: {
  455. color: '#FF3D00'
  456. }
  457. }
  458. ]
  459. }],
  460. grid: {
  461. top: 0,
  462. left: 0,
  463. right: 0,
  464. bottom: 0,
  465. containLabel: true
  466. },
  467. }
  468. myChart.setOption(option);
  469. console.log(option)
  470. this.echartsList[key] = myChart;
  471. }
  472. }
  473. }
  474. </script>
  475. <style>
  476. page {
  477. /* background-color: #FFFFFF; */
  478. }
  479. </style>
  480. <style lang="scss">
  481. .back-blue {
  482. height: 0px;
  483. .back-color {
  484. height: 656rpx;
  485. background: linear-gradient(180deg, rgba(22, 119, 255, 1) 53%, rgba(203, 234, 255, 0) 100%);
  486. }
  487. }
  488. .top-main {
  489. display: flex;
  490. align-items: center;
  491. justify-content: space-between;
  492. .title-main {
  493. color: rgba(51, 51, 51, 1);
  494. font-size: 32rpx;
  495. font-weight: bold;
  496. }
  497. .goto-main {
  498. color: rgba(131, 131, 131, 1);
  499. font-size: 24rpx;
  500. }
  501. }
  502. .panel,
  503. .main_top {
  504. margin: 0 32rpx;
  505. }
  506. .panel {
  507. border-radius: 16rpx;
  508. background-color: rgba(255, 255, 255, 1);
  509. box-shadow: 0px 8rpx 16rpx 0px rgba(22, 119, 255, 0.1);
  510. }
  511. .main_top {
  512. margin-top: 32rpx;
  513. display: flex;
  514. justify-content: space-between;
  515. .main_top1 {
  516. display: flex;
  517. align-items: center;
  518. .logo_img {
  519. .img {
  520. border-radius: 16rpx;
  521. width: 96rpx;
  522. height: 96rpx;
  523. }
  524. margin-right: 16rpx;
  525. }
  526. .logo_text {
  527. color: #fff;
  528. .logo_text1 {
  529. font-size: 40rpx;
  530. }
  531. .logo_text2 {
  532. font-size: 32rpx;
  533. }
  534. }
  535. }
  536. .main_top2 {}
  537. }
  538. .main_navigation {
  539. margin-top: 32rpx;
  540. display: flex;
  541. justify-content: space-around;
  542. align-items: center;
  543. padding: 24rpx 0 20rpx 0;
  544. .item-na-b {
  545. border-left: 2rpx solid rgba(187, 187, 187, 0.43);
  546. height: 70rpx;
  547. }
  548. .item-na {
  549. width: 32%;
  550. text-align: center;
  551. .na-img {
  552. display: flex;
  553. justify-content: center;
  554. .img {
  555. width: 80rpx;
  556. height: 80rpx;
  557. }
  558. }
  559. }
  560. }
  561. .main_statuspanel {
  562. margin-top: 24rpx;
  563. padding: 24rpx;
  564. padding-bottom: 0;
  565. .body2pie {
  566. position: relative;
  567. top: -140rpx;
  568. height: 0px;
  569. left: 0px;
  570. width: 176rpx;
  571. text-align: center;
  572. .v1 {
  573. color: rgba(16, 16, 16, 1);
  574. font-size: 48rpx;
  575. font-weight: bold;
  576. }
  577. .v2 {
  578. color: rgba(119, 119, 119, 1);
  579. font-size: 24rpx;
  580. }
  581. }
  582. .body {
  583. display: flex;
  584. padding: 24rpx;
  585. .item-list {
  586. margin-left: 48rpx;
  587. display: flex;
  588. width: 100%;
  589. flex-wrap: wrap;
  590. .item-status {
  591. width: 50%;
  592. .num {
  593. color: rgba(51, 51, 51, 1);
  594. font-size: 36rpx;
  595. font-weight: bold;
  596. }
  597. }
  598. .statusN {
  599. display: flex;
  600. align-items: center;
  601. .statusC {
  602. margin-right: 8rpx;
  603. width: 16rpx;
  604. height: 16rpx;
  605. background-color: rgba(153, 153, 153, 1);
  606. }
  607. .status1 {
  608. background-color: rgba(0, 185, 98, 1);
  609. }
  610. .status2 {
  611. background-color: #FF3D00;
  612. }
  613. .status3 {
  614. background-color: #FF9600;
  615. }
  616. .status4 {
  617. background-color: #999999;
  618. }
  619. }
  620. }
  621. }
  622. }
  623. .main_list1 {
  624. background-color: #fff;
  625. margin-top: 24rpx;
  626. padding: 24rpx;
  627. padding-bottom: 36rpx;
  628. .title {
  629. display: flex;
  630. color: rgba(51, 51, 51, 1);
  631. font-size: 32rpx;
  632. font-weight: bold;
  633. }
  634. .list-body {
  635. padding: 24rpx 0;
  636. .item {
  637. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  638. display: flex;
  639. justify-content: space-between;
  640. padding: 12rpx 0;
  641. margin: 12rpx 0;
  642. .line1 {
  643. .value {
  644. color: #777777;
  645. font-size: 24rpx;
  646. margin-top: 8rpx;
  647. }
  648. }
  649. .line2 {
  650. display: flex;
  651. align-items: center;
  652. font-size: 32rpx;
  653. white-space: pre;
  654. }
  655. }
  656. }
  657. .item:not(:first-child) {
  658. //background-color: red;
  659. border-top: 0rpx solid rgba(232, 232, 232, 1);
  660. }
  661. .list {
  662. //padding: 24rpx 0;
  663. .item {
  664. display: flex;
  665. border-top: 2rpx solid rgba(232, 232, 232, 1);
  666. padding: 12rpx 0;
  667. margin: 12rpx 0;
  668. .img {
  669. width: 72rpx;
  670. height: 72rpx;
  671. }
  672. .body {
  673. //margin: 0 12rpx;
  674. width: 100%;
  675. .line1,
  676. .line2 {
  677. display: flex;
  678. justify-content: space-between;
  679. }
  680. .line2 {
  681. color: rgba(119, 119, 119, 1);
  682. font-size: 24rpx;
  683. margin-top: 8rpx;
  684. }
  685. .line1 {
  686. font-size: 32rpx;
  687. .status {
  688. background-color: rgba(255, 61, 0, 1);
  689. font-size: 24rpx;
  690. color: #fff;
  691. padding: 2rpx 8rpx;
  692. //border-radius: 8rpx;
  693. }
  694. .status0 {
  695. background-color: #FF7B00;
  696. }
  697. .status1 {
  698. background-color: #007aff;
  699. }
  700. .status2 {
  701. background-color: #ff9900;
  702. }
  703. .status3 {
  704. background-color: #19be6b;
  705. }
  706. .status4 {
  707. border: 2rpx solid rgba(255, 61, 0, 1);
  708. color: rgba(255, 61, 0, 1);
  709. }
  710. }
  711. .errorDesc {
  712. margin: 8rpx 0;
  713. width: 480rpx;
  714. color: #777777;
  715. font-size: 24rpx;
  716. overflow: hidden;
  717. text-overflow: ellipsis;
  718. white-space: nowrap;
  719. /* 禁止换行,强制单行 */
  720. }
  721. }
  722. }
  723. // .item:not(:last-child) {
  724. // border-bottom:2rpx solid rgba(232,232,232,1);
  725. // }
  726. }
  727. }
  728. .getHourDistanceArrNum10 {
  729. color: #FF7B00;
  730. }
  731. .getHourDistanceArrNum12 {
  732. color: red;
  733. }
  734. .getHourDistanceArrNum24 {
  735. color: #8161FF;
  736. }
  737. </style>