smallPest.vue 15 KB

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