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

<!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 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/json2.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 src="../scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        var count = 0;
        var counts = 0;
        $(function () {
            LoadList();
        });
        var singleClick;
        function LoadList() {
            count += 1;
            counts = count;
            var sql = GetSql();
            try {
                gridlist = $("#divDataList").ligerGrid({
                    checkbox: true,
                    height: '90%',
                    columns: [
                { display: 'Id', name: '_f_expbaseid', hide: '_f_manid', width: 1 },
                { display: '扩展代码', name: '_f_fieldname', width: 110 },
                { display: '扩展字段名', name: '_f_showname', width: 180 },
                { display: '所属表名', name: '_f_tablename', width: 80, render: getTableName },
                { display: '扩展类型', name: '_f_showtype', width: 100, render: getTypeName },
                { display: '字典值', name: '_f_dictvalue', width: 100 }
                ],
                    url: 'ajax/expandlist.ashx?action=getallexpandlist&keywords=' + encodeURIComponent(document.getElementById("txtKeywords").value), pageSize: 10, rownumbers: true,
                    onSelectRow: function (data, rowindex, rowobj) {
                        singleClick = data._f_manid;
                    },
                    onDblClickRow: function (data, rowindex, rowobj) {
                        Edit('modify');
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function GetSql() {
            var sql = "";
            return sql;
        }
        function getTableName(rowdata, index, value, columns) {
            var param;
            switch (value) {
                case "T_Cus_CustomerBase":
                    param = "客户表";
                    break;
                case "T_Wo_WorkOrderBase":
                    param = "工单表";
                    break;
                default:
                    param = "表错误"
            }
            return param;
        }
        function getTypeName(rowdata, index, value, columns) {
            var param;
            switch (value) {
                case 1:
                    param = "文本框";
                    break;
                case 2:
                    param = "下拉框";
                    break;
                case 3:
                    param = "日期控件";
                    break;
                default:
                    param = "类型错误"
            }
            return param;
        }
        function Delete() {
            try {
                //获取选择的行
                var rows = gridlist.getSelectedRows();
                if (rows.length > 0) {
                    $.ligerDialog.confirm('确定要批量删除选择的记录吗？', function (yes) {
                        if (yes) {
                            try {
                                var arr = new Array();
                                var i = 0;
                                for (var i = 0; i < rows.length; i++) {
                                    arr[i] = rows[i]._f_manid;
                                }
                                $.post("ajax/person.ashx?action=delete&arrid=" + arr.toString(), function (data) {
                                    if (data == "success") {
                                        $.ligerDialog.success('删除成功');
                                        LoadList();
                                    }
                                    else {
                                        $.ligerDialog.error('删除失败');
                                    }
                                });
                            }
                            catch (e) {
                                alert(e.Message);
                            }
                        }
                        else {
                        }
                    });
                }
                else {
                    $.ligerDialog.error('没有选择要删除的联系人');
                }
            }
            catch (e) {
                $.ligerDialog.error(e.Message);
            }
        }
        function AddPerson() {
            var vheight = $("#form1").height();
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 800) {
                vwidth = 800;
            }
            $.ligerDialog.open({ url: 'personedit.aspx?actionFlag=add', title: '添加客户联系人信息',
                height: vheight, width: vwidth, isResize: true
            });
        }
        function Edit(params) {
            if (count > 1) {
                count -= 1;
                return;
            } else {
                count = counts;
                if (singleClick == "" || singleClick == undefined) {
                    $.ligerDialog.error("请选择修改行！");
                } else {
                    var vheight = $("#form1").height();
                    var vwidth = $("#form1").width() * 0.9;
                    if (vwidth > 800) {
                        vwidth = 800;
                    }
                    $.ligerDialog.open({ url: 'personedit.aspx?actionFlag=' + params + '&personId=' + singleClick,
                        title: '修改客户联系人信息', height: vheight, width: vwidth, isResize: true
                    });
                }
            }
        }
        function Export() {
            if (singleClick == "" || singleClick == undefined) {
                $.ligerDialog.error("请选择导出行！");
            }
        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                LoadList();
            }
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar">
            <a class="tools_btn" href="#" onclick="AddPerson();"><span><b class="add">添加</b></span>
            </a><a class="tools_btn" href="#" onclick="Edit('modify');"><span><b class="modify">
                修改</b></span> </a><a class="tools_btn" href="#" onclick="Delete();"><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="divDataList">
    </div>
    </form>
</body>
</html>
