hpSjlrFzxsEdit.js 4.6 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. //点击input键盘弹出滚动区域translateY往上滚动;
  25. $(document).ready(function () {
  26. var clickQian = document.body.clientHeight;
  27. var switcha = true;
  28. var a = null;
  29. $("input[type='number']").on("tap",function(){
  30. a = $(".content")[0].style.transform.split(',')[1].split(' ')[1].match(/\d+(\.\d+)?/)[0];
  31. if($("input[type='number']") && switcha){
  32. setTimeout(function(){
  33. var clickHou = document.body.clientHeight;
  34. var zimujpHeight = clickQian - clickHou - a - 270 + "px";
  35. $(".content")[0].style.transform = "translateY(-"+zimujpHeight+")";
  36. myScroll.refresh();
  37. switcha = false;
  38. },250);
  39. }
  40. });
  41. });
  42. //点击input键盘弹出滚动区域translateY往上滚动;
  43. $(document).ready(function () {
  44. var clickQian = document.body.clientHeight;
  45. var switcha = true;
  46. var a = null;
  47. $("input[type='number']").on("tap",function(){
  48. a = $(".content")[0].style.transform.split(',')[1].split(' ')[1].match(/\d+(\.\d+)?/)[0];
  49. if($("input[type='number']") && switcha){
  50. setTimeout(function(){
  51. var clickHou = document.body.clientHeight;
  52. var zimujpHeight = clickQian - clickHou - a - 270 + "px";
  53. $(".content")[0].style.transform = "translateY(-"+zimujpHeight+")";
  54. myScroll.refresh();
  55. switcha = false;
  56. },250);
  57. }
  58. });
  59. });
  60. //元素失去焦点隐藏软键盘
  61. $("#fzxsForm").on("tap",function(e){
  62. if(e.target.nodeName != "INPUT"){
  63. $('input').blur();
  64. };
  65. });
  66. });
  67. /**
  68. * 保存
  69. * @param type
  70. */
  71. function saveFzxs(type) {
  72. jQuery('#fzxsForm').ajaxSubmit({
  73. dataType : 'json',
  74. data : {"mcid" : $("#mcid").val()},
  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", "hpSjlrFzxsIndex.htm?mcid=" + $("#mcid").val());
  90. } else {
  91. haifmp.loadMobilePage("haifmp", "hpSjlrFzxsEdit.htm?mcid=" + $("#mcid").val());
  92. }
  93. }else{
  94. if (type == "1") {
  95. alert(msg.msg);
  96. $('.sub').text('保存');
  97. $('.sub').attr('onclick','saveFzxs(1)');//改变提交按钮上的文字并将按钮设置为可点击
  98. } else {
  99. alert(msg.msg);
  100. $('.subAdd').text('保存并新增');
  101. $('.subAdd').attr('onclick','saveFzxs(2)');//改变提交按钮上的文字并将按钮设置为可点击
  102. }
  103. }
  104. },
  105. error : function(data) {
  106. if(type=="1") {
  107. alert('网络繁忙,请稍后再试...');
  108. $('.sub').text('保存');
  109. $('.sub').attr('onclick','saveFzxs(1)');//改变提交按钮上的文字并将按钮设置为可点击
  110. }else {
  111. alert('网络繁忙,请稍后再试...');
  112. $('.subAdd').text('保存并新增');
  113. $('.subAdd').attr('onclick','saveFzxs(2)');//改变提交按钮上的文字并将按钮设置为可点击
  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. function backUrl() {
  136. haifmp.loadMobilePage("haifmp", "hpSjlrFzxsIndex.htm?mcid=" + $("#mcid").val());
  137. }