12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235 |
- <template>
- <view class="content">
- <!-- 第一排盒子开始 -->
- <view class="box-first">
- <view class="machineStatus">
- <SubTitle title="机器人状态" titleEng="ROBOT STATUS"></SubTitle>
- <view class="bottom">
- <view class="list">
- <view class="plcConnect">
- <PannelItem show="true" words="PLC通讯" :status="robotInfoVo.plcState ? '正常' : '异常'"
- :flag="robotInfoVo.plcState" />
- </view>
- <view class="plcModel">
- <PannelItem show="true" words="机器人模式" :status="PlcMode" :flag="robotInfoVo.exchangeMode" />
- </view>
- </view>
- <view class="status-only">
- <view class="circle">
- <image :src="PlcState[0]"></image>
- </view>
- <view class="descript">机器人状态</view>
- <view class="frame">
- <span :class="PlcState[1]">{{PlcState[2] || '—'}}</span>
- <view class="shinning"></view>
- </view>
- </view>
- <PannelItem show="true" words="急停状态" :status="robotInfoVo.emergencyMode == 1 ? '急停' : robotInfoVo.emergencyMode == 0 ?'未急停' :'—'"
- :flag="robotInfoVo.emergencyMode == 0" />
- <PannelItem show="true" words="暂停状态" :status="robotInfoVo.pause == 1 ? '暂停' : robotInfoVo.pause == 0?'未暂停':'—' " handle="true"
- @ExchangeMessage='ExchangeMessage' :flag="robotInfoVo.pause == 0" />
- </view>
- </view>
- <view class="machineStatus carInfo">
- <SubTitle title="车辆信息" titleEng="VEHICLE INFORMATION"></SubTitle>
- <view class="bottom">
- <view class="list">
- <view class="carLeft">
- <PannelTitle words="车牌号" :value="vehicleInfo.plate" Isblue="true" :circle="true"
- :flag="vehicleInfo.plateState" @ShowCarline="ShowCarline" />
- </view>
- <view class="carRight">
- <PannelTitle words="在线车辆" circle="false" :value="vehicleInfo.onlineNum" flag="true"
- @ShowCarline="ShowCarline" />
- </view>
- </view>
- <view class="list">
- <view class="carLeft">
- <PannelTitle words="车辆识别" :value="vehicleInfo.plateState == 1 ? '成功' : '未识别'"
- :flag="vehicleInfo.plateState" @handleStatusShow="handleStatusShow"/>
- </view>
- <view class="carRight">
- <PannelTitle words="鉴权状态" :value="vehicleInfo.authState ? '已通过' : '未通过'"
- :flag="vehicleInfo.authState" />
- </view>
- </view>
- <view class="list">
- <view class="carLeft">
- <PannelTitle words="连接状态" :value="vehicleInfo.conState == 1 ? '已连接' : vehicleInfo.conState == 0 ?'未连接':'—'"
- :flag="vehicleInfo.conState == 1" />
- </view>
- <view class="carRight">
- <PannelTitle words="车辆到位" :value="vehicleInfo.sensorState ? '已到位' : '未到位'"
- :flag="vehicleInfo.sensorState" />
- </view>
- </view>
- <view class="list">
- <view class="carLeft">
- <PannelTitle circle="false" words="解锁状态"
- :value="vehicleInfo.lockState==null ? '—': vehicleInfo.lockState?'已上锁' : '已解锁'"
- @ExchangeMessage="ExchangeMessage" :flag="vehicleInfo.lockState == 0" />
- </view>
-
- </view>
- </view>
- </view>
- </view>
- <!-- 第一排盒子结束-->
- <!-- 选电模式开始 -->
- <view class="getModel">
- <view class="subtilte-only">
- <view class="title">
- <view class="icon"></view>
- <view class="name">选电模式</view>
- <view class="letter">POWER SELECTION MODE</view>
- <view class="handle-model">
- <view class="leftBtn" :class="[pamars.batChooseMode===0 ? 'active' : '']"
- @click="ChangeModel(0)">自动选电</view>
- <view class="leftBtn Rbtn" :class="[pamars.batChooseMode===1 ? 'active' : '']"
- @click="ChangeModel(1)">手动选电</view>
- </view>
- </view>
- </view>
-
- <view class="storeList">
- <scroll-view scroll-x="true" class="scroll_x">
- <view v-for="(item, index) in storeInfoList">
- <!-- 电池列表信息 -->
- <BatteryInfo :soc="item.soc"
- :chgState="item.chargerInfoVo.chgState" :chgEstimatedTime="item.chargerInfoVo.chgEstimatedTime"
- :key="index" :storeState="item.storeState" :storeCode="item.storeCode"
- :freezeState="item.freezeState" :comState="item.comState" :lineType="item.chargerInfoVo.linktype"
- :chargerComState="item.chargerInfoVo.comState" :BatterySelectAllArr="BatterySelectAllArr"
- :BatterySelected="BatterySelected" :IsSelect="BatteryIsSelectArr[index]" />
- <!-- 电池信息结束 -->
- </view>
- </scroll-view>
- </view>
-
- </view>
- <!-- 选电模式结束-->
- <!-- 底部开始 -->
- <view class="box-last">
- <view class="Exchange-done">
- <view class="subtilte-only">
- <view class="title">
- <view class="icon"></view>
- <view class="name">换电操作</view>
- <view class="letter">POWER EXCHANGE OPERATION</view>
- <view class="switch">
- <view class="uni-list-cell-db">{{powerChangeStatus?'开启中':'已关闭'}}</view>
- <switch color="#91FDB9" style="transform:scale(0.6)" @change="switchChange" :checked="powerChangeStatus" />
- </view>
- </view>
- </view>
- <view class="Exchange-bottom">
- <view class="Exchange-times">
- <view class="Progress-btn" :class='!powerChangeStatus?"isshowactive":""' @click="BeginChangePower">开始换电</view>
- <view class="Exchange-status" v-if="!TcInfoVoData.sourceCode && !TcInfoVoData.targetCode && !xfTargetCodeData.xfTargetCode">
- <view class="lock">
- <span>{{ forbidLockState ? '锁止已屏蔽' : '锁止已放开'}}</span>
- <span class="time">换电时长:<font>{{PlcChangerTime || '—'}}</font></span>
- </view>
- <view class="percent">
- <view class="percent-bar">
- <view class="bar">
- <view class="bar-green" :style="{ 'width': swapPercent + '%' }">
- <view class="bar-percent" :class="[swapPercent <15 ? 'bar-ten' : '']">
- {{ swapPercent }}%
- </view>
- </view>
- </view>
- </view>
- <view class="count-step">
- <font>{{swapProcess.step || 0}}</font>/{{swapProcess.plcStep || 0}}
- </view>
- </view>
- <view class="lock">
- <span></span>
- <span class="time">机器人工作时长:<font>{{PlcWorkTime || '—'}}</font></span>
- </view>
- </view>
- <view class="Exchange-status" v-if="TcInfoVoData.sourceCode && TcInfoVoData.targetCode">
- <view class="Exchange-status-left">
- <view class="Exchange-status-left-box">
- <text class="text1">仓位</text><text
- class="text2">{{TcInfoVoData.sourceCode}}—>{{TcInfoVoData.targetCode}}号仓位</text>
- </view>
- <view class="Exchange-status-left-box">
- <text class="text1">电池状态</text><text
- class="text2">{{TcInfoVoData.chargerState?'充电中':'未充电'}}</text>
- </view>
- </view>
- <view class="Exchange-status-left">
- <view class="Exchange-status-left-box">
- <text class="text1">动作流程</text><text
- class="text2">{{TcInfoVoData.actionFlow || '-'}}</text>
- </view>
- <view class="Exchange-status-left-box">
- <text class="text1">工作时长</text><text class="text2">{{warehouse || '-'}}</text>
- </view>
- </view>
- </view>
- <view class="Exchange-status" v-if="xfTargetCodeData.xfTargetCode">
- <view class="Exchange-status-left">
- <view class="Exchange-status-left-box change-store">
- <text class="text1">仓位</text><text
- class="text2">{{xfTargetCodeData.xfTargetCode}}号仓位</text>
- </view>
- <view class="Exchange-status-left-box">
- <text class="text1">电池状态</text><text
- class="text2">{{xfTargetCodeData.chargerState?'充电中':'未充电'}}</text>
- </view>
- </view>
- <view class="Exchange-status-left">
- <view class="Exchange-status-left-box">
- <text class="text1">动作流程</text><text
- class="text2">{{xfTargetCodeData.actionFlow || '-'}}</text>
- </view>
- <view class="Exchange-status-left-box">
- <text class="text1">工作时长</text><text class="text2">{{changeWareHouse || '-'}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="Exchange-handle">
- <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleIsLock(1)">锁止屏蔽</view>
- <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleChangeStore">调仓</view>
- <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="PausePLC(1)">急停</view>
- <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleFireStore">消防换仓</view>
- <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="HandleIsLock(0)">锁止放开</view>
- <view class="handle" :class='!powerChangeStatus?"isshowactive":""' @click="PausePLC(6)">中止</view>
- </view>
- </view>
- </view>
- <view class="Exchange-log">
- <view class="subtilte-only">
- <view class="title">
- <view class="icon"></view>
- <view class="name">换电日志</view>
- <view class="letter">POWER EXCHANGE OPERATION</view>
- <!-- <view class="log-descript">支持手动急停充电机,倒计时1分钟</view> -->
- </view>
- </view>
- <view class="log_bottom">
- <scroll-view scroll-y="true" class="scroll_x">
- <view class="log-list" v-for="item in logList" :key="item.id">
- <view class="log-times" :class="[item.remark=='error'?'logRed':'']">{{item.createTime}}</view>
- <view class="log-info" :class="[item.remark=='error'?'logRed':'']">{{item.content}}</view>
- </view>
- </scroll-view>
- </view>
- </view>
- </view>
- <!-- 底部结束 -->
- <!-- 顶部公共提示信息 -->
- <uni-popup ref="Exchangepopup" type="message">
- <uni-popup-message :type="popupType" :message="popupMessage" :duration="2000"></uni-popup-message>
- </uni-popup>
- <uni-popup ref="popup" :mask-click="false">
- <view class="popup-container">
- <view class="popup-title">
- <view class="title-text">
- 车辆识别设备网络
- </view>
- <view class="title-close" @click="closePopup">
- 关闭
- </view>
- </view>
- <view class="popup-content">
- <PannelTitle words="车牌识别器" :value="vehicleInfo.plateComState == 1 ? '已连接' : '未连接'" :flag="vehicleInfo.plateComState"/>
- </view>
- <view class="popup-content">
- <PannelTitle words="FRID识别器" :value="vehicleInfo.rfidConnState ? '已连接' : '未连接'" :flag="vehicleInfo.rfidConnState"/>
- </view>
- </view>
- </uni-popup>
- <!-- 顶部提示信息结束-->
- <!--在线、编辑车辆抽屉 -->
- <uni-drawer ref="carlineDrawer" mode="right" :width="400" :mask-click="true">
- <scroll-view style="height: 100%;" scroll-y="true">
- <PublicDrawer :flag="isDrawer" title="在线车辆" @closeDrawer="closeDrawer" v-if="isDrawer">
- <view class="carPosition">
- <view class="CarnoData" v-if="CarlineList.length==0"></view>
- <view class="Carlist" v-for="item in CarlineList" :key="item.id">
- <view class="carDetail">
- <view class="plateNumber">
- <view class="icon">
- <image src="/static/change/car.png"></image>
- </view>
- <view class="pNumber">{{item.vehiclePlate}}</view>
- </view>
- <view class="vinMa">
- <view>VIN码</view>
- <view>{{item.vehicleVin}}</view>
- </view>
- <view class="vinMa">
- <view>熄火状态</view>
- <view>{{item.keyState}}</view>
- </view>
- <view class="vinMa">
- <view>解锁状态</view>
- <view>{{item.lockState?'已上锁':'已解锁'}}</view>
- </view>
- </view>
- </view>
- </view>
- </PublicDrawer>
- <PublicDrawer :flag="isDrawer" title="编辑车牌" @HandleEditPlate="HandleEditPlate"
- :plate="vehicleInfo.plate" @closeDrawer="closeDrawer" v-if="!isDrawer">
- <view class="carPosition">
- <view class="carForm">
- <view>编辑车牌号:</view>
- <input class="uni-input" type="text" v-model="plate" placeholder="请输入车牌号" />
- </view>
- </view>
- </PublicDrawer>
- </scroll-view>
- </uni-drawer>
- <!-- 在线、编辑车辆抽屉结束-->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- popupMessage: '成功消息',
- popupType: 'success',
- robotInfoVo: {}, //机器人状态对象
- vehicleInfo: {}, //车辆信息对象
- batteryInfo: {}, //电池信息对象
- swapProcess: {}, //换电进度对象
- storeInfoList: [], //电池仓列表数组
- logList: [], //日志列表
- BatteryIsSelectArr: [false, false, false, false, false, false, false, false], //存储电池的选中状态
- BatteryFullStatus: true, //切换满电、亏点电池状态
- BatterySelectAllArr: [], //存储所有选中的电池仓位号
- CarlineList: [], //在线车辆列表
- pamars: {
- batChooseMode: 0,
- batChosenIndex: 0,
- startMode: 0,
- userId: 1,
- userName: 'admin'
- }, //开始换电参数
- ws: null, //ws连接对象
- timer: null, //ws连接
- isDrawer: true, //切换抽屉显示内容
- plate: '—', //弹窗车牌号
- powerChangeStatus: false,
- isSelectstoreState: [], //选择的仓位存储电池状态
- TcInfoVoData: {}, //调仓信息对象
- xfTargetCodeData: {}, //消防换仓对象
- heartbeatTimer:null,
- onMessageTime:null,
- TcNumber:0,//调仓计数器 大于5时显示换电页面
- XfNumber:0,//消防调仓计数器 大于5时显示换电页面
- forbidLockState:true,//锁止状态
- }
- },
- mounted() {
- this.onMessageTime = new Date();
- this.InitWs()
- this.heartbeatTimer = setInterval(()=>{
- let newDate = new Date();
- if(newDate-this.onMessageTime>3000){
- if(this.ws!=null){
- this.ws.close()
- this.ws=null
- }
- }
- },3000)
- },
- destroyed(){
- clearInterval(this.timer)
- this.ws.close()
- },
- onUnload() {
- if(this.timer!=null){
- clearInterval(this.timer)
- this.timer = null
- }
- if(this.ws!=null){
- this.ws.close()
- this.ws=null
- }
- if(this.heartbeatTimer!=null){
- this.heartbeatTimer.close()
- this.heartbeatTimer=null
- }
- },
- computed: {
- //换电时长
- PlcChangerTime() {
- if (this.swapProcess.swapStartTime) {
- let end_time = this.$moment()
- let seconds = end_time.diff(this.swapProcess.swapStartTime, "seconds")
- return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
- }
- },
- //机器人工作时长
- PlcWorkTime() {
- if (this.swapProcess.plcStartTime) {
- let end_time = this.$moment()
- let seconds = end_time.diff(this.swapProcess.plcStartTime, "seconds")
- return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
- }
- },
- //调仓工作时长
- warehouse() {
- if (this.TcInfoVoData.startTime) {
- let end_time = this.$moment()
- let seconds = end_time.diff(this.TcInfoVoData.startTime, "seconds")
- return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
- }
- },
- //消防换仓工作时长
- changeWareHouse() {
- if (this.xfTargetCodeData.startTime) {
- let end_time = this.$moment()
- let seconds = end_time.diff(this.xfTargetCodeData.startTime, "seconds")
- return parseInt(seconds / 60) + '分' + (seconds % 60) + '秒'
- }
- },
- //换电百分比
- swapPercent() {
- if (this.swapProcess.plcPercentage) {
- return this.swapProcess.plcPercentage
- } else {
- return 0
- }
- },
- //换电解锁状态
- swapIsLock() {
- switch (this.swapProcess.lockState) {
- case true:
- return '已上锁'
- case false:
- return '已解锁'
- default:
- return '—'
- }
- },
- //机器人状态
- PlcState() {
- switch (this.robotInfoVo.robotState) {
- case 1:
- return ['/static/change/green.png', '', '就绪']
- case 2:
- return ['/static/change/blue.png', 'isblue', '运行']
- case 3:
- return ['/static/change/yellow.png', 'isflag', '完成']
- case 4:
- return ['/static/change/yellow.png', 'isflag', '故障']
- case 5:
- return ['/static/change/yellow.png', 'isflag', '中止']
- default:
- return ['/static/change/yellow.png', 'isflag', '未就绪']
- }
- },
- //机器人模式
- PlcMode() {
- switch (this.robotInfoVo.exchangeMode) {
- case 0:
- return '无效';
- case 1:
- return '手动模式';
- case 2:
- return '自动模式';
- case 3:
- return '单步模式';
- }
- },
- },
- methods: {
- handleStatusShow() {
- this.$refs.popup.open('center');
- },
- closePopup() {
- this.$refs.popup.close();
- },
- //修改车牌号提交
- HandleEditPlate(plate) {
- let that = this
- if (this.$checks.validateLicensePlateNumber(this.plate)) {
- this.$http.EditPlate(this.plate)
- .then(res => {
- if (res.code === 0) {
- that.ExchangeMessage('success', '修改成功!')
- that.closeDrawer()
- } else {
- that.ExchangeMessage('error', '修改失败!')
- }
- }).catch(err => {
- console.error(err)
- })
- } else {
- that.ExchangeMessage('warn', '请填写新能源车牌号!')
- }
- },
- closeDrawer() {
- this.$refs.carlineDrawer.close();
- },
- //顶部公共消息提示
- ExchangeMessage(type, message) {
- this.popupType = type
- this.popupMessage = message ? message : '后端接口404错误!'
- this.$refs.Exchangepopup.open()
- },
- //切换换电模式(0自动、1手动)
- ChangeModel(id) {
- let that = this
- let modelText = id === 1 ? '手动' : '自动'
- uni.showModal({
- title: `请确认选电模式切换为${modelText}?`,
- content: '',
- success: function(res) {
- if (res.confirm) {
- that.$http.setMode(id + '').then(res => {
- if (res.code === 0) {
- that.pamars.batChooseMode = id === 1 ? 1 : 0
- }
- that.ExchangeMessage(res.code === 0 ? 'success' : 'error',
- res.code === 0 ? '选电模式切换成功!' : '选电模式切换失败!')
- })
- } else if (res.cancel) {
- return false
- //用户点击取消按钮触发
- }
- }
- })
- },
- //开始换电
- BeginChangePower() {
- if (this.powerChangeStatus) {
- if (this.pamars.batChooseMode === 1) {
- //手动模式下传仓位号参数
- if (this.BatterySelectAllArr.length !== 1 || this.BatterySelectAllArr[0].storeState !== 1) {
- this.ExchangeMessage('warn', '请手动选择一个电池进行换电!')
- return
- } else {
- this.pamars.batChosenIndex = this.BatterySelectAllArr[0].storeCode
- }
- } else {
- this.pamars.batChosenIndex = 0
- if (this.BatterySelectAllArr.length !== 0) {
- this.ExchangeMessage('warn', '自动换电不用选择电池,请取消选中的电池!')
- return
- }
- }
- const pamars = this.pamars
- let that = this
- uni.showModal({
- title: '请确认站控发起换电?',
- content: '',
- success: function(res) {
- if (res.confirm) {
- // that.ExchangeMessage('success', '换电指令已下发,请等待!')
- that.$http.beginSwap(pamars)
- .then(res => {
- that.clearStore()
- that.ExchangeMessage(res.code === 0 ? 'success' : 'error',
- res.code === 0 ? '发起换电成功!' : res.msg)
- })
- .catch(err => {
- console.error(err)
- })
- } else if (res.cancel) {
- return false
- //用户点击取消按钮触发
- }
- }
- })
- } else {
- this.PowerChangeStatusTips()
- }
- },
- //switch开关
- switchChange(e) {
- this.powerChangeStatus = e.detail.value
- },
- //实时车辆弹窗
- ShowCarline(pamars) {
- this.$refs.carlineDrawer.open();
- if (pamars == 'line') {
- this.getCarOnline()
- this.isDrawer = true
- } else {
- this.isDrawer = false
- this.plate = pamars
- }
- },
- //已连接站控车辆列表
- getCarOnline() {
- this.$http.CarOnline().then(res => {
- this.CarlineList = res.data; //[{vehicleVin:123,keyState:2,vehiclePlate:"渝AFB3182"}]
- this.CarlineList.forEach(item => {
- if (item.keyState == 0) {
- item.keyState = '熄火'
- } else if (item.keyState == 1) {
- item.keyState = '未点火'
- } else if (item.keyState == 2) {
- item.keyState = '启动'
- } else {
- item.keyState = '-'
- }
- })
- })
- },
- //切换满电、亏电电池信息
- ChangeBattery(id) {
- this.BatteryFullStatus = id === 1 ? true : false
- },
- //锁止屏蔽、放开
- HandleIsLock(islock) {
- if (this.powerChangeStatus) {
- let that = this
- let lockTest = islock ? '锁止屏蔽' : '锁止放开'
- uni.showModal({
- title: `请确认${lockTest}`,
- content: '',
- success: function(res) {
- if (res.confirm) {
- that.$http.EditforbidLock(islock + '')
- .then(res => {
- if (res.code === 0) {
- that.ExchangeMessage('success', islock ? '屏蔽成功' : '放开成功')
- } else {
- that.ExchangeMessage('error', islock ? '屏蔽失败' : '放开失败')
- }
- }).catch(err => {
- console.error(err)
- })
- } else if (res.cancel) {
- return false
- //用户点击取消按钮触发
- }
- }
- })
- } else {
- this.PowerChangeStatusTips()
- }
- },
- //急停、中止
- PausePLC(isStop) {
- if (this.powerChangeStatus) {
- let that = this
- const text = isStop == 1 ? '急停机器人' : '中止机器人'
- uni.showModal({
- title: `请确认${text}?`,
- content: '',
- success: function(res) {
- if (res.confirm) {
- that.$http.plcStop(isStop + '')
- .then(res => {
- if (res.code === 0) {
- that.ExchangeMessage('success', isStop == 1 ? '急停指令下发成功' : '中止指令下发成功')
- } else {
- that.ExchangeMessage('error', isStop == 1 ? '急停指令下发失败' : '中止指令下发失败')
- }
- }).catch(err => {
- console.error(err)
- })
- } else if (res.cancel) {
- return false
- //用户点击取消按钮触发
- }
- }
- })
- } else {
- this.PowerChangeStatusTips()
- }
- },
- //选择电池仓位数
- BatterySelected(CurrentStore) {
- this.$set(this.BatteryIsSelectArr, CurrentStore.storeCode - 1, !this.BatteryIsSelectArr[CurrentStore
- .storeCode - 1]) //选中电池取反
- if (this.BatteryIsSelectArr[CurrentStore.storeCode - 1]) {
- this.BatterySelectAllArr = [...this.BatterySelectAllArr, CurrentStore] //将选中的电池放入数组中
- } else {
- this.BatterySelectAllArr = this.BatterySelectAllArr.filter(item => item.storeCode != CurrentStore
- .storeCode) //将取消选中的电池从数组中移除
- }
- if (this.BatterySelectAllArr.length === 3) {
- this.$set(this.BatteryIsSelectArr, this.BatterySelectAllArr[0].storeCode - 1, false)
- this.BatterySelectAllArr.shift() //删除第一个元素
- }
- // console.log(this.BatterySelectAllArr)
- },
- //开始调仓
- HandleChangeStore() {
- let that = this
- if (this.powerChangeStatus) {
- let source = 0
- let target = 0
- if (this.BatterySelectAllArr.length === 2) {
- source = this.BatterySelectAllArr[0].storeState ? 1 : 0
- target = this.BatterySelectAllArr[1].storeState ? 1 : 0
- }
- if (this.BatterySelectAllArr.length !== 2 || source == target) {
- that.ExchangeMessage('warn', '请选择一个电池和一个空仓位!')
- return
- } else if (this.BatterySelectAllArr[0].getChgState == 2 || this.BatterySelectAllArr[1].getChgState ==
- 2) {
- that.ExchangeMessage('warn',
- `【${this.BatterySelectAllArr[0].storeState===1?this.BatterySelectAllArr[0].storeCode:this.BatterySelectAllArr[1].storeCode}】号仓位电池未断电,请断电后在进行调仓!`
- )
- } else {
- const params = {
- sourceCode: this.BatterySelectAllArr[0].storeState === 1 ? this.BatterySelectAllArr[0]
- .storeCode : this.BatterySelectAllArr[1].storeCode, //选有电池的仓位号
- targetCode: this.BatterySelectAllArr[1].storeState !== 1 ? this.BatterySelectAllArr[1]
- .storeCode : this.BatterySelectAllArr[0].storeCode //选空仓的仓位号
- }
- uni.showModal({
- title: '',
- content: `请确认将【${params.sourceCode}】号仓位电池移至【${params.targetCode}号】仓位?`,
- success: function(res) {
- if (res.confirm) {
- // that.ExchangeMessage('success', '调仓指令已下发,请等待!')
- that.$http.RuleChangestorage(params)
- .then(res => {
- if (res.code === 0) {
- that.clearStore()
- }
- that.ExchangeMessage(res.code === 0 ? 'success' : 'error', res
- .code === 0 ? '调仓指令下发成功!' : '调仓指令下发失败!')
- }).catch(err => {
- console.error(err)
- })
- } else if (res.cancel) {
- return false
- //用户点击取消按钮触发
- }
- }
- })
- }
- } else {
- this.PowerChangeStatusTips()
- }
- },
- //消防换仓
- HandleFireStore() {
- let that = this
- if (this.powerChangeStatus) {
- if (this.BatterySelectAllArr.length !== 1 || this.BatterySelectAllArr[0].storeState !== 1) {
- this.ExchangeMessage('warn', '请选择一个电池操作消防换仓!')
- } else if (this.BatterySelectAllArr[0].getChgState == 2) {
- that.ExchangeMessage('warn', `【${this.BatterySelectAllArr[0].storeCode}】号仓位电池未断电,请断电后在进行消防换仓!`)
- } else {
- const params = {
- targetCode: this.BatterySelectAllArr[0].storeCode
- }
- uni.showModal({
- title: '',
- content: `请确认消防换仓,将【${that.BatterySelectAllArr[0].storeCode}】号仓位电池移至消防仓?`,
- success: function(res) {
- if (res.confirm) {
- // that.ExchangeMessage('success', '消防换仓指令已下发,请等待!')
- that.$http.FireChangestorage(params)
- .then(res => {
- if (res.code === 0) {
- that.clearStore()
- }
- that.ExchangeMessage(res.code === 0 ? 'success' : 'error',
- res.code === 0 ? '消防换仓指令下发成功!' : '消防换仓指令下发失败!')
- }).catch(err => {
- console.error(err)
- })
- } else if (res.cancel) {
- return false
- //用户点击取消按钮触发
- }
- }
- })
- }
- } else {
- this.PowerChangeStatusTips()
- }
- },
- //换电操作开关提示公用方法
- PowerChangeStatusTips() {
- this.ExchangeMessage('warn', '请先开启换电操作!')
- },
- //清空选择的仓位
- clearStore() {
- this.BatterySelectAllArr = []
- this.BatteryIsSelectArr = [false, false, false, false, false, false, false, false]
- },
- //websocket连接函数
- InitWs() {
- uni.showLoading({
- title:'数据加载中...'
- })
- if (this.ws != null) {
- this.ws.close()
- this.ws = null
- }
- if (this.timer != null) {
- clearInterval(this.timer)
- this.timer = null
- }
- let token = this.$storage.getJson('token');
- if (token == null) {
- uni.navigateTo({
- url: '/pages/login/index'
- })
- return false;
- }
- this.ws = uni.connectSocket({
- url: this.$config.web_socket_url + token,
- header: {
- 'content-type': 'application/json'
- },
- complete: () => {}
- })
- this.ws.onOpen(() => {
- console.log('socket连接成功')
- let msg = {
- type: "page",
- payload: "power-change-monitoring"
- }
- this.ws.send({
- data: JSON.stringify(msg)
- })
- })
- this.ws.onMessage((res) => {
- this.onMessageTime = new Date();
- let d = JSON.parse(res.data)
- // console.log(d)
- // uni.hideLoading()
- //电池仓位列表
- if (d.storeInfoList) {
- this.storeInfoList = d.storeInfoList
- uni.hideLoading()
- }
- //日志列表
- if (d.logList) {
- this.logList = d.logList.reverse()
- }
- // 车辆信息
- if (d.vehicleInfo) {
- this.vehicleInfo = d.vehicleInfo
- }
- // 电池信息
- if (d.batteryInfo) {
- this.batteryInfo = d.batteryInfo
- }
- //机器人状态
- if (d.robotInfoVo) {
- this.robotInfoVo = d.robotInfoVo
- }
- //换电进度
- if (d.swapProcess) {
- this.swapProcess = d.swapProcess
- //清空调仓数据
- if(d.swapProcess.swapId){
- this.xfTargetCodeData={}//消防调仓
- this.TcInfoVoData={}//调仓
- }
- }
- //选电模式
- if (d.batChooseMode >= 0) {
- this.pamars.batChooseMode = d.batChooseMode
- //锁止状态
- }
- if(d.hasOwnProperty('forbidLockState')){
- this.forbidLockState=d.forbidLockState
- }
- //调仓
- if (d.sourceCode && d.targetCode) {
- this.TcInfoVoData = {
- sourceCode: d.sourceCode,
- targetCode: d.targetCode,
- actionFlow: d.actionFlow,
- startTime: d.startTime,
- chargerState: d.chargerState,
- }
- this.xfTargetCodeData={}
- this.TcNumber=0
- }else{
- if(this.TcNumber<=5){
- this.TcNumber=this.TcNumber+1
- }else{
- this.TcInfoVoData={}//调仓
- }
- }
- //消防换仓
- if (d.xfTargetCode) {
- this.xfTargetCodeData = {
- xfTargetCode: d.xfTargetCode,
- chargerState: d.chargerState,
- startTime: d.startTime,
- actionFlow: d.actionFlow,
- }
- this.TcInfoVoData={}
- this.XfNumber=0
- }else{
- if(this.XfNumber<=5){
- this.XfNumber=this.XfNumber+1
- }else{
- this.xfTargetCodeData={}//调仓
- }
- }
- })
- // 监听WebSocket关闭事件
- this.ws.onClose(() => {
- console.log('WebSocket连接已关闭!')
- })
- this.ws.onError(() => {
- console.log("WebSocket连接错误")
- })
- if(this.timer == null){
- //检查断开重连
- this.timer = setInterval(() => {
- // if (this.ws==null || this.ws.readyState != 1) {
- // this.ws.close()
- // this.ws = null
- // console.log('检查断开重连')
- // this.InitWs()
- // }
- if(this.ws==null){
- console.log('ws为null,检查断开重连')
- this.InitWs()
- }else if(this.ws.readyState != 1){
- this.ws.close()
- this.ws = null
- console.log('未连接成功,检查断开重连')
- this.InitWs()
- }
- }, 2000)
- }
-
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- @import './index.scss';
- .popup-container {
- width: 300px;
- height: 200px;
- background: #263042;
- .popup-title {
- height: 60px;
- display: flex;
- padding: 0 15px;
- border-bottom: 1px solid #C7D2DF;
- position: relative;
- .title-text {
- text-align: left;
- background: #263042;
- font-weight: 500;
- color: #FFFFFF;
- font-size: 20px;
- line-height: 60px;
- width: 200px;
- }
- .title-close {
- text-align: right;
- background: #263042;
- font-weight: 500;
- color: #FFFFFF;
- font-size: 20px;
- line-height: 60px;
- width: 60px;
- }
- }
- .popup-content {
- display: flex;
- margin-top: 20px;
- padding: 0 20px 0 10px;
- }
- }
- .carPosition {
- // margin-top: 76px;
- .carForm {
- display: flex;
- justify-items: flex-end;
- view:first-child {
- font-weight: 400;
- color: rgba(153, 174, 197, 0.65);
- font-size: 14px;
- flex: 1;
- text-align: right;
- line-height: 34px;
- }
- .uni-input {
- width: 245px;
- height: 34px;
- background: rgba(255, 255, 255, 0);
- border-radius: 2px;
- border: 1px solid #263042;
- text-indent: 15px;
- font-size: 14px;
- font-weight: 400;
- color: #FFFFFF;
- }
- }
- .CarnoData {
- width: 274px;
- height: 227px;
- background-image: url('/static/change/noData.png');
- background-size: 100% 100%;
- margin: 20px 43px;
- }
- .Carlist {
- display: flex;
- flex-direction: column;
- width: 100%;
- .carDetail {
- width: 360px;
- height: 169px;
- border-radius: 8px;
- margin-bottom: 16px;
- background-image: url('/static/change/car-bg.png');
- background-size: 100% 100%;
- box-sizing: border-box;
- padding: 20px;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .plateNumber {
- display: flex;
- align-items: center;
- height: 24px;
- line-height: 24px;
- .icon {
- margin-right: 8px;
- }
- .pNumber {
- font-size: 16px;
- font-weight: 600;
- color: #FFFFFF;
- }
- image {
- width: 18px;
- height: 18px;
- vertical-align: middle;
- margin-bottom: 3px;
- }
- }
- .vinMa {
- display: flex;
- view:first-child {
- width: 60px;
- font-size: 14px;
- font-weight: 400;
- color: rgba(153, 174, 197, 0.65);
- }
- view:last-child {
- flex: 1;
- font-size: 14px;
- font-weight: 400;
- color: rgba(255, 255, 255, 0.85);
- }
- }
- }
- }
- }
- .status-only {
- display: flex;
- width: 100%;
- align-items: center;
- .circle {
- width: 24px;
- height: 24px;
- margin-right: 4px;
- image {
- width: 24px;
- height: 24px;
- }
- }
- .descript {
- font-size: 14px;
- font-weight: 500;
- width: 78px;
- color: rgba(153, 174, 197, 0.65);
- text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
- }
- .carTitle {
- width: 68px !important;
- }
- .frameText {
- color: #C7D2DF;
- text-shadow: 0px 0px 4px #0027D8;
- }
- .frame {
- flex: 1;
- position: relative;
- height: 32px;
- text-indent: 15px;
- font-size: 14px;
- font-weight: 500;
- color: #91FDB9;
- line-height: 32px;
- text-shadow: 0px 0px 4px #0027D8;
- border: 1px solid #334568;
- box-sizing: border-box;
- .shinning {
- position: absolute;
- border: 1px solid #c9f8ff;
- border-radius: 1px;
- left: -1px;
- top: -1px;
- }
- .editCar {
- cursor: pointer;
- position: absolute;
- right: 20px;
- top: 3px;
- width: 18px;
- height: 18px;
- img {
- width: 18px;
- height: 18px;
- }
- }
- .isflag {
- color: #ED7735;
- text-shadow: 0px 0px 4px rgba(39, 69, 201, 0.5);
- }
- .isblue {
- color: #148CFA;
- }
- .btn {
- display: flex;
- position: absolute;
- right: 15px;
- top: 5px;
- button {
- width: 48px;
- height: 28px;
- background: #91FDB9;
- border-radius: 2px 2px 2px 2px;
- font-size: 16px;
- font-weight: 400;
- line-height: 28px;
- text-align: center;
- border: none;
- padding: 0;
- color: black;
- }
- button:hover {
- background: #69b889;
- }
- }
- }
- }
- .subtilte-only {
- display: flex;
- flex-direction: column;
- border-top: $lineColor solid 1px;
- border-bottom: $lineColor solid 1px;
- width: 100%;
- .title {
- width: 100%;
- background-color: $titColor;
- margin: 1px 0px;
- height: 24px;
- display: flex;
- .icon {
- width: 17px;
- height: 10px;
- background-image: url('/static/public/ico2.png');
- background-size: 100% 100%;
- margin-left: 2px;
- }
- .name {
- font-size: 16px;
- margin-left: -5px;
- height: 24px;
- line-height: 22px;
- font-weight: 600;
- letter-spacing: 1px;
- text-shadow: 0 0 2px #1753ce, 0 0 2px #1753ce, 0 0 2px #1753ce, 0 0 2px #1753ce;
- color: white;
- }
- .letter {
- color: #2A3855;
- font-size: 10px;
- margin-left: 5px;
- padding-top: 5px;
- font-weight: 600;
- }
- .switch {
- margin-left: auto;
- color: white;
- height: 20px;
- font-size: 12px;
- width: 100px;
- display: flex;
- align-items: center;
- uni-switch {
- margin-top: 3px;
- }
- }
- .log-descript {
- margin-left: auto;
- font-size: 12px;
- font-weight: 400;
- color: rgba(153, 174, 197, 0.65);
- line-height: 22px;
- padding-right: 26px;
- }
- }
- }
- .carLeft{
- color: #fff !important;
- }
- .carRight{
- color: #fff !important;
- }
- .isshowactive{
- color: rgba(153, 174, 197, 0.65) !important;
- }
-
- </style>
|