/* Minification failed. Returning unminified contents.
(2,14): run-time error CSS1031: Expected selector, found '='
(2,14): run-time error CSS1025: Expected comma or open brace, found '='
(6,16): run-time error CSS1031: Expected selector, found '='
(6,16): run-time error CSS1025: Expected comma or open brace, found '='
(25,16): run-time error CSS1031: Expected selector, found '='
(25,16): run-time error CSS1025: Expected comma or open brace, found '='
(89,10): run-time error CSS1031: Expected selector, found 'ListOnSuccess('
(89,10): run-time error CSS1025: Expected comma or open brace, found 'ListOnSuccess('
(92,10): run-time error CSS1031: Expected selector, found 'ListOnFailure('
(92,10): run-time error CSS1025: Expected comma or open brace, found 'ListOnFailure('
(95,10): run-time error CSS1031: Expected selector, found 'CreateOnbegin('
(95,10): run-time error CSS1025: Expected comma or open brace, found 'CreateOnbegin('
(98,10): run-time error CSS1031: Expected selector, found 'CreateOnSuccess('
(98,10): run-time error CSS1025: Expected comma or open brace, found 'CreateOnSuccess('
(101,10): run-time error CSS1031: Expected selector, found 'CreateOnFailure('
(101,10): run-time error CSS1025: Expected comma or open brace, found 'CreateOnFailure('
(104,10): run-time error CSS1031: Expected selector, found 'UpdateOnbegin('
(104,10): run-time error CSS1025: Expected comma or open brace, found 'UpdateOnbegin('
(107,10): run-time error CSS1031: Expected selector, found 'UpdateOnSuccess('
(107,10): run-time error CSS1025: Expected comma or open brace, found 'UpdateOnSuccess('
(110,10): run-time error CSS1031: Expected selector, found 'UpdateOnFailure('
(110,10): run-time error CSS1025: Expected comma or open brace, found 'UpdateOnFailure('
(117,4): run-time error CSS1031: Expected selector, found '('
(117,4): run-time error CSS1025: Expected comma or open brace, found '('
(126,10): run-time error CSS1031: Expected selector, found 'Reconnection('
(126,10): run-time error CSS1025: Expected comma or open brace, found 'Reconnection('
(143,10): run-time error CSS1031: Expected selector, found 'SetSelect('
(143,10): run-time error CSS1025: Expected comma or open brace, found 'SetSelect('
(147,10): run-time error CSS1031: Expected selector, found 'SetSelectTab('
(147,10): run-time error CSS1025: Expected comma or open brace, found 'SetSelectTab('
(159,10): run-time error CSS1031: Expected selector, found 'SelectInit('
(159,10): run-time error CSS1025: Expected comma or open brace, found 'SelectInit('
(167,10): run-time error CSS1031: Expected selector, found 'WindowResize('
(167,10): run-time error CSS1025: Expected comma or open brace, found 'WindowResize('
(175,10): run-time error CSS1031: Expected selector, found 'SetFootable('
(175,10): run-time error CSS1025: Expected comma or open brace, found 'SetFootable('
(181,10): run-time error CSS1031: Expected selector, found 'SetSwitchery('
(181,10): run-time error CSS1025: Expected comma or open brace, found 'SetSwitchery('
(187,10): run-time error CSS1031: Expected selector, found 'SetDateRange('
(187,10): run-time error CSS1025: Expected comma or open brace, found 'SetDateRange('
(224,10): run-time error CSS1031: Expected selector, found 'SetDate('
(224,10): run-time error CSS1025: Expected comma or open brace, found 'SetDate('
(250,10): run-time error CSS1031: Expected selector, found 'SetValidateIgnore('
(250,10): run-time error CSS1025: Expected comma or open brace, found 'SetValidateIgnore('
(257,10): run-time error CSS1031: Expected selector, found 'GetQueryString('
(257,10): run-time error CSS1025: Expected comma or open brace, found 'GetQueryString('
(262,1): run-time error CSS1019: Unexpected token, found '$'
(262,2): run-time error CSS1019: Unexpected token, found '('
(262,3): run-time error CSS1019: Unexpected token, found '"#inputPageName"'
(262,19): run-time error CSS1019: Unexpected token, found ')'
(262,21): run-time error CSS1030: Expected identifier, found 'val('
(262,21): run-time error CSS1019: Unexpected token, found 'val('
(262,25): run-time error CSS1019: Unexpected token, found 'GetQueryString('
(262,40): run-time error CSS1019: Unexpected token, found '"page"'
(262,46): run-time error CSS1019: Unexpected token, found ')'
(262,48): run-time error CSS1019: Unexpected token, found '='
(262,49): run-time error CSS1019: Unexpected token, found '='
(262,56): run-time error CSS1031: Expected selector, found '?'
(262,56): run-time error CSS1025: Expected comma or open brace, found '?'
(263,10): run-time error CSS1031: Expected selector, found 'BtnPageTarget('
(263,10): run-time error CSS1025: Expected comma or open brace, found 'BtnPageTarget('
(276,4): run-time error CSS1031: Expected selector, found '('
(276,4): run-time error CSS1025: Expected comma or open brace, found '('
(279,10): run-time error CSS1031: Expected selector, found 'SetPageSize('
(279,10): run-time error CSS1025: Expected comma or open brace, found 'SetPageSize('
(292,10): run-time error CSS1031: Expected selector, found 'OnkeyBtnPageTarget('
(292,10): run-time error CSS1025: Expected comma or open brace, found 'OnkeyBtnPageTarget('
(298,10): run-time error CSS1031: Expected selector, found 'SortColumn('
(298,10): run-time error CSS1025: Expected comma or open brace, found 'SortColumn('
(312,10): run-time error CSS1031: Expected selector, found 'SetIcheck('
(312,10): run-time error CSS1025: Expected comma or open brace, found 'SetIcheck('
(357,10): run-time error CSS1031: Expected selector, found 'IcheckAction('
(357,10): run-time error CSS1025: Expected comma or open brace, found 'IcheckAction('
(376,10): run-time error CSS1031: Expected selector, found 'IeditAction('
(376,10): run-time error CSS1025: Expected comma or open brace, found 'IeditAction('
(396,10): run-time error CSS1031: Expected selector, found 'Action('
(396,10): run-time error CSS1025: Expected comma or open brace, found 'Action('
(413,10): run-time error CSS1031: Expected selector, found 'IcheckStockAction('
(413,10): run-time error CSS1025: Expected comma or open brace, found 'IcheckStockAction('
(452,10): run-time error CSS1031: Expected selector, found 'ActionAjax('
(452,10): run-time error CSS1025: Expected comma or open brace, found 'ActionAjax('
(505,10): run-time error CSS1031: Expected selector, found 'GetColor('
(505,10): run-time error CSS1025: Expected comma or open brace, found 'GetColor('
 */
//LaddaButton
var laddaBtn = $('.ladda-button').ladda();
//EndLaddaButton

//Toastr
toastr.options = {
    "closeButton": false,
    "debug": false,
    "progressBar": true,
    "preventDuplicates": true,
    "positionClass": "toast-top-center",
    "onclick": null,
    "showDuration": "2000",
    "hideDuration": "2000",
    "timeOut": "2000",
    "extendedTimeOut": "2000",
    "showEasing": "swing",
    "hideEasing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
}
//EndToastr

//Ajax
var AjaxHandle = {
    "ErrorTitle": "提示",
    "SuccessTitle": "提示",
    "Onbegin": function (msg) {
        laddaBtn.ladda('start');
    },
    "Success": function (data) {
        if (data.Status === 200) {
            if (data.Data != undefined && data.Data.alert != undefined && data.Data.alert === true) {
                swal({
                    title: this.SuccessTitle,
                    text: data.Message,
                    type: "success"
                }, function () {
                    if (data.Data != undefined && data.Data.target != undefined) {
                        window.location.href = data.Data.target;
                    }
                });
            } else {
                toastr.success(data.Message + ",加载中...", this.SuccessTitle);
                if (data.Data != undefined && data.Data.target != undefined) {
                    window.location.href = data.Data.target;
                }
            }
        } else if (data.Status === 201) {
            var cover = jQuery.parseJSON(data.Message);
            if (cover.name == '' || cover == undefined) { cover.name = "其他人"; }
            swal({
                title: cover.name,
                text: cover.time + "已修改，确定要覆盖？",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: GetColor("red"),
                confirmButtonText: "覆盖",
                cancelButtonText: "取消",
                closeOnConfirm: false
            }, function () {
                toastr.success(data.Message + ",加载中...", this.SuccessTitle);
                $("#UpdateTime").val(cover.time);
                $("form").submit();
            });
            laddaBtn.ladda('stop');
        } else if (data.Status === 500) {
            Reconnection(this.ErrorTitle, data.Message);
            laddaBtn.ladda('stop');
        } else {
            toastr.error(data.Message, this.ErrorTitle);
            laddaBtn.ladda('stop');
        }
        
    },
    "Failure": function (msg) {
        laddaBtn.ladda('stop');
        toastr.error(msg, this.ErrorTitle);
    },
    "ListSuccess": function (data) {
        if (data != null && data.Status != null && data.Status === 500) {
            Reconnection(this.ErrorTitle, data.Message)
        }
    },
    "ListFailure": function (data) {
        toastr.error(msg, this.ErrorTitle);
    }
};
function ListOnSuccess(data) {
    AjaxHandle.ListSuccess(data);
}
function ListOnFailure(data) {
    AjaxHandle.ListFailure(data);
}
function CreateOnbegin() {
    AjaxHandle.Onbegin("正在提交...");
}
function CreateOnSuccess(data) {
    AjaxHandle.Success(data);
}
function CreateOnFailure() {
    AjaxHandle.Failure("连接超时，请稍候再试！");
}
function UpdateOnbegin() {
    AjaxHandle.Onbegin("正在提交...");
}
function UpdateOnSuccess(data) {
    AjaxHandle.Success(data);
}
function UpdateOnFailure() {
    AjaxHandle.Failure("连接超时，请稍候再试！");
}
//EndAjax


//Heartbeat
if (window.location.pathname.toLowerCase() != "/home/login" && window.location.pathname.toLowerCase() != "/") {
    self.setInterval(function () {
        $.post("/home/init", function (data) {
            if (data.Status === 500) {
                Reconnection("提示", "连接超时，请重新登录。");
            }
        });
    }, 100000);
}
function Reconnection(title, text) {
    swal({
        title: title,
        text: text,
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: GetColor("green"),
        confirmButtonText: "重新登录",
        cancelButtonText: "取消",
        closeOnConfirm: false
    }, function () {
        $.post("/home/init", function (data) { if (data.Status === 500) { window.location.reload(); } else if (data.Status === 200) { swal("提示", "登录成功", "success"); } });
    });
}
//EndHeartbeat

//Select2
function SetSelect(obj) {
    SelectInit(obj);
    WindowResize();
}
function SetSelectTab() {
    $(".tab-pane-btn").click(function () {
        setTimeout(function () {
            var tabPane = $(".tab-pane");
            if (tabPane != undefined && tabPane.length > 0) {
                tabPane.each(function () {
                    if ($(this).find(".input-validation-error").length > 0) { $("ul").find("[href='#" + $(this).attr("id") + "']").click(); return false; }
                });
            }
        }, 1);
    });
}
function SelectInit(obj) {
    if (obj == undefined) { obj = { placeholder: "", allowClear: true, minimumResultsForSearch: 5 } }
    $(".select2_single").select2(obj);
    $(".select2_multiple").select2();
}
//EndSelect2

//WindowResize
function WindowResize() {
    $(window).resize(function () {
        setTimeout(SelectInit, 250);
    });
}
//EndWindowResize

//Footable
function SetFootable() {
    $('.footable').footable();
}
//EndFootable

//Switchery
function SetSwitchery(classId, color) {
    return new Switchery(document.querySelector(classId), { color: GetColor(color) })
}
//SwitcheryEnd

//DateTimepicker
function SetDateRange(startId, endId, minView) {
    if (minView == 0) {
        format = "yyyy/mm/dd hh:ii";
    } else if (minView == 2) {
        format = "yyyy/mm/dd";
    } else {
        minView = 2;
        format = "yyyy/mm/dd";
    }
    $(startId).attr("autocomplete", "off").datetimepicker({
        format: format,
        autoclose: true,
        minView: minView,
        language: 'cn',
        minuteStep: 1,
        todayBtn: 1,
        forceParse: true
    }).on('changeDate', function () {
        var startTime = $(startId).val();
        $(endId).datetimepicker('setStartDate', startTime);
        $(startId).datetimepicker('hide');
    });
    $(endId).attr("autocomplete", "off").datetimepicker({
        format: format,
        autoclose: true,
        minView: minView,
        language: 'cn',
        minuteStep: 1,
        todayBtn: 1,
        forceParse: true
    }).on('changeDate', function () {
        var startTime = $(startId).val();
        var endtime = $(endId).val();
        $(startId).datetimepicker('setEndDate', endtime);
        $(endId).datetimepicker('hide');
    });
}
function SetDate(minView, startTime, minuteStep) {
    if (minView == 0) {
        format = "yyyy/mm/dd hh:ii";
    } else if (minView == 2) {
        format = "yyyy/mm/dd";
    } else {
        minView = 2;
        format = "yyyy/mm/dd";
    }
    $(".inputdatepicker").attr("autocomplete", "off").datetimepicker({
        format: format,
        autoclose: true,
        minView: minView,
        language: 'cn',
        minuteStep: minuteStep,
        todayBtn: 1,
        forceParse: true,
        startDate: startTime,
        showMeridian: true
    }).on('changeDate', function () {
        $(".inputdatepicker").valid();
    });
}
//EndDateTimepicker

//JqueryValidate
function SetValidateIgnore(id) {
    $(id).validate().settings.ignore = [];
    $(".select2_single,.select2_multiple").change(function () { $(this).valid(); });
}
//EndJqueryValidate

//PagedBtn
function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}
$("#inputPageName").val(GetQueryString("page") == null ? 1 : GetQueryString("page"));
function BtnPageTarget() {
    var txtPage = document.getElementById("inputPageName").value;
    if (window.location.href.toLowerCase().indexOf("page=") == -1) {
        if (window.location.href.indexOf("?") == -1) {
            window.location.href = window.location.pathname + "?page=" + txtPage;
        } else {
            window.location.href = window.location.href + "&page=" + txtPage;
        }
    } else {
        var page = "page=" + GetQueryString("page");
        window.location.href = window.location.href.toLowerCase().replace(page, "page=" + txtPage);
    }
}
if ($("#selectPagedSize").length > 0) {
    $("#selectPagedSize").val(GetQueryString("size") == null ? 10 : GetQueryString("size"));
}
function SetPageSize() {
    var txtPageSize = $('#selectPagedSize option:selected').val();
    if (window.location.href.toLowerCase().indexOf("size=") == -1) {
        if (window.location.href.indexOf("?") == -1) {
            window.location.href = window.location.pathname + "?size=" + txtPageSize;
        } else {
            window.location.href = window.location.href + "&size=" + txtPageSize;
        }
    } else {
        var page = "size=" + GetQueryString("size");
        window.location.href = window.location.href.toLowerCase().replace(page, "size=" + txtPageSize);
    }
}
function OnkeyBtnPageTarget(obj) {
    if (obj.keyCode == 13) { BtnPageTarget(); }
}
//EndPagedBtn

//SortColumn
function SortColumn(obj, name) {
    $("#SortName").val(name);
    if (obj.classList.contains("footable-sortable") == true && obj.classList.contains("footable-sorted-desc") == true) {
        $("#SortType").val("desc");
    } else if (obj.classList.contains("footable-sortable") == true && obj.classList.contains("footable-sorted") == true) {
        $("#SortType").val("asc");
    } else {
        $("#SortType").val("asc");
    }
    $("form").submit();
}
//EndSortColumn

//Icheck
function SetIcheck() {
    $('.i-checks').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
    });
    var $checkboxAll = $(".i-checks-all"),
        $checkbox = $("tbody").find("[type='checkbox']").not("[disabled]"),
        checkboxLength = $checkbox.length,
        checkboxCheckCount = 0,
        checkoxAllSpan = $("#ichecks_span"),
        checkboxBulk = $("#ichecks_bulk"),
        checkboxBulkUl = $("#ichecks_bulk_ul");

    $checkboxAll.on("ifClicked", function (event) {
        if (event.target.checked) {
            $checkbox.iCheck('uncheck');
            checkboxCheckCount = 0;
            checkoxAllSpan.text(0);
            checkboxBulk.attr("class", "btn btn-white");
            checkboxBulk.attr("disabled", true);
            checkboxBulkUl.removeClass("show");
        } else {
            $checkbox.iCheck('check');
            checkboxCheckCount = checkboxLength;
            checkoxAllSpan.text(checkboxLength);
            checkboxBulk.attr("class", "btn btn-primary");
            checkboxBulk.attr("disabled", false);
        }
    });
    $checkbox.on('ifClicked', function (event) {
        event.target.checked ? checkboxCheckCount-- : checkboxCheckCount++;
        if (checkboxBulk != undefined) {
            if (checkboxCheckCount > 0) { checkboxBulk.attr("class", "btn btn-primary"); checkboxBulk.attr("disabled", false); } else { checkboxBulk.attr("class", "btn btn-white"); checkboxBulk.attr("disabled", true); checkboxBulkUl.removeClass("show"); }
        }
        checkoxAllSpan.text(checkboxCheckCount);
        if (checkboxCheckCount == checkboxLength) {
            $checkboxAll.iCheck('check');
        } else {
            $checkboxAll.iCheck('uncheck');
        }
    });
}
//EndIcheck

//Action
function IcheckAction(url, title, color) {
    if (title == null || title == "" || title == undefined) { title = "批量操作"; }
    var checkBoxArr = [];
    $("tbody").find("[type='checkbox']:checked").not("[disabled]").each(function () { checkBoxArr.push($(this).val()); });
    if (checkBoxArr == null || checkBoxArr.length == 0) { swal(title + "失败", "请先选择信息", "error"); return; }
    swal({
        title: "确定要" + title + "吗?",
        text: "当前已选择" + checkBoxArr.length + "行信息",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: GetColor(color),
        confirmButtonText: title,
        cancelButtonText: "取消",
        closeOnConfirm: false
    }, function () {
        ActionAjax(url, { Ids: checkBoxArr }, title, "", "");
    });
}

function IeditAction(url, title, color, values) {
    if (title == null || title == "" || title == undefined) { title = "批量操作"; }
    var checkBoxArr = [];
    $("tbody").find("[type='checkbox']:checked").not("[disabled]").each(function () { checkBoxArr.push($(this).val()); });
    if (checkBoxArr == null || checkBoxArr.length == 0) { swal(title + "失败", "请先选择信息", "error"); return; }
    swal({
        title: "确定要" + title + "吗?",
        text: "当前已选择" + checkBoxArr.length + "行信息",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: GetColor(color),
        confirmButtonText: title,
        cancelButtonText: "取消",
        closeOnConfirm: false
    }, function () {
        ActionAjax(url, { Ids: checkBoxArr, Values: values }, title, "", "");
    });
}


function Action(url, data, title, text, color,showType) {
    if (title == null || title == "" || title == undefined) { title = "操作"; }
    swal({
        title: "确定要" + title + "吗?",
        text: text,
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: GetColor(color),
        confirmButtonText: title,
        cancelButtonText: "取消",
        closeOnConfirm: false
    }, function () {
        ActionAjax(url, data, title, text, showType);
    });
}

//入库/出库/调拨时使用  数量可以录入的
function IcheckStockAction(url, title, color) {
    if (title == null || title == "" || title == undefined) { title = "批量操作"; }
    var checkBoxArr = [];
    var param = [];
    var EndDate1 = $("#EndDate").val() || null;
    if (url.toLowerCase() == "/stockpurchase/waitinput") {
        if (!EndDate1) {
            swal(title + "失败", "效期无效", "error");
            return;
        }
    }
    $("tbody").find("[type='checkbox']:checked").not("[disabled]").each(function () {
        checkBoxArr.push($(this).val());
        var productInfoId = $(this).parent().parent().parent().find("td:eq(6) input").attr("data-1");
        var productSKUId = $(this).parent().parent().parent().find("td:eq(6) input").attr("data-2");
        var PurchasePrice = $(this).parent().parent().parent().find("td:eq(6) input").attr("data-3");
        var EndDate = $(this).parent().parent().parent().find("td:eq(6) input").attr("data-4") || EndDate1;
        var productName = $(this).parent().parent().parent().find("td:eq(3)").text();
        var productSku = $(this).parent().parent().parent().find("td:eq(4)").text();
        var productQuantity = $(this).parent().parent().parent().find("td:eq(6) #ProductQuantity").val();
        var DetailId = $(this).val();
        param.push({ EndDate:EndDate,PurchasePrice: PurchasePrice, ProductInfoId: productInfoId, ProductSKUId: productSKUId, ProductName: productName, ProductSku: productSku, ProductQuantity: productQuantity, DetailId: DetailId });
    });
    if (checkBoxArr == null || checkBoxArr.length == 0) { swal(title + "失败", "请先选择信息", "error"); return; }
    if (param == null || param.length == 0) { swal(title + "失败", "请先选择信息", "error"); return; }
    swal({
        title: "确定要" + title + "吗?",
        text: "当前已选择" + checkBoxArr.length + "行信息",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: GetColor(color),
        confirmButtonText: title,
        cancelButtonText: "取消",
        closeOnConfirm: false
    }, function () {
        ActionAjax(url, { Ids: checkBoxArr, Param: JSON.stringify(param), EndDate: EndDate1 }, title, "", "");
    });
}

function ActionAjax(url, data, title, text, showType) {
    laddaBtn = $('.ladda-button').ladda();
    $.ajax({
        type: "post",
        url: url,
        data: data,
        dataType: "json",
        beforeSend: function () {
            laddaBtn.ladda('start');
        },
        complete: function () {
            laddaBtn.ladda('stop');
        },
        success: function (data) {
            laddaBtn.ladda('stop');
            if (data.Status === 200) {
                toastr.success(text, data.Message);
                if (data.Data != undefined && data.Data.target != undefined) {
                    window.location.href = data.Data.target;
                } else {
                    location.reload();
                }
                //if (showType != undefined && showType.toLowerCase() == "toastr") {
                //    toastr.success(text, data.Message);
                //    if (data.Data != undefined && data.Data.target != undefined) {
                //        window.location.href = data.Data.target;
                //    } else {
                //        location.reload();
                //    }
                //} else {
                //    swal({
                //        title: data.Message,
                //        text: text,
                //        type: "success",
                //        confirmButtonText: "确定",
                //    }, function () {
                //        if (data.Data != undefined && data.Data.target != undefined) {
                //            window.location.href = data.Data.target;
                //        } else {
                //            location.reload();
                //        }
                //    });
                //}
            } else {
                swal(title + "失败", data.Message, "error");
            }
        },
        error: function () {
            laddaBtn.ladda('stop');
            swal(title + "失败", data.Message, "error");
        }
    });
}
function GetColor(color) {
    var result = "#DD6B55";
    if (color.toLowerCase() == "red") {
        result = "#DD6B55";
    } else if (color.toLowerCase() == "green") {
        result = "#1BB394";
    }
    return result;
}
//EdnAction

