equip-detail.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. <template>
  2. <view>
  3. <view :class="['info', equipInfo.is_online == 1 ? 'on' : 'off']">
  4. <view class="" @click="copy(equipInfo)">
  5. 设备ID:{{ equipInfo.imei || equipInfo.device_id }}
  6. <image
  7. :src="$imageURL+'/bigdata_app/image/environment/fuzhi.png'"
  8. mode=""
  9. class="tishi"
  10. >
  11. </image>
  12. </view>
  13. <view class="">
  14. 设备名称:{{
  15. equipInfo.device_name == '' ? '无' : equipInfo.device_name
  16. }}
  17. </view>
  18. <view class="">
  19. 设备类型:<span v-if="equipInfo.type">{{
  20. equipInfo.type | equipType
  21. }}</span
  22. ><span v-else>{{ equipInfo.type_name }}</span>
  23. </view>
  24. <view class="">
  25. 最新上报时间:{{ equipInfo.addtime || equipInfo.uptime | timeFormat }}
  26. </view>
  27. <view class=""> 设备地址:{{ equipInfo.address || city }} </view>
  28. <view v-if="type == 7" @click="setTime(equipInfo.d_id)">
  29. <text space="emsp">载玻片、培养液更换时间</text>
  30. <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  31. </view>
  32. <view v-if="type == 7">
  33. <text space="emsp">
  34. <span
  35. :class="{
  36. red: equipInfo.status_glass == 2 || equipInfo.status_glass == 1,
  37. }"
  38. >
  39. {{ glass_slide_timeTime(equipInfo.status_glass) }}
  40. </span>
  41. <span style="margin: 0 10px">|</span>
  42. <span
  43. :class="{
  44. red: equipInfo.status_cul == 2 || equipInfo.status_cul == 1,
  45. }"
  46. >
  47. {{ cultivateTime(equipInfo.status_cul) }}
  48. </span>
  49. </text>
  50. </view>
  51. <view v-if="type == 4" @click="addYx(equipInfo.d_id)">
  52. <text space="emsp">添加诱芯</text>
  53. <text style="margin: 0 10px">{{ equipInfo.decoy || '暂无' }}</text>
  54. <u-icon name="edit-pen" color="#f0ad4e" size="28"></u-icon>
  55. </view>
  56. <view v-if="type == 4">
  57. <text space="emsp">诱芯更新时间</text>
  58. <text style="margin: 0 10px">{{ equipInfo.xy_uptime }}</text>
  59. </view>
  60. <view v-if="type == 4">
  61. <text space="emsp">诱芯到期时间</text>
  62. <text style="margin: 0 10px">{{ equipInfo.xy_expire }}</text>
  63. </view>
  64. <u-popup v-model="setTimeShow" mode="center" width="600rpx">
  65. <u-field
  66. label="载玻片更换时间"
  67. placeholder="选择日期"
  68. label-width="240"
  69. required
  70. :error-message="glassErr"
  71. v-model="glass_slide_time"
  72. @click="glass_show = true"
  73. :field-style="fieldstyle"
  74. disabled
  75. >
  76. </u-field>
  77. <u-field
  78. label="培养液更换时间"
  79. placeholder="选择日期"
  80. label-width="240"
  81. required
  82. :error-message="culErr"
  83. v-model="cultivate_time"
  84. @click="cultivate_show = true"
  85. :field-style="fieldstyle"
  86. disabled
  87. >
  88. </u-field>
  89. <view class="btn-box">
  90. <u-button @click="setTimeSubmit" size="mini" type="success"
  91. >确定</u-button
  92. >
  93. </view>
  94. <u-calendar
  95. v-model="glass_show"
  96. mode="date"
  97. :max-date="date"
  98. @change="timeChange($event, 'glass')"
  99. >
  100. </u-calendar>
  101. <u-calendar
  102. v-model="cultivate_show"
  103. mode="date"
  104. :max-date="date"
  105. @change="timeChange($event, 'cultivate')"
  106. ></u-calendar>
  107. </u-popup>
  108. <u-popup v-model="yxShow" mode="center" width="600rpx">
  109. <u-field
  110. label="监测害虫名称"
  111. label-width="240"
  112. required
  113. :error-message="xyErr"
  114. v-model="decoy"
  115. :field-style="fieldstyle"
  116. >
  117. </u-field>
  118. <view class="btn-box">
  119. <u-button @click="yxSubmit" size="mini" type="success">确定</u-button>
  120. </view>
  121. </u-popup>
  122. <u-toast ref="toast" />
  123. </view>
  124. <view class="equip_part">
  125. <template v-for="item in curEquip">
  126. <view
  127. :class="[equipInfo.type == 3 ? 'item2' : 'item1']"
  128. v-show="item.tf"
  129. @click="partClick(item.path)"
  130. >
  131. <image
  132. :src="$imageURL+'/bigdata_app' + item.icon"
  133. mode="widthFix"
  134. ></image>
  135. <view class="">
  136. {{ item.tex }}
  137. </view>
  138. </view>
  139. </template>
  140. </view>
  141. <view class="tit">
  142. <p>实时数据</p>
  143. <p
  144. class="span"
  145. @click="partClicks"
  146. v-if="
  147. equipInfo.type != 4 && $QueryPermission(60) && equipInfo.type == 3
  148. "
  149. >
  150. 历史数据>>>
  151. </p>
  152. <p
  153. class="span"
  154. @click="partClicks"
  155. v-if="
  156. equipInfo.type != 4 && $QueryPermission(71) && equipInfo.type == 7
  157. "
  158. >
  159. 历史数据>>>
  160. </p>
  161. </view>
  162. <view class="newtishi" v-if="dataloadingtf">
  163. <p class="dataloading">加载中</p>
  164. </view>
  165. <view class="newtishi" v-else-if="newtishitf"> 暂无数据 </view>
  166. <view class="newState" v-else>
  167. <view class="item" v-for="item in curState">
  168. <image
  169. :src="$imageURL+'/bigdata_app' + item.icon"
  170. mode="widthFix"
  171. ></image>
  172. <view class="info-con">
  173. <view class="active">
  174. {{ item.txt }}
  175. </view>
  176. <view class="val">
  177. {{ item.value | formatValue(item.txt, type) }}
  178. </view>
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. </template>
  184. <script>
  185. import equipState from '../../../static/js/equipState_dict.json';
  186. import { QueryPermission } from '../../../util/QueryPermission.js';
  187. export default {
  188. data() {
  189. return {
  190. fieldstyle: {
  191. border: '2rpx solid #f6f6f6',
  192. 'border-radius': '24px',
  193. 'padding-left': '20rpx',
  194. 'background-color': '#f6f6f6',
  195. },
  196. city: '',
  197. type: null, //设备类型
  198. device_status: null,
  199. equipInfo: {},
  200. cbd: [
  201. {
  202. icon: '/image/cb/1.png',
  203. tex: '查看图片',
  204. path: '/pages/cb/cbd/equip-set/imgpage',
  205. tf: QueryPermission(61),
  206. },
  207. {
  208. icon: '/image/cb/3.png',
  209. tex: '害虫分析',
  210. path: '/pages/cb/cbd/equip-set/analyse',
  211. tf: QueryPermission(163),
  212. },
  213. {
  214. icon: '/image/cb/4.png',
  215. tex: '设备控制',
  216. path: '/pages/cb/cbd/equip-set/equip-set',
  217. tf: QueryPermission(62),
  218. },
  219. {
  220. icon: '/image/cb/6.png',
  221. tex: 'sim卡详情',
  222. path: '/pages/prevention/sim',
  223. tf: QueryPermission(274),
  224. },
  225. {
  226. icon: '/image/environment/7.png',
  227. tex: '一键报修',
  228. path: '/pages/afterSale/addafter',
  229. tf: true,
  230. },
  231. ],
  232. bzy: [
  233. {
  234. icon: '/image/cb/4.png',
  235. tex: '设备控制',
  236. path: '/pages/cb/bzy/equip-set/equip-set',
  237. tf: QueryPermission(69),
  238. },
  239. {
  240. icon: '/image/cb/1.png',
  241. tex: '查看图片',
  242. path: '/pages/cb/cbd/equip-set/imgpage',
  243. tf: QueryPermission(68),
  244. },
  245. {
  246. icon: '/image/cb/6.png',
  247. tex: 'sim卡详情',
  248. path: '/pages/prevention/sim',
  249. tf: QueryPermission(70),
  250. },
  251. {
  252. icon: '/image/environment/7.png',
  253. tex: '一键报修',
  254. path: '/pages/afterSale/addafter',
  255. tf: true,
  256. },
  257. ],
  258. xy: [
  259. {
  260. icon: '/image/cb/4.png',
  261. tex: '设备控制',
  262. path: '/pages/cb/xy/equip-set/equip-set',
  263. tf: QueryPermission(65),
  264. },
  265. {
  266. icon: '/image/cb/6.png',
  267. tex: 'sim卡详情',
  268. path: '/pages/prevention/sim',
  269. tf: QueryPermission(66),
  270. },
  271. {
  272. icon: '/image/cb/2.png',
  273. tex: '历史数据',
  274. path: '/pages/cb/xy/equip-set/xyhistoryile',
  275. tf: QueryPermission(67),
  276. },
  277. {
  278. icon: '/image/environment/7.png',
  279. tex: '一键报修',
  280. path: '/pages/afterSale/addafter',
  281. tf: true,
  282. },
  283. ],
  284. newState: {}, //设备最新状态
  285. setTimeShow: false,
  286. glass_show: false,
  287. cultivate_show: false,
  288. cultivate_time: '',
  289. glass_slide_time: '',
  290. glassErr: '',
  291. culErr: '',
  292. yxShow: false, //诱芯弹框
  293. xyErr: '',
  294. decoy: '',
  295. newtishitf: false, //暂无数据提示
  296. dataloadingtf: true, //加载中提示
  297. date: '', //最大可选时间
  298. };
  299. },
  300. computed: {
  301. curEquip() {
  302. switch (this.type) {
  303. case 3:
  304. if (this.equipInfo.device_model == 11) {
  305. // 虫情信息采集设备
  306. let permission = [
  307. QueryPermission(294),
  308. QueryPermission(296),
  309. QueryPermission(295),
  310. QueryPermission(293),
  311. true,
  312. ];
  313. this.cbd.map((cb, index) => {
  314. cb.tf = permission[index];
  315. });
  316. console.log(this.cbd);
  317. }
  318. return this.cbd;
  319. case 7:
  320. if (this.equipInfo.device_model == 51) {
  321. // 孢子仪1.0
  322. let permission = [
  323. QueryPermission(301),
  324. QueryPermission(302),
  325. QueryPermission(303),
  326. true,
  327. ];
  328. this.bzy.map((cb, index) => {
  329. cb.tf = permission[index];
  330. });
  331. } else if (this.equipInfo.device_model == 52) {
  332. // 孢子仪2.0
  333. let permission = [
  334. QueryPermission(308),
  335. QueryPermission(309),
  336. QueryPermission(310),
  337. true,
  338. ];
  339. this.bzy.map((cb, index) => {
  340. cb.tf = permission[index];
  341. });
  342. }
  343. return this.bzy;
  344. case 4:
  345. return this.xy;
  346. }
  347. },
  348. curState() {
  349. switch (this.type) {
  350. case 3:
  351. let blbs = ''; //灯管状态
  352. if (this.newState.lamp != undefined) {
  353. if (this.newState.ws == 1) {
  354. if (this.newState.lamp == 1) {
  355. blbs = '异常';
  356. } else if (equipState.lux == 0) {
  357. blbs = 'N/A(未检测到传感器)';
  358. } else if (this.newState.lamp == 0) {
  359. blbs = '工作';
  360. }
  361. } else {
  362. blbs = '待机';
  363. }
  364. } else {
  365. blbs = '--';
  366. }
  367. console.log('新状态:::::', this.newState);
  368. return [
  369. {
  370. icon: '/image/cb/icon02.png',
  371. txt: '在线状态',
  372. value: Number(this.device_status) == 1 ? '在线' : '离线',
  373. },
  374. {
  375. icon: '/image/cb/icon05.png',
  376. txt: '开关状态',
  377. value: Number(this.newState.ds) == 1 ? '开机' : '关机',
  378. },
  379. {
  380. icon: '/image/cb/icon13.png',
  381. txt: '通道状态',
  382. value: Number(this.newState.upds) == 1 ? '落虫' : '排水',
  383. },
  384. {
  385. icon: '/image/cb/icon10.png',
  386. txt: '加热状态',
  387. value: Number(this.newState.hs) == 1 ? '加热' : '正常',
  388. },
  389. {
  390. icon: '/image/cb/icon08.png',
  391. txt: '环境温度(℃)',
  392. value:
  393. this.newState.at == '2.5' ||
  394. this.newState.at == '25.0' ||
  395. this.newState.at == '' ||
  396. this.newState.at == '25'
  397. ? this.newState.new_tem
  398. : this.newState.at,
  399. },
  400. {
  401. icon: '/image/cb/icon07.png',
  402. txt: '环境湿度(%)',
  403. value:
  404. this.newState.ah == '30.0' ||
  405. this.newState.ah == '30.0' ||
  406. this.newState.ah == '' ||
  407. this.newState.ah == '30'
  408. ? this.newState.new_hum
  409. : this.newState.ah,
  410. },
  411. {
  412. icon: '/image/cb/icon16.png',
  413. txt: '信号强度',
  414. value: this.newState.csq,
  415. },
  416. {
  417. icon: '/image/cb/icon12.png',
  418. txt: '设备版本',
  419. value: this.newState.dver,
  420. },
  421. {
  422. icon: '/image/cb/icon17.png',
  423. txt: '雨控状态',
  424. value: Number(this.newState.rps) == 1 ? '雨控' : '正常',
  425. },
  426. {
  427. icon: '/image/cb/icon14.png',
  428. txt: '温控状态',
  429. value: Number(this.newState.tps) == 1 ? '温控' : '正常',
  430. },
  431. {
  432. icon: '/image/cb/icon06.png',
  433. txt: '光控状态',
  434. value: Number(this.newState.lps) == 1 ? '光控' : '正常',
  435. },
  436. {
  437. icon: '/image/cb/icon01.png',
  438. txt: '灯管状态',
  439. value: blbs,
  440. },
  441. {
  442. icon: '/image/cb/icon11.png',
  443. txt: '上仓门',
  444. value: Number(this.newState.upds) == 1 ? '打开' : '关闭',
  445. },
  446. {
  447. icon: '/image/cb/icon15.png',
  448. txt: '下仓门',
  449. value: Number(this.newState.dnds) == 1 ? '打开' : '关闭',
  450. },
  451. ];
  452. case 7:
  453. if (this.newState.pre_temp) {
  454. return [
  455. {
  456. icon: '/image/cb/icon02.png',
  457. txt: '在线状态',
  458. value: Number(this.device_status) == 1 ? '在线' : '离线',
  459. },
  460. {
  461. icon: '/image/cb/icon05.png',
  462. txt: '设备开关',
  463. value: Number(this.newState.ds) == 1 ? '开启' : '关闭',
  464. },
  465. {
  466. icon: '/image/cb/bzy/3.png',
  467. txt: '摄像头状态',
  468. value: this.newState.usb_sta == 1 ? '异常' : '正常',
  469. },
  470. {
  471. icon: '/image/prevention/44.png',
  472. txt: '当前电压',
  473. value: this.newState.v_bat,
  474. },
  475. {
  476. icon: '/image/cb/icon08.png',
  477. txt: '环境温度(℃)',
  478. value:
  479. this.newState.at == '2.5' ||
  480. this.newState.at == '25' ||
  481. this.newState.at == '' ||
  482. this.newState.at == '25.0'
  483. ? this.newState.new_tem
  484. : this.newState.at,
  485. },
  486. {
  487. icon: '/image/prevention/66.png',
  488. txt: '环境湿度(%)',
  489. value:
  490. this.newState.ah == '30' ||
  491. this.newState.ah == '3.0' ||
  492. this.newState.ah == '' ||
  493. this.newState.ah == '30.0'
  494. ? this.newState.new_hum
  495. : this.newState.ah,
  496. },
  497. {
  498. icon: '/image/cb/icon16.png',
  499. txt: '信号强度',
  500. value: this.newState.csq,
  501. },
  502. {
  503. icon: '/image/cb/bzy/8.png',
  504. txt: '已培养时间',
  505. value: this.newState.staytime,
  506. },
  507. {
  508. icon: '/image/cb/icon12.png',
  509. txt: '设备版本',
  510. value: this.newState.dver,
  511. },
  512. {
  513. icon: '/image/cb/icon09.png',
  514. txt: '保温仓当前温度',
  515. value: this.newState.pre_temp,
  516. },
  517. {
  518. icon: '/image/cb/icon08.png',
  519. txt: '保温仓设定温度',
  520. value: this.newState.set_temp,
  521. },
  522. ];
  523. } else {
  524. return [
  525. {
  526. icon: '/image/cb/icon02.png',
  527. txt: '在线状态',
  528. value: Number(this.device_status) == 1 ? '在线' : '离线',
  529. },
  530. {
  531. icon: '/image/cb/icon05.png',
  532. txt: '设备开关',
  533. value: Number(this.newState.ds) == 1 ? '开启' : '关闭',
  534. },
  535. {
  536. icon: '/image/cb/bzy/3.png',
  537. txt: '摄像头状态',
  538. value: this.newState.usb_sta == 1 ? '异常' : '正常',
  539. },
  540. {
  541. icon: '/image/prevention/44.png',
  542. txt: '当前电压',
  543. value: this.newState.v_bat,
  544. },
  545. {
  546. icon: '/image/cb/icon08.png',
  547. txt: '环境温度(℃)',
  548. value:
  549. this.newState.at == '2.5' ||
  550. this.newState.at == '25' ||
  551. this.newState.at == '' ||
  552. this.newState.at == '25.0'
  553. ? this.newState.new_tem
  554. : this.newState.at,
  555. },
  556. {
  557. icon: '/image/prevention/66.png',
  558. txt: '环境湿度(%)',
  559. value:
  560. this.newState.ah == '30' ||
  561. this.newState.ah == '3.0' ||
  562. this.newState.ah == '' ||
  563. this.newState.ah == '30.0'
  564. ? this.newState.new_hum
  565. : this.newState.ah,
  566. },
  567. {
  568. icon: '/image/cb/icon16.png',
  569. txt: '信号强度',
  570. value: this.newState.csq,
  571. },
  572. {
  573. icon: '/image/cb/bzy/8.png',
  574. txt: '已培养时间',
  575. value: this.newState.staytime,
  576. },
  577. {
  578. icon: '/image/cb/icon12.png',
  579. txt: '设备版本',
  580. value: this.newState.dver,
  581. },
  582. ];
  583. }
  584. case 4:
  585. return [
  586. {
  587. icon: '/image/cb/icon02.png',
  588. txt: '在线状态',
  589. value: Number(this.device_status) == 1 ? '在线' : '离线',
  590. },
  591. {
  592. icon: '/image/cb/icon05.png',
  593. txt: '设备开关',
  594. value: this.newState.ds == 1 ? '开启' : '关闭',
  595. },
  596. {
  597. icon: '/image/cb/icon02.png',
  598. txt: '工作状态',
  599. value: this.newState.ws == 1 ? '工作' : ' 待机',
  600. },
  601. {
  602. icon: '/image/cb/icon12.png',
  603. txt: '设备版本',
  604. value: this.newState.dver,
  605. },
  606. {
  607. icon: '/image/cb/icon08.png',
  608. txt: '环境温度(℃)',
  609. value:
  610. this.newState.at == '2.5' ||
  611. this.newState.at == '25' ||
  612. this.newState.at == '' ||
  613. this.newState.at == '25.0'
  614. ? this.newState.new_tem
  615. : this.newState.at,
  616. },
  617. {
  618. icon: '/image/cb/icon07.png',
  619. txt: '环境湿度(%)',
  620. value:
  621. this.newState.ah == '30' ||
  622. this.newState.ah == '3.0' ||
  623. this.newState.ah == '' ||
  624. this.newState.ah == '30.0'
  625. ? this.newState.new_hum
  626. : this.newState.ah,
  627. },
  628. {
  629. icon: '/image/prevention/105.png',
  630. txt: '充电电压',
  631. value: this.newState.cv,
  632. },
  633. {
  634. icon: '/image/prevention/106.png',
  635. txt: '电池电压',
  636. value: this.newState.bv,
  637. },
  638. {
  639. icon: '/image/cb/icon16.png',
  640. txt: '信号强度',
  641. value: this.newState.csq,
  642. },
  643. {
  644. icon: '/image/cb/xy/9.png',
  645. txt: '充电状态',
  646. value: Number(this.newState.cs) == 1 ? '充电' : '正常',
  647. },
  648. {
  649. icon: '/image/cb/xy/10.png',
  650. txt: '电池状态',
  651. value: this.newState.bs,
  652. },
  653. {
  654. icon: '/image/cb/xy2.0/yujing.png',
  655. txt: '诱虫次数',
  656. value: this.newState.yc,
  657. },
  658. ];
  659. }
  660. },
  661. },
  662. filters: {
  663. equipType(type) {
  664. switch (type) {
  665. case 3:
  666. return '虫情测报灯';
  667. case 7:
  668. return '孢子仪';
  669. case 4:
  670. return '性诱测报';
  671. }
  672. },
  673. formatValue(val, a1, a2) {
  674. if (a2 == 4 && a1 == '电池状态') {
  675. switch (Number(val)) {
  676. case 0:
  677. return '正常';
  678. break;
  679. case 1:
  680. return '欠压';
  681. break;
  682. case 2:
  683. return '过压';
  684. break;
  685. }
  686. } else {
  687. return val ? val : '无';
  688. }
  689. },
  690. },
  691. onLoad(option) {
  692. this.equipInfo = JSON.parse(option.info);
  693. this.type =
  694. Number(this.equipInfo.type) ||
  695. Number(this.equipInfo.equip_type) ||
  696. Number(this.equipInfo.device_type_id);
  697. this.equipInfo.type = this.type;
  698. this.device_status = this.equipInfo.is_online;
  699. this.getState();
  700. console.log(this.equipInfo);
  701. if (this.equipInfo.disable) {
  702. if (this.equipInfo.disable == 0) {
  703. this.cbd[3].tf = false;
  704. } else {
  705. this.cbd[3].tf = true;
  706. }
  707. }
  708. this.selectaddress(Number(this.equipInfo.lat), Number(this.equipInfo.lng));
  709. var times = new Date();
  710. this.date =
  711. times.getFullYear() +
  712. 1 +
  713. '-' +
  714. Number(times.getMonth() + 1) +
  715. '-' +
  716. times.getDate();
  717. },
  718. methods: {
  719. async getState() {
  720. this.dataloadingtf = true;
  721. const res = await this.$myRequest({
  722. url: '/api/api_gateway?method=forecast.worm_lamp.device_history_data',
  723. data: {
  724. device_type_id:
  725. this.equipInfo.type ||
  726. this.equipInfo.equip_type ||
  727. this.equipInfo.device_type_id,
  728. device_id: this.equipInfo.imei || this.equipInfo.device_id,
  729. page: 1,
  730. page_size: 1,
  731. start_time: Math.floor((+new Date() - 24 * 60 * 60 * 1000) / 1000),
  732. end_time: Math.floor(+new Date() / 1000),
  733. },
  734. });
  735. if (res.counts != 0) {
  736. this.newState = res.data[0].d_h_t;
  737. this.newtishitf = false;
  738. } else {
  739. this.newtishitf = true;
  740. }
  741. this.getxyyc();
  742. },
  743. async getxyyc() {
  744. const res = await this.$myRequest({
  745. url: '/api/api_gateway?method=forecast.worm_lamp.xycb_pest_chart',
  746. data: {
  747. device_type_id:
  748. this.equipInfo.type ||
  749. this.equipInfo.equip_type ||
  750. this.equipInfo.device_type_id,
  751. d_id: this.equipInfo.d_id,
  752. page: 1,
  753. page_size: 1,
  754. start_time: Math.floor(
  755. (+new Date() - 30 * 24 * 60 * 60 * 1000) / 1000
  756. ),
  757. end_time: Math.floor(+new Date() / 1000),
  758. },
  759. });
  760. this.newState.yc = res.total_num;
  761. this.dataloadingtf = false;
  762. },
  763. partClick(path) {
  764. console.log(path);
  765. var device_id = this.equipInfo.device_id || this.equipInfo.imei;
  766. uni.navigateTo({
  767. url:
  768. path +
  769. '?d_id=' +
  770. this.equipInfo.d_id +
  771. '&device_id=' +
  772. device_id +
  773. '&device_type=' +
  774. this.type +
  775. '&disable=' +
  776. this.equipInfo.disable,
  777. });
  778. },
  779. partClicks() {
  780. var path = '';
  781. var device_id = this.equipInfo.device_id || this.equipInfo.imei;
  782. if (this.type == 3) {
  783. path = '/pages/cb/cbd/equip-set/historyfile';
  784. } else if (this.type == 7) {
  785. path = '/pages/cb/bzy/equip-set/bzyhistoryile';
  786. }
  787. uni.navigateTo({
  788. url:
  789. path +
  790. '?d_id=' +
  791. this.equipInfo.d_id +
  792. '&device_id=' +
  793. device_id +
  794. '&device_type=' +
  795. this.type,
  796. });
  797. },
  798. async setTime(d_id) {
  799. const res = await this.$myRequest({
  800. url: '/api/api_gateway?method=device.device_manage.get_spore_time',
  801. data: {
  802. device_type_id: this.type,
  803. d_id,
  804. },
  805. });
  806. this.glass_slide_time = res.glass_slide_time
  807. ? this.formatTime(res.glass_slide_time * 1000, 'yyyy-MM-dd')
  808. : '';
  809. this.cultivate_time = res.cultivate_time
  810. ? this.formatTime(res.cultivate_time * 1000, 'yyyy-MM-dd')
  811. : '';
  812. this.setTimeShow = true;
  813. },
  814. timeChange(e, a) {
  815. if (a == 'glass') {
  816. this.glass_slide_time = e.result;
  817. this.glassErr = '';
  818. } else {
  819. this.cultivate_time = e.result;
  820. this.culErr = '';
  821. }
  822. },
  823. async setTimeSubmit() {
  824. if (!this.glass_slide_time) {
  825. this.glassErr = '请填写载玻片更换时间';
  826. }
  827. if (!this.cultivate_time) {
  828. this.culErr = '请填写培养液更换时间';
  829. return;
  830. }
  831. let glass = parseInt(new Date(this.glass_slide_time).getTime() / 1000);
  832. let cultivate = parseInt(new Date(this.cultivate_time).getTime() / 1000);
  833. const res = await this.$myRequest({
  834. url: '/api/api_gateway?method=device.device_manage.updata_spore_time',
  835. data: {
  836. device_type_id: this.type,
  837. d_id: this.equipInfo.d_id,
  838. glass_slide_time: glass,
  839. cultivate_time: cultivate,
  840. },
  841. });
  842. if (res) {
  843. this.$refs.toast.show({
  844. title: '修改成功!',
  845. type: 'success',
  846. });
  847. }
  848. this.setTimeShow = false;
  849. },
  850. async addYx(d_id) {
  851. const res = await this.$myRequest({
  852. url: '/api/api_gateway?method=device.device_manage.get_spore_time',
  853. data: {
  854. device_type_id: this.type,
  855. d_id,
  856. },
  857. });
  858. this.decoy = res.decoy;
  859. this.yxShow = true;
  860. },
  861. async cbnote(d_id) {
  862. const res = await this.$myRequest({
  863. url: '/api/api_gateway?method=device.device_manage.get_spore_time',
  864. data: {
  865. device_type_id: this.type,
  866. d_id,
  867. },
  868. });
  869. this.decoy = res.decoy;
  870. this.yxShow = true;
  871. },
  872. async yxSubmit() {
  873. if (!this.decoy) {
  874. this.xyErr = '请填写监测害虫名称';
  875. return false;
  876. }
  877. const res = await this.$myRequest({
  878. url: '/api/api_gateway?method=device.device_manage.updata_spore_time',
  879. data: {
  880. device_type_id: this.type,
  881. d_id: this.equipInfo.d_id,
  882. decoy: this.decoy,
  883. },
  884. });
  885. if (res) {
  886. this.xyErr = '';
  887. this.yxShow = false;
  888. }
  889. },
  890. selectaddress(lat, lng) {
  891. //获取分布位置
  892. uni.request({
  893. type: 'GET',
  894. url:
  895. 'https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=' +
  896. lng +
  897. ',' +
  898. lat +
  899. '&key=27273b81090f78759e4057f94474516f&radius=1000&extensions=all',
  900. dataType: 'json',
  901. complete: (ress) => {
  902. console.log(ress);
  903. // this.city = ress.data.regeocode.formatted_address
  904. if (ress.data.regeocode.formatted_address.length == 0) {
  905. this.city = '--';
  906. } else {
  907. this.city = ress.data.regeocode.formatted_address;
  908. }
  909. },
  910. });
  911. },
  912. copy(item) {
  913. console.log(item);
  914. uni.setClipboardData({
  915. data: item.imei || item.device_id,
  916. success: function () {
  917. console.log('success');
  918. },
  919. });
  920. },
  921. glass_slide_timeTime(date) {
  922. if (date === 0) {
  923. return '载玻片未到期';
  924. } else if (date == 1) {
  925. return '载玻片已到期';
  926. } else if (date == 2) {
  927. return '载玻片即将到期';
  928. } else if (date === '') {
  929. return '请设置培养液时间';
  930. }
  931. },
  932. cultivateTime(date) {
  933. console.log(date);
  934. if (date === 0) {
  935. return '培养液未到期';
  936. } else if (date == 1) {
  937. return '培养液已到期';
  938. } else if (date == 2) {
  939. return '培养液即将到期';
  940. } else if (date === '') {
  941. return '请设置培养液时间';
  942. }
  943. },
  944. },
  945. };
  946. </script>
  947. <style lang="scss">
  948. page {
  949. padding: 20rpx;
  950. box-sizing: border-box;
  951. .info {
  952. padding: 20rpx 40rpx;
  953. color: #fff;
  954. line-height: 50rpx;
  955. font-size: 26rpx;
  956. background-size: 100% auto;
  957. background-repeat: no-repeat;
  958. background-color: #0dc6b6;
  959. background-position: top left;
  960. box-sizing: border-box;
  961. width: 100%;
  962. .tishi {
  963. width: 28rpx;
  964. height: 28rpx;
  965. margin: 0rpx 0 0 20rpx;
  966. }
  967. }
  968. .on {
  969. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cb/onBg.png');
  970. }
  971. .off {
  972. background-image: url('https://s3.hnyfwlw.com/webstaticimg/bigdata_app/image/cb/offBg.png');
  973. }
  974. .equip_part {
  975. display: flex;
  976. flex-wrap: wrap;
  977. text-align: center;
  978. font-size: 28rpx;
  979. color: #666;
  980. line-height: 50rpx;
  981. image {
  982. width: 52rpx;
  983. }
  984. .item1 {
  985. padding: 20rpx 0;
  986. box-sizing: border-box;
  987. flex-basis: 25%;
  988. }
  989. .item2 {
  990. padding: 20rpx 10rpx;
  991. box-sizing: border-box;
  992. flex-basis: 33%;
  993. /* flex-grow: 1; */
  994. }
  995. .item3 {
  996. padding: 20rpx 0;
  997. box-sizing: border-box;
  998. flex-basis: 25%;
  999. }
  1000. }
  1001. .tit {
  1002. font-weight: 800;
  1003. height: 50rpx;
  1004. font-size: 30rpx;
  1005. margin-bottom: 20rpx;
  1006. display: flex;
  1007. justify-content: space-between;
  1008. .span {
  1009. color: #6e6c76;
  1010. font-size: 24rpx;
  1011. display: flex;
  1012. justify-content: space-between;
  1013. /* margin-top: 12rpx; */
  1014. }
  1015. }
  1016. .newtishi {
  1017. width: 90%;
  1018. margin: 0 auto;
  1019. text-align: center;
  1020. padding-top: 40rpx;
  1021. font-size: 32rpx;
  1022. .dataloading:after {
  1023. overflow: hidden;
  1024. display: inline-block;
  1025. vertical-align: bottom;
  1026. animation: ellipsis 2s infinite;
  1027. content: '\2026';
  1028. }
  1029. @keyframes ellipsis {
  1030. from {
  1031. width: 2px;
  1032. }
  1033. to {
  1034. width: 15px;
  1035. }
  1036. }
  1037. }
  1038. .newState {
  1039. display: flex;
  1040. flex-wrap: wrap;
  1041. text-align: center;
  1042. margin: 0 -10rpx;
  1043. .item {
  1044. display: flex;
  1045. flex-wrap: nowrap;
  1046. margin: 10rpx;
  1047. width: 345rpx;
  1048. justify-content: flex-start;
  1049. padding: 20rpx 20rpx 20rpx 30rpx;
  1050. box-sizing: border-box;
  1051. border-radius: 4px;
  1052. box-shadow: 0px 0px 5px 3px rgba(136, 136, 136, 0.1);
  1053. font-size: 24rpx;
  1054. .info-con {
  1055. padding-left: 30rpx;
  1056. text-align: left;
  1057. line-height: 40rpx;
  1058. }
  1059. image {
  1060. width: 70rpx;
  1061. height: 72rpx;
  1062. }
  1063. }
  1064. }
  1065. .btn-box {
  1066. text-align: center;
  1067. padding: 30rpx;
  1068. }
  1069. .field {
  1070. ::v-deep .uni-input-input {
  1071. border: 2rpx solid #ff0000;
  1072. border-radius: 24rpx;
  1073. width: 140px;
  1074. padding-left: 10rpx;
  1075. box-sizing: border-box;
  1076. }
  1077. }
  1078. }
  1079. ::v-deep .u-calendar__action {
  1080. display: flex;
  1081. justify-content: space-around;
  1082. .u-calendar__action__text {
  1083. line-height: 25px;
  1084. }
  1085. }
  1086. .red {
  1087. color: rgb(235, 103, 101);
  1088. }
  1089. </style>