dispatchselectprovinces.blade.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <style type='text/css'>
  2. .province { float:left; position:relative;width:175px; 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:320px;' >
  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. //由于页面出现点击省份而地区正在加载时,地区没有被选择的情况
  36. //改为同步请求
  37. $.ajaxSettings.async = false;
  38. var _this = $(this);
  39. if(_this.find('ul').text().length == 0){
  40. $.get('{!! yzWebUrl("area.area.select-city") !!}', {
  41. parent_id: $(this).data('parent-id')
  42. }, function(dat){
  43. _this.find('ul').html(dat);
  44. });
  45. }
  46. _this.find('ul').show();
  47. //ajax同步请求完毕后再重新设置回异步
  48. $.ajaxSettings.async = true;
  49. }).mouseout(function(){
  50. $(this).find('ul').hide();
  51. });
  52. $('.cityall').click(function(){
  53. var checked = $(this).get(0).checked;
  54. var citys = $(this).parent().parent().find('.city');
  55. citys.each(function(){
  56. $(this).get(0).checked = checked;
  57. });
  58. var count = 0;
  59. if(checked){
  60. count = $(this).parent().parent().find('.city:checked').length;
  61. }
  62. if(count>0){
  63. $(this).next().html("(" + count + ")") ;
  64. }
  65. else{
  66. $(this).next().html("");
  67. //注意,如果为没有子区域选择,则父区域要取消选择,这里可能没必要,但是还是加上的稳
  68. $($(this).get(0)).attr('checked',false).removeAttr('checked');
  69. }
  70. });
  71. });
  72. </script>