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 | 46 | |
47 | 47 | $scope.handleClick = function ($event) { |
48 | 48 | $scope.state.checked = !$scope.state.checked; |
49 | - $event.target.checked = $scope.state.checked; | |
50 | 49 | $scope.onChange({ |
51 | 50 | event: $event, |
52 | 51 | }); | ... | ... |
build/Pagination/Pagination.js
... | ... | @@ -34,9 +34,10 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { |
34 | 34 | defaultPageSize: $scope.defaultPageSize || 10, |
35 | 35 | }; |
36 | 36 | $scope.watch = { |
37 | - total: function (newVal, oldVal) { | |
38 | - if (newVal && oldVal) { | |
37 | + total: function (newVal) { | |
38 | + if (newVal) { | |
39 | 39 | $scope.state.total = Number(newVal); |
40 | + $scope.reset(); | |
40 | 41 | $scope.state.pageNum = $scope.getPageNum(); |
41 | 42 | $scope.state.pageNumList = $scope.getPageNumList(); |
42 | 43 | } |
... | ... | @@ -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 | 74 | $scope.getPageNumList = function () { |
70 | 75 | let pageNumList = [$scope.state.current]; |
71 | 76 | let pageNum = $scope.getPageNum(); |
... | ... | @@ -137,7 +142,7 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { |
137 | 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 | 148 | $scope.handlePrev = function () { |
... | ... | @@ -145,7 +150,7 @@ angular.module("esNgAntd").directive("antdPagination", function (esNgAntd) { |
145 | 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 | 156 | $scope.handleClick = function (value) { | ... | ... |
build/Table/Table.js
... | ... | @@ -59,13 +59,6 @@ angular.module("esNgAntd").directive("antdTable", function (esNgAntd) { |
59 | 59 | } |
60 | 60 | |
61 | 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 | 62 | row[column.key] = column.render |
70 | 63 | ? $scope.getRender(column, record, index) |
71 | 64 | : record[column.key]; |
... | ... | @@ -213,7 +206,14 @@ angular.module("esNgAntd").directive("antdTable", function (esNgAntd) { |
213 | 206 | }; |
214 | 207 | }, |
215 | 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 | 30 | }; |
31 | 31 | |
32 | 32 | watch = { |
33 | - total: function (newVal, oldVal) { | |
34 | - if (newVal && oldVal) { | |
33 | + total: function (newVal) { | |
34 | + if (newVal) { | |
35 | 35 | this.state.total = Number(newVal); |
36 | + this.reset(); | |
36 | 37 | this.state.pageNum = this.getPageNum(); |
37 | 38 | this.state.pageNumList = this.getPageNumList(); |
38 | 39 | } |
... | ... | @@ -70,6 +71,10 @@ class Pagination { |
70 | 71 | } |
71 | 72 | } |
72 | 73 | |
74 | + reset() { | |
75 | + this.state.current = 1; | |
76 | + } | |
77 | + | |
73 | 78 | getPageNumList() { |
74 | 79 | let pageNumList = [this.state.current]; |
75 | 80 | let pageNum = this.getPageNum(); |
... | ... | @@ -127,14 +132,14 @@ class Pagination { |
127 | 132 | if (this.state.current === this.state.pageNum) { |
128 | 133 | return false; |
129 | 134 | } |
130 | - this.handleClick(++this.state.current); | |
135 | + this.handleClick(this.state.current+1); | |
131 | 136 | } |
132 | 137 | |
133 | 138 | handlePrev() { |
134 | 139 | if (this.state.current === 1) { |
135 | 140 | return false; |
136 | 141 | } |
137 | - this.handleClick(--this.state.current); | |
142 | + this.handleClick(this.state.current-1); | |
138 | 143 | } |
139 | 144 | |
140 | 145 | handleClick(value) { | ... | ... |
src/Table/Table.js
... | ... | @@ -50,11 +50,6 @@ class Table { |
50 | 50 | row = Object.assign(row, extraAttr); |
51 | 51 | } |
52 | 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 | 53 | row[column.key] = column.render |
59 | 54 | ? this.getRender(column, record, index) |
60 | 55 | : record[column.key]; |
... | ... | @@ -82,6 +77,13 @@ class Table { |
82 | 77 | |
83 | 78 | constructor() { |
84 | 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 | 89 | getParameterName(fn) { | ... | ... |
webpack.config.js
... | ... | @@ -6,11 +6,11 @@ module.exports = { |
6 | 6 | entry: "./build/index.js", |
7 | 7 | output: { |
8 | 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 | 10 | // boss |
11 | 11 | // path: "/Users/shann/Project/essa/boss/trunk/vendor-lib/ng-antd", |
12 | 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 | 14 | // local |
15 | 15 | // path: path.resolve(__dirname, "dist"), |
16 | 16 | filename: "ng-antd.js", | ... | ... |