xyhistoryile.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view>
  3. <view style="position: fixed;z-index: 100;">
  4. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" title="查看图片"></uni-nav-bar>
  5. </view>
  6. <view class="shuju_one">
  7. <view class="shuju_one_title">
  8. <view :class="titleidnex==index?'title_text_color':'tltle_text'" v-for="(item,index) in titletext" :key="index"
  9. @click="changeindex(index)">
  10. {{item}}
  11. </view>
  12. </view>
  13. <highcharts :chartOptions="options" :styles="styles" ref="simpleChart"></highcharts>
  14. </view>
  15. <view class="wind">
  16. <p class="wind_titie">风速、风向</p>
  17. <view class="wind_text">
  18. <view class="wind_speed">
  19. <image src="../../../../static/image/cb/xy/1c24243bb184e84ffd13540367569ba.png" mode=""></image>
  20. <p>风速:{{wind_sped}}(m/s)</p>
  21. </view>
  22. <view class="wind_direction">
  23. <image src="../../../../static/image/cb/xy/c44ae038324e1040a1eaa702e6d71a5.png" mode=""></image>
  24. <p>风速:{{wind_drec}}</p>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="condition">
  29. <scroll-view scroll-top="0" scroll-x="true" class="scroll-X">
  30. <!-- @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll" -->
  31. <table class="table">
  32. <tr class="tr">
  33. <th class="th" v-for="(item,index) in thdata" :key="'a'+index">{{item}}</th>
  34. </tr>
  35. <tr class="tr" v-for="(items,indexs) in historylistdata" :key="'b'+indexs" v-if="!forbidden">
  36. <td class="td">{{items.d_h_t.proj}}</td>
  37. <td class="td">{{items.d_h_t.ds==0?"关":"开"}}</td>
  38. <td class="td">{{items.d_h_t.ws==0?"待机":"工作"}}</td>
  39. <td class="td">{{items.d_h_t.at}}</td>
  40. <td class="td">{{items.d_h_t.ah}}</td>
  41. <td class="td">{{items.d_h_t.cv}}</td>
  42. <td class="td">{{items.d_h_t.bv}}</td>
  43. <td class="td">{{items.d_h_t.bs}}</td>
  44. <td class="td">{{items.d_h_t.cs?"正常":"充电"}}</td>
  45. <td class="td">{{items.d_h_t.infr_ct}}</td>
  46. <td class="td">{{items.d_h_t.csq}}</td>
  47. <td class="td">{{items.d_h_t.dver}}</td>
  48. <td class="td">{{items.d_h_t.addtime|timeFormat()}}</td>
  49. </tr>
  50. <tr class="tr" v-if="forbidden">
  51. <td class="td" v-for="item in 13">暂无数据</td>
  52. </tr>
  53. </table>
  54. </scroll-view>
  55. <view class="pagenumber">
  56. <button @click="prev">上一页</button>
  57. <view class="pagenumber_page">
  58. 第{{page}}页
  59. </view>
  60. <button @click="next" :disabled="forbidden">下一页</button>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <style lang="scss">
  66. </style>
  67. <script>
  68. import highcharts from "@/components/highcharts/highcharts"
  69. var newtime = +new Date()
  70. var strrttime = newtime - 24*60*60*1000
  71. export default {
  72. data() {
  73. return {
  74. styles: {
  75. // width: "650rpx",
  76. height: "400rpx"
  77. },
  78. options: {
  79. lang:{
  80. noData:"暂无数据"
  81. },
  82. chart: {
  83. type: 'spline', //指定图表的类型,默认是折线图(line)
  84. zoomType: 'x',
  85. panning: true,
  86. panKey: 'shift'
  87. },
  88. title: {
  89. text: '' // 标题
  90. },
  91. credits: {
  92. enabled: false
  93. },
  94. xAxis: {
  95. type: 'datetime',
  96. crosshair: true, //十字基准线
  97. dateTimeLabelFormats: {
  98. //根据时间间距X轴自动显示哪种格式
  99. millisecond: "%H:%M:%S.%L",
  100. second: "%H:%M:%S",
  101. minute: "%H:%M",
  102. hour: "%H:%M",
  103. day: "%m-%d",
  104. week: "%m-%d",
  105. month: "%Y-%m",
  106. year: "%Y",
  107. },
  108. },
  109. yAxis: {
  110. title: false,
  111. },
  112. legend: {
  113. // layout: 'vertical',
  114. align: "center",
  115. verticalAlign: "top",
  116. },
  117. tooltip: {
  118. // crosshairs: true,
  119. shared: true, //折线共享
  120. headerFormat: "<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>",
  121. },
  122. plotOptions: {
  123. spline: {
  124. marker: {
  125. enabled: false
  126. },
  127. }
  128. },
  129. series: [
  130. {
  131. name: "温度(°C)",
  132. data: [],
  133. color: "#00E29D"
  134. },
  135. {
  136. name: "湿度(%)",
  137. data: [],
  138. color: "#6CBBFF"
  139. }
  140. ],
  141. },
  142. d_id:'',
  143. start_time:strrttime,
  144. end_time:newtime,
  145. historydatas:[],
  146. titletext: ["24小时", "近一个月", "近半年", "近一年"],
  147. titleidnex: 0,
  148. device_id:'',
  149. page:1,
  150. historylistdata:[],
  151. thdata: ["型号", "设备开关", "工作状态","环境温度(°C)", "环境湿度(%)", "充电电压(V)", "电池电压(V)", "电池状态","充电状态","红外计数值","信号强度", "版本号", "上报时间"],
  152. forbidden:false,
  153. wind_sped:'',//风速
  154. wind_drec:''
  155. }
  156. },
  157. methods: {
  158. //forecast.worm_lamp.device_polyline_data 历史数据折线图
  159. // device_type_id 必传(string) 设备类型 3虫情测报灯 7孢子仪 4智能性诱 2杀虫灯 9糖醋测报灯 10测报灯rtu
  160. // d_id 必传 设备id
  161. // start_time 非必传(string 时间戳) 开始时间 (用于时间搜索)
  162. // end_time
  163. async history() { //获取图片列表
  164. const res = await this.$myRequest({
  165. url: '/api/api_gateway?method=forecast.worm_lamp.device_polyline_data',
  166. data: {
  167. device_type_id:4,
  168. d_id:this.d_id,
  169. start_time :parseInt(this.start_time/1000),
  170. end_time:parseInt(this.end_time/1000)
  171. }
  172. })
  173. this.historydatas = res
  174. console.log(this.historydatas)
  175. this.options.series[0].data = []
  176. this.options.series[1].data = []
  177. if(res.length==0){
  178. this.wind_sped = "--"
  179. this.wind_drec = "--"
  180. }else{
  181. this.wind_sped = res[0].others.wind_sped
  182. console.log(res[0].others.wind_drec)
  183. if(22<res[0].others.wind_drec&&67<res[0].others.wind_drec){
  184. this.wind_drec = "东北"
  185. }else if(67<res[0].others.wind_drec&&112>res[0].others.wind_drec){
  186. this.wind_drec = "东"
  187. }else if(112<res[0].others.wind_drec&&157>res[0].others.wind_drec){
  188. this.wind_drec = "东南"
  189. }else if(157<res[0].others.wind_drec&&202>res[0].others.wind_drec){
  190. this.wind_drec = "南"
  191. }else if(202<res[0].others.wind_drec&&247>res[0].others.wind_drec){
  192. this.wind_drec = "西南"
  193. }else if(247<res[0].others.wind_drec&&292>res[0].others.wind_drec){
  194. this.wind_drec = "西"
  195. }else if(292<res[0].others.wind_drec&&337>res[0].others.wind_drec){
  196. this.wind_drec = "西北"
  197. }else {
  198. this.wind_drec = "北"
  199. }
  200. }
  201. for(var i=0;i<res.length;i++){
  202. var arr1 = []
  203. arr1.push(res[i].addtime * 1000 + 8 * 3600000, Number(res[i].temperature))
  204. this.options.series[0].data.push(arr1)
  205. var arr2 = []
  206. arr2.push(res[i].addtime * 1000 + 8 * 3600000, Number(res[i].humidity))
  207. this.options.series[1].data.push(arr2)
  208. }
  209. },
  210. //forecast.worm_lamp.device_history_data历史数据列表
  211. async historylist() { //获取图片列表
  212. const res = await this.$myRequest({
  213. url: '/api/api_gateway?method=forecast.worm_lamp.device_history_data',
  214. data: {
  215. device_type_id: 4,
  216. device_id: this.device_id,
  217. start_time: parseInt(this.start_time/1000),
  218. end_time: parseInt(this.end_time/1000),
  219. page: this.page
  220. }
  221. })
  222. this.historylistdata = res.data
  223. if(res.data.length == 0){
  224. this.forbidden =true
  225. }else{
  226. this.forbidden =false
  227. }
  228. for(var i=0;i<this.historylistdata.length;i++){
  229. if(res.data[i].d_h_t.bs==0){
  230. this.historylistdata[i].d_h_t.bs = "正常"
  231. }else if(res.data[i].d_h_t.bs==1){
  232. this.historylistdata[i].d_h_t.bs = "欠压"
  233. }else if(res.data[i].d_h_t.bs==2){
  234. this.historylistdata[i].d_h_t.bs = "超压"
  235. }
  236. }
  237. console.log(this.historylistdata)
  238. },
  239. changeindex(index){
  240. this.titleidnex = index
  241. var now = new Date()
  242. this.$forceUpdate()
  243. if(index==0){
  244. this.start_time = strrttime
  245. this.history()
  246. this.historylist()
  247. }else if(index == 1){
  248. var oldtime = now.setMonth(now.getMonth() - 1)
  249. this.start_time = parseInt(oldtime)
  250. this.history()
  251. this.historylist()
  252. }else if(index == 2){
  253. var oldtime = now.setMonth(now.getMonth() - 6)
  254. this.start_time = parseInt(oldtime)
  255. this.history()
  256. this.historylist()
  257. }else if(index == 3){
  258. var oldtime = now.setFullYear(now.getFullYear() - 1)
  259. this.start_time = parseInt(oldtime)
  260. this.history()
  261. this.historylist()
  262. }
  263. },
  264. prev(){//上一页
  265. if(this.page > 1){
  266. this.page--
  267. this.historylist()
  268. }
  269. },
  270. next(){//下一页
  271. this.page++
  272. this.historylist()
  273. },
  274. clickLeft(){
  275. uni.navigateBack({
  276. delta:1
  277. })
  278. }
  279. },
  280. onLoad(option){
  281. this.d_id = option.d_id
  282. this.device_id = option.device_id
  283. this.history()
  284. this.historylist()
  285. }
  286. }
  287. </script>
  288. <style lang="scss">
  289. .shuju_one,
  290. .shuju_two {
  291. position: absolute;
  292. top: 54px;
  293. width: 90%;
  294. left: 5%;
  295. box-shadow: 0 0 10rpx #bcb9ca;
  296. padding-top: 20rpx;
  297. .shuju_one_title {
  298. width: 70%;
  299. margin: 0 auto;
  300. display: flex;
  301. .tltle_text {
  302. width: 25%;
  303. border: 2rpx solid #B2B2B2;
  304. color: #B2B2B2;
  305. text-align: center;
  306. font-size: 24rpx;
  307. height: 50rpx;
  308. line-height: 50rpx;
  309. }
  310. .title_text_color {
  311. width: 25%;
  312. border: 2rpx solid #28AE4F;
  313. color: #28AE4F;
  314. text-align: center;
  315. font-size: 24rpx;
  316. height: 50rpx;
  317. line-height: 50rpx;
  318. }
  319. }
  320. }
  321. .wind{
  322. position: absolute;
  323. top: 600rpx;
  324. width: 90%;
  325. left: 5%;
  326. box-shadow: 0 0 10rpx #bcb9ca;
  327. padding: 20rpx;
  328. .wind_titie{
  329. border-left: 6rpx solid #26D696;
  330. height: 34rpx;
  331. padding-left: 20rpx;
  332. }
  333. .wind_text{
  334. display: flex;
  335. .wind_speed,.wind_direction{
  336. width: 50%;
  337. text-align: center;
  338. margin-top: 30rpx;
  339. image{
  340. width: 160rpx;
  341. height: 130rpx;
  342. }
  343. }
  344. }
  345. }
  346. .condition {
  347. position: absolute;
  348. top: 900rpx;
  349. display: flex;
  350. flex-wrap: wrap;
  351. width: 90%;
  352. left: 5%;
  353. box-shadow: 0 0 10rpx #bcb9ca;
  354. margin-bottom: 30rpx;
  355. .scroll-X {
  356. width: 95%;
  357. margin: 20rpx auto;
  358. .tr {
  359. display: flex;
  360. overflow: hidden;
  361. .th,
  362. .td {
  363. display: inline-block;
  364. padding: 5rpx;
  365. width: 240rpx;
  366. text-align: center;
  367. height: 52rpx;
  368. line-height: 52rpx;
  369. border: 2rpx solid #F1F1F1;
  370. }
  371. }
  372. }
  373. .pagenumber {
  374. display: flex;
  375. margin: 20rpx auto;
  376. button {
  377. width: 150rpx;
  378. height: 50rpx;
  379. line-height: 50rpx;
  380. font-size: 26rpx;
  381. text-align: center;
  382. background-color: #17BB89;
  383. color: #FFFFFF;
  384. }
  385. .pagenumber_page {
  386. width: 150rpx;
  387. height: 50rpx;
  388. line-height: 50rpx;
  389. font-size: 26rpx;
  390. text-align: center;
  391. }
  392. }
  393. }
  394. </style>