wsclBjsz.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. $(function () {
  2. var mask = mui.createMask();//callback为用户点击蒙版时自动执行的回调;
  3. /**
  4. * 初始化二级菜单按钮
  5. */
  6. var strButton = $("#sj").val();
  7. var strBArr = strButton.split(",");
  8. for (var i = 0 ; i < strBArr.length ; i++) {
  9. if (strBArr[i] == "0") {
  10. $(".show"+i).hide();
  11. }else {
  12. $(".show"+i).show();
  13. }
  14. }
  15. /**
  16. * 点击td选中input
  17. */
  18. $(".listcenter>li,.checkBox").on("tap",function (e) {
  19. if (e && e.stopPropagation) {
  20. e.stopPropagation();
  21. } else {
  22. window.event.cancelBubble = true;
  23. }
  24. if ($(this).find("input[type='checkbox']").is(":checked")) {
  25. $(this).find("input[type='checkbox']").removeAttr("checked");
  26. } else {
  27. $(this).find("input[type='checkbox']").prop("checked", true);
  28. }
  29. });
  30. /**
  31. * 拖拽
  32. */
  33. if ($("#hkbjtb").val() == "true" || $("#flzbjtb").val() == "true") {
  34. tuozhuai("kgtb","box1");
  35. tuozhuai("cstb","box2");
  36. tuozhuai("iphonetb","box3");
  37. }
  38. /**
  39. * 滚动input以外失去焦点
  40. * */
  41. iscroll.on('scrollStart',function(e){
  42. var el = document.activeElement;
  43. if (el.nodeName.toLowerCase() == 'input') {
  44. el.blur();
  45. this.disable();
  46. this.enable();
  47. };
  48. return;
  49. });
  50. /**
  51. * 点击input以外失去焦点
  52. * */
  53. var beforeIpt=null;
  54. $("input").on("focus", function (e) {
  55. beforeIpt=this;
  56. });
  57. $(document).on("tap", function (e) {
  58. if(e.target.nodeName.toLowerCase()!="input") {
  59. if(beforeIpt) {
  60. beforeIpt.blur();
  61. beforeIpt=null;
  62. }
  63. }
  64. });
  65. /**
  66. * 开关事件
  67. * */
  68. mui('.mui-content .mui-switch').each(function() { //循环所有toggle
  69. mui(this)['switch']();
  70. //toggle 事件监听
  71. this.addEventListener('toggle', function(event) {
  72. event.stopPropagation();
  73. //event.detail.isActive 可直接获取当前状态
  74. var isActive = this.classList.contains("mui-active"); //判断打开ON或者关闭OFF
  75. if(isActive){ //打开状态
  76. $(this).parent().next().slideDown(500,function(){
  77. iscroll.refresh();
  78. });
  79. }else{ //关闭状态
  80. $(this).parent().next().slideUp(500,function(){
  81. iscroll.refresh();
  82. });
  83. }
  84. });
  85. });
  86. /**
  87. * 行为选择
  88. * */
  89. $(".xiugai").on("tap",function(){
  90. $(this).addClass("qq");
  91. mask.show();//显示遮罩
  92. $(".xw").show();
  93. mScrol3.refresh();
  94. //赋值
  95. var val = $(this).data("box") + "";
  96. var checkeds = $(".xwa").find("input[type='checkbox']");
  97. var m = 0;
  98. for (var i = 0; i < checkeds.length; i++) {
  99. if (i < 3) {//有可能四位 那么依次是声光,电话,短信,蜂鸣器
  100. m = i;
  101. } else {
  102. if (val.length > 4) { //如果超过4位那么,一次是 声光,电话,短信,其他1,其他2, 蜂鸣器
  103. m = i + 2;
  104. } else {
  105. m = i;
  106. }
  107. }
  108. checkeds.eq(i).prop("checked", "");
  109. checkeds.eq(i).next().removeClass("colorActive");
  110. if (val.charAt(m) == "2") {
  111. checkeds.eq(i).prop("checked", "true");
  112. checkeds.eq(i).next().addClass("colorActive");
  113. }
  114. }
  115. $(".xwdq").bind("tap",function(){
  116. //box赋值
  117. var box = $(".xw li .xwa").find("input[type='checkbox']");
  118. var boxarr = "";
  119. for (var i = 0 ; i < box.length ; i++) {
  120. boxarr += box.eq(i).is(":checked") ? 2 : 1;
  121. }
  122. $(".qq").data("box", boxarr);
  123. $(".qq").parent().prev().attr("value",boxarr);
  124. if ($(".xwa").find("input[type='checkbox']").is(":checked")) {
  125. var chk_value =[];
  126. $('.xw li .xwa input[type="checkbox"]:checked').each(function(i,checkbox){
  127. chk_value.push($(this).siblings().html());
  128. $(this).prop("checked", false);
  129. });
  130. var temp_string = chk_value.join("/");
  131. $(".wdxxbox .row .qq").html(temp_string + "<span class='caret'></span>");
  132. }
  133. $(".wdxxbox .row div").removeClass("qq");
  134. $(".xw,.xgmsgbox").hide();
  135. mask.close();//关闭遮罩
  136. iscroll.refresh();
  137. });
  138. });
  139. mui('body').on('tap', '.mui-backdrop', function(e) {
  140. $(".xw,.xgmsgbox").hide();
  141. $(".xgmsgbox").hide();
  142. });
  143. });
  144. //返回
  145. function bjcsBackUrl() {
  146. var zsid = $("#zsid").val();
  147. haifm.loadMobilePage("haifm", "wsclHaifmvMain.htm?mcid=" + $("#mcid").val()); //污水处理页面
  148. }
  149. /**
  150. * 保存
  151. */
  152. function savebjcs() {
  153. var cod = $("#cod").val();
  154. var bod = $("#bod").val();
  155. var ss = $("#ss").val();
  156. var nhsn = $("#nhsn").val();
  157. jQuery.ajax({
  158. dataType : 'json',
  159. type : "post",
  160. url : "saveWsclBjsz.htm",
  161. data : {
  162. "lqid" : $("#lqid").val(),
  163. "cod" : cod,
  164. "bod" : bod,
  165. "ss" : ss,
  166. "nhsn" : nhsn
  167. },
  168. dataType : "json",
  169. async : true,
  170. success : function(data) {
  171. // 保存成功
  172. if (data.returnCode == 1) {
  173. mui.alert("保存成功");
  174. }else if (data.returnCode == 2) {
  175. mui.alert("系统出错请稍后");
  176. }else if (data.returnCode == 3) {
  177. mui.alert("查无此栏期");
  178. }
  179. },
  180. error : function(data) {
  181. alert("系统异常 请稍后再试");
  182. }
  183. });
  184. }