var orderNo;
var allCustomer = [];

$(function () {

    SetColor();

    $("#tOrder tr td").click(function () {
        if ($(this).hasClass("client-name")) {
            ShowDetail($(this).parent().attr("id"));
        }
        else if ($(this).parent().hasClass("totalTd")) {
            return;
        }
        else if ($(this).hasClass("td-last") || $(this).hasClass("td-checkbox")) {
            return;
        }
        else {
            ShowDetail($(this).parent().attr("id"));
        }
    });

    TdRowOverOutWithSpan("tOrder");   
 
});

function SetColor() {
    $("#tOrder").find("tr").each(function (i, val) {
        if ($(val).find("#spanPaymentStatus").html() == "未支付") {
            //$(val).find("#spanPaymentStatus").css("background-color", "#FF0000");
            $(val).find("#spanPaymentStatus").css("color", "#FF0000");
        }
        else if ($(val).find("#spanPaymentStatus").html() == "部分支付") {
            //3366FF
            // $(val).find("#spanPaymentStatus").css("background-color", "#FF6600");
            $(val).find("#spanPaymentStatus").css("color", "#288a51");
        }
        else if ($(val).find("#spanPaymentStatus").html() == "已支付") {
            //$(val).find("#spanPaymentStatus").css("background-color", "#00FF00");
            $(val).find("#spanPaymentStatus").css("color", "#000000");
        }

    });
}

function DeleteFile(no, name) {
    ClearErrorMsg();

    if (inUploading) {
        return false;
    }

    if (confirm('确定删除附件 ' + name + ' 吗？')) {
        $.ajax({
            url: "/Portal/DeleteAttachment",
            type: 'GET',
            cache: false,
            data: { FileNo: no, OrderNo: $("#OrderNo").val() },
            success: function (result) {
                if (result.code == 0) {
                    $("#tAttachment").find("tr[id=" + result.FileNo + "]").remove();
                }
                else {
                    alert("删除失败.");
                }

            },
            error: function (e) {
                alert("删除失败.");
            }
        });
    }
}

function EditOrder(id) {

    var url = {};
    url.root = "/Portal/Index";
    url.paras = [];
    url.paras.push({ name: "page", value: $($(".currentnum")[0]).html() });

    location.href = "/Portal/SimpleEdit?OrderNo=" + id + "&GoBackURL=" + JSON.stringify(url);
}