<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">
	<table class="table list-table">
		<colgroup>
			<col width="70px" />
			<col />
			<col width="220px" />
			<col width="220px" />
			<col width="150px" />
		</colgroup>
		<caption>
            <a class="btn btn-default" href="{url:/brand/brand_edit}">
                <i class="fa fa-plus"></i>添加品牌
            </a>
			<form name="searchbrand" action="{url:/}" method="get" class="pull-right form-inline">
				<input type='hidden' name='controller' value='brand' />
				<input type='hidden' name='action' value='brand_list' />
				<input class="form-control" name="search" type="text" value="{$search}" placeholder="品牌名称" />

				<button class="btn btn-default" type="submit">
                    <i class="fa fa-search"></i>搜 索
                </button>
			</form>
		</caption>
		<thead>
			<tr>
				<th>排序</th>
				<th>品牌名称</th>
				<th>网址</th>
				<th>品牌分类</th>
				<th>操作</th>
			</tr>
		</thead>

		<tbody>
            {set:$queryObj=Api::run('getListByBrand',['name' => $search]);$resultData=$queryObj->find()}
            {foreach:items=$resultData}
			<tr>
				<td><input class="form-control" id="sort{$item['id']}" type="text" onblur="toSort({$item['id']});" value="{$item['sort']}" pattern='int' /></td>
				<td><a href="{url:/site/brand_zone/id/$item['id']}" target="_blank">{$item['name']}</a></td>
				<td>{$item['url']}</td>
				<td>
				{foreach:items = explode(',',$item['category_ids']) item = $val}
				[{$catAll[$val]}]
				{/foreach}
				</td>
				<td>
                    <a href="{url:/brand/brand_edit/bid/$item['id']}"><i class='operator fa fa-edit'></i></a>
                    <a onclick="delModel({link:'{url:/brand/brand_del/bid/$item['id']}'})"><i class='operator fa fa-close'></i></a>
                </td>
			</tr>
			{/foreach}
		</tbody>
	</table>
</div>
{$queryObj->getPageBar()}

<script language="javascript">
//排序
function toSort(id)
{
	if(id!='')
	{
		var va = $('#sort'+id).val();
		var part = /^\d+$/i;
		if(va!='' && va!=undefined && part.test(va))
		{
			$.get("{url:/goods/brand_sort}",{'id':id,'sort':va}, function(data)
			{
				if(data=='1')
				{
					alert('修改商品品牌排序成功!');
				}else
				{
					alert('修改商品品牌排序错误!');
				}
			});
		}
	}
}
</script>