xyhistoryile.vue 10 KB

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