offpay_area.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. {extend name="default/base/base_seller" /}
  2. {block name="seller_main"}
  3. <div class="alert alert-block mt10">
  4. <ul>
  5. <li>{$Think.lang.notes_district_settings1}</li>
  6. <li>{$Think.lang.notes_district_settings2}</li>
  7. </ul>
  8. </div>
  9. <style>
  10. #table_area_box td {text-align:left;}
  11. .area-list {display:inline-block;width:200px;padding:5px 0px;}
  12. </style>
  13. <form id="area_form" method="post">
  14. <input type="hidden" name="county" id="county" value="" />
  15. <table class="dssc-default-table order" id="table_area_box">
  16. <tbody>
  17. <?php foreach ($areas['children'][0] as $provinceId) { ?>
  18. <tr>
  19. <td class="w120">
  20. <label>
  21. <input type="checkbox"<?php if (array_key_exists($provinceId, $province_checked_array)) echo ' checked="checked"'; ?> value="{$provinceId}" name="province[]" />
  22. <strong><?php echo $areas['name'][$provinceId]; ?></strong>
  23. </label>
  24. </td>
  25. <td>
  26. <?php foreach ($areas['children'][$provinceId] as $cityId) { ?>
  27. <div class="area-list">
  28. <label>
  29. <input type="checkbox" ds_province="{$provinceId}" {present name="city_checked_array[$cityId]"}checked="checked"{/present} value="{$cityId}" name="city[]" />
  30. {$areas['name'][$cityId]}
  31. </label>
  32. (<span city_id="{$cityId}" title="{$Think.lang.selected_lower_region}">{present name="city_checked_child_array[$cityId]"}{:count($city_checked_child_array[$cityId])}{/present}</span>)
  33. <a city_id="{$cityId}" ds_title="" province_id="{$provinceId}" ds_type="edit" href="javascript:void(0);" title="{$Think.lang.choose_lower_region}"><i class="iconfont">&#xe731;</i></a>
  34. </div>
  35. <?php } ?>
  36. </td>
  37. </tr>
  38. <?php } ?>
  39. </tbody>
  40. <tfoot>
  41. <tr class="tfoot">
  42. <td colspan="15">
  43. <div class="tc mt10 mb10">
  44. <a href="javascript:void(0);" class="dssc-btn dssc-btn-green" id="submitBtn"><span>{$Think.lang.submit_save}</span></a>
  45. </div>
  46. </td>
  47. </tr>
  48. </tfoot>
  49. </table>
  50. </form>
  51. <script type="text/javascript">
  52. var ds_a = $.parseJSON('{$area_array_json|raw}');
  53. //将系统已选择的县ID放入JS数组
  54. var CUR_COUNTY = new Array();
  55. {notempty name="city_checked_child_array"}
  56. {foreach name="city_checked_child_array" item="county_ids" key="city_id"}
  57. CUR_COUNTY[{$city_id}] = new Array();
  58. {foreach name="county_ids" item="v"}
  59. CUR_COUNTY[{$city_id}][{$v}] = true;
  60. {/foreach}
  61. {/foreach}
  62. {/notempty}
  63. $(function(){
  64. //省点击事件
  65. $('input[name="province[]"]').on('click',function(){
  66. if ($(this).prop('checked')){
  67. $('input[ds_province="' + $(this).val() + '"]').each(function(){
  68. $(this).prop('checked','checked');
  69. if (typeof ds_a[$(this).val()] == 'object') {
  70. county_array = ds_a[$(this).val()];
  71. } else {
  72. county_array = new Array();
  73. }
  74. CUR_COUNTY[$(this).val()] = new Array();
  75. for(i = 0; i < county_array.length; i++) {
  76. CUR_COUNTY[$(this).val()][county_array[i][0]] = true;
  77. }
  78. count = county_array.length;
  79. $('span[city_id="'+$(this).val()+'"]').html(count);
  80. });
  81. }else{
  82. $('input[ds_province="' + $(this).val() + '"]').each(function(){
  83. $(this).prop('checked',false);
  84. CUR_COUNTY[$(this).val()] = undefined;
  85. $('span[city_id="'+$(this).val()+'"]').html(0);
  86. });
  87. }
  88. });
  89. //点击编辑事件
  90. $('a[ds_type="edit"]').on('click',function(){
  91. if (typeof CUR_COUNTY[$(this).attr('city_id')] == 'object'){
  92. cur_county = CUR_COUNTY[$(this).attr('city_id')];
  93. }else{
  94. cur_county = new Array();
  95. }
  96. var province_array = ds_a[$(this).attr('city_id')];
  97. if (typeof ds_a[$(this).attr('city_id')] == 'object'){
  98. county_array = ds_a[$(this).attr('city_id')];
  99. }else{
  100. county_array = new Array();
  101. }
  102. if (county_array.length == 0) {
  103. layer.msg('{$Think.lang.no_editing_required}');
  104. return;
  105. }
  106. 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')+'">';
  107. for(i = 0; i < county_array.length; i++){
  108. county_html += '<label style="display:inline-block;width:100px;padding:5px 10px;"><input type="checkbox"';
  109. if (typeof(cur_county[county_array[i][0]]) != 'undefined') {
  110. county_html += ' checked ' ;
  111. }
  112. county_html += (' value="'+county_array[i][0]+'" name="county[]">' + county_array[i][1] + '</label>');
  113. }
  114. county_html += '</td></tr><tr><td style="padding:5px;"><a id="county_submit" class="dssc-btn dssc-btn-green" href="javascript:void(0);"><span>{$Think.lang.ds_common_button_confirm}</span></a> <span style="color:#f30;">{$Think.lang.complete_save_operation}</span></td></tr></tbody></table>';
  115. html_form('select_county', '{$Think.lang.ds_common_button_select} '+ $(this).attr('ds_title') +' {$Think.lang.sub_region}', county_html, 500,1);
  116. });
  117. //选择市级事件
  118. $('input[name="city[]"]').on('click',function(){
  119. if ($(this).prop('checked')) {
  120. if (typeof ds_a[$(this).val()] == 'object') {
  121. county_array = ds_a[$(this).val()];
  122. } else {
  123. county_array = new Array();
  124. }
  125. CUR_COUNTY[$(this).val()] = new Array();
  126. for(i = 0; i < county_array.length; i++) {
  127. CUR_COUNTY[$(this).val()][county_array[i][0]] = true;
  128. }
  129. count = county_array.length;
  130. if ($('input[ds_province="'+$(this).attr('ds_province')+'"]').size() == $('input[ds_province="'+$(this).attr('ds_province')+'"]:checked').size()) {
  131. $('input[value="'+$(this).attr('ds_province')+'"]').prop('checked',true);
  132. } else {
  133. $('input[value="'+$(this).attr('ds_province')+'"]').prop('checked',false);
  134. }
  135. } else {
  136. CUR_COUNTY[$(this).val()] = undefined;
  137. count = 0;
  138. $('input[value="'+$(this).attr('ds_province')+'"]').prop('checked',false);
  139. }
  140. $('span[city_id="'+$(this).val()+'"]').html(count);
  141. });
  142. //弹出县编辑确认事件
  143. $('body').on('click','#county_submit',function(){
  144. cur_td = $('.dialog_content > table > tbody > tr > td');
  145. cur_checkbox = cur_td.find('input[type="checkbox"]');
  146. cur_checkbox.each(function(){
  147. if ($(this).prop('checked')) {
  148. if (typeof CUR_COUNTY[cur_td.attr('city_id')] != 'object') {
  149. CUR_COUNTY[cur_td.attr('city_id')] = new Array();
  150. }
  151. CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] = true;
  152. } else {
  153. if (typeof CUR_COUNTY[cur_td.attr('city_id')] == 'object') {
  154. if (typeof CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] != 'undefined') {
  155. CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] = undefined;
  156. }
  157. }
  158. }
  159. });
  160. cur_new_county = cur_td.find('input[type="checkbox"]:checked').size();
  161. $('span[city_id="'+cur_td.attr('city_id')+'"]').html(cur_new_county);
  162. if (cur_checkbox.size() == cur_new_county) {
  163. v = true;
  164. } else {
  165. v = false;
  166. }
  167. $('input[value="'+cur_td.attr('city_id')+'"]').prop('checked',v);
  168. if ($('input[ds_province="'+cur_td.attr('province_id')+'"]').size() == $('input[ds_province="'+cur_td.attr('province_id')+'"]:checked').size()) {
  169. $('input[value="'+cur_td.attr('province_id')+'"]').prop('checked',true);
  170. } else {
  171. $('input[value="'+cur_td.attr('province_id')+'"]').prop('checked',false);
  172. }
  173. DialogManager.close('select_county');
  174. });
  175. //表单提交事件
  176. $("#submitBtn").click(function(){
  177. var county_id_str = '';
  178. for(var city_id in CUR_COUNTY) {
  179. for(var county_d in CUR_COUNTY[city_id]) {
  180. if (typeof(CUR_COUNTY[city_id][county_d]) != 'undefined') {
  181. county_id_str += county_d + ',';
  182. }
  183. }
  184. }
  185. $("#county").val(county_id_str);
  186. ds_ajaxpost('area_form')
  187. });
  188. });
  189. </script>
  190. {/block}