selectprovinces.blade.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <style type='text/css'>
  2. .province { float:left; position:relative;width:185px; height:35px; line-height:35px;border:1px solid #fff;}
  3. .province:hover { border:1px solid #f7e4a5;border-bottom:1px solid #fffec6; background:#fffec6;}
  4. .province .cityall { margin-top:10px;}
  5. .province ul { list-style: outside none none;position:absolute;padding:0;background:#fffec6;border:1px solid #f7e4a5;display:none;
  6. width:auto; width:300px; z-index:999999;left:-1px;top:32px;}
  7. .province ul li { float:left;min-width:60px;margin-left:20px; height:30px;line-height:30px; }
  8. </style>
  9. <div id="modal-areas" class="modal fade" tabindex="-1">
  10. <div class="modal-dialog" style='width: 970px;'>
  11. <div class="modal-content">
  12. <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>选择区域</h3></div>
  13. <div class="modal-body" style='height:370px;' >
  14. @foreach ($parents as $value)
  15. @if ($value['areaname'] == '请选择省份') {{--{php continue }--}} @endif
  16. <div class='province' data-parent-id="{{ $value['id'] }}">
  17. <label class='checkbox-inline' style='margin-left:20px;'>
  18. <input type='checkbox' class='cityall' /> {{ $value['areaname'] }}
  19. <span class="citycount" style='color:#ff6600'></span>
  20. </label>
  21. <ul></ul>
  22. </div>
  23. @endforeach
  24. </div>
  25. <div class="modal-footer">
  26. <a href="javascript:;" id='btnSubmitArea' class="btn btn-success" data-dismiss="modal" aria-hidden="true">确定</a>
  27. <a href="javascript:;" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <script language='javascript'>
  33. $(function(){
  34. $('.province').mouseover(function(){
  35. var _this = $(this);
  36. if(_this.find('ul').text().length == 0){
  37. $.get('{!! yzWebUrl("area.area.select-city") !!}', {
  38. parent_id: $(this).data('parent-id')
  39. }, function(dat){
  40. _this.find('ul').html(dat);
  41. });
  42. }
  43. _this.find('ul').show();
  44. }).mouseout(function(){
  45. $(this).find('ul').hide();
  46. });
  47. $('.cityall').click(function(){
  48. var checked = $(this).get(0).checked;
  49. var citys = $(this).parent().parent().find('.city');
  50. citys.each(function(){
  51. $(this).get(0).checked = checked;
  52. });
  53. var count = 0;
  54. if(checked){
  55. count = $(this).parent().parent().find('.city:checked').length;
  56. }
  57. if(count>0){
  58. $(this).next().html("(" + count + ")") ;
  59. }
  60. else{
  61. $(this).next().html("");
  62. }
  63. });
  64. $('.city').click(function(){
  65. var checked = $(this).get(0).checked;
  66. var cityall = $(this).parent().parent().parent().parent().find('.cityall');
  67. if(checked){
  68. cityall.get(0).checked = true;
  69. }
  70. var count = cityall.parent().parent().find('.city:checked').length;
  71. if(count>0){
  72. cityall.next().html("(" + count + ")") ;
  73. }
  74. else{
  75. cityall.next().html("");
  76. }
  77. });
  78. });
  79. function clearSelects(){
  80. $('.city').attr('checked',false).removeAttr('disabled');
  81. $('.cityall').attr('checked',false).removeAttr('disabled');
  82. $('.citycount').html('');
  83. }
  84. function selectAreas(){
  85. clearSelects();
  86. var old_citys = $('#areas').html().split(';');
  87. $('.city').each(function(){
  88. var parentcheck = false;
  89. for(var i in old_citys){
  90. if(old_citys[i]==$(this).attr('city')){
  91. parentcheck = true;
  92. $(this).get(0).checked = true;
  93. break;
  94. }
  95. }
  96. if(parentcheck){
  97. $(this).parent().parent().parent().parent().find('.cityall').get(0).checked= true;
  98. }
  99. });
  100. $("#modal-areas").modal();
  101. var citystrs = '';
  102. var cityids = '';
  103. $('#btnSubmitArea').unbind('click').click(function(){
  104. $('.city:checked').each(function(){
  105. citystrs+= $(this).attr('city') +";";
  106. cityids+= $(this).attr('city_id') +",";
  107. });
  108. $('#areas').html(citystrs);
  109. $("#selectedareas").val(citystrs);
  110. $("#selectedareaids").val(cityids);
  111. })
  112. }
  113. </script>