var srvID = "";
var userID = "";
var auPro = "";
var mPage = 1;
var firstLoad = 0;
var ifrm;
if ('ontouchstart' in document.documentElement) document.write("<script src='Scripts/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
function resize_r() {
    var s = 0;
    var ss = $(window.parent.document).find('iframe[id=' + ifrm + ']');
    var l = $(window.parent.document).height() - ss.offset().top;
    var t = $(document).height();
    if (l > t) {
        s = l;
    }
    else {
        s = $(document).height();
    }
    $($(window.parent.document).find('iframe[id=' + ifrm + ']')).height(s);
    window.parent.sidebar_r();
}
function ClickEvent() {
    $('[data-rel=tooltip]').tooltip();
    $('[data-rel=popover]').popover({ html: true });
}
jQuery(function ($) {
    $('[data-rel=tooltip]').tooltip();
    $('[data-rel=popover]').popover({ html: true });
});
$(function () {
    $(document).on('click', 'th input:checkbox', function () {
        var that = this;
        $(this).closest('table').find('tr > td:first-child input:checkbox')
			    .each(function () {
			        this.checked = that.checked;
			        $(this).closest('tr').toggleClass('selected');
			    });
    });
    $("#PSize").change(function () {
        firstLoad = 0;
        mPage = 1;
        LoadFenye($("#PSize").val(), 1);
    });
});
function createPage(pageSize, buttons, total) {
    $("#z_p").jBootstrapPage({
        pageSize: pageSize,
        total: total,
        maxPageButton: buttons,
        onPageClicked: function (obj, pageIndex) {
            mPage = pageIndex + 1;
            LoadFenye($("#PSize").val(), mPage);
        }
    });
}
function existRole(s, p) {
    var e = p.indexOf(s);
    if (e == -1) {
        return false;
    }
    else {
        return true;
    }
}
function iniParms() {
    var coks = document.cookie.substring(document.cookie.indexOf('userinf_tcwl'));
    var ary = coks.split(';');
    var ary1 = ary[0].split('=');
    if (!ary1[2]) {
        $('html').empty();
        return;
    }
    userID = ary1[2].split('&')[0];
    srvID = ary1[3];
    $('#Huserid').val(userID);
    $('#Hsrvid').val(srvID);
    var s = window.location.href.split('=');
    if (s.length == 4) {
        ifrm = s[3];
    }
    resize_r();
    var coksau = document.cookie.substring(document.cookie.indexOf('TCWL_All'));
    var aryau = coksau.split(';');
    var aryau1 = aryau[0].split('=');
    auPro = aryau1[2];

    $('#checkform button').each(function (i, e) {
        var tag = $(e).attr('tag');
        if (tag) {
            if (existRole(tag, auPro)) {
                $(e).show();
            }
        }
    });
    LoadData($("#PSize").val(), 1);
}
function LoadData(pagesize, page) {
    $('th input:checkbox').removeAttr("checked");
    var l = layer.load('正在加载数据......');
    $.ajax({
        url: "../Handlers/StationNews/StationNews.aspx?Method=GetNewsRemind&srvid=" + srvID + "&page=" + page + "&rows=" + pagesize + "&user=" + userID,
        type: "post",
        cache: false,
        dataType: "json",
        success: function (data) {
            CreateTable(data);
            firstLoad = 0;
            if (firstLoad == 0) {
                createPage(pagesize, 5, data.total);
                firstLoad = 1;
            }
            if (pagesize < data.total) {
                if (mPage * pagesize >= data.total) {
                    $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + data.total + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
                }
                else {
                    $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + mPage * pagesize + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
                }
            }
            else {
                $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + data.total + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
            }
            layer.close(l);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
}
function LoadFenye(pagesize, page) {
    var l = layer.load('正在加载数据......');
    $.ajax({
        url: "../Handlers/StationNews/StationNews.aspx?Method=GetNewsRemind&srvid=" + srvID + "&page=" + page + "&rows=" + pagesize + "&user=" + userID,
        type: "post",
        cache: false,
        dataType: "json",
        success: function (data) {
            CreateTable(data);
            if (firstLoad == 0) {
                createPage(pagesize, 5, data.total);
                firstLoad = 1;
            }
            if (pagesize < data.total) {
                if (mPage * pagesize >= data.total) {
                    $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + data.total + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
                }
                else {
                    $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + mPage * pagesize + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
                }
            }
            else {
                $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + data.total + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
            }
            layer.close(l);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
}
function Btn_check(pagesize, page) {
    var title = encodeJson($("#Title").val());
    var type = $("#Type").val();
    var jjd = $("#jjd").val();
    var l = layer.load('正在加载数据......');
    $.ajax({
        url: "../Handlers/StationNews/StationNews.aspx?Method=GetNewsRemind&srvid=" + srvID + "&page=" + page + "&rows=" + pagesize + "&user=" + userID + "&where=select&title=" + encodeURI(encodeURI(title)) + "&type=" + type + "&jjd=" + jjd,
        type: "post",
        cache: false,
        dataType: "json",
        success: function (data) {
            CreateTable(data);
            firstLoad = 0;
            if (firstLoad == 0) {
                createPage(pagesize, 5, data.total);
                firstLoad = 1;
            }
            if (pagesize < data.total) {
                if (mPage * pagesize >= data.total) {
                    $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + data.total + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
                }
                else {
                    $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + mPage * pagesize + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
                }

            }
            else {
                $("#pFooter").html("当前显示：" + ((mPage - 1) * pagesize + 1).toString() + "---" + data.total + "条记录；&nbsp;&nbsp;共：" + data.total + "条记录");
            }
            layer.close(l);
            resize_r();
        },
        error: function () {
            layer.msg('网络请求错误！', 2, 5);
        }
    });
}
function CreateTable(data) {
    $('th input:checkbox').removeAttr("checked");
    var tb = document.getElementById("Management");
    for (var i = tb.rows.length - 1; i > 0; i--) {
        tb.deleteRow(i);
    }
    for (var i = 0; i < data.rows.length; i++) {
        var _tr1 = $('<tr></tr>');
        var _td0 = $('<td></td>');
        _td0.html("<input type='checkbox' value=\"" + data.rows[i].ID + "\"  class='ace'><label class='lbl'></label>");
        var _td1 = $('<td></td>');
        if (data.rows[i].Title.length >= 20) {
            if (data.rows[i].SeePeople.indexOf(userID) >= 0) {//判断是否已读
                _td1.append('<span style="cursor:pointer;color:#000;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Title + '" onclick="Select_Con(this)">' + data.rows[i].Title.substring(0, 20) + "..." + '</span>');
            } else {
                _td1.append('<span style="cursor:pointer;color:#428bca;font-weight:bold;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Title + '" onclick="Select_Con(this)">' + data.rows[i].Title.substring(0, 20) + "..." + '</span>');
            }
        } else {
            if (data.rows[i].SeePeople.indexOf(userID) >= 0) {
                _td1.append('<span style="cursor:pointer;color:#000;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Title + '" onclick="Select_Con(this)">' + data.rows[i].Title + '</span>');
            } else {
                _td1.append('<span style="cursor:pointer;color:#428bca;font-weight:bold;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Title + '" onclick="Select_Con(this)">' + data.rows[i].Title + '</span>');
            }
        }
        var _td2 = $('<td></td>');
        _td2.text(data.rows[i].Typess);
        var _td10 = $('<td></td>');

        if (data.rows[i].State == 1) {
            _td10.text("中等");
        } else {
            if (data.rows[i].State == 2) {
                _td10.text("紧急");
            } else {
                _td10.text("普通");
            }
        }
        var _td3 = $('<td></td>');
        _td3.text(data.rows[i].TimeStr);
        var _td4 = $('<td style="display: none;"></td>');
        _td4.text(data.rows[i].ID);
        var _td5 = $('<td style="display: none;"></td>');
        _td5.text(data.rows[i].Title);
        var _td6 = $('<td style="display: none;"></td>');
        _td6.text(data.rows[i].RelevantNumber);
        var _td7 = $('<td style="display: none;"></td>');
        _td7.text(data.rows[i].OrchestrationType);
        var _td8 = $('<td style="display: none;"></td>');
        _td8.text(data.rows[i].Type);
        var _td9 = $('<td style="display: none;"></td>');
        if (data.rows[i].SeePeople.indexOf(userID) >= 0) {
            _td9.text("1");
        } else {
            _td9.text("0");
        }
        _tr1.append(_td0);
        _tr1.append(_td1);
        _tr1.append(_td2);
        _tr1.append(_td10);
        _tr1.append(_td3);
        _tr1.append(_td4);
        _tr1.append(_td5);
        _tr1.append(_td6);
        _tr1.append(_td7);
        _tr1.append(_td8);
        _tr1.append(_td9);
        $('#Management tbody').append(_tr1);
        ClickEvent();
    }
}
function Select_Con(obj) {
    var tds = $(obj).parent().parent().find('td');
    var ID = tds.eq(5).text();
    var type = tds.eq(9).text();
    var xg_id = tds.eq(7).text();
    var lc_type = tds.eq(8).text();
    var sf_yd = tds.eq(10).text();
    $(obj).removeAttr("style");
    $(obj).css({ cursor: 'pointer', color: '#000' });
    if (sf_yd == "0") {
        $.ajax({
            type: "post",
            url: "../Handlers/StationNews/StationNews.aspx?Method=Update_See&ID=" + ID + "&user=" + userID,
            cache: false,
            success: function (msg) {
            },
            error: function () {
            }
        });
    }
    if (type == '0') {
        var id = xg_id;
        var l = layer.load("正在加载...");
        $.ajax({
            type: "get",
            dataType: "json",
            url: "../Handlers/Process/Process.aspx?Method=LoadById",
            data: { id: id },
            cache: false,
            success: function (data) {
                CheckChangeForm_s(data[0].Type);
                var formType = "";
                if (data[0].Type == "0") {
                    formType = CbType("TCWL_ALL_Dic_Absence", data[0].FormType);
                } else if (data[0].Type == "1") {
                    formType = CbType("TCWL_ALL_Dic_OverTime", data[0].FormType);
                } else if (data[0].Type == "5") {
                    formType = CbType("TCWL_All_Dic_Reimburse", data[0].FormType);
                }
                var type = GetFormName(data[0].Type);
                var emergtype = GetEmerg(data[0].EmerType);
                $("#hid").val(xg_id);
                $("#slbapply").text(data[0].userXM);
                $("#slbtype").text(type);
                $("#slbmodel").text(data[0].PName);
                $("#slbtitle").text(data[0].Title);
                $("#slbbz").text(data[0].Instruction);
                $("#slbwsdate").text(data[0].WorkSdate);
                $("#slbwedate").text(data[0].WorkEdate);
                $("#slbsdate").text(data[0].SDate);
                $("#slbedate").text(data[0].EDate);
                $("#slbfmtype").text(data[0].EDate);
                $("#slbfmtype").text(formType);
                $("#slbaddress").text(data[0].District);
                $("#slbusedate").text(data[0].UserDate);
                $("#slbemerg").text(emergtype);
                $("#slbattach").text(data[0].AttachUserNames);
                $("#slbstate").text(data[0].CuTypeDes);
                $("#slbname").text(data[0].userXM);
                $("#slbmoney").text(data[0].Money);
                AnotateTable_s(data[0].AnnotaterNames, data[0].Annotate);
                if (data[0].CuAnnotater != userID) {
                    $("#btn1").hide();
                    $("#btn2").hide();
                    $("#strpy").hide();
                    $("#btn1").removeAttr("onclick");
                    $("#btn2").removeAttr("onclick");
                }
                $("#piyu").val("同意！");
                $('#Dialog_Approval').modal('show');
                layer.close(l);
            },
            error: function () {
                layer.msg('网络请求错误!', 2, 5);
            }
        });
    }
    if (type == '3' || type == '2' || type == '1') {
        var type_number = type;
        var id = xg_id;
        var l = layer.load("正在加载...");
        $.ajax({
            type: "get",
            dataType: "json",
            url: "../Handlers/Process/Process.aspx?Method=LoadById",
            data: { id: id },
            cache: false,
            success: function (data) {
                CheckChangeForm(data[0].Type);
                var formType = "";
                if (data[0].Type == "0") {
                    formType = CbType("TCWL_ALL_Dic_Absence", data[0].FormType);
                } else if (data[0].Type == "1") {
                    formType = CbType("TCWL_ALL_Dic_OverTime", data[0].FormType);
                } else if (data[0].Type == "5") {
                    formType = CbType("TCWL_All_Dic_Reimburse", data[0].FormType);
                }
                var type = GetFormName(data[0].Type);
                var emergtype = GetEmerg(data[0].EmerType);
                $("#lbtype").text(type);
                $("#lbmodel").text(data[0].PName);
                $("#lbtitle").text(data[0].Title);
                $("#lbbz").text(data[0].Instruction);
                $("#lbwsdate").text(data[0].WorkSdate);
                $("#lbwedate").text(data[0].WorkEdate);
                $("#lbsdate").text(data[0].SDate);
                $("#lbedate").text(data[0].EDate);
                $("#lbfmtype").text(data[0].EDate);
                $("#lbfmtype").text(formType);
                $("#lbaddress").text(data[0].District);
                $("#lbusedate").text(data[0].UserDate);
                $("#lbemerg").text(emergtype);
                $("#lbattach").text(data[0].AttachUserNames);
                $("#lbstate").text(data[0].CuTypeDes);
                $("#lbname").text(data[0].userXM);
                $("#lbmoney").text(data[0].Money);
                AnotateTable(data[0].AnnotaterNames, data[0].Annotate);
                if (type_number == "3") {
                    var spnames = data[0].spname.split(',');
                    var sp = '';
                    var userlength = 0;
                    if (data[0].AnnotaterNames != "") {
                        userlength = data[0].AnnotaterNames.split(',').length;
                    }
                    var i_num = 0;
                    for (var i = 0; i < spnames.length; i++) {
                        if (i == 0) {
                            sp = '<div class="project-screening-yellow"></div><div class="select-1-yellow"></div>';
                        }
                        if (spnames.length == 1) {
                            sp += '<div class="screening-select slse" ><a href="#">' + spnames[i] + '</a></div>';
                        } else {
                            if (i <= userlength) {
                                if (i == userlength) {
                                    sp += '<div class="screening-select current" ><a href="#">' + spnames[i] + '</a></div>';
                                } else {
                                    if (i == (spnames.length - 1)) {
                                        sp += '<div class="screening-select current" ><a href="#" style="color:#000;background:none;">' + spnames[i] + '</a></div>';
                                    } else {
                                        sp += '<div class="screening-select" ><a href="#">' + spnames[i] + '</a></div>';
                                    }
                                }
                            } else {
                                sp += '<div class="screening-select slse" ><a href="#">' + spnames[i] + '</a></div>';
                            }
                        }
                        i_num = i_num + 1;
                    }
                    if (i_num == 1) {
                        $("#spname").css("width", "10px");
                    } else {
                        $("#spname").css("width", "50%");
                    }
                    $('#spname').html(sp);
                    var bfb = 100 / (i_num - 1);
                    var div_class = $("#spname .screening-select");
                    for (var i = 0; i < div_class.length; i++) {
                        var bfb_num = 0;
                        if (i != 0) {
                            bfb_num = bfb * i;
                            bfb_num = bfb_num + "%";
                            $(div_class[i]).css("left", bfb_num);
                        } else {
                            $(div_class[i]).css("left", "-1px");
                        }
                    }
                    $('#Dialog_Procedure').on('shown.bs.modal', function () {
                        var _parent = $("#spname .current");
                        var _postX = _parent.position().left;
                        _parent.siblings(".project-screening-yellow").animate({ width: _postX }, 300);
                        _parent.siblings(".select-1-yellow").animate({ left: _postX - 5 }, 300);
                    })
                    $("#divspname").show();
                } else {
                    $("#divspname").hide();
                }
                $("#Dialog_Procedure").modal("show");
                layer.close(l);
            },
            error: function () {
                layer.msg('网络请求错误!', 2, 5);
            }
        });
    }
    if (type == '4') {
        $("#oYuanyin").removeAttr("readonly");
        var l = layer.load('正在加载数据......');
        $.ajax({
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetOrder&ID=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                $('#osddbh').val(data.rows[0].orderID);
                $('#oskhmc').val(data.rows[0].KeHuMingCheng);
                $('#oslxr').val(data.rows[0].LianXiRenMingCheng);
                $('#oslxdh').val(data.rows[0].ContactTelephone);
                $('#oshtlb').val(data.rows[0].ContractCategory);
                $('#osyszje').val(accounting.formatMoney(data.rows[0].totalMoney));
                $('#ossszje').val(accounting.formatMoney(data.rows[0].actualMoney));
                $('#osbz').val(data.rows[0].Remarks);
                $('#osqdrq').val(data.rows[0].timeStr);
                $('#osdqrq').val(data.rows[0].ExpirationTime);
                if (data.rows[0].Annex != "") {
                    $('#osfj').val(data.rows[0].Annex);
                    document.getElementById("osxz").href = data.rows[0].Annex;
                    $("#osxz").text("下载");
                    $("#osxz").attr("target", "_blank");
                } else {
                    $('#osfj').val("");
                    $("#osxz").text("没附件");
                    $("#osxz").removeAttr('target');
                    document.getElementById("osxz").href = "#";
                }
                $('#osHid').val(xg_id);
                $('#osxsrybh').val(data.rows[0].saleMan);
                $('#osxsry').val(data.rows[0].saleMan);
                $("#oYuanyin").val(data.rows[0].Noremarks);
                if (data.rows[0].state != "待审") {
                    $("#order_sx").hide();
                    $("#order_bsx").hide();
                    $("#order_sx").removeAttr("onclick");
                    $("#order_bsx").removeAttr("onclick");
                    $("#order_gb").show();
                } else {
                    if (existRole("M_105", auPro)) {
                        $("#order_sx").show();
                        $("#order_bsx").show();
                        $("#order_sx").attr("onclick", "Order_sx()");
                        $("#order_bsx").attr("onclick", "order_bhsx()");
                        $("#order_gb").hide();
                    } else {
                        $("#order_sx").hide();
                        $("#order_bsx").hide();
                        $("#order_sx").removeAttr("onclick");
                        $("#order_bsx").removeAttr("onclick");
                        $("#order_gb").show();
                    }
                }
            },
            error: function () {
                layer.msg('网络请求错误!', 2, 5);
            }
        });
        $.ajax({
            url: "../Handlers/Order/Order.aspx?Method=loadCP&page=1&rows=10000&order=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                var tb = document.getElementById("sManagement_A_C");
                for (var i = tb.rows.length - 1; i > 0; i--) {
                    tb.deleteRow(i);
                }
                for (var i = 0; i < data.rows.length; i++) {
                    var _tr1 = $('<tr></tr>');
                    var _td1 = $('<td></td>');
                    _td1.text(data.rows[i].ProductsName);
                    var _td2 = $('<td></td>');
                    _td2.text(data.rows[i].actualPrice);
                    var _td3 = $('<td></td>');
                    _td3.text(data.rows[i].saleCount);
                    var _td4 = $('<td></td>');
                    _td4.append(data.rows[i].AllMoney);
                    var _td5 = $('<td></td>');
                    _td5.text("");
                    var _td6 = $('<td style="display: none;"></td>');
                    _td6.text(data.rows[i].ID);
                    var _td7 = $('<td style="display: none;"></td>');
                    _td7.text(data.rows[i].productID);
                    _tr1.append(_td1);
                    _tr1.append(_td2);
                    _tr1.append(_td3);
                    _tr1.append(_td4);
                    _tr1.append(_td5);
                    _tr1.append(_td6);
                    _tr1.append(_td7);
                    $('#sManagement_A_C tbody').append(_tr1);
                }
                resize_r();
            },
            error: function () {
                layer.msg('网络请求错误！', 2, 5);
            }
        });
        $.ajax({
            url: "../Handlers/Order/Order.aspx?Method=loadJL&page=1&rows=10000&order=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                var tb = document.getElementById("sManagement_A_J");
                for (var i = tb.rows.length - 1; i > 0; i--) {
                    tb.deleteRow(i);
                }
                for (var i = 0; i < data.rows.length; i++) {
                    var _tr1 = $('<tr></tr>');
                    var _td1 = $('<td></td>');
                    _td1.text(data.rows[i].dueDates);
                    var _td2 = $('<td></td>');
                    _td2.text(data.rows[i].Payment);
                    var _td3 = $('<td></td>');
                    _td3.text(data.rows[i].Invoice);
                    var _td4 = $('<td></td>');
                    _td4.text(data.rows[i].receivedAmount);
                    var _td5 = $('<td></td>');
                    if (data.rows[i].Beizhu.length >= 5) {
                        _td5.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Beizhu + '">' + data.rows[i].Beizhu.substring(0, 20) + "..." + '</span>');
                    } else {
                        _td5.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Beizhu + '">' + data.rows[i].Beizhu + '</span>');
                    }
                    var _td6 = $('<td></td>');
                    _td6.text(data.rows[i].State);
                    var _td7 = $('<td style="display: none;"></td>');
                    _td7.text(data.rows[i].ID);
                    var _td8 = $('<td style="display: none;"></td>');
                    _td8.text(data.rows[i].Beizhu);
                    _tr1.append(_td1);
                    _tr1.append(_td2);
                    _tr1.append(_td3);
                    _tr1.append(_td4);
                    _tr1.append(_td5);
                    _tr1.append(_td6);
                    _tr1.append(_td7);
                    _tr1.append(_td8);
                    $('#sManagement_A_J tbody').append(_tr1);
                    ClickEvent();
                }
            },
            error: function () {
                layer.close(l);
                layer.msg('网络请求错误！', 2, 5);
            }
        });
        resize_r();
        layer.close(l);
        $("#Dialog_Order").modal("show");
    }
    if (type == '5') {
        $("#order_sx").hide();
        $("#order_bsx").hide();
        $("#order_sx").removeAttr("onclick");
        $("#order_bsx").removeAttr("onclick");
        $("#order_gb").show();
        $("#oYuanyin").attr("readonly", "readonly");
        var l = layer.load('正在加载数据......');
        $.ajax({
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetOrder&ID=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                $('#osddbh').val(data.rows[0].orderID);
                $('#oskhmc').val(data.rows[0].KeHuMingCheng);
                $('#oslxr').val(data.rows[0].LianXiRenMingCheng);
                $('#oslxdh').val(data.rows[0].ContactTelephone);
                $('#oshtlb').val(data.rows[0].ContractCategory);
                $('#osyszje').val(accounting.formatMoney(data.rows[0].totalMoney));
                $('#ossszje').val(accounting.formatMoney(data.rows[0].actualMoney));
                $('#osbz').val(data.rows[0].Remarks);
                $('#osqdrq').val(data.rows[0].timeStr);
                $('#osdqrq').val(data.rows[0].ExpirationTime);
                if (data.rows[0].Annex != "") {
                    $('#osfj').val(data.rows[0].Annex);
                    document.getElementById("osxz").href = data.rows[0].Annex;
                    $("#osxz").text("下载");
                    $("#osxz").attr("target", "_blank");
                } else {
                    $('#osfj').val("");
                    $("#osxz").text("没附件");
                    $("#osxz").removeAttr('target');
                    document.getElementById("osxz").href = "#";
                }
                $('#osHid').val(xg_id);
                $('#osxsrybh').val(data.rows[0].saleMan);
                $('#osxsry').val(data.rows[0].saleMan);
                if (data.rows[0].state == "已生效") {
                    $("#oYuanyin").val("审核通过,合同生已生效!");
                } else {
                    if (data.rows[0].Noremarks == "") {
                        $("#oYuanyin").val("审核不通过,合同生未生效!");
                    } else {
                        $("#oYuanyin").val(data.rows[0].Noremarks);
                    }
                }
            },
            error: function () {
                layer.msg('网络请求错误!', 2, 5);
            }
        });
        $.ajax({
            url: "../Handlers/Order/Order.aspx?Method=loadCP&page=1&rows=10000&order=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                var tb = document.getElementById("sManagement_A_C");
                for (var i = tb.rows.length - 1; i > 0; i--) {
                    tb.deleteRow(i);
                }
                for (var i = 0; i < data.rows.length; i++) {
                    var _tr1 = $('<tr></tr>');
                    var _td1 = $('<td></td>');
                    _td1.text(data.rows[i].ProductsName);
                    var _td2 = $('<td></td>');
                    _td2.text(data.rows[i].actualPrice);
                    var _td3 = $('<td></td>');
                    _td3.text(data.rows[i].saleCount);
                    var _td4 = $('<td></td>');
                    _td4.append(data.rows[i].AllMoney);
                    var _td5 = $('<td></td>');
                    _td5.text("");
                    var _td6 = $('<td style="display: none;"></td>');
                    _td6.text(data.rows[i].ID);
                    var _td7 = $('<td style="display: none;"></td>');
                    _td7.text(data.rows[i].productID);
                    _tr1.append(_td1);
                    _tr1.append(_td2);
                    _tr1.append(_td3);
                    _tr1.append(_td4);
                    _tr1.append(_td5);
                    _tr1.append(_td6);
                    _tr1.append(_td7);
                    $('#sManagement_A_C tbody').append(_tr1);
                }
                resize_r();
            },
            error: function () {
                layer.msg('网络请求错误！', 2, 5);
            }
        });
        $.ajax({
            url: "../Handlers/Order/Order.aspx?Method=loadJL&page=1&rows=10000&order=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                var tb = document.getElementById("sManagement_A_J");
                for (var i = tb.rows.length - 1; i > 0; i--) {
                    tb.deleteRow(i);
                }
                for (var i = 0; i < data.rows.length; i++) {
                    var _tr1 = $('<tr></tr>');
                    var _td1 = $('<td></td>');
                    _td1.text(data.rows[i].dueDates);
                    var _td2 = $('<td></td>');
                    _td2.text(data.rows[i].Payment);
                    var _td3 = $('<td></td>');
                    _td3.text(data.rows[i].Invoice);
                    var _td4 = $('<td></td>');
                    _td4.text(data.rows[i].receivedAmount);
                    var _td5 = $('<td></td>');
                    if (data.rows[i].Beizhu.length >= 5) {
                        _td5.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Beizhu + '">' + data.rows[i].Beizhu.substring(0, 20) + "..." + '</span>');
                    } else {
                        _td5.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].Beizhu + '">' + data.rows[i].Beizhu + '</span>');
                    }
                    var _td6 = $('<td></td>');
                    _td6.text(data.rows[i].State);
                    var _td7 = $('<td style="display: none;"></td>');
                    _td7.text(data.rows[i].ID);
                    var _td8 = $('<td style="display: none;"></td>');
                    _td8.text(data.rows[i].Beizhu);
                    _tr1.append(_td1);
                    _tr1.append(_td2);
                    _tr1.append(_td3);
                    _tr1.append(_td4);
                    _tr1.append(_td5);
                    _tr1.append(_td6);
                    _tr1.append(_td7);
                    _tr1.append(_td8);
                    $('#sManagement_A_J tbody').append(_tr1);
                    ClickEvent();
                }
            },
            error: function () {
                layer.close(l);
                layer.msg('网络请求错误！', 2, 5);
            }
        });
        resize_r();
        layer.close(l);
        $("#Dialog_Order").modal("show");
    }
    if (type == '6') {
        var l = layer.load("正在加载回款记录信息。。。");
        $.ajax({
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetOrderM&ID=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                $("#orderm_id").val(xg_id);
                $("#jorder_id").val(data.rows[0].parentID);
                $("#jorder_je").val(data.rows[0].receivedAmount);
                $("#jsddbh").val(data.rows[0].bianhao);
                $("#jskhmc").val(data.rows[0].KeHuMingCheng);
                $("#jsqdrq").val(data.rows[0].dueDates);
                $("#jsdqrq").val(data.rows[0].ExpirationTime);
                $("#jsskfs").val(data.rows[0].Payment);
                $("#jsje").val(accounting.formatMoney(data.rows[0].receivedAmount));
                $("#jsfp").val(data.rows[0].Invoice);
                $("#jsbz").val(data.rows[0].Beizhu);
                if (data.rows[0].state != "待审") {
                    $("#orderm_ys").hide();
                    $("#orderm_ws").hide();
                    $("#orderm_ys").removeAttr("onclick");
                    $("#orderm_ws").removeAttr("onclick");
                    $("#orderm_gb").show();
                } else {
                    if (existRole("M_106", auPro)) {
                        $("#orderm_ys").show();
                        $("#orderm_ws").show();
                        $("#orderm_ys").attr("onclick", "OrderM_ys()");
                        $("#orderm_ws").attr("onclick", "OrderM_wsk()");
                        $("#orderm_gb").hide();
                    } else {
                        $("#orderm_ys").hide();
                        $("#orderm_ws").hide();
                        $("#orderm_ys").removeAttr("onclick");
                        $("#orderm_ws").removeAttr("onclick");
                        $("#orderm_gb").show();
                    }
                }
            },
            error: function () {
                layer.msg('网络请求错误！', 2, 5);
            }
        });
        layer.close(l);
        $("#Dialog_OrderM").modal("show");
    }
    if (type == '7') {
        var l = layer.load('正在加载回款信息......');
        $.ajax({
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetOrderM&ID=" + xg_id,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                $("#OrderMs").text("合同编号为：" + data.rows[0].bianhao + "的回款记录已审核完成");
                $("#sddbh").val(data.rows[0].bianhao);
                $("#skhmc").val(data.rows[0].KeHuMingCheng);
                $("#sqdrq").val(data.rows[0].dueDates);
                $("#sdqrq").val(data.rows[0].ExpirationTime);
                $("#sskfs").val(data.rows[0].Payment);
                $("#sje").val(accounting.formatMoney(data.rows[0].receivedAmount));
                $("#sfp").val(data.rows[0].Invoice);
                $("#sbz").val(data.rows[0].Beizhu);
                if (data.rows[0].state == "未收到") {
                    $("#sjg").val("未收到合同回款金额！");
                }
                if (data.rows[0].state == "已审") {
                    $("#sjg").val("已成功收到合同回款金额！");
                }
            },
            error: function () {
                layer.msg('网络请求错误！', 2, 5);
            }
        });
        layer.close(l);
        $("#Dialog_OrderMs").modal("show");
    }
    if (type == '8') {
        var url = "../IndividualCenter/WorkingLog.htm";
        parent.$('#tctabs').append($('<li ><a href="#a_bwl" data-toggle="tab">工作备忘录<span class="fa fa-times" style=" margin-left:8px;width:10px;height:10px;" onclick="tab_close(this);" onmouseover ="close_over(this);" onmouseout ="close_out(this);"></span></a></li>'));
        parent.$('#tctabcontent').append($('<div class="tab-pane" id="a_bwl" style="height:100%;margin-top:5px;"><iframe src="' + url + '?userid=' + escape(userID) + '&srvid=' + escape(srvID) + '&name=frm_bwl" style="border:0px;width:100%;height:100%;position:absolute;" id="frm_bwl"></iframe></div>'));
        parent.$('#tctabs a:last').tab('show');
    }
    if (type == '9') {
        var l = layer.load('正在加载任务信息......');
        var username = "";
        $.ajax({
            type: "get",
            url: "../Handlers/system/Mission.aspx?Method=GetName&ID=" + userID,
            cache: false,
            async: false,
            success: function (data) {
                username = data;
            },
            error: function () {
                layer.msg("网络错误！", 2, 3);
            }
        });
        layer.close(l);
        var k = layer.load('正在加载任务信息......');
        $.ajax({
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetMission&ID=" + xg_id + "&userid=" + userID,
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                if (data.rows.length == 0) {
                    $("#fmGonggao").text("该任务信息已被删除！！！");
                    $("#btnres").hide();
                    $("#btnres").removeAttr("onclick");
                    $("#Dialog_missincheck").modal("show");
                    return;
                }
                var id = xg_id;
                var receivenames = data.rows[0].sendername;
                var contentstr = data.rows[0].ContentStr;
                var state = data.rows[0].State;
                var mtime = data.rows[0].TimeStr.split(" ")[0];
                var endtime = data.rows[0].EndTime;
                $("#hidname").val(username);
                $.ajax({
                    type: "get",
                    url: "../Handlers/system/Mission.aspx?Method=receive&ID=" + id + "&userid=" + userID + "&name=" + username + "",
                    cache: false,
                    success: function (data) {
                        if (data == "success") {
                            var now = new Date();
                            var year = now.getFullYear().toString();
                            var month = (now.getMonth() + 1).toString();
                            var date = now.getDate();
                            if (date < 10) {
                                date = "0" + date;
                            }
                            var nowtime = parseInt(year + month + date);
                            var etime = parseInt(endtime.replace("-", "").replace("-", ""));
                            var datediff = etime - nowtime;
                            if (datediff < 0) {
                                $("#btnres").hide();
                            } else {
                                if (state == "已处理") {
                                    $("#btnres").hide();
                                    $("#btnres").removeAttr("onclick");
                                    $("#s2").attr("checked", "checked");
                                } else {
                                    $("#btnres").attr("onclick", "Add_Mission()");
                                    $("#btnres").show();
                                }
                            }
                            $("#hidid").val(id);
                            $("#slbreceive").text(receivenames);
                            $("#slbcontent").text(contentstr);
                            $("#slbtime").text(mtime);
                            $("#slbendtime").text(endtime);
                            $("#recon").val("");
                            $("#Dialog_missincheck").modal("show");
                        }
                    },
                    error: function () {
                        layer.msg("网络错误！", 2, 3);
                    }
                });
            },
            error: function () {
                layer.msg('网络请求错误!', 2, 5);
            }
        });
        layer.close(k);
    }
    if (type == '10') {
        $("#lbrespond").text("");
        var l = layer.load("正在加载任务信息...");
        $.ajax({
            type: "get",
            url: "../Handlers/system/Mission.aspx?Method=get&ID=" + xg_id,
            cache: false,
            dataType: "json",
            success: function (data) {
                layer.close(l);
                if (data != null) {
                    $("#lbreceive").text(data.rows[0].ReceiverName);
                    var state = data.rows[0].State.toString().split("|");
                    var statestr = "";
                    if (state.length > 0) {
                        for (var i = 0; i < state.length - 1; i++) {
                            var ss = state[i].split(",");
                            var d = "";
                            if (ss[0] == "0") {
                                d = "未接收";
                            }
                            if (ss[0] == "1") {
                                d = "已接收";
                            }
                            if (ss[0] == "2") {
                                d = "处理中";
                            }
                            if (ss[0] == "3") {
                                d = "已完成";
                            }
                            statestr += ss[3] + "(" + d + ")[" + ss[1] + "],";
                        }
                    }
                    $("#lbhasreceive").text(statestr);
                    $("#lbendtime").text(data.rows[0].EndTime);
                    $("#lbcontent").text(data.rows[0].ContentStr);
                    $("#lbrespond").append(data.rows[0].Respond);
                }
            },
            error: function () {
                layer.close(l);
                layer.msg("网络错误！", 2, 3);
            }
        });
        $("#Dialog_missin").modal("show");
    }
    if (type == '11') {
        var l = layer.load("正在加载日志信息...");
        $.ajax({
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetDaily&ID=" + xg_id,
            type: "get",
            cache: false,
            dataType: "json",
            success: function (data) {
                $("#AddName").text(data.rows[0].Adder);
                $("#AddTime").text(data.rows[0].Time);
                var fj = data.rows[0].Annex;
                var csrname = data.rows[0].Attach;
                var pz = data.rows[0].Respond;
                var yd = data.rows[0].WhoRead;
                $('#fList2').empty();
                if (fj != "") {
                    var fjList = fj.split('╯');
                    for (var i = 0; i < fjList.length; i++) {
                        if (fjList[i].length > 0) {
                            var mc = fjList[i].substring(fjList[i].lastIndexOf('/') + 1);
                            mc = mc.substring(0, mc.lastIndexOf('.'));
                            var eachItem = $('<li style="float:left;"><img ></img><a style="float:left;"></a></li>');
                            eachItem.find('a').attr('href', "../" + fjList[i]);
                            eachItem.find('a').attr('target', "_blank");
                            eachItem.find('a').css({ 'display': 'block' });
                            eachItem.find('img').attr('src', "../../Scripts/BootStrap/img/fj.png");
                            eachItem.find('img').css({ 'width': '15px', 'height': '15px', 'float': 'left', 'margin-left': '5px' });
                            eachItem.find('a').text(mc);
                            $('#fList2').append(eachItem);
                        }
                    }
//                    $("#fj_s").text(fj.split("/")[5]);
//                    $("#fj_s").removeAttr("href");
//                    $("#fj_s").attr("href", fj);
                } else {
                    var eachItem = $('<li style="float:left;">暂无附件！</li>');
                    $('#fList2').append(eachItem);
//                    $("#fj_s").removeAttr("href");
//                    $("#fj_s").text("暂无附件！");
                }
                $("#csr_s").text(csrname);
                var pz_s = pz.split(";");
                var tb = document.getElementById("pz");
                for (var i = tb.rows.length - 1; i >= 0; i--) {
                    tb.deleteRow(i);
                }
                for (var i = 0; i < pz_s.length; i++) {
                    var _tr1 = $('<tr></tr>');
                    var _td0 = $('<td></td>');
                    _td0.text(pz_s[i]);
                    _tr1.append(_td0);
                    $('#pz').append(_tr1);
                }
                var yd_s = yd.split(";");
                var tb_y = document.getElementById("yd");
                for (var i = tb_y.rows.length - 1; i >= 0; i--) {
                    tb_y.deleteRow(i);
                }
                for (var i = 0; i < yd_s.length; i++) {
                    var _tr = $('<tr></tr>');
                    var _td1 = $('<td></td>');
                    _td1.text(yd_s[i]);
                    _tr.append(_td1);
                    $('#yd').append(_tr);
                }
            },
            error: function () {
                layer.close(l);
                layer.msg('网络请求错误!', 2, 5);
            }
        });
        $.ajax({
            type: "get",
            url: "../Handlers/system/Daily.aspx?Method=getCon&update=no&ID=" + xg_id + "&user=" + userID,
            cache: false,
            dataType: "text",
            success: function (data) {
                $("#contentstr").empty();
                if (data != null) {
                    $("#contentstr").append(data);
//                    $("img").bind("click", function () {
//                        $.ajax({
//                            url: "../Handlers/system/Daily.aspx?Method=Encryp&img=" + $(this).attr("src"),
//                            type: "post",
//                            cache: false,
//                            success: function (msg) {
//                                layer.close(l);
//                                if (data != "error") {
//                                    window.open("../System/ReadImg.htm?img=" + msg);
//                                }
//                                else {
//                                    layer.msg("读取失败！", 2, 3);
//                                }
//                            },
//                            error: function () {
//                                layer.close(l);
//                                layer.msg('网络请求错误!', 2, 5);
//                            }
//                        });
//                    });
                }
            },
            error: function () {
                layer.close(l);
                layer.msg("网络错误！", 2, 3);
            }
        });
        layer.close(l);
        $("#Dialog_daily").modal("show");
    }
    if (type == '12') {
        $("#sqjh_id").val(xg_id);
        var zpr = "";
        var l = layer.load("正在加载机会信息。。。");
        $.ajax({
            type: "post",
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetZPJiHui&ID=" + xg_id,
            cache: false,
            dataType: "json",
            success: function (data) {
                zpr = data.rows[0].ZhiPaiRen;
                $('#sjKeHuMingCheng').val(data.rows[0].KeHuMingCheng);
                $('#sjlxr').val(data.rows[0].LianXiRen);
                $('#sjDianHuaHaoMa').val(data.rows[0].LianXiDianHua);
                $('#sjJiHuiMiaoShu').val(data.rows[0].JiHuiMiaoShu);
                layer.close(l);
            },
            error: function () {
                layer.close(l);
                layer.msg("网络错误！", 1, 5);
            }
        });
        layer.close(l);
        var k = layer.load("正在加载机会信息。。。");
        $.ajax({
            url: "../Handlers/SalesManagement/sellChance/ChanceApply.aspx?Method=applyuser&saleid=" + xg_id + "&page=1&rows=10000",
            type: "post",
            cache: false,
            dataType: "json",
            success: function (data) {
                var tb = document.getElementById("Management_zpjh");
                for (var i = tb.rows.length - 1; i > 0; i--) {
                    tb.deleteRow(i);
                }
                for (var i = 0; i < data.rows.length; i++) {
                    var _tr1 = $('<tr></tr>');
                    var _td1 = $('<td></td>');
                    _td1.text(data.rows[i].userXM);
                    var _td2 = $('<td></td>');
                    if (data.rows[i].ApplicationReason.length >= 10) {
                        _td2.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].ApplicationReason + '">' + data.rows[i].ApplicationReason.substring(0, 10) + "..." + '</span>');
                    } else {
                        _td2.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].ApplicationReason + '">' + data.rows[i].ApplicationReason + '</span>');
                    }
                    var _td3 = $('<td></td>');
                    _td3.text(data.rows[i].TimeStr);
                    var _td4 = $('<td class="center"></td>');
                    if (zpr != "") {
                        _td4.append('<div class="wjsygn"><a title="指派" data-toggle="modal" data-target="#uDialog" style="color:#808A87;" ><i>指派</i></a></div>');
                    } else {
                        _td4.append('<div class="wjsygn"><a title="指派" data-toggle="modal" data-target="#uDialog" onclick="ZhiPai_ZD(\'' + data.rows[i].SalesID + '\',\'' + data.rows[i].Applicant + '\')" ><i>指派</i></a></div>');
                    }
                    var _td5 = $('<td style="display: none;"></td>');
                    _td5.text(data.rows[i].Applicant);
                    var _td6 = $('<td style="display: none;"></td>');
                    _td6.text(data.rows[i].SalesID);
                    _tr1.append(_td1);
                    _tr1.append(_td2);
                    _tr1.append(_td3);
                    _tr1.append(_td4);
                    _tr1.append(_td5);
                    _tr1.append(_td6);
                    $('#Management_zpjh tbody').append(_tr1);
                }
                ClickEvent();
            },
            error: function () {
                layer.close(k);
                layer.msg('网络请求错误!', 3, 5);
            }
        });
        layer.close(k);
        $('#Dialog_sqjh').modal('show');
    }
    if (type == '13') {
        var l = layer.load("正在加载机会信息。。。");
        $.ajax({
            type: "post",
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetZPJiHui&ID=" + xg_id,
            cache: false,
            dataType: "json",
            success: function (data) {
                $('#jkhmc').val(data.rows[0].KeHuMingCheng);
                $('#jlxr').val(data.rows[0].LianXiRen);
                $('#jlxdh').val(data.rows[0].LianXiDianHua);
                $('#jcgl').val(data.rows[0].ChengGongLv);
                $("#jjhjd").val(data.rows[0].jhjd);
                $("#jjhly").val(data.rows[0].jhly);
                $("#jjhlx").val(data.rows[0].jhlx);
                $("#jjhdj").val(data.rows[0].jhdj);
                $('#jjhms').val(data.rows[0].JiHuiMiaoShu);
                $('#jbz').val(data.rows[0].Remarks);
                $('#jHzpr').val(data.rows[0].username);
                $('#jzpr').val(data.rows[0].ZhiPaiRen);
                $('#jyqje').val(data.rows[0].ExpectedAmount);
                layer.close(l);
            },
            error: function () {
                layer.close(l);
                layer.msg("网络错误！", 1, 5);
            }
        });
        layer.close(l);
        $('#Dialog_zpjh').modal('show');
    }
    if (type == '14') {
        $("#sqkh_id").val(xg_id);
        var cjr = "";
        var l = layer.load("加载数据中。。。");
        $.ajax({
            type: "post",
            url: "../Handlers/CustomerInformation/PublicManagement/PublicMg.aspx?Method=GetByID",
            data: { "id": xg_id },
            cache: false,
            dataType: "json",
            success: function (data) {
                var jsons = data.rows[0];
                cjr = jsons.ChuangJianRen;
                $('#sKeHuMingCheng').val(jsons.KeHuMingCheng);
                $("#slxr").val(jsons.Contact);
                $("#sDianHuaHaoMa").val(jsons.DianHuaHaoMa);
                $("#sKeHuDiZhi").val(jsons.KeHuDiZhi);
            },
            error: function () {
                layer.msg("网络错误！", 1, 5);
            }
        });
        layer.close(l);
        var k = layer.load("加载数据中。。。");
        $.ajax({
            url: "../Handlers/CustomerInformation/PublicManagement/PublicMg.aspx?Method=CheckApply&srvid=" + srvID + "&userid=" + userID + "&page=1&rows=1000000&cusid=" + xg_id + "",
            type: "get",
            cache: false,
            dataType: "json",
            success: function (data) {
                var tb = document.getElementById("tbapply");
                for (var i = tb.rows.length - 1; i > 0; i--) {
                    tb.deleteRow(i);
                }
                for (var i = 0; i < data.rows.length; i++) {
                    var _tr1 = $('<tr></tr>');
                    var _td1 = $('<td></td>');
                    _td1.text(data.rows[i].userXM);
                    var _td2 = $('<td></td>');
                    if (data.rows[i].ApplicationReason.length >= 10) {
                        _td2.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].ApplicationReason + '">' + data.rows[i].ApplicationReason.substring(0, 10) + "..." + '</span>');
                    } else {
                        _td2.append('<span style="cursor:pointer;" class="tooltip-info" data-placement="right" data-rel="tooltip" data-original-title="' + data.rows[i].ApplicationReason + '">' + data.rows[i].ApplicationReason + '</span>');
                    }
                    var _td3 = $('<td></td>');
                    _td3.text(data.rows[i].TimeStr);
                    var _td4 = $('<td></td>');
                    if (cjr != "") {
                        _td4.append('<div class="wjsygn"><a title="指派" data-toggle="modal" data-target="#uDialog" href="javascript:void(0)" style="color:#808A87;" ><i>指派</i></a></div>');
                    } else {
                        _td4.append('<div class="wjsygn"><a title="指派" data-toggle="modal" data-target="#uDialog" href="javascript:void(0)" onclick="Zhipai_kh(this);" ><i>指派</i></a></div>');
                    }
                    var _td5 = $('<td style="display: none;"></td>');
                    _td5.text(data.rows[i].Applicant);
                    _tr1.append(_td1);
                    _tr1.append(_td2);
                    _tr1.append(_td3);
                    _tr1.append(_td4);
                    _tr1.append(_td5);
                    $('#tbapply tbody').append(_tr1);
                }
                ClickEvent();
            },
            error: function () {
                layer.close(k);
                layer.msg('网络请求错误!', 2, 5);
            }
        });
        layer.close(k);
        $('#Dialog_sqkh').modal('show');
    }
    if (type == '15') {
        var l = layer.load("正在加载客户信息。。。");
        $.ajax({
            type: "post",
            url: "../Handlers/CustomerInformation/PublicManagement/PublicMg.aspx?Method=GetByID",
            data: { "id": xg_id },
            cache: false,
            dataType: "json",
            success: function (data) {
                var jsons = data.rows[0];
                $('#uKeHuMingCheng').val(jsons.KeHuMingCheng);
                $("#ulxr").val(jsons.Contact);
                $("#uDianHuaHaoMa").val(jsons.DianHuaHaoMa);
                $("#uKeHuDiZhi").val(jsons.KeHuDiZhi);
                $("#uQQ").val(jsons.QQ);
                $("#uYouXiang").val(jsons.YouXiang);
                $("#ukhxyd").val(jsons.KeHuXinYuDu);
                $("#ukhdj").val(jsons.KeHuDengJi);
                $("#uYouBian").val(jsons.YouBian);
                $("#ukhyxj").val(jsons.KeHuYouXianJi);
                $("#uChuanZhen").val(jsons.ChuanZhen);
                $("#uMSN").val(jsons.MSN);
                $("#udhlx").val(jsons.DianHuaLeiXing);
                $("#ukhbeizhu").val(jsons.Beizhu);
                $("#Hukhid").val(jsons.ID);
                var quyu = jsons.KeHuQuYu;
                var result = quyu.split(",");
                var guo = result[result.length - 4];
                var sheng = result[result.length - 3];
                var shi = result[result.length - 2];
                var qu = result[result.length - 1];
                $("#ukhguo").val(guo);
                $("#ukhsheng").val(sheng);
                $("#ukhshi").val(shi);
                $("#ukhqu").val(qu);
                $("#ukhly").val(jsons.KeHuLaiYuan);
                $("#ukhdj").val(jsons.KeHuDengJi);
                $("#ukhyxj").val(jsons.KeHuYouXianJi);
                $("#udhlx").val(jsons.DianHuaLeiXing);
                $("#ukhzt").val(jsons.ZhuangTai);
                $("#ukhxyd").val(jsons.KeHuXinYuDu);
                $("#ukhsex").val(jsons.Sex);
                layer.close(l);
            },
            error: function () {
                layer.close(l);
                layer.msg("网络错误！", 1, 5);
            }
        });
        layer.close(l);
        $('#Dialog_zpkh').modal('show');
    }
    if (type == '16') {
        var url = "../System/News.htm?xt=xt&id=" + xg_id;
        parent.$('#tctabs').append($('<li ><a href="#a_' + xg_id + '" data-toggle="tab">系统公告<span class="fa fa-times" style=" margin-left:8px;width:10px;height:10px;" onclick="tab_close(this);" onmouseover ="close_over(this);" onmouseout ="close_out(this);"></span></a></li>'));
        parent.$('#tctabcontent').append($('<div class="tab-pane" id="a_' + xg_id + '" scrolling="no" style="height:100%;margin-top:5px;"><iframe  id="m' + xg_id + '"  src="' + url + '" style="border:0px;width:100%;height:100%;position:absolute;"></iframe></div>'));
        parent.$('#tctabs a:last').tab('show');
    }
    if (type == '17') {
        var l = layer.load("正在加载数据。。。");
        $.ajax({
            type: "post",
            url: "../Handlers/StationNews/StationNews.aspx?Method=GetSomeoneNews&ID=" + ID,
            cache: false,
            dataType: "json",
            success: function (data) {
                $("#News_Title").text(data[0].Title);
                $("#News_Send").text(data[0].Sender);
                $("#News_Time").text(data[0].TimeStr);
                $("#News_Con").text(data[0].Content);
                layer.close(l);
            },
            error: function () {
                layer.close(l);
                layer.msg("网络错误！", 1, 5);
            }
        });
        layer.close(l);
        $('#Dialog_News').modal('show');
    }
}
function Zhipai_kh(obj) {
    var tds = $(obj).parent().parent().parent().find('td');
    var id = $("#sqkh_id").val();
    var user = tds.eq(4).text();
    var l = layer.load("正在指派...");
    layer.confirm("确定指派吗？", function () {
        $.post("../Handlers/CustomerInformation/PublicManagement/PublicMg.aspx?Method=zhipai&user=" + user + "&id=" + id + "",
                function (data) {
                    if (data == "success") {
                        $("#Dialog_sqkh").modal("hide");
                        LoadData($("#PSize").val(), 1);
                    }
                    else {
                        layer.msg('网络请求错误!', 2, 5);
                    }
                }, "text");
    });
    layer.close(l);
}
function ZhiPai_ZD(ID, user) {
    layer.confirm("确定指派吗？", function () {
        var l = layer.load("正在指派...");
        $.post("../Handlers/SalesManagement/sellChance/sellChance.aspx?Method=zp&ID=" + ID + "&userID=" + user,
                function (data) {
                    if (data == "success") {
                        $('#Dialog_sqjh').modal('hide');
                        LoadData($("#PSize").val(), 1);
                    }
                    else {
                        layer.msg('网络请求错误!', 2, 5);
                    }
                }, "text");
    });
    layer.close(l);
}
function Add_Mission() {
    $('#fmGonggao').validation();
    var alm = $(".popover");
    if (alm.length > 0) {
        return;
    }
    $(".popover ").remove();
    var l = layer.load("正在回复任务中...");
    $.ajax({
        url: "../Handlers/system/Mission.aspx?Method=done&user=" + userID,
        type: "post",
        cache: false,
        data: encodeJson_News(decodeURIComponent($('#fmGonggao').serialize())),
        success: function (data) {
            if (data == "success") {
                $('#Dialog_missincheck').modal('hide');
                LoadData($("#PSize").val(), 1);
            }
            else {
                layer.msg("操作失败！", 2, 3);
            }
        },
        error: function () {
            layer.msg('网络请求错误!', 2, 5);
        }
    });
    layer.close(l);
}
function OrderM_ys() {
    var l = layer.load('正在审核...');
    var ID = $("#orderm_id").val();
    var money = $("#jorder_je").val();
    var bh = $("#jorder_id").val();
    var fp = $("#jsfp").val();
    $.ajax({
        type: "post",
        url: "../Handlers/Order/Order.aspx?Method=UpdateJ&ID=" + encodeURI(encodeURI(ID)) + "&money=" + encodeURI(encodeURI(money)) + "&bh=" + encodeURI(encodeURI(bh)) + "&user=" + encodeURI(encodeURI(userID)) + "&fp=" + encodeURI(encodeURI(fp)),
        cache: false,
        success: function (msg) {
            if (msg == "sucess") {
                $('#Dialog_OrderM').modal('hide');
                LoadData($("#PSize").val(), 1);
            }
            else {
                layer.msg("操作失败！", 2, 3);
            }
        },
        error: function () {
            layer.msg("网络请求错误！", 2, 5);
        }
    });
    layer.close(l);
}
function OrderM_wsk() {
    var l = layer.load('正在审核...');
    var ID = $("#orderm_id").val();
    $.ajax({
        type: "post",
        url: "../Handlers/Order/Order.aspx?Method=UpdateJN&ID=" + encodeURI(encodeURI(ID)) + "&User=" + encodeURI(encodeURI(userID)),
        cache: false,
        success: function (msg) {
            if (msg == "sucess") {
                $('#Dialog_OrderM').modal('hide');
                LoadData($("#PSize").val(), 1);
            }
            else {
                layer.msg("操作失败！", 2, 3);
            }
        },
        error: function () {
            layer.msg("网络请求错误！", 2, 5);
        }
    });
    layer.close(l);
}
function Order_sx() {
    var l = layer.load('正在审核...');
    var id = $('#osHid').val();
    var rowcount_jl = $("#sManagement_A_J tbody tr");
    var jl = "";
    for (var i = 0; i < rowcount_jl.length; i++) {
        jl += $(rowcount_jl[i]).children(":eq(6)").text() + ",";
        jl += userID + ",";
        jl += $(rowcount_jl[i]).children(":eq(3)").text() + ",";
        jl += $(rowcount_jl[i]).children(":eq(2)").text() + ";";
    }
    jl = jl.substring(0, jl.length - 1);
    $.ajax({
        type: "post",
        url: "../Handlers/Order/Order.aspx?Method=UpdateQR&ID=" + encodeURI(encodeURI(id)) + "&user=" + encodeURI(encodeURI(userID)) + "&jl=" + encodeURI(encodeURI(jl)),
        cache: false,
        success: function (msg) {
            if (msg == "sucess") {
                $('#Dialog_Order').modal('hide');
                LoadData($("#PSize").val(), 1);
            }
            else {
                layer.msg("操作失败！", 2, 3);
            }
        },
        error: function () {
            layer.msg("网络请求错误！", 2, 5);
        }
    });
    layer.close(l);
}
function order_bhsx() {
    var l = layer.load('正在审核...');
    var bz = $("#oYuanyin").val();
    if (bz == "") {
        layer.msg("审核意见不可为空！", 2, 3);
        return;
    }
    bz = encodeJson(bz);
    var id = $('#osHid').val();
    $.ajax({
        type: "post",
        url: "../Handlers/Order/Order.aspx?Method=UpdateS_N&ID=" + encodeURI(encodeURI(id)) + "&bz=" + encodeURI(encodeURI(bz)),
        cache: false,
        success: function (msg) {
            if (msg == "sucess") {
                $('#Dialog_Order').modal('hide');
                LoadData($("#PSize").val(), 1);
            }
            else {
                layer.msg("操作失败！", 2, 3);
            }
        },
        error: function () {
            layer.msg("网络请求错误！", 2, 5);
        }
    });
    layer.close(l);
}
function Del_List() {
    var cbs = $('#Management tbody').find('tr > td:first-child :checkbox:checked');
    var cbslt = cbs.length;
    if (cbslt <= 0) {
        layer.msg('选择不可为空!请重新选择！!', 1, 5);
    }
    else {
        var ids = "'";
        for (var i = 0; i < cbslt; i++) {
            ids += $(cbs[i]).parent().parent().find("td").eq(5).text() + "','";
        }
        ids = ids.substring(0, ids.length - 2);
        var l = layer.load("正在批量删除...");
        layer.confirm("确定删除吗？", function () {
            $.post("../Handlers/StationNews/StationNews.aspx?Method=Del_List&ID=" + ids,
                    function (data) {
                        if (data == "sucess") {
                            layer.msg('删除成功!', 2, 5);
                            LoadData($("#PSize").val(), 1);
                        }
                        else {
                            layer.msg('网络请求错误!', 2, 5);
                        }
                    }, "text");
        });
        layer.close(l);
    }
}
function Read_List() {
    var cbs = $('#Management tbody').find('tr > td:first-child :checkbox:checked');
    var cbslt = cbs.length;
    if (cbslt <= 0) {
        layer.msg('选择不可为空!请重新选择！!', 1, 5);
    }
    else {
        var ids = "'";
        for (var i = 0; i < cbslt; i++) {
            ids += $(cbs[i]).parent().parent().find("td").eq(5).text() + "','";
        }
        ids = ids.substring(0, ids.length - 2);
        var l = layer.load("正在批量阅读...");
        layer.confirm("确定改为已读状态吗？", function () {
            $.post("../Handlers/StationNews/StationNews.aspx?Method=Read_List&ID=" + ids + "&user=" + userID,
                    function (data) {
                        if (data == "sucess") {
                            layer.msg('阅读成功!', 2, 5);
                            LoadData($("#PSize").val(), 1);
                        }
                        else {
                            layer.msg('网络请求错误!', 2, 5);
                        }
                    }, "text");
        });
        layer.close(l);
    }
}
function ShuaXin() {
    LoadData($("#PSize").val(), 1);
}
function CheckChangeForm(id) {
    switch (id) {
        case "0":
            $("#chBz").text("请假原因：");
            $("#chWorkTime").hide();
            $("#chUseDate").hide();
            $("#chMoney").hide();
            $("#chFmType").show();
            $("#chAddress").hide();
            break;
        case "1":
            $("#chBz").text("加班原因：");
            $("#chWorkTime").hide();
            $("#chUseDate").hide();
            $("#chMoney").hide();
            $("#chFmType").show();
            $("#chAddress").hide();
            break;
        case "2":
            $("#chBz").text("调休原因：");
            $("#chWorkTime").show();
            $("#chUseDate").hide();
            $("#chMoney").hide();
            $("#chFmType").hide();
            $("#chAddress").hide();
            break;
        case "3":
            $("#chBz").text("出差原因：");
            $("#chWorkTime").hide();
            $("#chUseDate").hide();
            $("#chMoney").hide();
            $("#chFmType").hide();
            $("#chAddress").show();
            break;
        case "4":
            $("#chBz").text("外出原因：");
            $("#chWorkTime").hide();
            $("#chUseDate").hide();
            $("#chMoney").hide();
            $("#chFmType").hide();
            $("#chAddress").show();
            break;
        case "5":
            $("#chBz").text("费用明细：");
            $("#chWorkTime").hide();
            $("#chUseDate").show();
            $("#chMoney").show();
            $("#chFmType").hide();
            $("#chAddress").hide();
            break;
        case "6":
            $("#chBz").text("借款原因：");
            $("#chWorkTime").hide();
            $("#chUseDate").show();
            $("#chMoney").show();
            $("#chFmType").hide();
            $("#chAddress").hide();
            break;
        case "7":
            $("#chBz").text("用车原因：");
            $("#chWorkTime").hide();
            $("#chUseDate").show();
            $("#chMoney").hide();
            $("#chFmType").hide();
            $("#chAddress").hide();
            break;
    }
}
function CbType(tbname, id) {
    var value = "";
    if (id != "") {
        $.ajax({
            url: "../Handlers/system/DataDic.aspx?Method=GetByID&ID=" + id + "&tbname=" + tbname + "",
            cache: false,
            async: false,
            success: function (data) {
                value = data;
            },
            error: function () { layer.msg('获取类型错误！', 1, 3); }
        });
    }
    return value;
}
function GetFormName(id) {
    var name = "请假";
    switch (id) {
        case "0":
            name = "请假";
            break;
        case "1":
            name = "加班";
            break;
        case "2":
            name = "调休";
            break;
        case "3":
            name = "出差";
            break;
        case "4":
            name = "外出";
            break;
        case "5":
            name = "费用报销";
            break;
        case "6":
            name = "借款申请";
            break;
        case "7":
            name = "派车申请";
            break;
    }
    return name;
}
function GetEmerg(id) {
    var name = "普通";
    switch (id) {
        case "0":
            name = "普通";
            break;
        case "1":
            name = "中等";
            break;
        case "2":
            name = "紧急";
            break;
    }
    return name;
}
function AnotateTable(names, contens) {
    $("#ckState").empty();
    if (names != "") {
        var users = names.split(",");
        var content = contens.split(",");
        for (var i = 0; i < users.length; i++) {
            var _tr1 = $('<tr></tr>');
            var _td0 = $('<td ></td>');
            _td0.append(users[i] + "：");
            var _td1 = $('<td ></td>');
            _td1.append(content[i]);
            _tr1.append(_td0);
            _tr1.append(_td1);
            $('#ckState').append(_tr1);
        }
    }
    else {
        $("#ckState").append("<tr><td>还没有人审批</td></tr>");
    }
}
function CheckChangeForm_s(id) {
    switch (id) {
        case "0":
            $("#schBz").text("请假原因：");
            $("#schWorkTime").hide();
            $("#schUseDate").hide();
            $("#schMoney").hide();
            $("#schFmType").show();
            $("#schAddress").hide();
            break;
        case "1":
            $("#schBz").text("加班原因：");
            $("#schWorkTime").hide();
            $("#schUseDate").hide();
            $("#schMoney").hide();
            $("#schFmType").show();
            $("#schAddress").hide();
            break;
        case "2":
            $("#schBz").text("调休原因：");
            $("#schWorkTime").show();
            $("#schUseDate").hide();
            $("#schMoney").hide();
            $("#schFmType").hide();
            $("#schAddress").hide();
            break;
        case "3":
            $("#schBz").text("出差原因：");
            $("#schWorkTime").hide();
            $("#schUseDate").hide();
            $("#schMoney").hide();
            $("#schFmType").hide();
            $("#schAddress").show();
            break;
        case "4":
            $("#schBz").text("外出原因：");
            $("#schWorkTime").hide();
            $("#schUseDate").hide();
            $("#schMoney").hide();
            $("#schFmType").hide();
            $("#schAddress").show();
            break;
        case "5":
            $("#schBz").text("费用明细：");
            $("#schWorkTime").hide();
            $("#schUseDate").show();
            $("#schMoney").show();
            $("#schFmType").hide();
            $("#schAddress").hide();
            break;
        case "6":
            $("#schBz").text("借款原因：");
            $("#schWorkTime").hide();
            $("#schUseDate").show();
            $("#schMoney").show();
            $("#schFmType").hide();
            $("#schAddress").hide();
            break;
        case "7":
            $("#schBz").text("用车原因：");
            $("#schWorkTime").hide();
            $("#schUseDate").show();
            $("#schMoney").hide();
            $("#schFmType").hide();
            $("#schAddress").hide();
            break;
    }
}
function AnotateTable_s(names, contens) {
    $("#sckState").empty();
    if (names != "") {
        var users = names.split(",");
        var content = contens.split(",");
        for (var i = 0; i < users.length; i++) {
            var _tr1 = $('<tr></tr>');
            var _td0 = $('<td ></td>');
            _td0.append(users[i] + "：");
            var _td1 = $('<td ></td>');
            _td1.append(content[i]);
            _tr1.append(_td0);
            _tr1.append(_td1);
            $('#sckState').append(_tr1);
        }
    }
    else {
        $("#sckState").append("<tr><td>还没有人审批</td></tr>");
    }
}
function Agree() {
    if ($("#piyu").val() == "") {
        layer.msg("请填写批语！", 1, 8);
        $("#piyu").focus();
        return;
    }
    var l = layer.load("正在添加...");
    $.ajax({
        type: "post",
        url: "../Handlers/Process/Process.aspx?Method=Agree&userid=" + userID + "",
        cache: false,
        data: encodeJson_News(decodeURIComponent($("#sfmPz").serialize())),
        success: function (data) {
            if (data == "s") {
                $("#Dialog_Approval").modal("hide");
                LoadData($("#PSize").val(), 1);
            }
            else {
                layer.msg("批注失败！", 1, 8);
            }
        },
        error: function () {
            layer.msg('网络请求错误!', 2, 5);
        }
    });
}
function DisAgree() {
    if ($("#piyu").val() == "") {
        layer.msg("请填写批语！", 1, 8);
        $("#piyu").focus();
        return;
    }
    if ($("#piyu").val() == "") {
        layer.msg("请填写批语！", 1, 8);
        $("#piyu").focus();
        return;
    }
    var con = $("#piyu").val();
    if (con == "同意！") {
        $("#piyu").val("不同意！");
    }
    var l = layer.load("正在添加...");
    $.ajax({
        type: "post",
        url: "../Handlers/Process/Process.aspx?Method=DisAgree&userid=" + userID + "",
        cache: false,
        data: encodeJson_News(decodeURIComponent($("#sfmPz").serialize())),
        success: function (data) {
            if (data == "s") {
                $("#Dialog_Approval").modal("hide");
                LoadData($("#PSize").val(), 1);
            }
            else {
                layer.msg("批注失败！", 1, 8);
            }
        },
        error: function () {
            layer.msg('网络请求错误!', 2, 5);
        }
    });
}