<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><string:message="menu.consignee_info_set" /></title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
   	<link href="<%=basePath %>resource/css/base.css" rel="stylesheet">
    <link href="<%=basePath %>resource/css/basic_info.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=basePath %>resource/easyui/uimaker/icon.css">
    <link rel="stylesheet" href="<%=basePath %>resource/easyui/uimaker/easyui.css">
    <link rel="stylesheet" href="<%=basePath %>resource/css/form.css">
    <script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate.js"></script>
    <script type="text/javascript" src="<%=basePath %>resource/validate/validate-extends.js"></script>
    <script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="<%=basePath %>resource/easyui/easyui-lang-${pageContext.response.locale}.js"></script>
    <script type="text/javascript" src="<%=basePath %>resource/js/tools.js"></script>
	<!--弹出层引入的JS-->
	<script type="text/javascript" src="<%=basePath %>resource/layer-v3.0.3/layer/layer.js"></script>
    
    
    <style type="text/css">
    	.required_span{
    		color:red;
    		margin-left:10px;
    		font-size:20px;
    	}
    </style>
   	    <!-- validate 验证中英文 -->
    <script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate-${pageContext.response.locale}.js"></script>
</head>
<body>
	<div class="container">
	    <table id="dg" style="width:100%;" title='<spring:message code="role.list"/>'
	    data-options="
	                rownumbers:true,
	                singleSelect:false,
	                autoRowHeight:false,
	                pagination:true,
	                fitColumns:true,
	                striped:true,
	                collapsible:true,
	                toolbar:'#tb',
	                pageSize:10" >
	        <thead>
	        <tr>
	        	<th field="id" checkbox="true"></th>
                <th field="."  formatter="editFormat" width="40"><spring:message code="opt.edit" /></th>
	        	<th field="code" width="100"><spring:message code="consignee.code"/></th>
	        	<th field="name" width="100"><spring:message code="consignee.name"/></th>
	        	<th field="address" width="100"><spring:message code="consignee.address"/></th>
	        	<th field="tel" width="50"><spring:message code="consignee.tel"/></th>
	        </tr>
	        </thead>
	    </table>
        <div id="tb" style="padding:0 30px;"> <input type="hidden" id="idcc">
	        <form id="searchForm">
		        <table class="search_form_table">
		              <a href="javascript:editRow()" class="easyui-linkbutton" style="background:#18A197;color:#FFF;border: 1px solid #18A197;" iconCls="icon-add"><spring:message code="opt.add" /></a>
		              <a href="javascript:doDelete()" class="easyui-linkbutton" style="background:red;color:#FFF;border: 1px solid red" iconCls="icon-no"><spring:message code="opt.delete" /></a>
		              
		        </table>
	        </form>
        </div>
	</div>
	
	<script>
		<%-- $.ajax({
			url:"<%=basePath %>consignee/grid.json",
			success:function(data){
				console.log(data);
			}
		}); --%>
		$(function(){
			$("#dg").datagrid({
				url:"<%=basePath %>consignee/grid.json",
				/* queryParams:$("#searchForm").serializeJson(), */
				onLoadSuccess:function(data){
					console.log("load data success!");
				}
			});
		});
		
		function editFormat(val, row, index){
			console.log(row);
			return '<a href="javascript:void(0)" style="padding-left:10px;text-decoration:none;padding-right:20px;" onclick="editRow('+row.id+')"><i class="iconfont">&#xe65a;</i></a>';
		}
		function editRow(id){
			if(typeof(id) == "undefined")
				window.location.href = "<%=basePath %>/consignee/edit";
			else
				window.location.href = "<%=basePath %>/consignee/edit?id="+id;
		}
		   function doDelete(){
		        var rows = $("#dg").datagrid('getChecked');
		        if(rows.length==0){
		            layer.open({content:"请先选中要删除的行"});
		            return false;
		        }
		        layer.confirm("确定要删除么?",{btn:['确定','取消']}, function () {
		            $.post("<%=basePath%>consignee/delete",{ids:getIds().join(",")},function(data){
		                if(data.status == 200) {
		                    layer.confirm("删除成功!",{btn:['确定','取消']},function(){
		                        window.location.href="<%=basePath%>consignee/list";
		                    })
		                }else{
		                    layer.open({content:"删除失败!"});
		                }
		            },"json");

		        });
		    }
	</script>
</body>
</html>