<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="basedatalist.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.sysmanage.basedatalist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>基本数据管理</title>
    <link href="../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerMenu.js" type="text/javascript"></script>
    <script src="../scripts/CustomersData.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var menu;
        var actionNodeID;
        var gridlist;
        var singleClick;
        var NodeSingId;
        var ClickSingId;
        function itemclick(item, i) {
            alert(actionNodeID + " | " + item.text);
        }
        $(function () {
            $("#layout1").ligerLayout({
                leftWidth: 200
            });

            menu = $.ligerMenu({ top: 100, left: 100, width: 120, items:
            [
            { text: '增加', click: itemclick, icon: 'add' },
            { text: '修改', click: itemclick },
            { line: true },
            { text: '查看', click: itemclick }
            ]
            });

            TreeData();
            LoadList();
        });

        function TreeData() {
            $("#tree1").ligerTree({
                nodeWidth: 135,
                checkbox: false,
                url: '../sysmanage/ajax/basedatalistAction.ashx?action=Getexpstate',
                onClick: function (node, e) {
                    actionNodeID = node.data.id;
                    NodeSingId = node.data.id;
                    ClickSingId = "";
                    LoadList();
                }
            });
        }



        function getWhereStr() {
            var keyWords = "";
            if (document.getElementById("txtKeywords").value != "") {
                keyWords += document.getElementById("txtKeywords").value;
            }
            return keyWords;
        }
        function LoadList() {
            if (actionNodeID == undefined) {
                actionNodeID = "";
            }
            gridlist = $("#divDataList").ligerGrid({
                height: '90%',
                columns: [
                { display: '选项值', name: 'F_ValueCode', align: 'left', width: 100, minWidth: 60 },
                { display: '选项名称', name: 'F_Name', minWidth: 60 },
                 { display: '选项类别', name: 'F_DictionaryFlag', minWidth: 60 },
                { display: '状态', name: 'F_State', minWidth: 60, render: function (rowdata, rowindex) {
                    if (rowdata.F_State == 0) { return '正常'; }
                    else { return '注销'; }
                }
                }
                ], url: '../sysmanage/ajax/basedatalistAction.ashx?action=getbasedataList&keyWords=' + getWhereStr() + '&basedataID=' + actionNodeID, pageSize: 50, pageSizeOptions: [10, 20, 50, 100], rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj) {
                    singleClick = data.F_DictionaryValueId;
                    ClickSingId = data.F_DictionaryValueId;
                    NodeSingId = "";
                }
            });
            $("#pageloading").hide();
        }

        function Deletebasedata() {
            var row = gridlist.getSelectedRows();
            var idStr = "";
            jQuery.each(row, function (i, val) {
                idStr += val.F_DictionaryValueId + ",";
            });
            idStr = idStr.substring(0, idStr.length - 1);
            if (idStr == "") {
                alert("请选择删除行！");
            } else {
                $.ligerDialog.confirm('确定要删除吗?', function (yes) {
                    if (yes) {
                        gridlist = $("#divDataList").ligerGrid({
                            url: '../sysmanage/ajax/basedatalistAction.ashx?action=delete&taolCount=' + idStr, pageSize: 10, rownumbers: true
                        });
                    }
                    LoadList();
                });
            }
        }

        function Add() {
            if (actionNodeID == "" || actionNodeID == "ZH") {
                $.ligerDialog.confirm('您要添加选项类型吗?如果不是请选取类型！', function (yes) {
                    if (yes) {
                        $.ligerDialog.open({ url: 'basedataedit.aspx?Flasge=Add', title: '添加基础数据类型', height: 350, width: 500, isResize: true
                        });
                    }
                });
            } else { 
            $.ligerDialog.open({ url: 'basedataedit.aspx?Flasge=AddData&Nodeid=' + actionNodeID, title: '添加基础数据类型', height: 350, width: 500, isResize: true
              });
            }
        }


        function modifyEdit() {
            if ((NodeSingId == "" || NodeSingId == "ZH" || NodeSingId == undefined) && (ClickSingId == "" || ClickSingId == undefined)) {
                alert("请选择要修改的类型或者数据信息！");
            } else {
                if ((NodeSingId != "" || NodeSingId != "ZH") && (ClickSingId == "" || ClickSingId ==undefined)) {
                  $.ligerDialog.open({ url: 'basedataedit.aspx?Flasge=Edit&NodeidEdit=' + NodeSingId, title: '修改基础数据类型', height: 350, width: 500, isResize: true
                  });
                }
                if ((NodeSingId == "" || NodeSingId == "ZH") && (ClickSingId != "" || ClickSingId != undefined)) {
                    // 这是actionNodeID 为空的情况
                    $.ligerDialog.open({ url: 'basedataedit.aspx?Flasge=EditGrid&ClickSingId=' + ClickSingId, title: '修改基础数据数据', height: 350, width: 500, isResize: true
                    });
            }
            }
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar"><a class="tools_btn" href="#" onclick="Add();">
                <span><b class="add">添加</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="modifyEdit();">
                <span><b class="modify">修改</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="Deletebasedata();">
                <span><b class="delete">批量删除</b></span>
            </a>
            
            <div class="search_box">
                
                关键字：<asp:TextBox ID="txtKeywords" runat="server" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="LoadList();" />
            </div>
        </div>
    </div>
    <div id="layout1">
        <div position="left" title="数据类别">
        <ul id="tree1">
        <li>
            <span>所有类别</span>
            <ul>
                <li>
                    <span>发货方式</span>
                 </li>
                 <li><span>订单状态</span></li>
            </ul>
        </li> 
    </ul>
        </div>
        <div position="center" title="数据列表">
        <div id="divDataList">
    </div>
        </div>
    </div>
    </form>
</body>
</html>
