欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

html+vue實(shí)現(xiàn)分頁功能的示例代碼

 更新時(shí)間:2024年04月20日 11:16:06   作者:星晨羽  
這篇文章主要為大家詳細(xì)介紹了如何使用html+vue實(shí)現(xiàn)簡單的分頁功能,文中的示例代碼簡潔易懂,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下

實(shí)現(xiàn)效果:

html關(guān)鍵代碼:

<div class="ui-jqgrid-resize-mark" id="rs_mlist_table_C87E35BE">&nbsp;</div>
            <div class="list_component_pager ui-jqgrid-pager undefined" dir="ltr">
                <div id="pg_list_table_C87E35BE_pager" class="ui-pager-control" role="group">
                    <table class="ui-pg-table ui-common-table ui-pager-table table table-sm">
                        <tbody>
                        <tr>
                            <td id="list_table_C87E35BE_pager_left" align="left"></td>
                            <td id="list_table_C87E35BE_pager_center" align="center"
                                style="white-space: pre; width: 370.844px;">
                                <table class="ui-pg-table ui-common-table ui-paging-pager">
                                    <tbody>
                                    <tr>
                                        <td ng-show="pageNum<=1" class="ui-pg-button undefined ui-disabled"
                                            title="第一頁">
                                            <span class="bi bi-chevron-bar-left"></span>
                                        </td>
                                        <td ng-show="pageNum>1" class="ui-pg-button undefined" title="第一頁"
                                            ng-click='ctrl.firstPage()'>
                                            <span class="bi bi-chevron-bar-left"></span>
                                        </td>
                                        <td ng-show="pageNum<=1" class="ui-pg-button undefined ui-disabled"
                                            title="上一頁">
                                            <span class="bi bi-chevron-left"></span>
                                        </td>
                                        <td ng-show="pageNum>1" class="ui-pg-button undefined" title="上一頁"
                                            ng-click='ctrl.upperPage()'>
                                            <span class="bi bi-chevron-left"></span>
                                        </td>
                                        <td class="ui-pg-button ui-disabled" style="cursor: default;">
                                            <span class="ui-separator"></span>
                                        </td>
                                        <td id="input_list_table_C87E35BE_pager" dir="ltr">
                                            <input class="ui-pg-input undefined" type="text" size="2" maxlength="7"
                                                   ng-model="pageNum" role="textbox">  共
                                            <span id="sp_1_list_table_C87E35BE_pager">{{totalPages}}</span>頁
                                        </td>
                                        <td class="ui-pg-button ui-disabled" style="cursor: default;">
                                            <span class="ui-separator"></span>
                                        </td>
                                        <td ng-show="totalPages==pageNum"
                                            class="ui-pg-button undefined ui-disabled"
                                            title="下一頁"
                                            style="cursor: default;">
                                            <span class="bi bi-chevron-right"></span>
                                        </td>
                                        <td ng-show="pageNum>=1&&totalPages>1&&pageNum!=totalPages"
                                            class="ui-pg-button undefined"
                                            title="下一頁"
                                            ng-click='ctrl.nextPage()'
                                            style="cursor: default;">
                                            <span class="bi bi-chevron-right"></span>
                                        </td>
                                        <td ng-show="pageNum<totalPages"
                                            class="ui-pg-button undefined" title="最后一頁"
                                            ng-click='ctrl.lastPage()'>
                                            <span class="bi bi-chevron-bar-right"></span>
                                        </td>
                                        <td ng-show="pageNum>=totalPages"
                                            class="ui-pg-button undefined ui-disabled"
                                            title="最后一頁">
                                            <span class="bi bi-chevron-bar-right"></span>
                                        </td>
                                        <td style="margin-top: 20px;">
                                            <cb-select style="border: 1px solid #f0f0f0;margin-top: 20px;"
                                                       ng-model="statType" options="statTypeOptions"
                                                       ng-change='ctrl.flippingPage()'
                                                       inline="true" title="每頁記錄數(shù)">
                                            </cb-select>
                                            <!--                                            <select class="ui-pg-selbox undefined" size="1" role="listbox"-->
                                            <!--                                                    title="每頁記錄數(shù)">-->
                                            <!--                                                <option role="option" value="15" selected="selected">15</option>-->
                                            <!--                                                <option role="option" value="50">50</option>-->
                                            <!--                                                <option role="option" value="100">100</option>-->
                                            <!--                                            </select>-->
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </td>
                            <td id="list_table_C87E35BE_pager_right" align="right">
                                <div dir="ltr" style="text-align:right" class="ui-paging-info">{{test1}}-{{test2}}  共
                                    {{count}} 條
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>

vue代碼:

$scope.statTypeOptions = [{id: '1', name: '15'}, {id: '2', name: '50'}, {id: '3', name: '100'}];
$scope.statType = $scope.statTypeOptions[0];
$scope.count = '';//總數(shù)
$scope.test1 = '';//開始頁數(shù)
$scope.test2 = '';//結(jié)束頁數(shù)
$scope.totalPages = '';//總頁數(shù)
$scope.pageNum = '';//頁碼
$scope.pageSize = '';//每頁數(shù)
$scope.lastSize = '';//最后一頁
                initialize: function () {
                    ctrl.initData();
                },
                initData: function () {
                    ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
                },
                getList: function (keyword, dateRange, dateRanges, pageNum, pageSize) {
                    http.get('maintenanceRecords/total', {
                        keyword: keyword,
                        dateRange: util.encodeJSON(dateRange),
                        dateRanges: util.encodeJSON(dateRanges),
                        pageNum: pageNum, pageSize: pageSize
                    }).then(function (response) {
                        var result = _.get(response, 'data.datas.result', {});
                        $scope.entity = result.list;
                        $scope.count = result.count;
                        $scope.totalPages = result.totalPages;
                        $scope.pageNum = result.pageNum;
                        $scope.pageSize = result.pageSize;
 
                        if ($scope.pageNum == '1') {
                            $scope.test1 = '1'
                            $scope.test2 = $scope.count
                        } else {
                            $scope.test1 = $scope.pageSize * 1 + 1
                            if ($scope.pageSize * $scope.pageNum <= $scope.count) {
                                $scope.test2 = $scope.pageSize * $scope.pageNum
                            } else {
                                $scope.test2 = $scope.count
                            }
                        }
                        $scope.lastSize = Math.ceil($scope.totalPages / $scope.pageSize);
                        util.apply($scope);
                    });
                },
                firstPage: function () {
                    ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, '1', $scope.pageSize)
                },
                upperPage: function () {
                    $scope.pageNum = $scope.pageNum * 1 - 1
                    ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
                },
                nextPage: function () {
                    $scope.pageNum = $scope.pageNum * 1 + 1
                    ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
                },
                lastPage: function () {
                    $scope.pageNum = Math.ceil($scope.count * 1 / $scope.pageSize * 1);
                    ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
                },
                flippingPage: function () {
                    $scope.pageSize = $scope.statType.name
                    ctrl.getList(ctrl.filter.keyword, ctrl.filter.dateRange, ctrl.filter.dateRanges, $scope.pageNum, $scope.pageSize)
                },

Java后端代碼:

@GetMapping("/total")
    public CheckMessage total(@RequestParam(value = "keyword", required = false) String keyword,
                              @RequestParam(value = "dateRanges", required = false) String dateRanges,
                              @RequestParam(value = "dateRange", required = false) String dateRange,
                              @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                              @RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize) {
        Document userDoc = UserUtils.getUser();
        Document query = new Document();
 
        //維修單編號(hào)、狀態(tài)、產(chǎn)品類型、產(chǎn)品編碼、產(chǎn)品名稱、SN碼(新舊碼一起搜索)、處理方案、創(chuàng)建日期、維修完成日期
        if (StrUtil.isNotEmpty(keyword)) {
            query = new Document()
                    .append("$or", Arrays.asList(
                            new Document("repairOrderNumber", new Document("$regex", keyword)),
                            new Document("orderWorkStatus", new Document("$regex", keyword)),
                            new Document("appraisal.service.name", new Document("$regex", keyword)),
                            new Document("product.type", new Document("$regex", keyword)),
                            new Document("product.code", new Document("$regex", keyword)),
                            new Document("product.name", new Document("$regex", keyword)),
                            new Document("snCode", new Document("$regex", keyword)),
                            new Document("resultsRepair.newSnCode", new Document("$regex", keyword)),
                            new Document("resultsRepair.machine", new Document("$regex", keyword))));
        }
 
        if (UserUtils.isOEMUser()) {
            Document oemDto = userDoc.get("oem", Document.class);
            query.append("oemCode", oemDto.getString("id"));
        }
 
        if (StrUtil.isNotEmpty(dateRange)) {
            Document entity = DocuLib.parseDecode(dateRange);
            if (entity.size() > 0) {
                query.append("$and", Arrays.asList(
                        new Document("createTime", new Document("$gte", entity.getString("start"))),
                        new Document("createTime", new Document("$lte", entity.getString("end")))
                ));
            }
        }
 
        if (StrUtil.isNotEmpty(dateRanges)) {
            Document entity = DocuLib.parseDecode(dateRanges);
            if (entity.size() > 0) {
                query.append("$and", Arrays.asList(
                        new Document("completedRepairData", new Document("$gte", entity.getString("start"))),
                        new Document("completedRepairData", new Document("$lte", entity.getString("end")))
                ));
            }
        }
 
        // 計(jì)算跳過的記錄數(shù)
        int skipCount = (pageNum - 1) * pageSize;
 
        List<Document> list = DBUtils.list(MaintenanceRecords.collectionName, query, null, null, pageSize, skipCount);
 
        //總數(shù)
        long count = DBUtils.count(MaintenanceRecords.collectionName, query);
 
        // 計(jì)算總頁數(shù)
        int totalPages = (int) Math.ceil((double) count / pageSize);
        Document entity = new Document();
        entity.put("list", list);
        entity.put("count", count);
        entity.put("pageNum", pageNum);
        entity.put("pageSize", pageSize);
        entity.put("totalPages", totalPages);
 
        return ResultData.succ(entity);
    }

到此這篇關(guān)于html+vue實(shí)現(xiàn)分頁功能的示例代碼的文章就介紹到這了,更多相關(guān)vue分頁內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Vue路由切換和Axios接口取消重復(fù)請(qǐng)求詳解

    Vue路由切換和Axios接口取消重復(fù)請(qǐng)求詳解

    在web項(xiàng)目開發(fā)的過程中,經(jīng)常會(huì)遇到客服端重復(fù)發(fā)送請(qǐng)求的場景,下面這篇文章主要給大家介紹了關(guān)于Vue路由切換和Axios接口取消重復(fù)請(qǐng)求的相關(guān)資料,需要的朋友可以參考下
    2022-05-05
  • vue?+?element-ui?季度選擇器組件?el-quarter-picker示例詳解

    vue?+?element-ui?季度選擇器組件?el-quarter-picker示例詳解

    本文介紹如何在Vue項(xiàng)目中使用基于Element-UI的季度選擇器組件ElQuarterPicker,通過引用并調(diào)用ElQuarterPicker.vue組件來實(shí)現(xiàn)季度選擇功能,感興趣的朋友跟隨小編一起看看吧
    2024-09-09
  • vue中el-message的封裝使用

    vue中el-message的封裝使用

    本文主要介紹了vue中el-message的封裝使用,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • vue實(shí)現(xiàn)指定日期之間的倒計(jì)時(shí)

    vue實(shí)現(xiàn)指定日期之間的倒計(jì)時(shí)

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)指定日期之間的倒計(jì)時(shí),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • Vue中EpicEditor和vue-quill-editor的使用詳解

    Vue中EpicEditor和vue-quill-editor的使用詳解

    EpicEditor和Vue-quill-editor都是基于Quill.js的富文本編輯器,并且都提供了許多強(qiáng)大的功能,下面我們就來介紹一下二者的具體使用,感興趣的小伙伴可以了解一下
    2023-11-11
  • Vue的百度地圖插件嘗試使用

    Vue的百度地圖插件嘗試使用

    本篇文章主要介紹了Vue的百度地圖插件嘗試使用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-09-09
  • 詳解Vuex的屬性

    詳解Vuex的屬性

    Vuex是專為Vue.js應(yīng)用程序開發(fā)的狀態(tài)管理模式,這篇文章主要介紹了Vuex的屬性,本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-08-08
  • 在vue中實(shí)現(xiàn)表單驗(yàn)證碼與滑動(dòng)驗(yàn)證功能的代碼詳解

    在vue中實(shí)現(xiàn)表單驗(yàn)證碼與滑動(dòng)驗(yàn)證功能的代碼詳解

    在Web應(yīng)用程序中,表單驗(yàn)證碼和滑動(dòng)驗(yàn)證是常見的安全機(jī)制,用于防止惡意攻擊和機(jī)器人攻擊,本文將介紹如何使用Vue和vue-verify-code庫來實(shí)現(xiàn)表單驗(yàn)證碼和滑動(dòng)驗(yàn)證功能,需要的朋友可以參考下
    2023-06-06
  • 親自動(dòng)手實(shí)現(xiàn)vue日歷控件

    親自動(dòng)手實(shí)現(xiàn)vue日歷控件

    這篇文章主要記錄了親自動(dòng)手實(shí)現(xiàn)vue日歷控件的詳細(xì)過程,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-06-06
  • 搭建vue3項(xiàng)目以及按需引入element-ui框架組件全過程

    搭建vue3項(xiàng)目以及按需引入element-ui框架組件全過程

    element是基于vue.js框架開發(fā)的快速搭建前端的UI框架,下面這篇文章主要給大家介紹了關(guān)于搭建vue3項(xiàng)目以及按需引入element-ui框架組件的相關(guān)資料,文中通過圖文以及代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-02-02

最新評(píng)論