index.vue 34 KB

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