<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 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">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<form class="layui-form" action="" lay-filter="formDemo" style="transform: none">
    <div class="layui-form layuimini-form" style="padding-bottom: 100px">
<!--        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">费用申请</label>
            <div class="layui-input-inline" style="width: 80%">
                <input type="text" id="fysqmc" name="fysqmc" class="layui-input" th:value="${payapproval.fysqmc}"
                       readonly>
            </div>
        </div>-->
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">任务书</label>
            <div class="layui-input-inline" style="width: 80%">
                <input type="text" id="rwsmc" name="rwsmc" class="layui-input" th:value="${payapproval.rwsmc}" readonly>
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">合同</label>
            <div class="layui-input-inline" style="width: 30%">
                <input type="text" id="htmc" name="htmc" class="layui-input" th:value="${payapproval.htmc}" readonly>
            </div>
            <label class="layui-form-label" style="width: 15%">合同金额(万元)</label>
            <div class="layui-input-inline" style="width: 30%">
                <input type="number" id="htje" name="htje" class="layui-input" th:value="${payapproval.htje}" readonly>
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">付款计划</label>
            <div class="layui-input-inline" style="width: 30%">
                <input type="text" id="fkjhmc" name="fkjhmc" class="layui-input" th:value="${payapproval.fkjhmc}+' / '+${payapproval.zfje}"
                       readonly>
            </div>
            <label class="layui-form-label" style="width: 15%; ">本次付款金额(万元)</label>
            <div class="layui-input-inline" style="width: 30%">
                <input type="number" id="bcfkje" name="bcfkje" class="layui-input" th:value="${payapproval.bcfkje}"
                       readonly>
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">合同文件</label>
            <div class="layuimini-container" style="width: 80%;margin-left: 11.8%">
                <input type="hidden" id="htwj" name="htwj" class="layui-input" th:value="${payapproval.htwj}">
                <table class="layui-hide" id="currentTableId1" name="currentTableId1"
                       lay-filter="currentTableFilter1"></table>
            </div>
        </div>
        <div class="layui-form-item layui-inline" style="width: 100%">
            <label class="layui-form-label" style="width: 10%">验收资料</label>
            <div class="layuimini-container" style="width: 80%; margin-left: 11.8%">
                <input type="hidden" id="yszl" name="yszl" class="layui-input" th:value="${payapproval.yszl}">
                <table class="layui-hide" id="currentTableId2" name="currentTableId2"
                       lay-filter="currentTableFilter2"></table>
            </div>
        </div>

        <!-- 右侧悬浮按钮 -->
        <div class="right-bottom-btn">
            <button type="button" class="layui-btn" lay-filter="cancleBtn1">
                <i class="layui-icon layui-icon-list"></i>合同文件预览
            </button>
            <button type="button" class="layui-btn" lay-filter="cancleBtn2">
                <i class="layui-icon layui-icon-list"></i>验收资料预览
            </button>
            <button type="button" class="layui-btn" lay-filter="cancleBtn">
                <i class="layui-icon layui-icon-close"></i>关闭
            </button>
        </div>
    </div>
</form>

<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="@{/lib/xm-select-v1.2.2/xm-select.js}" charset="utf-8"></script>
<script th:src="@{/js/lay-config.js}" charset="utf-8"></script>

<script type="text/javascript" th:inline="javascript">
    AjaxUtil.ctx = /*[[@{/}]]*/'';
    var travelExpense = [];//差旅费
    var updateflag = 0;//更新标志

    layui.use(['form', 'table', 'treeTable', 'layCascader'], function () {
        var form = layui.form,
            table = layui.table,
            layer = layui.layer;


        // 用于存放表格数据
        var dataHtwj = new Array();
        if ([[${payapproval.htwj}]] != null && [[${payapproval.htwj}]] != "") {
            dataHtwj = eval('(' + [[${payapproval.htwj}]] + ')');
        }
        //合同文件
        var currTable1 = table.render({
            elem: '#currentTableId1',
            data: dataHtwj,
            cols: [
                [
                    {type: 'numbers', align: 'center',width: '7%',title: '序号'},
                    {field: 'wjm', title: '文件名', width: '60%'},
                    {field: 'scrq', title: '上传日期', width: '15%', align: 'center'},
                    {field: 'sm', title: '说明',width: '20%'}
                ]
            ],
            autoSort: false,
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            done: function (res, curr, count) { // done为数据渲染完的回调
            }
        });
        //双击（合同文件）
        table.on('rowDouble(currentTableFilter1)', function (obj) {
            // window.open(obj.data.Url);
            // 创建一个对象
            var data = {
                'id': [[${payapproval.ht}]]
                ,'type':'ht'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType:"application/json",// 传输文件类型
                data: JSON.stringify(data), // 传输数据类型
                success: function (res) {

                    if (res.code === 0){
                        //你的代码
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-x: scroll;overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:20px; padding: 5px; display: inline-block;");
                            }
                        })

                    }else {

                        layer.msg(res.message,{icon: 3});
                        return false;
                    }

                },
                fail:function (res) {
                    layer.close(index);// 关闭页面
                    layer.msg(res.message,{icon:3});
                },
                error:function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员!',{icon:3})

                }
            })
        });


        // 用于存放表格数据
        var dataYszl = new Array();
        if ([[${payapproval.yszl}]] != null && [[${payapproval.yszl}]] != "") {
            dataYszl = eval('(' + [[${payapproval.yszl}]] + ')');
        }
        //验收资料
        var currTable2 = table.render({
            elem: '#currentTableId2',
            data: dataYszl,
            cols: [
                [
                    {type: 'numbers', align: 'center',width: '7%',title: '序号'},
                    {field: 'wjm', title: '文件名', width: '60%'},
                    {field: 'scrq', title: '上传日期', width: '15%', align: 'center'},
                    {field: 'sm', title: '说明',width: '20%'}
                ]
            ],
            autoSort: false,
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            done: function (res, curr, count) { // done为数据渲染完的回调
            }
        });
        // 批量查看合同文件
        $("button[lay-filter='cancleBtn1']").click(function () {
            // 创建一个对象
            var data = {
                'id': [[${payapproval.ht}]]
                ,'type':'ht'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType:"application/json",// 传输文件类型
                data: JSON.stringify(data), // 传输数据类型
                success: function (res) {

                    if (res.code === 0){
                        //你的代码
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:10px; display: inline-block;");
                            }
                        })

                    }else {

                        layer.msg(res.message,{icon: 3});
                        return false;
                    }

                },
                fail:function (res) {
                    layer.close(index);// 关闭页面
                    layer.msg(res.message,{icon:3});
                },
                error:function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员!',{icon:3})

                }
            })

        });

        // 批量查看验收资料
        $("button[lay-filter='cancleBtn2']").click(function () {
            var data = {
                'id':[[${payapproval.ht}]]
                ,'type':'ys'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType: "application/json", // 传输文件类型 韦 json 类型
                data:JSON.stringify(data), // 传输数据类型 为 Json类型
                success: function (res) {
                    console.log(res);
                    if (res.code === 0){
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:10px;  display: inline-block;");
                            }
                        })
                    }else {
                        layer.msg(res.message,{icon: 3});
                        return false;
                    }
                },
                fail: function (res) {
                    layer.close(index);
                    layer.msg(res.message,{icon : 3});

                },
                error: function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员');

                }
            })

        })
        //双击（验收资料）
        table.on('rowDouble(currentTableFilter2)', function (obj) {
            var data = {
                'id':[[${payapproval.ht}]]
                ,'type':'ys'
            }
            AjaxUtil.post({
                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
                contentType: "application/json", // 传输文件类型 韦 json 类型
                data:JSON.stringify(data), // 传输数据类型 为 Json类型
                success: function (res) {
                    console.log(res);
                    if (res.code === 0){
                        layer.tab({
                            area: ['100%', '100%'],
                            tab: res.data,
                            maxmin: true,
                            shadeClose: true,
                            success: function (index, layero) {//打开tab后的执行的内容
                                //你的代码
                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%;background-color: #f0f0f0; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
                                $("div>span").attr("style", "width:10px;  display: inline-block;");
                            }
                        })
                    }else {
                        layer.msg(res.message,{icon: 3});
                        return false;
                    }
                },
                fail: function (res) {
                    layer.close(index);
                    layer.msg(res.message,{icon : 3});

                },
                error: function (error) {
                    layer.close(index);
                    layer.msg('服务器异常！请联系管理员');

                }
            })
        });

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

    function setTravelExpense(expense) {
        travelExpense = expense;
    }

    function getTravelExpense() {
        return travelExpense;
    }

    function setUpdateFlag() {
        updateflag = 1;
    }
</script>
</body>
</html>