Commit 5b2482824b04d0c16ee814eab901d5131f23c781
1 parent
fe4cf8e2
优化
Showing
6 changed files
with
35 additions
and
24 deletions
Show diff stats
build/Checkbox/Checkbox.js
@@ -46,7 +46,6 @@ angular.module("esNgAntd").directive("antdCheckbox", function (esNgAntd) { | @@ -46,7 +46,6 @@ angular.module("esNgAntd").directive("antdCheckbox", function (esNgAntd) { | ||
46 | 46 | ||
47 | $scope.handleClick = function ($event) { | 47 | $scope.handleClick = function ($event) { |
48 | $scope.state.checked = !$scope.state.checked; | 48 | $scope.state.checked = !$scope.state.checked; |
49 | - $event.target.checked = $scope.state.checked; | ||
50 | $scope.onChange({ | 49 | $scope.onChange({ |
51 | event: $event, | 50 | event: $event, |
52 | }); | 51 | }); |
build/Pagination/Pagination.js
@@ -34,9 +34,10 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | @@ -34,9 +34,10 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | ||
34 | defaultPageSize: $scope.defaultPageSize || 10, | 34 | defaultPageSize: $scope.defaultPageSize || 10, |
35 | }; | 35 | }; |
36 | $scope.watch = { | 36 | $scope.watch = { |
37 | - total: function (newVal, oldVal) { | ||
38 | - if (newVal && oldVal) { | 37 | + total: function (newVal) { |
38 | + if (newVal) { | ||
39 | $scope.state.total = Number(newVal); | 39 | $scope.state.total = Number(newVal); |
40 | + $scope.reset(); | ||
40 | $scope.state.pageNum = $scope.getPageNum(); | 41 | $scope.state.pageNum = $scope.getPageNum(); |
41 | $scope.state.pageNumList = $scope.getPageNumList(); | 42 | $scope.state.pageNumList = $scope.getPageNumList(); |
42 | } | 43 | } |
@@ -66,6 +67,10 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | @@ -66,6 +67,10 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | ||
66 | } | 67 | } |
67 | }; | 68 | }; |
68 | 69 | ||
70 | + $scope.reset = function () { | ||
71 | + $scope.state.current = 1; | ||
72 | + }; | ||
73 | + | ||
69 | $scope.getPageNumList = function () { | 74 | $scope.getPageNumList = function () { |
70 | let pageNumList = [$scope.state.current]; | 75 | let pageNumList = [$scope.state.current]; |
71 | let pageNum = $scope.getPageNum(); | 76 | let pageNum = $scope.getPageNum(); |
@@ -137,7 +142,7 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | @@ -137,7 +142,7 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | ||
137 | return false; | 142 | return false; |
138 | } | 143 | } |
139 | 144 | ||
140 | - $scope.handleClick(++$scope.state.current); | 145 | + $scope.handleClick($scope.state.current + 1); |
141 | }; | 146 | }; |
142 | 147 | ||
143 | $scope.handlePrev = function () { | 148 | $scope.handlePrev = function () { |
@@ -145,7 +150,7 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | @@ -145,7 +150,7 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { | ||
145 | return false; | 150 | return false; |
146 | } | 151 | } |
147 | 152 | ||
148 | - $scope.handleClick(--$scope.state.current); | 153 | + $scope.handleClick($scope.state.current - 1); |
149 | }; | 154 | }; |
150 | 155 | ||
151 | $scope.handleClick = function (value) { | 156 | $scope.handleClick = function (value) { |
build/Table/Table.js
@@ -59,13 +59,6 @@ angular.module("esNgAntd").directive("antdTable", function (esNgAntd) { | @@ -59,13 +59,6 @@ angular.module("esNgAntd").directive("antdTable", function (esNgAntd) { | ||
59 | } | 59 | } |
60 | 60 | ||
61 | $scope.columns.forEach((column) => { | 61 | $scope.columns.forEach((column) => { |
62 | - // 排序 | ||
63 | - if (column.sortOrder) { | ||
64 | - $scope.state.sorter.field = column.key; | ||
65 | - $scope.state.sorter.order = | ||
66 | - column.sortOrder; | ||
67 | - } | ||
68 | - | ||
69 | row[column.key] = column.render | 62 | row[column.key] = column.render |
70 | ? $scope.getRender(column, record, index) | 63 | ? $scope.getRender(column, record, index) |
71 | : record[column.key]; | 64 | : record[column.key]; |
@@ -213,7 +206,14 @@ angular.module("esNgAntd").directive("antdTable", function (esNgAntd) { | @@ -213,7 +206,14 @@ angular.module("esNgAntd").directive("antdTable", function (esNgAntd) { | ||
213 | }; | 206 | }; |
214 | }, | 207 | }, |
215 | link: function ($scope, $element, $attrs, $controllers, $transclude) { | 208 | link: function ($scope, $element, $attrs, $controllers, $transclude) { |
216 | - esNgAntd.createStyle("ant-table", style); | 209 | + esNgAntd.createStyle("ant-table", style); // 初始化默认排序 |
210 | + | ||
211 | + $scope.columns.forEach((column) => { | ||
212 | + if (column.sortOrder) { | ||
213 | + $scope.state.sorter.field = column.key; | ||
214 | + $scope.state.sorter.order = column.sortOrder; | ||
215 | + } | ||
216 | + }); | ||
217 | }, | 217 | }, |
218 | }; | 218 | }; |
219 | }); | 219 | }); |
src/Pagination/Pagination.js
@@ -30,9 +30,10 @@ class Pagination { | @@ -30,9 +30,10 @@ class Pagination { | ||
30 | }; | 30 | }; |
31 | 31 | ||
32 | watch = { | 32 | watch = { |
33 | - total: function (newVal, oldVal) { | ||
34 | - if (newVal && oldVal) { | 33 | + total: function (newVal) { |
34 | + if (newVal) { | ||
35 | this.state.total = Number(newVal); | 35 | this.state.total = Number(newVal); |
36 | + this.reset(); | ||
36 | this.state.pageNum = this.getPageNum(); | 37 | this.state.pageNum = this.getPageNum(); |
37 | this.state.pageNumList = this.getPageNumList(); | 38 | this.state.pageNumList = this.getPageNumList(); |
38 | } | 39 | } |
@@ -70,6 +71,10 @@ class Pagination { | @@ -70,6 +71,10 @@ class Pagination { | ||
70 | } | 71 | } |
71 | } | 72 | } |
72 | 73 | ||
74 | + reset() { | ||
75 | + this.state.current = 1; | ||
76 | + } | ||
77 | + | ||
73 | getPageNumList() { | 78 | getPageNumList() { |
74 | let pageNumList = [this.state.current]; | 79 | let pageNumList = [this.state.current]; |
75 | let pageNum = this.getPageNum(); | 80 | let pageNum = this.getPageNum(); |
@@ -127,14 +132,14 @@ class Pagination { | @@ -127,14 +132,14 @@ class Pagination { | ||
127 | if (this.state.current === this.state.pageNum) { | 132 | if (this.state.current === this.state.pageNum) { |
128 | return false; | 133 | return false; |
129 | } | 134 | } |
130 | - this.handleClick(++this.state.current); | 135 | + this.handleClick(this.state.current+1); |
131 | } | 136 | } |
132 | 137 | ||
133 | handlePrev() { | 138 | handlePrev() { |
134 | if (this.state.current === 1) { | 139 | if (this.state.current === 1) { |
135 | return false; | 140 | return false; |
136 | } | 141 | } |
137 | - this.handleClick(--this.state.current); | 142 | + this.handleClick(this.state.current-1); |
138 | } | 143 | } |
139 | 144 | ||
140 | handleClick(value) { | 145 | handleClick(value) { |
src/Table/Table.js
@@ -50,11 +50,6 @@ class Table { | @@ -50,11 +50,6 @@ class Table { | ||
50 | row = Object.assign(row, extraAttr); | 50 | row = Object.assign(row, extraAttr); |
51 | } | 51 | } |
52 | this.props.columns.forEach((column) => { | 52 | this.props.columns.forEach((column) => { |
53 | - // 排序 | ||
54 | - if (column.sortOrder) { | ||
55 | - this.state.sorter.field = column.key; | ||
56 | - this.state.sorter.order = column.sortOrder; | ||
57 | - } | ||
58 | row[column.key] = column.render | 53 | row[column.key] = column.render |
59 | ? this.getRender(column, record, index) | 54 | ? this.getRender(column, record, index) |
60 | : record[column.key]; | 55 | : record[column.key]; |
@@ -82,6 +77,13 @@ class Table { | @@ -82,6 +77,13 @@ class Table { | ||
82 | 77 | ||
83 | constructor() { | 78 | constructor() { |
84 | esNgAntd.createStyle("ant-table", style); | 79 | esNgAntd.createStyle("ant-table", style); |
80 | + // 初始化默认排序 | ||
81 | + this.props.columns.forEach((column) => { | ||
82 | + if (column.sortOrder) { | ||
83 | + this.state.sorter.field = column.key; | ||
84 | + this.state.sorter.order = column.sortOrder; | ||
85 | + } | ||
86 | + }); | ||
85 | } | 87 | } |
86 | 88 | ||
87 | getParameterName(fn) { | 89 | getParameterName(fn) { |
webpack.config.js
@@ -6,11 +6,11 @@ module.exports = { | @@ -6,11 +6,11 @@ module.exports = { | ||
6 | entry: "./build/index.js", | 6 | entry: "./build/index.js", |
7 | output: { | 7 | output: { |
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", |