<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GiveChild_List.aspx.cs" Inherits="Base_Employee_GiveChild_List" %>
<%@ Register Src="~/Scripts/AWGridRuntime/UserControl/ListHeader.ascx" TagPrefix="uc1" TagName="ListHeader" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <uc1:ListHeader runat="server" ID="ListHeader" />
    <script type="text/javascript">
        var parent_ele_id = '<%=Request["parent_ele_id"]%>';
        //搜索
        function search_grid() {
            var fg = document.getElementById("frame_grid");
            var keyword = $("#keyword").val();
            var url = "GiveChild_List_Grid.aspx?keyword=" + escape(keyword);
            fg.src = url;
        }
        //新增
        function add() {
            asyncbox.open({
                id: 'win_modify',
                url: '../../Component/AdvancedSearch/Employee_Select.aspx?parent_ele_id=' + parent_ele_id,
                modal: true,
                width: 600,
                height:450,
                title:'新增下级'
	        });
        }
        //修改
        function modify() {
           
        }
        //删除
        function del() {
            var fg = document.getElementById("frame_grid"); //得到grid控件所在iframe
            var cw = fg.contentWindow;
            var data = fg.aw_myData;
            var id = cw.aw_GetSelectRows(cw._ec_id);//返回一维数组
            if (id.length == 0) {
                AlertNO('请选择要删除的下级!');
                return;
            }
            asyncbox.confirm('确定要删除吗', '警告', function (buttonResult) {
                if (buttonResult == "ok") {
                    ShowLoadingMask(); //显示遮罩
                    $.ajax({
                        type: "POST",
                        contentType: "application/json",
                        url: "GiveChild_Service.asmx/Delete",
                        data: "{ids:'" + id + "'}",
                        dataType: 'json',
                        success: function (result) {
                            var r = result.d;
                            if (r == "success") {
                                AlertOK('删除成功!');
                                search_grid();
                            } else {
                                AlertNO(r);
                            }
                            HideLoadingMask(); //关闭遮罩
                        }
                    });
                }
            });
        }
        //选择
        function select_emplyoee(ele_id) {
            ShowLoadingMask(); //显示遮罩
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: "GiveChild_Service.asmx/GiveChild",
                data: "{parent_ele_id:'" + parent_ele_id + "',ele_ids:'" + ele_id + "'}",
                dataType: 'json',
                success: function (result) {
                    var r = result.d;
                    if (r == "success") {
                        AlertOK('添加下级成功!');
                        search_grid();
                    } else {
                        AlertNO(r);
                    }
                    HideLoadingMask(); //关闭遮罩
                }
            });
        }
    </script>
</head>
<body onload="search_grid();load_tree();">
    <!--工具栏-->
    <div style="height:30px;" class="list_menu_bar">
        <input type="text" class="keyword_box" id="keyword"/>
        <a plain="true" class="easyui-linkbutton" onclick="search_grid()">搜索</a>
        <a plain="true" class="easyui-linkbutton" onclick="add()" style='<%=auth.AuthView("Base_Employee_GiveChild")%>'>新增下级</a>
        <a plain="true" class="easyui-linkbutton" onclick="del()" style='<%=auth.AuthView("Base_Employee_GiveChild")%>'>删除下级</a>
        <a plain="true" class="easyui-linkbutton" onclick="DesignModuleFormat('Base_Employee_Child_List')" style='<%=auth.FormatView()%>'>格式</a>
    </div>
    <!--Grid控件所在的iframe-->
    <iframe id="frame_grid" frameborder="0" style="width:100%;height:98%" scrolling="no"></iframe>
</body>
</html>
