123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- $(function(){
- /* 滚轮 */
- var myScroll = new IScroll(".iscroll",{
- scrollbars: true,
- fadeScrollbars:true,
- scrollbars: 'custom',
- shrinkScrollbars:'clip',
- });
- setTimeout(function () {
- $("body").height(document.body.scrollHeight);
- myScroll.refresh();
- }, 250);
- /**
- * 滚动input以外失去焦点
- * */
- myScroll.on('scrollStart',function(e){
- var el = document.activeElement;
- if (el.nodeName.toLowerCase() == 'input') {
- el.blur();
- this.disable();
- this.enable();
- };
- return;
- });
-
- var theme="android-ics";
- $("#date").mobiscroll().date({
- lang: "zh",//显示中文
- theme: theme,//主题
- setText: '确定',//确认按钮名称
- cancelText: '取消',//取消按钮名称
- dateFormat: 'yy-mm-dd',// 日期格式
- dateOrder: 'yymmdd',//面板中日期排列格式
- display: 'bottom',//显示方式
- endYear:2050,//结束年份
- });
- if ($("#date").val() == "") {
- $("#date").val(new Date().getFullYear()+"-"+p(new Date().getMonth()+1)+"-"+p(new Date().getDate()));
- }
- if ($("#id").val() != "") {
- if ($("#dweb").val() != "") {
- $("#dweb" ).prop("disabled" , true);
- }
- }
- if ($("#id").val() != "" && $("#id").val() != "0"){
- $("#date" ).prop("disabled" , true);
- }
- $("#eph").bind("click", function() {
- haifmp.loadMobilePage("haifm", "getRsjlSearchDweb.htm?mcid=" + $("#mcid").val()+"&date=" + $("#date").val());
- });
-
- //点击input键盘弹出滚动区域translateY往上滚动;
- $(document).ready(function () {
- var clickQian = document.body.clientHeight;
- var switcha = true;
- var a = null;
- $("input[type='text']").on("tap",function(){
- a = $(".content")[0].style.transform.split(',')[1].split(' ')[1].match(/\d+(\.\d+)?/)[0];
- if($("input[type='text']") && switcha){
- setTimeout(function(){
- var clickHou = document.body.clientHeight;
- var zimujpHeight = clickQian - clickHou - a - 135 + "px";
- $(".content")[0].style.transform = "translateY(-"+zimujpHeight+")";
- myScroll.refresh();
- switcha = false;
- },250);
- }
- });
- });
- //元素失去焦点隐藏软键盘
- $("#rsjlForm").on("tap",function(e){
- if(e.target.nodeName != "INPUT"){
- $('input').blur();
- };
- });
- });
- /**
- * 保存
- * @param type
- */
- function saveRsjl(type) {
- //选择的日期不能大于当前日期
- var tof = EventUtil.dateLimit($("#date").val());
- if (!tof) {
- alert("大于当前日期");
- return false;
- }
-
- var dweb = $("#dweb").val();
- if (dweb == "") {
- alert("请输入正确的耳标号!");
- return false;
- } else {
- jQuery('#rsjlForm').ajaxSubmit({
- dataType : 'json',
- data : {"mcid" : $("#mcid").val(),
- "dweb" : dweb,
- "id" :$("#id").val()
- },
- beforeSend:function() {//触发ajax请求开始时执行
- if (type == 1){
- $(".sub").text("提交中……");
- $('.sub').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
- } else {
- $(".subAdd").text("提交中……");
- $('.subAdd').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
- }
- },
- success : function(msg) {
- // 保存成功
- if (msg.count == 1) {
- alert("保存成功!");
- if (type == "1") {
- haifmp.loadMobilePage("haifm", "hpSjlrRsIndex.htm?mcid=" + $("#mcid").val());
- } else {
- haifmp.loadMobilePage("haifm", "hpSjlrRsAdd.htm?mcid=" + $("#mcid").val());
- }
- }else if (msg.count == 2) {
- alert("已有该妊娠记录,请勿重复保存");
- if (type == "1") {
- $('.sub').text('保存');
- $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- } else {
- $('.subAdd').text('保存并新增');
- $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- }
- }else if (msg.count ==3) {
- alert("妊娠时间小于配种时间");
- if (type == "1") {
- $('.sub').text('保存');
- $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- } else {
- $('.subAdd').text('保存并新增');
- $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- }
- }
- },
- error : function(msg) {
- if (type == "1") {
- alert('网络繁忙,请稍后再试...');
- $('.sub').text('保存');
- $('.sub').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- } else {
- alert('网络繁忙,请稍后再试...');
- $('.subAdd').text('保存并新增');
- $('.subAdd').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- }
- },
- complete: function(msg) {
- //ajax请求完成时执行
- if (msg.count == 1) {
- if (type == 1){
- $(".sub").text("提交中……");
- $('.sub').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
- } else {
- $(".subAdd").text("提交中……");
- $('.subAdd').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
- }
- }
- }
- });
- }
- }
- /**
- * 返回
- */
- function backUrl() {
- haifmp.loadMobilePage("haifm", "hpSjlrRsIndex.htm?mcid=" + $("#mcid").val());
- }
|