Commit 3b005863389ce544cf09b2ed428d1e30284f6d10
1 parent
ba3e34e0
update Cascader
update Cascader
Showing
3 changed files
with
65 additions
and
1 deletions
Show diff stats
src/components/cascader/cascader.vue
@@ -141,6 +141,7 @@ | @@ -141,6 +141,7 @@ | ||
141 | emitValue (val, oldVal) { | 141 | emitValue (val, oldVal) { |
142 | if (JSON.stringify(val) !== oldVal) { | 142 | if (JSON.stringify(val) !== oldVal) { |
143 | this.$emit('on-change', this.value, JSON.parse(JSON.stringify(this.selected))); | 143 | this.$emit('on-change', this.value, JSON.parse(JSON.stringify(this.selected))); |
144 | + this.$dispatch('on-form-change', this.value, JSON.parse(JSON.stringify(this.selected))); | ||
144 | } | 145 | } |
145 | } | 146 | } |
146 | }, | 147 | }, |
@@ -168,6 +169,12 @@ | @@ -168,6 +169,12 @@ | ||
168 | if (lastValue && !fromInit) { | 169 | if (lastValue && !fromInit) { |
169 | this.handleClose(); | 170 | this.handleClose(); |
170 | } | 171 | } |
172 | + }, | ||
173 | + 'on-form-blur' () { | ||
174 | + return false; | ||
175 | + }, | ||
176 | + 'on-form-change' () { | ||
177 | + return false; | ||
171 | } | 178 | } |
172 | }, | 179 | }, |
173 | watch: { | 180 | watch: { |
src/styles/components/cascader.less
test/routers/form.vue
@@ -155,6 +155,9 @@ | @@ -155,6 +155,9 @@ | ||
155 | <form-item label="两个日期" prop="date2"> | 155 | <form-item label="两个日期" prop="date2"> |
156 | <Date-picker :value.sync="form.date2" type="daterange" placement="bottom-start" placeholder="选择日期" @on-change="c"></Date-picker> | 156 | <Date-picker :value.sync="form.date2" type="daterange" placement="bottom-start" placeholder="选择日期" @on-change="c"></Date-picker> |
157 | </form-item> | 157 | </form-item> |
158 | + <form-item label="级联" prop="cascader"> | ||
159 | + <Cascader :data="data" :value.sync="form.cascader"></Cascader> | ||
160 | + </form-item> | ||
158 | <form-item> | 161 | <form-item> |
159 | <i-button type="primary" @click="onSubmit('form')">提交</i-button> | 162 | <i-button type="primary" @click="onSubmit('form')">提交</i-button> |
160 | </form-item> | 163 | </form-item> |
@@ -166,6 +169,53 @@ | @@ -166,6 +169,53 @@ | ||
166 | props: {}, | 169 | props: {}, |
167 | data () { | 170 | data () { |
168 | return { | 171 | return { |
172 | + data: [{ | ||
173 | + value: 'beijing', | ||
174 | + label: '北京', | ||
175 | + children: [ | ||
176 | + { | ||
177 | + value: 'gugong', | ||
178 | + label: '故宫' | ||
179 | + }, | ||
180 | + { | ||
181 | + value: 'tiantan', | ||
182 | + label: '天坛' | ||
183 | + }, | ||
184 | + { | ||
185 | + value: 'wangfujing', | ||
186 | + label: '王府井' | ||
187 | + } | ||
188 | + ] | ||
189 | + }, { | ||
190 | + value: 'jiangsu', | ||
191 | + label: '江苏', | ||
192 | + children: [ | ||
193 | + { | ||
194 | + value: 'nanjing', | ||
195 | + label: '南京', | ||
196 | + children: [ | ||
197 | + { | ||
198 | + value: 'fuzimiao', | ||
199 | + label: '夫子庙', | ||
200 | + } | ||
201 | + ] | ||
202 | + }, | ||
203 | + { | ||
204 | + value: 'suzhou', | ||
205 | + label: '苏州', | ||
206 | + children: [ | ||
207 | + { | ||
208 | + value: 'zhuozhengyuan', | ||
209 | + label: '拙政园', | ||
210 | + }, | ||
211 | + { | ||
212 | + value: 'shizilin', | ||
213 | + label: '狮子林', | ||
214 | + } | ||
215 | + ] | ||
216 | + } | ||
217 | + ], | ||
218 | + }], | ||
169 | cityList: [ | 219 | cityList: [ |
170 | { | 220 | { |
171 | value: 'beijing', | 221 | value: 'beijing', |
@@ -202,7 +252,8 @@ | @@ -202,7 +252,8 @@ | ||
202 | selectm: [], | 252 | selectm: [], |
203 | slider: [40, 50], | 253 | slider: [40, 50], |
204 | date: '', | 254 | date: '', |
205 | - date2: '' | 255 | + date2: '', |
256 | + cascader: [] | ||
206 | }, | 257 | }, |
207 | rules: { | 258 | rules: { |
208 | mail: [ | 259 | mail: [ |
@@ -272,6 +323,11 @@ | @@ -272,6 +323,11 @@ | ||
272 | } | 323 | } |
273 | } | 324 | } |
274 | } | 325 | } |
326 | + ], | ||
327 | + cascader: [ | ||
328 | + { | ||
329 | + type: 'array', required: true | ||
330 | + } | ||
275 | ] | 331 | ] |
276 | } | 332 | } |
277 | } | 333 | } |