<extend name="Public:base" />
<block name="content">
<link rel="stylesheet" href="__CSS__/transport.css" />	

<div class="page-header">
		<h1>
			{$breadcrumb2}
			<small>
				<i class="icon-double-angle-right"></i>
				{$crumbs}
			</small>
		</h1>
	</div>
<div class="row">
	<div class="col-xs-12">	
	<div id="append_parent"></div>
	<div class="ncsc-form-default">
  <form method="post" id="tpl_form" name="tpl_form" action='{:U("Transport/save")}'>
    <input type="hidden" name="transport_id" value="{$output['transport'].id|default=''}" />
    <input type="hidden" name="form_submit" value="ok" />
    <?php $unit=get_weight_name(C('WEIGHT_ID')); ?>
    <dl>
      <dt>
        <label for="J_TemplateTitle" class="label-like">模版名称</label>
      </dt>
      <dd>
        <input type="text"  class="text"  id="title" autocomplete="off"  value="{$output['transport'].title|default=''}" name="title">
        <p class="J_Message" style="display:none" error_type="title"><i class="icon-exclamation-sign"></i>必须填写模板名称</p>
      </dd>
    </dl>
    <dl>
      <dt>运送方式</dt>
      <dd>除指定地区外，其余地区的运费采用"默认运费"</dd>
    </dl>

    <!-----------------------POST begin--------------------------------------->
    <dl>
      <dt></dt>
      <dd class="trans-line">
      </dd>
    </dl>
    <div class="bottom">
      <label class="submit-border"><input type="submit" id="submit_tpl" class="submit" value="保存" /></label>
    </div>
  </form>
  <div class="ks-ext-mask" style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; z-index: 999; display:none"></div>
  <div id="dialog_areas" class="dialog-areas" style="display:none">
    <div class="ks-contentbox">
      <div class="title">选择区域<a class="ks-ext-close" href="javascript:void(0)">X</a></div>
      <form method="post">
        <ul id="J_CityList">
          
          <include file="Transport:transport_area"/>
        </ul>
        <div class="bottom"> <a href="javascript:void(0);" class="J_Submit ncsc-btn ncsc-btn-green">确定</a> <a href="javascript:void(0);" class="J_Cancel ncsc-btn">取消</a> </div>
      </form>
    </div>
  </div>
  <div id="dialog_batch" class="dialog-batch" style="z-index: 9999; display:none">
    <div class="ks-contentbox">
      <div class="title">批量操作<a class="ks-ext-close" href="javascript:void(0)">X</a></div>
      <form method="post">
        <div class="batch">默认运费：
        <input class="w30 mr5 text" type="text" maxlength="4" autocomplete="off" data-field="start" value="1" name="express_start">
        <?php echo $unit; ?>内
        <input class="w60 text" type="text" maxlength="6" autocomplete="off" value="0.00" name="express_postage" data-field="postage"><em class="add-on"> <i class="icon-renminbi"></i> </em>，每增加
        <input class="w30 mr5 text" type="text" maxlength="4" autocomplete="off" value="1" data-field="plus" name="express_plus">
        <?php echo $unit; ?>，增加运费
        <input class="w60 text" type="text" maxlength="6" autocomplete="off" value="0.00" data-field="postageplus" name="express_postageplus"><em class="add-on"> <i class="icon-renminbi"></i> </em></div>
        <div class="J_DefaultMessage"></div>
        <div class="bottom"> <a href="javascript:void(0);" class="J_SubmitPL ncsc-btn ncsc-btn-green">确认</a> <a href="javascript:void(0);" class="J_Cancel ncsc-btn">取消</a> </div>
      </form>
    </div>
  </div>
</div>
		
	</div>
</div>
</block>

<block name="javascript">

<script src="__JS__/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>
<link rel="stylesheet" href="__JS__/dialog/dialog.css" />	

<js href="__JS__/transport.js" />	

<script>

var unit ='<?php echo $unit; ?>';

$(function(){
	$('.trans-line').append(TransTpl.replace(/TRANSTYPE/g,'kd'));
	$('.tbl-except').append(RuleHead);
	<?php if (isset($output['extend'])&&is_array($output['extend'])){?>
	<?php foreach ($output['extend'] as $value){?>

		<?php if ($value['is_default']==1){?>

			var cur_tr = $('.tbl-except').prev();
			$(cur_tr).find('input[data-field="start"]').val('<?php echo $value['snum'];?>');
			$(cur_tr).find('input[data-field="postage"]').val('<?php echo $value['sprice'];?>');
			$(cur_tr).find('input[data-field="plus"]').val('<?php echo $value['xnum'];?>');
			$(cur_tr).find('input[data-field="postageplus"]').val('<?php echo $value['xprice'];?>');							

		<?php }else{?>

			StartNum +=1;
			cell = RuleCell.replace(/CurNum/g,StartNum); 
			cell = cell.replace(/TRANSTYPE/g,'kd');
			$('.tbl-except').find('table').append(cell);
			$('.tbl-attach').find('.J_ToggleBatch').css('display','').html('批量操作');

			var cur_tr = $('.tbl-except').find('table').find('tr:last');
			$(cur_tr).find('.area-group>p').html('<?php echo $value['area_name'];?>');
			$(cur_tr).find('input[type="hidden"]').val('<?php echo trim($value['area_id'],',');?>|||<?php echo $value['area_name'];?>');
			$(cur_tr).find('input[data-field="start"]').val('<?php echo $value['snum'];?>');
			$(cur_tr).find('input[data-field="postage"]').val('<?php echo $value['sprice'];?>');
			$(cur_tr).find('input[data-field="plus"]').val('<?php echo $value['xnum'];?>');
			$(cur_tr).find('input[data-field="postageplus"]').val('<?php echo $value['xprice'];?>');

		<?php }?>
	<?php }?>
	<?php }?>
});
</script>
</block>