{set:$seller_id = $this->seller['seller_id']}
<article class="col-lg-12">
	<div class="card forms">
		<div class="card-header">
			<h3>拼团编辑</h3>
		</div>
		<div class="card-body">
			<form action="{url:/seller/assemble_update}" method="post" name='assemble_edit' enctype='multipart/form-data' class="form-horizontal">
				<input type='hidden' name='id' />

				<div class="form-group row">
					<label class="col-sm-2 col-form-label">拼团标题</label>
					<div class="col-sm-10">
						<input class="form-control" name='title' pattern='required' alt='请填写团购标题' />
					</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2 col-form-label">是否开启</label>
					<div class="col-sm-10">
					    <div class="form-check form-check-inline">
							<label class="form-check-label"><input type='radio' name="is_close" value="0" checked="checked" class="radio-template form-check-input" />是</label>
					    </div>

					    <div class="form-check form-check-inline">
					        <label class="form-check-label"><input type='radio' name="is_close" value="1" class="radio-template form-check-input" />否</label>
					    </div>
					</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2 col-form-label">设置拼团商品</label>
					<div class="col-sm-10">
						<table class='table'>
							<colgroup>
								<col width="120px" />
								<col />
							</colgroup>

							<input type='hidden' name='goods_id' />

							<tbody id='assemble_box'>
							</tbody>

							<tfoot>
								<tr>
									<td colspan=2>
										<input type='button' class='btn btn-primary' onclick='searchGoods({"seller_id":{$seller_id},"callback":searchGoodsCallback});' value="添加商品" />
										<small class="help-block-none">* 添加要拼团的商品</small>
									</td>
								</tr>
							</tfoot>
						</table>
					</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2 col-form-label">设置拼团成团人数</label>
					<div class="col-sm-10">
						<input class='form-control' name='limit_nums' pattern='^\d{2,}|[2-9]$' placeholder='请填写大于2的正整数值' />
						<small class="help-block-none">* 多少人可以成团，必须大于2以上</small>
					</div>
				</div>

				<div class="form-group row">
					<label class="col-sm-2 col-form-label">介绍</label>
					<div class="col-sm-10">
						<textarea name="intro" style="height:80px;" class="form-control">{$this->assembleRow['intro']}</textarea>
					</div>
				</div>

				<div class="form-group row">
					<div class="col-sm-4 offset-sm-2">
						<input type="submit" class="btn btn-primary" value="确 定" />
						<input type="reset" class="btn btn-secondary" value="重 置" />
					</div>
				</div>
			</form>
		</div>
	</div>
</article>

<script type='text/javascript'>
//输入筛选商品的条件
function searchGoodsCallback(goodsList)
{
	goodsList.each(function()
	{
		var temp = $.parseJSON($(this).attr('data'));
		var content = {
			"data":
			{
				"id":temp.goods_id,
				"name":temp.name,
				"img":temp.img,
				"sell_price":temp.sell_price,
				"img":temp.img,
				"store_nums":temp.store_nums
			}
		};
		relationCallBack(content);
	});
}

//关联商品回调处理函数
function relationCallBack(content,assembleImg)
{
	if(content)
	{
		$('[name="goods_id"]').val(content['data']['id']);
		assembleImg = !assembleImg ? content['data']['img'] : assembleImg;
		var imgUrl  = webroot(assembleImg);

		var html = '<tr><th>商品名称：</th><td>'+content['data']['name']+'</td></tr>'
				  +'<tr><th>展示图片：</th><td><img src="'+imgUrl+'" title="'+content['data']['name']+'" style="max-width:140px;" /><p><input type="file" class="form-control-file" name="img"/></p></td></tr>'
				  +'<tr><th>拼团价格：</th><td><input type="text" class="form-control col-6" name="assemble_price" pattern="float" alt="填写数字" /><small class="help-block-none">目前原价：'+content['data']['sell_price']+'元</small></td></tr>';

		$('#assemble_box').html(html);
	}
}

jQuery(function()
{
	//关联商品信息
	{if:isset($this->assembleRow['goodsRow'])}
	relationCallBack({$this->assembleRow['goodsRow']},"{$this->assembleRow['img']}");
	{/if}

	//表单回填
	var formObj = new Form('assemble_edit');
	formObj.init({echo:JSON::encode($this->assembleRow)});
});
</script>