| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- <template>
- <div>
- <el-breadcrumb separator-class="el-icon-arrow-right">
- <el-breadcrumb-item :to="{ path: '/index/xycb' }">智能性诱测报</el-breadcrumb-item>
- <el-breadcrumb-item>数据详情</el-breadcrumb-item>
- </el-breadcrumb>
- <div class="equipInfo">
- <div class="equipMsg">
- <span>设备ID:{{this.queryInfo.e_id}}</span>
- <span>设备名称:{{name || '无'}}</span>
- </div>
- <DateSearch @dateChange="dateChange"></DateSearch>
- </div>
- <div class="ctrl-check">
- <el-button type="primary" size="mini" @click="refresh">刷新</el-button>
- </div>
- <!-- 统计图 -->
- <div>
- <div>
- <el-row :gutter="10">
- <el-col :md="24" :lg="14">
- <el-card class="box-card">
- <div class="charts">
- <template v-if="Object.keys(options).length>0">
- <highcharts :options="options"></highcharts>
- </template>
- <template v-else>
- <div style="text-align:center;font-size:20px;line-height:450px">暂无数据</div>
- </template>
- </div>
- </el-card>
- </el-col>
- <el-col :md="24" :lg="10">
- <el-card class="box-card">
- <div class="pie">
- <template v-if="device_model==1">
- <!-- <highcharts :options="options2" :key="1"></highcharts> -->
- <template v-if="Object.keys(options2).length>0">
- <highcharts :options="options2"></highcharts>
- </template>
- <template v-else>
- <div style="text-align:center;font-size:20px;line-height:450px">暂无数据</div>
- </template>
- </template>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <div class="dataTableSearch">
- <div>
- </div>
- </div>
- </div>
- <el-card class="box-card">
- <el-table :data="tableData" stripe style="width: 100%">
- <el-table-column
- v-for="(item,index) in tableHeadTxt"
- :key="index"
- :prop="item[1]"
- :label="item[0]"
- :width="setWidth(item)"
- >
- <template slot-scope="scope">{{scope.row[scope.column.property]}}</template>
- </el-table-column>
- </el-table>
- <el-pagination
- background
- layout="prev, pager, next"
- :total="total"
- :current-page="queryInfo.page"
- @current-change="changePage"
- ></el-pagination>
- </el-card>
- </div>
- </div>
- </template>
- <script>
- import DateSearch from '@/components/DateSearch'
- export default {
- data() {
- return {
- device_model: 1, //性诱1型或II型
- name:this.$route.query.name,
- btnSelected: '',
- lineTime: '',
- dataTime: '',
- options: {},
- worms: [
- {
- value: 1,
- label: '蛾子'
- },
- {
- value: 2,
- label: '蚊子'
- }
- ],
- options2: {},
- // 状态信息
- equipStatus: {},
- // 统计图表信息
- equipChartData: [],
- //总数据条数
- total: 0,
- // 动态表头
- tableHeadTxt: [
- ['设备开关', 'ds'],
- ['工作状态', 'ws'],
- ['环境温度', 'at'],
- ['环境湿度', 'ah'],
- ['充电电压', 'cv'],
- ['电池电压', 'bv'],
- ['红外计数值', 'infr_ct'],
- ['充电状态', 'cs'],
- ['电池状态', 'bs'],
- ['信号强度', 'csq'],
- ['版本号', 'dver'],
- ['上报时间', 'addtime']
- ],
- // 表格数据
- tableData: [],
- timeRange: '',
- queryInfo: {
- begin: '',
- end: '',
- e_id: this.$route.query.e_id,
- page: 1
- },
- //图表实时否有数据
- isEchartData: true,
- //表格和图表按钮样式切换参数
- display: '0', //0代表表格、1代表图表
- displayView: true,
- // 表格和图表显示切换控制
- showControl: true,
- //echarts图表参数
- echartOptions: [],
- // 动态表头
- tableHead: [],
- // 表格数据
- hisData: []
- }
- },
- created() {},
- mounted() {
- // this.getChartDataList()
- // this.getHisDataList()
- },
- methods: {
- // 返回时间戳
- returnTime(time) {
- var thisTime = time.replace(/-/g, '/');
- var time = new Date(thisTime);
- var timestamp = time.getTime() + 8 * 3600000;
- return timestamp;
- },
- //获取折线数据
- getChartDataList() {
- this.$axios({
- method: 'POST',
- url: '/sex_at_ah',
- data: this.qs.stringify({
- begin: this.queryInfo.begin,
- end: this.queryInfo.end,
- e_id: this.queryInfo.e_id,
- })
- }).then((res) => {
- if (res.data.length > 0) {
- var ChartData = [
- {
- name: '温度(°C)',
- dat: []
- },
- {
- name: '湿度(%)',
- dat: []
- },
- {
- name: '红外计数值',
- dat: []
- },
- {
- name: '高压计数值',
- dat: []
- },
- {
- name: 'cpu温度(°C)',
- dat: []
- }
- ]
- var data = res.data
- for (let item of data) {
- ChartData[0].dat.unshift([
- this.returnTime(item.tim),
- Number(item.at)
- ])
- ChartData[1].dat.unshift([
- this.returnTime(item.tim),
- Number(item.ah)
- ])
- }
- this.options = {
- chart: {
- zoomType: 'x'
- },
- title: {
- text: '环境温度',
- align: 'left'
- },
- subtitle: {
- text: ''
- },
- xAxis: {
- crosshair: true, //十字基准线
- type: 'datetime',
- dateTimeLabelFormats: {
- //根据时间间距X轴自动显示哪种格式
- millisecond: '%H:%M:%S.%L',
- second: '%H:%M:%S',
- minute: '%H:%M',
- hour: '%H:%M',
- day: '%m-%d',
- week: '%m-%d',
- month: '%Y-%m',
- year: '%Y'
- }
- },
- yAxis: {
- title: {
- text: ''
- }
- },
- legend: {
- // layout: 'vertical',
- align: 'right',
- verticalAlign: 'top'
- },
- plotOptions: {
- series: {
- label: {
- connectorAllowed: false
- },
- pointStart: 2010
- }
- },
- series: [
- {
- type: 'spline',
- name: ChartData[0].name,
- data: ChartData[0].dat
- },
-
- ],
- colors: ['#6cbbff', '#ff3f3f','#00e29d', ],
- credits: {
- //去掉默认的highcharts.com
- enabled: false
- },
- tooltip: {
- // crosshairs: true,
- shared: true, //折线共享
- headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
- }
- }
- this.options2 = {
- chart: {
- zoomType: 'x'
- },
- title: {
- text: '环境湿度',
- align: 'left'
- },
- subtitle: {
- text: ''
- },
- xAxis: {
- crosshair: true, //十字基准线
- type: 'datetime',
- dateTimeLabelFormats: {
- //根据时间间距X轴自动显示哪种格式
- millisecond: '%H:%M:%S.%L',
- second: '%H:%M:%S',
- minute: '%H:%M',
- hour: '%H:%M',
- day: '%m-%d',
- week: '%m-%d',
- month: '%Y-%m',
- year: '%Y'
- }
- },
- yAxis: {
- title: {
- text: ''
- }
- },
- legend: {
- // layout: 'vertical',
- align: 'right',
- verticalAlign: 'top'
- },
- plotOptions: {
- series: {
- label: {
- connectorAllowed: false
- },
- pointStart: 2010
- }
- },
- series: [
- {
- type: 'spline',
- name: ChartData[1].name,
- data: ChartData[1].dat
- }
- ],
- colors: ['#00e29d', '#6cbbff', '#ff3f3f'],
- credits: {
- //去掉默认的highcharts.com
- enabled: false
- },
- tooltip: {
- // crosshairs: true,
- shared: true, //折线共享
- headerFormat: '<b>{point.x:%Y-%m-%e %H:%M:%S}</b><br>'
- },
- responsive: {
- rules: [
- {
- condition: {
- maxWidth: 500
- },
- chartOptions: {
- legend: {
- layout: 'horizontal',
- align: 'center',
- verticalAlign: 'bottom'
- }
- }
- }
- ]
- }
- }
-
- }else{
- this.options = {};
- this.options2 = {};
- }
- })
- },
- //获取表格数据
- getHisDataList() {
- this.$axios({
- method: 'POST',
- url: '/sex_trap_data',
- data: this.qs.stringify({
- e_id: this.queryInfo.e_id,
- begin: this.queryInfo.begin,
- end: this.queryInfo.end,
- page: this.queryInfo.page
- })
- }).then((res) => {
- this.total = res.data.nums
- if (this.total > 0) {
- var data = res.data.dat
- if (data.length > 0) {
- this.tableData = []
- for (var i = 0; i < data.length; i++) {
- var dht = eval('('+data[i].sex_trap+')');
- dht.addtime = data[i].upl_time
- dht.ws = dht.ws ? '工作' : '待机'
- dht.cs = dht.cs ? '充电中' : '未充电'
- if(dht.bs == 0){
- dht.bs = '正常'
- }else if(dht.bs == 1){
- dht.bs = '欠压'
- }else if(dht.bs == 0){
- dht.bs = '过压'
- }
- dht.rps = dht.rps ? '正常' : '雨控'
- dht.ds = dht.ds ? '关' : '开'
- dht.tps = dht.tps ? '正常' : '温控'
- dht.lps = dht.lps ? '夜晚' : '白天'
- dht.cv = (dht.cv /1000).toFixed(2);
- dht.bv = (dht.bv/1000).toFixed(2);
- if (dht.lamp != undefined) {
- if (dht.ws == 1) {
- if (stat.lamp == 1) {
- dht.blbs = '工作中'
- } else if (dht.lux == 0) {
- dht.blbs = 'N/A(未检测到传感器)'
- } else {
- dht.blbs = '异常'
- }
- } else {
- dht.blbs = '关闭'
- }
- } else {
- dht.blbs = '--'
- }
- this.tableData.push(dht)
- }
- }else{
- this.tableData = []
- }
- }
- })
- },
- //改变page
- changePage(val) {
- this.queryInfo.page = val
- this.getHisDataList()
- },
- dateChange(data) {
- console.log(data.begin);
- this.queryInfo.page = 1
- this.queryInfo.begin = data.begin?new Date(data.begin*1000).toLocaleDateString().replace(/\//g,'-'):'';
- this.queryInfo.end = data.end?new Date(data.end*1000).toLocaleDateString().replace(/\//g,'-'):'';
- this.getHisDataList()
- this.getChartDataList()
- },
- setWidth(item) {
- if (item[1] == 'addtime') {
- return 180 + 'px'
- }
- },
- refresh() {
- this.$axios({
- method: 'POST',
- url: '/sex_mqtt_v1',
- data: this.qs.stringify({
- ext: 'data',
- e_id: this.queryInfo.e_id,
- })
- }).then((res) => {
- if (res.data == 0) {
- this.$message.success('刷新成功')
- } else {
- this.$message.err('刷新失败')
- }
- })
- }
- },
- components: {
- DateSearch
- }
- }
- </script>
- <style lang='less' scoped>
- .box-card {
- position: relative;
- }
- .equipInfo {
- .equipMsg {
- font-size: 14px;
- color: #3d3d3d;
- i {
- font-size: 16px;
- color: #14a478;
- }
- span {
- margin-left: 5px;
- }
- }
- display: flex;
- justify-content: space-between;
- margin-bottom: 15px;
- }
- .time-check {
- display: flex;
- justify-content: space-between;
- .el-input__inner {
- margin-left: 10px;
- width: 222px;
- }
- }
- .chartsSelect {
- text-align: right;
- position: absolute;
- z-index: 999;
- left: 0;
- right: 21px;
- }
- .charts,
- .pie {
- height: 423px;
- }
- .equipStatus {
- display: flex;
- justify-content: center;
- margin: 10px 0;
- .equipIcon {
- margin-right: 14%;
- }
- .equipParams {
- min-width: 80px;
- line-height: 27px;
- p {
- color: #a6a6a6;
- }
- }
- }
- .dataTableSearch {
- display: flex;
- justify-content: space-between;
- margin: 20px 0;
- .el-input__inner {
- width: 222px;
- }
- }
- // .check-btns{display:flex;justify-content: space-between;margin-bottom:20px}
- .echarts {
- width: 100%;
- height: 300px;
- }
- .ctrl-check {
- margin-bottom: 20px;
- }
- </style>
|