bootstrap.paginator.js的使用

葛安和
2023-12-01
​
        function query(page) {
            $.ajax({
                type: "GET",
                url: "/users/query",
                dataType: "json",
                data: "page=" + page,
                success: function (data) {
                    if (data.Count > 0) {

                var options = {
                    currentPage:  data.PageNumber,
                    bootstrapMajorVersion: 3,
                    size: "normal",
                    totalPages: data.TotalPages,

                    itemTexts: function (type, page, current) {

                        switch (type) {

                            case "first":
                                return "首页";
                            case "prev":
                                return "上一页";
                            case "next":
                                return "下一页";
                            case "last":
                                return "末页";
                            case "page":
                                return page;
                        }
                    },
                    itemContainerClass: function (type, page, current) {
                        return (page === current) ? "active" : "pointer-cursor";
                    },
                    onPageClicked: function (event, originalEvent, type, page) {

                        //show the corresponding page and retrieve the newly built item related to the page clicked before for the event return

                        var currentTarget = $(event.currentTarget);

                        switch (type) {
                            case "first":
                                currentTarget.bootstrapPaginator("showFirst");
                                query(page);//add
                                break;
                            case "prev":
                                currentTarget.bootstrapPaginator("showPrevious");
                                query(page);//add
                                break;
                            case "next":
                                currentTarget.bootstrapPaginator("showNext");
                                query(page);//add
                                break;
                            case "last":
                                currentTarget.bootstrapPaginator("showLast");
                                query(page);//add
                                break;
                            case "page":
                                currentTarget.bootstrapPaginator("show", page);
                                query(page);//add
                                break;
                        }

                    }
                }

                $('#pageLimit').bootstrapPaginator(options);
               // $('#pageLimit').bootstrapPaginator('show',7);

                        //拼表单
                        weave(data.Data);

            }
                }
            });
        }

        function weave(data) {
            $("#tableShow  tr:not(:first)").empty("");

            $.each(data, function (index) {

                      var Status = '';
                if (data[index].Status == -1) {
                          Status = '失败';
                      }
                else if (data[index].Status == 0) {
                          Status = '付款中';
                      }
                else if (data[index].Status == 1) {
                          Status = '成功';
                }

                var ShowMoney = data[index].ShowMoney.toFixed(2).toString();
                var Income = data[index].Income.toFixed(2).toString();
               // var CreateTime = '2019-3-20';
                var CreateTime = data[index].CreateTime;
                var time = CreateTime.substring(CreateTime.indexOf('(') + 1, CreateTime.indexOf(')'));
                var da = new Date(parseInt(time));
                var year = da.getFullYear() + '-';
                var month = da.getMonth() + 1 + '-';
                var date = da.getDate() + ' ';
                var hour = da.getHours()+':';
                var minutes = da.getMinutes() + ':';
                if (minutes.length == 2) {
                    minutes = '0' + minutes;
                }
                var seconds = da.getSeconds().toString();
                if (seconds.length == 1) {
                    seconds = '0' + seconds;
                }

                var timeFinal = year + month + date +  hour + minutes + seconds;
                      var tr1 = '';
                      var tr1='<tr>'+
                          '<td>' + data[index].TransNo+'</td>'+
                          '<td>' + data[index].Accounts+'</td>'+
                          '<td>' + data[index].MirName+'</td>'+
                          '<td>' + data[index].ProductName+'</td>'+
                          '<td>' + ShowMoney+'</td>'+
                          '<td><span>' +Income+'</span></td>'+
                          '<td>' + timeFinal+'</td>'+
                          '<td>' +Status+'</td>' +
                          '<td>';

                    if (data[index].Status == 1) {

                        if (data[index].Sent) {
                            tr1 = tr1 + '<span>已发送</span>';
                        }
                        else {
                            if (!data[index].Stop) {
                                tr1 = tr1 + '<a href="javascript:;" onclick="Postordersend(el.TransNo)">未发送</a>';
                            }
                            else {
                                   tr1 = tr1 + '<span class="font-gray">-</span>';
                            }
                        }
                    }
                    else {
                        tr1 = tr1 + '<span class="font-gray">-</span>';
                    }

                       tr1 = tr1 + '</td> </tr>';

                      $("#tableShow").append($(tr1));

            });

        }

​

这一篇是异步拼表单的

 类似资料: