<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <base th:href="${#request.getContextPath() + '/'} ">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-anim layui-anim-fadein">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <table class="layui-table">
                            <col width="60">
                            <col>
                            <col>
                            <col width="80">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>节点ID</th>
                            <th>节点名称</th>
                            <th>表单管理</th>
                        </tr>
                        </thead>
                        <tbody id="tBody"></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
    layui.config({
        base: 'assets/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'table', 'laydate', 'common'], function() {
        var $ = layui.$;
        var $win = $(window);
        var laydate = layui.laydate;
        var common = layui.common;
        var deploymentId = top.restAjax.params(window.location.href).deploymentId;

        function initData() {
            var loadLayerIndex;
            top.restAjax.get(top.restAjax.path('api/node-field/list-node/deployment-id/{deploymentId}', [deploymentId]), {}, null, function(code, data) {
                var trs = ''
                for(var i = 0, item; item = data[i++];) {
                    var tr = '<tr>' +
                        '<td>'+ i +'</td>' +
                        '<td>'+ item.flowNodeId +'</td>' +
                        '<td>'+ item.flowNodeName +'</td>' +
                        '<td><button type="button" class="layui-btn layui-btn-xs form-config" data-flow-node-id="'+ item.flowNodeId +'" data-form-id="'+ item.formId +'">表单配置</button></td>' +
                        '</tr>';
                    trs += tr;
                }
                $('#tBody').append(trs);
            }, function(code, data) {
                top.dialog.msg(data.msg);
            }, function() {
                loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
            }, function() {
                top.dialog.close(loadLayerIndex);
            });
        }
        initData();

        $(document).on('click', '.form-config', function() {
            var flowNodeId = this.dataset.flowNodeId;
            var formId = this.dataset.formId;
            top.dialog.open({
                url: top.restAjax.path('route/oa/node-field/list-node-field?deploymentId={deploymentId}&flowNodeId={flowNodeId}', [deploymentId, flowNodeId]),
                title: '【'+ flowNodeId +'】节点表单字段',
                width: '600px',
                height: '500px',
                onClose: function() {}
            });
        })
    });
</script>
</body>
</html>