index.vue 33 KB

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