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

<!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/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>
    <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 treelist = null;
        var historylist;
        $(function () {
            try {
                $("#layout1").ligerLayout({
                    leftWidth: 250
                });
                var w = $("#form1").width() - 260;
                $("#divOrderForm").ligerPanel({
                    title: '工单信息',
                    height: 330,
                    width: w
                });
                $.ajax({
                    type: 'get',
                    url: '../../telmanage/ajax/telrecords.ashx?action=insertCallLogs&serverip=&ctiusercode=',
                    dataType: 'html',
                    success: function (res) {
                        try {
                            InitList();
                        }
                        catch (e) {
                            alert(e.Message);
                        }
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
        });
        function SetTreeValue() {
            try {
                treelist.setValue(document.getElementById("hidSeriveDeptParentId").value);
                if (document.getElementById("hidSeriveDeptParentId").value == "" || document.getElementById("hidSeriveDeptParentId").value == "0") {
                    treelist.setText("顶级部门");
                }
            }
            catch (e) {

            }
        }

        function InitList() {

            treelist = $("#drpServiceDept").ligerComboBox({
                width: 130,
                selectBoxWidth: 200,
                selectBoxHeight: 150, valueField: 'id', resize: false, treeLeafOnly: false,
                tree: {
                    url: '../../customermanage/ajax/customeredit.ashx?action=getservicedepttreelist',
                    checkbox: false,
                    height: 150,
                    ajaxType: 'get',
                    onSuccess: function (data) { SetTreeValue(); }
                },
                onSelected: function (newvalue) {
                    $("#hiddSeriveDeptId").val(newvalue);
                }
            });
            $("#txtByDept").ligerComboBox({
                width: 130,
                selectBoxWidth: 200,
                selectBoxHeight: 150, valueField: 'id', resize: false, treeLeafOnly: false,
                tree: {
                    url: '../../customermanage/ajax/customeredit.ashx?action=getservicedepttreelist',
                    checkbox: false,
                    height: 150,
                    ajaxType: 'get',
                    onSuccess: function (data) { }
                }
            });

            $("#drpProvince").ligerComboBox({
                url: '../../customermanage/ajax/customeredit.ashx?action=getregionlist',
                valueField: '_f_regionid',
                textField: '_f_regionname',
                autocomplete: true,
                onSelected: function (newvalue) {
                    $("#hiddProvinceId").val(newvalue);
                    $("#drpCity").ligerComboBox({
                        url: '../../customermanage/ajax/customeredit.ashx?action=getregionlist&regionpid=' + newvalue,
                        valueField: '_f_regionid',
                        textField: '_f_regionname', onSelected: function (newvalue) {
                            $("#hiddCityId").val(newvalue);
                        }
                    });
                }
            });
            var cid = document.getElementById("hiddCityId").value;
            var sprovinceid = document.getElementById("hiddProvinceId").value;
            if (sprovinceid != "") {
                $("#drpCity").ligerComboBox({
                    url: '../../customermanage/ajax/customeredit.ashx?action=getregionlist&regionpid=' + sprovinceid,
                    valueField: '_f_regionid',
                    textField: '_f_regionname',
                    isMultiSelect: false,
                    isShowCheckBox: false,
                    onSuccess: function (data) {
                        if (cid != "") {
                            liger.get("drpCity").setValue(cid);
                        } else {
                            liger.get("drpCity").setValue(data[0]._f_regionid);
                            document.getElementById("hiddCityId").value = data[0]._f_regionid;
                        }
                    }, onSelected: function (newvalue) {
                        $("#hiddCityId").val(newvalue);
                    }
                });
            }
            else {
                $("#drpCity").ligerComboBox({
                    data: null,
                    valueField: '_f_regionid',
                    textField: '_f_regionname',
                    isMultiSelect: false,
                    isShowCheckBox: false
                });
            }

            document.getElementById("HdPanduan").value = "";
            document.getElementById("hiddCityId").value = cid;

            BindData("txtTsType", "hiddTsType", "TSLX");

            $("#drpAfterSaleName").ligerComboBox({
                url: '../../customermanage/ajax/customeredit.ashx?action=getaftersalelist',
                valueField: '_f_userid',
                textField: '_f_username',
                autocomplete: true, onSelected: function (newvalue) {
                    $("#hiddAfterSaleNameID").val(newvalue);
                }
            });
            $("#txtByName").ligerComboBox({
                url: '../../customermanage/ajax/customeredit.ashx?action=getaftersalelist',
                valueField: '_f_userid',
                textField: '_f_username',
                autocomplete: true, onSelected: function (newvalue) {
                    $("#hiddByName").val(newvalue);
                }
            });
        }
        function SelectJDDept(deptid, deptname) {
            document.getElementById("txtJDDept").value = deptname;
            document.getElementById("hiddJDDept").value = deptid;
            try {
                $("#txtJDUser").ligerComboBox({
                    url: '../../telmanage/ajax/selectuser.ashx?action=getaftersalelist&deptid=' + deptid,
                    valueField: '_f_userid',
                    textField: '_f_username',
                    autocomplete: true, onSelected: function (newvalue) {
                        $("#hiddJDUser").val(newvalue);
                    }
                });
            }
            catch (e) { }
        }
        function BindData(objid, hiddid, param) {
            $("#" + objid).ligerComboBox({
                url: '../../customermanage/ajax/customeredit.ashx?action=getdictionarylist&param=' + param,
                valueField: '_f_dictionaryvalueid',
                textField: '_f_name',
                autocomplete: true,
                onSelected: function (newvalue) {
                    $("#" + hiddid).val(newvalue);
                }
            });
        }
        function ProvinceData() {
            $.post("../../customermanage/ajax/customeredit.ashx?action=getprovincelist", function (data, states) {
                if (states == "success") {
                    return data;
                }
            })
        }

        function GetCustomerInfo() {
            $.ajax({
                type: 'get',
                url: '../../telmanage/ajax/customeropt.ashx?action=getCustomerInfoByPhone&tel=' + document.getElementById("hfPhone").value,
                dataType: 'html',
                success: function (res) {
                    if (res != "") {
                    }
                }
            });
        }

        function OpenWindowShow1(Url, Title, Width, Height) {
            $.ligerDialog.open({
                title: Title, url: Url, height: Height, width: Width, isResize: true, modal: true, buttons: [
                    { text: '关闭', onclick: function (item, dialog) { dialog.close(); AgentFree(); } }
                ], isResize: true
            });
        }
        function OpenWindowShow(Url, Title, Width, Height) {
            $.ligerDialog.open({
                title: Title, url: Url, height: Height, width: Width, isResize: true, modal: true, isResize: true
            });
        }
        function Player(path) {
            OpenWindowShow1('voiceplay.aspx?path=' + path, '录音播放与下载', 600, 300);
        }

        function validate(optid) {
            $.ligerDialog.waitting('工单提交中...');
            return true;
        }

        function SelectCustomer() {
            var vheight = $("#form1").height();
            var vwidth = $("#form1").width() * 0.9;
            OpenWindowShow('../../telmanage/selectcustomer.aspx?name=' + escape(document.getElementById("txtCustomerName").value), "选择客户", vwidth, vheight);
        }
        function ShowCustomer(id) {
        }
        function SetCustomerInfo(F_CustomerId,
        F_CustomerName,
        F_CustomerCode,
        F_ServiceDeptID,
        F_RegionId,
        F_CityID,
        F_ServiceDept,
        F_Province,
        F_City,
        _f_chargename, F_Telephone, F_Mobile, F_ChargeTelephone) {

            document.getElementById("hiddCustomerId").value = F_CustomerId;
            document.getElementById("txtCustomerName").value = F_CustomerName;
            document.getElementById("divCustomerCode").innerHTML = "<a href=\"javascript:void(null)\" target=\"_self\" onclick=\"ShowCustomer('" + F_CustomerId + "');\">" + F_CustomerCode + "</a>";
            document.getElementById("hiddSeriveDeptId").value = F_ServiceDeptID;
            document.getElementById("hiddProvinceId").value = F_RegionId;
            document.getElementById("hiddCityId").value = F_CityID;

            document.getElementById("hiddTelephone").value = F_Telephone;
            document.getElementById("hiddMobile").value = F_Mobile;
            document.getElementById("hiddChargeTelephone").value = F_ChargeTelephone;

            document.getElementById("drpServiceDept").value = F_ServiceDept;
            document.getElementById("drpProvince").value = F_Province;
            document.getElementById("drpCity").value = F_City;

            document.getElementById("drpTelephone").value = F_Telephone;
            document.getElementById("drpMobile").value = F_Mobile;
            document.getElementById("drpChargeTelephone").value = F_ChargeTelephone;

            document.getElementById("txtTsName").value = _f_chargename;
        }
        var sgridlist;
        function FastSearch() {
            var txtobj = document.getElementById("txtJDUser");
            var txtobjcode = document.getElementById("hiddJDUser");
            var divobj = document.getElementById("divJDDept");
            var divdataobj = document.getElementById("divDataJDDept");
            if (txtobj.value == "") {
                divobj.style.display = "none";
                //divdataobj.innerHTML = "";
                txtobjcode.value = "0";
            }
            else {
                divobj.style.display = "inline";
                document.getElementById("hiddJDUser").value = "0";
                document.getElementById("hiddJDDept").value = "0";
                sgridlist = $("#divDataJDDept").ligerGrid({
                    height: 180,
                    columns: [
                { display: 'ID', name: '_f_userid', align: 'left', width: 0, hide: true },
                { display: '用户名称', name: '_f_username', width: 100 },
                { display: '部门', name: '_f_deptname', width: 150 }
                    ], url: '../../telmanage/ajax/selectuser.ashx?action=getuserbyname' + '&name=' + encodeURI(txtobj.value), pageSize: 5, rownumbers: true,
                    onDblClickRow: function (data, rowindex, rowobj) {
                        try {
                            document.getElementById("txtJDUser").value = data._f_username;
                            document.getElementById("hiddJDUser").value = data._f_userid;
                            document.getElementById("txtJDDept").value = data._f_deptname;
                            document.getElementById("hiddJDDept").value = data._f_deptid;
                        }
                        catch (e) {
                            alert(e.Message);
                        }
                        document.getElementById("divJDDept").style.display = "none";
                    }

                });
                sgridlist.changePage('first');
                $("#pageloading").hide();
            }
        }

        function pandaun() {
            if (document.getElementById("F_CODE").value == "") {
                $.ligerDialog.alert("工单记录编号不能为空！");
            }
        }
        // 2015-4-11 张高炯
        function EditAndSaveCustomerInfo() {
            //客户名称
            var cid = encodeURIComponent(document.getElementById("hiddCustomerId").value);
            if (cid == "" || cid <= 0 || cid == "undefined") { $.ligerDialog.warn('没有选择客户'); return; }
            var cname = encodeURIComponent(document.getElementById("txtCustomerName").value);
            //客户编号
            //var ccode = encodeURIComponent(document.getElementById("divCustomerCode").innerHTML);
            //所属客服部
            var sdepid = encodeURIComponent(document.getElementById("hiddSeriveDeptId").value);
            var sdep = encodeURIComponent(document.getElementById("drpServiceDept").value);
            //所属省份
            var prid = encodeURIComponent(document.getElementById("hiddProvinceId").value);
            var pr = encodeURIComponent(document.getElementById("drpProvince").value);
            //所属市县
            var ctid = encodeURIComponent(document.getElementById("hiddCityId").value);
            var ct = encodeURIComponent(document.getElementById("drpCity").value);
            //联系电话
            var tel = encodeURIComponent(document.getElementById("drpTelephone").value);
            var mobile = encodeURIComponent(document.getElementById("drpMobile").value);
            var tel1 = encodeURIComponent(document.getElementById("drpChargeTelephone").value);

            var params = "cid=" + cid + "&cname=" + cname
            //+ "&ccode=" + ccode
                        + "&sdepid=" + sdepid + "&sdep=" + sdep
                        + "&prid=" + prid + "&pr=" + pr
                        + "&ctid=" + ctid + "&ct=" + ct
                        + "&tel="
                        + tel + "&mobile=" + mobile + "&tel1=" + tel1;
            $.ajax({
                type: "get",
                url: "/telmanage/ajax/editandsavecustomerinfo.ashx?action=editAndSave",
                data: params,
                cache: false,
                success: function (res, state) {
                    if (state == "success") {
                        if (res == "True") {
                            $.ligerDialog.success('修改客户信息成功');
                        } else if (res == "False") {
                            $.ligerDialog.error('修改客户信息失败');
                        }
                    }
                }
            });
        }
        function TabCloseById() {

            document.getElementById("hfBusinessType").value = "";
            document.getElementById("hfPhone").value = "";
            document.getElementById("hfCallId").value = "";
            document.getElementById("hfTab").value = "";
            document.getElementById("hiddCustomerId").value = "";
            document.getElementById("txtCustomerName").value = "";
            document.getElementById("drpServiceDept").value = "";
            document.getElementById("hiddSeriveDeptId").value = "";
            document.getElementById("drpProvince").value = "";
            document.getElementById("hiddProvinceId").value = "";

            document.getElementById("txtTsType").value = "";
            document.getElementById("hiddTsType").value = "";
            document.getElementById("txtTsName").value = "";
            document.getElementById("txtTsPhone").value = "";
            document.getElementById("txtByDept").value = "";
            document.getElementById("hiddByDept").value = "";
            document.getElementById("txtByName").value = "";
            document.getElementById("hiddByName").value = "";
            document.getElementById("txtByPhone").value = "";
            document.getElementById("txtTsContent").value = "";

            document.getElementById("divCustomerCode").innerHTML = "";
            document.getElementById("drpCity").value = "";
            document.getElementById("hiddCityId").value = "";
            document.getElementById("HdPanduan").value = "nocity";
        }

        document.onkeydown = function (e) {
            //捕捉回车事件
            var ev = (typeof event != 'undefined') ? window.event : e;
            if (ev.keyCode == 13 && document.activeElement.id == "txtCustomerName") {
                SelectCustomer();
            }
            if (ev.keyCode == 13 && document.activeElement.id == "F_CODE") {
                pandaun();
            }
        }
    </script>
</head>
<body style="overflow: hidden;" scroll="no">
    <form id="form1" runat="server">
        <asp:HiddenField ID="hfBusinessType" Value="1" runat="server"></asp:HiddenField>
        <%--按键选择类型--%>
        <asp:HiddenField ID="hfPhone" Value="" runat="server"></asp:HiddenField>
        <%--来电号码--%>
        <asp:HiddenField ID="hfCallId" Value="0" runat="server"></asp:HiddenField>
        <%--来电callid--%>
        <asp:HiddenField ID="hfUserId" Value="0" runat="server"></asp:HiddenField>
        <asp:HiddenField ID="hfTab" Value="0" runat="server"></asp:HiddenField>
        <div id="layout1">
            <div position="left" title="客户信息" style="overflow: auto; height: 100%;">
                <table class="form_table">
                    <col width="85px" />
                    <col />
                    <tbody>
                        <tr>
                            <th>客户名称：
                            </th>
                            <td>
                                <div style="float: left;">
                                    <asp:HiddenField ID="hiddCustomerId" Value="0" runat="server" />
                                    <asp:TextBox ID="txtCustomerName" class="entertype" runat="server" CssClass="txtInput normal" Style="width: 90px;"></asp:TextBox>
                                </div>
                                <div style="float: left; padding-top: 2px;">
                                    <img src="../../images/btn_off_lookup.gif" onclick="SelectCustomer();" alt="选择客户" style="cursor: pointer;" />
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>客户编号：
                            </th>
                            <td>
                                <div id="divCustomerCode" runat="server">
                                    <a href="javascript:void(null)" target="_self" onclick="ShowCustomer('0');">0000</a>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>所属单位：
                            </th>
                            <td>
                                <asp:TextBox ID="drpServiceDept" runat="server"></asp:TextBox><asp:HiddenField ID="hiddSeriveDeptId"
                                    runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <th>所属省份：
                            </th>
                            <td>
                                <asp:TextBox ID="drpProvince" runat="server"></asp:TextBox><asp:HiddenField ID="hiddProvinceId"
                                    runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <th>所属市县：
                            </th>
                            <td>
                                <asp:TextBox ID="drpCity" runat="server"></asp:TextBox><asp:HiddenField ID="hiddCityId"
                                    runat="server" />
                                <asp:HiddenField ID="HdPanduan" runat="server" />
                            </td>
                        </tr>
                        <tr>
                            <th>联系电话1：
                            </th>
                            <td>
                                <asp:TextBox ID="drpTelephone" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox><asp:HiddenField
                                    ID="hiddTelephone" runat="server" />


                            </td>
                        </tr>
                        <tr>
                            <th>联系电话2：
                            </th>
                            <td>
                                <asp:TextBox ID="drpMobile" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox><asp:HiddenField
                                    ID="hiddMobile" runat="server" />

                            </td>
                        </tr>
                        <tr>
                            <th>联系电话3：
                            </th>
                            <td>
                                <asp:TextBox ID="drpChargeTelephone" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox><asp:HiddenField
                                    ID="hiddChargeTelephone" runat="server" />


                            </td>
                        </tr>
                        <tr>
                            <th colspan="2" style="text-align: center">
                                <input id="editandsave" type="button" title="修改并保存" value="修改并保存" class="btnSubmit" onclick="EditAndSaveCustomerInfo()" />
                            </th>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div position="center" title="">
                <div id="divOrderForm">
                    <div style="position: relative; z-index: 9999;">
                        <div id="divJDDept" ostate="0" onmouseover="this.ostate='1';" onmouseout="this.ostate='0';"
                            style="display: none; height: 180px; width: 280px; background-color: White; border: solid 1px #89BBDC; position: absolute; top: 100px; left: 488px;">
                            <div id="divDataJDDept" style="height: 180px; width: 100%; overflow-y: auto;">
                            </div>
                        </div>
                        <div id="divJDDeptZX" ostate="0" onmouseover="this.ostate='1';" onmouseout="this.ostate='0';"
                            style="display: none; height: 180px; width: 280px; background-color: White; border: solid 1px #89BBDC; position: absolute; top: 120px; left: 450px;">
                            <div id="divDataJDDeptZX" style="height: 230px; width: 100%; overflow-y: auto;">
                            </div>
                        </div>
                    </div>
                    <div id="contentTab" style="width: 100%; height: auto;">
                        <ul class="tab_nav">
                            <li id="tabli0" class="selected"><a onclick="tabs(0);" href="javascript:;">诉求问题</a></li>
                        </ul>
                        <div class="tab_con" id="tabdiv0" style="height: 180px;display: block; overflow-y: auto;">
                            <table class="form_table" style="width: 100%; height: auto;">
                                <col width="95px" />
                                <col />
                                <col width="95px" />
                                <col />
                                <col width="95px" />
                                <col />
                                <tbody>
                                    <tr>
                                        <th>诉求类型：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="txtTsType" runat="server" Style="width: 120px;"></asp:TextBox><asp:HiddenField
                                                ID="hiddTsType" runat="server" Value="0" />
                                        </td>
                                        <th>诉求人：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="txtTsName" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                                        </td>
                                        <th>诉求人电话：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="txtTsPhone" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>承办单位：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="txtByDept" runat="server" Style="width: 120px;"></asp:TextBox><asp:HiddenField
                                                ID="hiddByDept" runat="server" Value="0" />
                                        </td>
                                        <th>工单处理人</th>
                                        <td>
                                            <div style="float: left;">
                                                <asp:TextBox ID="txtJDDept" runat="server" Style="display: none;"></asp:TextBox><asp:HiddenField
                                                    ID="hiddJDDept" runat="server" Value="0" />
                                                <asp:TextBox ID="txtJDUser" runat="server" CssClass="txtInput normal" onkeyup="FastSearch();"
                                                    Style="width: 120px;"></asp:TextBox><asp:HiddenField ID="hiddJDUser" runat="server"
                                                        Value="0" />
                                            </div>
                                            <div style="float: left; padding-top: 2px; display: none;">
                                                <div id="selectDeptUser" onclick="SelectJDUser();"
                                                    alt="选择处理人" style="cursor: pointer; width: 21px; height: 19px; background: url(../images/btn_off_lookup.gif) no-repeat;">
                                                    &nbsp;
                                                </div>
                                            </div>
                                        </td>
                                        <th>直接接单说明</th>
                                        <td>
                                            <asp:TextBox ID="F_EXAMINETYPE" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox></td>
                                        <%--<th>被投诉人：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="txtByName" runat="server" Style="width: 120px;"></asp:TextBox><asp:HiddenField
                                                ID="hiddByName" runat="server" Value="0" />
                                        </td>
                                        <th>被投诉人电话：
                                        </th>
                                        <td>
                                            <asp:TextBox ID="txtByPhone" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                                        </td>--%>
                                    </tr>
                                    <tr>
                                        <th>诉求内容：
                                        </th>
                                        <td colspan="5">
                                            <textarea id="txtTsContent" cols="20" rows="2" runat="server" class="txtInput normal"
                                                style="width: 600px; height: 40px;"></textarea>
                                        </td>
                                        
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <div style="width: 100%; text-align: center; display: none;">
                            <asp:Button ID="btnSubmit" runat="server" Text="保&nbsp;&nbsp;存" CssClass="btnSubmit"
                                OnClientClick="return validate();" OnClick="btnSubmit_Click" />
                        </div>
                        <div id="divOpt0" runat="server" style="width: 100%; text-align: center;">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</body>
</html>
