ybq_image.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //关闭设置
  2. function closePopWin(obj) {
  3. $('.mfp-close').click();
  4. obj.parents('form')[0].reset();
  5. }
  6. //保存
  7. function savePopWin() {
  8. var wormName = $('.pupopBody select[name="wormName"]').val();
  9. var wormKind = $('.pupopBody input[name="wormKind"]').val();
  10. var wormNum = $('.pupopBody input[name="wormNum"]').val();
  11. // var wormSex = $('.pupopBody select[name="wormSex"]').val();
  12. var wormTime = $('.pupopBody input[name="wormTime"]').val();
  13. var addr = $('#imgPath').val();
  14. var describe = { pest_name: wormName, crop_name: wormKind, pest_num: wormNum, pest_case: wormTime }
  15. console.log(describe)
  16. if (wormName) {
  17. $.ajax({
  18. url: 'cbd_describe_img',
  19. type: 'post',
  20. data: { req:'add_save',addr: addr, describe: JSON.stringify(describe) },
  21. success: function (data) {
  22. if (data==0){
  23. layer.msg('添加成功!')
  24. location.reload();
  25. }else if(data == 2){
  26. layer.msg('该害虫描述已存在!')
  27. }
  28. else if(data == 1){
  29. layer.msg('添加描述失败!')
  30. }
  31. }
  32. })
  33. }else{
  34. layer.msg('害虫名称必须填写')
  35. }
  36. }
  37. //删除
  38. function del(obj) {
  39. layer.confirm('是否删除?', {
  40. btn: ['确定', '取消'] //可以无限个按钮
  41. , btn3: function (index, layero) {
  42. //按钮【按钮三】的回调
  43. }
  44. }, function (index, layero) {
  45. var array = [];
  46. var addr = obj.parent().find('img').attr('src');
  47. array.push(addr);
  48. var imei = obj.prev().val();
  49. layer.close(index)
  50. $.ajax({
  51. url: 'ybq_delete_img',
  52. type: 'post',
  53. data: {
  54. addr: addr,
  55. // addr: array,
  56. imei: imei
  57. },
  58. success: function (data) {
  59. if (data) {
  60. $.ajax({
  61. url: '/ybq/ybq_photo?imei=' + $('#imei').val() + '&page=' + $('.layui-laypage-curr em').eq(1).html(),
  62. type: 'get',
  63. success: function (data) {
  64. $('#imgList').html('');
  65. $('#imgList').html(data);
  66. if ($('.content').height() > 750) {
  67. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  68. } else {
  69. $('#iframe-main', parent.document).css('height', '750px')
  70. }
  71. }
  72. })
  73. } else {
  74. alert('删除失败')
  75. }
  76. }
  77. })
  78. }, function (index) {
  79. //按钮【按钮二】的回调
  80. });
  81. }
  82. // 批量删除
  83. function delimgAll(obj){
  84. if($('.imgcheckbox').css('display') == 'none'){
  85. $('.imgcheckbox').css('display','inline');
  86. $('.canceldelimgBtn').show();
  87. $(obj).html('删除')
  88. }else{
  89. if(topicid.length){
  90. // alert(2)
  91. var imei = $('.delBtn').prev().val();
  92. console.log($('.delBtn').prev().val())
  93. // $.ajax({
  94. // url: 'delete_img',
  95. // type: 'post',
  96. // data: {
  97. // addr: topicid,
  98. // imei: imei
  99. // },
  100. // success: function (data) {
  101. // if (data) {
  102. // location.reload()
  103. // } else {
  104. // alert('删除失败')
  105. // }
  106. // }
  107. // })
  108. }else{
  109. console.log(imei)
  110. layer.msg('请至少选择一张图片');
  111. }
  112. }
  113. }
  114. // 取消删除
  115. function canceldelimg(obj){
  116. topicid = [];
  117. $('.imgcheckbox').css('display','none');
  118. $('.imgcheckbox input').prop('checked',false);
  119. $(obj).hide();
  120. $(obj).prev().html('批量删除');
  121. }
  122. // 分页初始化
  123. layui.use('laypage', function () {
  124. var laypage = layui.laypage;
  125. laypage.render({
  126. elem: 'page' //注意,这里的 test1 是 ID,不用加 # 号
  127. , count: $('#totalPage').val()
  128. , limit: 8
  129. , layout: ['prev', 'page', 'next', 'skip']
  130. , jump: function (obj) {
  131. $.ajax({
  132. url: 'ybq_img_list?imei=' + $('#imei').val() + '&page=' + obj.curr,
  133. type: 'get',
  134. success: function (data) {
  135. $('#imgList').html('');
  136. $('#imgList').html(data);
  137. if ($('.content').height() > 750) {
  138. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  139. } else {
  140. $('#iframe-main', parent.document).css('height', '750px')
  141. }
  142. }
  143. })
  144. }
  145. });
  146. });
  147. window.onresize = function () {
  148. if ($('.content').height() > 750) {
  149. $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
  150. } else {
  151. $('#iframe-main', parent.document).css('height', '750px')
  152. }
  153. }