<!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">
    <div class="layui-tab layui-tab-card">
        <ul class="layui-tab-title">
            <li class="layui-this">常规</li>
            <li>付款计划</li>
        </ul>
        <div class="layui-tab-content">
            <!--常规开始-->
            <div class="layui-tab-item layui-show" style="min-height: 550px; margin-bottom: 5px">
                <form class="layui-form" action="" lay-filter="formDemo">
                    <div class="layui-form layuimini-form">
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 60px">任务书</label>
                            <div class="layui-input-inline" style="width: 790px">
                                <input type="hidden" id="rws" name="rws" class="layui-input" th:value="${contract.rws}"
                                       readonly>
                                <input type="text" id="rwsmc" name="rwsmc" class="layui-input"
                                       th:value="${contract.rwsmc}" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 60px">合同名称</label>
                            <div class="layui-input-inline" style="width: 380px">
                                <input type="hidden" id="id" name="id" class="layui-input" th:value="${contract.htid}">
                                <input type="text" id="htmc" name="htmc" th:value="${contract.htmc}" class="layui-input"
                                       readonly>
                            </div>
                            <label class="layui-form-label" style="width: 100px">合同金额(万元)</label>
                            <div class="layui-input-inline" style="width: 270px">
                                <input type="number" id="htje" name="htje" class="layui-input"
                                       th:value="${contract.htje}" readonly>
                            </div>
                        </div>

                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label " style="width: 60px">招标批次</label>
                            <div class="layui-input-inline" style="width: 380px">
                                <input type="text" id="zbpc" name="zbpc" autocomplete="off" class="layui-input"
                                       th:value="${contract.zbpc}" readonly>
                            </div>
                            <label class="layui-form-label " style="width: 100px">中选单位</label>
                            <div class="layui-input-inline" style="width: 270px">
                                <input type="text" id="zxdw" name="zxdw" class="layui-input" autocomplete="off"
                                       th:value="${contract.zxdw}" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label required" style="width: 60px">执行周期</label>
                            <div class="layui-input-inline" style="width: 380px">
                                <input type="text" name="kssj" id="kssj" placeholder="开始时间" class="layui-input" lay-verify="required" lay-reqtext="开始时间不能为空"
                                       th:value="${contract.kssj}" readonly>
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 380px">
                                <input type="text" name="jssj" id="jssj" placeholder="终止时间" class="layui-input" lay-verify="required" lay-reqtext="结束不能为空"
                                       th:value="${contract.jssj}" readonly>
                            </div>
                        </div>

                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 60px">合同文件</label>
                            <div class="layuimini-container"
                                 style="margin-left: 90px; margin-right: 20px; padding-bottom: 10px">
                                <input type="hidden" id="wj" name="wj" class="layui-input" th:value="${contract.wj}">
                                <div class="layui-btn-group" style="margin-bottom: -8px">
                                    <button type="button" class="layui-btn  layui-btn-primary layui-btn-sm upload"
                                            id="upLoad1" lay-data="{fileType:'htwj'}"><i class="layui-icon"></i>上传
                                    </button>
                                    <button type="button" class="layui-btn  layui-btn-primary layui-btn-sm"
                                            lay-filter="deleteFile1"><i class="layui-icon"></i>删除
                                    </button>
                                </div>
                                <table class="layui-hide" id="currentTableId1" name="currentTableId1"
                                       lay-filter="currentTableFilter1"
                                       style="                           padding-top: 0px;margin-top: 0px"></table>
                                <label>上传招标合同、中标通知书、合同流转单。</label>
                            </div>
                        </div>

                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 60px">验收资料</label>
                            <div class="layuimini-container"
                                 style="margin-left: 90px; margin-right: 20px; margin-bottom: -30px">
                                <input type="hidden" id="yszl" name="yszl" class="layui-input"
                                       th:value="${contract.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-submit lay-filter="viewBtn">
                                <i class="layui-icon layui-icon-ok"></i>查看合同修改前数据
                            </button>
                            <button type="button" class="layui-btn" lay-filter="cancleBtn">
                                <i class="layui-icon layui-icon-close"></i>关闭
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <!--常规结束-->
            <!--付款计划开始-->
            <div class="layui-tab-item" style="min-height: 550px; padding-left: 30px; padding-right: 30px">
                <form class="layui-form" action="" lay-filter="formDemo">
                    <div class="layui-form layuimini-form">
                        <table class="layui-hide" id="currentTableId3" name="currentTableId3"
                               lay-filter="currentTableFilter3"></table>

                        <!-- 右侧悬浮按钮 -->
                        <div class="right-bottom-btn" style="margin-bottom: 5px">
                            <button class="layui-btn" lay-filter="cancleBtn">
                                <i class="layui-icon layui-icon-close"></i>关闭
                            </button>
                        </div>
                    </div>
                </form>
            </div>
            <!--付款计划结束-->
        </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 = /*[[@{/}]]*/'';

    layui.use(['form', 'table'], function () {
        var table = layui.table;
            form  = layui.form;
        var htId = $("#id").val();


        // 用于存放表格数据
        var dataHtwj = new Array();
        if ([[${contract.wj}]] != null && [[${contract.wj}]] != "") {
            dataHtwj = eval('(' + [[${contract.wj}]] + ')');
        }
        //合同文件
        table.render({
            elem: '#currentTableId1',
            data: dataHtwj,
            cols: [
                [
                    {type: 'numbers', align: 'center'},
                    {field: 'wjm', title: '文件名', width: '40%'},
                    {field: 'scrq', title: '上传日期', width: '15%', align: 'center'},
                    {field: 'sm', title: '说明', edit: 'text'}
                ]
            ],
            autoSort: false,
            limits: Number.MAX_VALUE,
            limit: 10,
            page: false,
            skin: 'grid',
            done: function (res, curr, count) { // done为数据渲染完的回调
            }
        });
        //双击（合同文件）
        table.on('rowDouble(currentTableFilter1)', function (obj) {
            window.open(obj.data.Url);
        });

        //付款计划
        table.render({
            elem: '#currentTableId3',
            url: AjaxUtil.ctx + 'prjPayplanXg/list/' + htId,
            method: 'post',
            cols: [
                [
                    {type: 'numbers', align: 'center'},
                    {field: 'jhmc', title: '计划名称', width: '15%'},
                    {field: 'fkyq', title: '付款要求', width: '20%'},
                    {field: 'zfbl', title: '支付比例（%）', width: '14%'},
                    {field: 'zfje', title: '支付金额（万元）', width: '16%'},
                    {field: 'cjsj', title: '创建时间', align: 'center'}
                ]
            ],
            autoSort: false,
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.rows //解析数据列表
                };
            }
        });
        //双击（付款计划）
        table.on('rowDouble(currentTableFilter3)', function (obj) {
            var data = obj.data;
            layer.open({
                title: '浏览付款计划',
                type: 2,
                maxmin: true,
                shade: 0.2,
                area: [layerwidth + 'px', layerheight + 'px'],
                content: AjaxUtil.ctx + 'prjPayplanXg/forView/' + data.id,
                end: function (index) {
                    layer.close(index);
                }
            });
        });

        // 用于存放表格数据
        var dataYszl = new Array();
        if ([[${contract.yszl}]] != null && [[${contract.yszl}]] != "") {
            dataYszl = eval('(' + [[${contract.yszl}]] + ')');
        }
        //验收资料
        var currTable2 = table.render({
            elem: '#currentTableId2',
            data: dataYszl,
            cols: [
                [
                    {type: 'numbers', align: 'center'},
                    {field: 'wjm', title: '文件名', width: '30%'},
                    {field: 'scrq', title: '上传日期', width: '15%', align: 'center'},
                    {field: 'sm', title: '说明'}
                ]
            ],
            autoSort: false,
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: false,
            skin: 'grid',
            done: function (res, curr, count) { // done为数据渲染完的回调
            }
        });
        //双击（验收资料）
        table.on('rowDouble(currentTableFilter2)', function (obj) {
            window.open(obj.data.Url);
        });
        form.on('submit(viewBtn)',function () {
            var index = layer.open({
                title: '浏览合同',
                type: 2,
                shade: 0.2,
                maxmin: true,
                area: ['1050px', layerheight + 'px'],
                content: AjaxUtil.ctx + 'prjContract/forView/' + htId
            });
        })
        // 监听取消按钮
        $("button[lay-filter='cancleBtn']").click(function () {
            var iframeIndex = parent.layer.getFrameIndex(window.name);
            parent.layer.close(iframeIndex);
        });
    });

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