Açıklama Yok

custom_select.js 5.3KB

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