/*!
 * Modernizr v2.8.3
 * www.modernizr.com
 *
 * Copyright (c) Faruk Ates, Paul Irish, Alex Sexton
 * Available under the BSD and MIT licenses: www.modernizr.com/license/
 */

/*
 * 其它项目选择
 */



(function ($) {

    $.SelectExpense = function (_l, backData) {
        if (ExpenseIsExistData(_l)) {
            $.popAlter({
                content: "正在加载账户，请稍等...",
                title: "选择项目",
                Buttons: [{ Name: "确定", Val: 2 }],
                okCallback: function () {

                    //var that = $(".ok-click");
                    //that.hide().after("<span>请稍后...</span>");

                    //var vselt = $("#hidSelectId").val().length;
                    //if (vselt == undefined || vselt == 0) {
                    //    alert("请选择项目"); 

                    //    that.show().next("span").remove();
                    //} else {

                    //    $('#sysmodal').modal('hide');

                    //    //var areaData = '{LeaderId:' + $("#hidLeaderId").val() + ',LeaderName:"' + $("#hidLeaderName").val() + '"}';

                    //    //var areas = eval("([" + areaData + "])");
                    //    backData($("#hidSelectId").val());
                    //}
                    $('#sysmodal').modal('hide');
                    //去除必须选择项目的判断，自费和购物项目非必选项。
                    var d = $.trim($("#hidSelectId").val()) == "" ? "" : $.trim($("#hidSelectId").val())
                    backData(d);
                }
            });
            var cityIds = _l.cityIds;
            var type = _l.type;
            var ids = _l.ids;

            $.ajax({
                type: "POST",
                url: "/expense/expenseselect",
                data: { cityIds: cityIds, type: type, ids: ids },
                success: function (data) {
                    $(".modal-body").html(data);
                }
            });
        }
        else
            $.popAlter({
                content: "未查询到自费或购物项目，请先给该产品的目的地城市添加项目",
                title: "选择项目"
            });
    }
})(jQuery);

//验证当前传入的城市Ids下是否存在项目数据，存在直接弹出选择项目控件，不存在直接提出不存在提示，
function ExpenseIsExistData(obj)
{
    var result = false;
    $.ajax({
        type: "POST",
        async: false,
        url: "/expense/isexistexpensedata",
        data: { cityIds: obj.cityIds, type: obj.type },
        success: function (data) {
            result = data;
        }
    });
    return result;
}