zoukankan      html  css  js  c++  java
  • 5月29 流程

    关于流程处理需要访问的数据库名有:Users,FlowPath,UserPath,LiuCheng

    #流程表
    create table LiuCheng
    (
        Code varchar(50)primary key, #流程代号
        Name varchar(50) #流程名称
    );
    #流程对应节点表
    create table FlowPath
    (
        Ids int auto_increment primary key,    #节点代号
        Code varchar(50) references LiuCheng(Code), # 流程代号
        Uids varchar(50) references Users(UserName),#节点人员代号
        Orders int #节点次序号
    );
    #用户发起流程表
    create table UserFlow
    (
        Ids int auto_increment primary key,    #代号
        Code varchar(50) references LiuCheng(Code), # 流程代号
        Uid varchar(50) references Users(UserName),#发起人员代号
        Content text,#流程内容    
        IsOk bit, #是否完成
        RiQi datetime, # 发起日期
        ToWhere int #流程到哪
    );

    实现流程的操作处理:

    登录数据显示页面:denglu.php

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>流程的一些例题:登录</title>
    </head>
    
    <body>
    <br />
    <br />
    <h1>登录</h1>
    <form action="dengluchuli.php" method="post">
    <div>用户名:<input type="text" name="uid" /></div>
    <br />
    <div>密&nbsp;码&nbsp;:<input type="text" name="pwd" /></div>
    <br />
    <input type="submit" value="登录" />
    </form>
    </body>
    </html>
    View Code

    登录数据处理页面:dengluchuli.php

    <?php
    session_start();
    include("../DBDA.php");
    $db = new DBDA();
    $uid = $_POST["uid"];
    $pwd = $_POST["pwd"];
    
    $sql = "select count(*) from Users where Uid = '{$uid}' and Pwd = '{$pwd}'";
    $attr = $db->StrQuery($sql);
    
    if($attr==1)
    {
        header("location:main.php");
        $_SESSION["uid"] = $uid;
    }
    else
    {
        header("location:denglu.php");    
    }
    View Code

    主页面:main.php

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>流程的一些例题:登录</title>
    <style type="text/css">
    *
    {
        margin:0 auto;
        padding:0
    }
    .liucheng
    {
        margin:10px;}
    .zi
    {
        margin:20px;}
    </style>
    </head>
    
    <body>
    <br />
    <center><h1>主页面</h1></center><br />
    
    <div class="liucheng">
        <div class="zi">
            <a href="xinjian4.php">新建流程</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="faqi5.php">发起流程</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="LCchuli6.php">流程处理</a>
        </div>    
    </div>
    <br />
    <br />
    <a href="denglu.php">跳转到登录</a>
    </body>
    </html>
    View Code

    新建流程数据显示页面:xinjian4.php

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script src="../jquery-1.11.2.min.js"></script>
    </head>
    
    <body>
    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $attr = array();
    if(!empty($_SESSION["jiedian"]))
    {
        $attr = $_SESSION["jiedian"];    
        
    }
    
    ?>
    <h1>新建流程</h1>
    <div>
        请选择节点人员:
        <?php
            $sry = "select * from users";
            $ary = $db->Query($sry);
            
            foreach($ary as $v)
            {
                echo "<input type='radio' class='ry' name='ry' value='{$v[0]}' />{$v[2]}";    
            }    
        ?>  
    </div>
    <br />
    <div>
        <input type="button" value="添加节点" id="tjjd" />
    </div>
    <br />
    <div>
    <?php
        foreach($attr as $k=>$v)
        {
            $sname = "select Name from Users where Uid = '{$v}'";
            $name = $db->StrQuery($sname);
            
            echo "<div>{$k}--{$name}--<input type='button' value='删除' class='sc' bs='{$k}' /></div>";
        }
    
    ?>
    </div>
    <br />
    <div>请输入流程名称:
        <input type="text" name="mc" id="mc" />
    </div>
    <br />
    <div>
        <input type="button" value="添加" id="add" />
    </div>
    <br />
    <a href="main.php">返回主页面</a>
    
    </body>
    </html>
    <script type="text/javascript">
    $(document).ready(function(e) {
        //设置李四选中
        $(".ry").eq(2).prop("checked",true);
        
        //添加节点按钮点击事件
        $("#tjjd").click(function(){
            
            var rd = $(".ry");//找到单选按钮
            
            var uid = "";//空的uid
            for(var i=0;i<rd.length;i++)
            {
                if(rd.eq(i).prop("checked"))
                {
                    uid = rd.eq(i).val();
                }
            }
            //调用ajax
                $.ajax({
                    url:"tjjdchuli4.php",
                    data:{uid:uid},
                    dataType:"TEXT",
                    type:"POST",
                    success: function(data){
                        
                        //alert(data);
                        window.location = "xinjian4.php";
                        }
                    });
            
            })
        
        //删除节点的点击事件
        $(".sc").click(function(){
            
            var id = $(this).attr("bs");
            
                $.ajax({
                    url:"scjdchuli4.php",
                    data:{id:id},
                    dataType:"TEXT",
                    type:"POST",
                    success: function(data){
                        
                        window.location = "xinjian4.php";
                        
                        }
                    });
            })
        
        //添加流程按钮
        $("#add").click(function(){
            
            var name = $("#mc").val();
            
                $.ajax({
                    url:"tjlcchuli4.php",
                    data:{name:name},
                    dataType:"TEXT",
                    type:"POST",
                    success: function(data){
                        
                        if(data.trim()=="OK")
                        {
                            alert("添加成功");
                        }
                        else
                        {
                            alert("添加失败");    
                        }
                        }
                    });
            
            })
        
        
        
        
        
    });
    </script>
    View Code

    添加节点处理页面:tjjdchuli4.php

    <?php
    session_start();
    
    $uid = $_POST["uid"];
    
    
    if(empty($_SESSION["jiedian"]))//第一次添加节点
    {
        $attr = array($uid);
        $_SESSION["jiedian"] = $attr;
    }
    else
    {
        $attr = $_SESSION["jiedian"];
        array_push($attr,$uid);
        $_SESSION["jiedian"] = $attr;    
    }
    View Code

    删除节点处理页面:scjdchuli4.php

    <?php
    session_start();
    
    $id = $_POST["id"];
    $attr = $_SESSION["jiedian"];
    
    unset($attr[$id]);
    $attr = array_values($attr);
    
    $_SESSION["jiedian"] = $attr;
    View Code

    添加流程名称处理页面:tjlcchuli4.php

    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $attr = array();//先定义空的数组
    if(!empty($_SESSION["jiedian"]))
    {
        $attr = $_SESSION["jiedian"];    
    }
    
    $name = $_POST["name"];
    
    //向流程表中添加数据
    $code = date("YmdHis");
    $slc = "insert into liucheng values('{$code}','{$name}')";
    //判断是否执行成功的变量
    $isok = true;
    
    if($db->Query($slc,1))
    {
        foreach($attr as $k=>$v)
        {
            //向流程对应的节点表添加数据
            $sfl = "insert into flowpath values('','{$code}','{$v}',{$k})";
            $isok = $isok && $db->Query($sfl,1);
        }    
    }
    if($isok)
    {
        echo "OK";    
    }
    else
    {
        echo "NO";    
    }
    View Code

    发起流程数据显示页面:faqi5.php

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>发起流程</title>
    <script src="../jquery-1.11.2.min.js"></script>
    </head>
    
    <body>
    <h1>发起流程</h1>
    <?php
    
    include("../DBDA.php");
    $db = new DBDA();
    ?>
    <div>请选择流程:
    <select id="lc">
    <?php
        $slc = "select * from liucheng";
        $alc = $db->Query($slc);
        
        foreach($alc as $v)
        {
            echo "<option value='{$v[0]}' />{$v[1]}</option>";
        }
    
    ?>
    </select>
    </div>
    <br />
    <div>请输入流程内容:
        <textarea id="nr" cols="30" rows="8"></textarea>
    
    </div>
    <br />
    <div><input type="button" value="发起" id="fq" /></div>
    <br />
    
    <a href="main.php">返回</a>
    </body>
    </html>
    <script type="text/javascript">
    $(document).ready(function(e) {
        $("#fq").click(function(){
            
            var code = $("#lc").val();
            var nr = $("#nr").val();
            
            $.ajax({
                url:"faqichuli5.php",
                data:{code:code,nr:nr},
                type:"POST",
                dataType:"TEXT",
                success: function(data){
                        
                        if(data.trim()=="OK")
                        {
                            alert("添加成功");    
                        }
                        else
                        {
                            alert("添加失败");    
                        }
                    
                    }
                
                });
            
            })
        
        
        
        
        
        
        
    });
    
    </script>
    View Code

    发起流程数据处理页面:faqichuli5.php

    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $code = $_POST["code"];
    $nr = $_POST["nr"];
    $rq = date("Y-m-d H:i:s",time());
    $uid = $_SESSION["uid"];
    
    //echo $uid;
    
    $sql = "insert into userflow values('','{$code}','{$uid}','{$nr}',false,'{$rq}',0)";
    
    if($db->Query($sql,1))
    {
        echo "OK";    
    }
    else
    {
        echo "NO";    
    }
    View Code

    流程处理数据显示页面:LCchuli6.php

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>流程处理</title>
    </head>
    
    <body>
    <?php
    session_start();
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $uid = $_SESSION["uid"];
    ?>
    <h1>审核流程</h1>
    <br />
    <a href="main.php">返回</a>
    <br />
    <br />
    
    <br />
    <table width="100%" cellpadding="0" cellspacing="0" border="1">
        <tr bgcolor="#0000FF" style="color:#FFF" align="center">
            <td>流程名称</td>
            <td>发起人</td>
            <td>内容</td>
            <td>是否结束</td>
            <td>发起时间</td>
            <td>操作</td>
        </tr>
    
        <?php
           
            /*$sfl = "select Code,Orders from FlowPath where Uids = '{$uid}'";//做法会有误差时间,没有以时间降序排列不好看
            $afl = $db->Query($sfl);
            //var_dump($afl);
            foreach($afl as $v)
            {
                $suf = "select * from Userflow where Code = '{$v[0]}' and ToWhere >= '{$v[1]}'";
                
                $auf = $db->Query($suf);
                //var_dump($auf);
                foreach($auf as $vuf)
                {
                    echo "<tr align='center'>
                            <td>{$vuf[1]}</td>
                            <td>{$vuf[2]}</td>
                            <td>{$vuf[3]}</td>
                            <td>{$vuf[4]}</td>
                            <td>{$vuf[5]}</td>
                            <td>操作</td>
                        </tr>";    
                }
            }
        */
        
            //日期的降序排列
            $suf = "select * from UserFlow order by RiQi desc";
            $auf = $db->Query($suf);
            //var_dump($auf);
               
            foreach($auf as $vuf)
            {
                //$vuf[1]code
                //$vuf[6]towhere
                
                //根据流程的代号去flowpath表中查询
                $fql = "select Code,Orders from flowpath where Uids = '{$uid}' and Code = '{$vuf[1]}'";
                $fattr = $db->Query($fql);
                //var_dump($fattr);
                if($fattr)
                {
                    
                    $ucode = $fattr[0][0];//流程代号
                    $ucx = $fattr[0][1];//次序
                    //判断该流程是否通过该用户
                    if($vuf[1] == $ucode && $vuf[6] >= $ucx)
                    {
                        $lnmae = Lname($db,$vuf[1]);
                        $fname = Fname($db,$vuf[2]);
                        //处理是否结束 isok布尔型的如果是true,$isok 随便定义
                        $isok =$vuf[4]?"<span style='background-color:red'>已结束</span>":"<span style='color:blue'>处理中</span>";
                        
                        //处理操作
                        $chuli = "";
                        if($vuf[6]==$ucx)
                        {
                            $chuli = "<a href='shenhechuli6.php?id={$vuf[0]}'>审核</a>";    
                        }
                        else
                        {
                            $chuli = "<span style='color:red'>已通过</span>";    
                        }
                        
                        echo "<tr align='center'>
                            <td>{$lnmae}</td>
                            <td>{$fname}</td>
                            <td>{$vuf[3]}</td>
                            <td>{$isok}</td>
                            <td>{$vuf[5]}</td>
                            <td>{$chuli}</td>
                        </tr>";    
                    }    
                }
                
            }
            
            //处理流程名的函数
            function Lname($db,$code)
            {
                $sql = "select Name from LiuCheng where Code = '{$code}'";
                return $db->StrQuery($sql);
                
            }
            //处理发起人姓名的函数
            function Fname($db,$uid)
            {
                $sql = "select Name from Users where Uid = '{$uid}'";    
                return $db->StrQuery($sql);
            }
        
        ?>
    
    
    </table>
    </body>
    </html>
    View Code

    审核处理页面:shenhechuli6.php

    <?php
    
    include("../DBDA.php");
    $db = new DBDA();
    
    $id = $_GET["id"];//主键
    
    $sql = "update userflow set ToWhere = ToWhere+1 where Ids = '{$id}'";
    $attr = $db->Query($sql,1);
    
    if($attr)
    {
        //查看流程走到哪里了
        $stw = "select Code,ToWhere from UserFlow where Ids = '{$id}'";    
        $atw = $db->Query($stw);
        $code = $atw[0][0];  //流程号
        $towhere = $atw[0][1]; //到哪了
        
        //查询节点数量
        $sjd = "select count(*) from FlowPath where Code = '{$code}'";
        $ajd = $db->StrQuery($sjd);
        
        //如果流程走到位置大于等于了该流程中节点的总数
        if($towhere>=$ajd)
        {
            $sok = "update userflow set Isok = true where Ids = '{$id}'";    
            $db->Query($sok,1);
        }
        header("location:LCchuli6.php");
    }
    else
    {
        echo "审核失败";
    }
    View Code

    显示的网页效果如下:

    主页面:

    新建流程:

    发起流程

    流程处理

  • 相关阅读:
    深入理解DOM事件类型系列第四篇——剪贴板事件
    深入理解DOM事件机制系列第四篇——事件模拟
    利用select实现年月日三级联动的日期选择效果
    深入理解表单脚本系列第四篇——选择框脚本
    存储过程返回布尔值以及C#相关处理
    Type 'Insus.NET.PictureObject' in Assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
    打开Windows10网络发现或是文件打印共享
    反射(Reflection)的SetValue遇上DBNULL转换为string
    MS SQL中使用UPDATE ... INNER JOIN ...
    Visual Studio 2015正式企业(Enterprise)版
  • 原文地址:https://www.cnblogs.com/Duriyya/p/5540717.html
Copyright © 2011-2022 走看看