Commit 80abca23eac81673294da0fbb02cee6506077730
1 parent
061629e7
feat(pagination): 新增分页总数
Showing
7 changed files
with
55 additions
and
8 deletions
Show diff stats
build/Pagination/Pagination.html
1 | <ul ng-class="'ant-pagination'+(size==='small'?' mini':'')"> | 1 | <ul ng-class="'ant-pagination'+(size==='small'?' mini':'')"> |
2 | + <li class="ant-pagination-total-text" ng-if="showTotal()">{{handleShowTotal()}}</li> | ||
2 | <li ng-class="'ant-pagination-prev'+(state.current===1?' ant-pagination-disabled':'')" ng-click="handlePrev()"> | 3 | <li ng-class="'ant-pagination-prev'+(state.current===1?' ant-pagination-disabled':'')" ng-click="handlePrev()"> |
3 | <button type="button" class="ant-pagination-item-link"> | 4 | <button type="button" class="ant-pagination-item-link"> |
4 | <es-icon type="LeftOutlined"></es-icon> | 5 | <es-icon type="LeftOutlined"></es-icon> |
build/Pagination/Pagination.js
@@ -17,6 +17,7 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { | @@ -17,6 +17,7 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { | ||
17 | showQuickJumper: "@", | 17 | showQuickJumper: "@", |
18 | showSizeChanger: "@", | 18 | showSizeChanger: "@", |
19 | size: "@", | 19 | size: "@", |
20 | + showTotal: "&", | ||
20 | }, | 21 | }, |
21 | template: template, | 22 | template: template, |
22 | controller: function ($scope, $element, $attrs) { | 23 | controller: function ($scope, $element, $attrs) { |
@@ -31,6 +32,25 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { | @@ -31,6 +32,25 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { | ||
31 | pageNum: null, | 32 | pageNum: null, |
32 | pageNumList: null, | 33 | pageNumList: null, |
33 | }; | 34 | }; |
35 | + $scope.watch = { | ||
36 | + total: function (newVal, oldVal) { | ||
37 | + if (newVal && oldVal) { | ||
38 | + $scope.state.total = Number(newVal); | ||
39 | + $scope.state.pageNum = $scope.getPageNum(); | ||
40 | + $scope.state.pageNumList = $scope.getPageNumList(); | ||
41 | + } | ||
42 | + }, | ||
43 | + }; | ||
44 | + | ||
45 | + for (const key in $scope.watch) { | ||
46 | + $scope.$watch(key, $scope.watch[key], true); | ||
47 | + } | ||
48 | + | ||
49 | + $scope.handleShowTotal = function () { | ||
50 | + return $scope.showTotal({ | ||
51 | + total: $scope.state.total, | ||
52 | + }); | ||
53 | + }; | ||
34 | 54 | ||
35 | $scope.getItemLinkClassName = function (value) { | 55 | $scope.getItemLinkClassName = function (value) { |
36 | if (typeof value === "number") { | 56 | if (typeof value === "number") { |
dist/ng-antd.js
@@ -137,7 +137,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac | @@ -137,7 +137,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac | ||
137 | /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | 137 | /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
138 | 138 | ||
139 | "use strict"; | 139 | "use strict"; |
140 | -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Form_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Form.html */ \"./build/Form/Form.html\");\n/* harmony import */ var antd_lib_form_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/form/style/index.css */ \"./node_modules/antd/lib/form/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esForm\", function (esNgAntd) {\n return {\n controllerAs: \"esForm\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n name: \"@\",\n labelCol: \"=\",\n wrapperCol: \"=\",\n onFinish: \"&\",\n form: \"=\",\n },\n template: _Form_html__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n controller: function ($scope, $element) {\n this.getContext = function () {\n return $scope;\n };\n\n $scope.state = {\n formItems: [],\n };\n\n $scope.resetFields = function () {\n $scope.state.formItems.forEach(function (item) {\n if (typeof item.setValue === \"function\") {\n item.setValue(item.defaultValue || null);\n } else {\n item.value = null;\n }\n });\n };\n\n $scope.handleSubmit = function () {\n let values = {};\n $scope.state.formItems.forEach(function (item) {\n let name = item.esFormItem && item.esFormItem.name;\n let value = item.value || item.state.value || null;\n values[name] = value;\n }); // for (let i = 0; i < inputs.length; i++) {\n // const element = inputs[i];\n // const value = element.value === \"\" ? null : element.value;\n // if (element.id) {\n // if (element.id.split(\"_\").length > 1) {\n // values[element.id.split(\"_\")[1]] = value;\n // } else {\n // values[element.id] = value;\n // }\n // }\n // }\n\n $scope.onFinish({\n values: values,\n });\n };\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-form\", antd_lib_form_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n $scope.form = $scope;\n\n if ($scope.name) {\n let inputs = $element[0].querySelectorAll(\"input\");\n\n for (let i = 0; i < inputs.length; i++) {\n const element = inputs[i];\n element.id = $scope.name + \"_\" + element.id;\n }\n }\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Form/Form.js?"); | 140 | +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Form_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Form.html */ \"./build/Form/Form.html\");\n/* harmony import */ var antd_lib_form_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/form/style/index.css */ \"./node_modules/antd/lib/form/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esForm\", function (esNgAntd) {\n return {\n controllerAs: \"esForm\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n name: \"@\",\n labelCol: \"=\",\n wrapperCol: \"=\",\n onFinish: \"&\",\n form: \"=\",\n },\n template: _Form_html__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n controller: function ($scope, $element, $attrs) {\n this.getContext = function () {\n return $scope;\n };\n\n $scope.state = {\n formItems: [],\n };\n\n $scope.resetFields = function () {\n $scope.state.formItems.forEach(function (item) {\n if (typeof item.setValue === \"function\") {\n item.setValue(item.defaultValue || null);\n } else {\n item.value = null;\n }\n });\n };\n\n $scope.submit = function () {\n $scope.handleSubmit();\n };\n\n $scope.handleSubmit = function () {\n let values = {};\n $scope.state.formItems.forEach(function (item) {\n let name = item.esFormItem && item.esFormItem.name;\n let value = item.value || item.state.value || null;\n values[name] = value;\n });\n $scope.onFinish({\n values: values,\n });\n };\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-form\", antd_lib_form_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n $scope.form = $scope;\n\n if ($scope.name) {\n let inputs = $element[0].querySelectorAll(\"input\");\n\n for (let i = 0; i < inputs.length; i++) {\n const element = inputs[i];\n element.id = $scope.name + \"_\" + element.id;\n }\n }\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Form/Form.js?"); |
141 | 141 | ||
142 | /***/ }), | 142 | /***/ }), |
143 | 143 | ||
@@ -280,7 +280,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Mod | @@ -280,7 +280,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Mod | ||
280 | /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | 280 | /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
281 | 281 | ||
282 | "use strict"; | 282 | "use strict"; |
283 | -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Pagination_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pagination.html */ \"./build/Pagination/Pagination.html\");\n/* harmony import */ var antd_lib_pagination_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/pagination/style/index.css */ \"./node_modules/antd/lib/pagination/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esPagination\", function (esNgAntd) {\n return {\n controllerAs: \"esPagination\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n defaultCurrent: \"@\",\n current: \"@\",\n total: \"@\",\n defaultPageSize: \"@\",\n pageSize: \"@\",\n onChange: \"&\",\n onShowSizeChange: \"&\",\n showQuickJumper: \"@\",\n showSizeChanger: \"@\",\n size: \"@\",\n },\n template: _Pagination_html__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n controller: function ($scope, $element, $attrs) {\n this.getContext = function () {\n return $scope;\n };\n\n $scope.state = {\n total: null,\n current: null,\n pageSize: null,\n pageNum: null,\n pageNumList: null,\n };\n\n $scope.getItemLinkClassName = function (value) {\n if (typeof value === \"number\") {\n return (\n \"ant-pagination-item\" +\n ($scope.state.current === value\n ? \" ant-pagination-item-active\"\n : \"\")\n );\n } else {\n return \"ant-pagination-jump-next ant-pagination-jump-next-custom-icon\";\n }\n };\n\n $scope.getPageNumList = function () {\n let pageNumList = [$scope.state.current];\n let pageNum = $scope.getPageNum();\n\n if (pageNum <= 7 || $scope.state.current - 1 < 4) {\n for (let i = $scope.state.current - 1; i > 0; i--) {\n pageNumList.unshift(i);\n }\n } else {\n let len =\n $scope.state.current - 1 > 2\n ? 2\n : $scope.state.current - 1;\n\n for (let i = 1; i <= len; i++) {\n pageNumList.unshift($scope.state.current - i);\n }\n\n if ($scope.state.current - 2 > 2) {\n pageNumList.unshift(\"prev\");\n pageNumList.unshift(1);\n }\n }\n\n if (pageNum <= 7 || pageNum - $scope.state.current < 4) {\n for (let i = $scope.state.current + 1; i <= pageNum; i++) {\n pageNumList.push(i);\n }\n } else {\n let limit =\n 3 - $scope.state.current > 0\n ? 2 + (3 - $scope.state.current)\n : 2;\n let len =\n pageNum - $scope.state.current > limit\n ? limit\n : pageNum - $scope.state.current;\n\n for (let i = 1; i <= len; i++) {\n pageNumList.push($scope.state.current + i);\n }\n\n if (pageNum - $scope.state.current > 2) {\n pageNumList.push(\"next\");\n pageNumList.push(pageNum);\n }\n }\n\n return pageNumList;\n };\n\n $scope.getPageNum = function () {\n return (\n Math.ceil(\n $scope.state.total /\n ($scope.pageSize || $scope.defaultPageSize || 10)\n ) || 1\n );\n };\n\n $scope.getPopupContainer = function () {\n return $element[0].querySelector(\".ant-pagination-options\");\n };\n\n $scope.handleNext = function () {\n if ($scope.state.current === $scope.state.pageNum) {\n return false;\n }\n\n $scope.handleClick(++$scope.state.current);\n };\n\n $scope.handlePrev = function () {\n if ($scope.state.current === 1) {\n return false;\n }\n\n $scope.handleClick(--$scope.state.current);\n };\n\n $scope.handleClick = function (value) {\n if (value === \"next\") {\n value = $scope.state.current + 5;\n }\n\n if (value === \"prev\") {\n value = $scope.state.current - 5;\n }\n\n $scope.setCurrent($scope.getCurrent(value)); // 更新回调\n\n $scope.onChange({\n page: $scope.state.current,\n pageSize: $scope.state.pageSize,\n });\n };\n\n $scope.handleChange = function () {\n let current = $scope.state.current;\n\n if ($scope.state.current > $scope.state.pageNum) {\n current = $scope.state.pageNum;\n } else if ($scope.state.current < 1) {\n current = 1;\n }\n\n $scope.onChange({\n page: current,\n pageSize: $scope.state.pageSize,\n });\n };\n\n $scope.handleSelectChange = function (value) {\n $scope.state.current = 1;\n $scope.state.pageSize = parseInt(value);\n $scope.handleChange();\n };\n\n $scope.getCurrent = function (number) {\n if (number > $scope.state.pageNum) {\n return $scope.state.pageNum;\n }\n\n if (number < 1) {\n return 1;\n }\n\n return parseInt(number);\n };\n\n $scope.setCurrent = function (value) {\n if (!value) {\n return;\n }\n\n $scope.state.current = $scope.getCurrent(value);\n $scope.state.pageNumList = $scope.getPageNumList();\n $scope.handleChange();\n };\n\n $scope.handleBlur = function (event) {\n $scope.setCurrent(event.target.value);\n event.target.value = null;\n };\n\n $scope.onKeyPress = function (event) {\n if (event.keyCode === 13 || event.keyCode === 32) {\n $scope.setCurrent(event.target.value);\n event.target.value = null;\n }\n };\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-pagination\", antd_lib_pagination_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n $scope.state.total = Number($scope.total || 0);\n $scope.state.current = Number(\n $scope.current || $scope.defaultCurrent || 1\n );\n $scope.state.pageSize =\n $scope.pageSize || $scope.defaultPageSize || 10;\n $scope.state.pageNum = $scope.getPageNum();\n $scope.state.pageNumList = $scope.getPageNumList();\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Pagination/Pagination.js?"); | 283 | +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Pagination_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pagination.html */ \"./build/Pagination/Pagination.html\");\n/* harmony import */ var antd_lib_pagination_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/pagination/style/index.css */ \"./node_modules/antd/lib/pagination/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esPagination\", function (esNgAntd) {\n return {\n controllerAs: \"esPagination\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n defaultCurrent: \"@\",\n current: \"@\",\n total: \"@\",\n defaultPageSize: \"@\",\n pageSize: \"@\",\n onChange: \"&\",\n onShowSizeChange: \"&\",\n showQuickJumper: \"@\",\n showSizeChanger: \"@\",\n size: \"@\",\n showTotal: \"&\",\n },\n template: _Pagination_html__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n controller: function ($scope, $element, $attrs) {\n this.getContext = function () {\n return $scope;\n };\n\n $scope.state = {\n total: null,\n current: null,\n pageSize: null,\n pageNum: null,\n pageNumList: null,\n };\n $scope.watch = {\n total: function (newVal, oldVal) {\n if (newVal && oldVal) {\n $scope.state.total = Number(newVal);\n $scope.state.pageNum = $scope.getPageNum();\n $scope.state.pageNumList = $scope.getPageNumList();\n }\n },\n };\n\n for (const key in $scope.watch) {\n $scope.$watch(key, $scope.watch[key], true);\n }\n\n $scope.handleShowTotal = function () {\n return $scope.showTotal({\n total: $scope.state.total,\n });\n };\n\n $scope.getItemLinkClassName = function (value) {\n if (typeof value === \"number\") {\n return (\n \"ant-pagination-item\" +\n ($scope.state.current === value\n ? \" ant-pagination-item-active\"\n : \"\")\n );\n } else {\n return \"ant-pagination-jump-next ant-pagination-jump-next-custom-icon\";\n }\n };\n\n $scope.getPageNumList = function () {\n let pageNumList = [$scope.state.current];\n let pageNum = $scope.getPageNum();\n\n if (pageNum <= 7 || $scope.state.current - 1 < 4) {\n for (let i = $scope.state.current - 1; i > 0; i--) {\n pageNumList.unshift(i);\n }\n } else {\n let len =\n $scope.state.current - 1 > 2\n ? 2\n : $scope.state.current - 1;\n\n for (let i = 1; i <= len; i++) {\n pageNumList.unshift($scope.state.current - i);\n }\n\n if ($scope.state.current - 2 > 2) {\n pageNumList.unshift(\"prev\");\n pageNumList.unshift(1);\n }\n }\n\n if (pageNum <= 7 || pageNum - $scope.state.current < 4) {\n for (let i = $scope.state.current + 1; i <= pageNum; i++) {\n pageNumList.push(i);\n }\n } else {\n let limit =\n 3 - $scope.state.current > 0\n ? 2 + (3 - $scope.state.current)\n : 2;\n let len =\n pageNum - $scope.state.current > limit\n ? limit\n : pageNum - $scope.state.current;\n\n for (let i = 1; i <= len; i++) {\n pageNumList.push($scope.state.current + i);\n }\n\n if (pageNum - $scope.state.current > 2) {\n pageNumList.push(\"next\");\n pageNumList.push(pageNum);\n }\n }\n\n return pageNumList;\n };\n\n $scope.getPageNum = function () {\n return (\n Math.ceil(\n $scope.state.total /\n ($scope.pageSize || $scope.defaultPageSize || 10)\n ) || 1\n );\n };\n\n $scope.getPopupContainer = function () {\n return $element[0].querySelector(\".ant-pagination-options\");\n };\n\n $scope.handleNext = function () {\n if ($scope.state.current === $scope.state.pageNum) {\n return false;\n }\n\n $scope.handleClick(++$scope.state.current);\n };\n\n $scope.handlePrev = function () {\n if ($scope.state.current === 1) {\n return false;\n }\n\n $scope.handleClick(--$scope.state.current);\n };\n\n $scope.handleClick = function (value) {\n if (value === \"next\") {\n value = $scope.state.current + 5;\n }\n\n if (value === \"prev\") {\n value = $scope.state.current - 5;\n }\n\n $scope.setCurrent($scope.getCurrent(value)); // 更新回调\n\n $scope.onChange({\n page: $scope.state.current,\n pageSize: $scope.state.pageSize,\n });\n };\n\n $scope.handleChange = function () {\n let current = $scope.state.current;\n\n if ($scope.state.current > $scope.state.pageNum) {\n current = $scope.state.pageNum;\n } else if ($scope.state.current < 1) {\n current = 1;\n }\n\n $scope.onChange({\n page: current,\n pageSize: $scope.state.pageSize,\n });\n };\n\n $scope.handleSelectChange = function (value) {\n $scope.state.current = 1;\n $scope.state.pageSize = parseInt(value);\n $scope.handleChange();\n };\n\n $scope.getCurrent = function (number) {\n if (number > $scope.state.pageNum) {\n return $scope.state.pageNum;\n }\n\n if (number < 1) {\n return 1;\n }\n\n return parseInt(number);\n };\n\n $scope.setCurrent = function (value) {\n if (!value) {\n return;\n }\n\n $scope.state.current = $scope.getCurrent(value);\n $scope.state.pageNumList = $scope.getPageNumList();\n $scope.handleChange();\n };\n\n $scope.handleBlur = function (event) {\n $scope.setCurrent(event.target.value);\n event.target.value = null;\n };\n\n $scope.onKeyPress = function (event) {\n if (event.keyCode === 13 || event.keyCode === 32) {\n $scope.setCurrent(event.target.value);\n event.target.value = null;\n }\n };\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-pagination\", antd_lib_pagination_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n $scope.state.total = Number($scope.total || 0);\n $scope.state.current = Number(\n $scope.current || $scope.defaultCurrent || 1\n );\n $scope.state.pageSize =\n $scope.pageSize || $scope.defaultPageSize || 10;\n $scope.state.pageNum = $scope.getPageNum();\n $scope.state.pageNumList = $scope.getPageNumList();\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Pagination/Pagination.js?"); |
284 | 284 | ||
285 | /***/ }), | 285 | /***/ }), |
286 | 286 | ||
@@ -9617,7 +9617,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac | @@ -9617,7 +9617,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac | ||
9617 | /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | 9617 | /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { |
9618 | 9618 | ||
9619 | "use strict"; | 9619 | "use strict"; |
9620 | -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n// Module\nvar code = \"<ul ng-class=\\\"'ant-pagination'+(size==='small'?' mini':'')\\\">\\n <li ng-class=\\"'ant-pagination-prev'+(state.current===1?' ant-pagination-disabled':'')\\" ng-click=\\"handlePrev()\\">\n <button type=\\"button\\" class=\\"ant-pagination-item-link\\">\n <es-icon type=\\"LeftOutlined\\"></es-icon>\n </button>\n </li>\n <li ng-repeat=\\"(key, value) in state.pageNumList track by key\\" ng-class=\\"''+getItemLinkClassName(value)\\" ng-click=\\"handleClick(value)\\">\n <a ng-if=\\"value!=='prev'&&value!=='next'\\">{{value}}</a>\n <a ng-if=\\"value==='prev'||value==='next'\\" class=\\"ant-pagination-item-link\\">\n <div class=\\"ant-pagination-item-container\\">\n <es-icon ng-if=\\"value==='prev'\\" type=\\"DoubleLeftOutlined\\" class=\\"ant-pagination-item-link-icon\\"></es-icon>\n <es-icon ng-if=\\"value==='next'\\" type=\\"DoubleRightOutlined\\" class=\\"ant-pagination-item-link-icon\\"></es-icon>\n <span class=\\"ant-pagination-item-ellipsis\\">•••</span>\n </div>\n </a>\n </li>\n <li ng-class=\\"'ant-pagination-next'+(state.current===state.pageNum?' ant-pagination-disabled':'')\\" ng-click=\\"handleNext()\\">\n <button type=\\"button\\" class=\\"ant-pagination-item-link\\">\n <es-icon type=\\"RightOutlined\\"></es-icon>\n </button>\n </li>\n <li class=\\"ant-pagination-options\\">\n <es-select ng-if=\\"showSizeChanger==='true'\\" class=\\"ant-pagination-options-size-changer\\" size=\\"{{size}}\\" value=\\"10\\" get-popup-container=\\"getPopupContainer\\" on-change=\\"handleSelectChange(value)\\">\n <es-select-option value=\\"10\\">10 条/页</es-select-option>\n <es-select-option value=\\"20\\">20 条/页</es-select-option>\n <es-select-option value=\\"30\\">30 条/页</es-select-option>\n <es-select-option value=\\"40\\">40 条/页</es-select-option>\n </es-select>\n <div ng-if=\\"showQuickJumper==='true'\\" class=\\"ant-pagination-options-quick-jumper\\">\n 跳至<input type=\\"text\\" ng-blur=\\"handleBlur($event)\\" ng-keypress=\\"onKeyPress($event)\\" />页\n </div>\n </li>\n</ul>\";\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (code);\n\n//# sourceURL=webpack://ng-antd/./build/Pagination/Pagination.html?"); | 9620 | +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n// Module\nvar code = \"<ul ng-class=\\\"'ant-pagination'+(size==='small'?' mini':'')\\\">\\n <li class=\\\"ant-pagination-total-text\\\" ng-if=\\\"showTotal()\\\">{{handleShowTotal()}}</li>\\n <li ng-class=\\"'ant-pagination-prev'+(state.current===1?' ant-pagination-disabled':'')\\" ng-click=\\"handlePrev()\\">\n <button type=\\"button\\" class=\\"ant-pagination-item-link\\">\n <es-icon type=\\"LeftOutlined\\"></es-icon>\n </button>\n </li>\n <li ng-repeat=\\"(key, value) in state.pageNumList track by key\\" ng-class=\\"''+getItemLinkClassName(value)\\" ng-click=\\"handleClick(value)\\">\n <a ng-if=\\"value!=='prev'&&value!=='next'\\">{{value}}</a>\n <a ng-if=\\"value==='prev'||value==='next'\\" class=\\"ant-pagination-item-link\\">\n <div class=\\"ant-pagination-item-container\\">\n <es-icon ng-if=\\"value==='prev'\\" type=\\"DoubleLeftOutlined\\" class=\\"ant-pagination-item-link-icon\\"></es-icon>\n <es-icon ng-if=\\"value==='next'\\" type=\\"DoubleRightOutlined\\" class=\\"ant-pagination-item-link-icon\\"></es-icon>\n <span class=\\"ant-pagination-item-ellipsis\\">•••</span>\n </div>\n </a>\n </li>\n <li ng-class=\\"'ant-pagination-next'+(state.current===state.pageNum?' ant-pagination-disabled':'')\\" ng-click=\\"handleNext()\\">\n <button type=\\"button\\" class=\\"ant-pagination-item-link\\">\n <es-icon type=\\"RightOutlined\\"></es-icon>\n </button>\n </li>\n <li class=\\"ant-pagination-options\\">\n <es-select ng-if=\\"showSizeChanger==='true'\\" class=\\"ant-pagination-options-size-changer\\" size=\\"{{size}}\\" value=\\"10\\" get-popup-container=\\"getPopupContainer\\" on-change=\\"handleSelectChange(value)\\">\n <es-select-option value=\\"10\\">10 条/页</es-select-option>\n <es-select-option value=\\"20\\">20 条/页</es-select-option>\n <es-select-option value=\\"30\\">30 条/页</es-select-option>\n <es-select-option value=\\"40\\">40 条/页</es-select-option>\n </es-select>\n <div ng-if=\\"showQuickJumper==='true'\\" class=\\"ant-pagination-options-quick-jumper\\">\n 跳至<input type=\\"text\\" ng-blur=\\"handleBlur($event)\\" ng-keypress=\\"onKeyPress($event)\\" />页\n </div>\n </li>\n</ul>\";\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (code);\n\n//# sourceURL=webpack://ng-antd/./build/Pagination/Pagination.html?"); |
9621 | 9621 | ||
9622 | /***/ }), | 9622 | /***/ }), |
9623 | 9623 |
example/pagination.html
@@ -9,7 +9,8 @@ | @@ -9,7 +9,8 @@ | ||
9 | <body> | 9 | <body> |
10 | <div ng-app="esNgAntd" ng-controller="mainCtrl"> | 10 | <div ng-app="esNgAntd" ng-controller="mainCtrl"> |
11 | <div class="container" style="padding: 50px"> | 11 | <div class="container" style="padding: 50px"> |
12 | - <es-pagination default-current="1" total="1" on-change="handleChange(page, pageSize)" show-quick-jumper="true" show-size-changer="true"></es-pagination> | 12 | + <es-pagination default-current="1" total="{{total}}" on-change="handleChange(page, pageSize)" |
13 | + show-quick-jumper="true" show-size-changer="true" show-total="showTotal(total)"></es-pagination> | ||
13 | <!-- <es-pagination size="small" default-current="1" total="50" on-change="handleChange(page, pageSize)" show-quick-jumper="true" show-size-changer="true"></es-pagination> --> | 14 | <!-- <es-pagination size="small" default-current="1" total="50" on-change="handleChange(page, pageSize)" show-quick-jumper="true" show-size-changer="true"></es-pagination> --> |
14 | </div> | 15 | </div> |
15 | </div> | 16 | </div> |
@@ -18,10 +19,17 @@ | @@ -18,10 +19,17 @@ | ||
18 | <script> | 19 | <script> |
19 | angular | 20 | angular |
20 | .module("esNgAntd") | 21 | .module("esNgAntd") |
21 | - .controller("mainCtrl", function ($scope) { | 22 | + .controller("mainCtrl", function ($scope, $timeout) { |
23 | + $scope.total = 1; | ||
22 | $scope.handleChange = function (page, pageSize) { | 24 | $scope.handleChange = function (page, pageSize) { |
23 | console.log(page, pageSize) | 25 | console.log(page, pageSize) |
24 | } | 26 | } |
27 | + $scope.showTotal = function (total) { | ||
28 | + return `Total ${total} items`; | ||
29 | + } | ||
30 | + $timeout(()=>{ | ||
31 | + $scope.total = 80 | ||
32 | + }, 2000) | ||
25 | }); | 33 | }); |
26 | </script> | 34 | </script> |
27 | </body> | 35 | </body> |
src/Pagination/Pagination.html
1 | -<ul className={"ant-pagination"+(size==="small"?" mini": "")}> | 1 | +<ul className={"ant-pagination" + (size === "small" ? " mini" : "")}> |
2 | + <li className="ant-pagination-total-text" ng-if="showTotal()">{handleShowTotal()}</li> | ||
2 | <li className={"ant-pagination-prev" + (state.current === 1 ? " ant-pagination-disabled" : "")} onClick={this.handlePrev}> | 3 | <li className={"ant-pagination-prev" + (state.current === 1 ? " ant-pagination-disabled" : "")} onClick={this.handlePrev}> |
3 | <button type="button" class="ant-pagination-item-link"> | 4 | <button type="button" class="ant-pagination-item-link"> |
4 | <es-icon type="LeftOutlined"></es-icon> | 5 | <es-icon type="LeftOutlined"></es-icon> |
src/Pagination/Pagination.js
@@ -17,6 +17,7 @@ class Pagination { | @@ -17,6 +17,7 @@ class Pagination { | ||
17 | showQuickJumper: Boolean, | 17 | showQuickJumper: Boolean, |
18 | showSizeChanger: Boolean, | 18 | showSizeChanger: Boolean, |
19 | size: String, | 19 | size: String, |
20 | + showTotal: Function, | ||
20 | }; | 21 | }; |
21 | 22 | ||
22 | state = { | 23 | state = { |
@@ -27,6 +28,16 @@ class Pagination { | @@ -27,6 +28,16 @@ class Pagination { | ||
27 | pageNumList: null, | 28 | pageNumList: null, |
28 | }; | 29 | }; |
29 | 30 | ||
31 | + watch = { | ||
32 | + total: function (newVal, oldVal) { | ||
33 | + if (newVal && oldVal) { | ||
34 | + this.state.total = Number(newVal); | ||
35 | + this.state.pageNum = this.getPageNum(); | ||
36 | + this.state.pageNumList = this.getPageNumList(); | ||
37 | + } | ||
38 | + } | ||
39 | + } | ||
40 | + | ||
30 | constructor() { | 41 | constructor() { |
31 | esNgAntd.createStyle("ant-pagination", style); | 42 | esNgAntd.createStyle("ant-pagination", style); |
32 | this.state.total = Number(this.props.total || 0); | 43 | this.state.total = Number(this.props.total || 0); |
@@ -39,6 +50,12 @@ class Pagination { | @@ -39,6 +50,12 @@ class Pagination { | ||
39 | this.state.pageNumList = this.getPageNumList(); | 50 | this.state.pageNumList = this.getPageNumList(); |
40 | } | 51 | } |
41 | 52 | ||
53 | + handleShowTotal() { | ||
54 | + return this.props.showTotal({ | ||
55 | + total: this.state.total | ||
56 | + }) | ||
57 | + } | ||
58 | + | ||
42 | getItemLinkClassName(value) { | 59 | getItemLinkClassName(value) { |
43 | if (typeof value === "number") { | 60 | if (typeof value === "number") { |
44 | return ( | 61 | return ( |
webpack.config.js
@@ -8,11 +8,11 @@ module.exports = { | @@ -8,11 +8,11 @@ module.exports = { | ||
8 | // bpms | 8 | // bpms |
9 | // path: "/Users/shann/Project/essa/bpms/bpms-webapp/src/main/webapp/lib/ng-antd", | 9 | // path: "/Users/shann/Project/essa/bpms/bpms-webapp/src/main/webapp/lib/ng-antd", |
10 | // boss | 10 | // boss |
11 | - path: "/Users/shann/Project/essa/boss/trunk/vendor-lib/ng-antd", | 11 | + // path: "/Users/shann/Project/essa/boss/trunk/vendor-lib/ng-antd", |
12 | // mvo | 12 | // mvo |
13 | // path: "/Users/shann/Project/essa/mvo/mvo-webapp/public/browser-vendor/ng-antd", | 13 | // path: "/Users/shann/Project/essa/mvo/mvo-webapp/public/browser-vendor/ng-antd", |
14 | // local | 14 | // local |
15 | - // path: path.resolve(__dirname, "dist"), | 15 | + path: path.resolve(__dirname, "dist"), |
16 | filename: "ng-antd.js", | 16 | filename: "ng-antd.js", |
17 | }, | 17 | }, |
18 | module: { | 18 | module: { |