123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- $(function () {
- var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
- var type = $("#type").val();
- mask.close();//关闭遮罩
- $(".xgmsgbox").hide();
- $("#modal-4").hide();
- $(".haifm").css("background-color","#D7DFEA");
- var zsIscrollHeight = $(".fmjlIscroll");
- var cententHeight = $(".fmjlIscroll div:first-child");
- heightvs(zsIscrollHeight,cententHeight);
- //初始化page
- if(localStorage.hasOwnProperty("shIndex"+type)) {
- $("#page").val(localStorage.getItem("shIndex"+type));
- }
- //输入框快速删除初始化
- mui(".mui-input-row input").input();
- if (type != "") {
- $("#type > div").eq(type).addClass("green");
- }
- if (type != 0) {
- $(".checkAll").hide();
- $("input[type='checkbox']").hide();
- }
-
- $(".right").on("tap",function(){
- var id = $(this).data("id");
- var pc = $(this).data("pc");
- if (type != 0) {
- haifm.loadMobilePage("haifm", "clDealWhith.htm?mcid="
- + $("#mcid").val() + "&shxxID=" + id+"&from=sh" +"&type="+type);
- }else {
- haifm.loadMobilePage("haifm", "whhSubmit.htm?mcid="
- + $("#mcid").val() + "&pc=" + pc+"&type="+type);
- }
- });
- //时间初始化
- var date = new Date();
- var year = date.getFullYear()+"";
- var month = date.getMonth()+1;
- var day = date.getDate();
- date.setDate(date.getDate()-7);
- var lYear = date.getFullYear()+"";
- var lMonth = date.getMonth()+1;
- var lwDay = date.getDate();
- if ($("#startT").data("for") == "") {
- $("#startT .nian").html(lYear);
- $("#startT .yue").html(lMonth);
- $("#startT .ri").html(lwDay);
- } else {
- var ksrq = $("#startT").data("for");
- var ksrqArr = ksrq.split("-");
- $("#startT .nian").html(ksrqArr[0]);
- $("#startT .yue").html(ksrqArr[1]);
- $("#startT .ri").html(ksrqArr[2]);
- }
-
- if ($("#endT").data("for") == "") {
- $("#endT .nian").html(year);
- $("#endT .yue").html(month);
- $("#endT .ri").html(day);
- } else {
- var jsrq = $("#endT").data("for");
- var jsrqArr = jsrq.split("-");
- $("#endT .nian").html(jsrqArr[0]);
- $("#endT .yue").html(jsrqArr[1]);
- $("#endT .ri").html(jsrqArr[2]);
- }
- /**
- * 初始化滚动条
- * */
- var iscroll;
- iscroll = new IScroll(".fmjlIscroll",{
- scrollbars: true,
- fadeScrollbars:true,
- scrollbars: 'custom',
- shrinkScrollbars:'clip',
- probeType: 2,
- click:true
- });
- setTimeout(function(){
- iscroll.refresh();
- }, 600);
- /**
- * 点击input获取焦点
- * */
- $(".mui-input-row.mui-search,.mui-input-row .mui-input-clear~.mui-icon-clear:before").on("touchstart", function (e) {
- $("input[type='search']").focus();
- });
- /**
- * 滚动input以外失去焦点
- * */
- iscroll.on('scrollStart',function(e){
- var el = document.activeElement;
- if (el.nodeName.toLowerCase() == 'input') {
- el.blur();
- this.disable();
- this.enable();
- };
- return;
- });
- /**
- * 点击input以外失去焦点
- * */
- var beforeIpt=null;
- $("input").on("focus", function (e) {
- beforeIpt=this;
- });
- $(document).on("tap", function (e) {
- if(e.target.nodeName.toLowerCase()!="input") {
- if(beforeIpt) {
- beforeIpt.blur();
- beforeIpt=null;
- }
- }
- });
-
- mui('body').on('tap', '.mui-backdrop', function(e) {
- $(".xgmsgbox").hide();
- $("#modal-4").hide();
- });
-
- /**
- * 时间事件
- * */
- sjchaxun();
- //模糊查询键盘enter键事件
- $("input[type='search']").on('keypress',function(e) {
- var type = $("#type").val();
- var keycode = e.keyCode;
- if(keycode=='13') {
- e.preventDefault();
- //请求搜索接口
- clear();
- haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val()+"&type="+type + "&pch="+$("#pch").val());
- }
- });
- /* *
- * 下拉刷新上拉加载数据
- * */
- var pullUp = $("#pullUp"),
- pullUpLabel = $(".pullUpLabel"),
- loadingStep = 0;//加载状态0默认,1显示加载状态,2执行加载数据,只有当为0时才能再次加载,这是防止过快拉动刷新
- //滚动时触发
- iscroll.on("scroll",function(){
- if(loadingStep == 0 && !pullUp.attr("class").match('refresh')){
- if(this.y < (this.maxScrollY - 14)){//上拉加载更多
- pullUp.addClass("refresh").show();
- pullUp.css({"background":"","background-size":""});
- pullUpLabel.text("松手开始加载...");
- loadingStep = 1;
- iscroll.refresh();
- }
- }
- });
- //滚动结束触发
- iscroll.on("scrollEnd",function(){
- if(loadingStep == 1){
- if( pullUp.attr("class").match("refresh") ){//上拉加载操作
- pullUp.removeClass("refresh").addClass("loading");
- pullUpLabel.text("");
- pullUp.css({"background":"#D7DFEA url(views/haifmv/img/pullUp.gif) no-repeat center","background-size":"12%"});
- loadingStep = 2;
- pullUpAction();
- iscroll.refresh();
- }
- }
- //滑动定位
- var thisy = parseInt(this.y);
- localStorage.setItem("shIndexY"+type,thisy);
- });
-
- /**
- * 上拉加载方法
- * */
- function pullUpAction(){
- var kssj = $("#startT .nian").html()+"-" + $("#startT .yue").html()+"-" + $("#startT .ri").html();
- var jssj = $("#endT .nian").html()+"-" + $("#endT .yue").html()+"-" + $("#endT .ri").html();
- var page = parseInt($("#page").val())+1;
- var maxPages = $("#maxPages").val();
- if (page <= maxPages) {
- jQuery.ajax({
- type : "get",
- url : "AddWhhShsj.htm",
- data : {
- "mcid" : $("#mcid").val(),
- "pch": $("#pch").val(),
- "ksrq" : kssj,
- "jsrq" : jssj,
- "page" : page,
- "type" : $("#type").val()
- },
- dataType : "json",
- async : true,
- success : function(data) {
- var hc = localStorage.getItem("shIndex"+type);
- setTimeout(function() {
- var something = "";
- for (var i = 0 ; i < data.length; i++) {
- var obj = data[i];
- var str = "";
- var kuang = "";
- if (obj.sl > 1) {
- str = "等";
- }
- if (type == "0") {
- kuang += "<input type='checkbox' name='sProblem' value="+obj.pc+">";
- }
- something += "<div class='rowBox container-fluid whhShitem' data-id="+obj.id+" data-pc = "+obj.pc+">"
- +"<div class='left'>"+kuang
- +"</div>" +
- "<div class='right' onclick=\"toView('"+obj.id+"','"+obj.pc+"');\" data-id="+obj.id+" data-pc = "+obj.pc+">"
- +"<div class='row'>"
- +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>管理号:<span>"+obj.glh+str +"</span></div>"
- +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>批次编码:<span>"+obj.pc+"</span></div>"
- +"</div><div class='row'>"
- +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>处理方式:<span>"+obj.clfsStr+"</span></div>"
- +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>处理时间:<span>"+obj.clsjStr+"</span></div>"
- +"</div><div class='row'>"
- +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>数量:<span>"+obj.sl+"</span></div>"
- +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>处理人员:<span>"+obj.clry+"</span></div>"
- +"</div></div></div>";
- }
- $(".fmjlIscroll ul.mui-table-view").append($(something));
- pullUp.attr("class","");
- pullUpLabel.text("上拉加载更多");
- pullUp.css({"background":""});
- iscroll.refresh();
- loadingStep = 0;
- localStorage.setItem("shIndex"+type,hc + something);
- },1000);
- $("#page").val(page);
- localStorage.setItem("shIndexPage"+type,page);
- }
- });
- }else {
- pullUp.css({"background":"","background-size":""});
- pullUpLabel.text("没有数据了");
- iscroll.refresh();
- }
- }
- //加载缓存中的内容
- var type = $("#type").val();
- if (localStorage.hasOwnProperty("shIndex"+type)) {
- var sth = localStorage.getItem("shIndex"+type);
- $(".fmjlIscroll ul").append(sth.substring(4,sth.length));
- }
- if (localStorage.hasOwnProperty("shIndexY"+type)) {
- var tall = localStorage.getItem("shIndexY"+type);
- iscroll.scrollTo(0,tall,1000, IScroll.utils.ease.elastic);
- iscroll.refresh();
- }
-
- //切换内容
- $("#type>div").on("tap",function(){
- var type = $(this).data("for");
- var ksrq = $("#startT .nian").html() + "-" + $("#startT .yue").html() + "-" + $("#startT .ri").html();
- var jsrq = $("#endT .nian").html() + "-" + $("#endT .yue").html() + "-" + $("#endT .ri").html();
- haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val() + "&kssj=" + ksrq + "&jssj="
- + jsrq +"&type="+type);
- $("#type").each("div",function(){
- this.removeClass("green");
- });
- $("#type").find("div").eq(type).addClass("green");
- });
-
- //通过 驳回
- $(".sjokbox span").on("tap",function(){
- var data = $(this).data("for");
- var bz = $("#textarea").val();
- var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
- jQuery.ajax({
- dataType : 'json',
- type : "post",
- url : "ShdealWhith.htm",
- data : {
- "mcid" : $("#mcid").val(),
- "glid" : $("#glid").val(),
- "shbz" : data,
- "bz" : bz,
- "type" : $("#type").val()
- },
- dataType : "json",
- async : true,
- success : function(msg) {
- // 保存成功
- if (msg.count == 1) {
-
- $(".xgmsgbox").hide();
- $("#modal-4").hide();
- haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val()+"&type=0");
- clear();
- mask.close();//关闭遮罩
- $(".mui-backdrop").hide();
- mui.toast('保存成功');
- }else if (msg.count == 2) {
- mui.alert('数据接收错误 请联系开发人员-1', '提示', function() {});
- $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- }else if (msg.count == 3) {
- mui.alert('数据接收错误 请联系开发人员-0', '提示', function() {});
- $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- }else if (msg.count == 4) {
- mui.alert('数据接收错误 请联系开发人员-2', '提示', function() {});
- $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- }
-
- },
- error : function(msg) {
- mui.alert('网络繁忙,请稍后再试...', '提示', function() {});
- $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
- mask.close();//关闭遮罩
- $("#modal-4").hide();
- $(".xgmsgbox").hide();
- $(".mui-backdrop").hide();
- haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val()+"&type=0");
- },
- complete: function(msg) {
- //ajax请求完成时执行
- if (msg.count == 1) {
- $('.save').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
- }
- }
- });
- });
- });
- /**
- * 时间方法
- * */
- function sjchaxun(){
- mui.init();
- mui.ready(function() {
- //开始时间
- var startN = $('.nian')[0];
- var startnY = $('.yue')[0];
- var startR = $('.ri')[0];
- var startTbtns = $('#startT');
- startTbtns.each(function(i, startTbtn) {
- startTbtn.addEventListener('tap', function() {
- var dataFor = this.getAttribute('data-for');
- var that = this;
- dateP(startN,startnY,startR,dataFor,that);
- }, { passive: false });
- });
-
- //结束时间
- var endN = $('.nian')[1];
- var endY = $('.yue')[1];
- var endR = $('.ri')[1];
- var endTbtns = $('#endT');
- endTbtns.each(function(i, endTbtn) {
- endTbtn.addEventListener('tap', function() {
- var dataFor = this.getAttribute('data-for');
- var that = this;
- dateP(endN,endY,endR,dataFor,that);
- }, { passive: false });
- });
- });
- function dateP(nian,yue,ri,dataFor,that) {
- var picker = new mui.DtPicker({
- type: "date",//设置日历初始视图模式
- value: dataFor
- });
- picker.show(function(rs) {
- nian.innerHTML = rs.y.text;
- yue.innerHTML = rs.m.text;
- ri.innerHTML = rs.d.text;
- that.setAttribute('data-for',rs.value);
- picker.dispose();
- });
- }
- }
- /**
- *时间搜索
- */
- function timeSearch() {
- var ksrq = $("#startT .nian").html() + "-" + $("#startT .yue").html() + "-" + $("#startT .ri").html();
- var jsrq = $("#endT .nian").html() + "-" + $("#endT .yue").html() + "-" + $("#endT .ri").html();
- haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val() + "&kssj=" + ksrq + "&jssj="
- + jsrq +"&type="+$("#type").val()+"&pch="+$("#pch").val());
- clear();
- }
- //滑动高度和内容高度对比
- function heightvs(zsIscrollHeight,cententHeight){
- if(zsIscrollHeight.height() > cententHeight.height()){
- $("#pullUp").hide();
- }else{
- $("#pullUp").show();
- }
- }
- function clear() {
- var type = $("#type").val();
- if (localStorage.hasOwnProperty("shIndex"+type)) {
- localStorage.removeItem("shIndex"+type);
- }
- if (localStorage.hasOwnProperty("shIndexY"+type)) {
- localStorage.removeItem("shIndexY"+type);
- }
- if (localStorage.hasOwnProperty("shIndexPage"+type)) {
- localStorage.removeItem("shIndexPage"+type);
- }
- }
- function submit(){
- var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
- var glid = "";
- var type = $("#type").val();
- $("input[type='checkbox']").each(function() {
- if ( this.checked == true){
- var str = $(this).val();
- glid+= str+",";
- }
- });
- glid = glid.substring(0, glid.length-1);
- if (glid == "") {
- mui.alert("请勿空选");
- return;
- }else{
- mask.show();//显示遮罩
- $("#modal-4").show();
- $("#glid").val(glid);
- }
-
- }
- //全选与取消全选
- function Check() {
- if (checked == false) {
- $("input[type='checkbox']").each(function() {
- this.checked = true;
- });
- $("#allCheck").html("取消全选");
- checked = true;
- }else {
- $("input[type='checkbox']").each(function() {
- this.checked = false;
- });
- $("#allCheck").html("全选");
- checked = false;
- }
-
- }
- function toView(id,pc){
- var type = $("#type").val();
- if (type != 0) {
- haifm.loadMobilePage("haifm", "clDealWhith.htm?mcid="
- + $("#mcid").val() + "&shxxID=" + id+"&from=sh" +"&type="+type);
- }else {
- haifm.loadMobilePage("haifm", "whhSubmit.htm?mcid="
- + $("#mcid").val() + "&pc=" + pc+"&type="+type);
- }
-
- }
|