index.vue 34 KB

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