hpSjlrPtmyEdit.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. //元素失去焦点隐藏软键盘
  43. $("#ptmyForm").on("tap",function(e){
  44. if(e.target.nodeName != "INPUT"){
  45. $('input').blur();
  46. };
  47. });
  48. });
  49. /**
  50. * 保存
  51. * @param type
  52. */
  53. function savePtmy(type) {
  54. var dweb = $("#dweb").val();
  55. var myts = $("#myts").val();
  56. var sjyl = $("#sjyl").val();
  57. if (dweb == "") {
  58. alert("请输入正确的耳标号!");
  59. return false;
  60. }else if (myts == "") {
  61. alert("请输入免疫头数");
  62. return false;
  63. }else if (sjyl == "") {
  64. alert("请输入实际用量");
  65. return false;
  66. }else {
  67. jQuery('#ptmyForm').ajaxSubmit({
  68. dataType : 'json',
  69. data : {"mcid" : $("#mcid").val()},
  70. beforeSend:function() {//触发ajax请求开始时执行
  71. if (type == 1){
  72. $(".sub").text("提交中……");
  73. $('.sub').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  74. } else {
  75. $(".subAdd").text("提交中……");
  76. $('.subAdd').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  77. }
  78. },
  79. success : function(msg) {
  80. // 保存成功
  81. if (msg.count == 1) {
  82. alert("保存成功!");
  83. if (type == "1") {
  84. haifmp.loadMobilePage("haifmp", "hpSjlrPtmyIndex.htm?mcid=" + $("#mcid").val());
  85. } else {
  86. haifmp.loadMobilePage("haifmp", "hpSjlrPtmyEdit.htm?mcid=" + $("#mcid").val());
  87. }
  88. }
  89. },
  90. error : function(msg) {
  91. if (type == "1") {
  92. alert('网络繁忙,请稍后再试...');
  93. $('.sub').text('保存');
  94. $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  95. } else {
  96. alert('网络繁忙,请稍后再试...');
  97. $('.subAdd').text('保存并新增');
  98. $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  99. }
  100. },
  101. complete: function(msg) {
  102. //ajax请求完成时执行
  103. if (msg.count == 1) {
  104. if (type == 1){
  105. $(".sub").text("提交中……");
  106. $('.sub').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  107. } else {
  108. $(".subAdd").text("提交中……");
  109. $('.subAdd').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  110. }
  111. }
  112. }
  113. });
  114. }
  115. }
  116. /**
  117. * 返回
  118. */
  119. function backUrl() {
  120. haifmp.loadMobilePage("haifmp", "hpSjlrPtmyIndex.htm?mcid=" + $("#mcid").val());
  121. }