xctdetail.vue 14 KB

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