<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.DateFormat" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/pagination.css">
<div class="page-container">
    <div class="content" >
        <div style="width:3%;height:500px;float:left;margin-right:20px;">
            <div class="btn-primary radius " id="button1" onclick="javascript:getRightInfo('1');"  style="font-size:18px;text-align:center;height:100px;width:88%;background-color: #0A6999;margin:20px 10px;cursor: pointer;">待审批</div>
            <div class="btn-primary radius " id="button2" onclick="javascript:getRightInfo('2');"  style="font-size:18px;text-align:center;height:100px;width:88%;margin:20px 10px;cursor: pointer;">审批中</div>
            <div class="btn-primary radius " id="button3" onclick="javascript:getRightInfo('3');"  style="font-size:18px;text-align:center;height:100px;width:88%;margin:20px 10px;cursor: pointer;">已完结</div>
        </div>
        <div class="search-form" style="width:94%;float:left;">
            <form  method="post" id="data_form_search" name="data_form_search">
                <input type="hidden" name="ly_status" id="ly_status" value=""/>
                <input type="hidden" name="page_number" id="page_number" value="1"/>
                <input type="hidden" name="page_size" id="page_size" value="10"/>
            </form>
        </div>
        <div style="height:10px;background-color: #d9e4f6">
        </div>
        <div class="datalist " id="datalist" style="width:94%;float:left;">
        </div>
    </div>
</div>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.pagination.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript">
    function getRightInfo(type) {
        if(type=='1'){
            document.getElementById("button1").style.backgroundColor="#0A6999";
            document.getElementById("button2").style.backgroundColor="#5A98DE";
            document.getElementById("button3").style.backgroundColor="#5A98DE";
        }else if(type=='2'){
            document.getElementById("button2").style.backgroundColor="#0A6999";
            document.getElementById("button1").style.backgroundColor="#5A98DE";
            document.getElementById("button3").style.backgroundColor="#5A98DE";
        }else{
            document.getElementById("button3").style.backgroundColor="#0A6999";
            document.getElementById("button1").style.backgroundColor="#5A98DE";
            document.getElementById("button2").style.backgroundColor="#5A98DE";
        }
        $("#ly_status").val(type);
        searchModel();
    }
    function searchModel() {
        $.ajax({
            type: "post",
            url: "list_ajax.jsp",
            data: $('#data_form_search').serialize(),
            success: function (msg) {
                $("#datalist").html(msg);
            }
        });
    }


    function searchUserModel() {
        $("#page_number").val("1");
        searchModel();
    }
    $(function(){
        searchModel();
    });
    function chongzhi(){
        $("#page_size").val("10");
        data_form_search.reset();
        searchUserModel();
    }
    /*用户-编辑*/
    function addRules(url) {
        var abc = layer.open({
            title:'资产登记',
            type: 2,
            content: url,
            maxmin: true
        });
        layer.full(abc);
    }
    function viewSp(url) {
        var abc = layer.open({
            title:'审批资产',
            type: 2,
            content: url,
            maxmin: true
        });
        layer.full(abc);
    }
    function updateById(id){
        var abc = layer.open({
            title:"编辑",
            type: 2,
            content: "./list_ly-t.jsp?ly_id="+id+"&action=update",
            maxmin: true
        });
        layer.full(abc);
    }
    function setRules(id){
        var abc = layer.open({
            title:"添加元素",
            type: 2,
            content: "./zd_col_list_ajax-t.jsp?zd_id="+id,
            maxmin: true
        });
        layer.full(abc);
    }
    function deleteById(ly_id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: "POST",
                url: "./action.jsp",
                data: {"action":"delete","delete_id":"","ly_id":ly_id},
                success: function (msg) {
                    if (msg.indexOf("success") >= 0) {
                        layer.msg('操作成功!', {icon: 1, time: 1000},
                            function () {
                                searchModel();
                            });
                    } else {
                        layer.msg('操作失败', {
                            icon: 5,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        }, function () {
                        });
                    }
                }
            });
         })
    }
    function nahui(action,sp_id,ly_id) {
        layer.confirm('确认要拿回吗？', function (index) {
            $.ajax({
                type: "POST",
                url: "./action.jsp",
                data: {"action":action,"sp_id":sp_id,"ly_id":ly_id},
                success: function (msg) {
                    if (msg.indexOf("success") >= 0) {
                        layer.msg('操作成功!', {icon: 1, time: 1000},
                            function () {
                                searchModel();
                            });
                    } else {
                        layer.msg('操作失败', {
                            icon: 5,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        }, function () {
                        });
                    }
                }
            });
        })
    }
</script>