index.vue 33 KB

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