| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547 |
- <template>
- <view>
- <view class="timeandtype">
- <view class="timebox">
- <view class="firsttime" @click="timeshow=true">
- <view class="" v-if="start_time!=''">
- {{start_time/1000|timeFormat()}}
- </view>
- <view class="" v-else>
- {{start_time==""?'请选择开始时间':start_time}}
- </view>
- </view>
- <view class="jiange">
- -
- </view>
- <view class="endtime" @click="timeshow=true">
- <view class="" v-if="end_time!=''">
- {{end_time/1000|timeFormat()}}
- </view>
- <view class="" v-else>
- {{end_time==""?'请选择结束时间':end_time}}
- </view>
- </view>
- </view>
- </view>
- <view class="shuju_one">
- <view class="canvastishi" v-if="!canvastishiTF && !dataloadingtf">
- 暂无数据
- </view>
- <view class="canvastishi" v-if="dataloadingtf">
- <p class="dataloading">加载中</p>
- </view>
- <canvas v-if="canvastishiTF" v-show="!timeshow" canvas-id="canvasColumnA" id="canvasColumnA" class="charts" @touchstart="touchLineA($event)"
- @touchmove="moveLineA($event)" @touchend="touchEndLineA($event)" disable-scroll=true :style="{'width':cWidth*pixelRatio+'px','height':cHeight*pixelRatio+'px', 'transform': 'scale('+(1/pixelRatio)+')','margin-left':-cWidth*(pixelRatio-1)/2+'px','margin-top':-cHeight*(pixelRatio-1)/2+'px'}"></canvas>
- </view>
- <view class="shuju_one">
- <view class="canvastishi" v-if="!canvastishiTF2 && !dataloadingtf2">
- 暂无数据
- </view>
- <view class="canvastishi" v-if="dataloadingtf2">
- <p class="dataloading">加载中</p>
- </view>
- <canvas v-if="canvastishiTF2" v-show="!timeshow" canvas-id="canvasColumnB" id="canvasColumnB" class="charts" @touchstart="touchLineB($event)"
- @touchmove="moveLineB($event)" @touchend="touchEndLineB($event)" disable-scroll=true :style="{'width':cWidth*pixelRatio+'px','height':cHeight*pixelRatio+'px', 'transform': 'scale('+(1/pixelRatio)+')','margin-left':-cWidth*(pixelRatio-1)/2+'px','margin-top':-cHeight*(pixelRatio-1)/2+'px'}"></canvas>
- </view>
- <view class="condition">
- <scroll-view scroll-top="0" scroll-x="true" class="scroll-X">
- <table class="table" v-if="$QueryPermission(267)">
- <tr class="tr">
- <th class="th" v-for="(item,index) in thdata" :key="'a'+index">{{item}}</th>
- </tr>
- <tr class="tr" v-for="(items,indexs) in historylistdata" :key="'b'+indexs" v-if="!forbidden">
- <td class="td">{{items.d_h_t.addtime|timeFormat()}}</td>
- <td class="td">{{Circulation.ds.value[items.d_h_t.ds]}}</td>
- <td class="td">{{Circulation.ws.value[items.d_h_t.ws]}}</td>
- <td class="td">{{items.d_h_t.at}}</td>
- <td class="td">{{items.d_h_t.ah}}</td>
- <td class="td">{{items.d_h_t.cc}}</td>
- <td class="td">{{items.d_h_t.cv}}</td>
- <td class="td">{{items.d_h_t.bv}}</td>
- <td class="td">{{Circulation.bs.value[items.d_h_t.bs]}}</td>
- <td class="td">{{items.d_h_t.volt_ct}}</td>
- <td class="td">{{items.d_h_t.csq}}</td>
- </tr>
- <tr class="tr" v-if="forbidden">
- <td class="td" v-for="item in 11">暂无数据</td>
- </tr>
- </table>
- <table class="table" v-else>
- <tr class="tr">
- <th class="th" v-for="(item,index) in thdata2" :key="'a'+index">{{item}}</th>
- </tr>
- <tr class="tr" v-for="(items,indexs) in historylistdata" :key="'b'+indexs" v-if="!forbidden">
- <td class="td">{{items.d_h_t.addtime|timeFormat()}}</td>
- <td class="td">{{Circulation.ds.value[items.d_h_t.ds]}}</td>
- <td class="td">{{Circulation.ws.value[items.d_h_t.ws]}}</td>
- <td class="td">{{items.d_h_t.at}}</td>
- <td class="td">{{items.d_h_t.ah}}</td>
- <td class="td">{{Circulation.bs.value[items.d_h_t.bs]}}</td>
- <td class="td">{{items.d_h_t.volt_ct}}</td>
- </tr>
- <tr class="tr" v-if="forbidden">
- <td class="td" v-for="item in 7">暂无数据</td>
- </tr>
- </table>
- </scroll-view>
- <view class="pagenumber">
- <button @click="prev">上一页</button>
- <view class="pagenumber_page">
- 第 {{page}} 页
- </view>
- <view class="pagenumber_page">
- 共 {{pagesum}} 页
- </view>
- <button @click="next" :disabled="forbidden">下一页</button>
- </view>
- </view>
- <u-calendar v-model="timeshow" :mode="mode" @change="timechange"></u-calendar>
- </view>
- </template>
- <script>
- import uCharts from '../../../components/js_sdk/u-charts/u-charts/u-charts.js';
- import Circulation from "../../../static/js/equipState_dict.json"
- var canvaColumnA = null;
- var canvaColumnB = null
- export default {
- data() {
- return {
- start_time:"",
- end_time:"",
- timeshow:false,
- mode: 'range',
- cWidth: '400',
- cHeight: '400',
- pixelRatio: 1,
- canvastishiTF:false,
- dataloadingtf:false,
- canvastishiTF2:false,
- dataloadingtf2:false,
- equipInfo:{},
- historylistdata: [],
- thdata: [
- "上报时间","设备开关","工作状态","环境温度(℃)","环境湿度(%)","电流(mA)","充电电压(V)","电池电压(V)","电池状态","诱虫次数","信号强度",
- ],
- thdata2: [
- "上报时间","设备开关","工作状态","环境温度(℃)","环境湿度(%)","电池状态","诱虫次数",
- ],
- page:1,
- pagesum:"10",
- Circulation:Circulation,
- forbidden:false
- }
- },
- methods: {
- timechange(e){
- this.start_time = +new Date(e.startDate)
- this.end_time = +new Date(e.endDate)
- this.page = 1;
- this.history()
- this.getworm()
- this.getwind()
- },
- async history() { //历史数据列表折线图
- this.dataloadingtf = true
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_at_ah',
- data: {
- device_type_id: 8,
- d_id: this.equipInfo.d_id,
- start_time: Math.floor(+new Date(this.start_time) / 1000),
- end_time: Math.floor(+new Date(this.end_time) / 1000),
- }
- })
- console.log(res)
- this.dataloadingtf = false
- this.historydatas = res
- console.log(this.historydatas)
- if (this.historydatas.length == 0) {
- this.canvastishiTF = false
- } else {
- this.canvastishiTF = true
-
- var arr1 = []
- var arr2 = []
- var arr3 = []
- var xtitle = []
- for (var i = 0; i < res.length; i++) {
- var times = new Date(res[i].addtime * 1000)
- xtitle.push(times.getMonth() + 1 + "/" + times.getDate() + "-" + times.getHours() + ":" + times.getMinutes())
- arr1.push(res[i].at == "" ? "0" : res[i].at)
- arr2.push(res[i].ah == "" ? "0" : res[i].ah)
- }
- // console.log(arr1)
- var obj = [{
- name: '温度',
- data: arr1,
- color: '#00E29D'
- }, {
- name: '湿度',
- data: arr2,
- color: '#6CBBFF'
- }]
- this.showColumn("canvasColumnA", xtitle, obj)
- }
- },
- async getworm() {
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=forecast.worm_lamp.xycb_pest_chart',
- data: {
- d_id: this.equipInfo.d_id,
- start_time: Math.floor(+new Date(this.start_time) / 1000),
- end_time: Math.floor(+new Date(this.end_time) / 1000),
- device_type_id: "8",
- }
- })
- console.log(res)
- this.dataloadingtf2 = false
- var data = res.pest_data
- if (data.length == 0) {
- this.canvastishiTF2 = false
- } else {
- this.canvastishiTF2 = true
-
- var arr1 = []
- var xtitle = []
- for (var i = 0; i < data.length; i++) {
- var times = new Date(data[i].addtime * 1000)
- xtitle.push(times.getMonth() + 1 + "/" + times.getDate() + "-" + times.getHours() + ":" + times.getMinutes())
- arr1.push(data[i].pest_num == "" ? "0" : data[i].pest_num)
- }
- // console.log(arr1)
- var obj = [{
- name: '诱虫次数',
- data: arr1,
- color: '#00E29D'
- }]
- this.showColumn2("canvasColumnB", xtitle, obj)
- }
- },
- async getwind() {
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=forecast.worm_lamp.xy_three_history_data',
- data: {
- d_id: this.equipInfo.d_id,
- start_time: Math.floor(+new Date(this.start_time) / 1000),
- end_time: Math.floor(+new Date(this.end_time) / 1000),
- device_id: this.equipInfo.imei,
- page: this.page,
- }
- })
- console.log(res)
- if(res.data.length){
- this.historylistdata = res.data
- this.pagesum = Math.ceil(res.counts/10)
- this.forbidden = false
- }else{
- this.forbidden = true
- }
- },
- prev() { //上一页
- if (this.page > 1) {
- this.page--
- this.getwind()
- }
- },
- next() { //下一页
- if(this.page < this.pagesum){
- this.page++
- this.getwind()
- }
- },
- showColumn(id, xtitle, xinfo) {
- var _self = this
- const ctx = uni.createCanvasContext(id, this);
- canvaColumnA = new uCharts({
- context: ctx,
- type: 'line',
- legend: {
- position: "top"
- },
- fontSize: 11,
- background: '#FFFFFF',
- pixelRatio: 1,
- animation: true,
- dataLabel: false,
- categories: xtitle,
- series: xinfo,
- enableScroll: true, //开启图表拖拽功能
- xAxis: {
- disableGrid: true,
- type: 'grid',
- gridType: 'dash',
- itemCount: 4, //x轴单屏显示数据的数量,默认为5个
- scrollShow: true, //新增是否显示滚动条,默认false
- // scrollAlign: 'left', //滚动条初始位置
- scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
- scrollColor: '#DEE7F7', //默认为 #A6A6A6
- },
- yAxis: {},
- width: _self.cWidth * 1,
- height: _self.cHeight * 1,
- extra: {
- line: {
- type: 'curve'
- }
- }
- });
- },
- showColumn2(id, xtitle, xinfo) {
- var _self = this
- const ctx = uni.createCanvasContext(id, this);
- canvaColumnB = new uCharts({
- context: ctx,
- type: 'line',
- legend: {
- position: "top"
- },
- fontSize: 11,
- background: '#FFFFFF',
- pixelRatio: 1,
- animation: true,
- dataLabel: false,
- categories: xtitle,
- series: xinfo,
- enableScroll: true, //开启图表拖拽功能
- xAxis: {
- disableGrid: true,
- type: 'grid',
- gridType: 'dash',
- itemCount: 4, //x轴单屏显示数据的数量,默认为5个
- scrollShow: true, //新增是否显示滚动条,默认false
- // scrollAlign: 'left', //滚动条初始位置
- scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
- scrollColor: '#DEE7F7', //默认为 #A6A6A6
- },
- yAxis: {},
- width: _self.cWidth * 1,
- height: _self.cHeight * 1,
- extra: {
- line: {
- type: 'curve'
- }
- }
- });
- },
- touchLineA(e) {
- console.log(e)
- canvaColumnA.scrollStart(e);
- },
- moveLineA(e) {
- canvaColumnA.scroll(e);
- },
- touchEndLineA(e) {
- canvaColumnA.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaColumnA.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- touchLineB(e) {
- console.log(e)
- canvaColumnB.scrollStart(e);
- },
- moveLineB(e) {
- canvaColumnB.scroll(e);
- },
- touchEndLineB(e) {
- canvaColumnB.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaColumnB.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- },
- onLoad(option) {
- this.equipInfo = option
- console.log(option)
- this.end_time = +new Date()
- this.start_time = +new Date()-30*24*60*60*1000
- this.cWidth = uni.upx2px(650);
- this.cHeight = uni.upx2px(500);
- this.history()
- this.getworm()
- this.getwind()
- }
- }
- </script>
- <style lang="less">
- .timeandtype {
- // background-color: #F6F6FB;
- // padding: 20rpx;
- box-sizing: border-box;
- width: 90%;
- margin: 40rpx auto 0;
- .timebox {
- box-shadow: 0 0 10rpx #bcb9ca;
- display: flex;
- background-color: #fff;
- padding: 10px;
- border-top-right-radius: 5px;
- border-top-left-radius: 5px;
-
- .jiange {
- width: 5%;
- text-align: center;
- }
-
- .firsttime,
- .endtime {
- width: 45%;
- text-align: center;
- }
- }
-
- .warntypebox {
- display: flex;
- justify-content: space-between;
- background-color: #fff;
- padding: 10px;
- border-top: 1px solid #F6F6FB;
- border-bottom-right-radius: 5px;
- border-bottom-left-radius: 5px;
- }
- }
- .shuju_one {
- position: relative;
- width: 90%;
- margin: 30rpx auto;
- box-shadow: 0 0 10rpx #bcb9ca;
- padding-top: 20rpx;
- height: 550rpx;
-
- .canvastishi {
- font-size: 32rpx;
- position: absolute;
- top: 50%;
- left: 50%;
- margin-left: -64rpx;
- margin-top: -21rpx;
- .dataloading:after {
- overflow: hidden;
- display: inline-block;
- vertical-align: bottom;
- animation: ellipsis 2s infinite;
- content: "\2026";
- }
-
- @keyframes ellipsis {
- from {
- width: 2px;
- }
-
- to {
- width: 15px;
- }
- }
- }
-
- .shuju_one_title {
- width: 70%;
- margin: 0 auto;
- display: flex;
-
- .tltle_text {
- width: 25%;
- border: 2rpx solid #B2B2B2;
- color: #57c878;
- text-align: center;
- font-size: 24rpx;
- height: 50rpx;
- line-height: 50rpx;
- }
-
- .title_text_color {
- width: 25%;
- border: 2rpx solid #57c878;
- background-color: #57c878;
- color: #fff;
- text-align: center;
- font-size: 24rpx;
- height: 50rpx;
- line-height: 50rpx;
- }
- }
- }
- /deep/.u-calendar__action {
- display: flex;
- justify-content: space-around;
-
- .u-calendar__action__text {
- line-height: 25px;
- }
- }
- .condition {
- display: flex;
- flex-wrap: wrap;
- width: 90%;
- margin: 30rpx auto;
- box-shadow: 0 0 10rpx #bcb9ca;
- margin-bottom: 30rpx;
-
- .scroll-X {
- width: 95%;
- margin: 20rpx auto;
- .table{
- width: 1416px;
- }
- .tr {
- display: flex;
- overflow: hidden;
-
- .th,
- .td {
- display: inline-block;
- padding: 5rpx;
- width: 240rpx;
- text-align: center;
- height: 52rpx;
- line-height: 52rpx;
- border: 2rpx solid #F1F1F1;
- }
-
- .th:first-child,
- .td:first-child {
- width: 300rpx;
- }
- }
- .tr:nth-child(2n-1){
- background-color: #f5fff8;
- }
- .tr:first-child{
- background-color: #57c878;
- color: #fff;
- }
- }
-
- .pagenumber {
- display: flex;
- margin: 20rpx auto;
-
- button {
- width: 150rpx;
- height: 50rpx;
- line-height: 50rpx;
- font-size: 26rpx;
- text-align: center;
- background-color: #57c878;
- color: #FFFFFF;
- }
-
- .pagenumber_page {
- // width: 100rpx;
- height: 50rpx;
- line-height: 50rpx;
- font-size: 26rpx;
- text-align: center;
- margin: 0 20rpx;
- }
- }
- }
- </style>
|