index.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. {include file="public/header" /}
  2. <div class="page">
  3. <div class="fixed-bar">
  4. <div class="item-title">
  5. <div class="subject">
  6. <h3>{$Think.lang.ds_offpayarea}</h3>
  7. <h5></h5>
  8. </div>
  9. {include file="public/admin_items" /}
  10. </div>
  11. </div>
  12. <div class="explanation" id="explanation">
  13. <div class="title" id="checkZoom">
  14. <h4 title="{$Think.lang.ds_explanation_tip}">{$Think.lang.ds_explanation}</h4>
  15. <span id="explanationZoom" title="{$Think.lang.ds_explanation_close}" class="arrow"></span>
  16. </div>
  17. <ul>
  18. <li>{$Think.lang.offpayarea_index_help1}</li>
  19. <li>{$Think.lang.offpayarea_index_help2}</li>
  20. </ul>
  21. </div>
  22. <form id="area_form" method="post">
  23. <input type="hidden" name="county" id="county" value="" />
  24. <table id="table_area_box" class="ds-default-table">
  25. <thead>
  26. <tr class="thead">
  27. <th class="w10"></th>
  28. <th class="w120">{$Think.lang.offpayarea_province}</th>
  29. <th>{$Think.lang.offpayarea_city}</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. {foreach name="province_array" item="pinfo" key="pid"}
  34. <tr>
  35. <td></td>
  36. <td><label>
  37. <input type="checkbox" {php} if (in_array($pid, $parea_ids)) echo 'checked';{/php} value="{$pid}" name="province[]">
  38. <strong>{$pinfo.area_name}</strong></label></td>
  39. <td>
  40. {notempty name="pinfo.child"}
  41. {foreach name="pinfo.child" item="city_name" key="city_id"}
  42. <div class="area-list">
  43. <label>
  44. <input {if in_array($city_id,$parea_ids)}checked{/if} type="checkbox" ds_province="{$pid}" value="{$city_id}" name="city[]">
  45. {$city_name}
  46. </label>
  47. (<span city_id="{$city_id}" title="{$Think.lang.selected_sub_areas}">{present name="city_checked_child_array[$city_id]"}{:count($city_checked_child_array[$city_id])}{/present}</span>)
  48. <a city_id="{$city_id}" ds_title="{$city_name}" province_id="{$pid}" ds_type="edit" href="javascript:void(0);" title="{$Think.lang.select_sub_areas}">
  49. <i class="iconfont icon-bianji"></i>{$Think.lang.ds_edit}
  50. </a>
  51. </div>
  52. {/foreach}
  53. {/notempty}
  54. </td>
  55. </tr>
  56. {/foreach}
  57. </tbody>
  58. <tfoot>
  59. <tr class="tfoot">
  60. <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span>{$Think.lang.ds_submit}</span></a></td>
  61. </tr>
  62. </tfoot>
  63. </table>
  64. </form>
  65. </div>
  66. <style>
  67. #table_area_box .area-list {
  68. vertical-align: top;
  69. display: inline-block;
  70. *display: inline;
  71. width: 200px;
  72. margin: 0 0 10px 0;
  73. *zoom: 1;
  74. }
  75. </style>
  76. <script src="{$Think.PLUGINS_SITE_ROOT}/area_datas.js?{:rand(0,10000)}"></script>
  77. <script src="{$Think.PLUGINS_SITE_ROOT}/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>
  78. <script type="text/javascript">
  79. //将系统已选择的县ID放入JS数组
  80. var CUR_COUNTY = new Array();
  81. {notempty name="city_checked_child_array"}
  82. {foreach name="city_checked_child_array" item="county_ids" key="city_id"}
  83. CUR_COUNTY[{$city_id}] = new Array();
  84. {foreach name="county_ids" item="v"}
  85. CUR_COUNTY[{$city_id}][{$v}] = true;
  86. {/foreach}
  87. {/foreach}
  88. {/notempty}
  89. $(function(){
  90. //省点击事件
  91. $('input[name="province[]"]').on('click',function(){
  92. if ($(this).is(':checked')){
  93. $('input[ds_province="' + $(this).val() + '"]').each(function(){
  94. $(this).prop('checked',true);
  95. if (typeof ds_a[$(this).val()] == 'object') {
  96. county_array = ds_a[$(this).val()];
  97. } else {
  98. county_array = new Array();
  99. }
  100. CUR_COUNTY[$(this).val()] = new Array();
  101. for(i = 0; i < county_array.length; i++) {
  102. CUR_COUNTY[$(this).val()][county_array[i][0]] = true;
  103. }
  104. count = county_array.length;
  105. $('span[city_id="'+$(this).val()+'"]').html(count);
  106. });
  107. }else{
  108. $('input[ds_province="' + $(this).val() + '"]').each(function(){
  109. $(this).prop('checked',false);
  110. CUR_COUNTY[$(this).val()] = undefined;
  111. $('span[city_id="'+$(this).val()+'"]').html(0);
  112. });
  113. }
  114. });
  115. //点击编辑事件
  116. $('a[ds_type="edit"]').on('click',function(){
  117. if (typeof CUR_COUNTY[$(this).attr('city_id')] == 'object'){
  118. cur_county = CUR_COUNTY[$(this).attr('city_id')];
  119. }else{
  120. cur_county = new Array();
  121. }
  122. var province_array = ds_a[$(this).attr('city_id')];
  123. if (typeof ds_a[$(this).attr('city_id')] == 'object'){
  124. county_array = ds_a[$(this).attr('city_id')];
  125. }else{
  126. county_array = new Array();
  127. }
  128. if (county_array.length == 0) {
  129. layer.alert('{$Think.lang.no_child_region}');
  130. return;
  131. }
  132. county_html = '<table id="table_area_box_edit" class="ds-default-table"><tbody><tr class="noborder"><td city_id="'+$(this).attr('city_id')+'" province_id="'+$(this).attr('province_id')+'">';
  133. for(i = 0; i < county_array.length; i++){
  134. county_html += '<label><input type="checkbox"';
  135. if (typeof(cur_county[county_array[i][0]]) != 'undefined') {
  136. county_html += ' checked ' ;
  137. }
  138. county_html += (' value="'+county_array[i][0]+'" name="county[]">' + county_array[i][1] + '</label>');
  139. }
  140. county_html += '</td></tr><tr><td class="align-center"><a id="county_submit" class="btn" href="JavaScript:void(0);"><span>{$Think.lang.ds_confirm_submit}</span></a></td></tr><tr class="noborder"><td class="align-center" style="color:#f30;">{$Think.lang.offpayarea_index_help2}</td></tr></tbody></table>';
  141. html_form('select_county', '{$Think.lang.select} '+ $(this).attr('ds_title') +' {$Think.lang.child_region}', county_html, 500,1);
  142. });
  143. //选择市级事件
  144. $('input[name="city[]"]').on('click',function(){
  145. if ($(this).prop('checked')) {
  146. if (typeof ds_a[$(this).val()] == 'object') {
  147. county_array = ds_a[$(this).val()];
  148. } else {
  149. county_array = new Array();
  150. }
  151. CUR_COUNTY[$(this).val()] = new Array();
  152. for(i = 0; i < county_array.length; i++) {
  153. CUR_COUNTY[$(this).val()][county_array[i][0]] = true;
  154. }
  155. count = county_array.length;
  156. if ($('input[ds_province="'+$(this).attr('ds_province')+'"]').size() == $('input[ds_province="'+$(this).attr('ds_province')+'"]:checked').size()) {
  157. $('input[value="'+$(this).attr('ds_province')+'"]').prop('checked',true);
  158. } else {
  159. $('input[value="'+$(this).attr('ds_province')+'"]').prop('checked',false);
  160. }
  161. } else {
  162. CUR_COUNTY[$(this).val()] = undefined;
  163. count = 0;
  164. $('input[value="'+$(this).attr('ds_province')+'"]').prop('checked',false);
  165. }
  166. $('span[city_id="'+$(this).val()+'"]').html(count);
  167. });
  168. //弹出县编辑确认事件
  169. $('body').on('click','#county_submit',function(){
  170. cur_td = $('.dialog_content > table > tbody > tr > td');
  171. cur_checkbox = cur_td.find('input[type="checkbox"]');
  172. cur_checkbox.each(function(){
  173. if ($(this).prop('checked')) {
  174. if (typeof CUR_COUNTY[cur_td.attr('city_id')] != 'object') {
  175. CUR_COUNTY[cur_td.attr('city_id')] = new Array();
  176. }
  177. CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] = true;
  178. } else {
  179. if (typeof CUR_COUNTY[cur_td.attr('city_id')] == 'object') {
  180. if (typeof CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] != 'undefined') {
  181. CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] = undefined;
  182. }
  183. }
  184. }
  185. });
  186. cur_new_county = cur_td.find('input[type="checkbox"]:checked').size();
  187. $('span[city_id="'+cur_td.attr('city_id')+'"]').html(cur_new_county);
  188. if (cur_checkbox.size() == cur_new_county) {
  189. v = true;
  190. } else {
  191. v = false;
  192. }
  193. $('input[value="'+cur_td.attr('city_id')+'"]').prop('checked',v);
  194. if ($('input[ds_province="'+cur_td.attr('province_id')+'"]').size() == $('input[ds_province="'+cur_td.attr('province_id')+'"]:checked').size()) {
  195. $('input[value="'+cur_td.attr('province_id')+'"]').prop('checked',true);
  196. } else {
  197. $('input[value="'+cur_td.attr('province_id')+'"]').prop('checked',false);
  198. }
  199. DialogManager.close('select_county');
  200. });
  201. //表单提交事件
  202. $("#submitBtn").click(function(){
  203. var county_id_str = '';
  204. for(var city_id in CUR_COUNTY) {
  205. for(var county_d in CUR_COUNTY[city_id]) {
  206. if (typeof(CUR_COUNTY[city_id][county_d]) != 'undefined') {
  207. county_id_str += county_d + ',';
  208. }
  209. }
  210. }
  211. $("#county").val(county_id_str);
  212. $("#area_form").submit();
  213. });
  214. });
  215. </script>