| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- $(document).ready(function () {
- if ($('#totalPage').val() > 0) {
- $('.pestBtn').show();
- $('.delbox .batchesBtn').show();
- } else {
- $('.pestBtn').hide();
- $('.delbox .batchesBtn').hide();
- $('#page').parent().hide();
- }
-
- // $('.popup-gallery').magnificPopup({
- // delegate: '.popupA',
- // type: 'image',
- // tLoading: 'Loading image ......',
- // mainClass: 'mfp-img-mobile',
- // gallery: {
- // enabled: true,
- // navigateByImgClick: true,
- // preload: [0, 1], // Will preload 0 - before current, and 1 after the current image
- // arrowMarkup: '<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>', // markup of an arrow button
- // tPrev: 'Previous (Left arrow key)', // title for left button
- // tNext: 'Next (Right arrow key)', // title for right button
- // tCounter: '<span class="mfp-counter">%curr% of %total%</span>' // 标记的计数器
- // },
- // image: {
- // tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
- // titleSrc: function (item) {
- // return item.el.attr('title') + '<small></small>';
- // }
- // }
- // });
- // 添加描述
- $('.addDetial').on('click',function(){
- var _this = this;
- layer.open({
- type: 1,
- title:'添加详情',
- area:['550px','330px'],
- content: $('#test-popup'),
- success:function(){
- var photoTime = $(_this).parent().find('.photoTime').val();
- var addr = $(_this).parent().find('img').attr('src');
- $('#imgPath').val(addr);
- $('#photo_time').val(photoTime);
- $.ajax({
- url: 'cbd_describe_img',
- type: 'get',
- data: { req: "pest_kind", addr: addr },
- success: function (data) {
- var msg = $.parseJSON(data);
- if (msg.length) {
- //配置数据回显
- $('#pupopForm select[name="wormName"]').empty();
- $('#delwormType .pupopBody').empty();
- for (var i = 0; i < msg.length; i++) {
- var html = "<option value='" + msg[i].pest_name + "'>" + msg[i].pest_name + "</option>"
- $('#pupopForm select[name="wormName"]').append(html);
- var pestName = '<label class="my_protocol">'+
- '<input class="input_agreement_protocol" value="'+msg[i].pest_name+'" type="checkbox">'+
- '<span></span>'+msg[i].pest_name+'</label>';
- $('#delwormType .pupopBody').append(pestName);
- }
- if (msg.length >= 180 ) {
- $('#addNameBtn').hide();
- }else{
- $('#addNameBtn').show();
- }
- if ($('#pupopForm option').length <= 0) {
- $('#delNameBtn').hide();
- } else {
- $('#delNameBtn').show();
- }
- }else{
- $('#delNameBtn').hide();
- }
- if (msg.length >= 180 ) {
- $('#addNameBtn').hide();
- }else{
- $('#addNameBtn').show();
- }
- if ($('#pupopForm option').length <= 0) {
- $('#delNameBtn').hide();
- } else {
- $('#delNameBtn').show();
- }
- }
-
- })
-
- }
- });
- })
- // $('.addDetial').magnificPopup({
- // type: 'inline',
- // closeOnBgClick:false,
- // midClick: true,
- // callbacks: {
- // open: function () {
- // // 当前选中项
- // var item = this.currItem.el[0];
- // var addr = $(item).parent().find('img').attr('src');
- // var photoTime = $(item).parent().find('.photoTime').val();
- // $('#imgPath').val(addr);
- // $('#photo_time').val(photoTime);
- // $.ajax({
- // url: 'cbd_describe_img',
- // type: 'get',
- // data: { req: "pest_kind", addr: addr },
- // success: function (data) {
- // var msg = $.parseJSON(data);
- // if (msg.length) {
- // //配置数据回显
- // $('#pupopForm select[name="wormName"]').empty();
- // $('#delwormType .pupopBody').empty();
- // for (var i = 0; i < msg.length; i++) {
- // var html = "<option value='" + msg[i].pest_name + "'>" + msg[i].pest_name + "</option>"
- // $('#pupopForm select[name="wormName"]').append(html);
- // var pestName = '<label class="my_protocol">'+
- // '<input class="input_agreement_protocol" value="'+msg[i].pest_name+'" type="checkbox">'+
- // '<span></span>'+msg[i].pest_name+'</label>';
- // $('#delwormType .pupopBody').append(pestName);
- // }
- // if (msg.length >= 180 ) {
- // $('#addNameBtn').hide();
- // }else{
- // $('#addNameBtn').show();
- // }
- // if ($('#pupopForm option').length <= 0) {
- // $('#delNameBtn').hide();
- // } else {
- // $('#delNameBtn').show();
- // }
- // }else{
- // $('#delNameBtn').hide();
- // }
- // }
- // })
- // goBackAddDetial();
- // }
- // }
- // });
- //查看详情
- $('.lookDetial').on('click',function(){
- var _this = this;
- layer.open({
- type: 1,
- area:'800px',
- offset: '100px',
- content: $('#lookDescribe'),
- success:function(){
- $("#wormDetails tr:not(:first)").remove();
- var addr = $(_this).parent().find('img').attr('src');
- $('#imgPath_dteial').val(addr);
- $.ajax({
- url: 'cbd_describe_img',
- type: 'get',
- data: { req: "desc", addr: addr },
- success: function (data) {
- var msg = $.parseJSON(data);
- if (msg.length) {
- //配置数据回显
- console.log('data:', data)
- for (var i = 0; i < msg.length; i++) {
- var html = '<tr><td class="optionName">' + msg[i].pest_name + '</td><td class="option">' + msg[i].pest_num + '</td>' +
- '<td class="option">' + msg[i].crop_name + '</td><td class="option">' + msg[i].pest_case + '</td>' +
- '<td><button type="button" class="btn editBtn btn-xs btn-primary" onclick="edit($(this))">编辑</button>' +
- '<button type="button" class="btn btn-xs saveBtn btn-success" onclick="save($(this))">保存</button>' +
- '<button type="button" style="margin-left:5px" class="btn btn-xs delBtn btn-danger" onclick="delItemDetial($(this))">删除</button></td></tr>';
- $('#wormDetails').append(html);
- }
- } else {
- var html = '<tr><td class="nullData" colspan="5">暂无数据</td></tr>'
- $('#wormDetails').append(html);
- }
- }
- })
- }
- });
- })
-
- // $('.lookDetial').magnificPopup({
- // type: 'inline',
- // closeOnBgClick:false,//点击蒙版消失
- // midClick: true,
- // callbacks: {
- // open: function () {
- // // 当前选中项
- // $("#wormDetails tr:not(:first)").remove();
- // var item = this.currItem.el[0];
- // var addr = $(item).parent().find('img').attr('src');
- // $('#imgPath_dteial').val(addr);
- // $.ajax({
- // url: 'cbd_describe_img',
- // type: 'get',
- // data: { req: "desc", addr: addr },
- // success: function (data) {
- // var msg = $.parseJSON(data);
- // if (msg.length) {
- // //配置数据回显
- // console.log('data:', data)
- // for (var i = 0; i < msg.length; i++) {
- // var html = '<tr><td class="optionName">' + msg[i].pest_name + '</td><td class="option">' + msg[i].pest_num + '</td>' +
- // '<td class="option">' + msg[i].crop_name + '</td><td class="option">' + msg[i].pest_case + '</td>' +
- // '<td><button type="button" class="btn editBtn btn-xs btn-primary" onclick="edit($(this))">编辑</button>' +
- // '<button type="button" class="btn btn-xs saveBtn btn-success" onclick="save($(this))">保存</button>' +
- // '<button type="button" style="margin-left:5px" class="btn btn-xs delBtn btn-danger" onclick="delItemDetial($(this))">删除</button></td></tr>';
- // $('#wormDetails').append(html);
- // }
- // } else {
- // var html = '<tr><td class="nullData" colspan="5">暂无数据</td></tr>'
- // $('#wormDetails').append(html);
- // }
- // }
- // })
- // }
- // }
- // });
- // $('.addwormTypeBtn').magnificPopup({
- // type: 'inline',
- // closeOnBgClick:false,
- // midClick: true,
- // })
-
- })
- // 自动识别
- function autoSeeWormType(obj){
- var addr = $(obj).parent().find('img').attr('src');
- $.ajax({
- url: 'pests_identification',
- type: 'post',
- dataType:'json',
- data: {img_addr: addr },
- beforeSend: function () {
- loadingFlag = layer.load();
- },
- success: function (data) {
- layer.close(loadingFlag);
- if(data.result){
- var html = '';
- var wormArr = data.result.split('#');
- var wormImg = data.image;
- html += '<div class="resultTitle">图片标记</div>';
- html += '<div class="wormImgTag"><img src="'+wormImg+'" /></div>';
- html += '<div class="resultTitle">识别结果</div>';
- for(var i = 0;i < wormArr.length;i++){
- var worm = wormArr[i].split(',');
- var wormName = worm[0];
- var wormNum = worm[1];
- html += '<div class="wormResult"><span>害虫名称:<i>'+insect_dict[wormName]+'(序号:'+wormName+')</i></span><span>害虫个数:<i>'+wormNum+'</i></span></div>';
- if(i == wormArr.length-1){
- html += '<div class="clear"></div>';
- $('.wormBox').html(html);
- }
- }
- }else{
- var html = '';
- html += '<i class="fa fa-times wormIcon" style="color:#bd0606" aria-hidden="true"></i><div>'+
- '<h4 class="">此类暂未录入</h4></div>'
- $('.wormBox').html(html);
- }
- $.magnificPopup.open({
- items: {
- src: '#autoDiscern',
- midClick: true,
- type: 'inline'
- },
- closeOnBgClick:false,
- });
- },
- error:function(){
- layer.close(loadingFlag);
- $.magnificPopup.open({
- items: {
- src: '#autoDiscern',
- midClick: true,
- type: 'inline'
- },
- closeOnBgClick:false,
- });
- var html = '';
- html += '<i class="fa fa-times wormIcon" style="color:#bd0606" aria-hidden="true"></i><div>'+
- '<h4 class="">识别失败</h4></div>'
- $('.wormBox').html(html);
- }
- })
- }
- function newAutoDiscern(obj){
- var addr = $(obj).parent().find('img').attr('src');
- $.ajax({
- url: 'pests_identification_new',
- type: 'post',
- dataType:'json',
- data: {img_addr: addr },
- beforeSend: function () {
- loadingFlag = layer.load();
- },
- success: function (data) {
- layer.close(loadingFlag);
- if(data.result){
- var html = '';
- var htmlA = '';
- var htmlB = '';
- var wormArr = data.result.split('#');
- var wormImg = data.image;
- htmlB += '<div class="resultTitle">图片标记<button class="btn btn-sm btn-primary resultLookGitImg" onclick="window.open(\''+wormImg+'\')">查看大图</button></div>';
- htmlB += '<div class="wormImgTag"><img src="'+wormImg+'" /></div>';
- htmlA += '<div class="resultTitle">识别结果</div>';
- for(var i = 0;i < wormArr.length;i++){
- var worm = wormArr[i].split(',');
- var wormName = worm[0];
- var wormNum = worm[1];
- htmlA += '<div class="wormResult"><span>害虫名称:<a target="_blank" href = "https://baike.baidu.com/item/'+insect_dict[wormName]+'?fr=aladdin"><i>'+insect_dict[wormName]+'(序号:'+wormName+')</i></a></span><span class="dataNums">害虫个数:<i>'+wormNum+'</i></span></div>';
- if(i == wormArr.length-1){
- html += '<div class="dataListB">' + htmlB +'</div>';
- html += '<div class="dataListA">' + htmlA +'</div>';
- html += '<div class="clear"></div>';
- $('.wormBox').html(html);
- layui.use('layer', function(){
- var layer = layui.layer;
- layer.open({
- type:1,
- offset:'100px',
- // area:'900px',
- // area:'90%',
- area:'1400px',
- title:'害虫计数',
- content:$('#autoDiscern')
- });
- });
- }
- }
- }else{
- var html = '';
- html += '<i class="fa fa-times wormIcon" style="color:#bd0606" aria-hidden="true"></i><div>'+
- '<h4 class="">此类暂未录入</h4></div>'
- $('.wormBox').html(html);
- layui.use('layer', function(){
- var layer = layui.layer;
-
- layer.open({
- type:1,
- area:['400px','250px'],
- title:'提示',
- content:$('#failure')
- });
- });
- }
- // $.magnificPopup.open({
- // items: {
- // src: '#autoDiscern',
- // midClick: true,
- // type: 'inline'
- // },
- // closeOnBgClick:false,
- // });
- },
- error:function(){
- layer.close(loadingFlag);
- layui.use('layer', function(){
- var layer = layui.layer;
-
- layer.open({
- type:1,
- area:['400px','250px'],
- title:'提示',
- content:$('#failure')
- });
- });
- var html = '';
- html += '<i class="fa fa-times wormIcon" style="color:#bd0606" aria-hidden="true"></i><div>'+
- '<h4 class="">识别失败</h4></div>'
- $('.wormBox').html(html);
- }
- })
- }
|