| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006 |
- {% load staticfiles %}
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <link href="{% static '/lib/bootstrap-3.3.7/css/bootstrap.css' %}" rel="stylesheet">
- <link rel="stylesheet" href="{% static '/lib/font-awesome/4.5.0/css/font-awesome.css' %}">
- <link rel="stylesheet" href="{% static '/lib/css/ace.min.css' %}" />
- <link rel="stylesheet" href="{% static '/lib/css/ace-skins.min.css' %}">
- <link rel="stylesheet" href="{% static '/lib/css/ace-rtl.min.css' %}">
- <link rel="stylesheet" href="{% static '/lib/layui/css/layui.css' %}">
- <link rel="stylesheet" href="{% static '/css/loading.css' %}?versions=0.5.0" />
- <style type="text/css">
- body {
- overflow: hidden;
- background: #fff;
- }
- /* 返回 */
- .headerPlace {
- font-size: 22px;
- color: #418fbb;
- cursor: pointer;
- }
- .headerPlace img {
- vertical-align: middle;
- margin-right: 10px;
- margin-top: -4px;
- }
- /* table th {
- white-space: nowrap;
- }
- table td {
- white-space: nowrap;
- }
- .form-group {
- display: inline-block;
- }
- #distpicker5 {
- display: inline-block;
- }
- .unusual-title,
- .enter-form {
- margin: 6px 0;
- }
- .form-group {
- display: inline-block;
- margin-top: 6px;
- }
- .sx-title {
- margin-left: 20px;
- }
- .btn-shaixuan {
- margin-left: 40px;
- }
- .fl {
- float: left;
- }
- .fr {
- float: right;
- }
- .clearfix:after {
- content: "";
- display: block;
- clear: both;
- height: 0;
- visibility: hidden;
- }
- .clearfix {
- *zoom: 1;
- }
- .container-wrap {
- margin: 30px 0;
- }
- .container-cartogram>div {
- width: 100%;
- margin: 0 10px;
- height: 300px;
- text-align: center;
- line-height: 300px;
- font-size: 22px;
- color: #8a8a8a;
- position: relative;
- }
- .container-cartogram>div>div {
- width: 100%;
- height: 100%;
- }
- .container-cartogram>div>.hint {
- width: 100%;
- height: 100%;
- position: absolute;
- }
- .widget-content {
- overflow-x: scroll;
- padding-top: 0;
- }
- .searchBox {
- text-align: right;
- margin-right: 100px;
- margin-bottom: 30px;
- }
- #searchBtn {
- margin-bottom: 10px;
- margin-left: 10px;
- } */
- body {
- overflow: hidden;
- background: #fff;
- }
- .searchCover {
- margin: 20px 0;
- }
- .peatdata {
- padding: 0 1px 0 0;
- min-width: 750px;
- overflow-x: scroll;
- }
- .table,
- .table.table-striped>thead>tr>th {
- text-align: center;
- }
- table td {
- vertical-align: middle !important;
- }
- .nullData {
- width: 100%;
- height: 500px;
- background: #ddd;
- text-align: center;
- line-height: 500px;
- font-size: 20px;
- border: 1px solid #ddd;
- }
- .container-wrap {
- margin: 30px 0;
- }
- .container-cartogram>div {
- width: 100%;
- margin: 0 10px;
- height: 300px;
- text-align: center;
- line-height: 300px;
- font-size: 22px;
- color: #8a8a8a;
- position: relative;
- }
- .container-cartogram>div>div {
- width: 100%;
- height: 100%;
- }
- .container-cartogram>div>.hint {
- width: 100%;
- height: 100%;
- position: absolute;
- }
- .fl {
- float: left;
- }
- .fr {
- float: right;
- }
- .clearfix:after {
- content: "";
- display: block;
- clear: both;
- height: 0;
- visibility: hidden;
- }
- .clearfix {
- *zoom: 1;
- }
- #wormType {
- min-width: 150px;
- }
- .timeStage {
- display: none;
- }
- .downTitle {
- text-align: right;
- line-height: 27px;
- padding-left: 0;
- margin-bottom: 5px;
- }
- .downContent {
- padding-left: 0;
- margin-bottom: 5px;
- }
- .title{
- font-size: 20px;
- border-left: 5px solid #438eb9;
- padding-left: 12px;
- color: #438eb9;
- font-weight: 700;
- }
- .manualBtn{
- float: right;
- }
- .layui-input{
- height: 30px;
- }
- /* 设备信息 */
- .userinfo{
- margin: 20px 0;
- font-size: 14px;
- }
- .userinfo .fa {
- font-size: 18px;
- color: #26b3ff;
- margin: 0px 5px;
- }
- </style>
- </head>
- <body>
- <div class="content">
- <div class="page-header">
- <span class="headerPlace" onclick="goback('cbd_report')">
- <img src="{% static '/img/gobackIcon.png' %}" alt="">返回
- </span>
- </div>
- <div class="userinfo">
- <div class=" ">
- <i class="fa fa-user-o" aria-hidden="true"></i>
- 设备ID:
- <span class="userinfoTitle">{{ e_id }}</span>
- </div>
- </div>
- <div>
- <div class="title">
- 手动害虫统计
- </div>
- {% if disc == "0" %}{% else %}
- <!-- <button type="button" onclick="openPage('pest_statis','{{ e_id }}')" class="btn btn-sm btn-primary manualBtn">自动害虫统计</button> -->
- <button type="button" onclick="openDetialPage('pest_statis?id={{ e_id }}+')" class="btn btn-sm btn-primary manualBtn">自动害虫统计</button>
- {% endif %}
- </div>
-
- <div class="searchCover">
- 统计图筛选条件:
- <input type="text" id="searchTime" autocomplete="off" style="width: 180px;">
- <input type="hidden" id="begin" name="begin">
- <input type="hidden" id="end" name="end">
- <button type="button" onclick="datsub_filter()" class="btn btn-sm btn-primary">筛选</button>
- 害虫种类:
- <div style="display: inline-block;width: 187px;">
- <form class="layui-form" action="" lay-filter="wormTypeForm">
- <select name="wormType" id="wormType" lay-verify="" lay-filter="wormType" lay-search>
- <option value="">暂无害虫种类</option>
- </select>
- </form>
- </div>
-
- </div>
- <div class="container-wrap">
- <div>
-
- </div>
- <div class="container-cartogram clearfix">
- <div class="echartsBox fl" style="width:63%">
- <div class="hint"></div>
- <div class="fl" id="line-chart"></div>
- </div>
- <div class="echartsBox fl" style="width:30%">
- <div class="hint"></div>
- <div class="fl" id="pie-chart"></div>
- </div>
- </div>
- <div>
- <input id="imei" type="hidden" type="text" value={{ e_id }}>
- </div>
- </div>
- <div class="searchCover">
- 统计图筛选条件:
- <input type="text" id="tableSearchTime" autocomplete="off" style="width: 180px;">
- <input type="hidden" id="tableBegin" name="begin">
- <input type="hidden" id="tableEnd" name="end"> 种类查找:
- <div style="display: inline-block;width: 187px;">
- <form class="layui-form" action="" lay-filter="demoForm">
- <select name="pestCategory" id="pestCategory" lay-verify="" lay-search>
- <option value="">害虫种类为空</option>
- </select>
- </form>
- </div>
- <button type="button" onclick="table_sub_filter()" class="btn btn-sm btn-primary">筛选</button>
- <!-- <button type="button" class="btn btn-success btn-sm" onclick="decideExport()">导出</button> -->
- </div>
- <div class="innerTable peatdata">
- <table id="datatable" class="table table-striped table-hover">
- <thead>
- <tr>
- <!-- <th>设备ID</th>
- <th>设备名称</th> -->
- <th>害虫名称</th>
- <th>害虫数量</th>
- <th>作物种类</th>
- <th>虫害阶段</th>
- <!-- <th>拍照时间</th> -->
- <th>统计时间</th>
- </tr>
- </thead>
- <tbody>
- {% for i in descs %}
- <tr>
- <td>{{ i.pest_name }}</td>
- <td>{{ i.pest_num }}</td>
- <td>{{ i.crop_name }}</td>
- <td>{{ i.pest_case }}</td>
- <td>{{ i.add_time }}</td>
- <!-- <td>
- <a class="fpsb-link" href="allot?uname={{ user.username }}" style="display: inline-block;">
- <button class="btn btn-primary btn-shaixuan">分配设备</button>
- </a>
- </td> -->
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <div class="fenpei-bottom ">
- <input type="hidden" id="totalPage" value={{ nums }}>
- <div id="page" style="text-align: center;"></div>
- </div>
- </div>
- <!-- 导出提示框 -->
- <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- <h4 class="modal-title" id="myModalLabel">导出信息</h4>
- </div>
- <div class="modal-body">
- <div class="row">
- <div class="col-xs-3 downTitle">文件名称:</div>
- <div class="col-xs-8 downContent" style=>
- <input type="text" id="filename" placeholder="请输入文件的名称" maxlength="15" class="col-xs-12">
- </div>
- <div class="col-xs-3 downTitle">下载类型:</div>
- <div class="col-xs-8 downContent">
- <select name="downtype" id="downtype" onchange="downtype(this)" class="col-xs-12">
- <option value="1">全部</option>
- <option value="2">时间段</option>
- </select>
- </div>
- <div class="col-xs-3 downTitle timeStage">时间段:</div>
- <div class="col-xs-8 downContent timeStage">
- <input type="text" id="timSelectBox3" autocomplete="off" placeholder="请选择时间段 " class="col-xs-12">
- <input type="hidden" id="downbegin" name="begin">
- <input type="hidden" id="downend" name="end">
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-primary btn-sm" onclick="operation()">下载</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script src="{% static '/lib/js/jquery-2.1.4.min.js' %}"></script>
- <script src="{% static '/lib/layui/layui.all.js' %}"></script>
- <!-- 统计图 -->
- <script src="{% static '/lib/bootstrap-3.3.7/js/bootstrap.js' %}"></script>
- <script src="{% static '/js/common.js' %}?versions=0.5.0"></script>
- <script src="{% static '/lib/js/echarts.min.js' %}"></script>
- <script>
- $.ajaxSetup({
- data: { csrfmiddlewaretoken: '{{ csrf_token }}' },
- });
- function openPage(url,id) {
- window.location.href = url+"?id=" + id;
- }
- </script>
- <script>
- layui.use(['laydate', 'form'], function () {
- var laydate = layui.laydate;
- var form = layui.form;
- var _layDateMark = (new Date()).getTime();
- $('#searchTime').attr('lay-key', '11' + _layDateMark);
- $('#tableSearchTime').attr('lay-key', '22' + _layDateMark);
- $('#timSelectBox3').attr('lay-key', '33' + _layDateMark);
- //执行一个laydate实例
- laydate.render({
- elem: '#searchTime' //指定元素
- , type: 'date'
- , range: true
- , done: function (value, date) {
- var dateArray = value.split(' - ')
- $('#begin').val(dateArray[0]);
- $('#end').val(dateArray[1]);
- }
- });
- //执行一个laydate实例
- laydate.render({
- elem: '#tableSearchTime' //指定元素
- , type: 'date'
- , range: true
- , done: function (value, date) {
- var dateArray = value.split(' - ')
- $('#tableBegin').val(dateArray[0]);
- $('#tableEnd').val(dateArray[1]);
- }
- });
- //执行一个laydate实例
- laydate.render({
- elem: '#timSelectBox3' //指定元素
- , range: true
- , done: function (value, date) {
- var dateArray = value.split(' - ')
- $('#downbegin').val(dateArray[0])
- $('#downend').val(dateArray[1])
- }
- });
- });
- $.ajax({
- url: 'cbd/cbd_pest_data',
- type: 'post',
- data: {
- 'imei': $('#imei').val(),
- 'tbegin': '',
- 'tend': '',
- },
- beforeSend: function (XMLHttpRequest) {
- layui.use(['layer'], function () {
- var layer = layui.layer;
- //注意,layer.msg默认3秒自动关闭,如果数据加载耗时比较长,需要设置time
- loadingFlag= layer.msg('正在读取数据,请稍候……', { icon: 16, shade: 0.01,shadeClose:false ,time:false});
- })
- },
- complete: function (XMLHttpRequest, textStatus) {
- layer.close(loadingFlag);
- },
- dataType: "json",
- success: function (data) {
- wormEcharts(data)
- }
- })
- $.ajax({
- url: 'cbd/cbd_pest_table_data',
- type: 'post',
- data: {
- imei: $('#imei').val(),
- page: 1
- },
- beforeSend: function (XMLHttpRequest) {
- layui.use(['layer'], function () {
- var layer = layui.layer;
- //注意,layer.msg默认3秒自动关闭,如果数据加载耗时比较长,需要设置time
- loadingFlag1= layer.msg('正在读取数据,请稍候……', { icon: 16, shade: 0.01,shadeClose:false,time:false});
- })
- },
- complete: function (XMLHttpRequest, textStatus) {
- layer.close(loadingFlag1);
- },
- dataType: "json",
- success: function (data) {
- if (data.dat.length) {
- var categoryArr = [];
- var str = '<option value="">害虫种类</option>';
- for (var i = 0; i < data.dat.length; i++) {
- if(categoryArr.indexOf(data.dat[i].pest_name) == -1 && data.dat[i].pest_name){
- categoryArr.push(data.dat[i].pest_name);
- }
- if(i == data.dat.length-1){
- console.log(categoryArr)
- for (var z = 0; z < categoryArr.length; z++) {
- str += '<option value="' + categoryArr[z] + '">' + categoryArr[z] + '</option>';
- if(z == categoryArr.length-1){
- $('#pestCategory').html(str);
- }
- }
- }
- }
- var form = layui.form;
- form.render('select');
- $('#page').parent().show();
- pestFill_Table('datatable', data.dat);
- } else {
- $('#page').parent().hide();
- datFill_null_Table('datatable');
- $('#pestCategory').html('<option value="">害虫种类为空</option>');
- var form = layui.form;
- form.render('select');
- }
- initPage(data.nums)
- }
- })
- function downtype(obj) {
- if ($(obj).val() == 2) {
- $('.timeStage').show();
- } else {
- $('.timeStage').hide();
- $('#downbegin').val('');
- $('#downend').val('');
- $('#downtimSelectBox').val('');
- }
- }
- // 导出提示框
- function decideExport() {
- $('#myModal').modal('toggle')
- }
- //导出
- function operation() {
- if (!$('#filename').val()) {
- layer.msg("请填写文件名!", { time: 2000 });
- return false;
- }
- if ($('#downtype').val() == 2) {
- if (!($('#downbegin').val() && $('#downbegin').val())) {
- layer.msg("请选择时间段!", { time: 2000 });
- return false;
- }
- }
- window.location.href = 'pest_export?id=' + $('#imei').val() + '&begin=' + $('#downbegin').val() + '&end=' + $('#downend').val() + '&filename=' + $('#filename').val()
- }
- function initPage(count, parameter, tbegin, tend, pestCategory) {
- layui.use('laypage', function () {
- var laypage = layui.laypage;
- laypage.render({
- elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
- , count: count
- , theme: '#428BCA'
- , layout: ['prev', 'page', 'next', 'skip']
- , jump: function (obj, first) {
- if (!first) {
- $.ajax({
- url: 'cbd/cbd_pest_table_data',
- type: 'post',
- data: {
- imei: $('#imei').val(),
- page: obj.curr,
- tbegin: tbegin,
- tend: tend,
- pest_name: pestCategory
- },
-
- beforeSend: function (XMLHttpRequest) {
- layui.use(['layer'], function () {
- var layer = layui.layer;
- //注意,layer.msg默认3秒自动关闭,如果数据加载耗时比较长,需要设置time
- loadingFlag2= layer.msg('正在读取数据,请稍候……', { icon: 16, shade: 0.01,shadeClose:false,time:false});
- })
- },
- complete: function (XMLHttpRequest, textStatus) {
- layer.close(loadingFlag2);
- },
- dataType: "json",
- success: function (data) {
- if (data.dat.length) {
- $('#page').parent().show();
- pestFill_Table('datatable', data.dat);
- } else {
- $('#page').parent().hide();
- datFill_null_Table('datatable');
- }
- }
- })
- }
- }
- })
- })
- }
- function datFill_null_Table(table_id) {
- $("#datatable tr:not(:first)").remove();
- var table = document.getElementById(table_id).children[1];
- var row = table.insertRow(table.rows.length);
- var c1 = row.insertCell(0);
- c1.setAttribute('colspan', '16');
- c1.setAttribute('class', 'nullData');
- c1.innerHTML = "暂无数据";
- scrollBar();
- }
- function datFill_Table(table_id, dat) {
- var table = document.getElementById(table_id).children[1];
- for (var i = 0; i < dat.length - 1; i++) {
- var row = table.insertRow(table.rows.length);
- if (dat[i].length == 0) { continue; }
- //JSON字符串转换JSON对象
- // var stat = eval('(' + dat[i].cbd_data + ')');
- var c1 = row.insertCell(0);
- c1.innerHTML = dat[i].pest_name;
- var c2 = row.insertCell(1);
- c2.innerHTML = dat[i].pest_num;
- var c3 = row.insertCell(2);
- if (dat[i].crop_name == '') {
- c3.innerHTML = '无';
- } else {
- c3.innerHTML = dat[i].crop_name;
- }
- var c4 = row.insertCell(3);
- if (dat[i].pest_case == '') {
- c4.innerHTML = '无';
- } else {
- c4.innerHTML = dat[i].pest_case;
- }
- var c5 = row.insertCell(4);
- c5.innerHTML = dat[i].add_time;
- }
- }
- function pestFill_Table(table_id, dat) {
- $("#datatable tr:not(:first)").remove();
- var table = document.getElementById(table_id).children[1];
- for (var i = 0; i < dat.length; i++) {
- var row = table.insertRow(table.rows.length);
- var c1 = row.insertCell(0);
- c1.innerHTML = dat[i].pest_name;
- var c2 = row.insertCell(1);
- c2.innerHTML = dat[i].pest_num;
- var c3 = row.insertCell(2);
- c3.innerHTML = dat[i].crop_name;
- var c4 = row.insertCell(3);
- c4.innerHTML = dat[i].pest_case;
- var c5 = row.insertCell(4);
- c5.innerHTML = dat[i].add_time;
- }
- scrollBar();
- }
- var lineChart = echarts.init(document.getElementById('line-chart'));
- lineOption = {
- title: {
- text: '害虫统计',
- textStyle: {
- color: '#029eef',
- fontSize: 14
- }
- },
- legend: {
- 'right': '10%',
- data: []
- },
- toolbox: { //可视化的工具箱
- show: true,
- left: 'right',
- feature: {
-
- restore: { //重置
- show: true
- },
- dataZoom: { //数据缩放视图
- show: true
- },
- saveAsImage: {//保存图片
- show: true
- },
- magicType: {//动态类型切换
- type: ['bar', 'line']
- }
- }
- },
- tooltip: {
- trigger: 'axis',
- formatter: function (params) {
- return params[0].axisValue + '<br/>' + params[0].marker +params[0].seriesName+':'+params[0].value+'只';
- }
- },
- xAxis: {
- data: []
- },
- yAxis: [{
- axisLine: { show: true },
- type:'value'
- }],
- dataZoom: {
- show: true
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '6%',
- containLabel: true
- },
- series: []
- }
-
- var color = ['#5689f2', '#00c1de', '#4caf50', '#009688', '#4caf50', '#8bc34a', '#cddc39', '#ffeb3b', '#ffc107', '#ff9800'];
- var pieChart = echarts.init(document.getElementById('pie-chart'));
- pieOption = {
- title: {
- text: '害虫比例',
- textStyle: {
- color: '#029eef'
- }
- },
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b} : {c} ({d}%)"
- },
- legend: {
- orient: 'vertical',
- left: 'right',
- data: []
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '6%',
- containLabel: true
- },
- series: [
- {
- name: '害虫种类',
- type: 'pie',
- radius: '55%',
- radius: ['50%', '70%'],
- data: [],
- itemStyle: {
- emphasis: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- };
- window.onresize = function () {
- //当窗口发生变化时图表显示
- lineChart.resize();
- pieChart.resize();
- }
- function wormEcharts(data) {
- category = []; //害虫种类
- lineVal = []; //折线数据(时间+值+名称)
- if(data.length){
- for(var i = 0;i<data.length;i++){
- var json = {
- val:[],
- time:[],
- }
- if(category.indexOf(data[i].pest_name) != -1){
- lineVal[category.indexOf(data[i].pest_name)].val.unshift(data[i].pest_num)
- lineVal[category.indexOf(data[i].pest_name)].time.unshift(data[i].add_time)
- // lineVal[category.indexOf(data[i].dat[z].pest_name)].name.unshift(data[i].dat[z].pest_name)
- }else{
- category.push(data[i].pest_name);
- lineVal.push({
- val:[data[i].pest_num],
- time:[data[i].add_time],
- name:data[i].pest_name,
- })
- }
- if(i == data.length-1){
- console.log(category)
- console.log(lineVal)
- // 害虫种类填充
- var html = '';
- for (var s = 0; s < category.length; s++) {
- html += '<option value="' + s + '">' + category[s] + '</option>';
- if (s == category.length - 1) {
- if (html) {
- $('#wormType').html(html)
- } else {
- $('#wormType').html('<option value="">暂无害虫种类</option>')
- }
- }
- }
- var form = layui.form;
- form.render('select');
- form.on('select(wormType)', function(data){
- fillLineChart(data.value)
- });
- // 默认第一条折线填充
- if(lineVal.length){
- fillLineChart(0)
- // 害虫比例
- if (category.length) {
- pieOption.series[0].data = [];
- for (var a = 0; a < category.length; a++) {
- var num = eval(lineVal[a].val.join("+"))
- var da = '{ value:' + num + ', name:"' + lineVal[a].name + '"}';
- pieOption.series[0].data.push(eval('(' + da + ')'));
- }
- $('#pie-chart').prev().html('').css('z-index', 0);
- pieChart.setOption(pieOption);
- } else {
- pieOption.series[0].data = [];
- pieChart.setOption(pieOption);
- $('#pie-chart').prev().html('暂无害虫数据').css('z-index', 99);
- }
- }else{
- lineChart.clear();
- lineOption.series = [];
- lineOption.xAxis.data = [];
- pieOption.series[0].data = [];
- lineChart.setOption(lineOption);
- pieChart.setOption(pieOption);
- $('#line-chart').prev().html('暂无害虫数据').css('z-index', 99);
- $('#pie-chart').prev().html('暂无害虫数据').css('z-index', 99);
- $('#wormType').html('<option value="">暂无害虫种类</option>')
- }
-
- }
- }
- }else{
- lineChart.clear();
- lineOption.series = [];
- lineOption.xAxis.data = [];
- pieOption.series[0].data = [];
- lineChart.setOption(lineOption);
- pieChart.setOption(pieOption);
- $('#line-chart').prev().html('暂无害虫数据').css('z-index', 99);
- $('#pie-chart').prev().html('暂无害虫数据').css('z-index', 99);
- $('#wormType').html('<option value="">暂无害虫种类</option>')
- }
- // var legend = ['温度', '湿度', '害虫个数'];
- // var kindNum = dat.kind;
- var type1 = [];
- var typeValue = [];
- }
- pieChart.on("click", function (param) {
- pieConsole(param, '')
- });
- function pieConsole(param, type) {
- $('#wormType').val(param.dataIndex)
- $('#wormType').change()
- fillLineChart(param.dataIndex)
- var form = layui.form;
- form.render('select');
- }
- function fillLineChart(num){
- lineChart.clear();
- lineOption.series = [];
- lineOption.series.unshift({
- name: category[num],
- type: 'line',
- data: lineVal[num].val,
- itemStyle: {
- normal: {
- color: color[2],
- shadowBlur: 1,
- shadowColor: color[2],
- borderColor: color[2],
- borderWidth: 2,
- backgroundColor: 'transparent'
- }
- },
- areaStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
- offset: 0,
- color: color[2]
- }, {
- offset: 1,
- color: 'rgba(255, 2555, 255, 0.2)'
- }]),
- }
- }
- });
- $('#line-chart').prev().html('').css('z-index', 0);
- lineOption.xAxis.data = lineVal[num].time;
- lineChart.setOption(lineOption);
- }
- function datsub_filter() {
- var tbegin = $('#begin').val();
- var tend = $('#end').val();
- if (tbegin && tend) {
- $.ajax({
- url: 'cbd/cbd_pest_data',
- type: 'post',
- data: {
- 'imei': $('#imei').val(),
- 'tbegin': tbegin,
- 'tend': tend,
- },
- beforeSend: function (XMLHttpRequest) {
- layui.use(['layer'], function () {
- var layer = layui.layer;
- //注意,layer.msg默认3秒自动关闭,如果数据加载耗时比较长,需要设置time
- loadingFlag= layer.msg('正在读取数据,请稍候……', { icon: 16, shade: 0.01,shadeClose:false,time:false});
- })
- },
- complete: function (XMLHttpRequest, textStatus) {
- layer.close(loadingFlag);
- },
- dataType: "json",
- success: function (data) {
- wormEcharts(data)
- }
- })
- } else {
- layer.msg('请填写时间段')
- }
- }
- function table_sub_filter() {
- var pestCategory = $('#pestCategory').val();
- var tbegin = $('#tableBegin').val();
- var tend = $('#tableEnd').val();
- if ((tbegin && tend) || pestCategory) {
- $.ajax({
- url: 'cbd/cbd_pest_table_data',
- type: 'post',
- data: {
- req: 'filter',
- 'imei': $('#imei').val(),
- tbegin: tbegin,
- tend: tend,
- pest_name: pestCategory,
- page: 1
- },
- beforeSend: function (XMLHttpRequest) {
- layui.use(['layer'], function () {
- var layer = layui.layer;
- //注意,layer.msg默认3秒自动关闭,如果数据加载耗时比较长,需要设置time
- loadingFlag= layer.msg('正在读取数据,请稍候……', { icon: 16, shade: 0.01,shadeClose:false,time:false});
- })
- },
- complete: function (XMLHttpRequest, textStatus) {
- layer.close(loadingFlag);
- },
- dataType: "json",
- success: function (data) {
- if (data.dat.length) {
- $('#page').parent().show();
- pestFill_Table('datatable', data.dat);
- } else {
- $('#page').parent().hide();
- datFill_null_Table('datatable');
- }
- initPage(data.nums, 'filter', tbegin, tend, pestCategory);
- }
- })
- } else {
- layer.msg('请至少选择一项筛选')
- }
- }
- </script>
- </body>
- </html>
|