hpSjlrZzswEdit.js 4.5 KB

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