$(function(){

	$("#submitBtn").click(function(){

		var typeId = $("#typeId").val();
		var name = $("#name").val();
		var icon = $("#icon").val();
		var supId = $("#supId").val();
		var sortv =$("#sortv").val();
		
		var params = {
				typeId:typeId,
				name:name,
				icon:icon,
				supId:supId,
				sortv:sortv
		};

		var	_httpURL = HttpRest+"/prod/type/save.shtml";
		if(typeId==undefined ||typeId==''||typeId=='0'){
			_httpURL = HttpRest+"/prod/type/create.shtml";
		}
		$.ajax({
			url: _httpURL, 
			type: "post", 
			dataType: "json",
			data:$.toJSON(params),   
			contentType:"application/json",
			success: function(data) { 
				if(data.code=='01'){
					layer.confirm('保存成功！是否关闭窗口?', function(index) {
						parent.grid.loadData();
						parent.layer.close(parent.pageii);
						return false;
					});
				}else{
					layer.msg('保存失败！',{icon: 5});
				}
			}
		});
	});

	onloadurl();
});