| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989 |
- {% 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.4" />
- <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 == "1" or role == "superuser" or role == "staff" %}
- <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.4"></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: []
- },
- 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'
- }],
- toolbox: {
- left: 'center',
- },
- 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>
|