equip-detail.vue 15 KB

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