
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8" %>
<%@ include file="header.jsp" %>
<link rel="stylesheet" type="text/css" href="<%=webpath%>/css/printOut.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/css/addDialog.css"/>
<script type="text/javascript" src="<%=webpath%>/js/business/enterprise.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/business/role.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=webpath%>/js/jquery.jqprint-0.3.js"></script>
<script src="http://www.jq22.com/jquery/jquery-migrate-1.2.1.min.js"></script>
<style>
    table.searchTable td:nth-last-child(1) {
        width: auto;
    }

    table.searchTable td {
        width: auto;
    }
    .search{
        margin:15px 55px 10px 150px;
    }
</style>
<style media="print">
    .Noprint {
        display: none;
    }

    .PageNext {
        page-break-after: always;
    }
    table.searchTable td:nth-last-child(1){
        width:40%;
    }
</style>
<script type="text/javascript">
    function clearFormVal() {
        $("#userform").form("clear");
    }
    function queryes() {
        var queryParams = {};
        var name = $("#name").val();
        queryParams['name'] = name;
        queryCouponList("<%=path%>/role/getRole.do", queryParams);
    }
    function query() {
        var queryParams = {};
        var name = $("#name").val();
        if(name == null || name == ''){
            alert("查询条件不能为空");
            return;
        }
        queryParams['name'] = name;
        queryCouponList("<%=path%>/role/getRole.do", queryParams);
    }
    function clearVal() {
        $("#frame_code").val("");
        $("#license").val("");
        $("#caseCode").val("");
        $("#createTime").val("");
        $("#finishTime").val("");
    }

    function clearValState1() {
        $("#name").val("");
    }

    $(window).ready(function () {
        var name= $("#name").val();
        var queryParams = {};
        queryParams['name'] = name;
        queryCouponList("<%=path%>/role/getRole.do", queryParams);

    })
    function openNew() {
        $(".order_undo").show();
        clearFormVal();
        // 实例化树菜单
        $('#tt').tree({
            url:'/role/getTree.do',
            lines : true,
            checkbox:true,
            loadFilter: function(data){
                if (data.d){
                    return data.d;
                } else {
                    return data;
                }
            }
        });
    }
    function submit() {
        var name = $("#name").val();
        if(name == null && name == ''){
            alert("角色名称不能为空");
            return;
        }
        var checkeds=$('#tt').tree("getChecked");
        if(checkeds == ''){
            alert("权限名称不能为空");
            return;
        }
        var ids=[];
        for(var i=0;i<checkeds.length;i++){
            ids.push(checkeds[i].id);
        }
        $.ajax({
            cache: true,
            type: "POST",
            url:"/role/insertRole.do?ids="+ids,
            data: $('#userform').serialize(),
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                if (data.flag == 1) {
                    $("#addedit_dialog").hide();
                    queryes();
                } else {
                    alert(data.msg);
                }
            }
        });

    }
</script>
<input type="hidden" id="paths" value="<%=path%>"/>
<!--希望打印时不显示的内容设置class="Noprint"样式-->
<!--IE内置打印控件IEWebBrowser-->
<OBJECT id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb"></OBJECT>
<div id="main" class="Noprint">
    <div class="search">
            <table class="searchTable">
                <tbody>
                <tr>
                    <td style="position:relative;">名称: <span id="inputnameWrap">
							<input id="name" name="endSubmitDate" type="text" value=""
                                   class="mc-ipt-text hasDatepicker" style="width:156px"/> <span
                            class="mc-ipt" style="width:215px;"> <span id="input33Tip"
                                                                       class="mc-ipt-tip-query"
                                                                       style="font-size: 11px; line-height: 20px; height: 20px;">
									<font></td>
                    <td>
                        <button class="t-button searchBtn" id="CaseInfoList2btnCtClear" type="button"
                                onclick="clearValState1();"><img class="searchIcon" src="../images/clear.png">清空
                        </button>
                        <button class="t-button searchBtn" style="margin-right:10px;" id="CaseInfoList2btnCtSearch"
                                type="button" onclick="query();"><img class="searchIcon" src="../images/search.png">搜索
                        </button>
                        <button class="t-button searchBtn2" style="margin-right:10px;"
                                type="button" onclick="openNew();">
                            <img style="width:12px;" class="searchIcon"
                                 src="../images/add.png">新增
                        </button>
                        <!--
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <button class="t-button" id="CaseInfoList2btnCtSearch" type="button" onclick="query();">
                                <font><font>
                                    &nbsp;&nbsp;搜 索&nbsp;&nbsp;</font></font></button> -->
                    </td>

                </tr>
                </tbody>
            </table>
    </div>
    <table id="datatable"></table>
</div>
<div class="order_undo" id="addedit_dialog" style="display: none;">
    <form action="" id="userform" method="post">
        <input type="hidden" value="" id="enterpriseid" name="id">
        <div class="dialog_default" style="width:1300px;" id="dialogNb">
            <div class="dialog_title" style="margin:auto;width: 40%">新增/编辑</div>
            <div class="dialog_con" style="margin-left:390px;width:40%">
                <div class="dialog_left" style="padding: 15px 40px;">
                    <table>
                        <tbody>
                        <tr>
                            <td>
                                <span class="concat">角色名称</span>
                                <div class="contactWrap"><input autocomplete="off" id="name" class="contactInput" name="name" type="text" value=""/></div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                        <div>
                            <ul id="tt" ></ul>
                        </div>
                    <div class="confirm_cancel clearfix" style="padding-top:10px;width:400px;margin-bottom: 30px">
                        <a href="javascript:void(0);" class="btn2"
                           style="margin-right:20px;margin-left:40px" onclick="submit();">提&nbsp;&nbsp;交</a>
                        <a href="javascript:void(0);" class="btn1 cancel" onclick="cancel()">取&nbsp;&nbsp;消</a>
                    </div>

                </div>
            </div>
        </div>
    </form>

</div>
<%@ include file="footer.jsp" %>