diff --git a/build/Button/Button.html b/build/Button/Button.html index d67e1b0..c94b759 100644 --- a/build/Button/Button.html +++ b/build/Button/Button.html @@ -1,4 +1,4 @@ - + diff --git a/build/Button/Button.js b/build/Button/Button.js index 0c1d3f3..d818c53 100644 --- a/build/Button/Button.js +++ b/build/Button/Button.js @@ -9,13 +9,12 @@ angular.module("esNgAntd").directive("esButton", function (esNgAntd) { scope: { type: "@", size: "@", - disabled: "@", ghost: "@", loading: "@", htmlType: "@", }, template: template, - controller: function ($scope, $element) { + controller: function ($scope, $element, $attrs) { this.getContext = function () { return $scope; }; @@ -47,8 +46,6 @@ angular.module("esNgAntd").directive("esButton", function (esNgAntd) { link: function ($scope, $element, $attrs, $controllers, $transclude) { esNgAntd.createStyle("ant-btn", style); let className = ["ant-btn"]; - $scope.state.disabled = - $scope.disabled === "true" || $scope.disabled === "disabled"; if ($scope.type) { className.push("ant-btn-" + $scope.type); diff --git a/build/Common/Common.js b/build/Common/Common.js index 7051d36..77ea110 100644 --- a/build/Common/Common.js +++ b/build/Common/Common.js @@ -35,9 +35,10 @@ angular.module("esNgAntd").service("esNgAntd", [ rule.selectorText.indexOf(name) !== -1 ) { rule.selectorText = rule.selectorText.replace( - /\.ant-/g, + /\.ant\-/g, ".disabled-ant-" ); + console.log(rule.selectorText); } } }; diff --git a/build/Form/Form.js b/build/Form/Form.js index 9154453..40420aa 100644 --- a/build/Form/Form.js +++ b/build/Form/Form.js @@ -14,7 +14,7 @@ angular.module("esNgAntd").directive("esForm", function (esNgAntd) { form: "=", }, template: template, - controller: function ($scope, $element) { + controller: function ($scope, $element, $attrs) { this.getContext = function () { return $scope; }; @@ -33,24 +33,17 @@ angular.module("esNgAntd").directive("esForm", function (esNgAntd) { }); }; + $scope.submit = function () { + $scope.handleSubmit(); + }; + $scope.handleSubmit = function () { let values = {}; $scope.state.formItems.forEach(function (item) { let name = item.esFormItem && item.esFormItem.name; let value = item.value || item.state.value || null; values[name] = value; - }); // for (let i = 0; i < inputs.length; i++) { - // const element = inputs[i]; - // const value = element.value === "" ? null : element.value; - // if (element.id) { - // if (element.id.split("_").length > 1) { - // values[element.id.split("_")[1]] = value; - // } else { - // values[element.id] = value; - // } - // } - // } - + }); $scope.onFinish({ values: values, }); diff --git a/build/Pagination/Pagination.html b/build/Pagination/Pagination.html index 812b418..439d783 100644 --- a/build/Pagination/Pagination.html +++ b/build/Pagination/Pagination.html @@ -4,8 +4,15 @@ - - {{value}} + + {{value}} + + + + + ••• + + diff --git a/build/Pagination/Pagination.js b/build/Pagination/Pagination.js index 3fb7957..b166cc8 100644 --- a/build/Pagination/Pagination.js +++ b/build/Pagination/Pagination.js @@ -32,6 +32,70 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { pageNumList: null, }; + $scope.getItemLinkClassName = function (value) { + if (typeof value === "number") { + return ( + "ant-pagination-item" + + ($scope.state.current === value + ? " ant-pagination-item-active" + : "") + ); + } else { + return "ant-pagination-jump-next ant-pagination-jump-next-custom-icon"; + } + }; + + $scope.getPageNumList = function () { + let pageNumList = [$scope.state.current]; + let pageNum = $scope.getPageNum(); + + if (pageNum <= 7 || $scope.state.current - 1 < 4) { + for (let i = $scope.state.current - 1; i > 0; i--) { + pageNumList.unshift(i); + } + } else { + let len = + $scope.state.current - 1 > 2 + ? 2 + : $scope.state.current - 1; + + for (let i = 1; i <= len; i++) { + pageNumList.unshift($scope.state.current - i); + } + + if ($scope.state.current - 2 > 2) { + pageNumList.unshift("prev"); + pageNumList.unshift(1); + } + } + + if (pageNum <= 7 || pageNum - $scope.state.current < 4) { + for (let i = $scope.state.current + 1; i <= pageNum; i++) { + pageNumList.push(i); + } + } else { + let limit = + 3 - $scope.state.current > 0 + ? 2 + (3 - $scope.state.current) + : 2; + let len = + pageNum - $scope.state.current > limit + ? limit + : pageNum - $scope.state.current; + + for (let i = 1; i <= len; i++) { + pageNumList.push($scope.state.current + i); + } + + if (pageNum - $scope.state.current > 2) { + pageNumList.push("next"); + pageNumList.push(pageNum); + } + } + + return pageNumList; + }; + $scope.getPageNum = function () { return ( Math.ceil( @@ -41,6 +105,10 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { ); }; + $scope.getPopupContainer = function () { + return $element[0].querySelector(".ant-pagination-options"); + }; + $scope.handleNext = function () { if ($scope.state.current === $scope.state.pageNum) { return false; @@ -49,10 +117,6 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { $scope.handleClick(++$scope.state.current); }; - $scope.getPopupContainer = function () { - return $element[0].querySelector(".ant-pagination-options"); - }; - $scope.handlePrev = function () { if ($scope.state.current === 1) { return false; @@ -62,7 +126,15 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { }; $scope.handleClick = function (value) { - $scope.state.current = value; // 更新回调 + if (value === "next") { + value = $scope.state.current + 5; + } + + if (value === "prev") { + value = $scope.state.current - 5; + } + + $scope.setCurrent($scope.getCurrent(value)); // 更新回调 $scope.onChange({ page: $scope.state.current, @@ -109,6 +181,7 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { } $scope.state.current = $scope.getCurrent(value); + $scope.state.pageNumList = $scope.getPageNumList(); $scope.handleChange(); }; @@ -133,9 +206,7 @@ angular.module("esNgAntd").directive("esPagination", function (esNgAntd) { $scope.state.pageSize = $scope.pageSize || $scope.defaultPageSize || 10; $scope.state.pageNum = $scope.getPageNum(); - $scope.state.pageNumList = Array($scope.state.pageNum) - .fill(0) - .map((v, i) => i + 1); + $scope.state.pageNumList = $scope.getPageNumList(); }, }; }); diff --git a/build/Select/Select.js b/build/Select/Select.js index 1228b28..4b5d1c0 100644 --- a/build/Select/Select.js +++ b/build/Select/Select.js @@ -67,6 +67,8 @@ angular let func = $scope.getPopupContainer(); if (typeof func === "function" && func() !== undefined) { + let containerElement = func(); + containerElement.style.position = "relative"; return { top: $element[0].offsetTop, left: $element[0].offsetLeft, diff --git a/build/Table/Table.js b/build/Table/Table.js index 99feb65..0d1d7ce 100644 --- a/build/Table/Table.js +++ b/build/Table/Table.js @@ -59,6 +59,13 @@ angular.module("esNgAntd").directive("esTable", function (esNgAntd) { } $scope.columns.forEach((column) => { + // 排序 + if (column.sortOrder) { + $scope.state.sorter.field = column.key; + $scope.state.sorter.order = + column.sortOrder; + } + row[column.key] = column.render ? column.render( record[column.key], diff --git a/dist/ng-antd.js b/dist/ng-antd.js index 5a02160..c34c97f 100644 --- a/dist/ng-antd.js +++ b/dist/ng-antd.js @@ -49,7 +49,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Bre /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Button_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Button.html */ \"./build/Button/Button.html\");\n/* harmony import */ var antd_lib_button_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/button/style/index.css */ \"./node_modules/antd/lib/button/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esButton\", function (esNgAntd) {\n return {\n controllerAs: \"esButton\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n type: \"@\",\n size: \"@\",\n disabled: \"@\",\n ghost: \"@\",\n loading: \"@\",\n htmlType: \"@\",\n },\n template: _Button_html__WEBPACK_IMPORTED_MODULE_0__[\"default\"],\n controller: function ($scope, $element) {\n this.getContext = function () {\n return $scope;\n };\n\n $scope.state = {\n disabled: null,\n className: \"\",\n };\n $scope.watch = {\n loading: (newVal) => {\n if (newVal !== undefined) {\n if (newVal === \"true\") {\n $scope.state.className += \" ant-btn-loading\";\n } else {\n $scope.state.className =\n $scope.state.className.replace(\n \" ant-btn-loading\",\n \"\"\n );\n }\n }\n },\n };\n\n for (const key in $scope.watch) {\n $scope.$watch(key, $scope.watch[key], true);\n }\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-btn\", antd_lib_button_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n let className = [\"ant-btn\"];\n $scope.state.disabled =\n $scope.disabled === \"true\" || $scope.disabled === \"disabled\";\n\n if ($scope.type) {\n className.push(\"ant-btn-\" + $scope.type);\n }\n\n if ($scope.size && [\"lg\", \"sm\", \"xs\"].includes($scope.size)) {\n className.push(\"ant-btn-\" + $scope.size);\n }\n\n if ($scope.ghost) {\n className.push(\"ant-btn-background-ghost\");\n }\n\n $scope.state.className = className.join(\" \");\n\n if ($scope.htmlType) {\n $element[0].setAttribute(\"type\", $scope.htmlType);\n }\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Button/Button.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Button_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Button.html */ \"./build/Button/Button.html\");\n/* harmony import */ var antd_lib_button_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/button/style/index.css */ \"./node_modules/antd/lib/button/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esButton\", function (esNgAntd) {\n return {\n controllerAs: \"esButton\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n type: \"@\",\n size: \"@\",\n ghost: \"@\",\n loading: \"@\",\n htmlType: \"@\",\n },\n template: _Button_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 disabled: null,\n className: \"\",\n };\n $scope.watch = {\n loading: (newVal) => {\n if (newVal !== undefined) {\n if (newVal === \"true\") {\n $scope.state.className += \" ant-btn-loading\";\n } else {\n $scope.state.className =\n $scope.state.className.replace(\n \" ant-btn-loading\",\n \"\"\n );\n }\n }\n },\n };\n\n for (const key in $scope.watch) {\n $scope.$watch(key, $scope.watch[key], true);\n }\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-btn\", antd_lib_button_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n let className = [\"ant-btn\"];\n\n if ($scope.type) {\n className.push(\"ant-btn-\" + $scope.type);\n }\n\n if ($scope.size && [\"lg\", \"sm\", \"xs\"].includes($scope.size)) {\n className.push(\"ant-btn-\" + $scope.size);\n }\n\n if ($scope.ghost) {\n className.push(\"ant-btn-background-ghost\");\n }\n\n $scope.state.className = className.join(\" \");\n\n if ($scope.htmlType) {\n $element[0].setAttribute(\"type\", $scope.htmlType);\n }\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Button/Button.js?"); /***/ }), @@ -104,7 +104,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Col /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var antd_lib_style_index_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! antd/lib/style/index.css */ \"./node_modules/antd/lib/style/index.css\");\n\nangular.module(\"esNgAntd\").service(\"esNgAntd\", [\n \"$compile\",\n function ($compile) {\n this.styleSheets = null;\n\n this.createStyle = function (key, style) {\n if (!document.querySelector(\"#antd\")) {\n let styleElement = document.createElement(\"style\");\n styleElement.setAttribute(\"id\", \"antd\");\n styleElement.setAttribute(\"type\", \"text/css\");\n styleElement.innerHTML = antd_lib_style_index_css__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toString();\n document.head.appendChild(styleElement);\n }\n\n if (!document.querySelector(\"#\" + key)) {\n let styleElement = document.createElement(\"style\");\n styleElement.setAttribute(\"id\", key);\n styleElement.setAttribute(\"type\", \"text/css\");\n styleElement.innerHTML = style.toString();\n document.head.appendChild(styleElement);\n\n if (this.styleSheets) {\n this.disableStyle(key);\n }\n }\n };\n\n this.disableStyle = function (name) {\n for (let i = 0; i < this.styleSheets.cssRules.length; i++) {\n let rule = this.styleSheets.cssRules[i];\n\n if (\n rule.selectorText &&\n rule.selectorText.indexOf(name) !== -1\n ) {\n rule.selectorText = rule.selectorText.replace(\n /\\.ant-/g,\n \".disabled-ant-\"\n );\n }\n }\n };\n\n this.conflict = function (filename) {\n for (let i = 0; i < document.styleSheets.length; i++) {\n const element = document.styleSheets[i];\n\n if (element.href && element.href.indexOf(filename) !== -1) {\n this.styleSheets = element;\n }\n }\n };\n\n this.createLayer = function (content, scope) {\n let div = document.createElement(\"div\");\n div.innerHTML = content;\n document.body.appendChild(div);\n $compile(div)(scope);\n };\n },\n]);\n\n\n//# sourceURL=webpack://ng-antd/./build/Common/Common.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var antd_lib_style_index_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! antd/lib/style/index.css */ \"./node_modules/antd/lib/style/index.css\");\n\nangular.module(\"esNgAntd\").service(\"esNgAntd\", [\n \"$compile\",\n function ($compile) {\n this.styleSheets = null;\n\n this.createStyle = function (key, style) {\n if (!document.querySelector(\"#antd\")) {\n let styleElement = document.createElement(\"style\");\n styleElement.setAttribute(\"id\", \"antd\");\n styleElement.setAttribute(\"type\", \"text/css\");\n styleElement.innerHTML = antd_lib_style_index_css__WEBPACK_IMPORTED_MODULE_0__[\"default\"].toString();\n document.head.appendChild(styleElement);\n }\n\n if (!document.querySelector(\"#\" + key)) {\n let styleElement = document.createElement(\"style\");\n styleElement.setAttribute(\"id\", key);\n styleElement.setAttribute(\"type\", \"text/css\");\n styleElement.innerHTML = style.toString();\n document.head.appendChild(styleElement);\n\n if (this.styleSheets) {\n this.disableStyle(key);\n }\n }\n };\n\n this.disableStyle = function (name) {\n for (let i = 0; i < this.styleSheets.cssRules.length; i++) {\n let rule = this.styleSheets.cssRules[i];\n\n if (\n rule.selectorText &&\n rule.selectorText.indexOf(name) !== -1\n ) {\n rule.selectorText = rule.selectorText.replace(\n /\\.ant\\-/g,\n \".disabled-ant-\"\n );\n console.log(rule.selectorText);\n }\n }\n };\n\n this.conflict = function (filename) {\n for (let i = 0; i < document.styleSheets.length; i++) {\n const element = document.styleSheets[i];\n\n if (element.href && element.href.indexOf(filename) !== -1) {\n this.styleSheets = element;\n }\n }\n };\n\n this.createLayer = function (content, scope) {\n let div = document.createElement(\"div\");\n div.innerHTML = content;\n document.body.appendChild(div);\n $compile(div)(scope);\n };\n },\n]);\n\n\n//# sourceURL=webpack://ng-antd/./build/Common/Common.js?"); /***/ }), @@ -280,7 +280,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Mod /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -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.getPageNum = function () {\n return (\n Math.ceil(\n $scope.state.total /\n ($scope.pageSize || $scope.defaultPageSize || 10)\n ) || 1\n );\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.getPopupContainer = function () {\n return $element[0].querySelector(\".ant-pagination-options\");\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 $scope.state.current = 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.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 = Array($scope.state.pageNum)\n .fill(0)\n .map((v, i) => i + 1);\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Pagination/Pagination.js?"); +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?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Row /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Select_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Select.html */ \"./build/Select/Select.html\");\n/* harmony import */ var antd_lib_select_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/select/style/index.css */ \"./node_modules/antd/lib/select/style/index.css\");\n\n\nangular\n .module(\"esNgAntd\")\n .directive(\"esSelect\", function ($compile, $timeout, esNgAntd) {\n return {\n controllerAs: \"esSelect\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n value: \"@\",\n defaultValue: \"@\",\n placeholder: \"@\",\n onChange: \"&\",\n placeholder: \"@\",\n getPopupContainer: \"&\",\n size: \"@\",\n },\n template: _Select_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 open: false,\n childrens: [],\n label: null,\n value: $scope.value || $scope.defaultValue,\n popup: null,\n };\n\n $scope.setValue = function (value) {\n let option = $scope.state.childrens.find(function (option) {\n return option.value === value;\n });\n\n if (option) {\n option.label = option.element.text();\n $scope.state.label = option.label;\n $scope.state.value = option.value;\n } else {\n $scope.state.label = null;\n $scope.state.value = null;\n }\n };\n\n $scope.addOption = function (option) {\n $scope.state.childrens.push(option);\n };\n\n $scope.handleClick = function (option) {\n $scope.state.open = !$scope.state.open;\n $scope.state.label = option.label;\n $scope.state.value = option.value;\n $scope.onChange({\n value: $scope.state.value,\n });\n };\n\n $scope.getOffset = function (ele) {\n if (!ele || ele.nodeType != 1) {\n return;\n }\n\n let func = $scope.getPopupContainer();\n\n if (typeof func === \"function\" && func() !== undefined) {\n return {\n top: $element[0].offsetTop,\n left: $element[0].offsetLeft,\n };\n } else {\n let rect = ele.getBoundingClientRect();\n let doc = ele.ownerDocument.documentElement;\n return {\n top: rect.top + window.pageYOffset - doc.clientTop,\n left:\n rect.left + window.pageXOffset - doc.clientLeft,\n };\n }\n };\n\n $scope.myEvent = function () {\n $timeout(() => {\n $scope.state.open = false;\n document.body.removeEventListener(\n \"click\",\n $scope.myEvent\n );\n }, 0);\n };\n\n $scope.handleBlur = function () {\n // 事件绑定\n document.body.addEventListener(\"click\", $scope.myEvent);\n };\n\n $scope.handleOpen = function (event) {\n event.stopPropagation();\n const { height, width } =\n $element[0].getBoundingClientRect();\n const { top, left } = $scope.getOffset($element[0]); // 处理标签\n\n $scope.state.childrens.forEach(function (item) {\n item.label = item.element.text();\n });\n let div = document.createElement(\"div\");\n div.style.position = \"absolute\";\n div.style.left = 0;\n div.style.top = 0;\n div.style.width = \"100%\";\n div.appendChild(\n $compile(`\n \n {{option.label}}\n \n `)($scope)[0]\n );\n\n if ($scope.state.popup === null) {\n let func = $scope.getPopupContainer();\n\n if (\n typeof func === \"function\" &&\n func() !== undefined\n ) {\n $element[0].style.position = \"relative\";\n $scope.getPopupContainer()().appendChild(div);\n } else {\n document.body.appendChild(div);\n }\n\n $scope.state.popup = div;\n }\n\n $scope.state.open = !$scope.state.open;\n $scope.handleBlur();\n };\n },\n require: [\"?^esForm\", \"?^esFormItem\"],\n link: function (\n $scope,\n $element,\n $attrs,\n $controllers,\n $transclude\n ) {\n let [esForm, esFormItem] = $controllers;\n esNgAntd.createStyle(\"ant-select\", antd_lib_select_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n\n if (esForm) {\n $scope.esForm = esForm.getContext();\n $scope.esForm.state.formItems.push($scope);\n }\n\n if (esFormItem) {\n $scope.esFormItem = esFormItem.getContext();\n }\n\n $timeout(function () {\n $scope.setValue($scope.value || $scope.defaultValue);\n }, 100);\n },\n };\n });\n\n\n//# sourceURL=webpack://ng-antd/./build/Select/Select.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Select_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Select.html */ \"./build/Select/Select.html\");\n/* harmony import */ var antd_lib_select_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/select/style/index.css */ \"./node_modules/antd/lib/select/style/index.css\");\n\n\nangular\n .module(\"esNgAntd\")\n .directive(\"esSelect\", function ($compile, $timeout, esNgAntd) {\n return {\n controllerAs: \"esSelect\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n value: \"@\",\n defaultValue: \"@\",\n placeholder: \"@\",\n onChange: \"&\",\n placeholder: \"@\",\n getPopupContainer: \"&\",\n size: \"@\",\n },\n template: _Select_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 open: false,\n childrens: [],\n label: null,\n value: $scope.value || $scope.defaultValue,\n popup: null,\n };\n\n $scope.setValue = function (value) {\n let option = $scope.state.childrens.find(function (option) {\n return option.value === value;\n });\n\n if (option) {\n option.label = option.element.text();\n $scope.state.label = option.label;\n $scope.state.value = option.value;\n } else {\n $scope.state.label = null;\n $scope.state.value = null;\n }\n };\n\n $scope.addOption = function (option) {\n $scope.state.childrens.push(option);\n };\n\n $scope.handleClick = function (option) {\n $scope.state.open = !$scope.state.open;\n $scope.state.label = option.label;\n $scope.state.value = option.value;\n $scope.onChange({\n value: $scope.state.value,\n });\n };\n\n $scope.getOffset = function (ele) {\n if (!ele || ele.nodeType != 1) {\n return;\n }\n\n let func = $scope.getPopupContainer();\n\n if (typeof func === \"function\" && func() !== undefined) {\n let containerElement = func();\n containerElement.style.position = \"relative\";\n return {\n top: $element[0].offsetTop,\n left: $element[0].offsetLeft,\n };\n } else {\n let rect = ele.getBoundingClientRect();\n let doc = ele.ownerDocument.documentElement;\n return {\n top: rect.top + window.pageYOffset - doc.clientTop,\n left:\n rect.left + window.pageXOffset - doc.clientLeft,\n };\n }\n };\n\n $scope.myEvent = function () {\n $timeout(() => {\n $scope.state.open = false;\n document.body.removeEventListener(\n \"click\",\n $scope.myEvent\n );\n }, 0);\n };\n\n $scope.handleBlur = function () {\n // 事件绑定\n document.body.addEventListener(\"click\", $scope.myEvent);\n };\n\n $scope.handleOpen = function (event) {\n event.stopPropagation();\n const { height, width } =\n $element[0].getBoundingClientRect();\n const { top, left } = $scope.getOffset($element[0]); // 处理标签\n\n $scope.state.childrens.forEach(function (item) {\n item.label = item.element.text();\n });\n let div = document.createElement(\"div\");\n div.style.position = \"absolute\";\n div.style.left = 0;\n div.style.top = 0;\n div.style.width = \"100%\";\n div.appendChild(\n $compile(`\n \n {{option.label}}\n \n `)($scope)[0]\n );\n\n if ($scope.state.popup === null) {\n let func = $scope.getPopupContainer();\n\n if (\n typeof func === \"function\" &&\n func() !== undefined\n ) {\n $element[0].style.position = \"relative\";\n $scope.getPopupContainer()().appendChild(div);\n } else {\n document.body.appendChild(div);\n }\n\n $scope.state.popup = div;\n }\n\n $scope.state.open = !$scope.state.open;\n $scope.handleBlur();\n };\n },\n require: [\"?^esForm\", \"?^esFormItem\"],\n link: function (\n $scope,\n $element,\n $attrs,\n $controllers,\n $transclude\n ) {\n let [esForm, esFormItem] = $controllers;\n esNgAntd.createStyle(\"ant-select\", antd_lib_select_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n\n if (esForm) {\n $scope.esForm = esForm.getContext();\n $scope.esForm.state.formItems.push($scope);\n }\n\n if (esFormItem) {\n $scope.esFormItem = esFormItem.getContext();\n }\n\n $timeout(function () {\n $scope.setValue($scope.value || $scope.defaultValue);\n }, 100);\n },\n };\n });\n\n\n//# sourceURL=webpack://ng-antd/./build/Select/Select.js?"); /***/ }), @@ -400,7 +400,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Tab /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Table_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Table.html */ \"./build/Table/Table.html\");\n/* harmony import */ var antd_lib_table_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/table/style/index.css */ \"./node_modules/antd/lib/table/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esTable\", function (esNgAntd) {\n return {\n controllerAs: \"esTable\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n columns: \"=\",\n dSource: \"=\",\n rowSelection: \"=\",\n rowKey: \"@\",\n loading: \"@\",\n onChange: \"&\",\n size: \"@\",\n },\n template: _Table_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 size: $scope.size || \"default\",\n dataSource: [],\n selectedrecordKeys: [],\n selectedrecords: [],\n isSelectAll: false,\n rowKey: $scope.rowKey || \"id\",\n sortDirections: [\"ascend\", \"descend\"],\n sorter: {\n field: null,\n order: null,\n },\n };\n $scope.watch = {\n dSource: (newValue) => {\n if (newValue !== undefined) {\n let dataSource = [];\n newValue.forEach((record, index) => {\n let row = {};\n\n if ($scope.rowSelection) {\n row.checked = false;\n row.disabled = false;\n }\n\n if (\n $scope.rowSelection &&\n typeof $scope.rowSelection.getCheckboxProps ===\n \"function\"\n ) {\n let extraAttr =\n $scope.rowSelection.getCheckboxProps(\n record\n );\n row = Object.assign(row, extraAttr);\n }\n\n $scope.columns.forEach((column) => {\n row[column.key] = column.render\n ? column.render(\n record[column.key],\n record,\n index\n )\n : record[column.key];\n }); // 主键\n\n if ($scope.rowKey !== undefined) {\n row[$scope.state.rowKey] =\n record[$scope.state.rowKey];\n } else {\n row[$scope.state.rowKey] = index + 1;\n }\n\n dataSource[index] = row;\n });\n $scope.state.dataSource = dataSource;\n }\n },\n };\n\n for (const key in $scope.watch) {\n $scope.$watch(key, $scope.watch[key], true);\n }\n\n $scope.handleSelectAll = function (event) {\n $scope.state.isSelectAll = event.target.checked;\n $scope.state.selectedrecordKeys = [];\n $scope.state.selectedrecords = [];\n $scope.state.dataSource.map((record, key) => {\n if (record.disabled === false) {\n record.checked = event.target.checked;\n }\n\n if (record.checked) {\n $scope.state.selectedrecordKeys.push(key);\n $scope.state.selectedrecords.push($scope.dSource[key]);\n }\n\n return record;\n });\n $scope.rowSelection.onChange(\n $scope.state.selectedrecordKeys,\n $scope.state.selectedrecords\n );\n };\n\n $scope.handleSelect = function (event, index) {\n let pos = $scope.state.selectedrecordKeys.findIndex(\n (value) => value === index\n );\n\n if (event.target.checked && pos === -1) {\n $scope.state.selectedrecordKeys.push(index);\n $scope.state.selectedrecords.push($scope.dSource[index]);\n } else {\n $scope.state.selectedrecordKeys.splice(pos, 1);\n $scope.state.selectedrecords.splice(pos, 1);\n }\n\n if ($scope.state.selectedrecordKeys.length === 0) {\n $scope.state.isSelectAll = false;\n }\n\n $scope.rowSelection.onChange(\n $scope.state.selectedrecordKeys,\n $scope.state.selectedrecords\n );\n };\n\n $scope.handleSorter = function (key) {\n $scope.state.sorter.field = key;\n\n if ($scope.state.sorter.order === null) {\n $scope.state.sorter.order = \"ascend\";\n } else if ($scope.state.sorter.order === \"ascend\") {\n $scope.state.sorter.order = \"descend\";\n } else if ($scope.state.sorter.order === \"descend\") {\n $scope.state.sorter.order = null;\n $scope.state.sorter.field = null;\n }\n\n $scope.onChange({\n sorter: $scope.state.sorter,\n });\n };\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-table\", antd_lib_table_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Table/Table.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Table_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Table.html */ \"./build/Table/Table.html\");\n/* harmony import */ var antd_lib_table_style_index_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! antd/lib/table/style/index.css */ \"./node_modules/antd/lib/table/style/index.css\");\n\n\nangular.module(\"esNgAntd\").directive(\"esTable\", function (esNgAntd) {\n return {\n controllerAs: \"esTable\",\n restrict: \"E\",\n transclude: true,\n replace: true,\n scope: {\n columns: \"=\",\n dSource: \"=\",\n rowSelection: \"=\",\n rowKey: \"@\",\n loading: \"@\",\n onChange: \"&\",\n size: \"@\",\n },\n template: _Table_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 size: $scope.size || \"default\",\n dataSource: [],\n selectedrecordKeys: [],\n selectedrecords: [],\n isSelectAll: false,\n rowKey: $scope.rowKey || \"id\",\n sortDirections: [\"ascend\", \"descend\"],\n sorter: {\n field: null,\n order: null,\n },\n };\n $scope.watch = {\n dSource: (newValue) => {\n if (newValue !== undefined) {\n let dataSource = [];\n newValue.forEach((record, index) => {\n let row = {};\n\n if ($scope.rowSelection) {\n row.checked = false;\n row.disabled = false;\n }\n\n if (\n $scope.rowSelection &&\n typeof $scope.rowSelection.getCheckboxProps ===\n \"function\"\n ) {\n let extraAttr =\n $scope.rowSelection.getCheckboxProps(\n record\n );\n row = Object.assign(row, extraAttr);\n }\n\n $scope.columns.forEach((column) => {\n // 排序\n if (column.sortOrder) {\n $scope.state.sorter.field = column.key;\n $scope.state.sorter.order =\n column.sortOrder;\n }\n\n row[column.key] = column.render\n ? column.render(\n record[column.key],\n record,\n index\n )\n : record[column.key];\n }); // 主键\n\n if ($scope.rowKey !== undefined) {\n row[$scope.state.rowKey] =\n record[$scope.state.rowKey];\n } else {\n row[$scope.state.rowKey] = index + 1;\n }\n\n dataSource[index] = row;\n });\n $scope.state.dataSource = dataSource;\n }\n },\n };\n\n for (const key in $scope.watch) {\n $scope.$watch(key, $scope.watch[key], true);\n }\n\n $scope.handleSelectAll = function (event) {\n $scope.state.isSelectAll = event.target.checked;\n $scope.state.selectedrecordKeys = [];\n $scope.state.selectedrecords = [];\n $scope.state.dataSource.map((record, key) => {\n if (record.disabled === false) {\n record.checked = event.target.checked;\n }\n\n if (record.checked) {\n $scope.state.selectedrecordKeys.push(key);\n $scope.state.selectedrecords.push($scope.dSource[key]);\n }\n\n return record;\n });\n $scope.rowSelection.onChange(\n $scope.state.selectedrecordKeys,\n $scope.state.selectedrecords\n );\n };\n\n $scope.handleSelect = function (event, index) {\n let pos = $scope.state.selectedrecordKeys.findIndex(\n (value) => value === index\n );\n\n if (event.target.checked && pos === -1) {\n $scope.state.selectedrecordKeys.push(index);\n $scope.state.selectedrecords.push($scope.dSource[index]);\n } else {\n $scope.state.selectedrecordKeys.splice(pos, 1);\n $scope.state.selectedrecords.splice(pos, 1);\n }\n\n if ($scope.state.selectedrecordKeys.length === 0) {\n $scope.state.isSelectAll = false;\n }\n\n $scope.rowSelection.onChange(\n $scope.state.selectedrecordKeys,\n $scope.state.selectedrecords\n );\n };\n\n $scope.handleSorter = function (key) {\n $scope.state.sorter.field = key;\n\n if ($scope.state.sorter.order === null) {\n $scope.state.sorter.order = \"ascend\";\n } else if ($scope.state.sorter.order === \"ascend\") {\n $scope.state.sorter.order = \"descend\";\n } else if ($scope.state.sorter.order === \"descend\") {\n $scope.state.sorter.order = null;\n $scope.state.sorter.field = null;\n }\n\n $scope.onChange({\n sorter: $scope.state.sorter,\n });\n };\n },\n link: function ($scope, $element, $attrs, $controllers, $transclude) {\n esNgAntd.createStyle(\"ant-table\", antd_lib_table_style_index_css__WEBPACK_IMPORTED_MODULE_1__[\"default\"]);\n },\n };\n});\n\n\n//# sourceURL=webpack://ng-antd/./build/Table/Table.js?"); /***/ }), @@ -9430,7 +9430,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -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 = \"\\n \\n \\n \\n \\n \\n \\n\";\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (code);\n\n//# sourceURL=webpack://ng-antd/./build/Button/Button.html?"); +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 = \"\\n \\n \\n \\n \\n \\n \\n\";\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (code);\n\n//# sourceURL=webpack://ng-antd/./build/Button/Button.html?"); /***/ }), @@ -9617,7 +9617,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -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 = \"\\n \\n \\n \\n \\n \\n \\n {{value}}\\n \\n \\n \\n \\n \\n \\n \\n \\n 10 条/页\\n 20 条/页\\n 30 条/页\\n 40 条/页\\n \\n \\n 跳至页\\n \\n \\n\";\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (code);\n\n//# sourceURL=webpack://ng-antd/./build/Pagination/Pagination.html?"); +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 = \"\\n \\n \\n \\n \\n \\n \\n {{value}}\\n \\n \\n \\n \\n •••\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n 10 条/页\\n 20 条/页\\n 30 条/页\\n 40 条/页\\n \\n \\n 跳至页\\n \\n \\n\";\n// Exports\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (code);\n\n//# sourceURL=webpack://ng-antd/./build/Pagination/Pagination.html?"); /***/ }), diff --git a/example/button.html b/example/button.html index 302c4de..26062c9 100644 --- a/example/button.html +++ b/example/button.html @@ -20,6 +20,7 @@ I am button. Link Link + Link Ghost Link Loading diff --git a/example/pagination.html b/example/pagination.html index 9ae13bf..e00e97b 100644 --- a/example/pagination.html +++ b/example/pagination.html @@ -9,8 +9,8 @@ - - + + diff --git a/example/table.html b/example/table.html index 3ff7414..3e2fe51 100644 --- a/example/table.html +++ b/example/table.html @@ -30,6 +30,7 @@ title: "航线", key: "age", sorter: true, + sortOrder: "ascend" }, { title: "状态", diff --git a/src/Button/Button.html b/src/Button/Button.html index 9057f9e..2f106bb 100644 --- a/src/Button/Button.html +++ b/src/Button/Button.html @@ -1,4 +1,4 @@ - + {loading && diff --git a/src/Button/Button.js b/src/Button/Button.js index 3a61691..5e82401 100644 --- a/src/Button/Button.js +++ b/src/Button/Button.js @@ -8,7 +8,6 @@ class Button { props = { type: String, size: String, - disabled: Boolean, ghost: Boolean, loading: Boolean, htmlType: String, @@ -40,9 +39,6 @@ class Button { esNgAntd.createStyle("ant-btn", style); let className = ["ant-btn"]; - this.state.disabled = - this.props.disabled === "true" || - this.props.disabled === "disabled"; if (this.props.type) { className.push("ant-btn-" + this.props.type); } diff --git a/src/Common/Common.js b/src/Common/Common.js index 9c4b9a6..8fdd3b7 100644 --- a/src/Common/Common.js +++ b/src/Common/Common.js @@ -28,9 +28,10 @@ angular.module("esNgAntd").service("esNgAntd", ["$compile", function ($compile) let rule = this.styleSheets.cssRules[i]; if (rule.selectorText && rule.selectorText.indexOf(name) !== -1) { rule.selectorText = rule.selectorText.replace( - /\.ant-/g, + /\.ant\-/g, ".disabled-ant-" ); + console.log(rule.selectorText); } } }; diff --git a/src/Form/Form.js b/src/Form/Form.js index 93a3318..5a14b4e 100644 --- a/src/Form/Form.js +++ b/src/Form/Form.js @@ -42,6 +42,10 @@ class Form { }); } + submit() { + this.handleSubmit(); + } + handleSubmit() { let values = {}; this.state.formItems.forEach(function (item) { @@ -49,17 +53,6 @@ class Form { let value = item.value || item.state.value || null; values[name] = value; }); - // for (let i = 0; i < inputs.length; i++) { - // const element = inputs[i]; - // const value = element.value === "" ? null : element.value; - // if (element.id) { - // if (element.id.split("_").length > 1) { - // values[element.id.split("_")[1]] = value; - // } else { - // values[element.id] = value; - // } - // } - // } this.props.onFinish({ values: values, }); diff --git a/src/Pagination/Pagination.html b/src/Pagination/Pagination.html index de64c77..a88764d 100644 --- a/src/Pagination/Pagination.html +++ b/src/Pagination/Pagination.html @@ -4,9 +4,16 @@ - {state.pageNumList.map(function (value) { - return - {value} + {state.pageNumList.map(function (value, key) { + return + {(value!=='prev'&&value!=='next')&&{value}} + {(value==='prev'||value==='next')&& + + {value==="prev"&&} + {value==="next"&&} + ••• + + } })} diff --git a/src/Pagination/Pagination.js b/src/Pagination/Pagination.js index 3bc674e..e77ed59 100644 --- a/src/Pagination/Pagination.js +++ b/src/Pagination/Pagination.js @@ -2,7 +2,6 @@ import template from "./Pagination.html"; import style from "antd/lib/pagination/style/index.css"; class Pagination { - useModules = ["esNgAntd"]; template = template; @@ -31,16 +30,79 @@ class Pagination { constructor() { esNgAntd.createStyle("ant-pagination", style); this.state.total = Number(this.props.total || 0); - this.state.current = Number(this.props.current || this.props.defaultCurrent || 1); - this.state.pageSize = this.props.pageSize || this.props.defaultPageSize || 10; + this.state.current = Number( + this.props.current || this.props.defaultCurrent || 1 + ); + this.state.pageSize = + this.props.pageSize || this.props.defaultPageSize || 10; this.state.pageNum = this.getPageNum(); - this.state.pageNumList = Array(this.state.pageNum) - .fill(0) - .map((v, i) => i + 1); + this.state.pageNumList = this.getPageNumList(); + } + + getItemLinkClassName(value) { + if (typeof value === "number") { + return ( + "ant-pagination-item" + + (this.state.current === value + ? " ant-pagination-item-active" + : "") + ); + } else { + return "ant-pagination-jump-next ant-pagination-jump-next-custom-icon"; + } + } + + getPageNumList() { + let pageNumList = [this.state.current]; + let pageNum = this.getPageNum(); + if (pageNum <= 7 || this.state.current - 1 < 4) { + for (let i = this.state.current - 1; i > 0; i--) { + pageNumList.unshift(i); + } + } else { + let len = this.state.current - 1 > 2 ? 2 : this.state.current - 1; + for (let i = 1; i <= len; i++) { + pageNumList.unshift(this.state.current - i); + } + if (this.state.current - 2 > 2) { + pageNumList.unshift("prev"); + pageNumList.unshift(1); + } + } + + if (pageNum <= 7 || pageNum - this.state.current < 4) { + for (let i = this.state.current + 1; i <= pageNum; i++) { + pageNumList.push(i); + } + } else { + let limit = + 3 - this.state.current > 0 ? 2 + (3 - this.state.current) : 2; + let len = + pageNum - this.state.current > limit + ? limit + : pageNum - this.state.current; + for (let i = 1; i <= len; i++) { + pageNumList.push(this.state.current + i); + } + if (pageNum - this.state.current > 2) { + pageNumList.push("next"); + pageNumList.push(pageNum); + } + } + return pageNumList; } getPageNum() { - return Math.ceil(this.state.total / (this.props.pageSize || this.props.defaultPageSize || 10)) || 1; + return ( + Math.ceil( + this.state.total / + (this.props.pageSize || this.props.defaultPageSize || 10) + ) || 1 + ); + } + + getPopupContainer() { + return $element[0].querySelector(".ant-pagination-options"); } handleNext() { @@ -50,10 +112,6 @@ class Pagination { this.handleClick(++this.state.current); } - getPopupContainer() { - return $element[0].querySelector(".ant-pagination-options"); - } - handlePrev() { if (this.state.current === 1) { return false; @@ -62,7 +120,13 @@ class Pagination { } handleClick(value) { - this.state.current = value; + if (value === "next") { + value = this.state.current + 5; + } + if (value === "prev") { + value = this.state.current - 5; + } + this.setCurrent(this.getCurrent(value)); // 更新回调 this.props.onChange({ page: this.state.current, @@ -88,7 +152,7 @@ class Pagination { this.state.pageSize = parseInt(value); this.handleChange(); } - + getCurrent(number) { if (number > this.state.pageNum) { return this.state.pageNum; @@ -104,6 +168,7 @@ class Pagination { return; } this.state.current = this.getCurrent(value); + this.state.pageNumList = this.getPageNumList(); this.handleChange(); } diff --git a/src/Select/Select.js b/src/Select/Select.js index 8430ac7..4d5b6dd 100644 --- a/src/Select/Select.js +++ b/src/Select/Select.js @@ -72,6 +72,8 @@ class Select { } let func = this.props.getPopupContainer(); if (typeof func === "function" && func() !== undefined) { + let containerElement = func(); + containerElement.style.position = "relative"; return { top: $element[0].offsetTop, left: $element[0].offsetLeft, diff --git a/src/Table/Table.js b/src/Table/Table.js index d55efd4..1f89ec0 100644 --- a/src/Table/Table.js +++ b/src/Table/Table.js @@ -25,7 +25,7 @@ class Table { sorter: { field: null, order: null, - }, + } }; template = template; @@ -50,6 +50,11 @@ class Table { row = Object.assign(row, extraAttr); } this.props.columns.forEach((column) => { + // 排序 + if (column.sortOrder) { + this.state.sorter.field = column.key; + this.state.sorter.order = column.sortOrder; + } row[column.key] = column.render ? column.render(record[column.key], record, index) : record[column.key]; diff --git a/webpack.config.js b/webpack.config.js index 8aeae93..57039d4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,9 +6,9 @@ module.exports = { entry: "./build/index.js", output: { // bpms - path: "/Users/shann/Project/essa/bpms/bpms-webapp/src/main/webapp/lib/ng-antd", + // path: "/Users/shann/Project/essa/bpms/bpms-webapp/src/main/webapp/lib/ng-antd", // boss - // path: "/Users/shann/Project/essa/boss/trunk/vendor-lib/ng-antd", + path: "/Users/shann/Project/essa/boss/trunk/vendor-lib/ng-antd", // mvo // path: "/Users/shann/Project/essa/mvo/mvo-webapp/public/browser-vendor/ng-antd", // local -- libgit2 0.21.2