var nPageIndex = 0;
var nPageSize = 10;
var nPageCount = 0;

//查询方法
function Query() {
    nPageIndex = 0;
    BindData();
}
//创建二维码
function CreatCode()
{
    $("#EditModal").modal("show");
}

//创建文本消息
function CreatText() {
    $("#replayTextModel").modal("show");
}
//创建图片消息
function CreatPic() {
    $("#replayImageModel").modal("show");

}
//创建图文消息
function CreatTextPic() {
    $("#replayImageTextModel").modal("show");
}

//选择每页多少行
function ChangePageSize() {
    nPageIndex = 0;
    nPageSize = Number($("#selectPageSize").val());
    BindData();
}

//跳转到*页
function JumpPageIndex(index) {
    nPageIndex = index;
    BindData();
}

//按钮跳转到*页
function BtnJumpPageIndex() {
    if ($("#txtJumpPageIndex").val().length == 0) {
        return;
    }
    var nSelectPageIndex = Number($("#txtJumpPageIndex").val());
    if (nSelectPageIndex > nPageCount) {
        nPageIndex = nPageCount - 1;
    } else {
        nPageIndex = Number($("#txtJumpPageIndex").val()) - 1;
    }
    BindData();
}

//得到表格表头一列内容，非排序字段
function GetTableHeadNoOrderStr(thisColumnsMark) {
    var strTh = "<th>" + thisColumnsMark + "</th>";
    return strTh;
}


//得到页脚字符串
function GetPageFootStr(pageindex,ntotal) {
    //记录数选择
    var strFooter = "";
    

    var strFistPageEnabled = (nPageIndex <= 0) ? (" disabled=\"disabled\" ") : (" onclick=\"JumpPageIndex(0);\"");
    var strBfPageEnabled = (nPageIndex == 0) ? (" disabled=\"disabled\" ") : (" onclick=\"JumpPageIndex(" + (nPageIndex - 1) + ");\"");
    var strNextPageEnabled = (nPageIndex + 1 == nPageCount) ? (" disabled=\"disabled\" ") : (" onclick=\"JumpPageIndex(" + (nPageIndex + 1) + ");\"");
    var strLastPageEnabled = (nPageIndex + 1 == nPageCount) ? (" disabled=\"disabled\" ") : (" onclick=\"JumpPageIndex(" + (nPageCount - 1) + ");\"");

    strFooter += "<div class=\"col-md-12 footer-page-container\">";
    strFooter += "<div class=\"btn-toolbar button-group\" role=\"toolbar\" style=\"float:right\">";
    strFooter += "<div class=\"btn-group\">";
    strFooter += "<button type=\"button\" class=\"btn btn-default\"" + strFistPageEnabled + ">首页</button>";
    strFooter += "<button type=\"button\" class=\"btn btn-default\"" + strBfPageEnabled + ">上一页</button>";
    strFooter += "</div>";
    strFooter += "<div class=\"btn-group bottom-page\"><span>" + (nPageIndex + 1) + "/" + (nPageCount) + "</span></div>";
    strFooter += "<div class=\"btn-group\">";
    strFooter += "<button type=\"button\" class=\"btn btn-default\"" + strNextPageEnabled + ">下一页</button>";
    strFooter += "<button type=\"button\" class=\"btn btn-default\"" + strLastPageEnabled + ">尾页</button>";
    strFooter += "</div>";
    strFooter += "<div class=\"btn-group bottom-page\">";
    strFooter += "<span>共 <span>" + ntotal + "</span> 条 每页</span>";
    strFooter += "</div>";
    strFooter += "<div class=\"btn-group\">";
    strFooter += "<select id=\"selectPageSize\" class=\"selectpicker show-tick form-control\" onchange=\"ChangePageSize();\">";
       
    if (nPageSize != 10 && nPageSize != 20 && nPageSize != 50 && nPageSize != 100 && nPageSize != 1000) {
        strFooter += "<option value=\"" + nPageSize + "\"" + " selected=\"selected\"" + ">" + nPageSize + "</option>";
    }
    strFooter += "<option value=\"10\"" + (nPageSize == 10 ? " selected=\"selected\"" : "") + ">10</option>";
    strFooter += "<option value=\"20\"" + (nPageSize == 20 ? " selected=\"selected\"" : "") + ">20</option>";
    strFooter += "<option value=\"50\"" + (nPageSize == 50 ? " selected=\"selected\"" : "") + ">50</option>";
    strFooter += "<option value=\"100\"" + (nPageSize == 100 ? " selected=\"selected\"" : "") + ">100</option>";
    strFooter += "<option value=\"1000\"" + (nPageSize == 1000 ? " selected=\"selected\"" : "") + ">1000</option>";
    strFooter += "</select>";
    strFooter += "</div>";
    strFooter += "<div class=\"btn-group bottom-page\">";
    strFooter += "<span>条 </span>  <span>跳转到第</span>";
    strFooter += "</div>";
    strFooter += "<div class=\"btn-group\">";
    strFooter += "<input id=\"txtJumpPageIndex\" type=\"text\" class=\"form-control grpup-text\" value=" + (nPageIndex + 1) + " />";
    strFooter += "</div>";
    strFooter += "<div class=\"btn-group bottom-page\">";
    strFooter += "<span>页</span>";
    strFooter += "</div>";
    strFooter += "<div class=\"btn-group\">";
    strFooter += "<button type=\"button\" class=\"btn btn-success\" onclick=\"BtnJumpPageIndex();\">GO</button>";
    strFooter += "</div>";
    strFooter += "</div>";
    strFooter += "</div>";

    return strFooter;
}

