Ver código fonte

添加商品类型(商品分类)的分页

zhh 3 anos atrás
pai
commit
456aed0dfa

+ 43 - 2
kmall-admin/src/main/java/com/kmall/admin/controller/CategoryController.java

@@ -4,13 +4,18 @@ import com.kmall.admin.dto.CopyCategoryDto;
 import com.kmall.admin.dto.StoreDto;
 import com.kmall.admin.dto.StoreIdDto;
 import com.kmall.admin.entity.CategoryEntity;
+import com.kmall.admin.entity.SupplierEntity;
 import com.kmall.admin.service.CategoryService;
 import com.kmall.admin.utils.ParamUtils;
 import com.kmall.common.constant.JxlsXmlTemplateName;
 import com.kmall.common.utils.*;
 import com.kmall.common.utils.excel.ExcelUtil;
+import com.kmall.manager.manager.express.sf.ServiceException;
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.jxls.reader.XLSDataReadException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -27,10 +32,14 @@ import java.util.Map;
  * @author Scott
  * @email
  * @date 2017-08-21 15:32:31
+ * @author zhuhh
+ * @date 2021-12-7 16:12:16
  */
 @RestController
 @RequestMapping("category")
 public class CategoryController {
+    private static final Log logger = LogFactory.getLog(CategoryController.class);
+
     @Autowired
     private CategoryService categoryService;
     @Autowired
@@ -38,19 +47,51 @@ public class CategoryController {
 
     /**
      * 查看列表
+     *
+     * @author zhuhh
+     * @param params
      */
     @RequestMapping("/list")
     @RequiresPermissions("category:list")
     public R list(@RequestParam Map<String, Object> params) {
 //        ParamUtils.setQueryPowerByRoleType(params, "storeId", "merchSn", "thirdPartyMerchCode");
 //        ParamUtils.setName(params, "categoryName");
-        //查询列表数据
+        // 查询所有一级节点数据
         Query query = new Query(params);
+        query.put("parentId", "0");
 
         List<CategoryEntity> categoryList = categoryService.queryList(query);
+
+        // 获取父id
+        List<Integer> parentIdList = new ArrayList<>();
+         for (CategoryEntity c : categoryList) {
+             parentIdList.add(c.getId());
+        }
+
+        // 获取对应的所有子节点
+        List<CategoryEntity> categoryChildList = categoryService.queryListByParentId(parentIdList);
+        categoryList.addAll(categoryChildList);
+
+        return R.ok().put("list", categoryList);
+    }
+
+    /**
+     * 获取页数和总数
+     *
+     * @author zhuhh
+     * @param params
+     * @return R
+     */
+    @RequestMapping("/queryTotal")
+    @RequiresPermissions("category:list")
+    public R queryTotal(@RequestBody Map<String, Object> params) {
+        // 查询列表数据
+        Query query = new Query(params);
+        query.put("parentId", "0");
+
         int total = categoryService.queryTotal(query);
 
-        PageUtils pageUtil = new PageUtils(categoryList, total, query.getLimit(), query.getPage());
+        PageUtils pageUtil = new PageUtils(null, total, query.getLimit(), query.getPage());
 
         return R.ok().put("page", pageUtil);
     }

+ 3 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/CategoryDao.java

@@ -30,4 +30,7 @@ public interface CategoryDao extends BaseDao<CategoryEntity> {
     Long queryObjectCategoryByName(String trim);
 
     void updateObjectCategory(List<Mall2RulesDto> pointsRulesList);
+
+    List<CategoryEntity> queryListByParentId(List<Integer> parentId);
+
 }

+ 10 - 0
kmall-admin/src/main/java/com/kmall/admin/service/CategoryService.java

@@ -77,4 +77,14 @@ public interface CategoryService {
     int saveCopyCategory(CopyCategoryDto copyCategoryDto);
 
     void refreshBrandCache();
+
+    /**
+     * 根据父id获取所有子对象
+     *
+     * @author zhuhh
+     * @param parentId 父id,多个以逗号分割
+     * @return List
+     */
+    List<CategoryEntity> queryListByParentId(List<Integer> parentId);
+
 }

+ 7 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/CategoryServiceImpl.java

@@ -299,4 +299,11 @@ public class CategoryServiceImpl implements CategoryService {
         }
 
     }
+
+    @Override
+    public List<CategoryEntity> queryListByParentId(List<Integer> parentId) {
+        return categoryDao.queryListByParentId(parentId);
+    }
+
+
 }

+ 27 - 0
kmall-admin/src/main/resources/mybatis/mapper/CategoryDao.xml

@@ -299,4 +299,31 @@
 		</foreach>
 	</update>
 
+	<!--  根据父id查询子对象	-->
+	<select id="queryListByParentId" resultType="com.kmall.admin.entity.CategoryEntity">
+		select
+		`id`,
+		`name`,
+		`store_id`,
+		`merch_sn`,
+		`keywords`,
+		`front_desc`,
+		`parent_id`,
+		`sort_order`,
+		`show_index`,
+		`banner_url`,
+		`icon_url`,
+		`img_url`,
+		`wap_banner_url`,
+		`level`,
+		`type`,
+		`front_name`,
+		`is_show` as `show`
+		from mall_category
+		where `parent_id` in
+		<foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
+			#{id}
+		</foreach>
+	</select>
+
 </mapper>

+ 12 - 1
kmall-admin/src/main/webapp/WEB-INF/page/shop/category.html

@@ -37,7 +37,18 @@
             </div>
         </Row>
         <table id="jqGrid"></table>
-        <div id="jqGridPager"></div>
+        <!--    分页插件    -->
+        <div class="row">
+            <div class="col-lg-6 col-md-6 col-xs-6 col-sm-6" align="right">
+                <ul id="page-nav"></ul>
+            </div>
+            <div style="margin: 25px 0;" align="left" class="col-lg-3 col-md-3 col-xs-3 col-sm-3">
+                <span>当前第 {{ page.currPage }} 页,共 {{ page.totalPage }} 页</span>
+            </div>
+            <div style="margin: 25px 0;" align="right" class="col-lg-3 col-md-3 col-xs-3 col-sm-3">
+                <span>共 {{ page.totalCount }} 条</span>
+            </div>
+        </div>
     </div>
 
     <Card v-show="!showList">

+ 3 - 0
kmall-admin/src/main/webapp/WEB-INF/page/sys/header.html

@@ -41,6 +41,9 @@
 <script src="${rc.contextPath}/statics/plugins/treegrid/jquery.treegrid.bootstrap3.js"></script>
 <script src="${rc.contextPath}/statics/plugins/treegrid/tree.table.js"></script>
 
+<!--分页插件bootstrap-paginator-->
+<script src="${rc.contextPath}/statics/plugins/bootstrap-table/bootstrap-paginator.js"></script>
+
 <!--simplemde富文本-->
 <script src='${rc.contextPath}/statics/plugins/froala_editor/js/froala_editor.min.js'></script>
 <!--[if lt IE 9]>

+ 55 - 4
kmall-admin/src/main/webapp/js/shop/category.js

@@ -11,7 +11,7 @@ function initialPage() {
 
 function getGrid() {
     var colunms = TreeGrid.initColumn();
-    var table = new TreeTable(TreeGrid.id, '../category/queryAll', colunms, {'categoryName': vm.q.categoryName,'storeId':vm.q.storeId});
+    var table = new TreeTable(TreeGrid.id, '../category/list', colunms, {'categoryName': vm.q.categoryName,'storeId':vm.q.storeId, 'page': vm.page.currPage});
     table.setExpandColumn(2);
     table.setIdField("id");
     table.setCodeField("id");
@@ -20,6 +20,9 @@ function getGrid() {
     table.setHeight($(window).height() - 100);
     table.init();
     TreeGrid.table = table;
+
+    // 查询页数总数,生成分页插件
+    queryTotal();
 }
 
 var TreeGrid = {
@@ -58,7 +61,7 @@ TreeGrid.initColumn = function () {
             formatter: function (item, index) {
                 return transIsNot(item.show)
             }
-        },
+        }
         // {title: '操作', width: '90px', align: 'center', valign: 'middle',
         //     formatter: function (item, index) {
         //         if(hasPermission('category:saveCopyCategory')) {
@@ -105,6 +108,11 @@ var vm = new Vue({
         q: {
             name: ''
         },
+        page: {
+            currPage: 1,
+            totalPage: 1,
+            totalCount: 0
+        },
         categoryList: [],
         storeList: [],
         stores: [],
@@ -162,7 +170,6 @@ var vm = new Vue({
             });
         },
         uploadExcelL2Success: function (data) {
-            console.log(data);
             if(data.code==0){
                 alert(data.msg, function (index) {
                     vm.copyCategoryDto.storeList = data.copyCategoryDto.storeList;
@@ -182,7 +189,6 @@ var vm = new Vue({
             }
         },
         uploadExcelError: function (data) {
-            console.log(data);
             alert('上传出现异常,请重试!');
         },
         uploadExcelFormatError: function (file) {
@@ -388,3 +394,48 @@ var vm = new Vue({
         });
     }
 });
+
+// 查询页数、总页数和总数量
+function queryTotal() {
+    $.ajax({
+        type: "POST",
+        url: "../category/queryTotal",
+        contentType: "application/json",
+        data: JSON.stringify({'categoryName': vm.q.categoryName,'storeId':vm.q.storeId, 'page': vm.page.currPage}),
+        dataType: "JSON",
+        success: function (r) {
+            var options = {}
+            if (r.code === 0) {
+                // 分页插件 Bootstrap Paginator 参数设置
+                options = {
+                    currentPage: r.page.currPage,   // 当前页数
+                    totalPages: r.page.totalPage,   // 总页数
+                    bootstrapMajorVersion: 3,    // bootstrap 版本
+                    shouldShowPage: true,
+                    onPageClicked: function (event, originalEvent, type, page) {
+                        // 点击当前页,不做变化
+                        if (vm.page.currPage == page) {
+                            return;
+                        }
+                        vm.page = {
+                            currPage: page,
+                            totalPage: vm.page.totalPage,
+                            totalCount: vm.page.totalCount
+                        }
+                        vm.reload();
+                    }
+                }
+
+                vm.page = {
+                    currPage: r.page.currPage,
+                    totalPage: r.page.totalPage,
+                    totalCount: r.page.totalCount
+                }
+            } else {
+                alert(r.msg);
+            }
+            // 初始化分页插件
+            $("#page-nav").bootstrapPaginator(options);
+        }
+    });
+}

+ 678 - 0
kmall-admin/src/main/webapp/statics/plugins/bootstrap-table/bootstrap-paginator.js

@@ -0,0 +1,678 @@
+/**
+ * bootstrap-paginator-lj.js v1.0.0
+ * 基于bootstrap-paginator.js v1.0.2的优化
+ * --
+ * Copyright 2018 Liu HeJun <liuhejun108@163.com>
+ * --
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function ($) {
+
+    "use strict"; // jshint ;_;
+
+
+    /* Paginator PUBLIC CLASS DEFINITION
+     * ================================= */
+
+    /**
+     * Boostrap Paginator Constructor
+     *
+     * @param element element of the paginator
+     * @param options the options to config the paginator
+     *
+     * */
+    var BootstrapPaginator = function (element, options) {
+        this.init(element, options);
+    },
+        old = null;
+
+    BootstrapPaginator.prototype = {
+
+        /**
+         * Initialization function of the paginator, accepting an element and the options as parameters
+         *
+         * @param element element of the paginator
+         * @param options the options to config the paginator
+         *
+         * */
+        init: function (element, options) {
+
+            this.$element = $(element);
+
+            var version = (options && options.bootstrapMajorVersion) ? options.bootstrapMajorVersion : $.fn.bootstrapPaginator.defaults.bootstrapMajorVersion,
+                id = this.$element.attr("id");
+
+            if (version === 2 && !this.$element.is("div")) {
+
+                throw "in Bootstrap version 2 the pagination must be a div element. Or if you are using Bootstrap pagination 3. Please specify it in bootstrapMajorVersion in the option";
+            } else if (version > 2 && !this.$element.is("ul")) {
+                throw "in Bootstrap version 3 the pagination root item must be an ul element."
+            }
+
+
+
+            this.currentPage = 1;
+
+            this.lastPage = 1;
+
+            this.setOptions(options);
+
+            this.initialized = true;
+        },
+
+        /**
+         * Update the properties of the paginator element
+         *
+         * @param options options to config the paginator
+         * */
+        setOptions: function (options) {
+
+            this.options = $.extend({}, (this.options || $.fn.bootstrapPaginator.defaults), options);
+
+            // .LJ  若设置了totalPages, 则用, 否则根据total和pageSize计算得到
+            if ((this.options && this.options.totalPages)) {
+                this.totalPages = parseInt(this.options.totalPages, 10);  //setup the total pages property.
+            }else{
+                if (this.options.total == 0) {
+                    console.warn("正在根据'total'(0)和'pageSize'计算'totalPages', \n请确保您的数据量确实为0条!");
+                }
+                this.totalPages = parseInt((this.options.total + this.options.pageSize - 1) / this.options.pageSize);   //DEBUG: js里面整数相除, 需要手动取整, 否则结果为小数.  LJ: 2018-2-9 00:31:24
+            }
+
+            // this.totalPages = parseInt(this.options.totalPages, 10);  //setup the total pages property.
+            this.numberOfPages = parseInt(this.options.numberOfPages, 10); //setup the numberOfPages to be shown
+
+            //move the set current page after the setting of total pages. otherwise it will cause out of page exception.
+            if (options && typeof (options.currentPage)  !== 'undefined') {
+
+                this.setCurrentPage(options.currentPage);
+            }
+
+            this.listen();
+
+            //render the paginator
+            this.render();
+
+            if (!this.initialized && this.lastPage !== this.currentPage) {
+                this.$element.trigger("page-changed", [this.lastPage, this.currentPage]);
+            }
+
+        },
+
+        /**
+         * Sets up the events listeners. Currently the pageclicked and pagechanged events are linked if available.
+         *
+         * */
+        listen: function () {
+
+            this.$element.off("page-clicked");
+
+            this.$element.off("page-changed");// unload the events for the element
+
+            if (typeof (this.options.onPageClicked) === "function") {
+                this.$element.bind("page-clicked", this.options.onPageClicked);
+            }
+
+            if (typeof (this.options.onPageChanged) === "function") {
+                this.$element.on("page-changed", this.options.onPageChanged);
+            }
+
+            this.$element.bind("page-clicked", this.onPageClicked);
+        },
+
+
+        /**
+         *
+         *  Destroys the paginator element, it unload the event first, then empty the content inside.
+         *
+         * */
+        destroy: function () {
+
+            this.$element.off("page-clicked");
+
+            this.$element.off("page-changed");
+
+            this.$element.removeData('bootstrapPaginator');
+
+            this.$element.empty();
+
+        },
+
+        /**
+         * Shows the page
+         *
+         * */
+        show: function (page) {
+
+            this.setCurrentPage(page);
+
+            this.render();
+
+            if (this.lastPage !== this.currentPage) {
+                this.$element.trigger("page-changed", [this.lastPage, this.currentPage]);
+            }
+        },
+
+        /**
+         * Shows the next page
+         *
+         * */
+        showNext: function () {
+            var pages = this.getPages();
+
+            if (pages.next) {
+                this.show(pages.next);
+            }
+
+        },
+
+        /**
+         * Shows the previous page
+         *
+         * */
+        showPrevious: function () {
+            var pages = this.getPages();
+
+            if (pages.prev) {
+                this.show(pages.prev);
+            }
+
+        },
+
+        /**
+         * Shows the first page
+         *
+         * */
+        showFirst: function () {
+            var pages = this.getPages();
+
+            if (pages.first) {
+                this.show(pages.first);
+            }
+
+        },
+
+        /**
+         * Shows the last page
+         *
+         * */
+        showLast: function () {
+            var pages = this.getPages();
+
+            if (pages.last) {
+                this.show(pages.last);
+            }
+
+        },
+
+        /**
+         * Internal on page item click handler, when the page item is clicked, change the current page to the corresponding page and
+         * trigger the pageclick event for the listeners.
+         *
+         *
+         * */
+        onPageItemClicked: function (event) {
+
+            var type = event.data.type,
+                page = event.data.page;
+
+            this.$element.trigger("page-clicked", [event, type, page]);
+
+        },
+
+        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");
+                break;
+            case "prev":
+                currentTarget.bootstrapPaginator("showPrevious");
+                break;
+            case "next":
+                currentTarget.bootstrapPaginator("showNext");
+                break;
+            case "last":
+                currentTarget.bootstrapPaginator("showLast");
+                break;
+            case "page":
+                currentTarget.bootstrapPaginator("show", page);
+                break;
+            }
+
+        },
+
+        /**
+         * Renders the paginator according to the internal properties and the settings.
+         *
+         *
+         * */
+        render: function () {
+
+            //fetch the container class and add them to the container
+            var containerClass = this.getValueFromOption(this.options.containerClass, this.$element),
+                size = this.options.size || "normal",
+                alignment = this.options.alignment || "left",
+                pages = this.getPages(),
+                listContainer = this.options.bootstrapMajorVersion === 2 ? $("<ul></ul>") : this.$element,
+                listContainerClass = this.options.bootstrapMajorVersion === 2 ? this.getValueFromOption(this.options.listContainerClass, listContainer) : null,
+                first = null,
+                prev = null,
+                next = null,
+                last = null,
+                p = null,
+                i = 0;
+
+
+            this.$element.prop("class", "");
+
+            this.$element.addClass("pagination");
+
+            switch (size.toLowerCase()) {
+            case "large":
+            case "small":
+            case "mini":
+                this.$element.addClass($.fn.bootstrapPaginator.sizeArray[this.options.bootstrapMajorVersion][size.toLowerCase()]);
+                break;
+            default:
+                break;
+            }
+
+            if (this.options.bootstrapMajorVersion === 2) {
+                switch (alignment.toLowerCase()) {
+                case "center":
+                    this.$element.addClass("pagination-centered");
+                    break;
+                case "right":
+                    this.$element.addClass("pagination-right");
+                    break;
+                default:
+                    break;
+                }
+            }
+
+
+            this.$element.addClass(containerClass);
+
+            //empty the outter most container then add the listContainer inside.
+            this.$element.empty();
+
+            if (this.options.bootstrapMajorVersion === 2) {
+                this.$element.append(listContainer);
+
+                listContainer.addClass(listContainerClass);
+            }
+
+            //update the page element reference
+            this.pageRef = [];
+
+            if (pages.first) {//if the there is first page element
+                first = this.buildPageItem("first", pages.first);
+
+                if (first) {
+                    listContainer.append(first);
+                }
+
+            }
+
+            if (pages.prev) {//if the there is previous page element
+
+                prev = this.buildPageItem("prev", pages.prev);
+
+                if (prev) {
+                    listContainer.append(prev);
+                }
+
+            }
+
+
+            for (i = 0; i < pages.length; i = i + 1) {//fill the numeric pages.
+
+                p = this.buildPageItem("page", pages[i]);
+
+                if (p) {
+                    listContainer.append(p);
+                }
+            }
+
+            if (pages.next) {//if there is next page
+
+                next = this.buildPageItem("next", pages.next);
+
+                if (next) {
+                    listContainer.append(next);
+                }
+            }
+
+            if (pages.last) {//if there is last page
+
+                last = this.buildPageItem("last", pages.last);
+
+                if (last) {
+                    listContainer.append(last);
+                }
+            }
+        },
+
+        /**
+         *
+         * Creates a page item base on the type and page number given.
+         *
+         * @param page page number
+         * @param type type of the page, whether it is the first, prev, page, next, last
+         *
+         * @return Object the constructed page element
+         * */
+        buildPageItem: function (type, page) {
+
+            var itemContainer = $("<li></li>"),//creates the item container
+                itemContent = $("<a></a>"),//creates the item content
+                text = "",
+                title = "",
+                itemContainerClass = this.options.itemContainerClass(type, page, this.currentPage),
+                itemContentClass = this.getValueFromOption(this.options.itemContentClass, type, page, this.currentPage),
+                tooltipOpts = null;
+
+
+            switch (type) {
+
+            case "first":
+                if (!this.getValueFromOption(this.options.shouldShowPage, type, page, this.currentPage)) { return; }
+                text = this.options.itemTexts(type, page, this.currentPage);
+                title = this.options.tooltipTitles(type, page, this.currentPage);
+                break;
+            case "last":
+                if (!this.getValueFromOption(this.options.shouldShowPage, type, page, this.currentPage)) { return; }
+                text = this.options.itemTexts(type, page, this.currentPage);
+                title = this.options.tooltipTitles(type, page, this.currentPage);
+                break;
+            case "prev":
+                if (!this.getValueFromOption(this.options.shouldShowPage, type, page, this.currentPage)) { return; }
+                text = this.options.itemTexts(type, page, this.currentPage);
+                title = this.options.tooltipTitles(type, page, this.currentPage);
+                break;
+            case "next":
+                if (!this.getValueFromOption(this.options.shouldShowPage, type, page, this.currentPage)) { return; }
+                text = this.options.itemTexts(type, page, this.currentPage);
+                title = this.options.tooltipTitles(type, page, this.currentPage);
+                break;
+            case "page":
+                if (!this.getValueFromOption(this.options.shouldShowPage, type, page, this.currentPage)) { return; }
+                text = this.options.itemTexts(type, page, this.currentPage);
+                title = this.options.tooltipTitles(type, page, this.currentPage);
+                break;
+            }
+
+            itemContainer.addClass(itemContainerClass).append(itemContent);
+
+            itemContainer.addClass("page-item");
+            itemContainer.find("a").addClass("page-link");
+
+            itemContent.addClass(itemContentClass).html(text).on("click", null, {type: type, page: page}, $.proxy(this.onPageItemClicked, this));
+
+            if (this.options.pageUrl) {
+                itemContent.attr("href", this.getValueFromOption(this.options.pageUrl, type, page, this.currentPage));
+            }
+
+            if (this.options.useBootstrapTooltip) {
+                tooltipOpts = $.extend({}, this.options.bootstrapTooltipOptions, {title: title});
+
+                itemContent.tooltip(tooltipOpts);
+            } else {
+                itemContent.attr("title", title);
+            }
+
+            return itemContainer;
+
+        },
+
+        setCurrentPage: function (page) {
+            if (page > this.totalPages || page < 1) {// if the current page is out of range, throw exception.
+
+                throw "Page out of range";
+
+            }
+
+            this.lastPage = this.currentPage;
+
+            this.currentPage = parseInt(page, 10);
+
+        },
+
+        /**
+         * Gets an array that represents the current status of the page object. Numeric pages can be access via array mode. length attributes describes how many numeric pages are there. First, previous, next and last page can be accessed via attributes first, prev, next and last. Current attribute marks the current page within the pages.
+         *
+         * @return object output objects that has first, prev, next, last and also the number of pages in between.
+         * */
+        getPages: function () {
+
+            var totalPages = this.totalPages,// get or calculate the total pages via the total records
+                pageStart = (this.currentPage % this.numberOfPages === 0) ? (parseInt(this.currentPage / this.numberOfPages, 10) - 1) * this.numberOfPages + 1 : parseInt(this.currentPage / this.numberOfPages, 10) * this.numberOfPages + 1,//calculates the start page.
+                output = [],
+                i = 0,
+                counter = 0;
+
+            pageStart = pageStart < 1 ? 1 : pageStart;//check the range of the page start to see if its less than 1.
+
+            for (i = pageStart, counter = 0; counter < this.numberOfPages && i <= totalPages; i = i + 1, counter = counter + 1) {//fill the pages
+                output.push(i);
+            }
+
+            output.first = 1;//add the first when the current page leaves the 1st page.
+
+            if (this.currentPage > 1) {// add the previous when the current page leaves the 1st page
+                output.prev = this.currentPage - 1;
+            } else {
+                output.prev = 1;
+            }
+
+            if (this.currentPage < totalPages) {// add the next page when the current page doesn't reach the last page
+                output.next = this.currentPage + 1;
+            } else {
+                output.next = totalPages;
+            }
+
+            output.last = totalPages;// add the last page when the current page doesn't reach the last page
+
+            output.current = this.currentPage;//mark the current page.
+
+            output.total = totalPages;
+
+            output.numberOfPages = this.options.numberOfPages;
+
+            return output;
+
+        },
+
+        /**
+         * Gets the value from the options, this is made to handle the situation where value is the return value of a function.
+         *
+         * @return mixed value that depends on the type of parameters, if the given parameter is a function, then the evaluated result is returned. Otherwise the parameter itself will get returned.
+         * */
+        getValueFromOption: function (value) {
+
+            var output = null,
+                args = Array.prototype.slice.call(arguments, 1);
+
+            if (typeof value === 'function') {
+                output = value.apply(this, args);
+            } else {
+                output = value;
+            }
+
+            return output;
+
+        }
+
+    };
+
+
+    /* TYPEAHEAD PLUGIN DEFINITION
+     * =========================== */
+
+    old = $.fn.bootstrapPaginator;
+
+    $.fn.bootstrapPaginator = function (option) {
+
+        var args = arguments,
+            result = null;
+
+        $(this).each(function (index, item) {
+            var $this = $(item),
+                data = $this.data('bootstrapPaginator'),
+                options = (typeof option !== 'object') ? null : option;
+
+            if (!data) {
+                data = new BootstrapPaginator(this, options);
+
+                $this = $(data.$element);
+
+                $this.data('bootstrapPaginator', data);
+
+                return;
+            }
+
+            if (typeof option === 'string') {
+
+                if (data[option]) {
+                    result = data[option].apply(data, Array.prototype.slice.call(args, 1));
+                } else {
+                    throw "Method " + option + " does not exist";
+                }
+
+            } else {
+                result = data.setOptions(option);
+            }
+        });
+
+        return result;
+
+    };
+
+    $.fn.bootstrapPaginator.sizeArray = {
+
+        "2": {
+            "large": "pagination-large",
+            "small": "pagination-small",
+            "mini": "pagination-mini"
+        },
+        "3": {
+            "large": "pagination-lg",
+            "small": "pagination-sm",
+            "mini": ""
+        }
+
+    };
+
+    $.fn.bootstrapPaginator.defaults = {
+        containerClass: "",
+        size: "normal",
+        alignment: "left",
+        bootstrapMajorVersion: 2,
+        listContainerClass: "",
+        itemContainerClass: function (type, page, current) {
+            return (page === current) ? "active" : "";
+        },
+        itemContentClass: function (type, page, current) {
+            return "";
+        },
+        currentPage: 1,
+        numberOfPages: 5,
+        total:0,    //总记录数, 来自后台    +LJ
+        pageSize:10, //前台或后台均可设定    +LJ
+        // totalPages: 1,   //源码        -LJ
+        // totalPages:function (total,pageSize) {    // +LJ  !设置了totalPages, 则total, pageSize设置失效!
+        //     return (total + pageSize - 1) / pageSize;
+        // },
+        pageUrl: function (type, page, current) {
+            return null;
+        },
+        onPageClicked: null,
+        onPageChanged: null,
+        useBootstrapTooltip: false,
+        shouldShowPage: function (type, page, current) {
+            console.log(type)
+            console.log(page);
+            console.log(current);
+            var result = true;
+
+            switch (type) {
+            case "first":
+                result = (current !== 1);
+                break;
+            case "prev":
+                result = (current !== 1);
+                break;
+            case "next":
+                result = (current !== this.totalPages);
+                break;
+            case "last":
+                result = (current !== this.totalPages);
+                break;
+            case "page":
+                result = true;
+                break;
+            }
+
+            return result;
+
+        },
+        itemTexts: function (type, page, current) {
+            switch (type) {
+            case "first":
+                return "&lt;&lt;";
+            case "prev":
+                return "&lt;";
+            case "next":
+                return "&gt;";
+            case "last":
+                return "&gt;&gt;";
+            case "page":
+                return page;
+            }
+        },
+        tooltipTitles: function (type, page, current) {
+
+            switch (type) {
+            case "first":
+                return "Go to first page";
+            case "prev":
+                return "Go to previous page";
+            case "next":
+                return "Go to next page";
+            case "last":
+                return "Go to last page";
+            case "page":
+                return (page === current) ? "Current page is " + page : "Go to page " + page;
+            }
+        },
+        bootstrapTooltipOptions: {
+            animation: true,
+            html: true,
+            placement: 'top',
+            selector: false,
+            title: "",
+            container: false
+        }
+    };
+
+    $.fn.bootstrapPaginator.Constructor = BootstrapPaginator;
+
+
+
+}(window.jQuery));

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
kmall-admin/src/main/webapp/statics/plugins/bootstrap-table/bootstrap-paginator.min.js


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff