Nessuna descrizione

custom_select.js 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. var areaList=[],officeList=[],areaId="",officeId="",provinLeng,cityLeng ;
  2. $(document).ready(function(){
  3. $(".Regional").click(function(){
  4. event.stopPropagation();
  5. if ($('.grade-eject').hasClass('grade-w-roll')) {
  6. $('.grade-eject').removeClass('grade-w-roll');
  7. $(this).removeClass('current');
  8. setTimeout(function() {$(".grade-eject_bj").hide()},400);
  9. } else {
  10. $(".grade-eject").addClass("grade-w-roll");
  11. setTimeout(function() {$(".grade-eject_bj").show()},400)
  12. }
  13. cleanList();
  14. });
  15. $(".resBtn").click(function(){
  16. cleanList();
  17. })
  18. $('.grade-eject_bj').on('tap', function() {
  19. $('.grade-eject').removeClass('grade-w-roll');
  20. setTimeout(function() {$(".grade-eject_bj").hide()},400)
  21. cleanList();
  22. })
  23. $(document).click(function(event) {
  24. var _con = $('.clickArea'); // 设置目标区域
  25. if(!_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
  26. $('.grade-eject').removeClass('grade-w-roll');
  27. $(this).removeClass('current');
  28. }
  29. });
  30. $(".grade-w").on('click', 'li', function() {
  31. $(".grade-t").css("left","50%");
  32. if ($(this).hasClass("check_active")) {
  33. $(this).removeClass("check_active");
  34. $(this).children("img").hide();
  35. var areaDataRemove=$(this).attr("data-index");
  36. Array.prototype.indexOf = function (val) {
  37. for(var i = 0; i < this.length; i++){
  38. if(this[i] == val){return i;}
  39. }
  40. return -1;
  41. }
  42. Array.prototype.remove = function (val) {
  43. var index = this.indexOf(val);
  44. if(index > -1){this.splice(index,1);}
  45. }
  46. areaList.remove(areaDataRemove);
  47. officeList=[];
  48. $(".grade-t li img").hide();
  49. $(".mui-checkbox input").removeAttr("checked")
  50. } else{
  51. var areaData=$(this).attr("data-index");
  52. if ($(".mui-checkbox input").attr("checked")) {
  53. areaList=[];
  54. var allCheck=$(".grade-w li").length;
  55. for (var i=0; i<allCheck; i++ ) {
  56. areaData=$(".grade-w li").eq(i).attr("data-index");
  57. areaList.push(areaData);
  58. }
  59. }else{
  60. if ($(this).children("img").is(':hidden')) {
  61. areaList.push(areaData);
  62. }
  63. if (provinLeng==areaList.length) {
  64. $(".mui-checkbox input").attr("checked", "checked");
  65. }
  66. }
  67. $(this).addClass("check_active");
  68. $(this).children("img").show();
  69. $('#gradet li').remove();
  70. // 产品代码
  71. $.ajax({
  72. type: "get",
  73. url: huayi.config.callcenter_url + 'Department/GetCusAreaList',
  74. async: false,
  75. data: {
  76. pid:$(this).attr("data-index"),
  77. F_Layer: 2,
  78. token:localStorage.getItem("token")
  79. },
  80. dataType: 'json',
  81. success: function(res) {
  82. if(res.state.toLowerCase() === "success") {
  83. res = res.data;
  84. cityLeng = res.length;
  85. if(res && cityLeng > 0) {
  86. res.forEach(function(v, i) {
  87. var officeData=v.F_DeptId;
  88. officeList.push(officeData);
  89. $('<li data-index="'+v.F_DeptId+'">'+v.F_DeptName+
  90. '<img src="../img/check_true.png"/></li>').appendTo('#gradet')
  91. });
  92. }
  93. }
  94. }
  95. });
  96. }
  97. })
  98. $(".grade-t").on('click', 'li', function() {
  99. if ($(this).children("img").is(':visible')) {
  100. $(this).removeClass("check_active")
  101. $(this).children("img").hide();
  102. var officeDataRemove=$(this).attr("data-index");
  103. Array.prototype.indexOf = function (val) {
  104. for(var i = 0; i < this.length; i++){
  105. if(this[i] == val){return i;}
  106. }
  107. return -1;
  108. }
  109. Array.prototype.remove = function (val) {
  110. var index = this.indexOf(val);
  111. if(index > -1){this.splice(index,1);}
  112. }
  113. officeList.remove(officeDataRemove);
  114. } else{
  115. $(this).addClass("check_active");
  116. $(this).children("img").show();
  117. var officeData=$(this).attr("data-index");
  118. officeList.push(officeData);
  119. }
  120. })
  121. // 产品代码
  122. $.ajax({
  123. type: "get",
  124. url: huayi.config.callcenter_url + 'Department/GetCusAreaList',
  125. async: false,
  126. data: {
  127. pid: 1,
  128. F_Layer: 1,
  129. token:localStorage.getItem("token")
  130. },
  131. dataType: 'json',
  132. success: function(res) {
  133. if(res.state.toLowerCase() === "success") {
  134. res = res.data;
  135. provinLeng = res.length;
  136. if(res && provinLeng > 0) {
  137. res.forEach(function(v, i) {
  138. $('<li data-index="'+v.F_DeptId+'" lenTh="'+ res.length+'">'+v.F_DeptName+
  139. '<img src="../img/check_true.png"/></li>').appendTo('#gradew')
  140. });
  141. }
  142. }
  143. }
  144. });
  145. });
  146. mui('.mui-checkbox').on('change', 'input', function() {
  147. if(this.checked){
  148. areaList=[];
  149. $(".grade-w li").removeClass("check_active");
  150. var allCheck=$(".grade-w li").length;
  151. $(".grade-w li img").show();
  152. for (var i=0; i<allCheck; i++ ) {
  153. var areaData=$(".grade-w li").eq(i).attr("data-index");
  154. areaList.push(areaData);
  155. }
  156. }else{
  157. $(".grade-w li img").hide();
  158. areaList=[];
  159. $(".grade-t li img").hide();
  160. officeList=[];
  161. }
  162. });
  163. function cleanList () {
  164. areaList=[],officeList=[],areaId="",officeId="";
  165. $(this).removeClass("check_active");
  166. $(this).children("img").hide();
  167. $(".grade-w li").removeClass("check_active");
  168. $(".grade-w li img").hide();
  169. $(".grade-t li").removeClass("check_active");
  170. $(".grade-t li img").hide();
  171. $('#gradet li').remove();
  172. }
  173. function areaD() {
  174. for (var i=0, l=areaList.length; i<l; i++) {
  175. areaId += areaList[i]+ ","
  176. }
  177. if (areaList.length > 0 ) {
  178. areaId = areaId.substring(0, areaId.length-1);
  179. $('#AreaId').val(areaId);
  180. }
  181. }
  182. function officeD() {
  183. for (var i=0, l=officeList.length; i<l; i++) {
  184. officeId += officeList[i]+ ","
  185. }
  186. if (officeList.length > 0 ) {
  187. officeId = officeId.substring(0, officeId.length-1);
  188. $('#OfficeId').val(officeId);
  189. }
  190. }