var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		id : 'paging',
		l_column : [ {
			colkey : "ordId",
			width : "150px",
			name : "订单号"
		}, {
			colkey : "uname",
			name : "客户名称",
			width:"100px"
				
		}, {
			colkey : "phone",
			name : "电话",
			align: "left",
			width:"120px"
		}, {
			colkey : "pname",
			name : "商品名称",
		}, {
			colkey : "amount",
			name : "数量(件)",
			width:"80px"
		}, {
			colkey : "price",
			name : "单价（元）",
			width:"100px"
		}, {
			colkey : "freight",
			name : "运费（元）",
			width:"100px"
		}, {
			colkey : "style",
			name : "款式/尺码",
		}, {
			colkey : "createTime",
			name : "下单时间",
		}, {
			colkey : "addr",
			name : "联系地址",
		}, {
			colkey : "sum",
			name : "总金额（元￥）",
		}, {
			colkey : "ordStatus",
			name : "订单状态",
			renderData : function( rowindex ,data, rowdata, colkeyn) {
				if(rowdata.ordStatus=='UnConfirm'){
					return "等待确认";
				}else if(rowdata.ordStatus=='HasConfirm'||rowdata.ordStatus=='WaitShipped'){
					return "已确认，等待发货";
				}else if (rowdata.ordStatus=='Shipped'){
					return "已发货";
				}else if (rowdata.ordStatus=='stockout'){
					return "<span style='color:red;'>库存不足</span>";
				}else if(rowdata.ordStatus=='Finished'){
					return "交易完成";
				}else if(rowdata.ordStatus=='Cancle'){
					return "取消订单";
				}else{
					return "--";
				}
			}
		}],
		jsonUrl : rootPath + '/fastord/search.shtml',
		checkbox : true,
		serNumber : false,
		checkValue:'ordId'
	});

	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();// 初始化传参数
		grid.setOptions({
			data : searchParams
		});
	});
	
	$("#editBtn").click("click", function() {
		edit();
	});


});

function edit() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "订单详情",
		type : 2,
		area : [ "650px", "60%" ],
		content : rootPath + '/order/editUI.shtml?ordId=' + cbox
	});
}

