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

<!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 type="text/javascript" src="../../scripts/function.js"></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/ui/js/plugins/ligerTab.js" type="text/javascript"></script>
    <script src="../../scripts/ui/js/plugins/ligerDrag.js" type="text/javascript"></script>
    <script src="../../scripts/CustomersData.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" />
    <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 gridlist;
        var count = 0;
        var counts = 0;
        var sql = "";
        $(function () {
            InitList();
            //$("#tab1").ligerTab();
        });

        function bSearch() {
            sql = "";
            InitList();
        }
        var arrayObj = new Array();
        function InitList() {
            count += 1;
            counts = count;
            var sql = GetSql();
            try {
                gridlist = $("#divDataList").ligerGrid({
                    height: '100%',
                    columns: [
                { display: '操作', isSort: false, width: 100, render: function (rowdata, rowindex, value) {
                    var h = "";
                    if (!rowdata._editing) {
                        //h += "<a href='javascript:onclick=geta(" + rowdata._f_id + ")'>处理</a> ";
                        h += "<a href='javascript:ShowInfo(" + rowdata._f_workorderid + ")'>详情</a> ";
                    }
                    return h;
                }
                },
                { display: '状态', name: '_f_name', width: 80 },
                { display: '来电类型', name: '_f_typename', width: 80 },
//                { display: '报修级别', name: '_f_repairlevelname', width: 80 },
                { display: '制单人', name: '_f_username', width: 80 },
                { display: '新建时间', name: '_f_createdate', width: 150, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' },
                { display: 'Id', name: '_f_workorderid', hide: 'Id', width: 1 },
                { display: '工单记录编号', name: '_f_code', width: 140 },
                { display: '会员姓名', name: '_f_customername', minWidth: 120 },
                { display: '来电人', name: '_f_repairmanname', width: 80 },
                { display: '来电人联系方式', name: '_f_repairmanphone', width: 120 }
//                { display: '客户属性', name: '_f_customernature', width: 80 },
//                { display: '系统类型', name: '_f_systemtype', width: 120 },
//                { display: '客户归属部门', name: '_f_servicedept', width: 120 },
//                { display: '质保到期时间', name: '_f_qualityguaranteeendtime', width: 150, type: 'date', format: 'yyyy-MM-dd hh:mm:ss' }
//                ,{ display: '是否形成知识', name: '_f_instanceid', width: 100, render: getStateInfo },
//                { display: '是否已形成知识', name: '_f_instanceid', width: 100, render: getStateInfo }
                ],

                    url: '../ajax/workorderstatelist.ashx?action=getallstatelist&whereSql=' + sql, pageSize: 10, rownumbers: true,
                    onDblClickRow: function (data, rowindex, rowobj) {
                        try {
                            if (count > 1) {
                                count -= 1;
                                return;
                            } else {
                                count = counts;
                                ShowInfo(data._f_workorderid);
                            }
                        }
                        catch (e) {
                            alert(e.Message);
                        }
                    },
                    onSuccess: function (data, grid) {
                        if (count > 1) {
                            count -= 1;
                            return;
                        } else {
                            count = counts;
                            arrayObj = [];
                            for (var i = 0; i < 10; i++) {
                                if (data.Rows[i] != undefined) {
                                    arrayObj.push(data.Rows[i]._f_workorderid);
                                }
                            }
                        }
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function getStateInfo(rowdata, index, value, columns) {
            var param;
            if (columns.display == "是否形成知识") { param = "knowledge" }
            if (columns.display == "是否已形成知识") { param = "alreadyknowledge" }
            $.ajax({
                type: "get",
                url: "/workordermanage/ajax/workorderstatelist.ashx?action=getstateinfo&id=" + rowdata._f_instanceid + "&type=" + param,
                async: false,
                success: function (data, states) {
                    if (states == "success") {
                        param = data;
                    }
                }
            });
            return param;
        }
        function NextWorkOrderId(id, dir) {
            var length = arrayObj.length;
            for (var j = 0; j < length; j++) {
                if (arrayObj[j] == id) {
                    if (dir == "next") {
                        if (parseInt(j + 1) < length)
                            ShowInfo(arrayObj[j + 1]);
                        else
                            $.ligerDialog.warn('没有了');
                    }
                    else if (dir == "pre") {
                        if (j - 1 >= 0)
                            ShowInfo(arrayObj[j - 1]);
                        else
                            $.ligerDialog.warn('没有了');
                    }
                }
            }
        }
        function ShowInfo(id) {
            var w = $("#form1").width() - 20;
            var h = $("#form1").height();
            //OpenWindowShow('workordershow.aspx?id=' + id, '查看工单详细', w, h);
            OpenWindowShow('workordervipshow.aspx?id=' + id, '查看工单详细', w, h);
        }
        function OpenWindowShow(Url, Title, Width, Height) {
            $.ligerDialog.open({ title: Title, url: Url, height: Height, width: Width, isResize: true, modal: true, isResize: true
            });
        }

        function geta(param) {
            //alert(param);
        }
        function getdetail(workorderid) {
            var vheight = $("#form1").height() - 90;
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 800) {
                vwidth = 600;
            }
            $.ligerDialog.open({ url: 'workorderdetail.aspx?workorderid=' + workorderid, title: '处理信息', height: vheight, width: vwidth, isResize: true
            });
        }

        function GetSql() {
            if (sql == "undefined")
            {sql = "";}
            if (document.getElementById("HdUserid").value != "") {
                sql += "&userid=" + document.getElementById("HdUserid").value;
            }
            if (document.getElementById("_f_createdate").value != "") {
                sql += "&createdate=" + escape(document.getElementById("_f_createdate").value);
            }
            if (document.getElementById("_f_customername").value != "") {
                sql += "&customername=" + escape(document.getElementById("_f_customername").value);
            }
            if (document.getElementById("_f_repairmanname").value != "") {
                sql += "&repairmanname=" + escape(document.getElementById("_f_repairmanname").value);
            }
            if (document.getElementById("HdOwnerid").value != "") {
                sql += "&ownerid=" + document.getElementById("HdOwnerid").value;
            }
            if (document.getElementById("HdGDType").value != "") {
                sql += "&gdtype=" + document.getElementById("HdGDType").value;
            }
            return sql;
        }

        function Search(str) {
            sql = "";
            if (str != "") {
                sql += str;
            }
            InitList();
        }

        function tabs(tabId) {
            for (var i = 0; i <= 1; i++) {
                if (tabId == i) {
                    document.getElementById("tabli" + i).className = "selected";
                    document.getElementById("tab_" + i).style.display = "block";
                }
                else {
                    document.getElementById("tabli" + i).className = "";
                    document.getElementById("tab_" + i).style.display = "none";
                }
            }
        }
        function SearchGaoJi() {
            $.ligerDialog.open({ url: 'workorderSearchGaoJi.aspx', title: '高级搜索', height: 360, width: 600, isResize: true
            });
        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                bSearch();
            }
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar">
            <div class="search_box">
                <asp:HiddenField ID="HdUserid" runat="server" />
                <asp:HiddenField ID="HdOwnerid" runat="server" />
                <asp:HiddenField ID="HdGDType" runat="server" />
                <div class="search_box">
                    新建时间：<asp:TextBox ID="_f_createdate" runat="server" CssClass="txtInput" Width="80px" onfocus="WdatePicker({skin:'whyGreen'})"></asp:TextBox>&nbsp;&nbsp;
                    客户名称：<asp:TextBox ID="_f_customername" runat="server" CssClass="txtInput" Width="80px"></asp:TextBox>&nbsp;&nbsp;
                    来电人：<asp:TextBox ID="_f_repairmanname" runat="server" CssClass="txtInput" Width="80px"></asp:TextBox>&nbsp;&nbsp;
                    <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="bSearch();" />&nbsp;&nbsp;
                        <input id="btnSearchGaoJi" type="button" value="高级搜索" class="btnSearch"  onclick="SearchGaoJi();"/>
                </div>
            </div>
        </div>
    </div>
    <div id="divDataList">
    </div>
    </form>
</body>
</html>
