<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/other/kingedit/themes/default/default.css" rel="stylesheet" type="text/css" />
<title>添加商品</title>
<style>
	.ke-container.ke-container-default{width:740px!important;height:300px!important;}
</style>
</head>
<body>
<div class="pd-20">
	<form action="${pageContext.request.contextPath }/admin/product/add" class="form form-horizontal" id="form-addGoods" method="POST" enctype="multipart/form-data">
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>产品名称：</label>
			<div class="formControls col-3">
				<input id="productName" name="productName" type="text" class="input-text" value="" placeholder="" >
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>产品类型：</label>
			<div class="formControls col-3">
				<span class="select-box">
					<select id="typeId" name="productType.typeId" class="select">
						<c:forEach items="${typeList}" var="type" varStatus="status">
							<option value="${type.typeId}">${type.typeName }</option>
						</c:forEach>
		            </select>
	            </span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>产品颜色：</label>
			<div class="formControls col-8">
				<table class="table table-border table-bordered table-bg" id="example">
					<thead>
					<tr class="text-c">
						<!-- <th width="25"><input type="checkbox" name="" value=""></th> -->
						<th width="150">封面图</th>
						<th width="150">颜色名称</th>
						<th width="150">颜色简述</th>
						<th width="150">状态</th>
						<th width="100">市场价（元）</th>
						<th width="100">销售价（元）</th>
						<th width="100">69码</th>
						<th width="100">PTS产品</th>
						<th width="100">操作</th>
					</tr>
					</thead>
					<tbody id="colorTableId">
					<%--<tr class="text-c">
						<td><img src=""></td>
						<td>樱花粉</td>
						<td>美妙不可方物</td>
						<td>在售</td>
						<td>499.00</td>
						<td>399.00</td>
						<td>3792387283</td>
						<td>SD01-xx</td>
					</tr>--%>
					</tbody>
				</table>
				<input id="addColor" style="margin-top: 10px;" onclick="showAddColor();" class="btn btn-primary radius upload-btn" type="button" value="添加颜色" />
				<input id="addColor2"  style="margin-top: 10px;display: none" onclick="hideAddColor();" class="btn btn-primary radius upload-btn" type="button" value="关闭添加颜色" />
				<div id="addcolorDiv" style="display: none">
				<div  class="row cl">
					<label class="form-label col-2"><span class="c-red">*</span>产品图片：</label>
					<div class="col-10 ">
						<img alt="产品图片" src="${pageContext.request.contextPath }/common/images/noImage.jpg" id="introduceImg" width="90" height="80">
						<input type="hidden" id="productIntroduceImg" name="productIntroduceImg" value=""/>
						<input id="insertfileIntroduce" class="btn btn-primary radius upload-btn" type="button" value="点击上传（330 px * 280 px）" />
					</div>
				</div>
				<div  class="row cl">
					<label class="form-label col-2 colorName"><span class="c-red">*</span>颜色名称：</label>
					<div class="formControls col-3">
						<input type="text" name="colorName" id="colorName" placeholder="" value="" class="input-text" style="">
					</div>
					<label class="form-label col-2 colorName"><span class="c-red">*</span>颜色简述：</label>
					<div class="formControls col-3">
						<input type="text" name="colorPresent" id="colorPresent" placeholder="" value="" class="input-text" style="">
					</div>
				</div>
				<div  class="row cl">
					<label class="form-label col-2 colorName"><span class="c-red">*</span>颜色状态：</label>
					<div class="formControls col-3">
						<select id="colorStatus" name="colorStatus" class="select" style="height: 31px;">
							<option value="1">在售</option>
							<option value="2">停止销售</option>
							<option value="3">删除</option>
						</select>
					</div>
				</div>
				<div  class="row cl">
					<label class="form-label col-2 colorName"><span class="c-red">*</span>市场价：</label>
					<div class="formControls col-3">
						<input type="text" name="colorPrice" id="colorPrice" placeholder="" value="" class="input-text" style="">
					</div>
					<label class="form-label col-2 colorName"><span class="c-red">*</span>销售价：</label>
					<div class="formControls col-3">
						<input type="text" name="colorDiscount" id="colorDiscount" placeholder="" value="" class="input-text" style="">
					</div>
				</div>
				<div  class="row cl">
					<label class="form-label col-2 colorName"><span class="c-red">*</span>产品69码：</label>
					<div class="formControls col-3">
						<input type="text" name="color69Code" id="color69Code" placeholder="" value="" class="input-text" style="">
					</div>
				</div>
				<div  class="row cl">
					<label class="form-label col-2 colorName"><span class="c-red">*</span>PTS产品：</label>
					<div class="formControls col-3">
						<select id="ptsProductid" name="ptsProductid" class="select" style="height: 31px;">
							<c:forEach items="${toothInfo}" var="toothInfo">
								<option value="${toothInfo.produceId}">${toothInfo.produceName }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="row cl">
					<div class="col-10 col-offset-2">
						<!-- <button onClick="return admin_addGoods();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button> -->
						<button onClick="addColorTable();" class="btn btn-primary radius" type="button">
							<i class="Hui-iconfont">&#xe632;</i>确认添加
						</button>
					</div>
				</div>
				</div>
			</div>
		</div>
		<div  class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>产品banner图：</label>
			<div class="col-10 " id="bannerInfo">
				<div style="float: left;margin-right: 10px; margin-bottom: 10px;" class="bannerImageList">
					<img alt="请上传banner图" src="" id="bannerImg" width="90" height="80" onclick="removes(this)">
					<input type="hidden" id="productBannerImg" name="productBannerImg" value=""/>
				</div>
				<%--<input type="button" id="insertfileBanner" value="选择文件" />--%>
			</div>
		</div>

		<div id="spots" class="row cl">
			<label class="form-label col-2"></label>
			<input id="addBannerimages" class="btn btn-primary radius upload-btn" type="button" value="新增banner图" />
		</div>
		<div class="row cl" id="iamgeTextDiv">
			<label class="form-label col-2">商品图文：</label>
			<div class="formControls col-9">
				<textarea id="productsInfoProductdesc" name="productImageText.imagetextContext" cols="" rows="" class="textarea" ></textarea>
			</div>
		</div>



		<div class="row cl">
			<div class="col-10 col-offset-2">
				<!-- <button onClick="return admin_addGoods();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button> -->
				<button onClick="checkProduct();" class="btn btn-primary radius" type="button">
					<i class="Hui-iconfont">&#xe632;</i>保存
				</button>
			</div>
		</div>
		<!-- 已售数量 -->
		<input type="hidden" name="productSalesnum" value="0">
		<!-- 浏览量 -->
		<input type="hidden" name="productAccessnum" value="0">
		<input type="hidden" name="colorLists" id="colorLists">
		</form>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/tips.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/ueditor.all.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/ueditor.config.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/js/utils/tools.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/js/utils/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/other/kingedit/kindeditor.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/other/kingedit/lang/zh_CN.js"></script> 	
<script type="text/javascript">
<!-- 注册文本编辑器 -->
KindEditor.ready(function(K) {
       window.editor = K.create('#productsInfoProductdesc',{
       	fileManagerJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/file_manager_json.jsp',
           uploadJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/upload_json.jsp',
            allowFileManager : true,
            afterBlur: function(){this.sync();},
            width : '740px',
		    height : '300px'
        });
});

//上传介绍图
KindEditor.ready(function(K) {
	var editor = K.editor({
    	fileManagerJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/file_manager_json.jsp',
        uploadJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/upload_json.jsp',
		allowFileManager : true
	});
	K('#insertfileIntroduce').click(function() {
	     var imgid = $(this).attr("id");//获取当前ID
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				showRemote : false,
				imageUrl : K('#productIntroduceImg').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#introduceImg').attr("src",url);
					K('#productIntroduceImg').val(url);
					editor.hideDialog();
					return false; 
				}
			});
		});
	}); 
	
	K('#insertfileBanner').click(function() {
	     var imgid = $(this).attr("id");//获取当前ID
		editor.loadPlugin('image', function() {
			editor.plugin.imageDialog({
				showRemote : false,
				imageUrl : K('#productBannerImg').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#bannerImg').attr("src",url);
					K('#productBannerImg').val(url);
					editor.hideDialog();
					return false; 
				}
			});
		});
	});

	//添加banner图片
    K('#addBannerimages').click(function() {
        // var imgid = $(this).attr("id");//获取当前ID
		var bannerIamLength = $(".bannerImageList").length;
		var bannerImageDom,productBannerImgDom;
		var flag = false;
		if(bannerIamLength == 1){
		    var bannerSrc = $(".bannerImageList").eq(0).find("#bannerImg").attr("src");
			if(bannerSrc == null || bannerSrc == "" || bannerSrc == undefined || typeof(bannerSrc) == "undefined"){
                bannerImageDom = $(".bannerImageList").eq(0).find("#bannerImg");
                productBannerImgDom = $(".bannerImageList").eq(0).find("#productBannerImg");
                flag = true;
			}
		}
        editor.loadPlugin('image', function() {
            editor.plugin.imageDialog({
                showRemote : false,
                imageUrl : K('#productBannerImg').val(),
                clickFn : function(url, title, width, height, border, align) {
                    if(flag) {
						K(bannerImageDom).attr("src",url);
						K(productBannerImgDom).val(url);
                    }else{
                        var bannerHtml = '<div style="float: left;margin-right: 10px; margin-bottom: 10px;" class="bannerImageList">' +
                            '<img alt="产品banner图" src="' + url + '" id="bannerImg" width="90" height="80" onclick="removes(this)">' +
                            '<input type="hidden" id="productBannerImg" name="productBannerImg" value="' + url + '"/></div>';
                        K(bannerInfo).append(bannerHtml);
					}

					if($(".bannerImageList").length >= 10){
                        $("#addBannerimages").hide();
					}
					editor.hideDialog();
                    return false;
                }
            });
        });
    });
});

function toAddColorDiv(obj){
	var index = $('.colorName').length;
	if(index >= 9) {
		$("#addColorBtn").hide();
	}
	if(index > 1){
		$("#deleteColorBtn_" + (index-1)).hide();		
	}
	$('#iamgeTextDiv').before(
			'<div class="row cl colorListDiv">'
			+ '<label class="form-label col-2 colorName"><span class="c-red">*</span>颜色名称：</label>'
			+ '<div class="formControls col-1">'
			+ '<input type="text" name="colorList[' + index + '].colorName" id="" placeholder="" value="" class="input-text" style="width:90%"></div>'
			+ '<label class="form-label col-1"><span class="c-red">*</span>颜色69码：</label>'
			+ '<div class="formControls col-1">'
			+ '<input type="text" name="colorList[' + index + '].color69Code" id="" placeholder="" value="" class="input-text" style="width:90%"></div>'
			+ '<label class="form-label col-1"><span class="c-red">*</span>原价(元)：</label>'
			+ '<div class="formControls col-1">'
			+ '<input id="colorPrice' + index + '" type="text" name="colorList[' + index + '].colorPrice" id="" placeholder="" value="" class="input-text" style="width:90%"></div>'
			+ '<label class="form-label col-2"><span class="c-red">*</span>折扣价(元)：</label>'
			+ '<div class="formControls col-1">'
			+ '<input id="colorDiscount' + index + '" type="text" name="colorList[' + index + '].colorDiscount" id="" placeholder="" value="" class="input-text" style="width:90%"></div>'
			+ '<span class="l" id="deleteColorBtn_' + index + '"><a href="javascript:;" onclick="deleteDiv(this,' + index + ')" class="btn btn-danger radius">删除颜色</a>&nbsp;</span>'
		+ '</div>'
		
	)
}
function deleteDiv(obj,index){
	$(obj).parent().parent().remove();
	$("#addColorBtn").show();
	if(index > 1){
		$("#deleteColorBtn_" + (index-1)).show();		
	}
    preview();
}
$(document).ready(function(){
	//showHidden();
	addBtnEvent(1);
	var spotMax = 10;
	var ids = document.getElementsByName('productBannerImg').length;
	if(ids >= spotMax) {
		("#addimages").hide();
	}
	$("input#addimages").click(function(){     
		  addSpot(this, spotMax);
	});
});
function addSpot(obj, sm) {
	var goodsimagess = document.getElementsByName('productBannerImg').length;
	var ids = "imageFile"+(goodsimagess+1);
	var urls = "url"+(goodsimagess+1);
	var imagesClass = "urlClass"+(goodsimagess+1);
	var bannerImgs = "bannerImg"+(goodsimagess+1);
	
	$('div#spots').before(
		'<div class="row cl">'+
		'<label class="form-label col-2"></label>'+
		'<img alt="介绍图" src="" id="'+bannerImgs+'" width="90" height="80">'+
	    '<input name="productBannerImg" class='+imagesClass+' type="hidden" id='+urls+'/>'+
	    '&nbsp;<i class="Hui-iconfont">&#xe642;</i>&nbsp;'+
	    '<input type="button" class="addImagesClass btn btn-primary radius upload-btn" id='+ids+' value="选择图片" />' +
	    '&nbsp;<input type="button" class="remove btn btn-primary radius upload-btn" onclick="removes(this)" value="删除" /></div>')
	if((goodsimagess-1) >= sm) {
		$("#productBannerImg").hide();
	}
	//给新增的按钮绑定事件
	addBtnEvent((goodsimagess+1));
};
//删除banner图片
function removes(obj){
	var bannerIamLength = $(".bannerImageList").length;
	if(bannerIamLength == 1){
	    var bannerImg = $(".bannerImageList:first").find("#bannerImg").attr("src");
        if(bannerImg == null || bannerImg == "" || bannerImg == undefined || typeof(bannerImg) == "undefined"){
			return;
		}else{
            layer.msg("必须要有一张banner图！",{icon: 2,time:2000});
            return;
		}
	}
    layer.confirm('确定要删除吗？',function(index){
        $(obj).parent().remove();
        layer.msg("</br>",{icon: 1,time:1000});
	});
    $("#addBannerimages").show();
    // preview();
}

function addBtnEvent(goodsimagess){
	KindEditor.ready(function(K) {
		var editor = K.editor({
        	fileManagerJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/file_manager_json.jsp',
            uploadJson : '${pageContext.request.contextPath }/common/other/kingedit/jsp/upload_json.jsp',
			allowFileManager : true
		});
		K('#imageFile'+goodsimagess).click(function() {
			var imgid = $(this).attr("id");//获取当前ID
			var imagesClass =  "urlClass"+imgid.substr(imgid.length-1,1);
			var bannerImg = "bannerImg"+imgid.substr(imgid.length-1,1);
		     
			editor.loadPlugin('image', function() {
				editor.plugin.imageDialog({
					showRemote : false,
					imageUrl : K('.'+imagesClass).val(),
					clickFn : function(url, title, width, height, border, align) {
						K('#'+bannerImg).attr("src",url);
						K('.'+imagesClass).val(url);
						editor.hideDialog();
						return false; 
					}
				});
			});
		}); 

	});
}
var toothInfoJson = '${toothInfoJson}';
//数据校验
function checkProduct(){

    //产品名称验证
    var productName = $("#productName").val();
    if(productName == '' || productName == null){
        layer.msg("产品名称不能为空",{icon: 2,time:2000});
        return false;
    }

    /*至少一种颜色*/
    var colorHtml = $("#colorTableId").find("tr").html();
    if(colorHtml == null || colorHtml == ""){
        layer.msg("至少需要添加一种颜色",{icon: 2,time:2000});
        return false;
    }

	//产品banner图名称验证
    var productBannerImg = $("#productBannerImg").val();
    if(productBannerImg == null || productBannerImg == ''){
        layer.msg("产品banner图不能为空",{icon: 2,time:2000});
        return false;
    }

    /*产品图文必填*/
    var desc = $("#productsInfoProductdesc").val();
    if(desc == null || desc == ""){
        layer.msg("产品图文不能为空",{icon: 2,time:2000});
        return false;
	}

	/*//原价乘100 取整
	$.each(colorPrice,function(n,index){
		$(this).val(Math.round($(this).val() * 100));
	});
	
	//折扣价乘100 取整
	$.each(colorDiscountes,function(n,index){
		$(this).val(Math.round($(this).val() * 100));
	});*/

	var colorList = new Array();
    var tb = document.getElementById("example");  //根据id找到这个表格
    var rows = tb.rows;               //取得这个table下的所有行
    for(var i=1;i<rows.length;i++)//循环遍历所有的tr行
    {
        var color = {};
        for(var j=0;j<rows[i].cells.length;j++)//取得第几行下面的td个数，再次循环遍历该行下面的td元素
        {
            var cell = rows[i].cells[j];//获取某行下面的某个td元素
			if(j == 0){
			    var img = cell.children;
                color.colorProductPic = img[0].getAttribute("src");
			}
            if(j == 1){
                color.colorName = cell.innerHTML;
            }
            if(j == 2){
                color.colorPresent = cell.innerHTML;
            }
            if(j == 3){
                if(cell.innerHTML == "在售"){
                    color.colorStatus = 1;
				}
                if(cell.innerHTML == "停止销售"){
                    color.colorStatus = 2;
                }
                if(cell.innerHTML == "删除"){
                    color.colorStatus = 3;
                }
            }
            if(j == 4){
                color.colorPrice = cell.innerHTML;
            }
            if(j == 5){
                color.colorDiscount = cell.innerHTML;
            }
            if(j == 6){
                color.color69Code = cell.innerHTML;
            }
            if(j == 7){
                $.each(eval(toothInfoJson), function(index,item){
                    if(item.produceName == cell.innerHTML){
                        color.ptsProductId = item.produceId;
                    }
                });
            }
        }
        colorList.push(color);
    }
    $("#colorLists").val(JSON.stringify(colorList));
    $.ajax({
        url: '${pageContext.request.contextPath }/admin/product/add',
        type: "POST",
        dataType: "json",
        /*data: {productId : $("#productName").val(),
			   typeId : $("#typeId").val(),
			   productBannerImg : $("#productBannerImg").val(),
               productsInfoProductdesc : $("#productsInfoProductdesc").val(),
			   colorLists : $("#colorLists").val()
        },*/
        data: $("#form-addGoods").serialize(),
        error:function(data){
            layer.msg("添加失败！",{icon: 5,time:2000});
        },
        success:  function(data){
            if(data.status){
                layer.msg("添加成功！",{icon: 1,time:2000});
                window.location.href = '${pageContext.request.contextPath }/admin/product/list';
			}else{
                layer.msg("添加失败！",{icon: 2,time:2000});
			}

			/* $("#Goodstatus").val(obj.val()); */
			/* window.location.href = '${pageContext.request.contextPath }/admin/goods/listGoodsUI'; */
        }
    });
}
function showAddColor() {
    $("#addColor").hide();
    $("#addColor2").show();
    $("#addcolorDiv").show();
}
function hideAddColor() {
    $("#addColor").show();
    $("#addColor2").hide();
    $("#addcolorDiv").hide();
}
function addColorTable(){
	//产品图片名称验证
    var productIntroduceImg = $("#productIntroduceImg").val();
    if(productIntroduceImg == null || productIntroduceImg == ''){
        layer.msg("产品图片不能为空",{icon: 2,time:2000});
        return;
	}
    //产品颜色名称验证
    var colorNames = $("#colorName").val();
        if(colorNames == '' || colorNames == null){
            layer.msg("产品颜色名称不能为空",{icon: 2,time:2000});
            return;
        }
    //产品简述验证
    var colorPresent = $("#colorPresent").val();
        if(colorPresent == '' || colorPresent == null){
            layer.msg("产品简述不能为空",{icon: 2,time:2000});
            return;
        }

    //产品颜色69码验证
    var color69Codes = $("#color69Code").val();
        if(color69Codes == '' || color69Codes == null){
            layer.msg("产品颜色69码不能为空",{icon: 2,time:2000});
            return;
        }
    var r = /^\+?[1-9][0-9]*$/;　　//判断是否为正整数
    //产品市场价验证
    var colorPrice = $("#colorPrice").val();
        if(!r.test(colorPrice)){
            layer.msg("产品市场价不能为空!且须为金钱格式",{icon: 2,time:2000});
            return;
        }
    //产品销售价验证
    var colorDiscountes = $("#colorDiscount").val();
		if(!r.test(colorDiscountes)){
			layer.msg("产品销售价不能为空!且须为金钱格式",{icon: 2,time:2000});
			return;
		}

    var ptsProductid = null;
    $.each(eval(toothInfoJson), function(index,item){
        if(item.produceId == $("#ptsProductid").val()){
            ptsProductid = item.produceName;
		}
    });
    var colorStatus = null;
    if($("#colorStatus").val() == 1){
        colorStatus = "在售";
	}
    if($("#colorStatus").val() == 2){
        colorStatus = "停止销售";
    }
    if($("#colorStatus").val() == 3){
        colorStatus = "删除";
    }
    var colorTable = '<tr class="text-c">'+
        '<td><img style="width: 50px;height: 50px;" src="'+$("#productIntroduceImg").val()+'"></td>'+
        '<td>'+$("#colorName").val()+'</td>'+
        '<td>'+$("#colorPresent").val()+'</td>'+
        '<td>'+colorStatus+'</td>'+
        '<td>'+$("#colorPrice").val()+'</td>'+
        '<td>'+$("#colorDiscount").val()+'</td>'+
        '<td>'+$("#color69Code").val()+'</td>'+
        '<td>'+ptsProductid+'</td>'+
        '<td><a href="javascript:viod(0)" onclick="delColor(this)" style="color: #00d;">删除</a></td>'+
        '</tr>';
		$("#colorTableId").append(colorTable);
}

function delColor(node){
	$(node).parent().parent().remove();
}


</script>
</body>
</html>