equip-detail.vue 16 KB

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