hpSjlrCjjlAdd.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. $("#dweb").bind("click", function() {
  37. var id = $("#id").val();
  38. if (id == "") {
  39. haifmp.loadMobilePage("haifm", "getCjjlSearchDweb.htm?mcid=" + $("#mcid").val() +"&date=" + $("#date").val());
  40. }
  41. });
  42. if ($("#id").val() != "" && $("#id").val() != "0"){
  43. $("#date" ).prop("disabled" , true);
  44. }
  45. //点击input键盘弹出滚动区域translateY往上滚动;
  46. $(document).ready(function () {
  47. var clickQian = document.body.clientHeight;
  48. var switcha = true;
  49. var a = null;
  50. $("input[type='number']").on("tap",function(){
  51. a = $(".content")[0].style.transform.split(',')[1].split(' ')[1].match(/\d+(\.\d+)?/)[0];
  52. if($("input[type='number']") && switcha){
  53. setTimeout(function(){
  54. var clickHou = document.body.clientHeight;
  55. var zimujpHeight = clickQian - clickHou - a - 270 + "px";
  56. $(".content")[0].style.transform = "translateY(-"+zimujpHeight+")";
  57. myScroll.refresh();
  58. switcha = false;
  59. },250);
  60. }
  61. });
  62. });
  63. //元素失去焦点隐藏软键盘
  64. $("#cjjlForm").on("tap",function(e){
  65. if(e.target.nodeName != "INPUT"){
  66. $('input').blur();
  67. };
  68. });
  69. });
  70. /**
  71. * 保存
  72. * @param type
  73. */
  74. function saveCjjl(type) {
  75. //选择的日期不能大于当前日期
  76. var tof = EventUtil.dateLimit($("#date").val());
  77. if (!tof) {
  78. alert("大于当前日期");
  79. return false;
  80. }
  81. var dweb = $("#cjdweb").val();
  82. var eph = $("#dweb").val();
  83. var date = $("#date").val();
  84. if (eph == "") {
  85. alert("请输入正确的耳牌号!");
  86. return false;
  87. } else {
  88. jQuery('#cjjlForm').ajaxSubmit({
  89. dataType : 'json',
  90. data : {"mcid" : $("#mcid").val(),
  91. "id" :$("#id").val(),
  92. "dweb" :dweb,
  93. "date" :date
  94. },
  95. beforeSend:function() {//触发ajax请求开始时执行
  96. if (type == 1){
  97. $(".sub").text("提交中……");
  98. $('.sub').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  99. } else {
  100. $(".subAdd").text("提交中……");
  101. $('.subAdd').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  102. }
  103. },
  104. success : function(msg) {
  105. // 保存成功
  106. if (msg.count == 1) {
  107. alert("保存成功!");
  108. if (type == "1") {
  109. haifmp.loadMobilePage("haifm", "hpSjlrCjIndex.htm?mcid=" + $("#mcid").val());
  110. } else {
  111. haifmp.loadMobilePage("haifm", "hpSjlrCjAdd.htm?mcid=" + $("#mcid").val());
  112. }
  113. } else if (msg.count == 2) {
  114. alert("采精时间不能大于入栏时间");
  115. if (type == "1") {
  116. $('.sub').text('保存');
  117. $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  118. } else {
  119. $('.subAdd').text('保存并新增');
  120. $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  121. }
  122. }
  123. },
  124. error : function(msg) {
  125. if (type == "1") {
  126. alert('网络繁忙,请稍后再试...');
  127. $('.sub').text('保存');
  128. $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  129. } else {
  130. alert('网络繁忙,请稍后再试...');
  131. $('.subAdd').text('保存并新增');
  132. $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  133. }
  134. },
  135. complete: function(msg) {
  136. //ajax请求完成时执行
  137. if (msg.count == 1) {
  138. if (type == 1){
  139. $(".sub").text("提交中……");
  140. $('.sub').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  141. } else {
  142. $(".subAdd").text("提交中……");
  143. $('.subAdd').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  144. }
  145. }
  146. }
  147. });
  148. }
  149. }
  150. /**
  151. * 返回
  152. */
  153. function backUrl() {
  154. haifmp.loadMobilePage("haifm", "hpSjlrCjIndex.htm?mcid=" + $("#mcid").val());
  155. }