xycbDataDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <div>
  3. <el-breadcrumb separator-class="el-icon-arrow-right">
  4. <el-breadcrumb-item :to="{ path: '/index/xycb' }">智能性诱测报</el-breadcrumb-item>
  5. <el-breadcrumb-item>数据详情</el-breadcrumb-item>
  6. </el-breadcrumb>
  7. <div class="equipInfo">
  8. <div class="equipMsg">
  9. <span>设备ID:{{this.queryInfo.e_id}}</span>
  10. <span>设备名称:{{name || '无'}}</span>
  11. </div>
  12. <DateSearch @dateChange="dateChange"></DateSearch>
  13. </div>
  14. <div class="ctrl-check">
  15. <el-button type="primary" size="mini" @click="refresh">刷新</el-button>
  16. </div>
  17. <!-- 统计图 -->
  18. <div>
  19. <div>
  20. <el-row :gutter="10">
  21. <el-col :md="24" :lg="14">
  22. <el-card class="box-card">
  23. <div class="charts">
  24. <template v-if="Object.keys(options).length>0">
  25. <highcharts :options="options"></highcharts>
  26. </template>
  27. <template v-else>
  28. <div style="text-align:center;font-size:20px;line-height:450px">暂无数据</div>
  29. </template>
  30. </div>
  31. </el-card>
  32. </el-col>
  33. <el-col :md="24" :lg="10">
  34. <el-card class="box-card">
  35. <div class="pie">
  36. <template v-if="device_model==1">
  37. <!-- <highcharts :options="options2" :key="1"></highcharts> -->
  38. <template v-if="Object.keys(options2).length>0">
  39. <highcharts :options="options2"></highcharts>
  40. </template>
  41. <template v-else>
  42. <div style="text-align:center;font-size:20px;line-height:450px">暂无数据</div>
  43. </template>
  44. </template>
  45. </div>
  46. </el-card>
  47. </el-col>
  48. </el-row>
  49. <div class="dataTableSearch">
  50. <div>
  51. </div>
  52. </div>
  53. </div>
  54. <el-card class="box-card">
  55. <el-table :data="tableData" stripe style="width: 100%">
  56. <el-table-column
  57. v-for="(item,index) in tableHeadTxt"
  58. :key="index"
  59. :prop="item[1]"
  60. :label="item[0]"
  61. :width="setWidth(item)"
  62. >
  63. <template slot-scope="scope">{{scope.row[scope.column.property]}}</template>
  64. </el-table-column>
  65. </el-table>
  66. <el-pagination
  67. background
  68. layout="prev, pager, next"
  69. :total="total"
  70. :current-page="queryInfo.page"
  71. @current-change="changePage"
  72. ></el-pagination>
  73. </el-card>
  74. </div>
  75. </div>
  76. </template>
  77. <script>
  78. import DateSearch from '@/components/DateSearch'
  79. export default {
  80. data() {
  81. return {
  82. device_model: 1, //性诱1型或II型
  83. name:this.$route.query.name,
  84. btnSelected: '',
  85. lineTime: '',
  86. dataTime: '',
  87. options: {},
  88. worms: [
  89. {
  90. value: 1,
  91. label: '蛾子'
  92. },
  93. {
  94. value: 2,
  95. label: '蚊子'
  96. }
  97. ],
  98. options2: {},
  99. // 状态信息
  100. equipStatus: {},
  101. // 统计图表信息
  102. equipChartData: [],
  103. //总数据条数
  104. total: 0,
  105. // 动态表头
  106. tableHeadTxt: [
  107. ['设备开关', 'ds'],
  108. ['工作状态', 'ws'],
  109. ['环境温度', 'at'],
  110. ['环境湿度', 'ah'],
  111. ['充电电压', 'cv'],
  112. ['电池电压', 'bv'],
  113. ['红外计数值', 'infr_ct'],
  114. ['充电状态', 'cs'],
  115. ['电池状态', 'bs'],
  116. ['信号强度', 'csq'],
  117. ['版本号', 'dver'],
  118. ['上报时间', 'addtime']
  119. ],
  120. // 表格数据
  121. tableData: [],
  122. timeRange: '',
  123. queryInfo: {
  124. begin: '',
  125. end: '',
  126. e_id: this.$route.query.e_id,
  127. page: 1
  128. },
  129. //图表实时否有数据
  130. isEchartData: true,
  131. //表格和图表按钮样式切换参数
  132. display: '0', //0代表表格、1代表图表
  133. displayView: true,
  134. // 表格和图表显示切换控制
  135. showControl: true,
  136. //echarts图表参数
  137. echartOptions: [],
  138. // 动态表头
  139. tableHead: [],
  140. // 表格数据
  141. hisData: []
  142. }
  143. },
  144. created() {},
  145. mounted() {
  146. // this.getChartDataList()
  147. // this.getHisDataList()
  148. },
  149. methods: {
  150. // 返回时间戳
  151. returnTime(time) {
  152. var thisTime = time.replace(/-/g, '/');
  153. var time = new Date(thisTime);
  154. var timestamp = time.getTime() + 8 * 3600000;
  155. return timestamp;
  156. },
  157. //获取折线数据
  158. getChartDataList() {
  159. this.$axios({
  160. method: 'POST',
  161. url: '/sex_at_ah',
  162. data: this.qs.stringify({
  163. begin: this.queryInfo.begin,
  164. end: this.queryInfo.end,
  165. e_id: this.queryInfo.e_id,
  166. })
  167. }).then((res) => {
  168. if (res.data.length > 0) {
  169. var ChartData = [
  170. {
  171. name: '温度(°C)',
  172. dat: []
  173. },
  174. {
  175. name: '湿度(%)',
  176. dat: []
  177. },
  178. {
  179. name: '红外计数值',
  180. dat: []
  181. },
  182. {
  183. name: '高压计数值',
  184. dat: []
  185. },
  186. {
  187. name: 'cpu温度(°C)',
  188. dat: []
  189. }
  190. ]
  191. var data = res.data
  192. for (let item of data) {
  193. ChartData[0].dat.unshift([
  194. this.returnTime(item.tim),
  195. Number(item.at)
  196. ])
  197. ChartData[1].dat.unshift([
  198. this.returnTime(item.tim),
  199. Number(item.ah)
  200. ])
  201. }
  202. this.options = {
  203. chart: {
  204. zoomType: 'x'
  205. },
  206. title: {
  207. text: '环境温度',
  208. align: 'left'
  209. },
  210. subtitle: {
  211. text: ''
  212. },
  213. xAxis: {
  214. crosshair: true, //十字基准线
  215. type: 'datetime',
  216. dateTimeLabelFormats: {
  217. //根据时间间距X轴自动显示哪种格式
  218. millisecond: '%H:%M:%S.%L',
  219. second: '%H:%M:%S',
  220. minute: '%H:%M',
  221. hour: '%H:%M',
  222. day: '%m-%d',
  223. week: '%m-%d',
  224. month: '%Y-%m',
  225. year: '%Y'
  226. }
  227. },
  228. yAxis: {
  229. title: {
  230. text: ''
  231. }
  232. },
  233. legend: {
  234. // layout: 'vertical',
  235. align: 'right',
  236. verticalAlign: 'top'
  237. },
  238. plotOptions: {
  239. series: {
  240. label: {
  241. connectorAllowed: false
  242. },
  243. pointStart: 2010
  244. }
  245. },
  246. series: [
  247. {
  248. type: 'spline',
  249. name: ChartData[0].name,
  250. data: ChartData[0].dat
  251. },
  252. ],
  253. colors: ['#6cbbff', '#ff3f3f','#00e29d', ],
  254. credits: {
  255. //去掉默认的highcharts.com
  256. enabled: false
  257. },
  258. tooltip: {
  259. // crosshairs: true,
  260. shared: true, //折线共享
  261. headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
  262. }
  263. }
  264. this.options2 = {
  265. chart: {
  266. zoomType: 'x'
  267. },
  268. title: {
  269. text: '环境湿度',
  270. align: 'left'
  271. },
  272. subtitle: {
  273. text: ''
  274. },
  275. xAxis: {
  276. crosshair: true, //十字基准线
  277. type: 'datetime',
  278. dateTimeLabelFormats: {
  279. //根据时间间距X轴自动显示哪种格式
  280. millisecond: '%H:%M:%S.%L',
  281. second: '%H:%M:%S',
  282. minute: '%H:%M',
  283. hour: '%H:%M',
  284. day: '%m-%d',
  285. week: '%m-%d',
  286. month: '%Y-%m',
  287. year: '%Y'
  288. }
  289. },
  290. yAxis: {
  291. title: {
  292. text: ''
  293. }
  294. },
  295. legend: {
  296. // layout: 'vertical',
  297. align: 'right',
  298. verticalAlign: 'top'
  299. },
  300. plotOptions: {
  301. series: {
  302. label: {
  303. connectorAllowed: false
  304. },
  305. pointStart: 2010
  306. }
  307. },
  308. series: [
  309. {
  310. type: 'spline',
  311. name: ChartData[1].name,
  312. data: ChartData[1].dat
  313. }
  314. ],
  315. colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
  316. credits: {
  317. //去掉默认的highcharts.com
  318. enabled: false
  319. },
  320. tooltip: {
  321. // crosshairs: true,
  322. shared: true, //折线共享
  323. headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
  324. },
  325. responsive: {
  326. rules: [
  327. {
  328. condition: {
  329. maxWidth: 500
  330. },
  331. chartOptions: {
  332. legend: {
  333. layout: 'horizontal',
  334. align: 'center',
  335. verticalAlign: 'bottom'
  336. }
  337. }
  338. }
  339. ]
  340. }
  341. }
  342. }else{
  343. this.options = {};
  344. this.options2 = {};
  345. }
  346. })
  347. },
  348. //获取表格数据
  349. getHisDataList() {
  350. this.$axios({
  351. method: 'POST',
  352. url: '/sex_trap_data',
  353. data: this.qs.stringify({
  354. e_id: this.queryInfo.e_id,
  355. begin: this.queryInfo.begin,
  356. end: this.queryInfo.end,
  357. page: this.queryInfo.page
  358. })
  359. }).then((res) => {
  360. this.total = res.data.nums
  361. if (this.total > 0) {
  362. var data = res.data.dat
  363. if (data.length > 0) {
  364. this.tableData = []
  365. for (var i = 0; i < data.length; i++) {
  366. var dht = eval('('+data[i].sex_trap+')');
  367. dht.addtime = data[i].upl_time
  368. dht.ws = dht.ws ? '工作' : '待机'
  369. dht.cs = dht.cs ? '充电中' : '未充电'
  370. if(dht.bs == 0){
  371. dht.bs = '正常'
  372. }else if(dht.bs == 1){
  373. dht.bs = '欠压'
  374. }else if(dht.bs == 0){
  375. dht.bs = '过压'
  376. }
  377. dht.rps = dht.rps ? '正常' : '雨控'
  378. dht.ds = dht.ds ? '关' : '开'
  379. dht.tps = dht.tps ? '正常' : '温控'
  380. dht.lps = dht.lps ? '夜晚' : '白天'
  381. dht.cv = (dht.cv /1000).toFixed(2);
  382. dht.bv = (dht.bv/1000).toFixed(2);
  383. if (dht.lamp != undefined) {
  384. if (dht.ws == 1) {
  385. if (stat.lamp == 1) {
  386. dht.blbs = '工作中'
  387. } else if (dht.lux == 0) {
  388. dht.blbs = 'N/A(未检测到传感器)'
  389. } else {
  390. dht.blbs = '异常'
  391. }
  392. } else {
  393. dht.blbs = '关闭'
  394. }
  395. } else {
  396. dht.blbs = '--'
  397. }
  398. this.tableData.push(dht)
  399. }
  400. }else{
  401. this.tableData = []
  402. }
  403. }
  404. })
  405. },
  406. //改变page
  407. changePage(val) {
  408. this.queryInfo.page = val
  409. this.getHisDataList()
  410. },
  411. dateChange(data) {
  412. console.log(data.begin);
  413. this.queryInfo.page = 1
  414. this.queryInfo.begin = data.begin?new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-'):'';
  415. this.queryInfo.end = data.end?new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-'):'';
  416. this.getHisDataList()
  417. this.getChartDataList()
  418. },
  419. setWidth(item) {
  420. if (item[1] == 'addtime') {
  421. return 180 + 'px'
  422. }
  423. },
  424. refresh() {
  425. this.$axios({
  426. method: 'POST',
  427. url: '/sex_mqtt_v1',
  428. data: this.qs.stringify({
  429. ext: 'data',
  430. e_id: this.queryInfo.e_id,
  431. })
  432. }).then((res) => {
  433. if (res.data == 0) {
  434. this.$message.success('刷新成功')
  435. } else {
  436. this.$message.err('刷新失败')
  437. }
  438. })
  439. }
  440. },
  441. components: {
  442. DateSearch
  443. }
  444. }
  445. </script>
  446. <style lang='less' scoped>
  447. .box-card {
  448. position: relative;
  449. }
  450. .equipInfo {
  451. .equipMsg {
  452. font-size: 14px;
  453. color: #3d3d3d;
  454. i {
  455. font-size: 16px;
  456. color: #14a478;
  457. }
  458. span {
  459. margin-left: 5px;
  460. }
  461. }
  462. display: flex;
  463. justify-content: space-between;
  464. margin-bottom: 15px;
  465. }
  466. .time-check {
  467. display: flex;
  468. justify-content: space-between;
  469. .el-input__inner {
  470. margin-left: 10px;
  471. width: 222px;
  472. }
  473. }
  474. .chartsSelect {
  475. text-align: right;
  476. position: absolute;
  477. z-index: 999;
  478. left: 0;
  479. right: 21px;
  480. }
  481. .charts,
  482. .pie {
  483. height: 423px;
  484. }
  485. .equipStatus {
  486. display: flex;
  487. justify-content: center;
  488. margin: 10px 0;
  489. .equipIcon {
  490. margin-right: 14%;
  491. }
  492. .equipParams {
  493. min-width: 80px;
  494. line-height: 27px;
  495. p {
  496. color: #a6a6a6;
  497. }
  498. }
  499. }
  500. .dataTableSearch {
  501. display: flex;
  502. justify-content: space-between;
  503. margin: 20px 0;
  504. .el-input__inner {
  505. width: 222px;
  506. }
  507. }
  508. // .check-btns{display:flex;justify-content: space-between;margin-bottom:20px}
  509. .echarts {
  510. width: 100%;
  511. height: 300px;
  512. }
  513. .ctrl-check {
  514. margin-bottom: 20px;
  515. }
  516. </style>