index.vue 33 KB

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