flowable6.3教程-springboot-请假流程第二步:领导查看待办列表

介绍

提交请假后,实现领导查看待办列表功能,如下图:

Controller

在 QingjiaController 类中增加下面代码:

/**
 * 部门经理查看待办任务
 * @return
 */
@RequestMapping(value="/todo")
public JsonResult todo() {
    List<Qingjia> list = qingjiaService.daiban();
    return JsonResult.success(null,list);
}

Service

在 QingjiaService 类增加下面代码:

/**
 * 部门经理查看任务
 * @return
 */
public List<Qingjia> daiban(){
    // 查询 managers 的待办任务
    List<Task> tasks = taskService.createTaskQuery().taskCandidateGroup("managers")
            .orderByTaskCreateTime() // 按照任务创建时间
            .desc() // 倒序排列
            .list();
    // 将代码的pid放到list中
    List pidList = new ArrayList();
    for( Task task : tasks){
        pidList.add(task.getProcessInstanceId());
    }
    // 根据pid查询qingjia表
    List<Qingjia> retList = qingjiaMapper.daiban(pidList);
    return retList;
}

html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="js/jquery-1.11.0.min.js"></script>
  <script src="js/doT.js"></script>
    <script>
        function init(){
            $.ajax({
                url:'/qingjia/todo',//请求的url
                type:'POST', //请求方式,GET或POST
                data:{ //发送服务器的数据
                },
                dataType:'json',  //返回的数据格式:json/xml/html/script/jsonp/text
                success:function(data,textStatus,jqXHR){ //statusCode是2xx 或 304时,执行该函数
                    console.log(data)
                    //编译模板
                    var interation = doT.template( $('#tableTemp').html() );
                    //将数据显示到网页中
                    $( '#showTable' ).html(interation( data ));
                },
                error:function(xhr,textStatus){ //statusCode是 2xx 或 304 以外的值时,执行该函数
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                }
            })

        }
        window.onload = function () {
            init()
        }
    </script>
</head>
<body>


<!-- 定义模板 -->
<script id="tableTemp" type="text/x-dot-template">
    <table border="1">
        <tr>
            <td>序号</td>
            <td>请假人</td>
            <td>请假天数</td>
            <td>创建时间</td>
            <td>操作</td>
        </tr>
    {{~it.data:value:index}}
        <tr>
            <td>{{= index+1 }}</td>
            <td>{{= value.emp }}</td>
            <td>{{= value.day }}</td>
            <td>{{= value.createTime }}</td>
            <td><a href="qingjia_shenpi.html?id={{= value.id }}&actPid={{= value.actPid }}">审批</a></td>
        </tr>
    {{~}}
    </table>
</script>
<!-- 显示数据的位置 -->
<div id="showTable"></div>


</body>
</html>

测试

访问 http://localhost:8080/qingjia_daiban.html ,显示下图:


原文出处:/show_1IX5jMzVwLJk.html