梦幻之旅

DEBUG - 天道酬勤

   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  671 随笔 :: 6 文章 :: 256 评论 :: 0 Trackbacks
/** 创建systemColumn的树状结构 */    
    
function createLoadMidSubtable()
    
{
        $(
"#systemColumn").empty();
        
        
/** 创建系统列大项 */
        
var info="";
        info 
+= "<dt id='systemColumnBasicInfo'><span value='0'>+企业基本信息</span></dt>";
        info 
+= "<dt id='systemColumnConcact1'><span value='0'>+联系人1</span></dt>";
        info 
+= "<dt id='systemColumnConcact2'><span value='0'>+联系人2</span></dt>";
        info 
+= "<dt id='systemColumnConcact3'><span value='0'>+联系人3</span></dt>";
        info 
+= "<dt id='systemColumnBussiness'><span value='0'>+业务信息</span></dt>";
        info 
+= "<dt id='systemColumnOther'><span value='0'>+新增列</span></dt>";
        $(
"#systemColumn").append(info);
        $(
"#systemColumn").find("dt").css(
        
{
            
"font-weight":600,
            
"cursor":"pointer"
        }
);
        
        
/** 创建企业基础信息 */
        info 
= "";
        
for(var i=0;i<loadMidBiztable.length;i++)
        
{
            info
+="<dd id='"+loadMidBiztable[i][0]+"'>"+loadMidBiztable[i][1]+"</dd>";
        }

        $(
"#systemColumnBasicInfo").append(info);
        
        
/** 联系人1-3信息 */
        
for(var i=1; i<=3; i++)
        
{
            info 
= "";
            
for(var j=0;j<loadContact.length;j++)
            
{
                info
+="<dd id='c"+i+loadContact[j][0]+"'>"+loadContact[j][1]+"</dd>";
            }

            $(
"#systemColumnConcact"+i).append(info);
        }

        
var bussinessType = 1;
        
/** 业务信息 */
        info 
= "";
        
if(bussinessType == 1)
        
{
            
//发行订阅
            for(var i=0;i<loadMidSubtable.length;i++)
            
{
                info
+="<dd id='"+loadMidSubtable[i][0]+"'>"+loadMidSubtable[i][1]+"</dd>";
            }

        }

        
else if(bussinessType == 2)
        
{
            
//咨询
            for(var i=0;i<loadMidPritable.length;i++)
            
{
                info
+="<dd id='"+loadMidPritable[i][0]+"'>"+loadMidPritable[i][1]+"</dd>";
            }

        }

        
else if(bussinessType == 3)
        
{
            
//展会招展
            for(var i=0;i<loadMidExtable.length;i++)
            
{
                info
+="<dd id='"+loadMidExtable[i][0]+"'>"+loadMidExtable[i][1]+"</dd>";
            }

        }

        
else if(bussinessType == 4)
        
{
            
//稿件
            for(var i=0;i<loadMidManutable.length;i++)
            
{
                info
+="<dd id='"+loadMidManutable[i][0]+"'>"+loadMidManutable[i][1]+"</dd>";
            }

        }

        $(
"#systemColumnBussiness").append(info);
        
        
/** 对选项目添加样式和事件 */
        $(
"#systemColumn").find("dd").css(
        
{
            
"padding-left":"20px",
            
"font-weight":"300",
            
"padding-top":"3px",
            
"display":"none"
        }
);
        
        
/** 每个小项目点击变色  */
        $(
"#systemColumn").find("dd").click(function()
        
{
            
/** 全部设置成白色 */
            $(
"#systemColumn").find("dd").each(function(i)
            
{
                
if($(this).css("display"!= "none")
                
{
                    $(
this).css(
                    
{
                        
"background-color":"white",
                        
"color":"#100d08"
                    }
);
                }

            }
);
    
            
/** 把自己设置成蓝色 */
            $(
this).css(
            
{
                
"background-color":"#022658",
                
"color":"white"
            }
);
        }
);
            
        
/** 每个大项点击时可收缩 */
        $(
"#systemColumn").find("dt").find("span").click(function()
        
{
            
var spanHTML = $(this).html().substr(1);
            
if($(this).attr("value"== "0")
            
{
                $(
this).attr("value","1");
                $(
this).parent().children("dd").each(function(i){
                
                    
if($(this).css("background-color"!= "#022658")
                    
{
                        $(
this).css({"display":""});
                    }

                }
);
                
/** 替换第一个字符 */
                $(
this).html("-" + spanHTML);
            }

            
else
            
{
                $(
this).attr("value""0");
                $(
this).parent().children("dd").each(function(i){
                
                    
if($(this).css("background-color"== "#022658"
                        
&& $(this).css("display"!= "none")
                    
{
                        $(
this).css({"background-color":"white","color":"#100d08"});
                    }

                }
);
                $(
this).parent().children("dd").css({"display":"none"});
                $(
this).html("+" + spanHTML);
            }

        }
);
    }

    
    
/** 创建文字的字段列表 */
    
function originalColumn(index, fieldName)
    
{
        $(
"#originalColumn").append("<dd id='"+index+"'>" + fieldName + "<dd>");
        
/** 对选项目添加样式和事件 */
        $(
"#" + index).css({
            
"padding-left":"10px",
            
"font-weight":"300",
            
"padding-top":"3px",
            
"cursor":"pointer"
        }
);
        
/** 添加点击事件 */
        $(
"#" + index).click(function()
        
{
            
/** 全部设置成白色 */
            $(
"#originalColumn").find("dd").each(function(i)
            
{
                
if($(this).css("display"!= "none")
                
{
                    $(
this).css({
                    
"background-color":"white",
                    
"color":"#100d08"
                    }
);
                }

            }
);
            
            
/** 把自己设置成蓝色 */
            $(
this).css(
            
{
                
"background-color":"#022658",
                
"color":"white"
             }
);
        }
);
    }

    
    
/** 添加对应的关系 */
    
function columnConstrastAdd2()
    
{
        
/** 得到第一个列表的选中的对象 */
        
var origObj = $("#originalColumn").find("dd").filter(
            
function (index)
            
{
                
if($(this).css("background-color"== "#022658"
                    
&& $(this).css("display"!= "none")
                
{
                    
return $(this); 
                }

            }

        );
        
if(origObj.attr("id"== undefined)
        
{
            alert(
"请选择\"原文件列名\"");
            
return;
        }

        
        
/** 得到第二个列表选中的对象 */
        
var sysObj = $("#systemColumn").find("dd").filter(
            
function (index)
            
{
                
if($(this).css("background-color"== "#022658" 
                    
&& $(this).css("display"!= "none")
                
{
                    
return $(this); 
                }

            }

        );
        
if(sysObj.attr("id"== undefined)
        
{
            alert(
"请选择\"系统原列名\"");
            
return;
        }

        
        
/** 向关系框内添加 */
        
var relationDDId = origObj.attr("id")+"_"+sysObj.attr("id")+"_"+sysObj.text();
        
var relationDDValue = origObj.attr("id")+":"+sysObj.attr("id")+":"+sysObj.text();
        $(
"#relationColumn").append("<dd id='"+relationDDId+"' value='"+relationDDValue+"'>" + origObj.text()+"<strong> --> </strong> "+sysObj.text()+"</dd>");
        
        
/** 隐藏已经选中的 */
        origObj.hide();
        sysObj.hide();
        
        
/** 对选项目添加样式和事件 */
        $(
"#" + relationDDId).css({
            
"padding-left":"10px",
            
"font-weight":"300",
            
"padding-top":"3px",
            
"cursor":"pointer"
        }
);
        
/** 添加点击事件 */
        $(
"#" + relationDDId).click(function()
        
{
            
/** 全部设置成白色 */
            $(
"#relationColumn").find("dd").css({
                
"background-color":"white",
                
"color":"#100d08"
            }
);
            
            
/** 把自己设置成蓝色 */
            $(
this).css(
            
{
                
"background-color":"#022658",
                
"color":"white"
             }
);
        }
);
          
        
//alert(origObj.attr("id") + "-" + origObj.text());
        //alert(sysObj.attr("id") + "-" + sysObj.text());
    }

    
    
/** 删除对应关系 */
    
function columnConstrastDelete2()
    
{
        
var relationObj = $("#relationColumn>dd").filter(
            
function (index)
            
{
                
if($(this).css("background-color"== "#022658")
                
{
                    
return $(this); 
                }

            }

        );
        
        
/** 检查是否选中要删除的列 */
        
if(relationObj.attr("value"== undefined)
        
{
            alert(
"请选择要删除的列");
            
return;
        }

        
        
/** 文件字段开始 */
        
var orgiIdSysId = relationObj.attr("value").split(":");
        oriDDTemp 
= $("#originalColumn>dd[id="+orgiIdSysId[0]+"]");
        
/** 原框里如果有颜色为选中的,取消选择 */
        oriDDTemp.parent().find(
"dd").each(function(i)
        
{
            
if($(this).css("display"!= "none"
                
&& $(this).css("background-color"== "#022658")
            
{
                $(
this).css({"background-color":"white","color":"#100d08"});
            }

        }
);
        oriDDTemp.show();
        
        
/** 系统字段开始 */
        
/** 它一定要设置颜色(如果该大项是隐藏的,就改背景色,否则就显示) */
        
var sysDDTemp = $("#systemColumn>dt>dd[id="+orgiIdSysId[1]+"]");
        
        
/** 原框里如果有颜色为选中的,取消选择 */
        sysDDTemp.parent().find(
"dd").each(function(i)
        
{
            
if($(this).css("display"!= "none"
                
&& $(this).css("background-color"== "#022658")
            
{
                $(
this).css({"background-color":"white","color":"#100d08"});
            }

        }
);
        
        
if(sysDDTemp.parent().find("span").attr("value")=="0")
        
{
            sysDDTemp.css(
{"background-color":"white","color":"#100d08"});
        }

        
else
        
{
            $(
"#systemColumn>dt>dd[id="+orgiIdSysId[1]+"]").show();
        }

        
/** 删除对象 */
        relationObj.remove();
    }

    
    
/** 新增自定义列 */
    
function newColumnAdd()
    
{    
        
/** 对新增列的个数进行判断 */
        
if($("#systemColumnOther>dd").length>20)
        
{
            alert(
"最多只可以增加20个自定义列!");
            
return;
        }

        
/** 参数进行检查 */
        
var otherColumTemp = $.trim($("#systemColumnOtherInputId").attr("value"));
        
if(otherColumTemp.length<=0)
        
{
            alert(
"请填写自定义列的名称!");
            $(
"#systemColumnOtherInputId").focus();
            
return;
        }

        
/** 新增加列里不能包含空格 */
        
if(otherColumTemp.indexOf(" ")>0)
        
{
            alert(
"自定义列的名称不能包含空格!");
            $(
"#systemColumnOtherInputId").focus();
            
return;
        }

        
        
var columnNum = -1;
        
if($("#systemColumnOther>dd").length != 0)
        
{
            
/** 得到列的名称 */
            
for(var i=0; i<20; i++)
            
{
                
var isContain = false;
                
/** 从序数最小开始排列 */
                $(
"#systemColumnOther>dd").each(function(j){
                    
var tempId = $(this).attr("id");
                    
//alert(tempId);
                    if(tempId.replace("column","")==i)
                    
{
                        isContain 
= true;
                    }

                }
);
                
if(!isContain)
                
{
                    columnNum 
= i;
                    
break;
                }

            }

            
//alert(columnNum);
            if(columnNum == -1)
            
{
                alert(
"找不到对应的列");
                
return;
            }

        }

        
else
        
{
            
var columnNum = 0;
        }

        
        
/** 新增新定义列 */    
        $(
"#systemColumnOther").append("<dd id='column"+columnNum +"'>"+otherColumTemp+"_"+columnNum+"</dd>");
        
        
/** 对选项目添加样式和事件 */
        $(
"#systemColumnOther").find("dd").css(
        
{
            
"padding-left":"20px",
            
"font-weight":"300",
            
"padding-top":"3px"
        }
);
        
        
/** 每个小项目点击变色  */
        $(
"#systemColumnOther").find("dd").click(function()
        
{
            
/** 全部设置成白色 */
            $(
"#systemColumnOther").find("dd").each(function(i)
            
{
                
if($(this).css("display"!= "none")
                
{
                    $(
this).css(
                    
{
                        
"background-color":"white",
                        
"color":"#100d08"
                    }
);
                }

            }
);
    
            
/** 把自己设置成蓝色 */
            $(
this).css(
            
{
                
"background-color":"#022658",
                
"color":"white"
            }
);
        }
);
    }

    
    
/** 删除自定义列 */
    
function newColumnDelete()
    
{
        $(
"#systemColumnOther").find("dd").each(function(){
            
if($(this).css("display"!= "none" 
                
&& $(this).css("background-color"== "#022658" )
            
{
                $(
this).remove();
            }
 
        }
);        
    }
        
    
        $(document).ready(
function() {            
            
            $('#formFile').ajaxForm();
            createLoadMidSubtable();
            originalColumn(
1, 'column1');    
            originalColumn(
2, 'column2');
            originalColumn(
3, 'column3');    
        }
);
posted on 2010-04-12 17:53 HUIKK 阅读(342) 评论(0)  编辑  收藏 所属分类: JavaScript

只有注册用户登录后才能发表评论。


网站导航: