xctdetail.vue 17 KB

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