WebFolow

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>流程图</title>
<script type="text/javascript">
    var rectW = 160; //矩形宽度
    var rectH = 60; //矩形高度
    var rectWs = 50; //横向间距
    var rectHs = 50; //纵向间距
    //参数 标识_名称_父标识_状态
    //状态 0   1  进行中  2  超时  3  完成
    var folowS = "1a_爷爷_0_2|2_叔叔_1a_0|3_小叔叔_1a_1|4_小红_2_0|5_小红2_2_2|6_小红_3_0|7_小红2_4_3|8_小红22_3_0|9_小红42_6_0";
    var hRC = 1;      //纵向个数
    //var folowS = "1_爷爷_0|2_叔叔_1";
    var folowArray = folowS.split('|');
    function GetInfo(_id,w,_h){
        var w1 = w + rectW + rectWs;
        for (var i = 0; i < folowArray.length; i++) {
            var id = folowArray[i].split('_')[0]; //当前节点编号
            var name = folowArray[i].split('_')[1];//当前节点名称
            var pid = folowArray[i].split('_')[2]; //父节点编号
            var state = folowArray[i].split('_')[3]; //状态
            var color = getColor(state); //设置背景颜色
            if (pid == _id) {
                var h = (rectH + rectHs) * hRC;
                //绘制连线
                if (_id != 0) {
                    drawLine(w,_h,w1,h);
                }
                document.write('<div style="position:absolute; top:' + (h - rectH / 2) + 'px; left:' + (w - rectW / 2) + 'px; border:1px #000 solid;background-color:' + color + ';width:' + rectW + 'px;height:' + rectH + 'px;text-align:center;line-height:25px;">' + name + '</div>');
                hRC++;
                GetInfo(id, w1, h);
            }
        }
    }

    //画线
    function drawLine(w, h, w1, h1) {
        //竖线
        document.write('<div style="position:absolute; top:' + (h + rectH / 2) + 'px; left:' + (w - rectW - rectWs) + 'px; border-left:1px #000 solid;background-color:#cccccc;width:0px;height:' + (h1 - h - rectH / 2) + 'px;overflow:hidden"></div>');
        //横线
        document.write('<div style="position:absolute; top:' + (h1) + 'px; left:' + (w - rectW - rectWs) + 'px; border-top:1px #000 solid;background-color:#cccccc;width:' + (w1 - w - rectW / 2) + 'px;height:0px;overflow:hidden"></div>');
        //箭头
        document.write('<div style="position:absolute; top:' + (h1 - 10) + 'px; left:' + (w - rectW/2 -20) + 'px;width:20px;height:20px;font-size:20px;line-height:20px;overflow:hidden">→</div>');
    }
    //获取颜色
    function getColor(state) {
        var color = '#cccccc';
        switch (parseInt(state)) {
            case 1:
                color = '#1AA655';
                break;
            case 2:
                color = '#E97467';
                break;
            case 3:
                color = '#7B8DD5';
                break;
        }
        return color;
    }

    GetInfo(0, 110,90);


</script>
</head>
<body>

</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lijun_xiao2009

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值