<!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>
        </ul>
        <div class="layui-tab-content">
            <!--常规开始-->
            <div class="layui-tab-item layui-show" style="min-height: 500px">
                <form class="layui-form" action="" lay-filter="formDemo">
                    <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: 85px">课题名称</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="hidden" id="id" name="id" th:value="${subtopic.id}" class="layui-input"
                                       readonly>
                                <input type="text" id="ktmc" name="ktmc" th:value="${subtopic.ktmc}" class="layui-input"
                                       readonly>
                            </div>
                         <!--   <label class="layui-form-label" style="width: 110px">序号</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="number" id="xh" name="xh" th:value="${subtopic.xh}" class="layui-input"
                                       readonly>
                            </div>-->
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 85px">负责人</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="text" id="fzrxm" name="fzrxm" th:value="${subtopic.fzrxm}"
                                       class="layui-input" readonly>
                            </div>
                            <label class="layui-form-label" style="width: 110px">负责人所在单位</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="text" id="fzrszdwmc" name="fzrszdwmc" th:value="${subtopic.fzrszdwmc}"
                                       class="layui-input" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 85px">负责人2</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="text" id="fzr2xm" name="fzr2xm" th:value="${subtopic.fzr2xm}"
                                       class="layui-input" readonly>
                            </div>
                            <label class="layui-form-label" style="width: 110px">负责人2所在单位</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="text" id="fzrsz2dwmc" name="fzr2szdwmc" th:value="${subtopic.fzr2szdwmc}"
                                       class="layui-input" readonly>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label" style="width: 85px">单位分工</label>
                            <div class="layuimini-container"
                                 style="width: 850px; margin-left: 113px; margin-bottom: -10px">
                                <table class="layui-hide" id="currentTableId1" lay-filter="currentTableFilter1"></table>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 85px">主要研究内容</label>
                            <div class="layui-input-inline" style="width: 850px">
                                <textarea id="zyyjnr" name="zyyjnr" class="layui-textarea" th:text="${subtopic.zyyjnr}"
                                          style="width: 100%;height: 100px" readonly></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label" style="width: 85px">经费(万元)</label>
                            <div class="layui-input-inline" style="width: 350px">
                                <input type="number" id="jf" name="jf" class="layui-input" th:value="${subtopic.jf}"
                                       readonly>
                            </div>
                            <label class="layui-form-label" style="width: 110px">起止时间</label>
                            <div class="layui-input-inline" style="width: 162px">
                                <input type="text" name="qssj" id="qssj" class="layui-input" th:value="${subtopic.qssj}"
                                       readonly>
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline" style="width: 162px">
                                <input type="text" name="jssj" id="jssj" class="layui-input" th:value="${subtopic.jssj}"
                                       readonly>
                            </div>
                        </div>
                        <div class="layui-form-item layui-inline" style="width: 100%">
                            <label class="layui-form-label required" style="width: 100px">子课题研究计划</label>
                            <div class="layuimini-container" style="width: 850px; margin-left: 113px">
                                <div class="layui-btn-group" style="margin-bottom: -8px">
                                    <button type="button" class="layui-btn  layui-btn-primary layui-btn-sm"
                                            lay-filter="subAdd2"><i class="layui-icon"></i>新建
                                    </button>
                                    <button type="button" class="layui-btn  layui-btn-primary layui-btn-sm"
                                            lay-filter="subEdit2"><i class="layui-icon"></i>编辑
                                    </button>
                                    <button type="button" class="layui-btn  layui-btn-primary layui-btn-sm"
                                            lay-filter="subView2"><i class="layui-icon">&#xe63c;</i>查看
                                    </button>
                                    <button type="button" class="layui-btn  layui-btn-primary layui-btn-sm"
                                            lay-filter="subDelete2"><i class="layui-icon"></i>删除
                                    </button>
                                </div>
                                <table class="layui-hide" id="currentTableId2" lay-filter="currentTableFilter2"></table>
                            </div>
                        </div>
                        <!-- 右侧悬浮按钮 -->
                        <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>
            <!--常规结束-->
            <!--            &lt;!&ndash;计划开始&ndash;&gt;-->
            <!--            <div class="layui-tab-item"  style="height: 500px; padding-left: 20px; padding-right: 20px">-->
            <!--                <form class="layui-form" action="" lay-filter="formDemo">-->
            <!--                    <div class="layuimini-form" style="padding-bottom: 100px">-->
            <!--                        <table class="layui-hide" id="currentTableId2" lay-filter="currentTableFilter2"></table>-->
            <!--                        &lt;!&ndash; 右侧悬浮按钮 &ndash;&gt;-->
            <!--                        <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>-->
            <!--            &lt;!&ndash;计划结束&ndash;&gt;-->
        </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 fgCompany = [];//当前分工单位
    var subtopicPlan = [];//当前子课题计划

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

        var zktId = $("#id").val();

        // 用于存放表格数据
        var dataCompany = new Array();
        $.ajax({
            url: AjaxUtil.ctx + 'prjDivisioncompany/list/' + zktId,
            type: "post",
            async: false,
            dataType: "json",
            success: function (result) {
                dataCompany = result.data.rows;
            }
        });
        //单位分工
        table.render({
            elem: '#currentTableId1',
            data: dataCompany,
            cols: [
                [
                    {type: 'numbers', title: '序号', width: '8%', align: 'center'},
                    {field: 'dwmc', title: '单位', width: '30%'},
                    {field: 'zyyjnr', title: '主要研究内容', width: '40%'},
                    {field: 'jf', title: '经费(万元)'}
                ]
            ],
            limit: Number.MAX_VALUE
        });
        //双击(单位分工)
        table.on('rowDouble(currentTableFilter1)', function (obj) {
            var data = obj.data;
            fgCompany = {
                "xh": data.xh,
                "dwmc": data.dwmc,
                "dwqc": data.dwqc,
                "zyyjnr": data.zyyjnr,
                "jf": data.jf
            };

            layer.open({
                title: '浏览分工单位',
                type: 2,
                // maxmin: true,
                shade: 0.2,
                area: [layerwidth + 'px', layerheight + 'px'],
                content: AjaxUtil.ctx + 'prjDivisioncompany/forView',
                end: function (index) {
                    layer.class(index);
                }
            });
        });

        //子课题计划
        var dataPlan = new Array();
        $.ajax({
            url: AjaxUtil.ctx + 'prjSubtopicplan/list/' + zktId,
            type: "post",
            async: false,
            dataType: "json",
            success: function (result) {
                dataPlan = result.data.rows;
            }
        });
        table.render({
            elem: '#currentTableId2',
            data: dataPlan,
            cols: [
                [
                    {type: 'numbers', align: 'center',title: '序号'},
                    {field: 'yjnr', title: '研究内容', width: '35%'},
                    {field: 'khzb', title: '考核指标', width: '25%'},
                    {field: 'qssj', title: '起始时间', width: '15%', align: 'center'},
                    {field: 'jssj', title: '结束时间', width: '15%', align: 'center'}
                ]
            ],
            autoSort: false,
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true
        });
        //双击(子课题计划)
        table.on('rowDouble(currentTableFilter2)', function (obj) {
            var data = obj.data;
            subtopicPlan = {
                "zktmc": $("#ktmc").val(),
                "yjnr": data.yjnr,
                "khzb": data.khzb,
                "qssj": data.qssj,
                "jssj": data.jssj
            };

            layer.open({
                title: '浏览子课题计划',
                type: 2,
                // maxmin: true,
                shade: 0.2,
                area: [layerwidth + 'px', layerheight + 'px'],
                content: AjaxUtil.ctx + 'prjSubtopicplan/forView'
            });
        });

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

    //获取分工单位
    function getFgCompany() {
        return fgCompany;
    }

    function getSubtopicPlan() {
        return subtopicPlan;
    }
</script>
</body>
</html>