index.vue 36 KB

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