{set:$seller_id = $this->seller['seller_id']}
<article class="col-lg-12">
	<div class="card forms">
		<div class="card-header d-flex align-items-center justify-content-between">
			<h3>规格列表</h3>
			<div>
				<input type="button" class="btn btn-primary" onclick="addNewSpec();" value="添加规格" />
				<input type="button" class="btn btn-primary" onclick="selectAll('id[]')" value="全选" />
				<input type="button" class="btn btn-primary" onclick="delModel();" value="批量删除" />
			</div>
		</div>

		<div class="card-body">
			<form action='{url:/seller/spec_del}' method='post' name='specForm' class="form-horizontal">
				<table class="table">
					<colgroup>
						<col width="40px" />
						<col width="150px" />
						<col />
						<col width="100px" />
					</colgroup>

					<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" class="checkbox-template" 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="fa fa-edit fa-lg" title="编辑"></i></a>
								<a href='javascript:void(0)' onclick="delModel({link:'{url:/seller/spec_del/id/$item['id']}'});"><i class="fa fa-close fa-lg" title="删除"></i></a>
							</td>
						</tr>
						{/foreach}
					</tbody>
				</table>
			</form>
			{$queryObj->getPageBar()}
		</div>
	</div>
</article>

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

	art.dialog.open(url, {
		id: 'addSpecWin',
		title: '规格设置',
		okVal: '确定',
	    cancel:true,
	    width:'100%',
	    height:'100%',
		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>