<%--
  Created by IntelliJ IDEA.
  User: user
  Date: 2019/8/16
  Time: 14:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>工程管理</title>
    <link rel="stylesheet" href="${ctxp}/static/plugin/assets/layui/css/layui.css">
    <link rel="stylesheet" href="${ctxp}/static/plugin/assets/common.css"/>
    <script type="text/javascript" src="${ctxp}/static/plugin/assets/jquery-3.2.1.min.js"></script>
    <script src="${ctxp}/static/plugin/assets/layui/layui.js"></script>
</head>
<style>
    .layui-form-label {
        float: left;
        display: block;
        padding: 9px 15px;
        width: 100px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }
    .btn_out{
        width: 100px;
        margin: 0;
        float: right;
        margin-right:2%;
    }
    .div_main_form{
        width: 50%;
        margin-left: 10px;
    }
    .layui-icon-layer{
        display: none;
    }
    .layui-icon-file{
        display: none;
    }
    .btn-update{
        width: 90px;
    }
</style>
<body>
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">工程管理</div>
                <div class="layui-card-body">
                    <form class="layui-form" action="" style="margin-top: 10px;">
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">工程名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="hcmc" lay-verify="" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">登记人</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="person" lay-verify="" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">工程登记时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="beginName1" id="beginDate1" lay-verify="" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline">
                                    <input type="text" name="endName1" id="endDate1" lay-verify="" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">项目名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="xmmc" lay-verify="" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">项目划分</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="xmhf" lay-verify="" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">施工单位</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="sgdw" lay-verify="" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">项目登记时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="beginDate2" id="beginDate2" lay-verify="" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline">
                                    <input type="text" name="endDate2" id="endDate2" lay-verify="" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline" style="margin-left: 300px;">
                                <button class="layui-btn layui-btn-normal btn-update" lay-submit="" lay-filter="mybtnsubmit">查询</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="" style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
                        <div class="layui-btn-group">
                            <button type="button" class="layui-btn layui-btn-normal btn-update" onclick="addProject()">新建工程</button>
                            <!--<button type="button" class="layui-btn ">编辑</button>-->
                            <button type="button" class="layui-btn layui-btn-normal btn-update" onclick="refresh()">刷新</button>
                        </div>
                        <table id="table1" class="layui-table" lay-filter="table1"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#beginDate1'
        });
        laydate.render({
            elem: '#endDate1'
        });
        laydate.render({
            elem: '#beginDate2'
        });
        laydate.render({
            elem: '#endDate2'
        });

        //监听提交
        form.on('submit(mybtnsubmit)', function(data){
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return false;
        });
    });
</script>
<script>
    layui.config({
        base: 'module/'
    }).extend({
        treetable: 'treetable-lay/treetable'
    }).use(['layer', 'table', 'treetable'], function () {
        var $ = layui.jquery;
        var table = layui.table;
        var layer = layui.layer;
        var treetable = layui.treetable;

        var renderTable1 = function () {
            layer.load(2);
            treetable.render({
                treeColIndex: 0,
                treeSpid: -1,
                treeIdName: 'id',
                treePidName: 'pid',
                treeDefaultClose: false,
                treeLinkage: false,
                elem: '#table1',
                cols: [[
                    {field: 'gcmc',width:300,title: '工程名称',width:200},
                    {field:'xmsl',width:220,title:"项目数量"},
                    {field:'cjsq',width:220,title: '创建时期'},
                    {field:'djr',width:200,title:'登记人'},
                    {field:'op',align:'center',title:"操作",minWidth:160,templet:function(d){
                            ////对操作进行初始化
                            var xml = "";
                            if(d.status==1){
                                xml += "<a class='layui-btn layui-btn-primary layui-btn-xs' lay-event='look'>查看</a>"
                                    +"<a class='layui-btn layui-btn-xs' lay-event='update'>修改</a>"
                                    +"<a class='layui-btn layui-btn-normal layui-btn-xs' lay-event='add'>添加项目</a>"
                                    +"<a class='layui-btn layui-btn-warm layui-btn-xs' lay-event=''>导出</a>";
                            }
                            if(d.status==2){
                                xml +="<span>操作</span>";
                            }
                            if(d.status==3){
                                xml +="<a class='layui-btn layui-btn-xs' lay-event='update1'>编辑</a>";
                            }

                            return xml;
                        }}
                ]],
                "data": [
                    {
                        "id": "1",
                        "gcmc":"某线路工程",
                        "xmsl": "3",
                        "cjsq": "2018/8/14",
                        "djr":"home",
                        "status":"1",
                        "pid": -1
                    },
                    {
                        "id": "2",
                        "gcmc":"项目名称",
                        "xmsl": "施工单位",
                        "cjsq": "项目划分",
                        "djr":"创建时间",
                        "status":"2",
                        "pid": 1
                    },
                    {
                        "id": "3",
                        "gcmc":"某项目",
                        "xmsl": "某施工单位一",
                        "cjsq": "架空线路",
                        "djr":"2018/8/14",
                        "status":"3",
                        "pid": 2
                    },
                    {
                        "id": "4",
                        "gcmc":"某项目",
                        "xmsl": "某施工单位一",
                        "cjsq": "架空线路",
                        "djr":"2018/8/14",
                        "status":"3",
                        "pid": 2
                    },
                    {
                        "id": "5",
                        "gcmc":"某项目",
                        "xmsl": "某施工单位一",
                        "cjsq": "架空线路",
                        "djr":"2018/8/14",
                        "status":"3",
                        "pid": 2
                    },
                    {
                        "id": "6",
                        "gcmc":"某线路工程二",
                        "xmsl": "1",
                        "cjsq": "2018/8/15",
                        "djr":"home1",
                        "status":"1",
                        "pid": -1
                    },
                    {
                        "id": "7",
                        "gcmc":"项目名称",
                        "xmsl": "施工单位",
                        "cjsq": "项目类型",
                        "djr":"创建时间",
                        "status":"2",
                        "pid": 6
                    },
                    {
                        "id": "8",
                        "gcmc":"某项目",
                        "xmsl": "某施工单位一",
                        "cjsq": "架空线路",
                        "djr":"2018/8/14",
                        "status":"3",
                        "pid": 7
                    },
                    {
                        "id": "9",
                        "gcmc":"某项目",
                        "xmsl": "某施工单位一",
                        "cjsq": "架空线路",
                        "djr":"2018/8/14",
                        "status":"3",
                        "pid": 7
                    },
                ],

                done: function () {
                    layer.closeAll('loading');
                }
            });
        };
        renderTable1();
        table.on('tool(table1)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event == 'look'){
                alert("查看");
            }else if(obj.event == 'update'){
                alert("修改");
            }else if(obj.event == 'add'){
                alert("添加");
            }else if(obj.event =='update1'){
                alert("编辑");
            }
        });
    });
</script>
<script>
    function refresh(){
        window.location.reload();
    }
</script>
</body>
</html>
