暫無描述

custom_select.js 4.4KB

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