whhSh.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. $(function () {
  2. var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
  3. var type = $("#type").val();
  4. mask.close();//关闭遮罩
  5. $(".xgmsgbox").hide();
  6. $("#modal-4").hide();
  7. $(".haifm").css("background-color","#D7DFEA");
  8. var zsIscrollHeight = $(".fmjlIscroll");
  9. var cententHeight = $(".fmjlIscroll div:first-child");
  10. heightvs(zsIscrollHeight,cententHeight);
  11. //初始化page
  12. if(localStorage.hasOwnProperty("shIndex"+type)) {
  13. $("#page").val(localStorage.getItem("shIndex"+type));
  14. }
  15. //输入框快速删除初始化
  16. mui(".mui-input-row input").input();
  17. if (type != "") {
  18. $("#type > div").eq(type).addClass("green");
  19. }
  20. if (type != 0) {
  21. $(".checkAll").hide();
  22. $("input[type='checkbox']").hide();
  23. }
  24. $(".right").on("tap",function(){
  25. var id = $(this).data("id");
  26. var pc = $(this).data("pc");
  27. if (type != 0) {
  28. haifm.loadMobilePage("haifm", "clDealWhith.htm?mcid="
  29. + $("#mcid").val() + "&shxxID=" + id+"&from=sh" +"&type="+type);
  30. }else {
  31. haifm.loadMobilePage("haifm", "whhSubmit.htm?mcid="
  32. + $("#mcid").val() + "&pc=" + pc+"&type="+type);
  33. }
  34. });
  35. //时间初始化
  36. var date = new Date();
  37. var year = date.getFullYear()+"";
  38. var month = date.getMonth()+1;
  39. var day = date.getDate();
  40. date.setDate(date.getDate()-7);
  41. var lYear = date.getFullYear()+"";
  42. var lMonth = date.getMonth()+1;
  43. var lwDay = date.getDate();
  44. if ($("#startT").data("for") == "") {
  45. $("#startT .nian").html(lYear);
  46. $("#startT .yue").html(lMonth);
  47. $("#startT .ri").html(lwDay);
  48. } else {
  49. var ksrq = $("#startT").data("for");
  50. var ksrqArr = ksrq.split("-");
  51. $("#startT .nian").html(ksrqArr[0]);
  52. $("#startT .yue").html(ksrqArr[1]);
  53. $("#startT .ri").html(ksrqArr[2]);
  54. }
  55. if ($("#endT").data("for") == "") {
  56. $("#endT .nian").html(year);
  57. $("#endT .yue").html(month);
  58. $("#endT .ri").html(day);
  59. } else {
  60. var jsrq = $("#endT").data("for");
  61. var jsrqArr = jsrq.split("-");
  62. $("#endT .nian").html(jsrqArr[0]);
  63. $("#endT .yue").html(jsrqArr[1]);
  64. $("#endT .ri").html(jsrqArr[2]);
  65. }
  66. /**
  67. * 初始化滚动条
  68. * */
  69. var iscroll;
  70. iscroll = new IScroll(".fmjlIscroll",{
  71. scrollbars: true,
  72. fadeScrollbars:true,
  73. scrollbars: 'custom',
  74. shrinkScrollbars:'clip',
  75. probeType: 2,
  76. click:true
  77. });
  78. setTimeout(function(){
  79. iscroll.refresh();
  80. }, 600);
  81. /**
  82. * 点击input获取焦点
  83. * */
  84. $(".mui-input-row.mui-search,.mui-input-row .mui-input-clear~.mui-icon-clear:before").on("touchstart", function (e) {
  85. $("input[type='search']").focus();
  86. });
  87. /**
  88. * 滚动input以外失去焦点
  89. * */
  90. iscroll.on('scrollStart',function(e){
  91. var el = document.activeElement;
  92. if (el.nodeName.toLowerCase() == 'input') {
  93. el.blur();
  94. this.disable();
  95. this.enable();
  96. };
  97. return;
  98. });
  99. /**
  100. * 点击input以外失去焦点
  101. * */
  102. var beforeIpt=null;
  103. $("input").on("focus", function (e) {
  104. beforeIpt=this;
  105. });
  106. $(document).on("tap", function (e) {
  107. if(e.target.nodeName.toLowerCase()!="input") {
  108. if(beforeIpt) {
  109. beforeIpt.blur();
  110. beforeIpt=null;
  111. }
  112. }
  113. });
  114. mui('body').on('tap', '.mui-backdrop', function(e) {
  115. $(".xgmsgbox").hide();
  116. $("#modal-4").hide();
  117. });
  118. /**
  119. * 时间事件
  120. * */
  121. sjchaxun();
  122. //模糊查询键盘enter键事件
  123. $("input[type='search']").on('keypress',function(e) {
  124. var type = $("#type").val();
  125. var keycode = e.keyCode;
  126. if(keycode=='13') {
  127. e.preventDefault();
  128. //请求搜索接口
  129. clear();
  130. haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val()+"&type="+type + "&pch="+$("#pch").val());
  131. }
  132. });
  133. /* *
  134. * 下拉刷新上拉加载数据
  135. * */
  136. var pullUp = $("#pullUp"),
  137. pullUpLabel = $(".pullUpLabel"),
  138. loadingStep = 0;//加载状态0默认,1显示加载状态,2执行加载数据,只有当为0时才能再次加载,这是防止过快拉动刷新
  139. //滚动时触发
  140. iscroll.on("scroll",function(){
  141. if(loadingStep == 0 && !pullUp.attr("class").match('refresh')){
  142. if(this.y < (this.maxScrollY - 14)){//上拉加载更多
  143. pullUp.addClass("refresh").show();
  144. pullUp.css({"background":"","background-size":""});
  145. pullUpLabel.text("松手开始加载...");
  146. loadingStep = 1;
  147. iscroll.refresh();
  148. }
  149. }
  150. });
  151. //滚动结束触发
  152. iscroll.on("scrollEnd",function(){
  153. if(loadingStep == 1){
  154. if( pullUp.attr("class").match("refresh") ){//上拉加载操作
  155. pullUp.removeClass("refresh").addClass("loading");
  156. pullUpLabel.text("");
  157. pullUp.css({"background":"#D7DFEA url(views/haifmv/img/pullUp.gif) no-repeat center","background-size":"12%"});
  158. loadingStep = 2;
  159. pullUpAction();
  160. iscroll.refresh();
  161. }
  162. }
  163. //滑动定位
  164. var thisy = parseInt(this.y);
  165. localStorage.setItem("shIndexY"+type,thisy);
  166. });
  167. /**
  168. * 上拉加载方法
  169. * */
  170. function pullUpAction(){
  171. var kssj = $("#startT .nian").html()+"-" + $("#startT .yue").html()+"-" + $("#startT .ri").html();
  172. var jssj = $("#endT .nian").html()+"-" + $("#endT .yue").html()+"-" + $("#endT .ri").html();
  173. var page = parseInt($("#page").val())+1;
  174. var maxPages = $("#maxPages").val();
  175. if (page <= maxPages) {
  176. jQuery.ajax({
  177. type : "get",
  178. url : "AddWhhShsj.htm",
  179. data : {
  180. "mcid" : $("#mcid").val(),
  181. "pch": $("#pch").val(),
  182. "ksrq" : kssj,
  183. "jsrq" : jssj,
  184. "page" : page,
  185. "type" : $("#type").val()
  186. },
  187. dataType : "json",
  188. async : true,
  189. success : function(data) {
  190. var hc = localStorage.getItem("shIndex"+type);
  191. setTimeout(function() {
  192. var something = "";
  193. for (var i = 0 ; i < data.length; i++) {
  194. var obj = data[i];
  195. var str = "";
  196. var kuang = "";
  197. if (obj.sl > 1) {
  198. str = "等";
  199. }
  200. if (type == "0") {
  201. kuang += "<input type='checkbox' name='sProblem' value="+obj.pc+">";
  202. }
  203. something += "<div class='rowBox container-fluid whhShitem' data-id="+obj.id+" data-pc = "+obj.pc+">"
  204. +"<div class='left'>"+kuang
  205. +"</div>" +
  206. "<div class='right' onclick=\"toView('"+obj.id+"','"+obj.pc+"');\" data-id="+obj.id+" data-pc = "+obj.pc+">"
  207. +"<div class='row'>"
  208. +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>管理号:<span>"+obj.glh+str +"</span></div>"
  209. +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>批次编码:<span>"+obj.pc+"</span></div>"
  210. +"</div><div class='row'>"
  211. +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>处理方式:<span>"+obj.clfsStr+"</span></div>"
  212. +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>处理时间:<span>"+obj.clsjStr+"</span></div>"
  213. +"</div><div class='row'>"
  214. +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>数量:<span>"+obj.sl+"</span></div>"
  215. +"<div class='col-xs-5 col-sm-5 col-md-5 discenter'>处理人员:<span>"+obj.clry+"</span></div>"
  216. +"</div></div></div>";
  217. }
  218. $(".fmjlIscroll ul.mui-table-view").append($(something));
  219. pullUp.attr("class","");
  220. pullUpLabel.text("上拉加载更多");
  221. pullUp.css({"background":""});
  222. iscroll.refresh();
  223. loadingStep = 0;
  224. localStorage.setItem("shIndex"+type,hc + something);
  225. },1000);
  226. $("#page").val(page);
  227. localStorage.setItem("shIndexPage"+type,page);
  228. }
  229. });
  230. }else {
  231. pullUp.css({"background":"","background-size":""});
  232. pullUpLabel.text("没有数据了");
  233. iscroll.refresh();
  234. }
  235. }
  236. //加载缓存中的内容
  237. var type = $("#type").val();
  238. if (localStorage.hasOwnProperty("shIndex"+type)) {
  239. var sth = localStorage.getItem("shIndex"+type);
  240. $(".fmjlIscroll ul").append(sth.substring(4,sth.length));
  241. }
  242. if (localStorage.hasOwnProperty("shIndexY"+type)) {
  243. var tall = localStorage.getItem("shIndexY"+type);
  244. iscroll.scrollTo(0,tall,1000, IScroll.utils.ease.elastic);
  245. iscroll.refresh();
  246. }
  247. //切换内容
  248. $("#type>div").on("tap",function(){
  249. var type = $(this).data("for");
  250. var ksrq = $("#startT .nian").html() + "-" + $("#startT .yue").html() + "-" + $("#startT .ri").html();
  251. var jsrq = $("#endT .nian").html() + "-" + $("#endT .yue").html() + "-" + $("#endT .ri").html();
  252. haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val() + "&kssj=" + ksrq + "&jssj="
  253. + jsrq +"&type="+type);
  254. $("#type").each("div",function(){
  255. this.removeClass("green");
  256. });
  257. $("#type").find("div").eq(type).addClass("green");
  258. });
  259. //通过 驳回
  260. $(".sjokbox span").on("tap",function(){
  261. var data = $(this).data("for");
  262. var bz = $("#textarea").val();
  263. var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
  264. jQuery.ajax({
  265. dataType : 'json',
  266. type : "post",
  267. url : "ShdealWhith.htm",
  268. data : {
  269. "mcid" : $("#mcid").val(),
  270. "glid" : $("#glid").val(),
  271. "shbz" : data,
  272. "bz" : bz,
  273. "type" : $("#type").val()
  274. },
  275. dataType : "json",
  276. async : true,
  277. success : function(msg) {
  278. // 保存成功
  279. if (msg.count == 1) {
  280. $(".xgmsgbox").hide();
  281. $("#modal-4").hide();
  282. haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val()+"&type=0");
  283. clear();
  284. mask.close();//关闭遮罩
  285. $(".mui-backdrop").hide();
  286. mui.toast('保存成功');
  287. }else if (msg.count == 2) {
  288. mui.alert('数据接收错误 请联系开发人员-1', '提示', function() {});
  289. $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  290. }else if (msg.count == 3) {
  291. mui.alert('数据接收错误 请联系开发人员-0', '提示', function() {});
  292. $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  293. }else if (msg.count == 4) {
  294. mui.alert('数据接收错误 请联系开发人员-2', '提示', function() {});
  295. $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  296. }
  297. },
  298. error : function(msg) {
  299. mui.alert('网络繁忙,请稍后再试...', '提示', function() {});
  300. $('.save').removeAttr("disabled");//改变提交按钮上的文字并将按钮设置为可点击
  301. mask.close();//关闭遮罩
  302. $("#modal-4").hide();
  303. $(".xgmsgbox").hide();
  304. $(".mui-backdrop").hide();
  305. haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val()+"&type=0");
  306. },
  307. complete: function(msg) {
  308. //ajax请求完成时执行
  309. if (msg.count == 1) {
  310. $('.save').attr('disabled',true);//改变提交按钮上的文字并将按钮设置为不可点击
  311. }
  312. }
  313. });
  314. });
  315. });
  316. /**
  317. * 时间方法
  318. * */
  319. function sjchaxun(){
  320. mui.init();
  321. mui.ready(function() {
  322. //开始时间
  323. var startN = $('.nian')[0];
  324. var startnY = $('.yue')[0];
  325. var startR = $('.ri')[0];
  326. var startTbtns = $('#startT');
  327. startTbtns.each(function(i, startTbtn) {
  328. startTbtn.addEventListener('tap', function() {
  329. var dataFor = this.getAttribute('data-for');
  330. var that = this;
  331. dateP(startN,startnY,startR,dataFor,that);
  332. }, { passive: false });
  333. });
  334. //结束时间
  335. var endN = $('.nian')[1];
  336. var endY = $('.yue')[1];
  337. var endR = $('.ri')[1];
  338. var endTbtns = $('#endT');
  339. endTbtns.each(function(i, endTbtn) {
  340. endTbtn.addEventListener('tap', function() {
  341. var dataFor = this.getAttribute('data-for');
  342. var that = this;
  343. dateP(endN,endY,endR,dataFor,that);
  344. }, { passive: false });
  345. });
  346. });
  347. function dateP(nian,yue,ri,dataFor,that) {
  348. var picker = new mui.DtPicker({
  349. type: "date",//设置日历初始视图模式
  350. value: dataFor
  351. });
  352. picker.show(function(rs) {
  353. nian.innerHTML = rs.y.text;
  354. yue.innerHTML = rs.m.text;
  355. ri.innerHTML = rs.d.text;
  356. that.setAttribute('data-for',rs.value);
  357. picker.dispose();
  358. });
  359. }
  360. }
  361. /**
  362. *时间搜索
  363. */
  364. function timeSearch() {
  365. var ksrq = $("#startT .nian").html() + "-" + $("#startT .yue").html() + "-" + $("#startT .ri").html();
  366. var jsrq = $("#endT .nian").html() + "-" + $("#endT .yue").html() + "-" + $("#endT .ri").html();
  367. haifm.loadMobilePage("haifm", "whhShMain.htm?mcid=" + $("#mcid").val() + "&kssj=" + ksrq + "&jssj="
  368. + jsrq +"&type="+$("#type").val()+"&pch="+$("#pch").val());
  369. clear();
  370. }
  371. //滑动高度和内容高度对比
  372. function heightvs(zsIscrollHeight,cententHeight){
  373. if(zsIscrollHeight.height() > cententHeight.height()){
  374. $("#pullUp").hide();
  375. }else{
  376. $("#pullUp").show();
  377. }
  378. }
  379. function clear() {
  380. var type = $("#type").val();
  381. if (localStorage.hasOwnProperty("shIndex"+type)) {
  382. localStorage.removeItem("shIndex"+type);
  383. }
  384. if (localStorage.hasOwnProperty("shIndexY"+type)) {
  385. localStorage.removeItem("shIndexY"+type);
  386. }
  387. if (localStorage.hasOwnProperty("shIndexPage"+type)) {
  388. localStorage.removeItem("shIndexPage"+type);
  389. }
  390. }
  391. function submit(){
  392. var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
  393. var glid = "";
  394. var type = $("#type").val();
  395. $("input[type='checkbox']").each(function() {
  396. if ( this.checked == true){
  397. var str = $(this).val();
  398. glid+= str+",";
  399. }
  400. });
  401. glid = glid.substring(0, glid.length-1);
  402. if (glid == "") {
  403. mui.alert("请勿空选");
  404. return;
  405. }else{
  406. mask.show();//显示遮罩
  407. $("#modal-4").show();
  408. $("#glid").val(glid);
  409. }
  410. }
  411. //全选与取消全选
  412. function Check() {
  413. if (checked == false) {
  414. $("input[type='checkbox']").each(function() {
  415. this.checked = true;
  416. });
  417. $("#allCheck").html("取消全选");
  418. checked = true;
  419. }else {
  420. $("input[type='checkbox']").each(function() {
  421. this.checked = false;
  422. });
  423. $("#allCheck").html("全选");
  424. checked = false;
  425. }
  426. }
  427. function toView(id,pc){
  428. var type = $("#type").val();
  429. if (type != 0) {
  430. haifm.loadMobilePage("haifm", "clDealWhith.htm?mcid="
  431. + $("#mcid").val() + "&shxxID=" + id+"&from=sh" +"&type="+type);
  432. }else {
  433. haifm.loadMobilePage("haifm", "whhSubmit.htm?mcid="
  434. + $("#mcid").val() + "&pc=" + pc+"&type="+type);
  435. }
  436. }