equip-detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view>
  3. <view :class="['info',equipInfo.device_status==1?'on':'off']">
  4. <view class="">
  5. 设备ID:{{equipInfo.device_id}}
  6. </view>
  7. <view class="">
  8. 设备名称:{{equipInfo.device_name}}
  9. </view>
  10. <view class="">
  11. 设备类型:{{equipInfo.type|equipType}}
  12. </view>
  13. <view class="">
  14. 最新上报时间:{{equipInfo.status_time | timeFormat}}
  15. </view>
  16. <view class="">
  17. 设备地址:{{equipInfo.address}}
  18. </view>
  19. <view v-if="type==7" @click="setTime(equipInfo.d_id)">
  20. <text space="emsp">载玻片、培养液更换时间</text> <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  21. </view>
  22. <view v-if="type==4" @click="addYx(equipInfo.d_id)">
  23. <text space="emsp">添加诱芯</text> <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  24. </view>
  25. <u-popup v-model="setTimeShow" mode="center" width="600rpx" >
  26. <u-field
  27. label="载玻片更换时间"
  28. placeholder="选择日期"
  29. label-width='240'
  30. required
  31. :error-message="glassErr"
  32. v-model="glass_slide_time"
  33. @click="glass_show=true"
  34. >
  35. </u-field>
  36. <u-field
  37. label="培养液更换时间"
  38. placeholder="选择日期"
  39. label-width='240'
  40. required
  41. :error-message="culErr"
  42. v-model="cultivate_time"
  43. @click="cultivate_show=true"
  44. >
  45. </u-field>
  46. <view class="btn-box">
  47. <u-button @click="setTimeSubmit" size="mini" type="success">确定</u-button>
  48. </view>
  49. <u-calendar v-model="glass_show" mode="date" @change="timeChange($event,'glass')"></u-calendar>
  50. <u-calendar v-model="cultivate_show" mode="date" @change="timeChange($event,'cultivate')"></u-calendar>
  51. </u-popup>
  52. <u-popup v-model="yxShow" mode="center" width="600rpx" >
  53. <u-field
  54. label="监测害虫名称"
  55. label-width='240'
  56. required
  57. :error-message="xyErr"
  58. v-model="decoy"
  59. >
  60. </u-field>
  61. <view class="btn-box">
  62. <u-button @click="yxSubmit" size="mini" type="success">确定</u-button>
  63. </view>
  64. </u-popup>
  65. <u-toast ref="toast" />
  66. </view>
  67. <view class="equip_part">
  68. <template v-if="equipInfo.type==7">
  69. <view class="item1" v-for="item in bzy" @click="partClick(item.path)">
  70. <image :src="item.icon" mode="widthFix"></image>
  71. <view class="">
  72. {{item.tex}}
  73. </view>
  74. </view>
  75. </template>
  76. <template v-else>
  77. <view class="item2" v-for="item in curEquip" @click="partClick(item.path)">
  78. <image :src="item.icon" mode="widthFix"></image>
  79. <view class="">
  80. {{item.tex}}
  81. </view>
  82. </view>
  83. </template>
  84. </view>
  85. <view class="tit">
  86. 实时数据
  87. </view>
  88. <view class="newState">
  89. <view class="item" v-for="item in curState">
  90. <image :src="item.icon" mode="widthFix"></image>
  91. <view class="info-con">
  92. <view class="active">
  93. {{item.txt}}
  94. </view>
  95. <view class="val" >
  96. {{item.value | formatValue(item.txt,type)}}
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. data() {
  106. return {
  107. type:null,//设备类型
  108. device_status:null,
  109. equipInfo:{},
  110. cbd:[
  111. {
  112. icon:'/static/image/cb/1.png',
  113. tex:'查看图片',
  114. path:'',
  115. }, {
  116. icon:'/static/image/cb/2.png',
  117. tex:'历史数据',
  118. path:'',
  119. }, {
  120. icon:'/static/image/cb/3.png',
  121. tex:'害虫统计',
  122. path:'',
  123. }, {
  124. icon:'/static/image/cb/4.png',
  125. tex:'设备控制',
  126. path:'/pages/cb/cbd/equip-set/equip-set',
  127. }, {
  128. icon:'/static/image/cb/5.png',
  129. tex:'短信预警',
  130. path:'',
  131. }, {
  132. icon:'/static/image/cb/6.png',
  133. tex:'sim卡详情',
  134. path:'',
  135. }
  136. ],
  137. bzy:[
  138. {
  139. icon:'/static/image/cb/4.png',
  140. tex:'设备控制',
  141. path:'/pages/cb/bzy/equip-set/equip-set'
  142. },{
  143. icon:'/static/image/cb/1.png',
  144. tex:'查看图片',
  145. path:''
  146. },{
  147. icon:'/static/image/cb/2.png',
  148. tex:'历史数据',
  149. path:''
  150. },{
  151. icon:'/static/image/cb/6.png',
  152. tex:'sim卡详情',
  153. path:''
  154. }
  155. ],
  156. xy:[
  157. {
  158. icon:'/static/image/cb/4.png',
  159. tex:'设备控制',
  160. path:'/pages/cb/xy/equip-set/equip-set'
  161. },{
  162. icon:'/static/image/cb/6.png',
  163. tex:'sim卡详情',
  164. path:''
  165. },{
  166. icon:'/static/image/cb/2.png',
  167. tex:'历史数据',
  168. path:''
  169. }
  170. ],
  171. newState:{},//设备最新状态
  172. setTimeShow:false,
  173. glass_show:false,
  174. cultivate_show:false,
  175. cultivate_time: "",
  176. glass_slide_time: "",
  177. glassErr:'',
  178. culErr:'',
  179. yxShow:false,//诱芯弹框
  180. xyErr:'',
  181. decoy:''
  182. }
  183. },
  184. computed:{
  185. curEquip(){
  186. switch(this.type){
  187. case 3:
  188. return this.cbd;
  189. case 7:
  190. return this.bzy;
  191. case 4:
  192. return this.xy
  193. }
  194. },
  195. curState(){
  196. switch(this.type){
  197. case 3:
  198. let blbs=""//灯管状态
  199. if (this.newState.lamp != undefined) {
  200. if (this.newState.ws == 1) {
  201. if (this.newState.lamp == 1) {
  202. blbs = "工作中";
  203. } else if (dht.lux == 0) {
  204. blbs = "N/A(未检测到传感器)";
  205. } else {
  206. blbs = "异常";
  207. }
  208. } else {
  209. blbs = "关闭";
  210. }
  211. } else {
  212. blbs = "--";
  213. }
  214. return [
  215. {
  216. icon:'/static/image/cb/icon02.png',
  217. txt:'在线状态',
  218. value:this.device_status==1?'在线':'离线',
  219. },
  220. {
  221. icon:'/static/image/cb/icon02.png',
  222. txt:'开关状态',
  223. value:this.newState.ds==1?'关机':'开机'
  224. },
  225. {
  226. icon:'/static/image/cb/icon02.png',
  227. txt:'通道状态',
  228. value:this.newState.upds==1?'落虫':'排水'
  229. },
  230. {
  231. icon:'/static/image/cb/icon02.png',
  232. txt:'加热状态',
  233. value:this.newState.hs==1?'加热':'正常'
  234. },{
  235. icon:'/static/image/cb/icon02.png',
  236. txt:'环境温度(℃)',
  237. value:this.newState.at
  238. },{
  239. icon:'/static/image/cb/icon02.png',
  240. txt:'环境湿度(%)',
  241. value:this.newState.ah
  242. },{
  243. icon:'/static/image/cb/icon02.png',
  244. txt:'信号强度',
  245. value:this.newState.csq
  246. },{
  247. icon:'/static/image/cb/icon02.png',
  248. txt:'设备版本',
  249. value:this.newState.dver
  250. },
  251. {
  252. icon:'/static/image/cb/icon02.png',
  253. txt:'雨控状态',
  254. value:this.newState.rps==1?"雨控":'正常'
  255. },{
  256. icon:'/static/image/cb/icon02.png',
  257. txt:'温控状态',
  258. value:this.newState.tps==1?"温控":'正常'
  259. },{
  260. icon:'/static/image/cb/icon02.png',
  261. txt:'光控状态',
  262. value:this.newState.lps==1?"光控":'正常'
  263. },{
  264. icon:'/static/image/cb/icon02.png',
  265. txt:'灯管状态',
  266. value:blbs
  267. },{
  268. icon:'/static/image/cb/icon02.png',
  269. txt:'上仓门',
  270. value:this.newState.upds==1?"打开":'关闭'
  271. },{
  272. icon:'/static/image/cb/icon02.png',
  273. txt:'下仓门',
  274. value:this.newState.dnds==1?"打开":'关闭'
  275. }
  276. ]
  277. case 7:
  278. return [{
  279. icon:'/static/image/cb/icon02.png',
  280. txt:'在线状态',
  281. value:this.device_status==1?'在线':'离线',
  282. },
  283. {
  284. icon:'/static/image/cb/icon02.png',
  285. txt:'设备开关',
  286. value:this.newState.on_off==1?'开启':'关闭'
  287. },
  288. {
  289. icon:'/static/image/cb/icon02.png',
  290. txt:'摄像头状态',
  291. value:this.newState.usb_sta==1?'异常':'正常'
  292. },
  293. {
  294. icon:'/static/image/cb/icon02.png',
  295. txt:'当前电压',
  296. value:this.newState.v_bat
  297. },{
  298. icon:'/static/image/cb/icon02.png',
  299. txt:'环境温度(℃)',
  300. value:this.newState.at
  301. },{
  302. icon:'/static/image/cb/icon02.png',
  303. txt:'环境湿度(%)',
  304. value:this.newState.ah
  305. },{
  306. icon:'/static/image/cb/icon02.png',
  307. txt:'信号强度',
  308. value:this.newState.csq
  309. },{
  310. icon:'/static/image/cb/icon02.png',
  311. txt:'已培养时间',
  312. value:this.newState.staytime
  313. },{
  314. icon:'/static/image/cb/icon02.png',
  315. txt:'设备版本',
  316. value:this.newState.dver
  317. },{
  318. icon:'/static/image/cb/icon02.png',
  319. txt:'保温仓当前温度',
  320. value:this.newState.dver
  321. },{
  322. icon:'/static/image/cb/icon02.png',
  323. txt:'保温仓设定温度',
  324. value:this.newState.dver
  325. },{
  326. icon:'/static/image/cb/icon02.png',
  327. txt:'经度',
  328. value:this.newState.lng
  329. },{
  330. icon:'/static/image/cb/icon02.png',
  331. txt:'纬度',
  332. value:this.newState.lat
  333. },];
  334. case 4:
  335. return [{
  336. icon:'/static/image/cb/icon02.png',
  337. txt:'在线状态',
  338. value:this.device_status==1?'在线':'离线',
  339. },
  340. {
  341. icon:'/static/image/cb/icon02.png',
  342. txt:'设备开关',
  343. value:this.newState.ds==1?'开启':'关闭'
  344. },
  345. {
  346. icon:'/static/image/cb/icon02.png',
  347. txt:'工作状态',
  348. value:this.newState.ws==1?'工作':' 待机'
  349. },
  350. {
  351. icon:'/static/image/cb/icon02.png',
  352. txt:'环境温度(℃)',
  353. value:this.newState.at
  354. },
  355. {
  356. icon:'/static/image/cb/icon02.png',
  357. txt:'环境湿度(%)',
  358. value:this.newState.ah
  359. },
  360. {
  361. icon:'/static/image/cb/icon02.png',
  362. txt:'充电电压',
  363. value:this.newState.cv
  364. },
  365. {
  366. icon:'/static/image/cb/icon02.png',
  367. txt:'电池电压',
  368. value:this.newState.bv
  369. },
  370. {
  371. icon:'/static/image/cb/icon02.png',
  372. txt:'信号强度',
  373. value:this.newState.csq
  374. },
  375. {
  376. icon:'/static/image/cb/icon02.png',
  377. txt:'设备版本',
  378. value:this.newState.dver
  379. },
  380. {
  381. icon:'/static/image/cb/icon02.png',
  382. txt:'充电状态',
  383. value:this.newState.cs==1?'充电':'正常'
  384. },
  385. {
  386. icon:'/static/image/cb/icon02.png',
  387. txt:'电池状态',
  388. value:this.newState.bs
  389. },
  390. ]
  391. }
  392. }
  393. },
  394. filters:{
  395. equipType(type){
  396. switch(type){
  397. case 3:
  398. return "虫情测报灯";
  399. case 7:
  400. return "孢子仪";
  401. case 4:
  402. return "性诱测报"
  403. }
  404. },
  405. formatValue(val,a1,a2){
  406. if(a2==4&&a1=="电池状态"){
  407. switch(val){
  408. case 0:
  409. return '正常';
  410. break;
  411. case 1:
  412. return '欠压';
  413. break;
  414. case 2:
  415. return '过压';
  416. break;
  417. }
  418. }else{
  419. return val?val:'无'
  420. }
  421. }
  422. },
  423. onLoad(option){
  424. this.equipInfo=JSON.parse(option.info)
  425. this.type=this.equipInfo.type
  426. this.device_status=this.equipInfo.device_status
  427. this.getState()
  428. console.log(this.equipInfo)
  429. },
  430. methods: {
  431. async getState(){
  432. const res=await this.$myRequest({
  433. url:'/api/api_gateway?method=forecast.worm_lamp.device_history_data',
  434. data:{
  435. device_type_id:this.equipInfo.type,
  436. device_id:this.equipInfo.device_id,
  437. page: 1,
  438. page_size:1,
  439. }
  440. })
  441. this.newState=res.data[0].d_h_t
  442. },
  443. partClick(path){
  444. console.log(this.equipInfo)
  445. uni.navigateTo({
  446. url:path+ '?d_id=' + this.equipInfo.d_id
  447. });
  448. },
  449. async setTime(d_id){
  450. const res=await this.$myRequest({
  451. url:'/api/api_gateway?method=device.device_manage.get_spore_time',
  452. data:{
  453. device_type_id:this.type,
  454. d_id
  455. }
  456. })
  457. this.glass_slide_time=res.glass_slide_time?this.formatTime(res.glass_slide_time*1000,'yyyy-MM-dd'):''
  458. this.cultivate_time=res.cultivate_time?this.formatTime(res.cultivate_time*1000,'yyyy-MM-dd'):''
  459. this.setTimeShow=true
  460. },
  461. timeChange(e,a){
  462. if(a=='glass'){
  463. this.glass_slide_time=e.result
  464. this.glassErr=''
  465. }else{
  466. this.cultivate_time=e.result
  467. this.culErr=''
  468. }
  469. },
  470. async setTimeSubmit(){
  471. if(!this.glass_slide_time){
  472. this.glassErr="请填写载玻片更换时间"
  473. }
  474. if(!this.cultivate_time){
  475. this.culErr="请填写培养液更换时间"
  476. return
  477. }
  478. let glass = parseInt(
  479. new Date(this.glass_slide_time).getTime() / 1000
  480. );
  481. let cultivate = parseInt(
  482. new Date(this.cultivate_time).getTime() / 1000
  483. );
  484. const res=await this.$myRequest({
  485. url:'/api/api_gateway?method=device.device_manage.updata_spore_time',
  486. data:{
  487. device_type_id: this.type,
  488. d_id: this.equipInfo.d_id,
  489. glass_slide_time:glass,
  490. cultivate_time: cultivate
  491. }
  492. })
  493. if(res){
  494. this.$refs.toast.show({
  495. title: '修改成功!',
  496. type: 'success',
  497. })
  498. }
  499. this.setTimeShow=false
  500. },
  501. async addYx(d_id){
  502. const res=await this.$myRequest({
  503. url:'/api/api_gateway?method=device.device_manage.get_spore_time',
  504. data:{
  505. device_type_id:this.type,
  506. d_id
  507. }
  508. })
  509. this.decoy=res.decoy;
  510. this.yxShow=true
  511. },
  512. async yxSubmit(){
  513. if(!this.decoy){
  514. this.xyErr="请填写监测害虫名称";
  515. return false
  516. }
  517. const res=await this.$myRequest({
  518. url:'/api/api_gateway?method=device.device_manage.updata_spore_time',
  519. data:{
  520. device_type_id:this.type,
  521. d_id:this.equipInfo.d_id,
  522. decoy:this.decoy
  523. }
  524. })
  525. if(res){
  526. this.xyErr=""
  527. this.yxShow=false
  528. }
  529. }
  530. },
  531. }
  532. </script>
  533. <style lang='scss'>
  534. page{
  535. padding:20rpx;
  536. .info{
  537. padding:20rpx 40rpx;
  538. color:#fff;
  539. line-height:50rpx;
  540. font-size:26rpx;
  541. background-size:100% auto;
  542. background-repeat: no-repeat;
  543. background-color:#0DC6B6;
  544. background-position: top left;
  545. }
  546. .on{
  547. background-image:url('../../../static/image/cb/onBg.png')
  548. }
  549. .off{
  550. background-image:url('../../../static/image/cb/offBg.png')
  551. }
  552. .equip_part{
  553. display:flex;
  554. flex-wrap:wrap;
  555. text-align: center;
  556. font-size:28rpx;
  557. color:#666;
  558. line-height:50rpx;
  559. image{
  560. width:52rpx;
  561. }
  562. .item1{
  563. padding:20rpx 10rpx;
  564. box-sizing: border-box;
  565. flex-basis:25%;
  566. }
  567. .item2{
  568. padding:20rpx;
  569. box-sizing: border-box;
  570. flex-basis:33%;
  571. flex-grow:1;
  572. }
  573. }
  574. .tit{
  575. font-weight:800;
  576. line-height:50rpx;
  577. font-size:30rpx;
  578. margin-bottom:20rpx;
  579. }
  580. .newState{
  581. display:flex;
  582. flex-wrap:wrap;
  583. text-align: center;
  584. margin:0 -10rpx;
  585. .item{
  586. display:flex;
  587. flex-wrap: wrap;
  588. margin:10rpx;
  589. width: 345rpx;
  590. justify-content:flex-start;
  591. padding:20rpx;
  592. box-sizing: border-box;
  593. border-radius: 4px;
  594. box-shadow: 0px 0px 5px 3px rgba(136,136,136,.1);
  595. font-size:24rpx;
  596. .info-con{
  597. padding-left:30rpx;
  598. text-align: left;
  599. line-height:40rpx;
  600. }
  601. image{width:70rpx;}
  602. }
  603. }
  604. .btn-box{
  605. text-align:center;
  606. padding:30rpx;
  607. }
  608. }
  609. </style>