<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>修改记录</title>
    <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <link rel="stylesheet" th:href="@{/lib/font-awesome-4.7.0/css/font-awesome.min.css}" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="" lay-filter="formDemo">
            <div class="layui-form-item" style="margin: 20px 0px 0px 5px">
                <input type="text" style="width: 70px; border: 0px" value="年度预算：" readonly>
                <input type="text" name="xm" id="xm" style="width: 1000px; border: 0px" readonly>
            </div>
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

            <!-- 右侧悬浮按钮 -->
            <div class="layui-form layuimini-form" style="padding-bottom: 100px">
                <div class="right-bottom-btn">
                    <button class="layui-btn" lay-filter="cancleBtn">
                        <i class="layui-icon layui-icon-close"></i>关闭
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
<script th:src="@{/lib/coco-message/coco-message.js}" charset="utf-8"></script>
<script th:src="@{/js/lay-config.js}" charset="utf-8"></script>
<script th:src="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
<script th:inline="javascript" type="text/javascript">
    AjaxUtil.ctx = /*[[@{/}]]*/'';
    layui.use(['form', 'treeTable', 'tableSelect', 'laydate','table'], function () {

        var form = layui.form,
            table = layui.table;
        var xmApprove = parent.getXmApproval();
        $("#xm").val(xmApprove.xm);
        form.render();

        var xgjl = new Array();
        $.ajax({
            url: AjaxUtil.ctx + 'prjAnnualbudgetXgjl/getXGJL/' + xmApprove.xmid,
            type: "post",
            async: false,
            dataType: "json",
            success: function (result) {
                xgjl = result;
            }
        });
        var field = '';
        var title = '修改';
        var dynamicColumns = [];

        for (var i = 0; i < xgjl.length; i++) {
            field = 'xg'+xgjl[i].xh;
            title = xgjl[i].xgrq+'修改';
            dynamicColumns.push({field: field, width: '13%', title: title});
        }
        var newcols =[
            {type: 'numbers', align: 'center'},
            {field: 'fymc', width: '15%', title: '费用名称'},
            {field: 'nf', width: '7%', title: '年份'},
            {field: 'xmzys', width: '5%', title: '项目总预算'},
            {field: 'sptgzt', width: '10%', title: '审批通过状态'},
            {field: 'xgjlxz', width: '13%', title: '现在'},
        ].concat(dynamicColumns);
        var currTable = table.render({
            elem: '#currentTableId',
            url: AjaxUtil.ctx + 'PrjAnnualBudgetRecord/redordData/' + xmApprove.xmid,
            method: 'post',
            cols:[newcols],
            autoSort: false,
            toolbar: '#toolbarDemo',
            defaultToolbar:['filter', 'exports'],
            limits: [20, 25, 50, 100],
            limit: 30,
            maxmin:true,
            page: true,
            skin: 'grid',
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.rows, //解析数据列表
                };
            }
        });

        // 监听取消按钮
        $("button[lay-filter='cancleBtn']").click(function () {
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        });
    });
</script>
</body>
</html>