data.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. var bind_ajax_form_lock = false;
  2. jQuery(function(){
  3. bind_ajax_form();
  4. $("#listTable .check_all").click(function(){
  5. if($(this).attr("checked")){
  6. $("#listTable tbody input[name='check']").attr("checked",true);
  7. $(".datatabletool").show();
  8. }
  9. else{
  10. $("#listTable tbody input[name='check']").attr("checked",false);
  11. $(".datatabletool").hide();
  12. }
  13. });
  14. $("#listTable tbody input[name='check']").click(function(){
  15. if($("#listTable tbody input[name='check']:checked").length > 0){
  16. $(".datatabletool").show();
  17. }
  18. else{
  19. $(".datatabletool").hide();
  20. }
  21. });
  22. $(".datatabletool .btn").click(function(){
  23. var obj = $(this);
  24. if (obj.attr("attr") == "BatchDel") {
  25. $.showCfm("确定要删除选定的数据吗", function(){
  26. if ($("#listTable tbody input[name='check']:checked").length == 0) {
  27. $.weeboxs.close();
  28. return false;
  29. }
  30. var query = new Object();
  31. query.ids = "0";
  32. $("#listTable tbody input[name='check']:checked").each(function(){
  33. query.ids += ","+$(this).val();
  34. });
  35. $.ajax({
  36. url:obj.attr("url"),
  37. data:query,
  38. type:"post",
  39. dataType:"json",
  40. success:function(result){
  41. if(result.status==1){
  42. location.href = location.href;
  43. }
  44. else{
  45. $.weeboxs.close();
  46. $.showErr(result.msg);
  47. }
  48. },
  49. error:function(){
  50. location.href = location.href;
  51. }
  52. });
  53. }, function(){
  54. });
  55. }else if(obj.attr("attr") == "BatchLock"){
  56. $.showCfm("确定要冻结选定的会员吗", function(){
  57. if($("#listTable tbody input[name='check']:checked").length == 0)
  58. return false;
  59. var query = new Object();
  60. query.ids = "0";
  61. $("#listTable tbody input[name='check']:checked").each(function(){
  62. query.ids += ","+$(this).val();
  63. });
  64. query.status=0;
  65. $.ajax({
  66. url:obj.attr("url"),
  67. data:query,
  68. type:"post",
  69. dataType:"json",
  70. success:function(result){
  71. if(result.status==1){
  72. location.reload();
  73. }
  74. else{
  75. $.weeboxs.close();
  76. $.showErr(result.msg);
  77. }
  78. },
  79. error:function(){
  80. location.reload();
  81. }
  82. });
  83. }, function(){
  84. });
  85. }else if(obj.attr("attr") == "BatchUNLock"){
  86. $.showCfm("确定要解冻选定的会员吗", function(){
  87. if($("#listTable tbody input[name='check']:checked").length == 0)
  88. return false;
  89. var query = new Object();
  90. query.ids = "0";
  91. $("#listTable tbody input[name='check']:checked").each(function(){
  92. query.ids += ","+$(this).val();
  93. });
  94. query.status=1;
  95. $.ajax({
  96. url:obj.attr("url"),
  97. data:query,
  98. type:"post",
  99. dataType:"json",
  100. success:function(result){
  101. if(result.status==1){
  102. location.reload();
  103. }
  104. else{
  105. $.weeboxs.close();
  106. $.showErr(result.msg);
  107. }
  108. },
  109. error:function(){
  110. location.reload();
  111. }
  112. });
  113. }, function(){
  114. });
  115. }else if(obj.attr("attr") == "Batchyinc"){
  116. $.showCfm("确定要隐藏吗", function(){
  117. if($("#listTable tbody input[name='check']:checked").length == 0)
  118. return false;
  119. var query = new Object();
  120. query.ids = "0";
  121. $("#listTable tbody input[name='check']:checked").each(function(){
  122. query.ids += ","+$(this).val();
  123. });
  124. query.status=1;
  125. $.ajax({
  126. url:obj.attr("url"),
  127. data:query,
  128. type:"post",
  129. dataType:"json",
  130. success:function(result){
  131. if(result.status==1){
  132. location.reload();
  133. }
  134. else{
  135. $.weeboxs.close();
  136. $.showErr(result.msg);
  137. }
  138. },
  139. error:function(){
  140. location.reload();
  141. }
  142. });
  143. }, function(){
  144. });
  145. }else if (obj.attr("attr") == "BatchDone") {
  146. $.showCfm("确定要处理?", function(){
  147. if($("#listTable tbody input[name='check']:checked").length == 0)
  148. return false;
  149. var query = new Object();
  150. query.ids = "0";
  151. $("#listTable tbody input[name='check']:checked").each(function(){
  152. query.ids += ","+$(this).val();
  153. });
  154. $.ajax({
  155. url:obj.attr("url"),
  156. data:query,
  157. type:"post",
  158. dataType:"json",
  159. success:function(result){
  160. if(result.status==1){
  161. location.href = location.href;
  162. }
  163. else{
  164. $.weeboxs.close();
  165. $.showErr(result.msg);
  166. }
  167. },
  168. error:function(){
  169. location.href = location.href;
  170. }
  171. });
  172. }, function(){
  173. });
  174. }
  175. });
  176. $(".dropdown-toggle").click(function(){
  177. if($(this).parent().hasClass("open")){
  178. $(this).parent().removeClass("open");
  179. }
  180. else{
  181. $(".dropdown-toggle").parent().removeClass("open");
  182. $(this).parent().addClass("open");
  183. $("body").bind("click",function(){
  184. $(".dropdown-toggle").parent().removeClass("open");
  185. });
  186. return false;
  187. }
  188. });
  189. });
  190. function bind_ajax_form()
  191. {
  192. $(".ajax_form").find(".ipt_require").live("click",function(){
  193. $(this).removeClass("input-need");
  194. });
  195. $(".ajax_form").find(".ipt_require").live("blur",function(){
  196. if($.trim($(this).val())=="")
  197. $(this).addClass("input-need");
  198. });
  199. $(".ajax_form").live("submit",function(){
  200. if(bind_ajax_form_lock)
  201. {
  202. return false;
  203. }
  204. var empty = 0;
  205. var tel_num=0;
  206. var req_length = 0;
  207. $.each( $(this).find(".ipt_require"), function(i, obj){
  208. if($.trim($(obj).val())=="")
  209. {
  210. $(obj).addClass("input-need");
  211. empty++;
  212. }
  213. });
  214. $.each( $(this).find(".tel_require"), function(i, obj){
  215. if(!$.checkMobilePhone($(obj).val())||($.getStringLength($(obj).val())!=11))
  216. {
  217. $(obj).addClass("input-need");
  218. tel_num++;
  219. }
  220. });
  221. $.each( $(this).find(".length_require"), function(i, obj){
  222. if($.getStringLength($(obj).val()) >= parseInt($(obj).attr("maxlen")))
  223. {
  224. $(obj).addClass("input-need");
  225. req_length++;
  226. }
  227. });
  228. if(tel_num > 0){
  229. $.showErr("请输入正确的手机号");
  230. return false;
  231. }
  232. if(empty > 0){
  233. $.showErr("请检查必填项是否为空");
  234. return false;
  235. }
  236. if(req_length > 0){
  237. $.showErr("请检查输入框是否超出限制的长度");
  238. return false;
  239. }
  240. if(empty==0 && req_length==0)
  241. {
  242. bind_ajax_form_lock = true;
  243. var ajaxurl = $(this).attr("action");
  244. var query = $(this).serialize();
  245. var form = $(this);
  246. $.ajax({
  247. url: ajaxurl,
  248. dataType: "json",
  249. data:query,
  250. type: "POST",
  251. success: function(ajaxobj){
  252. if(ajaxobj.status==1)
  253. {
  254. $.showSuccess(ajaxobj.info,function(){
  255. if(ajaxobj.jump!=""&&ajaxobj.jump!=undefined){
  256. location.href = ajaxobj.jump;
  257. }
  258. else{
  259. location.reload(true);
  260. }
  261. });
  262. }
  263. else
  264. {
  265. if(ajaxobj.info!="")
  266. {
  267. $.showErr(ajaxobj.info,function(){
  268. if(ajaxobj.field!="")
  269. $(form).find("input[name='"+ajaxobj.field+"']").addClass("input-need");
  270. if(ajaxobj.jump!=""&&ajaxobj.jump!=undefined)
  271. {
  272. location.href = ajaxobj.jump;
  273. }else{
  274. location.reload(true);
  275. }
  276. });
  277. }
  278. else
  279. {
  280. if(ajaxobj.jump!=""&&ajaxobj.jump!=undefined)
  281. {
  282. location.href = ajaxobj.jump;
  283. }else{
  284. location.reload(true);
  285. }
  286. }
  287. }
  288. bind_ajax_form_lock = false;
  289. },
  290. error:function(ajaxobj)
  291. {
  292. bind_ajax_form_lock = false;
  293. }
  294. });
  295. }
  296. return false;
  297. });
  298. }
  299. function do_confirm(info,url){
  300. $.showCfm(info, function(){
  301. $.ajax({
  302. url:url,
  303. data:"ajax=1",
  304. dataType:"json",
  305. success:function(result){
  306. if(result.status==1){
  307. $.weeboxs.close();
  308. $.showSuccess(result.info,function(){
  309. if(result.jump!=""&&result.jump!=undefined)
  310. location.href = result.jump;
  311. else
  312. location.reload();
  313. });
  314. }
  315. else{
  316. $.weeboxs.close();
  317. $.showErr(result.info);
  318. }
  319. }
  320. });
  321. }, function(){
  322. });
  323. }
  324. function close_pop()
  325. {
  326. $(".dialog-close").click();
  327. }