hpSjlrZzxsEdit.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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", "getZzxsSearchDweb.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='number']").on("tap",function(){
  40. a = $(".content")[0].style.transform.split(',')[1].split(' ')[1].match(/\d+(\.\d+)?/)[0];
  41. if($("input[type='number']") && switcha){
  42. setTimeout(function(){
  43. var clickHou = document.body.clientHeight;
  44. var zimujpHeight = clickQian - clickHou - a - 280 + "px";
  45. $(".content")[0].style.transform = "translateY(-"+zimujpHeight+")";
  46. myScroll.refresh();
  47. switcha = false;
  48. },250);
  49. }
  50. });
  51. });
  52. //元素失去焦点隐藏软键盘
  53. $("#zzxsForm").on("tap",function(e){
  54. if(e.target.nodeName != "INPUT"){
  55. $('input').blur();
  56. };
  57. });
  58. });
  59. /**
  60. * 保存
  61. * @param type
  62. */
  63. function saveZzxs(type) {
  64. var dweb = $("#dweb").val();
  65. var eph = $("#eph").val();
  66. var je = $("#xsje").val();
  67. if (eph == "") {
  68. alert("请输入正确的耳牌号!");
  69. return false;
  70. }else if(je == ""){
  71. alert("请输入销售金额!");
  72. return false;
  73. } else {
  74. jQuery('#zzxsForm').ajaxSubmit({
  75. dataType : 'json',
  76. data : {"mcid" : $("#mcid").val(),
  77. "date" : $("#date").val(),
  78. "dweb" : dweb
  79. },
  80. beforeSend:function() { //触发ajax请求开始时执行
  81. if(type==1){
  82. $(".sub").text("提交中……");
  83. $('.sub').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  84. }else{
  85. $(".subAdd").text("提交中……");
  86. $('.subAdd').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  87. }
  88. },
  89. success : function(msg, data) {
  90. // 保存成功
  91. if (msg.result=1) {
  92. alert("保存成功!");
  93. if (type == "1") {
  94. haifmp.loadMobilePage("haifmp", "hpSjlrZzxsIndex.htm?mcid=" + $("#mcid").val());
  95. } else {
  96. haifmp.loadMobilePage("haifmp", "hpSjlrZzxsEdit.htm?mcid=" + $("#mcid").val());
  97. }
  98. }else{
  99. if (type == "1") {
  100. alert(msg.msg);
  101. $('.sub').text('提交表单');
  102. $('.sub').attr('onclick','submitorder()');//改变提交按钮上的文字并将按钮设置为可点击
  103. } else {
  104. alert(msg.msg);
  105. $('.subAdd').text('提交表单');
  106. $('.subAdd').attr('onclick','submitorder()');//改变提交按钮上的文字并将按钮设置为可点击
  107. }
  108. }
  109. },
  110. error : function(data) {
  111. if(type=="1") {
  112. alert('网络繁忙,请稍后再试...');
  113. $('.sub').text('提交表单');
  114. $('.sub').attr('onclick','submitorder()');//改变提交按钮上的文字并将按钮设置为可点击
  115. }else {
  116. alert('网络繁忙,请稍后再试...');
  117. $('.subAdd').text('提交表单');
  118. $('.subAdd').attr('onclick','submitorder()');//改变提交按钮上的文字并将按钮设置为可点击
  119. }
  120. },
  121. complete: function(msg, data)
  122. {
  123. //ajax请求完成时执行
  124. if(msg.result==1)
  125. {
  126. if(type==1){
  127. $(".sub").text("提交中……");
  128. $('.sub').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  129. }else{
  130. $(".subAdd").text("提交中……");
  131. $('.subAdd').attr('onclick','javascript:void(0)');//改变提交按钮上的文字并将按钮设置为不可点击
  132. }
  133. }
  134. }
  135. });
  136. }
  137. }
  138. /**
  139. * 返回
  140. */
  141. function backUrl() {
  142. haifmp.loadMobilePage("haifmp", "hpSjlrZzxsIndex.htm?mcid=" + $("#mcid").val());
  143. }