DataDetail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <div>
  3. <el-breadcrumb separator-class="el-icon-arrow-right">
  4. <el-breadcrumb-item :to="{ path: '/index/bzy' }">植物孢子捕捉仪</el-breadcrumb-item>
  5. <el-breadcrumb-item>数据详情</el-breadcrumb-item>
  6. </el-breadcrumb>
  7. <div class="equipInfo">
  8. <div class="detail">
  9. <i></i>
  10. <span>设备ID:{{id}}</span>
  11. <span>设备名称:{{name||'无'}}</span>
  12. </div>
  13. <DateSearch @dateChange="dateChange"></DateSearch>
  14. </div>
  15. <div class="ctrl-check">
  16. <el-button type="primary" size="mini" @click="refresh">刷新</el-button>
  17. </div>
  18. <el-row :gutter="20">
  19. <el-col :md="24" :lg="12">
  20. <el-card class="box-card">
  21. <div style="text-align:center;font-size:20px;height:360px;position: relative;" v-if="Object.keys(option1).length<=0"><div class="el-loading-mask" style=""><div class="el-loading-spinner"><svg viewBox="25 25 50 50" class="circular"><circle cx="50" cy="50" r="20" fill="none" class="path"></circle></svg><!----></div></div></div>
  22. <div v-else class="charts">
  23. <highcharts :options="option1" v-if="Object.keys(option1).length>0"></highcharts>
  24. <div v-else style="text-align:center;font-size:20px;line-height:360px">暂无数据</div>
  25. </div>
  26. </el-card>
  27. </el-col>
  28. <el-col :md="24" :lg="12">
  29. <el-card class="box-card">
  30. <div style="text-align:center;font-size:20px;height:360px;position: relative;" v-if="Object.keys(option2).length<=0"><div class="el-loading-mask" style=""><div class="el-loading-spinner"><svg viewBox="25 25 50 50" class="circular"><circle cx="50" cy="50" r="20" fill="none" class="path"></circle></svg><!----></div></div></div>
  31. <div v-else class="charts">
  32. <highcharts :options="option2" v-if="Object.keys(option2).length>0"></highcharts>
  33. <div v-else style="text-align:center;font-size:20px;line-height:360px">暂无数据</div>
  34. </div>
  35. </el-card>
  36. </el-col>
  37. </el-row>
  38. <div class="dataTableSearch">
  39. </div>
  40. <el-card class="box-card">
  41. <el-table v-loading="loading" :data="tableData" stripe style="width: 100%">
  42. <el-table-column
  43. v-for="(item,index) in tableHeadTxt"
  44. :key="index"
  45. :prop="item[1]"
  46. :label="item[0]"
  47. :show-overflow-tooltip="true"
  48. :width="setWidth(item)"
  49. >
  50. <template slot-scope="scope">{{scope.row[scope.column.property]}}</template>
  51. </el-table-column>
  52. </el-table>
  53. <el-pagination
  54. background
  55. layout="prev, pager, next"
  56. :total="total"
  57. :current-page="queryInfo.page"
  58. @current-change="changePage"
  59. ></el-pagination>
  60. </el-card>
  61. </div>
  62. </template>
  63. <script>
  64. import DateSearch from '@/components/DateSearch'
  65. export default {
  66. data() {
  67. return {
  68. loading:true,
  69. id: this.$route.params.e_id,
  70. name: this.$route.query.name,
  71. option1: {},
  72. option2: {},
  73. btnSelected: '',
  74. timeRange: '',
  75. lineTime: '',
  76. tableHeadTxt: [
  77. ['设备开关', 'on_off'],
  78. ['环境温度(°C)', 'at'],
  79. ['环境湿度(%)', 'ah'],
  80. ['保温仓设定温度(°C)', 'set_temp'],
  81. ['保温仓当前温度(°C)', 'pre_temp'],
  82. ['电池状态', 'bat_sta'],
  83. ['雨控状态', 'rps'],
  84. ['摄像头状态', 'usb_sta'],
  85. ['电压(V)', 'v_bat'],
  86. ['海拔高度', 'alti'],
  87. ['信号强度', 'csq'],
  88. ['设备版本', 'dver'],
  89. ['上报时间', 'addtime']
  90. ],
  91. queryInfo: {
  92. begin: '',
  93. end: '',
  94. e_id: this.$route.params.e_id,
  95. name: this.$route.query.name,
  96. page: 1
  97. },
  98. // 表格数据
  99. tableData: [],
  100. total: 0
  101. }
  102. },
  103. mounted() {
  104. // this.getChartDataList()
  105. // this.getHisDataList()
  106. },
  107. methods: {
  108. //获取折线数据
  109. getChartDataList() {
  110. this.$axios({
  111. method: 'POST',
  112. url: '/bzy_report_detail_chart',
  113. data: this.qs.stringify({
  114. req: 'filter',
  115. id: this.queryInfo.e_id,
  116. begin: this.queryInfo.begin,
  117. end: this.queryInfo.end
  118. })
  119. }).then((res) => {
  120. if (res.data.length) {
  121. var ChartData = [
  122. {
  123. name: '温度(°C)',
  124. dat: []
  125. },
  126. {
  127. name: '湿度(RH)',
  128. dat: []
  129. },
  130. {
  131. name: '保温仓温度(°C)',
  132. dat: []
  133. }
  134. ]
  135. var data = res.data
  136. for (let item of data) {
  137. ChartData[0].dat.unshift([
  138. this.returnTime(item.tim),
  139. parseFloat(item.at)
  140. ])
  141. ChartData[1].dat.unshift([
  142. this.returnTime(item.tim),
  143. parseFloat(item.ah)
  144. ])
  145. ChartData[2].dat.unshift([
  146. this.returnTime(item.tim),
  147. parseFloat(item.pre_temp)
  148. ])
  149. }
  150. this.option1 = {
  151. chart: {
  152. zoomType: 'x'
  153. },
  154. title: {
  155. text: '环境温湿度',
  156. align: 'left'
  157. },
  158. subtitle: {
  159. text: ''
  160. },
  161. xAxis: {
  162. crosshair: true, //十字基准线
  163. type: 'datetime',
  164. dateTimeLabelFormats: {
  165. //根据时间间距X轴自动显示哪种格式
  166. millisecond: '%H:%M:%S.%L',
  167. second: '%H:%M:%S',
  168. minute: '%H:%M',
  169. hour: '%H:%M',
  170. day: '%m-%d',
  171. week: '%m-%d',
  172. month: '%Y-%m',
  173. year: '%Y'
  174. }
  175. },
  176. yAxis: {
  177. title: {
  178. text: ''
  179. }
  180. },
  181. legend: {
  182. // layout: 'vertical',
  183. align: 'right',
  184. verticalAlign: 'top'
  185. },
  186. plotOptions: {
  187. series: {
  188. label: {
  189. connectorAllowed: false
  190. },
  191. pointStart: 2010 //该参数定义了数据点的起点
  192. }
  193. },
  194. series: [
  195. {
  196. name: ChartData[0].name,
  197. data: ChartData[0].dat
  198. },
  199. {
  200. name: ChartData[1].name,
  201. data: ChartData[1].dat
  202. }
  203. ],
  204. colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
  205. credits: {
  206. //去掉默认的highcharts.com
  207. enabled: false
  208. },
  209. tooltip: {
  210. // crosshairs: true,
  211. shared: true, //折线共享
  212. headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
  213. },
  214. responsive: {
  215. rules: [
  216. {
  217. condition: {
  218. maxWidth: 500
  219. },
  220. chartOptions: {
  221. legend: {
  222. layout: 'horizontal',
  223. align: 'center',
  224. verticalAlign: 'bottom'
  225. }
  226. }
  227. }
  228. ]
  229. }
  230. }
  231. this.option2 = {
  232. chart: {
  233. zoomType: 'x'
  234. },
  235. title: {
  236. text: '保温仓温度',
  237. align: 'left'
  238. },
  239. subtitle: {
  240. text: ''
  241. },
  242. xAxis: {
  243. crosshair: true, //十字基准线
  244. type: 'datetime',
  245. dateTimeLabelFormats: {
  246. //根据时间间距X轴自动显示哪种格式
  247. millisecond: '%H:%M:%S.%L',
  248. second: '%H:%M:%S',
  249. minute: '%H:%M',
  250. hour: '%H:%M',
  251. day: '%m-%d',
  252. week: '%m-%d',
  253. month: '%Y-%m',
  254. year: '%Y'
  255. }
  256. },
  257. yAxis: {
  258. title: { text: '' }
  259. },
  260. legend: {
  261. // layout: 'vertical',
  262. align: 'right',
  263. verticalAlign: 'top'
  264. },
  265. plotOptions: {
  266. series: {
  267. label: {
  268. connectorAllowed: false
  269. },
  270. pointStart: 2010
  271. }
  272. },
  273. series: [
  274. {
  275. name: ChartData[2].name,
  276. data: ChartData[2].dat
  277. }
  278. ],
  279. colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
  280. credits: {
  281. //去掉默认的highcharts.com
  282. enabled: false
  283. },
  284. tooltip: {
  285. // crosshairs: true,
  286. shared: true, //折线共享
  287. headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
  288. },
  289. responsive: {
  290. rules: [
  291. {
  292. condition: {
  293. maxWidth: 500
  294. },
  295. chartOptions: {
  296. legend: {
  297. layout: 'horizontal',
  298. align: 'center',
  299. verticalAlign: 'bottom'
  300. }
  301. }
  302. }
  303. ]
  304. }
  305. }
  306. }else{
  307. this.option1 = {}
  308. this.option2 = {}
  309. }
  310. })
  311. },
  312. // 返回时间戳
  313. returnTime(time) {
  314. var thisTime = time.replace(/-/g, '/');
  315. var time = new Date(thisTime);
  316. var timestamp = time.getTime() + 8 * 3600000;
  317. return timestamp;
  318. },
  319. //获取表格数据
  320. getHisDataList() {
  321. this.$axios({
  322. method: 'POST',
  323. url: '/bzy_report_detail',
  324. data: this.qs.stringify({
  325. req: 'filter',
  326. id: this.queryInfo.e_id,
  327. begin: this.queryInfo.begin,
  328. end: this.queryInfo.end,
  329. page: this.queryInfo.page
  330. })
  331. }).then((res) => {
  332. this.total = res.data.nums
  333. if (this.total>0) {
  334. var data = res.data.dat
  335. if (data.length > 0) {
  336. this.tableData = []
  337. for (var i = 0; i < data.length; i++) {
  338. var dht = eval('('+data[i].bzy_data+')');
  339. dht.addtime = data[i].upl_time
  340. dht.on_off = dht.on_off == 0 ? '关' : '开'
  341. dht.bat_sta = dht.bat_sta == 0 ? '正常' : '电量过低'
  342. dht.rps = dht.rps == 0 ? '正常' : '雨控'
  343. dht.usb_sta = dht.usb_sta == 0 ? '正常' : '异常' //摄像头状态
  344. if (dht.lamp != undefined) {
  345. if (dht.ws == 1) {
  346. if (stat.lamp == 1) {
  347. dht.blbs = '工作中'
  348. } else if (dht.lux == 0) {
  349. dht.blbs = 'N/A(未检测到传感器)'
  350. } else {
  351. dht.blbs = '异常'
  352. }
  353. } else {
  354. dht.blbs = '关闭'
  355. }
  356. } else {
  357. dht.blbs = '--'
  358. }
  359. this.tableData.push(dht)
  360. }
  361. }
  362. }else{
  363. this.tableData = []
  364. }
  365. this.loading = false;
  366. })
  367. },
  368. dateChange(data) {
  369. this.option1 = {}
  370. this.option2 = {}
  371. this.loading = true;
  372. this.queryInfo.page = 1
  373. this.queryInfo.begin = new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-');
  374. this.queryInfo.end = new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-');
  375. this.getHisDataList()
  376. this.getChartDataList()
  377. },
  378. changePage(val) {
  379. this.queryInfo.page = val
  380. this.getHisDataList()
  381. },
  382. setWidth(item) {
  383. if (item[1] == 'addtime') {
  384. return 180 + 'px'
  385. }
  386. },
  387. refresh() {
  388. this.$axios({
  389. method: 'POST',
  390. url: '/bzy_mqtt',
  391. data: this.qs.stringify({
  392. req: 'read',
  393. topicid: this.queryInfo.e_id,
  394. })
  395. }).then((res) => {
  396. if (res.data == 0) {
  397. this.$message.success('刷新成功')
  398. } else {
  399. this.$message.err('刷新失败')
  400. }
  401. })
  402. }
  403. },
  404. components: {
  405. DateSearch
  406. }
  407. }
  408. </script>
  409. <style lang='less' scoped>
  410. .equipInfo {
  411. display: flex;
  412. margin-bottom: 10px;
  413. justify-content: space-between;
  414. .detail {
  415. font-size: 14px;
  416. color: #666;
  417. span {
  418. margin-right: 20px;
  419. }
  420. }
  421. }
  422. .dataTableSearch {
  423. display: flex;
  424. justify-content: space-between;
  425. margin: 20px 0;
  426. }
  427. .el-input__inner {
  428. width: 222px !important;
  429. }
  430. .ctrl-check {
  431. margin-bottom: 20px;
  432. }
  433. </style>