@using GBLab.Entities
@model GBLab.Entities.T_Role
@using GBLab.Common.Utils
@{
    Layout = "~/Areas/Manage/Views/DefaultSkin/Shared_Back/_Layout_ContentBase.cshtml";

    // 权限列表
    var actions = ViewData["actions"] as Dictionary<string, string>;

    var ConfigInfo = ViewData["ConfigInfo"] as List<System.Web.Mvc.RelaInfo>;
}

@section Head{
    @Html.Partial("~/Areas/Manage/Views/DefaultSkin/Shared_Back/_Layout_Head_Edit.cshtml")
    <style>
        .tdright { width: 240px !important; text-align: left !important; }
        .cl-02 { }
        .cl-02 label input { margin-right: 3px; }
        .cl-03 { line-height: 30px !important }
        .cl-03 label { border: 1px solid #ccc; width: 140px !important; border-radius: 5px; line-height: 25px; display: inline-block; }
    </style>
}

@section JavaScript{
    <script language="javascript">
        //编辑
        function UserRoleRela(ActionGUID) {
            $("#IsNew").val("False");
            $("#ActionGUID").val(ActionGUID);
            Loading();
            $("#EditForm").submit();
        }

        $(".F_Contents").bind("click", function () {
            var items = $(this).parent().parent().parent().find("[name = Is_This_All]:checkbox");
            if ($(this).is(':checked') == true) {
                for (var i = 0; i < items.length; i++) {
                    $(items[i]).prop("checked", true);
                }
            }
        });

        $(".Is_This_All").bind("click", function () {
            var items = $(this).parent().parent().parent().find("[name = F_Contents]:checkbox");
            if ($(this).is(':checked') == true) {
                for (var i = 0; i < items.length; i++) {
                    $(items[i]).prop("checked", true);
                }
            } else {
                for (var i = 0; i < items.length; i++) {
                    $(items[i]).prop("checked", false);
                }
            }
        });

        $("#Is_All").bind("click", function () {
            var items = $("[name = F_Contents]:checkbox");
            var itemfunction = $("[name = Is_This_All]:checkbox");

            if ($("#Is_All").is(':checked') == true) {
                for (var i = 0; i < items.length; i++) {
                    $(items[i]).prop("checked", true);
                }
                for (var i = 0; i < itemfunction.length; i++) {
                    $(itemfunction[i]).prop("checked", true);
                }
            } else {
                for (var i = 0; i < items.length; i++) {
                    $(items[i]).prop("checked", false);
                }
                for (var i = 0; i < itemfunction.length; i++) {
                    $(itemfunction[i]).prop("checked", false);
                }
            }
        })
    </script>
}

<div data-options="region:'center',border:true">
    @using (Html.BeginForm("UserRoleRela", "User", new { action = "UserRoleRela" }, FormMethod.Post, new { ID = "EditForm", name = "EditForm", fit = "true", style = "width:100%;height:100%;" }))
    {
        @Html.Hidden("IsNew", false)
        @Html.Hidden("ActionGUID", "")
        @Html.Hidden("UserId", Request.QueryString["UserId"])
        @Html.Hidden("UserGuid", Request.QueryString["UserGuid"])
        @Html.Hidden("Template", ViewData["Template"])
        @Html.Hidden("MvcMarkName", ViewData["MvcMarkName"])
        @Html.Hidden("MvcClassID", ViewData["MvcClassID"])
        @Html.HiddenFor(m => m.F_Id)
        @Html.HiddenFor(m => m.F_Guid)
        @Html.HiddenFor(m => m.F_MarkName)
        <div class="easyui-tabs" data-options="border:false,fit:true,plain:true">
            <div title="基本信息" style="padding:5px;">
                <table class="table">
                    <thead>
                        <tr>
                            <th width="100px">权限名称：<span style="color:red; font-weight:bold;">角色配置</span></th>
                            <th width="50px"></th>
                            <th>
                                <label><input name="Is_All" type="checkbox" id="Is_All">全选</label>
                            </th>
                        </tr>
                        <tr>
                            <th style="color:blue;">菜单名称</th>
                            <th style="color:blue;">显示</th>
                            <th style="color:blue;">操作控制</th>
                        </tr>
                    </thead>
                    @foreach (var item in ConfigInfo)
                    {
                        <tr>
                            <th class="tdright" style="width: 100px;">
                                @item.F_ModuleName
                            </th>
                            <td class="cl-02" style="width: 50px;">
                                @if (item.F_Items.Count > 0)
                                {
                                    <text>
                                        <label style="color:darkorchid;"><input name="Is_This_All" type="checkbox" class="Is_This_All" value="@(item.F_Id)" @(item.F_IsCheck ? "checked=\"true\"" : "")>选中</label>
                                    </text>
                                }
                            </td>
                            <td class="cl-03" colspan="5">
                                @foreach (var midItem in item.F_Items)
                                {
                                    var _Text = midItem.F_ItemName;
                                    <text>
                                        <label title="@(midItem.F_ItemName) / @(midItem.F_Id)" @(Html.Raw(midItem.F_IsCheck ? "style=\"color:red!important;\"" : ""))>
                                            <input name="F_Contents" class="F_Contents" type="checkbox" value="@(midItem.F_Id)" @(midItem.F_IsCheck ? "checked=\"true\"" : "")>
                                            @Html.Raw(_Text)
                                        </label>
                                    </text>
                                }
                            </td>
                        </tr>
                    }
                </table>
            </div>
        </div>
    }
</div>

@*底部操作*@
<div class="dialog-button TextCenter" data-options="region:'south',border:false">
    @Html.Raw(T_FunctionAction.Get_Action_Buttons(actions["UserRoleRela"]))
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-no'" onclick="return window.parent.cancel();">取消</a>
</div>

<div id="form-windowEdit" title="查看" class="easyui-window" data-options="modal:true,closed:true,fit:true" style="width: 88%; height: 88%; padding: 6px;"></div>