index.vue 34 KB

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