<{import file="header.html" title="限时促销"}>
<!--datapiker--> 
<link rel="stylesheet" type="text/css" href="<{$__PUBLIC__}>plug/laydate/need/laydate.css"> 
<link rel="stylesheet" type="text/css" href="<{$__PUBLIC__}>plug/laydate/skins/default/laydate.css"> 
<!--data end---> 
<style type="text/css">
/*图片头像*/
.gs_img{ width:100%; padding:0 0 0 10px; float:left; }
.gs_img img{ max-width:35px; max-height:35px; float:left; }
.gs_img a{ padding:6px 0 0 10px; float:left; }

/*分页*/
.spage{ width:100%; padding:10px 0; text-align:right; float:left; }
.spage a{ padding:5px; background:#f8f8f8; border-radius:1px; margin:0 10px 0 0; }
.spage span a{ background:#39f; padding:2px 3px; line-height:12px; color:#fff; }

/*产品规格*/
table tbody tr td{ padding:0; }
table tbody.sku_box input{ width:38px; padding:2px; border-radius:0; }

.chgs{ width:100%; float:left; }
.chgs a{ padding:5px 10px 4px; border-radius:2px; background:#1583EF; color:#fff; float:left; }
.nogoods{ width:100%; height:20px; float:left; }
</style>
<div class="tab2"><a class="back" href="<{$__SELLER__}>promote/seckill">促销编辑</a></div> 
<div class="baseBox">
	<{uqcms m="promote" v="row" c="seckill_one:id=smarty.get.id"}>
	<form id="form" method="post"> 
		<{if $row.id}><input type="hidden" name="id" id="id" value="<{$row.id}>"/><{/if}>
		<input type="hidden" name="gid" id="gid" value="<{$row.gid}>"/>
		<table class="etable">
			<tr>
				<td width="120">活动名称：</td>
				<td><input type="text" name="name" id="name" value="<{$row.name}>" size="30"/></td>
			</tr>
			<tr>
				<td>活动时间：</td>
				<td><input type="text" name="start_time" id="start_time" size="15" id="text" value="<{$row.start_time}>" autocomplete="off"/></td>
			</tr>
			<{uqcms m="promote" v="tlist" c="seckill_time_range"}>
			<tr>
				<td>时间区间：</td>
				<td>
					<{if $tlist}>
						<{foreach item=i from=$tlist}>
							<label><input type="radio" name="time_range" value="<{$i.start_time}>"<{if $i.start_time == $row.time}> checked="checked"<{/if}>/><{$i.start_time}></label>
						<{/foreach}>
					<{/if}>
				</td>
			</tr>
			<tr>
				<td>产品选择：</td>
				<td>
					<div class="chgs">
						<a href="javascript:;" 
						onclick="goods_edit('选择产品', '<{$__SELLER__}>promote/sk_goods_list');" class="ckgoods" data-page="">选择产品</a>
					</div>
				</td>
			</tr>
			<tr>
				<td valign="top" style="padding-top:21px;">产品规格：</td>
				<td> 
					<table class="ltable" style="width:650px">
						<thead>
							<tr>
								<th>规格</th>
								<th width="60">价格</th>
								<th width="50">库存</th>
								<th width="70">优惠价格</th>
							</tr>
						</thead>
						<tbody class="sku_box">
						<{uqcms m="promote" v="data" c="seckill_goods:gid="|cat:$row.gid}>
						<{if $data}>
							<{foreach item=i from=$data}>
								<tr>
									<td style="text-align:left; padding-left:10px;"><{$i.sku_name}></td>
									<td><{$i.price}></td>
									<td><{$i.stock}></td>
									<td><input type="text" size="5" name="seckill_price[<{$i.id}>]" value="<{$i.act_price}>"/></td>
								</tr>
							<{/foreach}>
						<{else}>	
							<tr>
								<td colspan="4" style="border-bottom:1px solid #efefef;"><div style="width:100%; text-align:center; font-weight:100; padding:10px 0;">请选择产品</div></td>
							</tr>
						<{/if}>	
						</tbody>
					</table> 
				</td>
			</tr> 
			<tr>
				<td>&nbsp;</td>
				<td><input type="submit" name="submit" class="submit" value="保存"/></td>
			</tr>
		</table>
	</form> 
</div>
<{import file="footer.html"}>  
<script type="text/javascript" src="<{$__PUBLIC__}>plug/laydate/laydate.js"></script>
<script type="text/javascript"> 
function goods_edit(name,url){
	ajax_dialog(name, url, 800, 500); 
}
laydate({elem:'#start_time', format:'YYYY-MM-DD', max:'2099-06-16', istime:true, 
		choose:function(datas){
			end.min = datas; 
			end.start = datas 
		}}); 
$(function(){ 
	// 保存
	$("form").submit(function(){ 
		var name = $("#name").val();
		if(name == ''){
			$.alert('活动名称不能为空');	return false; 
		}
	 	$.ajax({
			type:'POST',
			url:SELLER+'promote/seckill_save',
			data:$("#form").serialize(),
			success:function(result){ 
				var data = jQuery.parseJSON(result); 
				if(data.error == 0){
					$.alert('保存成功', function(){
						location.href=SELLER+"promote/seckill";
					});
				}else{ 
					$.alert(data.msg); 
				}
			},error:function(){
				$.alert('错误');
			}
		}); 
		return false;
 	});
	
	// 双击覆盖
	$(document).on('dblclick', 'table tbody.sku_box tr td input', function(){ 
		price = $(this).val();
		$("table tbody.sku_box tr td input").val(price);
	});
});
</script>