Ei kuvausta

custom_select.js 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. $(".grade-t li img").hide();
  48. $(".mui-checkbox input").removeAttr("checked")
  49. } else{
  50. var areaData=$(this).attr("data-index");
  51. if ($(".mui-checkbox input").attr("checked")) {
  52. areaList=[];
  53. var allCheck=$(".grade-w li").length;
  54. for (var i=0; i<allCheck; i++ ) {
  55. areaData=$(".grade-w li").eq(i).attr("data-index");
  56. areaList.push(areaData);
  57. }
  58. }else{
  59. if ($(this).children("img").is(':hidden')) {
  60. areaList.push(areaData);
  61. }
  62. if (provinLeng==areaList.length) {
  63. $(".mui-checkbox input").attr("checked", "checked");
  64. }
  65. }
  66. $(this).addClass("check_active");
  67. $(this).children("img").show();
  68. $('#gradet li').remove();
  69. // 产品代码
  70. $.ajax({
  71. type: "get",
  72. url: huayi.config.callcenter_url + 'Department/GetCusAreaList',
  73. async: false,
  74. data: {
  75. pid:$(this).attr("data-index"),
  76. F_Layer: 2,
  77. token:localStorage.getItem("token")
  78. },
  79. dataType: 'json',
  80. success: function(res) {
  81. if(res.state.toLowerCase() === "success") {
  82. res = res.data;
  83. cityLeng = res.length;
  84. if(res && cityLeng > 0) {
  85. res.forEach(function(v, i) {
  86. var officeData=v.F_DeptId;
  87. officeList.push(officeData);
  88. $('<li data-index="'+v.F_DeptId+'">'+v.F_DeptName+
  89. '<img src="../img/check_true.png"/></li>').appendTo('#gradet')
  90. });
  91. }
  92. }
  93. }
  94. });
  95. }
  96. })
  97. $(".grade-t").on('click', 'li', function() {
  98. if ($(this).children("img").is(':visible')) {
  99. $(this).removeClass("check_active")
  100. $(this).children("img").hide();
  101. var officeDataRemove=$(this).attr("data-index");
  102. Array.prototype.indexOf = function (val) {
  103. for(var i = 0; i < this.length; i++){
  104. if(this[i] == val){return i;}
  105. }
  106. return -1;
  107. }
  108. Array.prototype.remove = function (val) {
  109. var index = this.indexOf(val);
  110. if(index > -1){this.splice(index,1);}
  111. }
  112. officeList.remove(officeDataRemove);
  113. } else{
  114. $(this).addClass("check_active");
  115. $(this).children("img").show();
  116. var officeData=$(this).attr("data-index");
  117. officeList.push(officeData);
  118. }
  119. })
  120. // 产品代码
  121. $.ajax({
  122. type: "get",
  123. url: huayi.config.callcenter_url + 'Department/GetCusAreaList',
  124. async: false,
  125. data: {
  126. pid: 1,
  127. F_Layer: 1,
  128. token:localStorage.getItem("token")
  129. },
  130. dataType: 'json',
  131. success: function(res) {
  132. if(res.state.toLowerCase() === "success") {
  133. res = res.data;
  134. provinLeng = res.length;
  135. if(res && provinLeng > 0) {
  136. res.forEach(function(v, i) {
  137. $('<li data-index="'+v.F_DeptId+'" lenTh="'+ res.length+'">'+v.F_DeptName+
  138. '<img src="../img/check_true.png"/></li>').appendTo('#gradew')
  139. });
  140. }
  141. }
  142. }
  143. });
  144. });
  145. mui('.mui-checkbox').on('change', 'input', function() {
  146. if(this.checked){
  147. areaList=[];
  148. $(".grade-w li").removeClass("check_active");
  149. var allCheck=$(".grade-w li").length;
  150. $(".grade-w li img").show();
  151. for (var i=0; i<allCheck; i++ ) {
  152. var areaData=$(".grade-w li").eq(i).attr("data-index");
  153. areaList.push(areaData);
  154. }
  155. }else{
  156. $(".grade-w li img").hide();
  157. areaList=[];
  158. $(".grade-t li img").hide();
  159. officeList=[];
  160. }
  161. });
  162. function cleanList () {
  163. areaList=[],officeList=[],areaId="",officeId="";
  164. $(this).removeClass("check_active");
  165. $(this).children("img").hide();
  166. $(".grade-w li").removeClass("check_active");
  167. $(".grade-w li img").hide();
  168. $(".grade-t li").removeClass("check_active");
  169. $(".grade-t li img").hide();
  170. $('#gradet li').remove();
  171. }
  172. function areaD() {
  173. for (var i=0, l=areaList.length; i<l; i++) {
  174. areaId += areaList[i]+ ","
  175. }
  176. if (areaList.length > 0 ) {
  177. areaId = areaId.substring(0, areaId.length-1);
  178. $('#AreaId').val(areaId);
  179. }
  180. }
  181. function officeD() {
  182. for (var i=0, l=officeList.length; i<l; i++) {
  183. officeId += officeList[i]+ ","
  184. }
  185. if (officeList.length > 0 ) {
  186. officeId = officeId.substring(0, officeId.length-1);
  187. $('#OfficeId').val(officeId);
  188. }
  189. }