equip-detail.vue 16 KB

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