<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li>
			<i class="home-icon fa fa-home"></i>
			<a href="#">商品</a>
		</li>
		<li>
			<a href="#">规格管理</a>
		</li>
		<li class="active">规格列表</li>
	</ul>
</div>
<div class="content">
	<form action='{url:/goods/spec_del}' method='post' name='specForm'>
		<table class="table list-table">
			<colgroup>
				<col width="35px" />
				<col width="120px" />
				<col />
				<col width="90px" />
			</colgroup>
			<caption>
                <a class="btn btn-default" onclick="addNewSpec()">
                    <i class="fa fa-plus"></i>添加规格
                </a>
                <a class="btn btn-default" onclick="selectAll('id[]')">
                    <i class="fa fa-check"></i>全选
                </a>
                <a class="btn btn-default" onclick="delModel()">
                    <i class="fa fa-close"></i>批量删除
                </a>
                <a class="btn btn-default" href='{url:/goods/spec_recycle_list}'>
                    <i class="fa fa-trash"></i>回收站
                </a>
			</caption>
			<thead>
				<tr>
					<th></th>
					<th>规格名称</th>
					<th>规格数据</th>
					<th>操作</th>
				</tr>
			</thead>

			<tbody>
                {set:$queryObj=Api::run('getListBySpec',array('is_del'=>0));$resultData=$queryObj->find()}
                {foreach:items=$resultData}
				<tr>
					<td><input type="checkbox" name="id[]" value="{$item['id']}" /></td>
					<td>{$item['name']}{echo:$item['note']?"【".$item['note']."】":"";}</td>
					<td>
						{set:$_specValue = JSON::decode($item['value'])}
						{if:$_specValue}
						{foreach:items=$_specValue item=$image key=$value}【{$value}】{/foreach}
						{/if}
					</td>
					<td>
						<a href="javascript:addNewSpec({$item['id']});"><i class='operator fa fa-edit'></i></a>
						<a href='javascript:void(0)' onclick="delModel({link:'{url:/goods/spec_del/id/$item['id']}'});"><i class='operator fa fa-close'></i></a>
					</td>
				</tr>
				{/foreach}
			</tbody>
		</table>
	</form>
</div>
{$queryObj->getPageBar()}

<script type='text/javascript'>
//添加新规格
function addNewSpec(spec_id)
{
	var url = '{url:/goods/spec_edit/id/@spec_id@}';
	url = url.replace('@spec_id@',spec_id?spec_id:0);

	art.dialog.open(url,{
		id:'addSpecWin',
	    title:'规格设置',
	    okVal:'确定',
	    cancel:true,
	    width:'80%',
	    height:'80%',
	    ok:function(iframeWin, topWin){
	    	var formObject = iframeWin.document.forms['specForm'];
	    	if(formObject.onsubmit() == false)
	    	{
	    		return false;
	    	}
			$.post(formObject.action,$(formObject).serialize(),function(json){
				if(json.flag == 'success')
				{
					window.location.reload();
					return true;
				}
				else
				{
					alert(json.message);
					return false;
				}
			},'json');
	    }
	});
}
</script>