| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105 |
- <template>
- <view class="content">
- <view class="header" style="margin:0;padding: 0px;">
- <view class="bg" style="position: fixed;top:0px;bottom:0px;left:0px;right:0px;background-image: url('https://jianyaoji.oss-cn-hangzhou.aliyuncs.com/jianyaoji/images/device/bg.png');background-size: 100% 100%;padding:0 40rpx">
- <view style="position: absolute;right:10rpx;top:30rpx">
- <u-button @click="reportError" color="#EC6D2F" text="上报异常" type="error" size="mini"></u-button>
- </view>
- <view style="position: absolute;right:52rpx;top:116rpx;" v-if="deviceInfo.status == 3">
- <view>
- <u-image :showLoading="true" src="/static/images/device/zaixian.png" width="200rpx" height="200rpx" ></u-image>
- </view>
- <view style="position: absolute;color:#48C373;top:110rpx;left:70rpx">在线</view>
- </view>
- <view style="position: absolute;right:52rpx;top:116rpx;" v-if="deviceInfo.status == 4">
- <view>
- <u-image :showLoading="true" src="/static/images/device/offline.png" width="200rpx" height="200rpx" ></u-image>
- </view>
- <view style="position: absolute;color:lightgray;top:110rpx;left:70rpx">离线</view>
- </view>
- <view style="font-weight: bold;font-size: 30rpx;margin-top:20rpx">
- {{deviceInfo.deviceName}}
- </view>
- <view class="prop-text">
- <text class="text-left">所属用户:</text>
- <text class="text-right">{{sysDept.deptName}}</text>
- </view>
- <view class="prop-text">
- <text class="text-left">设备编号:</text>
- <text class="text-right">{{deviceInfo.serialNumber}}</text>
- </view>
- <view class="prop-text">
- <text class="text-left">二维码ID:</text>
- <text class="text-right">{{deviceInfo.qrcodeId==null?"未绑定":deviceInfo.qrcodeId}}</text>
- </view>
- <view class="prop-text">
- <text class="text-left">激活时间:</text>
- <text class="text-right">{{deviceInfo.activeTime}}</text>
- </view>
- <view class="prop-text">
- <text class="text-left">查看位置:</text>
- <view style="position: absolute;top:0px;left:120rpx">
- <u-icon name="map-fill" label="查看位置" color="#2979ff" size="20" labelSize="12"></u-icon>
- </view>
- </view>
- <view class="prop-card-area">
- <view class="prop-card">
- <view class="prop-card-top">{{ deviceInfo.rssi }}</view>
- <view class="prop-card-bottom">设备信号</view>
- </view>
- <view class="prop-card">
- <view class="prop-card-top">{{ timeobj.alltime }}</view>
- <view class="prop-card-bottom">累计时长</view>
- </view>
- <view class="prop-card">
- <view class="prop-card-top">{{ timeobj.avgtime }}</view>
- <view class="prop-card-bottom">平均时长</view>
- </view>
- </view>
- <view class="tab-area">
- <!-- <u-tabs lineWidth="80" :activeStyle="{ color: '#3E9CFC' }" :list="summary" keyName="tabName" @change="getDeviceStatus"></u-tabs>-->
- <u-tabs lineWidth="80" :activeStyle="{ color: '#3E9CFC' }" :list="tabs" :current="current" keyName="tabName" @change="getNewDeviceStatus"></u-tabs>
- <view>
- <uni-row class="demo-uni-row">
- <uni-col :span="12">
- </uni-col>
- </uni-row>
- <uni-row class="demo-uni-row">
- <uni-col :span="12">
- </uni-col>
- </uni-row>
- <!-- 煎药控制 -->
- <view class="demo-uni-row" v-if="firstTab">
- <!-- 子tab -->
- <view style="width:70%;margin:0 auto">
- <u-tabs :list="summary" :current="subCurrent" @change="changeSub"></u-tabs>
- </view>
- <!-- 设备和锁定开关 -->
- <view class="demo-uni-row clearfix">
- <view style="clear: both"></view>
- </view>
- <!-- 头部 -->
- <view class="decoctControlHeader">
- <uni-icons custom-prefix="iconfont" type="icon-fuzhushuxian" size="30"></uni-icons>
- <text>煎药控制</text>
- </view>
- <!-- 腰部 -->
- <view>
- <!-- 上边部份 -->
- <view class="decoctControlTop">
- <!-- 左边 -->
- <view class="decoctControlTopLeft">
- <view>温度设置</view>
- <view class="control-input-box">
- <view style="width: 80px">
- <u-input placeholder="请输入" @change="changeTemperature()" v-model="temperature"></u-input>
- </view>
- <view class="control-input-box-danwei">℃</view>
- </view>
- <view class="gap">
- <view class="addTemperature" @click="addTemperature(1)">
- <u-image src="/static/images/device/up_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- <view class="subTemperature" @click="subTemperature(1)">
- <u-image src="/static/images/device/down_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- </view>
- </view>
- <!-- 右边 -->
- <view class="decoctControlTopRight">
- <view>煎药时间</view>
- <view class="control-input-box">
- <view style="width: 80px">
- <u-input placeholder="请输入" @change="changeTemperatureTime()" v-model="temperatureTime"></u-input>
- </view>
- <view class="control-input-box-danwei">min</view>
- </view>
- <view class="gap">
- <view class="addTime" @click="addTemperatureTime">
- <u-image src="/static/images/device/up_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- <view class="subTime" @click="subTemperatureTime">
- <u-image src="/static/images/device/down_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- </view>
- </view>
- </view>
- <!-- 下边部份 -->
- <view class="decoctControlTop" style="height: 220rpx">
- <!-- 左边 -->
- <view class="decoctControlTopLeft" style="width: 30%">
- <text>当前温度</text>
- <u-input placeholder="0" disabled :value="currentTemperature+'℃'"></u-input>
- </view>
- <!-- 右边 -->
- <view class="decoctControlTopRight" style="width: 30%">
- <text>高温时间</text>
- <u-input placeholder="0" disabled :value="hightTemperature+'min'"></u-input>
- </view>
- <view class="decoctControlTopRight" style="width: 30%">
- <text>剩余时间</text>
- <u-input placeholder="0" disabled :value="leftJianyaoTime+'min'"></u-input>
- </view>
- </view>
- </view>
- <!-- 尾部 -->
- <view>
- <!-- 上边 -->
- <view class="decoctControlBottom" >
- <!-- 左边 -->
- <view>
- <text>开关状态</text>
- </view>
- <!-- 右边 -->
- <view style="display: flex;align-items: center">
- <text style="margin-right: 15px" v-if="decoctControlOnOffStatus">已开机</text>
- <text style="margin-right: 15px" v-if="!decoctControlOnOffStatus">未开机</text>
- <u-switch v-model="decoctControlOnOffStatus" @change="decoctControlOnOffChange"></u-switch>
- </view>
- </view>
- <!-- 下边 -->
- <view class="decoctControlBottom">
- <!-- 左边 -->
- <view>
- <text v-if="decoctControlStatus">煎药状态</text>
- <text v-else>
- <text>
- 煎药状态
- </text>
- <text v-if="leftAppointmentTime>0" style="font-size: 10px">
- (已预约,开启煎药后进入倒计时)
- </text>
- </text>
- </view>
- <!-- 右边 -->
- <view style="display: flex;align-items: center">
- <text style="margin-right: 15px" v-if="!decoctControlStatus">
- 未煎药</text>
- <text v-else>
- <text style="margin-right: 15px" v-if="leftAppointmentTime == 0">煎药中</text>
- <text style="margin-right: 15px" v-if="leftAppointmentTime >0">已预约,剩余{{leftAppointmentTime}}分钟</text>
- </text>
- <u-switch v-model="decoctControlStatus" @change="decoctControlChange"></u-switch>
- </view>
- </view>
- </view>
- </view>
- <!-- 包装控制 -->
- <view class="demo-uni-row" v-if="!firstTab">
- <view class="demo-uni-row clearfix">
- <view style="clear: both"></view>
- </view>
- <!-- 头部 -->
- <view class="decoctControlHeader">
- <uni-icons custom-prefix="iconfont" type="icon-fuzhushuxian" size="30"></uni-icons>
- <text>包装控制</text>
- </view>
- <!-- 腰部 -->
- <view>
- <!-- 上边部份 -->
- <view class="decoctControlTop" style="margin:0 30rpx">
- <!-- 左边 -->
- <view class="decoctControlTopLeft" style="width: 23%;margin:0 5px;">
- <view>封边温度</view>
- <view class="control-input-box">
- <view style="width: 80px">
- <u-input placeholder="请输入" @change="changeEdegTemperature" v-model="setEdegTemperature"></u-input>
- </view>
- <view class="control-input-box-danwei">℃</view>
- </view>
- <view class="addTemperature baozhuang-add" @click="addEdegTemperature">
- <u-image src="/static/images/device/up_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- <view class="subTime baozhuang-sub" @click="subEdegTemperature">
- <u-image src="/static/images/device/down_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- </view>
- <!-- 右边 -->
- <view class="decoctControlTopLeft" style="width: 23%;margin:0 5px;">
- <view>封口温度</view>
- <view class="control-input-box">
- <view style="width: 80px">
- <u-input placeholder="请输入" @change="changeSealingTemperature" v-model="setSealingTemperature"></u-input>
- </view>
- <view class="control-input-box-danwei">℃</view>
- </view>
- <view class="addTemperature baozhuang-add" @click="addSealingTemperature">
- <u-image src="/static/images/device/up_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- <view class="subTime baozhuang-sub" @click="subSealingTemperature">
- <u-image src="/static/images/device/down_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- </view>
- <view class="decoctControlTopLeft" style="width: 23%;margin:0 5px;">
- <view>包装容量</view>
- <view class="control-input-box">
- <view style="width: 80px">
- <u-input placeholder="请输入" @change="changePackageVolume" :value="packageVolume"></u-input>
- </view>
- <view class="control-input-box-danwei">ml</view>
- </view>
- <view class="addTemperature baozhuang-add" @click="addPackageVolume">
- <u-image src="/static/images/device/up_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- <view class="subTime baozhuang-sub" @click="subPackageVolume">
- <u-image src="/static/images/device/down_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- </view>
- <!-- 右边 -->
- <view style="width:23%;line-height: 2;text-align: center;margin: 0 1px;position: relative">
- <view>包装数量</view>
- <view class="control-input-box">
- <view style="width: 80px">
- <u-input placeholder="请输入" @change="changePackageNumber" :value="packageNumber"></u-input>
- </view>
- <view class="control-input-box-danwei">个</view>
- </view>
- <view class="addTemperature baozhuang-add" @click="addPackageNumber">
- <u-image src="/static/images/device/up_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- <view class="subTime baozhuang-sub" @click="subPackageNumber">
- <u-image src="/static/images/device/down_btn.png" width="60rpx" height="60rpx"></u-image>
- </view>
- </view>
- </view>
- <!-- 下边部份 -->
- <view class="decoctControlTop">
- <view class="decoctControlTopLeft" style="width: 40%">
- <text>当前封边温度</text>
- <u-input placeholder="0" disabled :value="edegTemperature+'℃'"></u-input>
- </view>
- <!-- 右边 -->
- <view class="decoctControlTopRight" style="width: 40%">
- <text>当前封口温度</text>
- <u-input placeholder="0" disabled :value="sealingTemperature+'℃'"></u-input>
- </view>
- </view>
- </view>
- <!-- 尾部 -->
- <view>
- <!-- 上边 -->
- <view class="decoctControlBottom">
- <!-- 左边 -->
- <view>
- <text>开关</text>
- </view>
- <!-- 右边 -->
- <view style="display: flex;align-items: center">
- <text style="margin-right: 15px" v-if="decoctControlOnOffStatus">已开机</text>
- <text style="margin-right: 15px" v-if="!decoctControlOnOffStatus">未开机</text>
- <u-switch v-model="decoctControlOnOffStatus" @change="decoctControlOnOffChange"></u-switch>
- </view>
- </view>
- <view class="decoctControlBottom">
- <!-- 左边 -->
- <view>
- <text>启停开关</text>
- </view>
- <!-- 右边 -->
- <view style="display: flex;align-items: center">
- <text style="margin-right: 15px" v-if="!qitingTurn">未开启</text>
- <text style="margin-right: 15px" v-if="qitingTurn">已开启</text>
- <u-switch v-model="qitingTurn" @change="turnChange(1)"></u-switch>
- </view>
- </view>
- <view class="decoctControlBottom">
- <!-- 左边 -->
- <view>
- <text>包装开关</text>
- </view>
- <!-- 右边 -->
- <view style="display: flex;align-items: center">
- <text style="margin-right: 15px" v-if="!baozhuangTurn">未开启</text>
- <text style="margin-right: 15px" v-if="baozhuangTurn">已开启</text>
- <u-switch v-model="baozhuangTurn" @change="turnChange(2)"></u-switch>
- </view>
- </view>
- <view class="decoctControlBottom">
- <!-- 左边 -->
- <view>
- <text>清洗开关</text>
- </view>
- <!-- 右边 -->
- <view style="display: flex;align-items: center">
- <text style="margin-right: 15px" v-if="!qingxiTurn">未开启</text>
- <text style="margin-right: 15px" v-if="qingxiTurn">已开启</text>
- <u-switch v-model="qingxiTurn" @change="turnChange(3)"></u-switch>
- </view>
- </view>
- <!-- <!– 下边 –>-->
- <!-- <view class="decoctControlBottom">-->
- <!-- <!– 左边 –>-->
- <!-- <view>-->
- <!-- <text>模式</text>-->
- <!-- </view>-->
- <!-- <!– 右边 –>-->
- <!-- <view style="display: flex;align-items: center">-->
- <!-- <text class="packageControlBottomRight">包装</text>-->
- <!-- <text class="packageControlBottomClear">清洗</text>-->
- <!-- </view>-->
- <!-- </view>-->
- </view>
- </view>
- <view class="action-btn">
- <button @click="showDrawer" class="login-btn cu-btn block bg-blue lg round" style="flex: 0 0 auto;width: 55%;margin: 0 auto;margin-top:20px;">高级设置</button>
- </view>
- <uni-drawer ref="showLeft" :width="320" :maskClick="true" mode="left" @change="change($event,'showLeft')">
- <!-- <view class="item" style="padding-top:10rpx">-->
- <!-- <u-button v-if="deviceInfo.status==3"-->
- <!-- @tap="send(item)"-->
- <!-- text="发送"-->
- <!-- type="success"-->
- <!-- size="mini"-->
- <!-- ></u-button>-->
- <!-- <u-button v-if="deviceInfo.status!=3"-->
- <!-- @tap="send(item)"-->
- <!-- text="发送"-->
- <!-- type="info"-->
- <!-- size="mini"-->
- <!-- ></u-button>-->
- <!-- </view>-->
- <scroll-view style="height: 88%;" scroll-y="true">
- <view>
- <view class="prop-item" v-if="firstTab">
- <view class="prop-item-left">温度校准</view>
- <view class="prop-item-right">
- <view style="width:120rpx;position: absolute;top:0rpx;">
- <button @click="temperNumber" class="login-btn cu-btn block bg-blue lg round send_btn">点击校准</button>
- </view>
- </view>
- </view>
- <view class="prop-item" v-if="!firstTab">
- <view class="prop-item-left">容量校准</view>
- <view class="prop-item-right">
- <view style="width:120rpx;position: absolute;top:0rpx;">
- <button @click="volumeNumber" class="login-btn cu-btn block bg-blue lg round send_btn">点击校准</button>
- </view>
- </view>
- </view>
- <view class="prop-item">
- <view class="prop-item-left">恢复出厂</view>
- <view class="prop-item-right">
- <view style="width:120rpx;position: absolute;top:0rpx;">
- <button @click="reset" class="login-btn cu-btn block bg-blue lg round send_btn">点击恢复</button>
- </view>
- </view>
- </view>
- <view class="prop-item" v-if="firstTab">
- <view class="prop-item-left">工作模式</view>
- <view class="prop-item-right">
- <view style="width:320rpx;position: absolute;top:0rpx;">
- <view style="display: flex;align-items: center">
- <text @click="setMode(1)" class="packageControlBottomClear" :class="workMode == 1?'active_btn':''" style="font-size: 10px;width: 50rpx;margin-right:5px">模式1</text>
- <text @click="setMode(2)" class="packageControlBottomClear" :class="workMode == 2?'active_btn':''" style="font-size: 10px;width: 50rpx;margin-right:5px">模式2</text>
- <text @click="setMode(3)" class="packageControlBottomClear" :class="workMode == 3?'active_btn':''" style="font-size: 10px;width: 50rpx;margin-right:5px">模式3</text>
- </view>
- </view>
- </view>
- </view>
- <view class="prop-item" v-if="firstTab">
- <view class="prop-item-left">预约时间</view>
- <view class="prop-item-right">
- <view style="width:320rpx;position: absolute;top:0rpx;">
- <view style="display: flex;align-items: center">
- <view v-if="leftAppointmentTime>0" style=" width:600rpx; left: -28%;position: absolute;top:0rpx;display:flex;margin-top: 5px;font-size: 12px;">
- 预约剩余时间:{{leftAppointmentTime}}min
- <button @click="cancelPlan" class="login-btn cu-btn block bg-blue lg round " style="margin-top:0px;width: 160rpx;height: 40rpx ;
- font-size: 10px ;margin-left:5px">取消预约</button>
- </view>
- <view v-if="leftAppointmentTime==0" style="width:300rpx;position: absolute;top:0rpx;display: flex;flex-direction: row">
- <u-input customStyle="position: relative;width: 50px;left: 0px;top:5px;height: 40rpx;" placeholder="请输入" v-model="planTime"></u-input>
- <view style="margin-top: 6px;">min</view>
- <button @click="plan" class="login-btn cu-btn block bg-blue lg round " style="margin-left:10rpx;width: 160rpx;height: 40rpx ;
- font-size: 10px ;
- margin-top: 5px;">预约煎药</button>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="prop-item">
- <view class="prop-item-left">锁定设备</view>
- <view class="prop-item-right">
- <view style="width:320rpx;position: absolute;top:0rpx;">
- <view style="display: flex;align-items: center">
- <view v-if="lock.value == 0" style="margin-top: 4px;">
- <text class="packageControlBottomClear" style="font-size: 10px;width: 70rpx;margin-right:5px">未锁定</text>
- <text @click="lockCtrl(0)" class="packageControlBottomRight" style="font-size: 10px;width: 70rpx;margin-right:5px">点击锁定</text>
- </view>
- <view v-if="lock.value == 1" style="margin-top: 4px;">
- <text class="packageControlBottomClear" style="font-size: 10px;width: 70rpx;margin-right:5px;background: darkred">已锁定</text>
- <text @click="lockCtrl(1)" class="packageControlBottomClear" style="font-size: 10px;width: 70rpx;margin-right:5px;background: #EC6D2F">点击解锁</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- <button @click="closeDrawer" class="login-btn cu-btn block bg-blue lg round">关闭</button>
- </uni-drawer>
- </view>
- </view>
- </view>
- <u-picker @cancel="show=null" :show="show!=null" :columns="columns" @confirm="confirmItemData" keyName="text"></u-picker>
- <u-modal @cancel="cancel" :show="showErrDlg" title="异常上报" :showCancelButton="true" @confirm="doReportError" >
- <view class="slot-content">
- <view style="margin:10px">
- <textarea auto-height ="true" v-model="errorMsg" placeholder="请输入异常内容" ></textarea>
- </view>
- </view>
- </u-modal>
- <!-- <u-modal :show="showTimeDlg" title="查看时长" @confirm="closeTime" >-->
- <!-- <view class="slot-content">-->
- <!-- <view v-if="timeobj!=null && deviceInfo.status == 3">本次运行时长:{{ timeobj.runtime }}</view>-->
- <!-- <view v-if="timeobj!=null ">累计时长:{{ timeobj.alltime }}</view>-->
- <!-- <view v-if="timeobj!=null ">平均每天运行时长:{{ timeobj.avgtime }}</view>-->
- <!-- </view>-->
- <!-- </u-modal>-->
- </view>
- </view>
- </template>
- <script>
- import { getDetail,getDeviceStatus,cacheJsonThingsModel,reportError ,getDeviceRunTime} from '@/api/device/device.js'
- import UButton from "../../uni_modules/uview-ui/components/u-button/u-button";
- import UForm from "../../uni_modules/uview-ui/components/u--form/u--form";
- import UInput from "../../uni_modules/uview-ui/components/u--input/u--input";
- import UImage from "../../uni_modules/uview-ui/components/u--image/u--image";
- export default {
- components: {UImage, UInput, UForm, UButton},
- data(){
- return {
- planTime:10,
- setSealingTemperature:160,
- setEdegTemperature:160,
- sealingTemperature:0,
- edegTemperature:0,
- hightTemperature:0,
- currentTemperature:0,
- temperatureTime:0,
- temperature:0,
- packageNumber:0,
- packageVolume:50,
- firstTab:true,
- decoctControlStatus:false,
- decoctControlOnOffStatus:false,
- packageControlOnOffStatus:false,
- subDecoctTabList:[
- {name:'子煎药1'},
- {name:'子煎药2'},
- {name:'子煎药3'},
- ],
- DecoctControlStatus:false,
- PackagControlStatus:false,
- baozhuangTurn:false,
- qitingTurn:false,
- qingxiTurn:false,
- subCurrent:0,
- current:0,
- inputStyle:{height:'44rpx','fontSize':'20rpx'},
- modelKey:['PowerControl','LockControl'],
- jianyaoKeys : ["TempSetting","TimeSetting"],
- baozhuangKeys:["SetSealTemp","SetBandingTemp","PackageQuantity","PackingVolume"],
- power:{
- loading:true,
- value:0,
- },
- lock:{
- loading:true,
- value:0,
- },
- showTimeDlg:false,
- showErrDlg:null,
- errorMsg:"asdasdasdasd",
- show:null,
- value:"",
- deviceInfo:{},
- id:0,
- summary:[
- ],
- tabs:[
- {tabName:"煎药控制"},
- {tabName:"包装控制"},
- ],
- activeName:0,
- childId:0,
- oneToMul:false,
- inputProp:[],
- watchProp:[],
- columns:[],
- location:{},
- sysDept:null,
- timeobj:{alltime:0,avgtime:0},
- publishMsg:false,
- checkTimer:null,
- functions:[],
- properties:[],
- propMap:{},
- jianyaoTimer:null,
- baozhuangTimer:null,
- editing:false,
- workMode:1,
- leftAppointmentTime:0,
- leftJianyaoTime:0,
- }
- },
- onLoad: function(opt) {
- this.id = opt.id;
- // this.id = 61;
- this.connectMqtt();
- this.getDetail();
- },
- destroyed() {
- // 取消订阅主题
- this.mqttUnSubscribe(this.deviceInfo);
- clearTimeout(this.checkTimer);
- },
- methods:{
- changePackageVolume(){
- if(this.packageVolume<50){
- this.packageVolume = 50;
- }
- if(this.packageVolume>300){
- this.packageVolume = 300;
- }
- this.sendBaozhuang("PackingVolume");
- },
- changePackageNumber(){
- let min = 1;
- let max = 999;
- if(this.packageNumber<min){
- this.packageNumber = min;
- }
- if(this.packageNumber>max){
- this.packageNumber = max;
- }
- this.sendBaozhuang("PackageQuantity");
- },
- changeEdegTemperature(){
- let min = 80;
- let max = 220;
- if(this.setEdegTemperature<min){
- this.setEdegTemperature = min;
- }
- if(this.setEdegTemperature>max){
- this.setEdegTemperature = max;
- }
- console.log("current setEdegTemperature is :"+this.setEdegTemperature)
- this.sendBaozhuang("SetBandingTemp");
- },
- changeSealingTemperature(){
- let min = 80;
- let max = 220;
- if(this.setSealingTemperature<min){
- this.setSealingTemperature = min;
- }
- if(this.setSealingTemperature>max){
- this.setSealingTemperature = max;
- }
- console.log("current setSealingTemperature is :"+this.setSealingTemperature)
- this.sendBaozhuang("SetSealTemp");
- },
- changeTemperature(){
- let max = 140;
- let min = 100;
- if(this.workMode == 2){
- min = 1;
- }
- if(this.temperature<min){
- this.temperature = min;
- }
- if(this.temperature>max){
- this.temperature = max;
- }
- console.log("current temperature is :"+this.temperature)
- this.sendJianYao("TempSetting");
- },
- changeTemperatureTime(){
- let min = 1;
- let max = 600;
- if(this.temperatureTime<min){
- this.temperatureTime = min;
- }
- if(this.temperatureTime>max){
- this.temperatureTime = max;
- }
- console.log("current temperatureTime is :"+this.temperatureTime)
- this.sendJianYao("TimeSetting");
- },
- cancelPlan(){
- let arr = [];
- let obj = {};
- obj.id = "AppointmentTime";
- obj.shadow = 0;
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr,true);
- },
- plan(){
- let self = this;
- if(this.planTime>600){
- this.$modal.showToast('预约时间最大为600分钟')
- return;
- }
- if(this.planTime == 0){
- this.$modal.showToast('预约时间不能为空')
- }else{
- let arr = [];
- let obj = {};
- obj.id = "AppointmentTime";
- obj.shadow = this.planTime;
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr,true);
- }
- },
- lockCtrl(key){
- let arr = [];
- let obj = {};
- obj.id = "LockControl";
- if(key == 0){
- obj.shadow = 1;
- this.lock.value = 1;
- }else{
- obj.shadow = 0;
- this.lock.value = 0;
- }
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr)
- },
- setMode(type){
- let arr = [];
- let obj = {};
- obj.id = "WorkMode";
- obj.shadow = type;
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr,true)
- this.workMode = type;
- },
- temperNumber(){
- let arr = [];
- let obj = {};
- obj.id = "CalibrationTemp";
- obj.shadow = 1;
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr,true)
- },
- volumeNumber(){
- let arr = [];
- let obj = {};
- obj.id = "CapacityCalibration";
- obj.shadow = 1;
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr,true)
- },
- reset(){
- let arr = [];
- let obj = {};
- obj.id = "RestoreFactory";
- obj.shadow = 1;
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr)
- },
- turnChange(type){
- let flag = false;
- let obj = {};
- if(type ==3){
- if(this.baozhuangTurn || this.qitingTurn){
- this.$modal.showToast("启停、包装、清洗不能同时打开")
- this.qingxiTurn = !this.qingxiTurn;
- return;
- }
- flag = this.qingxiTurn;
- obj.id = "WashSwitch";
- }else if(type == 2){
- if(this.qingxiTurn || this.qitingTurn){
- this.$modal.showToast("启停、包装、清洗不能同时打开")
- this.baozhuangTurn = !this.baozhuangTurn;
- return;
- }
- flag = this.baozhuangTurn;
- obj.id = "PackageSwitch";
- }else if(type == 1) {
- if(this.qingxiTurn || this.baozhuangTurn){
- this.$modal.showToast("启停、包装、清洗不能同时打开")
- this.qitingTurn = !this.qitingTurn;
- return;
- }
- flag = this.qitingTurn;
- obj.id = "CarrybagSwitch";
- }
- let arr = [];
- if(flag){
- obj.shadow = 1;
- }else{
- obj.shadow = 0;
- }
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr)
- },
- addPackageVolume(){
- this.packageVolume++;
- console.log("增加包装容量")
- this.changePackageVolume()
- },
- subPackageVolume(){
- this.packageVolume--;
- console.log("减少包装容量")
- this.changePackageVolume()
- },
- addPackageNumber(){
- this.packageNumber++;
- console.log("增加包装数量")
- this.changePackageNumber();
- },
- subPackageNumber(){
- this.packageNumber--;
- console.log("减少包装数量")
- this.changePackageNumber();
- },
- addSealingTemperature(){
- console.log("增加封口温度")
- this.setSealingTemperature++;
- this.changeSealingTemperature();
- },
- subSealingTemperature(){
- console.log("减少封口温度")
- this.setSealingTemperature--;
- this.changeSealingTemperature();
- },
- addEdegTemperature(){
- console.log("增加封边温度")
- this.editing = true;
- this.setEdegTemperature++;
- this.changeEdegTemperature();
- },
- subEdegTemperature(){
- console.log("减少封边温度")
- this.editing = true;
- this.setEdegTemperature--;
- this.changeEdegTemperature();
- },
- addTemperatureTime(){
- console.log("增加煎药时间")
- this.temperatureTime++;
- this.changeTemperatureTime()
- },
- subTemperatureTime(){
- console.log("减少煎药时间")
- this.temperatureTime--;
- this.changeTemperatureTime()
- },
- addTemperature(){
- console.log("增加煎药温度")
- this.temperature++;
- this.changeTemperature();
- },
- subTemperature(type){
- console.log("减少煎药温度")
- this.temperature--;
- this.changeTemperature();
- },
- sendBaozhuang(targetKey){
- let self = this;
- let arr = [];
- if(this.baozhuangTimer != null){
- clearTimeout(this.baozhuangTimer);
- }
- this.baozhuangTimer = setTimeout(function (){
- for (let i = 0; i <this.baozhuangKeys.length; i++) {
- let key = this.baozhuangKeys[i];
- let obj = {};
- obj.id = key;
- if(key === "PackingVolume"){
- obj.shadow = this.packageVolume;
- }
- if(key === "PackageQuantity"){
- obj.shadow = this.packageNumber;
- }
- if(key === "SetSealTemp"){
- obj.shadow = this.setSealingTemperature;
- }
- if(key === "SetBandingTemp"){
- obj.shadow = this.setEdegTemperature;
- }
- if(targetKey == key){
- arr.push(obj);
- break;
- }
- }
- this.mqttPublish(2,this.deviceInfo,arr)
- }.bind(this),500);
- },
- sendJianYao(targetKey){
- let arr = [];
- if(this.jianyaoTimer != null){
- clearTimeout(this.jianyaoTimer);
- }
- this.jianyaoTimer = setTimeout(function (){
- for (let i = 0; i <this.jianyaoKeys.length; i++) {
- let key = this.jianyaoKeys[i];
- let obj = {};
- obj.id = key;
- if(key === "TempSetting"){
- obj.shadow = this.temperature;
- }
- if(key === "TimeSetting"){
- obj.shadow = this.temperatureTime;
- }
- if(targetKey == key){
- arr.push(obj);
- break;
- }
- }
- this.mqttPublish(2,this.deviceInfo,arr,true)
- }.bind(this),500);
- },
- buildPropKey(key){
- if(this.childId !=0){
- return key+"_"+this.childId;
- }else{
- return key;
- }
- },
- decoctControlChange(){
- let obj = {};
- let arr = [];
- obj.id = "DecoctingSwitch";
- if(this.decoctControlStatus){
- obj.shadow = 1;
- console.log("煎药状态打开")
- }else{
- obj.shadow = 0;
- console.log("煎药状态关闭")
- }
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr,true)
- },
- decoctControlOnOffChange(){
- let obj = {};
- let arr = [];
- obj.id = "PowerControl";
- let isMul = false;
- if(this.decoctControlStatus){
- this.$modal.showToast('请先结束煎药后,再开机')
- this.decoctControlOnOffStatus = !this.decoctControlOnOffStatus;
- return;
- }
- if(this.oneToMul && this.firstTab){
- obj.id = "PowerCtl";
- isMul = true;
- }
- if(this.decoctControlOnOffStatus){
- obj.shadow = 1;
- console.log("煎药机开关打开")
- }else{
- obj.shadow = 0;
- console.log("煎药机开关关闭")
- }
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr,isMul)
- },
- packageControlOnOffChange(){
- let obj = {};
- let arr = [];
- obj.id = "DecoctingSwitch";
- if(this.packageControlOnOffStatus){
- obj.shadow = 1;
- console.log("包装控制打开")
- }else{
- obj.shadow = 0;
- console.log("包装控制关闭")
- }
- arr.push(obj);
- this.mqttPublish(2,this.deviceInfo,arr)
- },
- containKey(arr,key){
- for (let i = 0; i < arr.length; i++) {
- const data = arr[i];
- if(data == key){
- return true;
- }
- }
- return false;
- },
- // 抽屉状态发生变化触发
- change(e, type) {
- console.log(e);
- },
- showDrawer() {
- this.$refs.showLeft.open();
- },
- closeDrawer() {
- this.$refs.showLeft.close();
- },
- checkItemValue(item){
- if(!item.shadow){
- item.shadow = 0;
- }
- if(!item.unit){
- item.unit = "";
- }
- return true;
- },
- sendProperties(){
- let properties = this.properties;
- for (let i = 0; i < properties; i++) {
- let property = this.properties[i];
- let shadow = property.shadow;
- if(shadow){
- arr.push(property);
- }
- }
- this.mqttPublish(1,this.deviceInfo,arr)
- },
- sendFunctions(){
- let arr = [];
- let functions = this.functions;
- for (let i = 0; i < functions.length; i++) {
- let functionObj = this.functions[i];
- let shadow = functionObj.shadow;
- if(shadow){
- arr.push(functionObj);
- }
- }
- this.mqttPublish(2,this.deviceInfo,arr)
- },
- changeProp(key,val){
- let item = null;
- let obj = null;
- let oneToMul = this.oneToMul;
- if(key === "LockControl"){
- this.lock.value = val;
- item = this.lock;
- }else if(key === "PowerControl"){
- this.power.value = val;
- item = this.power;
- }
- let value = val;
- obj = item.item;
- if(value){
- obj.value = 1;
- obj.shadow = 1;
- }else{
- obj.value = 0;
- obj.shadow = 0;
- }
- if(!oneToMul){
- }
- this.publishThingsModel(this.deviceInfo,obj);
- },
- checkCommonProp(item){
- let id =item.id;
- let isCommonKey = this.modelKey.some(res=>{
- return id === res;
- })
- return !isCommonKey;
- },
- getRunTime(){
- let self = this;
- getDeviceRunTime(this.id).then(res=>{
- self.timeobj = res.data;
- if(self.timeobj.avgtime == ""){
- self.timeobj.avgtime = 0;
- }
- if(self.timeobj.alltime == ""){
- self.timeobj.alltime = 0;
- }
- })
- },
- seeTime(){
- this.showTimeDlg = true;
- this.getRunTime();
- },
- closeTime(){
- this.showTimeDlg = false;
- },
- cancel(){
- this.showErrDlg = false;
- },
- reportError(){
- this.showErrDlg = true;
- },
- doReportError(){
- if(!this.errorMsg){
- this.$modal.showToast('异常信息不能为空')
- }else{
- let self = this;
- let errObj = {};
- errObj.deviceId = this.deviceInfo.deviceId;
- errObj.deviceName = this.deviceInfo.deviceName
- errObj.desc = this.errorMsg;
- errObj.deptId= this.deviceInfo.deptId;
- reportError(errObj).then(res=>{
- self.$modal.showToast(res.msg)
- self.cancel();
- })
- }
- },
- openLocation(){
- uni.openLocation({
- latitude: this.location.latitude,
- longitude: this.location.longitude,
- success: function () {
- console.log('success');
- }
- });
- },
- confirmItemData(e){
- let data = e.value[0];
- this.show.text = data.text;
- this.show.shadow=data.value;
- this.show = null;
- console.log(data);
- },
- send(){
- let shadow = false
- let _arr = []
- this.inputProp.forEach((item)=>{
- _arr.push(item.value)
- })
- // if(_arr.some(val => val === '' || val.length < 0)){
- // shadow = true
- // }
- if(this.deviceInfo.status != 3){
- uni.showToast({
- title:"设备暂未上线",
- icon:"error"
- })
- return;
- }
- if(shadow){
- uni.showToast({
- title:"数据不能为空",
- icon:"error"
- })
- return;
- }
- this.publishThingsModel(this.deviceInfo,this.inputProp.map(item=>{return{"id":item.id,"value":item.value}}))
- },
- /** 更新设备状态 */
- updateDeviceStatus(device) {
- },
- chooseItemData(data){
- if(this.deviceInfo.status != 3){
- uni.showToast({
- title:"设备暂未上线",
- icon:"error"
- })
- return;
- }
- this.columns = [data.enumList];
- this.show =data;
- },
- getDetail(){
- let self = this;
- getDetail(this.id).then(res=>{
- self.deviceInfo = res.data;
- self.location = {
- latitude: self.deviceInfo.latitude,
- longitude: self.deviceInfo.longitude};
- self.sysDept = self.deviceInfo.sysDept;
- self.parseSummay(res.data.summary)
- self.mqttSubscribe(res.data);
- self.getDeviceStatus();
- self.seeTime();
- });
- },
- getDeviceStatus(){
- let self = this;
- if(this.summary.length>1){
- }else{
- this.childId = 0;
- }
- getDeviceStatus(this.id,this.childId).then(res=>{
- let data =res.data;
- this.deviceInfo = data;
- self.parseStatusData(data)
- });
- },
- getNewDeviceStatus(item){
- console.log(item);
- let self = this;
- if(item.index == 0){
- this.firstTab = true;
- this.getDeviceStatus();
- }
- if(item.index == 1){
- this.firstTab = false;
- getDeviceStatus(this.id,0).then(res=>{
- let data =res.data;
- this.deviceInfo = data;
- self.parseStatusData(data)
- });
- }
- },
- changeSub(item){
- this.childId = item.id;
- this.getDeviceStatus()
- },
- parseEnumList(){
- let enumList = this.deviceInfo.enumList;
- for (let enumListElement of enumList) {
- let id = enumListElement.id;
- if(id.indexOf("LockControl") !=-1){
- let shadow = enumListElement.shadow;
- this.lock.item = enumListElement;
- if(shadow == 1){
- this.lock.value = true;
- this.lock.loading = false;
- }else if(shadow == 0){
- this.lock.value = false;
- this.lock.loading = false;
- }else{
- this.lock.loading = true;
- }
- }
- if(id.indexOf("PowerControl") !=-1){
- let shadow = enumListElement.shadow;
- if(this.oneToMul){
- if(!this.firstTab){
- if(shadow == 1){
- this.decoctControlOnOffStatus = true;
- }else if(shadow == 0){
- this.decoctControlOnOffStatus = false;
- }
- }
- }else{
- if(shadow == 1){
- this.decoctControlOnOffStatus = true;
- }else if(shadow == 0){
- this.decoctControlOnOffStatus = false;
- }
- }
- }
- if(id.indexOf("PowerCtl") !=-1){
- if(this.oneToMul && this.firstTab){
- let shadow = enumListElement.shadow;
- if(shadow == 1){
- this.decoctControlOnOffStatus = true;
- }else if(shadow == 0){
- this.decoctControlOnOffStatus = false;
- }
- }
- }
- this.formatValue(id,enumListElement,"DecoctingSwitch","decoctControlStatus")
- this.formatValue(id,enumListElement,"CarrybagSwitch","qitingTurn")
- this.formatValue(id,enumListElement,"WashSwitch","qingxiTurn")
- this.formatValue(id,enumListElement,"PackageSwitch","baozhuangTurn");
- if(id.indexOf("WorkMode") !=-1){
- let shadow = enumListElement.shadow;
- if(!shadow){
- shadow = 1;
- }
- this.workMode = shadow;
- }
- let shadow = enumListElement.shadow
- let valueList = enumListElement.enumList;
- for (let valueObj of valueList){
- if(valueObj.value == shadow){
- enumListElement.text = valueObj.text;
- }
- }
- }
- },
- formatValue(id,enumListElement,key,propkey){
- if(id.indexOf(key) !=-1){
- let shadow = enumListElement.shadow;
- if(shadow == 1){
- this[propkey] = true;
- }else if(shadow == 0){
- this[propkey] = false;
- }
- }
- },
- parseStatusData(data){
- let self = this;
- cacheJsonThingsModel(data.productId).then(res=>{
- let thingsModel = JSON.parse(res.data);
- let arr = [];
- let arrayList = data.arrayList;
- arr = arr.concat(arrayList);
- let enumList = data.enumList;
- arr = arr.concat(enumList);
- let integerList = data.integerList;
- arr = arr.concat(integerList);
- let stringList = data.stringList;
- arr = arr.concat(stringList);
- self.inputProp = arr;
- for (let i = 0; i < thingsModel.functions.length; i++) {
- for (let j = 0; j < arr.length; j++) {
- let model = arr[j];
- if(model.id == thingsModel.functions[i].id){
- self.functions.push(model);
- }
- }
- }
- for (let i = 0; i < thingsModel.properties.length; i++) {
- for (let j = 0; j < arr.length; j++) {
- let model = arr[j];
- if(model.id == thingsModel.properties[i].id){
- self.properties.push(model);
- }
- }
- }
- let readOnlyList = data.readOnlyList;
- self.watchProp = readOnlyList;
- self.parseEnumList();
- self.parseProp();
- })
- },
- parseProp(){
- let self = this;
- for (let i = 0; i <self.inputProp.length; i++) {
- let prop = self.inputProp[i];
- let value = prop.shadow||0;
- let id = prop.id;
- if(id === "TimeSetting"){//温度设置
- self.temperatureTime = value;
- }
- if(id === "TempSetting"){
- self.temperature = value;
- }
- this.setPropValue(id,"PackingVolume","packageVolume",value,50)
- this.setPropValue(id,"PackageQuantity","packageNumber",value,1)
- this.setPropValue(id,"SealTemp","sealingTemperature",value)
- this.setPropValue(id,"BandingTemp","edegTemperature",value)
- this.setPropValue(id,"SetSealTemp","setSealingTemperature",value,160)
- this.setPropValue(id,"SetBandingTemp","setEdegTemperature",value,160)
- this.setPropValue(id,"LeftAppointmentTime","leftAppointmentTime",value,0)
- self.propMap[id] = prop;
- }
- },
- setPropValue(id,key,propKey,value,defaultValue){
- if(!value && defaultValue){
- value = defaultValue;
- }
- if(id === key){
- this[propKey] = value;
- }
- },
- parseSummay(summary){
- let self = this;
- if(!summary){
- summary = "";
- }
- if(summary.length>0){
- this.summary = JSON.parse(summary);
- if(self.summary.length>0){
- this.oneToMul = true;
- for (let i = 0; i < self.summary.length; i++) {
- self.summary[i].tabName = self.summary[i].id+"_"+self.summary[i].name
- }
- let childId = "";
- if(this.oneToMul){
- this.childId = self.summary[0].id;
- }
- }else{
- this.summary = [{name:"详情查看"}]
- }
- }else{
- this.summary = [{name:"详情查看"}]
- }
- },
- goDeviceDetail(id){
- uni.navigateTo({
- url: '/pages/device/detail/detail?id='+id
- });
- },
- async connectMqtt() {
- if (this.$mqttTool.client == null) {
- await this.$mqttTool.connect(this.vuex_token);
- }
- this.mqttCallback();
- this.startCheck();
- },
- /** Mqtt订阅主题 */
- mqttSubscribe(device) {
- // 订阅当前设备状态和实时监测
- let topicStatus = '/' + device.productId + '/' + device.serialNumber + '/status/post';
- let topicProperty = '/' + device.productId + '/' + device.serialNumber + '/property/post';
- let topicFunction = '/' + device.productId + '/' + device.serialNumber + '/function/post';
- let topics = [];
- topics.push(topicStatus);
- topics.push(topicProperty);
- topics.push(topicFunction);
- this.$mqttTool.subscribe(topics);
- },
- /** Mqtt取消订阅主题 */
- mqttUnSubscribe(device) {
- // 订阅当前设备状态和实时监测
- let topicStatus = '/' + device.productId + '/' + device.serialNumber + '/status/post';
- let topicProperty = '/' + device.productId + '/' + device.serialNumber + '/property/post';
- let topicFunction = '/' + device.productId + '/' + device.serialNumber + '/function/post';
- let topics = [];
- topics.push(topicStatus);
- topics.push(topicProperty);
- topics.push(topicFunction);
- console.log('取消订阅', topics);
- this.$mqttTool.unsubscribe(topics);
- },
- /* Mqtt回调处理 */
- mqttCallback() {
- this.$mqttTool.client.on('message', (topic, message, buffer) => {
- let topics = topic.split('/');
- let productId = topics[1];
- let deviceNum = topics[2];
- console.log('接收到内容:'+message);
- message = JSON.parse(message.toString());
- if (topics[3] == 'status') {
- console.log('接收到【设备状态-运行】主题:', topic);
- console.log('接收到【设备状态-运行】内容:', message);
- // 更新列表中设备的状态
- if (this.deviceInfo.serialNumber == deviceNum) {
- this.deviceInfo.status = message.status;
- this.deviceInfo.isShadow = message.isShadow;
- this.deviceInfo.rssi = message.rssi;
- this.updateDeviceStatus(this.deviceInfo);
- }
- }
- if (topics[3] == 'property' || topics[3] == 'function') {
- console.log('接收到【物模型】主题:', topic);
- console.log('接收到【物模型】内容:', message);
- if(this.oneToMul){
- let curTabId = this.childId;
- let msg = [];
- for (let i = 0; i < message.length; i++) {
- let curMsg = message[i];
- let id = curMsg.id;
- let ids = id.split("_");
- let value = curMsg.value;
- if(ids.length == 2){
- if(curTabId == ids[1]){
- msg.push({id:ids[0],value:value});
- }
- }else{
- msg.push(curMsg);
- }
- }
- message = msg;
- }
- // 更新列表中设备的属性
- if (this.deviceInfo.serialNumber == deviceNum) {
- for (let j = 0; j < message.length; j++) {
- let isComplete = false;
- let msgId = message[j].id;
- this.exchangeData(msgId,message[j]);
- // 布尔类型
- for (let k = 0; k < this.deviceInfo.boolList.length && !isComplete; k++) {
- if (this.deviceInfo.boolList[k].id == message[j].id) {
- this.deviceInfo.boolList[k].shadow = message[j].value;
- isComplete = true;
- break;
- }
- }
- // 枚举类型
- for (let k = 0; k < this.deviceInfo.enumList.length && !isComplete; k++) {
- if (this.deviceInfo.enumList[k].id == message[j].id) {
- this.deviceInfo.enumList[k].shadow = message[j].value;
- isComplete = true;
- break;
- }
- }
- // 字符串类型
- for (let k = 0; k < this.deviceInfo.stringList.length && !isComplete; k++) {
- if (this.deviceInfo.stringList[k].id == message[j].id) {
- this.deviceInfo.stringList[k].shadow = message[j].value;
- isComplete = true;
- break;
- }
- }
- // 数组类型
- for (let k = 0; k < this.deviceInfo.arrayList.length && !isComplete; k++) {
- if (this.deviceInfo.arrayList[k].id == message[j].id) {
- this.deviceInfo.arrayList[k].shadow = message[j].value;
- isComplete = true;
- break;
- }
- }
- // 整数类型
- for (let k = 0; k < this.deviceInfo.integerList.length && !isComplete; k++) {
- if (this.deviceInfo.integerList[k].id == message[j].id) {
- this.deviceInfo.integerList[k].shadow = message[j].value;
- isComplete = true;
- break;
- }
- }
- // 小数类型
- for (let k = 0; k < this.deviceInfo.decimalList.length && !isComplete; k++) {
- if (this.deviceInfo.decimalList[k].id == message[j].id) {
- this.deviceInfo.decimalList[k].shadow = message[j].value;
- isComplete = true;
- break;
- }
- }
- // 监测数据
- for (let k = 0; k < this.deviceInfo.readOnlyList.length && !isComplete; k++) {
- if (this.deviceInfo.readOnlyList[k].id == message[j].id) {
- this.deviceInfo.readOnlyList[k].shadow = message[j].value;
- // 更新图表
- // for (let m = 0; m < this.monitorChart.length; m++) {
- // if (message[j].id == this.monitorChart[m].data.id) {
- // let data = [{
- // value: message[j].value,
- // name: this.monitorChart[m].data.name
- // }];
- // this.monitorChart[m].chart.setOption({
- // series: [{
- // data: data
- // }]
- // });
- // break;
- // }
- // }
- isComplete = true;
- break;
- }
- }
- }
- this.parseEnumList();
- }
- this.$forceUpdate();
- }
- });
- },
- exchangeData(msgId,obj){
- if(msgId === "TempSetting"){
- this.temperature = obj.value;
- }
- if(msgId === "TimeSetting"){
- this.temperatureTime = obj.value;
- }
- if(msgId === "CurrentTemp"){
- this.currentTemperature = obj.value;
- }
- if(msgId === "HighTempTime"){
- this.hightTemperature = obj.value;
- }
- if(msgId === "SealTemp"){
- if(!this.editing){
- this.sealingTemperature = obj.value;
- }
- }
- if(msgId === "BandingTemp"){
- if(!this.editing){
- this.edegTemperature = obj.value;
- }
- }
- if(msgId === "PackingVolume"){
- if(!this.editing){
- this.packageVolume = obj.value;
- }
- }
- if(msgId === "PackageQuantity"){
- if(!this.editing){
- this.packageNumber = obj.value;
- }
- }
- if(msgId === "LeftAppointmentTime"){
- this.leftAppointmentTime = obj.value;
- }
- if(msgId === "SlowfireTiem"){
- this.leftJianyaoTime = obj.value;
- }
- },
- /** 发布物模型 类型(1=属性,2=功能) */
- publishThingsModel(device, model) {
- // 获取缓存的Json物模型
- cacheJsonThingsModel(device.productId).then(response => {
- let thingsModel = JSON.parse(response.data);
- let type = 0;
- for (let i = 0; i < thingsModel.functions.length; i++) {
- if (model.id == thingsModel.functions[i].id) {
- type = 2;
- break;
- }
- }
- if (type == 0) {
- for (let i = 0; i < thingsModel.properties.length; i++) {
- if (model.id == thingsModel.properties[i].id) {
- type = 1;
- break;
- }
- }
- }
- if (type != 0) {
- this.mqttPublish(type, device, [model]);
- }
- });
- },
- notifyError(res){
- uni.showToast({
- title:res,
- icon:"error"
- })
- },
- notifySuccess(res){
- uni.showToast({
- title:res,
- icon:"success"
- })
- },
- /**
- * Mqtt发布消息
- * @type 类型(1=属性,2=功能,3=OTA升级,4=实时监测)
- * @device 设备
- * @model 物模型
- * */
- mqttPublish(type, device, modelList,needMore) {
- if(this.deviceInfo.status != 3){
- this.notifyError("请等待设备上线后操作")
- return;
- }
- if(modelList.length == 0){
- return;
- }
- let topic = "";
- let message = ""
- let oneToMul = false;
- if(this.summary.length>1){
- oneToMul = true;
- }
- if(!needMore){
- oneToMul = false;
- }
- if(!this.decoctControlOnOffStatus){
- let isKaijiKey = false;
- if(modelList.length == 1){
- let modelData = modelList[0];
- let curKeyId = modelData.id;
- if(this.firstTab){
- if(oneToMul){
- if(curKeyId.indexOf("PowerCtl") !=-1){
- isKaijiKey = true;
- }
- }else{
- if(curKeyId.indexOf("PowerControl") !=-1){
- isKaijiKey = true;
- }
- }
- }else{
- if(curKeyId.indexOf("PowerControl") !=-1){
- isKaijiKey = true;
- }
- }
- }
- if(!isKaijiKey){
- this.notifyError("请先开机后再进行操作")
- return;
- }
- }
- if (type == 1) {
- if (device.status == 3) {
- // 属性,在线模式
- topic = "/" + device.productId + "/" + device.serialNumber + "/property-online/get";
- }
- } else if (type == 2) {
- if (device.status == 3) {
- // 功能,在线模式
- topic = "/" + device.productId + "/" + device.serialNumber + "/function-online/get";
- }
- } else if (type == 3) {
- // OTA升级
- topic = "/" + device.productId + "/" + device.serialNumber + "/ota/get";
- } else {
- return;
- }
- let title = "";
- if(type == 1){
- title = "属性";
- }else if(type == 2){
- title = "功能";
- }
- if (topic != "") {
- // 发布
- let arr = [];
- for (let i = 0; i <modelList.length; i++) {
- let model = modelList[i];
- let modelId = model.id;
- if(oneToMul){
- let childId = this.childId;
- if(childId){
- modelId = modelId+"_"+childId;
- }
- }
- let shadow = model.shadow+"";
- let modelType = model.type;
- let shadowInt = parseInt(shadow,10);
- let isNumber = false;
- let shadowStr = shadowInt+"";
- if(shadowStr === shadow){
- isNumber = true;
- shadow = shadowInt;
- }
- if(modelType == "integer" && !isNumber){
- this.$modal.showToast(model.name+'的值必须是数字类型')
- return;
- }
- arr.push({id:modelId,value:shadow+""});
- }
- message = JSON.stringify(arr);
- let self = this;
- this.$mqttTool.publish(topic, message,title).then(res => {
- this.notifySuccess(res);
- }).catch(res => {
- this.notifyError(res);
- });
- }
- },
- startCheck(){
- let self = this;
- this.checkTimer = setTimeout(function (){
- self.sendHeart();
- self.startCheck();
- },20000);
- },
- checkActive(){
- let self = this;
- setTimeout(function (){
- if(self.publishMsg){
- self.resetConn()
- }
- },3000);
- },
- sendHeart(){
- console.log("发送心跳111")
- let device = this.deviceInfo;
- let self = this;
- let topic = "/property-offline/post";
- self.publishMsg = true;
- self.checkActive();
- this.$mqttTool.publish(topic, "ok", "heart").then(res => {
- self.publishMsg = false;
- }).catch(res => {
- self.publishMsg = false;
- });
- },
- resetConn(){
- console.log("检测异常,重连")
- this.$mqttTool.end();
- this.$mqttTool.client = null;
- this.connectMqtt();
- this.getDetail();
- }
- }
- }
- </script>
- <style>
- .send_btn{
- width: 160rpx !important;
- height: 40rpx !important;
- font-size: 10px !important;
- margin-top: 5px;
- }
- uni-col{
- width: 150px;
- }
- .header{
- width: 100%;
- background: white;
- padding:0px 20rpx;
- position: relative;
- }
- .content {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .logo {
- height: 200rpx;
- width: 200rpx;
- margin-top: 200rpx;
- margin-left: auto;
- margin-right: auto;
- margin-bottom: 50rpx;
- }
- .text-area {
- margin:10px;
- padding-bottom: 10px;
- justify-content: center;
- width: 100%;
- }
- .grid-text {
- font-size: 14px;
- color: #909399;
- padding: 10rpx 0 20rpx 0rpx;
- /* #ifndef APP-PLUS */
- box-sizing: border-box;
- /* #endif */
- }
- .title {
- font-size: 36rpx;
- color: #8f8f94;
- }
- .item{
- height: 80rpx;
- line-height: 80rpx;
- }
- .bg{
- position: relative;
- }
- .text-left{
- color: #8A92A5;
- }
- .text-right{
- color: #545454;
- }
- .prop-text{
- position: relative;
- margin:20rpx 0;
- font-size: 26rpx;
- }
- .prop-card-area{
- }
- .prop-card{
- width: 28%;
- height: 100rpx;
- text-align: center;
- display: inline-block;
- background: #F5FCFF;
- box-shadow: 0px 9rpx 8rpx 0px rgba(0,0,0,0.09);
- border-radius: 8rpx;
- margin:0px 15rpx;
- line-height: 48rpx;
- }
- .prop-card-top{
- color: #3E9CFC;
- }
- .prop-card-bottom{
- color: #8A92A5;
- }
- .tab-area {
- background: white;
- position: absolute;
- left: 0px;
- right: 0px;
- top:480rpx;
- bottom:-20px;
- min-height: 200rpx;
- box-shadow: 0rpx 5rpx 27rpx 0rpx rgba(195, 195, 195, 0.4);
- border-radius: 40rpx;
- overflow-y: auto;
- padding-bottom:80rpx;
- }
- .prop-item{
- justify-content:center;
- position: relative;
- border-bottom: 1px solid lightgray;
- height: 80rpx;
- margin:0 20rpx;
- }
- .prop-item-left{
- position: absolute;
- left:10rpx;
- top:22rpx;
- color: #545454;
- width: 50%;
- font-size: 12px;
- }
- .prop-item-right{
- position: absolute;
- right:10rpx;
- top:10rpx;
- width: 50%;
- }
- input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{
- color:#666;
- font-size:12px;
- }
- .clearfix::after {
- content: "";
- display: block;
- clear: both;
- }
- .decoctControlHeader {
- display: flex;
- align-items: center;
- font-weight: 600;
- }
- .decoctControlTop {
- display: flex;
- height: 240rpx;
- border-bottom:1px #B2B2B2 dotted;
- margin:0 40rpx;
- }
- .decoctControlTopLeft {
- width:40%;
- line-height: 2;
- text-align: center;
- margin: 0 15px;
- position: relative;
- }
- .addTemperature {
- border-radius:5px;
- position:absolute;
- background-color: dodgerblue;
- color:white;
- width: 30px;
- height: 30px;
- left:15px;
- top:80px;
- }
- .addTemperatureBtn {
- border-radius:10px;
- position:absolute;
- clip-path: polygon(50% 0,100% 100%,0 100%);
- transform: scale(0.5);
- left: 0;
- top:0;
- bottom: 0;
- right: 0;
- margin: auto;
- }
- .subTemperature {
- border-radius:5px;
- position:absolute;
- background-color: dodgerblue;
- color:white;
- width: 30px;
- height: 30px;
- right:15px;
- top:80px;
- }
- .subTemperatureBtn {
- border-radius:10px;
- position:absolute;
- clip-path: polygon(50% 0,100% 100%,0 100%);
- transform: scale(0.5);
- left: 0;
- top:0;
- bottom: 0;
- right: 0;
- margin: auto;
- }
- .decoctControlTopRight {
- width:40%;
- line-height: 2;
- text-align: center;
- margin: 0 15px;
- position: relative;
- }
- .decoctControlBottom {
- border-bottom:1px #B2B2B2 dotted;
- width:91vw;
- margin:0 auto;
- padding:10px;
- display: flex;
- justify-content:space-between;
- align-items: center;
- }
- .addTime {
- border-radius:5px;
- position:absolute;
- background-color: dodgerblue;
- color:white;
- width: 30px;
- height: 30px;
- left:15px;
- top:80px;
- }
- .addTimeBtn {
- border-radius:10px;
- position:absolute;
- clip-path: polygon(50% 0,100% 100%,0 100%);
- transform: scale(0.5);
- left: 0;
- top:0;
- bottom: 0;
- right: 0;
- margin: auto;
- }
- .subTime {
- border-radius:5px;
- position:absolute;
- background-color: dodgerblue;
- color:white;
- width: 30px;
- height: 30px;
- right:15px;
- top:80px;
- }
- .subTimeBtn {
- border-radius:10px;
- position:absolute;
- clip-path: polygon(50% 0,100% 100%,0 100%);
- transform: scale(0.5);
- left: 0;
- top:0;
- bottom: 0;
- right: 0;
- margin: auto;
- }
- .packageControlBottomRight {
- border-radius:5px;
- padding:5px 10px;
- margin-right: 15px;
- background-color: #3c9cff;
- color: #fff;
- }
- .packageControlBottomClear {
- border-radius:5px;
- padding:5px 10px;
- background-color: #B2B2B2;
- color: #fff;
- }
- .active_btn{
- background-color: #3c9cff;
- }
- .baozhuang-sub{
- right: 10rpx !important;
- }
- .baozhuang-add{
- left: 6rpx !important;
- }
- .control-input-box{
- display: flex;
- flex-direction: row;
- padding-left: 26rpx;
- }
- .control-input-box-danwei{
- padding-top:12rpx;
- margin-left:4rpx;
- }
- </style>
|