|
94 | 94 |
|
95 | 95 | watch: { |
96 | 96 | curProvince (val, oldVal) { |
97 | | - this.isSetDefault = true; |
| 97 | + this.provinceChange(val); |
| 98 | + }, |
| 99 | +
|
| 100 | + curCity (val, oldVal) { |
| 101 | + this.cityChange(val); |
| 102 | + }, |
| 103 | + |
| 104 | + curArea (val, oldVal) { |
| 105 | + this.areaChange(val); |
| 106 | + }, |
| 107 | +
|
| 108 | + curStreet (val, oldVal) { |
| 109 | + this.streetChange(val); |
| 110 | + }, |
| 111 | +
|
| 112 | + value () { |
| 113 | + if (isArray(this.value) && this.value.length && !this.isSetDefault) { |
| 114 | + this.beforeSetDefault(); |
| 115 | + this.setDefaultValue(); |
| 116 | + this.provinceChange(this.curProvince); |
| 117 | + } |
| 118 | + } |
| 119 | + }, |
| 120 | +
|
| 121 | + methods: { |
| 122 | + provinceChange (val) { |
98 | 123 | if (this.level === 0) { |
99 | 124 | this.selectChange(); |
100 | 125 | return; |
|
114 | 139 | } else { |
115 | 140 | this.curCity = Object.keys(this.citys)[0]; |
116 | 141 | } |
| 142 | + this.cityChange(this.curCity); |
117 | 143 | } |
118 | 144 | }, |
119 | 145 |
|
120 | | - curCity (val, oldVal) { |
| 146 | + cityChange (val) { |
121 | 147 | if (this.level === 1) { |
122 | 148 | this.selectChange(); |
123 | 149 | return; |
|
138 | 164 | // fix 市级下不存在城区(#7) |
139 | 165 | this.curArea = this.areas ? Object.keys(this.areas)[0] : val; |
140 | 166 | } |
| 167 | + this.areaChange(this.curArea); |
141 | 168 | } |
142 | 169 | }, |
143 | | - |
144 | | - curArea (val, oldVal) { |
| 170 | +
|
| 171 | + areaChange (val) { |
145 | 172 | if (!/^\d+$/.test(String(val))) { |
146 | 173 | return; |
147 | 174 | } |
|
165 | 192 | } else { |
166 | 193 | this.curStreet = this.streets ? Object.keys(this.streets)[0] : val; |
167 | 194 | } |
| 195 | + this.streetChange(this.curStreet); |
168 | 196 | } |
169 | 197 | }, |
170 | 198 |
|
171 | | - curStreet (val, oldVal) { |
| 199 | + streetChange (val) { |
172 | 200 | if (!/^\d+$/.test(String(val))) { |
173 | 201 | return; |
174 | 202 | } |
175 | 203 | this.curStreetCode = val; |
176 | 204 | this.selectChange(); |
177 | 205 | }, |
178 | 206 |
|
179 | | - value () { |
180 | | - if (isArray(this.value) && this.value.length && !this.isSetDefault) { |
181 | | - this.beforeSetDefault(); |
182 | | - this.setDefaultValue(); |
183 | | - } |
184 | | - } |
185 | | - }, |
186 | | -
|
187 | | - methods: { |
188 | 207 | getAreaText (selected) { |
189 | 208 | const texts = []; |
190 | 209 | let city = ''; |
|
269 | 288 | this.$nextTick(() => { |
270 | 289 | this.defaults = []; |
271 | 290 | this.isCode = false; |
| 291 | + this.isSetDefault = false; |
272 | 292 | }); |
273 | 293 | }, |
274 | 294 |
|
|
0 commit comments