| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- //关闭设置
- function closePopWin(obj) {
- $('.mfp-close').click();
- obj.parents('form')[0].reset();
- }
- //保存
- function savePopWin() {
- var wormName = $('.pupopBody select[name="wormName"]').val();
- var wormKind = $('.pupopBody input[name="wormKind"]').val();
- var wormNum = $('.pupopBody input[name="wormNum"]').val();
- // var wormSex = $('.pupopBody select[name="wormSex"]').val();
- var wormTime = $('.pupopBody input[name="wormTime"]').val();
- var addr = $('#imgPath').val();
- var describe = { pest_name: wormName, crop_name: wormKind, pest_num: wormNum, pest_case: wormTime }
- console.log(describe)
- if (wormName) {
- $.ajax({
- url: 'cbd_describe_img',
- type: 'post',
- data: { req:'add_save',addr: addr, describe: JSON.stringify(describe) },
- success: function (data) {
- if (data==0){
- layer.msg('添加成功!')
- location.reload();
- }else if(data == 2){
- layer.msg('该害虫描述已存在!')
- }
- else if(data == 1){
- layer.msg('添加描述失败!')
- }
-
- }
- })
- }else{
- layer.msg('害虫名称必须填写')
- }
- }
- //删除
- function del(obj) {
- layer.confirm('是否删除?', {
- btn: ['确定', '取消'] //可以无限个按钮
- , btn3: function (index, layero) {
- //按钮【按钮三】的回调
- }
- }, function (index, layero) {
- var array = [];
- var addr = obj.parent().find('img').attr('src');
- array.push(addr);
- var imei = obj.prev().val();
- layer.close(index)
- $.ajax({
- url: 'ybq_delete_img',
- type: 'post',
- data: {
- addr: addr,
- // addr: array,
- imei: imei
- },
- success: function (data) {
- if (data) {
- $.ajax({
- url: '/ybq/ybq_photo?imei=' + $('#imei').val() + '&page=' + $('.layui-laypage-curr em').eq(1).html(),
- type: 'get',
- success: function (data) {
- $('#imgList').html('');
- $('#imgList').html(data);
- if ($('.content').height() > 750) {
- $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
- } else {
- $('#iframe-main', parent.document).css('height', '750px')
- }
- }
- })
- } else {
- alert('删除失败')
- }
- }
- })
- }, function (index) {
- //按钮【按钮二】的回调
- });
- }
- // 批量删除
- function delimgAll(obj){
- if($('.imgcheckbox').css('display') == 'none'){
- $('.imgcheckbox').css('display','inline');
- $('.canceldelimgBtn').show();
- $(obj).html('删除')
- }else{
- if(topicid.length){
- // alert(2)
- var imei = $('.delBtn').prev().val();
- console.log($('.delBtn').prev().val())
- // $.ajax({
- // url: 'delete_img',
- // type: 'post',
- // data: {
- // addr: topicid,
- // imei: imei
- // },
- // success: function (data) {
- // if (data) {
- // location.reload()
- // } else {
- // alert('删除失败')
- // }
-
- // }
- // })
- }else{
- console.log(imei)
- layer.msg('请至少选择一张图片');
- }
- }
- }
- // 取消删除
- function canceldelimg(obj){
- topicid = [];
- $('.imgcheckbox').css('display','none');
- $('.imgcheckbox input').prop('checked',false);
- $(obj).hide();
- $(obj).prev().html('批量删除');
- }
- // 分页初始化
- layui.use('laypage', function () {
- var laypage = layui.laypage;
- laypage.render({
- elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
- , count: $('#totalPage').val()
- , limit: 8
- , layout: ['prev', 'page', 'next', 'skip']
- , jump: function (obj) {
- $.ajax({
- url: 'ybq_img_list?imei=' + $('#imei').val() + '&page=' + obj.curr,
- type: 'get',
- success: function (data) {
- $('#imgList').html('');
- $('#imgList').html(data);
- if ($('.content').height() > 750) {
- $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
- } else {
- $('#iframe-main', parent.document).css('height', '750px')
- }
- }
- })
- }
- });
- });
- window.onresize = function () {
- if ($('.content').height() > 750) {
- $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
- } else {
- $('#iframe-main', parent.document).css('height', '750px')
- }
- }
|