index.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  1. <template>
  2. <view class="content">
  3. <!-- 第一排盒子开始 -->
  4. <view class="box-first">
  5. <view class="machineStatus">
  6. <SubTitle title="机器人状态" titleEng="ROBOT STATUS"></SubTitle>
  7. <view class="bottom">
  8. <view class="list">
  9. <view class="plcConnect">
  10. <PannelItem show="true" words="PLC通讯" :status="robotInfoVo.plcState ? '正常' : '异常'"
  11. :flag="robotInfoVo.plcState" />
  12. </view>
  13. <view class="plcModel">
  14. <PannelItem show="true" words="机器人模式" :status="PlcMode" :flag="robotInfoVo.exchangeMode" />
  15. </view>
  16. </view>
  17. <view class="status-only">
  18. <view class="circle">
  19. <image :src="PlcState[0]"></image>
  20. </view>
  21. <view class="descript">机器人状态</view>
  22. <view class="frame">
  23. <span :class="PlcState[1]">{{PlcState[2] || '—'}}</span>
  24. <view class="shinning"></view>
  25. </view>
  26. </view>
  27. <PannelItem show="true" words="急停状态" :status="robotInfoVo.emergencyMode == 1 ? '急停' : robotInfoVo.emergencyMode == 0 ?'未急停' :'—'"
  28. :flag="robotInfoVo.emergencyMode == 0" />
  29. <PannelItem show="true" words="暂停状态" :status="robotInfoVo.pause == 1 ? '暂停' : robotInfoVo.pause == 0?'未暂停':'—' " handle="true"
  30. @ExchangeMessage='ExchangeMessage' :flag="robotInfoVo.pause == 0" />
  31. </view>
  32. </view>
  33. <view class="machineStatus carInfo">
  34. <SubTitle title="车辆信息" titleEng="VEHICLE INFORMATION"></SubTitle>
  35. <view class="bottom">
  36. <view class="list">
  37. <view class="carLeft">
  38. <PannelTitle words="车牌号" :value="vehicleInfo.plate" Isblue="true" :circle="true"
  39. :flag="vehicleInfo.plateState" @ShowCarline="ShowCarline" />
  40. </view>
  41. <view class="carRight">
  42. <PannelTitle words="在线车辆" circle="false" :value="vehicleInfo.onlineNum" flag="true"
  43. @ShowCarline="ShowCarline" />
  44. </view>
  45. </view>
  46. <view class="list">
  47. <view class="carLeft">
  48. <PannelTitle words="车牌识别器" :value="vehicleInfo.plateComState ? '正常' : '异常'"
  49. :flag="vehicleInfo.plateComState" />
  50. </view>
  51. <view class="carRight">
  52. <PannelTitle words="车辆识别" :value="vehicleInfo.plateState == 1 ? '成功' : '未识别'"
  53. :flag="vehicleInfo.plateState" @handleStatusShow="handleStatusShow"/>
  54. </view>
  55. </view>
  56. <view class="list">
  57. <view class="carLeft">
  58. <PannelTitle words="车辆到位" :value="vehicleInfo.sensorState ? '已到位' : '未到位'"
  59. :flag="vehicleInfo.sensorState" />
  60. </view>
  61. <view class="carRight">
  62. <PannelTitle words="连接状态" :value="vehicleInfo.conState == 1 ? '已连接' : vehicleInfo.conState == 0 ?'未连接':'—'"
  63. :flag="vehicleInfo.conState == 1" />
  64. </view>
  65. </view>
  66. <view class="list">
  67. <view class="carLeft">
  68. <PannelTitle words="鉴权状态" :value="vehicleInfo.authState ? '已通过' : '未通过'"
  69. :flag="vehicleInfo.authState" />
  70. </view>
  71. <view class="carRight">
  72. <PannelTitle circle="false" words="解锁状态"
  73. :value="vehicleInfo.lockState==null ? '—': vehicleInfo.lockState?'已上锁' : '已解锁'"
  74. @ExchangeMessage="ExchangeMessage" :flag="vehicleInfo.lockState == 0" />
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 第一排盒子结束-->
  81. <!-- 选电模式开始 -->
  82. <view class="getModel">
  83. <view class="subtilte-only">
  84. <view class="title">
  85. <view class="icon"></view>
  86. <view class="name">选电模式</view>
  87. <view class="letter">POWER SELECTION MODE</view>
  88. <view class="handle-model">
  89. <view class="leftBtn" :class="[pamars.batChooseMode===0 ? 'active' : '']"
  90. @click="ChangeModel(0)">自动选电</view>
  91. <view class="leftBtn Rbtn" :class="[pamars.batChooseMode===1 ? 'active' : '']"
  92. @click="ChangeModel(1)">手动选电</view>
  93. </view>
  94. </view>
  95. </view>
  96. <view class="storeList">
  97. <scroll-view scroll-x="true" class="scroll_x">
  98. <view v-for="(item, index) in storeInfoList">
  99. <!-- 电池列表信息 -->
  100. <BatteryInfo :soc="item.soc"
  101. :chgState="item.chargerInfoVo.chgState" :chgEstimatedTime="item.chargerInfoVo.chgEstimatedTime"
  102. :key="index" :storeState="item.storeState" :storeCode="item.storeCode"
  103. :freezeState="item.freezeState" :comState="item.comState" :lineType="item.chargerInfoVo.linktype"
  104. :chargerComState="item.chargerInfoVo.comState" :BatterySelectAllArr="BatterySelectAllArr"
  105. :BatterySelected="BatterySelected" :IsSelect="BatteryIsSelectArr[index]" />
  106. <!-- 电池信息结束 -->
  107. </view>
  108. </scroll-view>
  109. </view>
  110. </view>
  111. <!-- 选电模式结束-->
  112. <!-- 底部开始 -->
  113. <view class="box-last">
  114. <view class="Exchange-done">
  115. <view class="subtilte-only">
  116. <view class="title">
  117. <view class="icon"></view>
  118. <view class="name">换电操作</view>
  119. <view class="letter">POWER EXCHANGE OPERATION</view>
  120. <view class="switch">
  121. <view class="uni-list-cell-db">{{powerChangeStatus?'开启中':'已关闭'}}</view>
  122. <switch color="#91FDB9" style="transform:scale(0.6)" @change="switchChange" :checked="powerChangeStatus" />
  123. </view>
  124. </view>
  125. </view>
  126. <view class="Exchange-bottom">
  127. <view class="Exchange-times">
  128. <view class="Progress-btn" :class='!powerChangeStatus?"isshowactive":""' @click="BeginChangePower">开始换电</view>
  129. <view class="Exchange-status" v-if="!TcInfoVoData.sourceCode && !TcInfoVoData.targetCode && !xfTargetCodeData.xfTargetCode">
  130. <view class="lock">
  131. <span>{{ forbidLockState ? '锁止已屏蔽' : '锁止已放开'}}</span>
  132. <span class="time">换电时长:<font>{{PlcChangerTime || '—'}}</font></span>
  133. </view>
  134. <view class="percent">
  135. <view class="percent-bar">
  136. <view class="bar">
  137. <view class="bar-green" :style="{ 'width': swapPercent + '%' }">
  138. <view class="bar-percent" :class="[swapPercent <15 ? 'bar-ten' : '']">
  139. {{ swapPercent }}%
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. <view class="count-step">
  145. <font>{{swapProcess.step || 0}}</font>/{{swapProcess.plcStep || 0}}
  146. </view>
  147. </view>
  148. <view class="lock">
  149. <span></span>
  150. <span class="time">机器人工作时长:<font>{{PlcWorkTime || '—'}}</font></span>
  151. </view>
  152. </view>
  153. <view class="Exchange-status" v-if="TcInfoVoData.sourceCode && TcInfoVoData.targetCode">
  154. <view class="Exchange-status-left">
  155. <view class="Exchange-status-left-box">
  156. <text class="text1">仓位</text><text
  157. class="text2">{{TcInfoVoData.sourceCode}}—>{{TcInfoVoData.targetCode}}号仓位</text>
  158. </view>
  159. <view class="Exchange-status-left-box">
  160. <text class="text1">电池状态</text><text
  161. class="text2">{{TcInfoVoData.chargerState?'充电中':'未充电'}}</text>
  162. </view>
  163. </view>
  164. <view class="Exchange-status-left">
  165. <view class="Exchange-status-left-box">
  166. <text class="text1">动作流程</text><text
  167. class="text2">{{TcInfoVoData.actionFlow || '-'}}</text>
  168. </view>
  169. <view class="Exchange-status-left-box">
  170. <text class="text1">工作时长</text><text class="text2">{{warehouse || '-'}}</text>
  171. </view>
  172. </view>
  173. </view>
  174. <view class="Exchange-status" v-if="xfTargetCodeData.xfTargetCode">
  175. <view class="Exchange-status-left">
  176. <view class="Exchange-status-left-box change-store">
  177. <text class="text1">仓位</text><text
  178. class="text2">{{xfTargetCodeData.xfTargetCode}}号仓位</text>
  179. </view>
  180. <view class="Exchange-status-left-box">
  181. <text class="text1">电池状态</text><text
  182. class="text2">{{xfTargetCodeData.chargerState?'充电中':'未充电'}}</text>
  183. </view>
  184. </view>
  185. <view class="Exchange-status-left">
  186. <view class="Exchange-status-left-box">
  187. <text class="text1">动作流程</text><text
  188. class="text2">{{xfTargetCodeData.actionFlow || '-'}}</text>
  189. </view>
  190. <view class="Exchange-status-left-box">
  191. <text class="text1">工作时长</text><text class="text2">{{changeWareHouse || '-'}}</text>
  192. </view>
  193. </view>
  194. </view>
  195. </view>
  196. <view class="Exchange-handle">
  197. <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleIsLock(1)">锁止屏蔽</view>
  198. <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleChangeStore">调仓</view>
  199. <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="PausePLC(1)">急停</view>
  200. <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleFireStore">消防换仓</view>
  201. <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleIsLock(0)">锁止放开</view>
  202. <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="PausePLC(6)">中止</view>
  203. </view>
  204. </view>
  205. </view>
  206. <view class="Exchange-log">
  207. <view class="subtilte-only">
  208. <view class="title">
  209. <view class="icon"></view>
  210. <view class="name">换电日志</view>
  211. <view class="letter">POWER EXCHANGE OPERATION</view>
  212. <!-- <view class="log-descript">支持手动急停充电机,倒计时1分钟</view> -->
  213. </view>
  214. </view>
  215. <view class="log_bottom">
  216. <scroll-view scroll-y="true" class="scroll_x">
  217. <view class="log-list" v-for="item in logList" :key="item.id">
  218. <view class="log-times" :class="[item.remark=='error'?'logRed':'']">{{item.createTime}}</view>
  219. <view class="log-info" :class="[item.remark=='error'?'logRed':'']">{{item.content}}</view>
  220. </view>
  221. </scroll-view>
  222. </view>
  223. </view>
  224. </view>
  225. <!-- 底部结束 -->
  226. <!-- 顶部公共提示信息 -->
  227. <uni-popup ref="Exchangepopup" type="message">
  228. <uni-popup-message :type="popupType" :message="popupMessage" :duration="2000"></uni-popup-message>
  229. </uni-popup>
  230. <uni-popup ref="popup" :mask-click="false">
  231. <view class="popup-container">
  232. <view class="popup-title">
  233. <view class="title-text">
  234. 车辆识别设备网络
  235. </view>
  236. <view class="title-close" @click="closePopup">
  237. 关闭
  238. </view>
  239. </view>
  240. <view class="popup-content">
  241. <PannelTitle words="车牌识别器" :value="vehicleInfo.plateComState == 1 ? '已连接' : '未连接'" :flag="vehicleInfo.plateComState"/>
  242. </view>
  243. <view class="popup-content">
  244. <PannelTitle words="FRID识别器" :value="vehicleInfo.rfidConnState ? '已连接' : '未连接'" :flag="vehicleInfo.rfidConnState"/>
  245. </view>
  246. </view>
  247. </uni-popup>
  248. <!-- 顶部提示信息结束-->
  249. <!--在线、编辑车辆抽屉 -->
  250. <uni-drawer ref="carlineDrawer" mode="right" :width="400" :mask-click="true">
  251. <scroll-view style="height: 100%;" scroll-y="true">
  252. <PublicDrawer :flag="isDrawer" title="在线车辆" @closeDrawer="closeDrawer" v-if="isDrawer">
  253. <view class="carPosition">
  254. <view class="CarnoData" v-if="CarlineList.length==0"></view>
  255. <view class="Carlist" v-for="item in CarlineList" :key="item.id">
  256. <view class="carDetail">
  257. <view class="plateNumber">
  258. <view class="icon">
  259. <image src="/static/change/car.png"></image>
  260. </view>
  261. <view class="pNumber">{{item.vehiclePlate}}</view>
  262. </view>
  263. <view class="vinMa">
  264. <view>VIN码</view>
  265. <view>{{item.vehicleVin}}</view>
  266. </view>
  267. <view class="vinMa">
  268. <view>熄火状态</view>
  269. <view>{{item.keyState}}</view>
  270. </view>
  271. <view class="vinMa">
  272. <view>解锁状态</view>
  273. <view>{{item.lockState?'已上锁':'已解锁'}}</view>
  274. </view>
  275. </view>
  276. </view>
  277. </view>
  278. </PublicDrawer>
  279. <PublicDrawer :flag="isDrawer" title="编辑车牌" @HandleEditPlate="HandleEditPlate"
  280. :plate="vehicleInfo.plate" @closeDrawer="closeDrawer" v-if="!isDrawer">
  281. <view class="carPosition">
  282. <view class="carForm">
  283. <view>编辑车牌号:</view>
  284. <input class="uni-input" type="text" v-model="plate" placeholder="请输入车牌号" />
  285. </view>
  286. </view>
  287. </PublicDrawer>
  288. </scroll-view>
  289. </uni-drawer>
  290. <!-- 在线、编辑车辆抽屉结束-->
  291. </view>
  292. </template>
  293. <script>
  294. export default {
  295. data() {
  296. return {
  297. popupMessage: '成功消息',
  298. popupType: 'success',
  299. robotInfoVo: {}, //机器人状态对象
  300. vehicleInfo: {}, //车辆信息对象
  301. batteryInfo: {}, //电池信息对象
  302. swapProcess: {}, //换电进度对象
  303. storeInfoList: [], //电池仓列表数组
  304. logList: [], //日志列表
  305. BatteryIsSelectArr: [false, false, false, false, false, false, false, false], //存储电池的选中状态
  306. BatteryFullStatus: true, //切换满电、亏点电池状态
  307. BatterySelectAllArr: [], //存储所有选中的电池仓位号
  308. CarlineList: [], //在线车辆列表
  309. pamars: {
  310. batChooseMode: 0,
  311. batChosenIndex: 0,
  312. startMode: 0,
  313. userId: 1,
  314. userName: 'admin'
  315. }, //开始换电参数
  316. ws: null, //ws连接对象
  317. timer: null, //ws连接
  318. isDrawer: true, //切换抽屉显示内容
  319. plate: '—', //弹窗车牌号
  320. powerChangeStatus: false,
  321. isSelectstoreState: [], //选择的仓位存储电池状态
  322. TcInfoVoData: {}, //调仓信息对象
  323. xfTargetCodeData: {}, //消防换仓对象
  324. heartbeatTimer:null,
  325. onMessageTime:null,
  326. TcNumber:0,//调仓计数器 大于5时显示换电页面
  327. XfNumber:0,//消防调仓计数器 大于5时显示换电页面
  328. forbidLockState:true,//锁止状态
  329. }
  330. },
  331. mounted() {
  332. this.onMessageTime = new Date();
  333. this.InitWs()
  334. this.heartbeatTimer = setInterval(()=>{
  335. let newDate = new Date();
  336. if(newDate-this.onMessageTime>3000){
  337. if(this.ws!=null){
  338. this.ws.close()
  339. this.ws=null
  340. }
  341. }
  342. },3000)
  343. },
  344. destroyed(){
  345. clearInterval(this.timer)
  346. this.ws.close()
  347. },
  348. onUnload() {
  349. if(this.timer!=null){
  350. clearInterval(this.timer)
  351. this.timer = null
  352. }
  353. if(this.ws!=null){
  354. this.ws.close()
  355. this.ws=null
  356. }
  357. if(this.heartbeatTimer!=null){
  358. this.heartbeatTimer.close()
  359. this.heartbeatTimer=null
  360. }
  361. },
  362. computed: {
  363. //换电时长
  364. PlcChangerTime() {
  365. if (this.swapProcess.swapStartTime) {
  366. let end_time = this.$moment()
  367. let seconds = end_time.diff(this.swapProcess.swapStartTime, "seconds")
  368. return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
  369. }
  370. },
  371. //机器人工作时长
  372. PlcWorkTime() {
  373. if (this.swapProcess.plcStartTime) {
  374. let end_time = this.$moment()
  375. let seconds = end_time.diff(this.swapProcess.plcStartTime, "seconds")
  376. return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
  377. }
  378. },
  379. //调仓工作时长
  380. warehouse() {
  381. if (this.TcInfoVoData.startTime) {
  382. let end_time = this.$moment()
  383. let seconds = end_time.diff(this.TcInfoVoData.startTime, "seconds")
  384. return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
  385. }
  386. },
  387. //消防换仓工作时长
  388. changeWareHouse() {
  389. if (this.xfTargetCodeData.startTime) {
  390. let end_time = this.$moment()
  391. let seconds = end_time.diff(this.xfTargetCodeData.startTime, "seconds")
  392. return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
  393. }
  394. },
  395. //换电百分比
  396. swapPercent() {
  397. if (this.swapProcess.plcPercentage) {
  398. return this.swapProcess.plcPercentage
  399. } else {
  400. return 0
  401. }
  402. },
  403. //换电解锁状态
  404. swapIsLock() {
  405. switch (this.swapProcess.lockState) {
  406. case true:
  407. return '已上锁'
  408. case false:
  409. return '已解锁'
  410. default:
  411. return '—'
  412. }
  413. },
  414. //机器人状态
  415. PlcState() {
  416. switch (this.robotInfoVo.robotState) {
  417. case 1:
  418. return ['/static/change/green.png', '', '就绪']
  419. case 2:
  420. return ['/static/change/blue.png', 'isblue', '运行']
  421. case 3:
  422. return ['/static/change/yellow.png', 'isflag', '完成']
  423. case 4:
  424. return ['/static/change/yellow.png', 'isflag', '故障']
  425. case 5:
  426. return ['/static/change/yellow.png', 'isflag', '中止']
  427. default:
  428. return ['/static/change/yellow.png', 'isflag', '未就绪']
  429. }
  430. },
  431. //机器人模式
  432. PlcMode() {
  433. switch (this.robotInfoVo.exchangeMode) {
  434. case 0:
  435. return '无效';
  436. case 1:
  437. return '手动模式';
  438. case 2:
  439. return '自动模式';
  440. case 3:
  441. return '单步模式';
  442. }
  443. },
  444. },
  445. methods: {
  446. handleStatusShow() {
  447. this.$refs.popup.open('center');
  448. },
  449. closePopup() {
  450. this.$refs.popup.close();
  451. },
  452. //修改车牌号提交
  453. HandleEditPlate(plate) {
  454. let that = this
  455. if (this.$checks.validateLicensePlateNumber(this.plate)) {
  456. this.$http.EditPlate(this.plate)
  457. .then(res => {
  458. if (res.code === 0) {
  459. that.ExchangeMessage('success', '修改成功!')
  460. that.closeDrawer()
  461. } else {
  462. that.ExchangeMessage('error', '修改失败!')
  463. }
  464. }).catch(err => {
  465. console.error(err)
  466. })
  467. } else {
  468. that.ExchangeMessage('warn', '请填写新能源车牌号!')
  469. }
  470. },
  471. closeDrawer() {
  472. this.$refs.carlineDrawer.close();
  473. },
  474. //顶部公共消息提示
  475. ExchangeMessage(type, message) {
  476. this.popupType = type
  477. this.popupMessage = message ? message : '后端接口404错误!'
  478. this.$refs.Exchangepopup.open()
  479. },
  480. //切换换电模式(0自动、1手动)
  481. ChangeModel(id) {
  482. let that = this
  483. let modelText = id === 1 ? '手动' : '自动'
  484. uni.showModal({
  485. title: `请确认选电模式切换为${modelText}?`,
  486. content: '',
  487. success: function(res) {
  488. if (res.confirm) {
  489. that.$http.setMode(id + '').then(res => {
  490. if (res.code === 0) {
  491. that.pamars.batChooseMode = id === 1 ? 1 : 0
  492. }
  493. that.ExchangeMessage(res.code === 0 ? 'success' : 'error',
  494. res.code === 0 ? '选电模式切换成功!' : '选电模式切换失败!')
  495. })
  496. } else if (res.cancel) {
  497. return false
  498. //用户点击取消按钮触发
  499. }
  500. }
  501. })
  502. },
  503. //开始换电
  504. BeginChangePower() {
  505. if (this.powerChangeStatus) {
  506. if (this.pamars.batChooseMode === 1) {
  507. //手动模式下传仓位号参数
  508. if (this.BatterySelectAllArr.length !== 1 || this.BatterySelectAllArr[0].storeState !== 1) {
  509. this.ExchangeMessage('warn', '请手动选择一个电池进行换电!')
  510. return
  511. } else {
  512. this.pamars.batChosenIndex = this.BatterySelectAllArr[0].storeCode
  513. }
  514. } else {
  515. this.pamars.batChosenIndex = 0
  516. if (this.BatterySelectAllArr.length !== 0) {
  517. this.ExchangeMessage('warn', '自动换电不用选择电池,请取消选中的电池!')
  518. return
  519. }
  520. }
  521. const pamars = this.pamars
  522. let that = this
  523. uni.showModal({
  524. title: '请确认站控发起换电?',
  525. content: '',
  526. success: function(res) {
  527. if (res.confirm) {
  528. // that.ExchangeMessage('success', '换电指令已下发,请等待!')
  529. that.$http.beginSwap(pamars)
  530. .then(res => {
  531. that.clearStore()
  532. that.ExchangeMessage(res.code === 0 ? 'success' : 'error',
  533. res.code === 0 ? '发起换电成功!' : res.msg)
  534. })
  535. .catch(err => {
  536. console.error(err)
  537. })
  538. } else if (res.cancel) {
  539. return false
  540. //用户点击取消按钮触发
  541. }
  542. }
  543. })
  544. } else {
  545. this.PowerChangeStatusTips()
  546. }
  547. },
  548. //switch开关
  549. switchChange(e) {
  550. this.powerChangeStatus = e.detail.value
  551. },
  552. //实时车辆弹窗
  553. ShowCarline(pamars) {
  554. this.$refs.carlineDrawer.open();
  555. if (pamars == 'line') {
  556. this.getCarOnline()
  557. this.isDrawer = true
  558. } else {
  559. this.isDrawer = false
  560. this.plate = pamars
  561. }
  562. },
  563. //已连接站控车辆列表
  564. getCarOnline() {
  565. this.$http.CarOnline().then(res => {
  566. this.CarlineList = res.data; //[{vehicleVin:123,keyState:2,vehiclePlate:"渝AFB3182"}]
  567. this.CarlineList.forEach(item => {
  568. if (item.keyState == 0) {
  569. item.keyState = '熄火'
  570. } else if (item.keyState == 1) {
  571. item.keyState = '未点火'
  572. } else if (item.keyState == 2) {
  573. item.keyState = '启动'
  574. } else {
  575. item.keyState = '-'
  576. }
  577. })
  578. })
  579. },
  580. //切换满电、亏电电池信息
  581. ChangeBattery(id) {
  582. this.BatteryFullStatus = id === 1 ? true : false
  583. },
  584. //锁止屏蔽、放开
  585. HandleIsLock(islock) {
  586. if (this.powerChangeStatus) {
  587. let that = this
  588. let lockTest = islock ? '锁止屏蔽' : '锁止放开'
  589. uni.showModal({
  590. title: `请确认${lockTest}`,
  591. content: '',
  592. success: function(res) {
  593. if (res.confirm) {
  594. that.$http.EditforbidLock(islock + '')
  595. .then(res => {
  596. if (res.code === 0) {
  597. that.ExchangeMessage('success', islock ? '屏蔽成功' : '放开成功')
  598. } else {
  599. that.ExchangeMessage('error', islock ? '屏蔽失败' : '放开失败')
  600. }
  601. }).catch(err => {
  602. console.error(err)
  603. })
  604. } else if (res.cancel) {
  605. return false
  606. //用户点击取消按钮触发
  607. }
  608. }
  609. })
  610. } else {
  611. this.PowerChangeStatusTips()
  612. }
  613. },
  614. //急停、中止
  615. PausePLC(isStop) {
  616. if (this.powerChangeStatus) {
  617. let that = this
  618. const text = isStop == 1 ? '急停机器人' : '中止机器人'
  619. uni.showModal({
  620. title: `请确认${text}?`,
  621. content: '',
  622. success: function(res) {
  623. if (res.confirm) {
  624. that.$http.plcStop(isStop + '')
  625. .then(res => {
  626. if (res.code === 0) {
  627. that.ExchangeMessage('success', isStop == 1 ? '急停指令下发成功' : '中止指令下发成功')
  628. } else {
  629. that.ExchangeMessage('error', isStop == 1 ? '急停指令下发失败' : '中止指令下发失败')
  630. }
  631. }).catch(err => {
  632. console.error(err)
  633. })
  634. } else if (res.cancel) {
  635. return false
  636. //用户点击取消按钮触发
  637. }
  638. }
  639. })
  640. } else {
  641. this.PowerChangeStatusTips()
  642. }
  643. },
  644. //选择电池仓位数
  645. BatterySelected(CurrentStore) {
  646. this.$set(this.BatteryIsSelectArr, CurrentStore.storeCode - 1, !this.BatteryIsSelectArr[CurrentStore
  647. .storeCode - 1]) //选中电池取反
  648. if (this.BatteryIsSelectArr[CurrentStore.storeCode - 1]) {
  649. this.BatterySelectAllArr = [...this.BatterySelectAllArr, CurrentStore] //将选中的电池放入数组中
  650. } else {
  651. this.BatterySelectAllArr = this.BatterySelectAllArr.filter(item => item.storeCode != CurrentStore
  652. .storeCode) //将取消选中的电池从数组中移除
  653. }
  654. if (this.BatterySelectAllArr.length === 3) {
  655. this.$set(this.BatteryIsSelectArr, this.BatterySelectAllArr[0].storeCode - 1, false)
  656. this.BatterySelectAllArr.shift() //删除第一个元素
  657. }
  658. // console.log(this.BatterySelectAllArr)
  659. },
  660. //开始调仓
  661. HandleChangeStore() {
  662. let that = this
  663. if (this.powerChangeStatus) {
  664. let source = 0
  665. let target = 0
  666. if (this.BatterySelectAllArr.length === 2) {
  667. source = this.BatterySelectAllArr[0].storeState ? 1 : 0
  668. target = this.BatterySelectAllArr[1].storeState ? 1 : 0
  669. }
  670. if (this.BatterySelectAllArr.length !== 2 || source == target) {
  671. that.ExchangeMessage('warn', '请选择一个电池和一个空仓位!')
  672. return
  673. } else if (this.BatterySelectAllArr[0].getChgState == 2 || this.BatterySelectAllArr[1].getChgState ==
  674. 2) {
  675. that.ExchangeMessage('warn',
  676. `【${this.BatterySelectAllArr[0].storeState===1?this.BatterySelectAllArr[0].storeCode:this.BatterySelectAllArr[1].storeCode}】号仓位电池未断电,请断电后在进行调仓!`
  677. )
  678. } else {
  679. const params = {
  680. sourceCode: this.BatterySelectAllArr[0].storeState === 1 ? this.BatterySelectAllArr[0]
  681. .storeCode : this.BatterySelectAllArr[1].storeCode, //选有电池的仓位号
  682. targetCode: this.BatterySelectAllArr[1].storeState !== 1 ? this.BatterySelectAllArr[1]
  683. .storeCode : this.BatterySelectAllArr[0].storeCode //选空仓的仓位号
  684. }
  685. uni.showModal({
  686. title: '',
  687. content: `请确认将【${params.sourceCode}】号仓位电池移至【${params.targetCode}号】仓位?`,
  688. success: function(res) {
  689. if (res.confirm) {
  690. // that.ExchangeMessage('success', '调仓指令已下发,请等待!')
  691. that.$http.RuleChangestorage(params)
  692. .then(res => {
  693. if (res.code === 0) {
  694. that.clearStore()
  695. }
  696. that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res
  697. .code === 0 ? '调仓指令下发成功!' : '调仓指令下发失败!')
  698. }).catch(err => {
  699. console.error(err)
  700. })
  701. } else if (res.cancel) {
  702. return false
  703. //用户点击取消按钮触发
  704. }
  705. }
  706. })
  707. }
  708. } else {
  709. this.PowerChangeStatusTips()
  710. }
  711. },
  712. //消防换仓
  713. HandleFireStore() {
  714. let that = this
  715. if (this.powerChangeStatus) {
  716. if (this.BatterySelectAllArr.length !== 1 || this.BatterySelectAllArr[0].storeState !== 1) {
  717. this.ExchangeMessage('warn', '请选择一个电池操作消防换仓!')
  718. } else if (this.BatterySelectAllArr[0].getChgState == 2) {
  719. that.ExchangeMessage('warn', `【${this.BatterySelectAllArr[0].storeCode}】号仓位电池未断电,请断电后在进行消防换仓!`)
  720. } else {
  721. const params = {
  722. targetCode: this.BatterySelectAllArr[0].storeCode
  723. }
  724. uni.showModal({
  725. title: '',
  726. content: `请确认消防换仓,将【${that.BatterySelectAllArr[0].storeCode}】号仓位电池移至消防仓?`,
  727. success: function(res) {
  728. if (res.confirm) {
  729. // that.ExchangeMessage('success', '消防换仓指令已下发,请等待!')
  730. that.$http.FireChangestorage(params)
  731. .then(res => {
  732. if (res.code === 0) {
  733. that.clearStore()
  734. }
  735. that.ExchangeMessage(res.code === 0 ? 'success' : 'error',
  736. res.code === 0 ? '消防换仓指令下发成功!' : '消防换仓指令下发失败!')
  737. }).catch(err => {
  738. console.error(err)
  739. })
  740. } else if (res.cancel) {
  741. return false
  742. //用户点击取消按钮触发
  743. }
  744. }
  745. })
  746. }
  747. } else {
  748. this.PowerChangeStatusTips()
  749. }
  750. },
  751. //换电操作开关提示公用方法
  752. PowerChangeStatusTips() {
  753. this.ExchangeMessage('warn', '请先开启换电操作!')
  754. },
  755. //清空选择的仓位
  756. clearStore() {
  757. this.BatterySelectAllArr = []
  758. this.BatteryIsSelectArr = [false, false, false, false, false, false, false, false]
  759. },
  760. //websocket连接函数
  761. InitWs() {
  762. uni.showLoading({
  763. title:'数据加载中...'
  764. })
  765. if (this.ws != null) {
  766. this.ws.close()
  767. this.ws = null
  768. }
  769. if (this.timer != null) {
  770. clearInterval(this.timer)
  771. this.timer = null
  772. }
  773. let token = this.$storage.getJson('token');
  774. if (token == null) {
  775. uni.navigateTo({
  776. url: '/pages/login/index'
  777. })
  778. return false;
  779. }
  780. this.ws = uni.connectSocket({
  781. url: this.$config.web_socket_url + token,
  782. header: {
  783. 'content-type': 'application/json'
  784. },
  785. complete: () => {}
  786. })
  787. this.ws.onOpen(() => {
  788. console.log('socket连接成功')
  789. let msg = {
  790. type: "page",
  791. payload: "power-change-monitoring"
  792. }
  793. this.ws.send({
  794. data: JSON.stringify(msg)
  795. })
  796. })
  797. this.ws.onMessage((res) => {
  798. this.onMessageTime = new Date();
  799. let d = JSON.parse(res.data)
  800. // console.log(d)
  801. // uni.hideLoading()
  802. //电池仓位列表
  803. if (d.storeInfoList) {
  804. this.storeInfoList = d.storeInfoList
  805. uni.hideLoading()
  806. }
  807. //日志列表
  808. if (d.logList) {
  809. this.logList = d.logList.reverse()
  810. }
  811. // 车辆信息
  812. if (d.vehicleInfo) {
  813. this.vehicleInfo = d.vehicleInfo
  814. }
  815. // 电池信息
  816. if (d.batteryInfo) {
  817. this.batteryInfo = d.batteryInfo
  818. }
  819. //机器人状态
  820. if (d.robotInfoVo) {
  821. this.robotInfoVo = d.robotInfoVo
  822. }
  823. //换电进度
  824. if (d.swapProcess) {
  825. this.swapProcess = d.swapProcess
  826. //清空调仓数据
  827. if(d.swapProcess.swapId){
  828. this.xfTargetCodeData={}//消防调仓
  829. this.TcInfoVoData={}//调仓
  830. }
  831. }
  832. //选电模式
  833. if (d.batChooseMode >= 0) {
  834. this.pamars.batChooseMode = d.batChooseMode
  835. //锁止状态
  836. }
  837. if(d.hasOwnProperty('forbidLockState')){
  838. this.forbidLockState=d.forbidLockState
  839. }
  840. //调仓
  841. if (d.sourceCode && d.targetCode) {
  842. this.TcInfoVoData = {
  843. sourceCode: d.sourceCode,
  844. targetCode: d.targetCode,
  845. actionFlow: d.actionFlow,
  846. startTime: d.startTime,
  847. chargerState: d.chargerState,
  848. }
  849. this.xfTargetCodeData={}
  850. this.TcNumber=0
  851. }else{
  852. if(this.TcNumber<=5){
  853. this.TcNumber=this.TcNumber+1
  854. }else{
  855. this.TcInfoVoData={}//调仓
  856. }
  857. }
  858. //消防换仓
  859. if (d.xfTargetCode) {
  860. this.xfTargetCodeData = {
  861. xfTargetCode: d.xfTargetCode,
  862. chargerState: d.chargerState,
  863. startTime: d.startTime,
  864. actionFlow: d.actionFlow,
  865. }
  866. this.TcInfoVoData={}
  867. this.XfNumber=0
  868. }else{
  869. if(this.XfNumber<=5){
  870. this.XfNumber=this.XfNumber+1
  871. }else{
  872. this.xfTargetCodeData={}//调仓
  873. }
  874. }
  875. })
  876. // 监听WebSocket关闭事件
  877. this.ws.onClose(() => {
  878. console.log('WebSocket连接已关闭!')
  879. })
  880. this.ws.onError(() => {
  881. console.log("WebSocket连接错误")
  882. })
  883. if(this.timer == null){
  884. //检查断开重连
  885. this.timer = setInterval(() => {
  886. // if (this.ws==null || this.ws.readyState != 1) {
  887. // this.ws.close()
  888. // this.ws = null
  889. // console.log('检查断开重连')
  890. // this.InitWs()
  891. // }
  892. if(this.ws==null){
  893. console.log('ws为null,检查断开重连')
  894. this.InitWs()
  895. }else if(this.ws.readyState != 1){
  896. this.ws.close()
  897. this.ws = null
  898. console.log('未连接成功,检查断开重连')
  899. this.InitWs()
  900. }
  901. }, 2000)
  902. }
  903. },
  904. },
  905. }
  906. </script>
  907. <style lang="scss" scoped>
  908. @import './index.scss';
  909. .popup-container {
  910. width: 300px;
  911. height: 200px;
  912. background: #263042;
  913. .popup-title {
  914. height: 60px;
  915. display: flex;
  916. padding: 0 15px;
  917. border-bottom: 1px solid #C7D2DF;
  918. position: relative;
  919. .title-text {
  920. text-align: left;
  921. background: #263042;
  922. font-weight: 500;
  923. color: #FFFFFF;
  924. font-size: 20px;
  925. line-height: 60px;
  926. width: 200px;
  927. }
  928. .title-close {
  929. text-align: right;
  930. background: #263042;
  931. font-weight: 500;
  932. color: #FFFFFF;
  933. font-size: 20px;
  934. line-height: 60px;
  935. width: 60px;
  936. }
  937. }
  938. .popup-content {
  939. display: flex;
  940. margin-top: 20px;
  941. padding: 0 20px 0 10px;
  942. }
  943. }
  944. .carPosition {
  945. // margin-top: 76px;
  946. .carForm {
  947. display: flex;
  948. justify-items: flex-end;
  949. view:first-child {
  950. font-weight: 400;
  951. color: rgba(153, 174, 197, 0.65);
  952. font-size: 14px;
  953. flex: 1;
  954. text-align: right;
  955. line-height: 34px;
  956. }
  957. .uni-input {
  958. width: 245px;
  959. height: 34px;
  960. background: rgba(255, 255, 255, 0);
  961. border-radius: 2px;
  962. border: 1px solid #263042;
  963. text-indent: 15px;
  964. font-size: 14px;
  965. font-weight: 400;
  966. color: #FFFFFF;
  967. }
  968. }
  969. .CarnoData {
  970. width: 274px;
  971. height: 227px;
  972. background-image: url('/static/change/noData.png');
  973. background-size: 100% 100%;
  974. margin: 20px 43px;
  975. }
  976. .Carlist {
  977. display: flex;
  978. flex-direction: column;
  979. width: 100%;
  980. .carDetail {
  981. width: 360px;
  982. height: 169px;
  983. border-radius: 8px;
  984. margin-bottom: 16px;
  985. background-image: url('/static/change/car-bg.png');
  986. background-size: 100% 100%;
  987. box-sizing: border-box;
  988. padding: 20px;
  989. display: flex;
  990. flex-direction: column;
  991. justify-content: space-between;
  992. .plateNumber {
  993. display: flex;
  994. align-items: center;
  995. height: 24px;
  996. line-height: 24px;
  997. .icon {
  998. margin-right: 8px;
  999. }
  1000. .pNumber {
  1001. font-size: 16px;
  1002. font-weight: 600;
  1003. color: #FFFFFF;
  1004. }
  1005. image {
  1006. width: 18px;
  1007. height: 18px;
  1008. vertical-align: middle;
  1009. margin-bottom: 3px;
  1010. }
  1011. }
  1012. .vinMa {
  1013. display: flex;
  1014. view:first-child {
  1015. width: 60px;
  1016. font-size: 14px;
  1017. font-weight: 400;
  1018. color: rgba(153, 174, 197, 0.65);
  1019. }
  1020. view:last-child {
  1021. flex: 1;
  1022. font-size: 14px;
  1023. font-weight: 400;
  1024. color: rgba(255, 255, 255, 0.85);
  1025. }
  1026. }
  1027. }
  1028. }
  1029. }
  1030. .status-only {
  1031. display: flex;
  1032. width: 100%;
  1033. align-items: center;
  1034. .circle {
  1035. width: 24px;
  1036. height: 24px;
  1037. margin-right: 4px;
  1038. image {
  1039. width: 24px;
  1040. height: 24px;
  1041. }
  1042. }
  1043. .descript {
  1044. font-size: 14px;
  1045. font-weight: 500;
  1046. width: 78px;
  1047. color: rgba(153, 174, 197, 0.65);
  1048. text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
  1049. }
  1050. .carTitle {
  1051. width: 68px !important;
  1052. }
  1053. .frameText {
  1054. color: #C7D2DF;
  1055. text-shadow: 0px 0px 4px #0027D8;
  1056. }
  1057. .frame {
  1058. flex: 1;
  1059. position: relative;
  1060. height: 32px;
  1061. text-indent: 15px;
  1062. font-size: 14px;
  1063. font-weight: 500;
  1064. color: #91FDB9;
  1065. line-height: 32px;
  1066. text-shadow: 0px 0px 4px #0027D8;
  1067. border: 1px solid #334568;
  1068. box-sizing: border-box;
  1069. .shinning {
  1070. position: absolute;
  1071. border: 1px solid #c9f8ff;
  1072. border-radius: 1px;
  1073. left: -1px;
  1074. top: -1px;
  1075. }
  1076. .editCar {
  1077. cursor: pointer;
  1078. position: absolute;
  1079. right: 20px;
  1080. top: 3px;
  1081. width: 18px;
  1082. height: 18px;
  1083. img {
  1084. width: 18px;
  1085. height: 18px;
  1086. }
  1087. }
  1088. .isflag {
  1089. color: #ED7735;
  1090. text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
  1091. }
  1092. .isblue {
  1093. color: #148CFA;
  1094. }
  1095. .btn {
  1096. display: flex;
  1097. position: absolute;
  1098. right: 15px;
  1099. top: 5px;
  1100. button {
  1101. width: 48px;
  1102. height: 28px;
  1103. background: #91FDB9;
  1104. border-radius: 2px 2px 2px 2px;
  1105. font-size: 16px;
  1106. font-weight: 400;
  1107. line-height: 28px;
  1108. text-align: center;
  1109. border: none;
  1110. padding: 0;
  1111. color: black;
  1112. }
  1113. button:hover {
  1114. background: #69b889;
  1115. }
  1116. }
  1117. }
  1118. }
  1119. .subtilte-only {
  1120. display: flex;
  1121. flex-direction: column;
  1122. border-top: $lineColor solid 1px;
  1123. border-bottom: $lineColor solid 1px;
  1124. width: 100%;
  1125. .title {
  1126. width: 100%;
  1127. background-color: $titColor;
  1128. margin: 1px 0px;
  1129. height: 24px;
  1130. display: flex;
  1131. .icon {
  1132. width: 17px;
  1133. height: 10px;
  1134. background-image: url('/static/public/ico2.png');
  1135. background-size: 100% 100%;
  1136. margin-left: 2px;
  1137. }
  1138. .name {
  1139. font-size: 16px;
  1140. margin-left: -5px;
  1141. height: 24px;
  1142. line-height: 22px;
  1143. font-weight: 600;
  1144. letter-spacing: 1px;
  1145. text-shadow: 0 0 2px #1753ce, 0 0 2px #1753ce, 0 0 2px #1753ce, 0 0 2px #1753ce;
  1146. color: white;
  1147. }
  1148. .letter {
  1149. color: #2A3855;
  1150. font-size: 10px;
  1151. margin-left: 5px;
  1152. padding-top: 5px;
  1153. font-weight: 600;
  1154. }
  1155. .switch {
  1156. margin-left: auto;
  1157. color: white;
  1158. height: 20px;
  1159. font-size: 12px;
  1160. width: 100px;
  1161. display: flex;
  1162. align-items: center;
  1163. uni-switch {
  1164. margin-top: 3px;
  1165. }
  1166. }
  1167. .log-descript {
  1168. margin-left: auto;
  1169. font-size: 12px;
  1170. font-weight: 400;
  1171. color: rgba(153, 174, 197, 0.65);
  1172. line-height: 22px;
  1173. padding-right: 26px;
  1174. }
  1175. }
  1176. }
  1177. .carLeft{
  1178. color: #fff !important;
  1179. }
  1180. .carRight{
  1181. color: #fff !important;
  1182. }
  1183. .isshowactive{
  1184. color: rgba(153, 174, 197, 0.65) !important;
  1185. }
  1186. </style>