<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <div class="row border-bottom white-bg">
                <nav class="navbar navbar-static-top">
                    <div class="navbar-header"></div>
                    <div class="navbar-collapse collapse" id="navbar">
                        <ul class="nav navbar-nav nav-main">
                            <li>
                            </li>
                            <li><a href="#" class="menu-item" id="myTask">我的任务</a></li>
                            <li><a href="#" class="menu-item" id="todoTask">代办任务</a></li>
                            <li><a href="#" class="menu-item" id="finishedTask">已办任务</a></li>
                            <li><a href="#" class="menu-item " id="involvedTask">受邀任务</a></li>
                            <li><a href="#" class="menu-item" id="archivedTask">已经归档</a></li>
                        </ul>
                    </div>
                </nav>
            </div>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('activiti:process:edit')}]];
    var removeFlag = [[${@permission.hasPermi('activiti:process:remove')}]];
    var deployFlag = [[${@permission.hasPermi('activiti:process:deploy')}]];
    var todoFlag = [[${@permission.hasPermi('activiti:process:export')}]];

    var prefix = "/activiti/task";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            removeUrl: prefix + "/remove",
            updateUrl: prefix + "/edit/{id}",
            exportUrl: prefix + "/export",
            deploy: prefix + "/deploy/",
            sortName: "createTime",
            sortOrder: "desc",
            modalName: "流程实例",
            search: false,
            showExport: false,
            uniqueId: "deploymentId",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'id', // 列字段名
                    title: '任务' // 列标题
                },
                {
                    field: 'key', // 列字段名
                    title: '任务key' // 列标题
                },
                {
                    field: 'processId', // 列字段名
                    title: '流程编号' // 列标题
                },
                {
                    field: 'processDefinitionId', // 列字段名
                    title: '流程定义编号' // 列标题
                },
                {
                    field: 'name',
                    title: '任务名称'
                },
                {
                    field: 'executionId',
                    title: '跟踪',
                    formatter: function (value, row, index) {
                        return '<a onclick="createMenuItem(\'/activiti/task/trace/photo/' + row.processDefinitionId + '/' + row.executionId + '\',\''+row.processDefinitionId+'\')">跟踪</a>';
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + todoFlag + '" title="签收任务" href="#" onclick="form(\'' + row.processDefinitionId + '\',\'' + row.id + '\'"><i class="fa fa-play-circle-o"></i>审批</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        $('.menu-item').click(function () {
            var menu = $(this).attr('id');
            if (menu == 'myTask') {
                options.url = prefix + '/list';
            }
            if (menu == 'todoTask') {
                options.url = prefix + '/todo';
            }
            if (menu == 'finishedTask') {
                options.url = prefix + '/finished';
            }
            if (menu == 'involvedTask') {
                options.url = prefix + '/involved';
            }
            if (menu == 'archivedTask') {
                options.url = prefix + '/archived';
            }
            $("#bootstrap-table").bootstrapTable('refreshOptions', options);
        });
    });

    function form(proId, id) {
        layer.open({
            type: 2,
            title: '发起流程',
            maxmin: true,
            shadeClose: false,
            area: ['100%', '100%'],
            content: prefix + '/form/' + proId + '/' + id
        })
    }
</script>
</body>
</html>