From 5e09230c29738046d6bd35f30fd7608a9ae886e0 Mon Sep 17 00:00:00 2001 From: jiahengaa <2429803999@qq.com> Date: Thu, 6 May 2021 23:06:45 +0800 Subject: [PATCH] fix bug https://github.com/jiahengaa/BeeGridTable/issues/16 Please update to v1.5.2 For details, please see http://beegridtable.com/serverFilterAndSortAndPage --- package.json | 4 +- src/components/page/page.vue | 550 ++-- src/components/table/cell.vue | 209 +- src/components/table/headFilterSlot.js | 2 + src/components/table/table-head.vue | 1262 +++++---- src/components/table/table.vue | 3598 +++++++++++++----------- src/components/table/util.js | 58 +- src/locale/lang/en-US.js | 16 +- src/locale/lang/zh-CN.js | 16 +- types/table.d.ts | 8 +- 10 files changed, 3039 insertions(+), 2684 deletions(-) diff --git a/package.json b/package.json index 81b7df3..ec3fec7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "beegridtable", - "version": "1.3.0", + "version": "1.5.2", "title": "BeeGridTable", "description": "A high quality DataTable component Library with Vue.js", "homepage": "http://www.beegridtable.com", @@ -21,7 +21,7 @@ "types" ], "scripts": { - "dev": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --host 192.168.3.44 --port 8082 --config build/webpack.dev.config.js", + "dev": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --host localhost --port 8082 --config build/webpack.dev.config.js", "dev:s": "webpack-dev-server --content-base test/ --open --inline --hot --compress --history-api-fallback --port 8083 --config build/webpack.dev.config.js", "dist:style": "gulp --gulpfile build/build-style.js", "dist:dev": "webpack --config build/webpack.dist.dev.config.js", diff --git a/src/components/page/page.vue b/src/components/page/page.vue index a432660..f1f3356 100644 --- a/src/components/page/page.vue +++ b/src/components/page/page.vue @@ -157,289 +157,293 @@ import Locale from "../../mixins/locale"; const prefixCls = "bee-page"; export default { - name: "Page", - mixins: [Locale], - components: { Options }, - props: { - current: { - type: Number, - default: 1, - }, - total: { - type: Number, - default: 0, - }, - filterTotalData: { - type: Number, - default: 0, - }, - filterResultL: { - type: String, - default: "", - }, - filterResultR: { - type: String, - default: "", - }, - pageSize: { - type: Number, - default: 10, - }, - pageCount: { - type: Number, - default: 4, - }, - placement: { - validator(value) { - return oneOf(value, ["top", "bottom"]); - }, - default: "bottom", - }, - transfer: { - type: Boolean, - default() { - return !this.$BEETABLE || this.$BEETABLE.transfer === "" - ? false - : this.$BEETABLE.transfer; - }, - }, - size: { - validator(value) { - return oneOf(value, ["small"]); - }, - }, - simple: { - type: Boolean, - default: false, - }, - showTotal: { - type: Boolean, - default: false, - }, - showElevator: { - type: Boolean, - default: false, - }, - showSizer: { - type: Boolean, - default: false, - }, - className: { - type: String, - }, - styles: { - type: Object, - }, - prevText: { - type: String, - default: "", - }, - nextText: { - type: String, - default: "", - }, - disabled: { - type: Boolean, - default: false, - }, - }, - data() { - return { - prefixCls: prefixCls, - currentPage: this.current, - currentPageSize: this.pageSize, - currentPageSizeOpts: [10, 20, 30, 40], - }; - }, - watch: { - total(val) { - let maxPage = Math.ceil(val / this.currentPageSize); - if (maxPage < this.currentPage) { - this.currentPage = maxPage === 0 ? 1 : maxPage; - } - }, - current(val) { - this.currentPage = val; - }, - pageSize: { - handler(val) { - this.currentPageSize = val; - if (val > 0 && this.pageCount) { - this.currentPageSizeOpts = []; - for (var i = 1; i <= this.pageCount; i++) { - this.currentPageSizeOpts.push(val * i); - } + name: "Page", + mixins: [Locale], + components: { Options }, + props: { + current: { + type: Number, + default: 1 + }, + total: { + type: Number, + default: 0 + }, + filterTotalData: { + type: Number, + default: 0 + }, + filterResultL: { + type: String, + default: "" + }, + filterResultR: { + type: String, + default: "" + }, + pageSize: { + type: Number, + default: 10 + }, + pageCount: { + type: Number, + default: 4 + }, + placement: { + validator(value) { + return oneOf(value, ["top", "bottom"]); + }, + default: "bottom" + }, + transfer: { + type: Boolean, + default() { + return !this.$BEETABLE || this.$BEETABLE.transfer === "" + ? false + : this.$BEETABLE.transfer; + } + }, + size: { + validator(value) { + return oneOf(value, ["small"]); + } + }, + simple: { + type: Boolean, + default: false + }, + showTotal: { + type: Boolean, + default: false + }, + showElevator: { + type: Boolean, + default: false + }, + showSizer: { + type: Boolean, + default: false + }, + className: { + type: String + }, + styles: { + type: Object + }, + prevText: { + type: String, + default: "" + }, + nextText: { + type: String, + default: "" + }, + disabled: { + type: Boolean, + default: false } - }, - immediate: true, }, - pageCount: { - handler(val) { - if (this.pageSize > 0 && val > 0) { - this.currentPageSizeOpts = []; - for (var i = 1; i <= val; i++) { - this.currentPageSizeOpts.push(i * this.pageSize); - } + data() { + return { + prefixCls: prefixCls, + currentPage: this.current, + currentPageSize: this.pageSize, + currentPageSizeOpts: [10, 20, 30, 40] + }; + }, + watch: { + total(val) { + let maxPage = Math.ceil(val / this.currentPageSize); + if (maxPage < this.currentPage) { + this.currentPage = maxPage === 0 ? 1 : maxPage; + } + }, + current(val) { + this.currentPage = val; + }, + pageSize: { + handler(val) { + this.currentPageSize = val; + if (val > 0 && this.pageCount) { + this.currentPageSizeOpts = []; + for (var i = 1; i <= this.pageCount; i++) { + this.currentPageSizeOpts.push(val * i); + } + } + }, + immediate: true + }, + pageCount: { + handler(val) { + if (this.pageSize > 0 && val > 0) { + this.currentPageSizeOpts = []; + for (var i = 1; i <= val; i++) { + this.currentPageSizeOpts.push(i * this.pageSize); + } + } + }, + immediate: true } - }, - immediate: true, - }, - }, - computed: { - isSmall() { - return !!this.size; - }, - allPages() { - const allPage = Math.ceil(this.filterTotalData / this.currentPageSize); - return allPage === 0 ? 1 : allPage; - }, - simpleWrapClasses() { - return [ - `${prefixCls}`, - `${prefixCls}-simple`, - { - [`${this.className}`]: !!this.className, - }, - ]; - }, - simplePagerClasses() { - return `${prefixCls}-simple-pager`; - }, - wrapClasses() { - return [ - `${prefixCls}`, - { - [`${this.className}`]: !!this.className, - [`${prefixCls}-with-disabled`]: this.disabled, - mini: !!this.size, - }, - ]; - }, - prevClasses() { - return [ - `${prefixCls}-prev`, - { - [`${prefixCls}-disabled`]: this.currentPage === 1 || this.disabled, - [`${prefixCls}-custom-text`]: this.prevText !== "", - }, - ]; }, - nextClasses() { - return [ - `${prefixCls}-next`, - { - [`${prefixCls}-disabled`]: - this.currentPage === this.allPages || this.disabled, - [`${prefixCls}-custom-text`]: this.nextText !== "", - }, - ]; - }, - firstPageClasses() { - return [ - `${prefixCls}-item`, - { - [`${prefixCls}-item-active`]: this.currentPage === 1, + computed: { + isSmall() { + return !!this.size; }, - ]; - }, - lastPageClasses() { - return [ - `${prefixCls}-item`, - { - [`${prefixCls}-item-active`]: this.currentPage === this.allPages, + allPages() { + const allPage = Math.ceil( + this.filterTotalData / this.currentPageSize + ); + return allPage === 0 ? 1 : allPage; }, - ]; - }, - }, - methods: { - changePage(page) { - if (this.disabled) return; - if (this.currentPage != page) { - this.currentPage = page; - this.$emit("update:current", page); - this.$emit("on-change", page); - } - }, - prev() { - if (this.disabled) return; - const current = this.currentPage; - if (current <= 1) { - return false; - } - this.changePage(current - 1); - }, - next() { - if (this.disabled) return; - const current = this.currentPage; - if (current >= this.allPages) { - return false; - } - this.changePage(current + 1); - }, - fastPrev() { - if (this.disabled) return; - const page = this.currentPage - 5; - if (page > 0) { - this.changePage(page); - } else { - this.changePage(1); - } - }, - fastNext() { - if (this.disabled) return; - const page = this.currentPage + 5; - if (page > this.allPages) { - this.changePage(this.allPages); - } else { - this.changePage(page); - } - }, - onSize(pageSize) { - if (this.disabled) return; - this.currentPageSize = pageSize; - this.$emit("on-page-size-change", pageSize); - this.changePage(1); - }, - onPage(page) { - if (this.disabled) return; - this.changePage(page); + simpleWrapClasses() { + return [ + `${prefixCls}`, + `${prefixCls}-simple`, + { + [`${this.className}`]: !!this.className + } + ]; + }, + simplePagerClasses() { + return `${prefixCls}-simple-pager`; + }, + wrapClasses() { + return [ + `${prefixCls}`, + { + [`${this.className}`]: !!this.className, + [`${prefixCls}-with-disabled`]: this.disabled, + mini: !!this.size + } + ]; + }, + prevClasses() { + return [ + `${prefixCls}-prev`, + { + [`${prefixCls}-disabled`]: + this.currentPage === 1 || this.disabled, + [`${prefixCls}-custom-text`]: this.prevText !== "" + } + ]; + }, + nextClasses() { + return [ + `${prefixCls}-next`, + { + [`${prefixCls}-disabled`]: + this.currentPage === this.allPages || this.disabled, + [`${prefixCls}-custom-text`]: this.nextText !== "" + } + ]; + }, + firstPageClasses() { + return [ + `${prefixCls}-item`, + { + [`${prefixCls}-item-active`]: this.currentPage === 1 + } + ]; + }, + lastPageClasses() { + return [ + `${prefixCls}-item`, + { + [`${prefixCls}-item-active`]: + this.currentPage === this.allPages + } + ]; + } }, - keyDown(e) { - const key = e.keyCode; - const condition = - (key >= 48 && key <= 57) || - (key >= 96 && key <= 105) || - key === 8 || - key === 37 || - key === 39; + methods: { + changePage(page) { + if (this.disabled) return; + if (this.currentPage != page) { + this.currentPage = page; + this.$emit("update:current", page); + this.$emit("on-change", page); + } + }, + prev() { + if (this.disabled) return; + const current = this.currentPage; + if (current <= 1) { + return false; + } + this.changePage(current - 1); + }, + next() { + if (this.disabled) return; + const current = this.currentPage; + if (current >= this.allPages) { + return false; + } + this.changePage(current + 1); + }, + fastPrev() { + if (this.disabled) return; + const page = this.currentPage - 5; + if (page > 0) { + this.changePage(page); + } else { + this.changePage(1); + } + }, + fastNext() { + if (this.disabled) return; + const page = this.currentPage + 5; + if (page > this.allPages) { + this.changePage(this.allPages); + } else { + this.changePage(page); + } + }, + onSize(pageSize) { + if (this.disabled) return; + this.currentPageSize = pageSize; + this.$emit("on-page-size-change", pageSize); + this.changePage(1); + }, + onPage(page) { + if (this.disabled) return; + this.changePage(page); + }, + keyDown(e) { + const key = e.keyCode; + const condition = + (key >= 48 && key <= 57) || + (key >= 96 && key <= 105) || + key === 8 || + key === 37 || + key === 39; - if (!condition) { - e.preventDefault(); - } - }, - keyUp(e) { - const key = e.keyCode; - const val = parseInt(e.target.value); + if (!condition) { + e.preventDefault(); + } + }, + keyUp(e) { + const key = e.keyCode; + const val = parseInt(e.target.value); - if (key === 38) { - this.prev(); - } else if (key === 40) { - this.next(); - } else if (key === 13) { - let page = 1; + if (key === 38) { + this.prev(); + } else if (key === 40) { + this.next(); + } else if (key === 13) { + let page = 1; - if (val > this.allPages) { - page = this.allPages; - } else if (val <= 0 || !val) { - page = 1; - } else { - page = val; - } + if (val > this.allPages) { + page = this.allPages; + } else if (val <= 0 || !val) { + page = 1; + } else { + page = val; + } - e.target.value = page; - this.changePage(page); - } - }, - }, + e.target.value = page; + this.changePage(page); + } + } + } }; diff --git a/src/components/table/cell.vue b/src/components/table/cell.vue index 51ba86c..3fdaf0d 100644 --- a/src/components/table/cell.vue +++ b/src/components/table/cell.vue @@ -20,6 +20,7 @@