hpSjlrZzttEdit.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. $(function(){
  2. /* 滚轮 */
  3. var myScroll = new IScroll(".iscroll",{
  4. scrollbars: true,
  5. fadeScrollbars:true,
  6. scrollbars: 'custom',
  7. shrinkScrollbars:'clip',
  8. });
  9. setTimeout(function () {
  10. $("body").height(document.body.scrollHeight);
  11. myScroll.refresh();
  12. }, 250);
  13. /**
  14. * 滚动input以外失去焦点
  15. * */
  16. myScroll.on('scrollStart',function(e){
  17. var el = document.activeElement;
  18. if (el.nodeName.toLowerCase() == 'input') {
  19. el.blur();
  20. this.disable();
  21. this.enable();
  22. };
  23. return;
  24. });
  25. var theme="android-ics";
  26. $("#date").mobiscroll().date({
  27. lang: "zh",//显示中文
  28. theme: theme,//主题
  29. setText: '确定',//确认按钮名称
  30. cancelText: '取消',//取消按钮名称
  31. dateFormat: 'yy-mm-dd',// 日期格式
  32. dateOrder: 'yymmdd',//面板中日期排列格式
  33. display: 'bottom',//显示方式
  34. endYear:2050,//结束年份
  35. });
  36. $("#eph").bind("click", function() {
  37. var id = $("#id").val();
  38. if (id == "") {
  39. haifmp.loadMobilePage("haifm", "getZzttSearchDweb.htm?mcid=" + $("#mcid").val() +"&date=" + $("#date").val());
  40. }
  41. });
  42. //日期不能修改
  43. if ($("#id").val() != "" && $("#id").val() != "0"){
  44. $("#date" ).prop("disabled" , true);
  45. }
  46. //点击input键盘弹出滚动区域translateY往上滚动;
  47. $(document).ready(function () {
  48. var clickQian = document.body.clientHeight;
  49. var switcha = true;
  50. var a = null;
  51. $("input[type='text']").on("tap",function(){
  52. a = $(".content")[0].style.transform.split(',')[1].split(' ')[1].match(/\d+(\.\d+)?/)[0];
  53. if($("input[type='text']") && switcha){
  54. setTimeout(function(){
  55. var clickHou = document.body.clientHeight;
  56. var zimujpHeight = clickQian - clickHou - a - 270 + "px";
  57. $(".content")[0].style.transform = "translateY(-"+zimujpHeight+")";
  58. myScroll.refresh();
  59. switcha = false;
  60. },250);
  61. }
  62. });
  63. });
  64. //元素失去焦点隐藏软键盘
  65. $("#zzttForm").on("tap",function(e){
  66. if(e.target.nodeName != "INPUT"){
  67. $('input').blur();
  68. };
  69. });
  70. });
  71. /**
  72. * 保存
  73. * @param type
  74. */
  75. function saveZztt(type) {
  76. //选择的日期不能大于当前日期
  77. var tof = EventUtil.dateLimit($("#date").val());
  78. if (!tof) {
  79. alert("大于当前日期");
  80. return false;
  81. }
  82. var dweb = $("#dweb").val();
  83. var eph = $("#eph").val();
  84. if (eph == "") {
  85. alert("请输入正确的耳牌号!");
  86. return false;
  87. } else {
  88. jQuery('#zzttForm').ajaxSubmit({
  89. dataType : 'json',
  90. data : {"mcid" : $("#mcid").val(),
  91. "dweb" : dweb,
  92. "eph" : eph
  93. },
  94. beforeSend:function() {//触发ajax请求开始时执行
  95. if(type==1){
  96. $(".sub").text("提交中……");
  97. $('.sub').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  98. }else{
  99. $(".subAdd").text("提交中……");
  100. $('.subAdd').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  101. }
  102. },
  103. success : function(msg, data) {
  104. // 保存成功
  105. if (msg.result=1) {
  106. alert("保存成功!");
  107. if (type == "1") {
  108. haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val());
  109. } else {
  110. haifmp.loadMobilePage("haifm", "hpSjlrZzttEdit.htm?mcid=" + $("#mcid").val());
  111. }
  112. }else if (msg.count ==2) {
  113. alert("淘汰时间小于种猪入栏日期");
  114. if (type == "1") {
  115. $('.sub').text('保存');
  116. $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  117. } else {
  118. $('.subAdd').text('保存并新增');
  119. $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  120. }
  121. }
  122. },
  123. error : function(data) {
  124. if(type=="1") {
  125. alert('网络繁忙,请稍后再试...');
  126. $('.sub').text('保存');
  127. $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  128. }else {
  129. alert('网络繁忙,请稍后再试...');
  130. $('.subAdd').text('保存并新增');
  131. $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  132. }
  133. },
  134. complete: function(msg, data)
  135. {
  136. //ajax请求完成时执行
  137. if(msg.result==1)
  138. {
  139. if(type==1){
  140. $(".sub").text("提交中……");
  141. $('.sub').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  142. }else{
  143. $(".subAdd").text("提交中……");
  144. $('.subAdd').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  145. }
  146. }
  147. }
  148. });
  149. }
  150. }
  151. /**
  152. * 返回
  153. */
  154. function backUrl() {
  155. haifmp.loadMobilePage("haifm", "hpSjlrZzttIndex.htm?mcid=" + $("#mcid").val());
  156. }