smallPest.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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 src="http://www.hnyfwlw.com:8006/bigdata_app/image/environment/fuzhi.png" mode="" class="tishi">
  7. </image>
  8. </view>
  9. <view class="">
  10. 设备名称:{{equipInfo.device_name==""?"无":equipInfo.device_name}}
  11. </view>
  12. <!-- <view class="">
  13. 设备类型:吸虫塔
  14. </view> -->
  15. <view class="">
  16. 最新上报时间:{{equipInfo.uptime||equipInfo.uptime | timeFormat}}
  17. </view>
  18. <view class="">
  19. 设备地址:{{equipInfo.address||city}}
  20. </view>
  21. </view>
  22. <view class="caobox">
  23. <view class="caobox_item" v-if="$QueryPermission(351)" @click="tophoto">
  24. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/1.png" mode="widthFix"></image>
  25. <view class="">
  26. 查看图片
  27. </view>
  28. </view>
  29. <view class="caobox_item" v-if="$QueryPermission(350)" @click="toset">
  30. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/4.png" mode="widthFix"></image>
  31. <view class="">
  32. 设备控制
  33. </view>
  34. </view>
  35. <view class="caobox_item" v-if="$QueryPermission(353)" @click="toanal">
  36. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/3.png" mode="widthFix"></image>
  37. <view class="">
  38. 虫情分析
  39. </view>
  40. </view>
  41. <view class="caobox_item" @click="simRouter">
  42. <image src="http://www.hnyfwlw.com:8006/bigdata_app/image/cb/6.png" mode="widthFix"></image>
  43. <view class="">
  44. SIM卡
  45. </view>
  46. </view>
  47. </view>
  48. <view class="" v-if="$QueryPermission(352)">
  49. <view class="">
  50. 历史数据
  51. </view>
  52. <view class="timebox">
  53. <view class="firsttime" @click="timeshow=true">
  54. <view class="" v-if="start_time!=''">
  55. {{start_time/1000|timeFormat()}}
  56. </view>
  57. <view class="" v-else>
  58. {{start_time==""?'请选择开始时间':start_time}}
  59. </view>
  60. </view>
  61. <view class="jiange">
  62. -
  63. </view>
  64. <view class="endtime" @click="timeshow=true">
  65. <view class="" v-if="end_time!=''">
  66. {{end_time/1000|timeFormat()}}
  67. </view>
  68. <view class="" v-else>
  69. {{end_time==""?'请选择结束时间':end_time}}
  70. </view>
  71. </view>
  72. <u-calendar v-model="timeshow" :mode="mode" @change="timechange"></u-calendar>
  73. </view>
  74. <view class="shuju_one">
  75. <view class="canvastishi" v-if="!canvastishiTF && !dataloadingtf">
  76. 暂无数据
  77. </view>
  78. <view class="canvastishi" v-if="dataloadingtf">
  79. <p class="dataloading">加载中</p>
  80. </view>
  81. <canvas v-if="canvastishiTF" canvas-id="canvasColumnA" id="canvasColumnA" class="charts"
  82. @touchstart="touchLineA($event)" @touchmove="moveLineA($event)" @touchend="touchEndLineA($event)"
  83. disable-scroll=true
  84. :style="{'width':cWidth*pixelRatio+'px','height':cHeight*pixelRatio+'px', 'transform': 'scale('+(1/pixelRatio)+')','margin-left':-cWidth*(pixelRatio-1)/2+'px','margin-top':-cHeight*(pixelRatio-1)/2+'px'}"></canvas>
  85. </view>
  86. <view class="condition">
  87. <scroll-view scroll-top="0" scroll-x="true" class="scroll-X">
  88. <table class="table" v-if="$QueryPermission(354)">
  89. <tr class="tr">
  90. <th class="th" v-for="(item,index) in tableHeadTxt" :key="'a'+index">{{item}}</th>
  91. </tr>
  92. <tr class="tr" v-for="(items,indexs) in historylistdata" :key="'b'+indexs" v-if="!forbidden">
  93. <td class="td">{{items.d_h_t.addtime|timeFormat()}}</td>
  94. <td class="td">{{items.d_h_t.at}}</td>
  95. <td class="td">{{items.d_h_t.ah}}</td>
  96. <td class="td">{{items.d_h_t.dver}}</td>
  97. <td class="td">{{items.d_h_t.nrps}}</td>
  98. <td class="td">{{items.d_h_t.ntps}}</td>
  99. <td class="td">{{items.d_h_t.lps}}</td>
  100. <td class="td">{{items.d_h_t.lamp}}</td>
  101. <td class="td">{{items.d_h_t.current}}</td>
  102. <td class="td">{{items.d_h_t.vbat}}</td>
  103. <td class="td">{{items.d_h_t.lng}}</td>
  104. <td class="td">{{items.d_h_t.lat}}</td>
  105. </tr>
  106. <tr class="tr" v-if="forbidden">
  107. <td class="td" v-for="item in 9">暂无数据</td>
  108. </tr>
  109. </table>
  110. <table class="table" v-else>
  111. <tr class="tr">
  112. <th class="th" v-for="(item,index) in tableHeadTxt2" :key="'a'+index">{{item}}</th>
  113. </tr>
  114. <tr class="tr" v-for="(items,indexs) in historylistdata" :key="'b'+indexs" v-if="!forbidden">
  115. <td class="td">{{items.d_h_t.addtime|timeFormat()}}</td>
  116. <td class="td">{{items.d_h_t.at}}</td>
  117. <td class="td">{{items.d_h_t.ah}}</td>
  118. <td class="td">{{items.d_h_t.dver}}</td>
  119. <td class="td">{{items.d_h_t.lps}}</td>
  120. <td class="td">{{items.d_h_t.lng}}</td>
  121. <td class="td">{{items.d_h_t.lat}}</td>
  122. </tr>
  123. <tr class="tr" v-if="forbidden">
  124. <td class="td" v-for="item in 7">暂无数据</td>
  125. </tr>
  126. </table>
  127. </scroll-view>
  128. <view class="pagenumber">
  129. <button @click="prev">上一页</button>
  130. <view class="pagenumber_page">
  131. 第 {{page}} 页
  132. </view>
  133. <view class="pagenumber_page">
  134. 共 {{pagesum}} 页
  135. </view>
  136. <button @click="next" :disabled="forbidden">下一页</button>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="" v-else>
  141. 暂无数据
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. import uCharts from '../../../components/js_sdk/u-charts/u-charts/u-charts.js';
  147. // import Circulation from "../../../static/js/equipState_dict.json"
  148. var canvaColumnA = null;
  149. export default {
  150. data() {
  151. return {
  152. equipInfo: {},
  153. canvastishiTF: false,
  154. dataloadingtf: false,
  155. cWidth: '400',
  156. cHeight: '400',
  157. pixelRatio: 1,
  158. start_time: "",
  159. end_time: "",
  160. timeshow: false,
  161. mode: 'range',
  162. historydatas: [],
  163. tableHeadTxt: [
  164. "上报时间",
  165. "环境温度(°C)",
  166. "环境湿度(%)",
  167. "版本号",
  168. "雨控状态",
  169. "温控状态",
  170. "光控状态",
  171. "灯管状态",
  172. "电流(mA)",
  173. "电压(V)",
  174. "经度",
  175. "纬度",
  176. ],
  177. tableHeadTxt2: [
  178. "上报时间",
  179. "环境温度(°C)",
  180. "环境湿度(%)",
  181. "版本号",
  182. "光控状态",
  183. "经度",
  184. "纬度",
  185. ],
  186. historylistdata: [],
  187. pagesum: 10,
  188. page: 1,
  189. forbidden: false
  190. }
  191. },
  192. methods: {
  193. copy(item) {
  194. console.log(item)
  195. uni.setClipboardData({
  196. data: item.imei || item.device_id,
  197. success: function() {
  198. console.log('success');
  199. }
  200. });
  201. },
  202. toset() {
  203. uni.navigateTo({
  204. url: "./xctset?device_id=" + this.equipInfo.imei + "&d_id=" + this.equipInfo.d_id + "&dtype=" +
  205. this.equipInfo.dtype +
  206. "&device_name=" + this.equipInfo.device_name
  207. })
  208. },
  209. tophoto() {
  210. uni.navigateTo({
  211. url: "./photolist?device_id=" + this.equipInfo.imei + "&d_id=" + this.equipInfo.d_id
  212. })
  213. },
  214. toanal() {
  215. uni.navigateTo({
  216. url: "./analyse?d_id=" + this.equipInfo.d_id + "&device_id=" + this.equipInfo.imei +
  217. "&device_type=12&disable=" + this.equipInfo.disable
  218. })
  219. },
  220. simRouter() {
  221. uni.navigateTo({
  222. url: "/pages/prevention/sim?id=" + this.equipInfo.d_id
  223. })
  224. },
  225. timechange(e) {
  226. this.start_time = +new Date(e.startDate)
  227. this.end_time = +new Date(e.endDate)
  228. this.history()
  229. this.getwind()
  230. },
  231. async history() { //历史数据列表折线图
  232. this.dataloadingtf = true
  233. const res = await this.$myRequest({
  234. url: '/api/api_gateway?method=forecast.haomi.haomi_line',
  235. data: {
  236. d_id: this.equipInfo.d_id,
  237. device_type_id: 28,
  238. start: Math.floor(+new Date(this.start_time) / 1000),
  239. end: Math.floor(+new Date(this.end_time) / 1000),
  240. }
  241. })
  242. console.log(res)
  243. this.dataloadingtf = false
  244. this.historydatas = res
  245. console.log(this.historydatas)
  246. if (this.historydatas.length == 0) {
  247. this.canvastishiTF = false
  248. } else {
  249. this.canvastishiTF = true
  250. var arr1 = []
  251. var arr2 = []
  252. var arr3 = []
  253. var xtitle = []
  254. for (var i = 0; i < res.length; i++) {
  255. var times = new Date(res[i].addtime * 1000)
  256. xtitle.push(times.getMonth() + 1 + "/" + times.getDate() + "-" + times.getHours() + ":" + times
  257. .getMinutes())
  258. arr1.push(res[i].at == "" ? "0" : res[i].at)
  259. arr2.push(res[i].ah == "" ? "0" : res[i].ah)
  260. }
  261. // console.log(arr1)
  262. var obj = [{
  263. name: '温度',
  264. data: arr1,
  265. color: '#00E29D'
  266. }, {
  267. name: '湿度',
  268. data: arr2,
  269. color: '#6CBBFF'
  270. }]
  271. this.showColumn("canvasColumnA", xtitle, obj)
  272. }
  273. },
  274. showColumn(id, xtitle, xinfo) {
  275. var _self = this
  276. canvaColumnA = new uCharts({
  277. canvasId: id,
  278. type: 'line',
  279. legend: {
  280. position: "top"
  281. },
  282. fontSize: 11,
  283. background: '#FFFFFF',
  284. pixelRatio: 1,
  285. animation: true,
  286. dataLabel: false,
  287. categories: xtitle,
  288. series: xinfo,
  289. enableScroll: true, //开启图表拖拽功能
  290. xAxis: {
  291. disableGrid: true,
  292. type: 'grid',
  293. gridType: 'dash',
  294. itemCount: 4, //x轴单屏显示数据的数量,默认为5个
  295. scrollShow: true, //新增是否显示滚动条,默认false
  296. // scrollAlign: 'left', //滚动条初始位置
  297. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
  298. scrollColor: '#DEE7F7', //默认为 #A6A6A6
  299. },
  300. yAxis: {
  301. gridType: 'dash',
  302. gridColor: '#CCCCCC',
  303. dashLength: 8,
  304. splitNumber: 5,
  305. format: (val) => {
  306. return val.toFixed(1)
  307. }
  308. },
  309. width: _self.cWidth * 1,
  310. height: _self.cHeight * 1,
  311. extra: {
  312. line: {
  313. type: 'curve'
  314. }
  315. }
  316. });
  317. },
  318. touchLineA(e) {
  319. console.log(e)
  320. canvaColumnA.scrollStart(e);
  321. },
  322. moveLineA(e) {
  323. canvaColumnA.scroll(e);
  324. },
  325. touchEndLineA(e) {
  326. canvaColumnA.scrollEnd(e);
  327. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  328. canvaColumnA.showToolTip(e, {
  329. format: function(item, category) {
  330. return category + ' ' + item.name + ':' + item.data
  331. }
  332. });
  333. },
  334. async getwind() {
  335. const res = await this.$myRequest({
  336. url: '/api/api_gateway?method=forecast.haomi.haomi_data',
  337. data: {
  338. d_id: this.equipInfo.d_id,
  339. start_time: Math.floor(+new Date(this.start_time) / 1000),
  340. end_time: Math.floor(+new Date(this.end_time) / 1000),
  341. page: this.page,
  342. page_size: "10"
  343. }
  344. })
  345. console.log(res)
  346. if (res.data.length) {
  347. this.historylistdata = res.data
  348. this.pagesum = Math.ceil(res.counts / 10)
  349. this.forbidden = false
  350. } else {
  351. this.forbidden = true
  352. }
  353. },
  354. prev() { //上一页
  355. if (this.page > 1) {
  356. this.page--
  357. this.getwind()
  358. }
  359. },
  360. next() { //下一页
  361. if(this.page < this.pagesum){
  362. this.page++
  363. this.getwind()
  364. }
  365. },
  366. },
  367. onLoad(option) {
  368. console.log(JSON.parse(option.info))
  369. this.equipInfo = JSON.parse(option.info)
  370. this.end_time = +new Date()
  371. this.start_time = +new Date() - 30 * 24 * 60 * 60 * 1000
  372. this.cWidth = uni.upx2px(650);
  373. this.cHeight = uni.upx2px(500);
  374. this.history()
  375. this.getwind()
  376. },
  377. }
  378. </script>
  379. <style lang='scss'>
  380. page {
  381. padding: 20rpx;
  382. box-sizing: border-box;
  383. .info {
  384. padding: 20rpx 40rpx;
  385. color: #fff;
  386. line-height: 50rpx;
  387. font-size: 26rpx;
  388. background-size: 100% auto;
  389. background-repeat: no-repeat;
  390. background-color: #0DC6B6;
  391. background-position: top left;
  392. box-sizing: border-box;
  393. width: 100%;
  394. .tishi {
  395. width: 28rpx;
  396. height: 28rpx;
  397. margin: 0rpx 0 0 20rpx;
  398. }
  399. }
  400. .on {
  401. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/onBg.png')
  402. }
  403. .off {
  404. background-image: url('http://www.hnyfwlw.com:8006/bigdata_app/image/cb/offBg.png')
  405. }
  406. .caobox {
  407. display: flex;
  408. flex-wrap: wrap;
  409. text-align: center;
  410. font-size: 28rpx;
  411. color: #666;
  412. line-height: 50rpx;
  413. image {
  414. width: 52rpx;
  415. }
  416. .caobox_item {
  417. padding: 20rpx 0;
  418. box-sizing: border-box;
  419. flex-basis: 25%;
  420. }
  421. }
  422. .timebox {
  423. box-shadow: 0 0 10rpx #bcb9ca;
  424. display: flex;
  425. background-color: #fff;
  426. padding: 10px;
  427. border-top-right-radius: 5px;
  428. border-top-left-radius: 5px;
  429. margin-top: 30rpx;
  430. .jiange {
  431. width: 5%;
  432. text-align: center;
  433. }
  434. .firsttime,
  435. .endtime {
  436. width: 45%;
  437. text-align: center;
  438. }
  439. }
  440. .shuju_one {
  441. position: relative;
  442. width: 100%;
  443. margin: 40rpx auto;
  444. box-shadow: 0 0 10rpx #bcb9ca;
  445. padding-top: 20rpx;
  446. height: 550rpx;
  447. .canvastishi {
  448. font-size: 32rpx;
  449. position: absolute;
  450. top: 50%;
  451. left: 50%;
  452. margin-left: -64rpx;
  453. margin-top: -21rpx;
  454. .dataloading:after {
  455. overflow: hidden;
  456. display: inline-block;
  457. vertical-align: bottom;
  458. animation: ellipsis 2s infinite;
  459. content: "\2026";
  460. }
  461. @keyframes ellipsis {
  462. from {
  463. width: 2px;
  464. }
  465. to {
  466. width: 15px;
  467. }
  468. }
  469. }
  470. .shuju_one_title {
  471. width: 70%;
  472. margin: 0 auto;
  473. display: flex;
  474. .tltle_text {
  475. width: 25%;
  476. border: 2rpx solid #B2B2B2;
  477. color: #57c878;
  478. text-align: center;
  479. font-size: 24rpx;
  480. height: 50rpx;
  481. line-height: 50rpx;
  482. }
  483. .title_text_color {
  484. width: 25%;
  485. border: 2rpx solid #57c878;
  486. background-color: #57c878;
  487. color: #fff;
  488. text-align: center;
  489. font-size: 24rpx;
  490. height: 50rpx;
  491. line-height: 50rpx;
  492. }
  493. }
  494. }
  495. }
  496. .condition {
  497. display: flex;
  498. flex-wrap: wrap;
  499. width: 100%;
  500. margin: 30rpx auto;
  501. box-shadow: 0 0 10rpx #bcb9ca;
  502. margin-bottom: 30rpx;
  503. .scroll-X {
  504. width: 95%;
  505. margin: 20rpx auto;
  506. .table {
  507. width: 1432px;
  508. }
  509. .tr {
  510. display: flex;
  511. overflow: hidden;
  512. .th,
  513. .td {
  514. display: inline-block;
  515. padding: 5rpx;
  516. width: 240rpx;
  517. text-align: center;
  518. height: 52rpx;
  519. line-height: 52rpx;
  520. border: 2rpx solid #F1F1F1;
  521. }
  522. .th:first-child,
  523. .td:first-child {
  524. width: 300rpx;
  525. }
  526. }
  527. .tr:nth-child(2n-1) {
  528. background-color: #f5fff8;
  529. }
  530. .tr:first-child {
  531. background-color: #57c878;
  532. color: #fff;
  533. }
  534. }
  535. .pagenumber {
  536. display: flex;
  537. margin: 20rpx auto;
  538. button {
  539. width: 150rpx;
  540. height: 50rpx;
  541. line-height: 50rpx;
  542. font-size: 26rpx;
  543. text-align: center;
  544. background-color: #57c878;
  545. color: #FFFFFF;
  546. }
  547. .pagenumber_page {
  548. width: 150rpx;
  549. height: 50rpx;
  550. line-height: 50rpx;
  551. font-size: 26rpx;
  552. text-align: center;
  553. }
  554. }
  555. }
  556. /deep/.u-calendar__action {
  557. display: flex;
  558. justify-content: space-around;
  559. .u-calendar__action__text {
  560. line-height: 25px;
  561. }
  562. }
  563. </style>