Commit afd3509a89a8a8bf6bd6fd1f4d51ee03311cac66
1 parent
3b005863
update Transfer
update Transfer
Showing
3 changed files
with
51 additions
and
2 deletions
Show diff stats
src/components/transfer/search.vue
@@ -28,6 +28,14 @@ | @@ -28,6 +28,14 @@ | ||
28 | if (this.query === '') return; | 28 | if (this.query === '') return; |
29 | this.query = ''; | 29 | this.query = ''; |
30 | } | 30 | } |
31 | + }, | ||
32 | + events: { | ||
33 | + 'on-form-blur' () { | ||
34 | + return false; | ||
35 | + }, | ||
36 | + 'on-form-change' () { | ||
37 | + return false; | ||
38 | + } | ||
31 | } | 39 | } |
32 | }; | 40 | }; |
33 | </script> | 41 | </script> |
src/components/transfer/transfer.vue
@@ -172,6 +172,7 @@ | @@ -172,6 +172,7 @@ | ||
172 | 172 | ||
173 | this.$refs[opposite].toggleSelectAll(false); | 173 | this.$refs[opposite].toggleSelectAll(false); |
174 | this.$emit('on-change', newTargetKeys, direction, moveKeys); | 174 | this.$emit('on-change', newTargetKeys, direction, moveKeys); |
175 | + this.$dispatch('on-form-change', newTargetKeys, direction, moveKeys); | ||
175 | } | 176 | } |
176 | }, | 177 | }, |
177 | watch: { | 178 | watch: { |
test/routers/form.vue
1 | <template> | 1 | <template> |
2 | - <div style="width: 400px"> | 2 | + <div style="width: 600px"> |
3 | <i-form v-ref:form :model="form" :rules="rules" :label-width="100" label-position="right"> | 3 | <i-form v-ref:form :model="form" :rules="rules" :label-width="100" label-position="right"> |
4 | <form-item label="邮箱" prop="mail"> | 4 | <form-item label="邮箱" prop="mail"> |
5 | <i-input :value.sync="form.mail" placeholder="请输入邮箱"> | 5 | <i-input :value.sync="form.mail" placeholder="请输入邮箱"> |
@@ -158,6 +158,13 @@ | @@ -158,6 +158,13 @@ | ||
158 | <form-item label="级联" prop="cascader"> | 158 | <form-item label="级联" prop="cascader"> |
159 | <Cascader :data="data" :value.sync="form.cascader"></Cascader> | 159 | <Cascader :data="data" :value.sync="form.cascader"></Cascader> |
160 | </form-item> | 160 | </form-item> |
161 | + <form-item label="穿梭框" prop="targetKeys1"> | ||
162 | + <Transfer | ||
163 | + :data="form.transfer" | ||
164 | + :target-keys="form.targetKeys1" | ||
165 | + :render-format="render1" | ||
166 | + @on-change="handleChange1"></Transfer> | ||
167 | + </form-item> | ||
161 | <form-item> | 168 | <form-item> |
162 | <i-button type="primary" @click="onSubmit('form')">提交</i-button> | 169 | <i-button type="primary" @click="onSubmit('form')">提交</i-button> |
163 | </form-item> | 170 | </form-item> |
@@ -253,7 +260,9 @@ | @@ -253,7 +260,9 @@ | ||
253 | slider: [40, 50], | 260 | slider: [40, 50], |
254 | date: '', | 261 | date: '', |
255 | date2: '', | 262 | date2: '', |
256 | - cascader: [] | 263 | + cascader: [], |
264 | + transfer: this.getMockData(), | ||
265 | + targetKeys1: this.getTargetKeys() | ||
257 | }, | 266 | }, |
258 | rules: { | 267 | rules: { |
259 | mail: [ | 268 | mail: [ |
@@ -328,6 +337,11 @@ | @@ -328,6 +337,11 @@ | ||
328 | { | 337 | { |
329 | type: 'array', required: true | 338 | type: 'array', required: true |
330 | } | 339 | } |
340 | + ], | ||
341 | + targetKeys1: [ | ||
342 | + { | ||
343 | + type: 'array', min: 8, max: 10 | ||
344 | + } | ||
331 | ] | 345 | ] |
332 | } | 346 | } |
333 | } | 347 | } |
@@ -346,6 +360,32 @@ | @@ -346,6 +360,32 @@ | ||
346 | }, | 360 | }, |
347 | c (s) { | 361 | c (s) { |
348 | console.log(this.form.date) | 362 | console.log(this.form.date) |
363 | + }, | ||
364 | + getMockData () { | ||
365 | + let mockData = []; | ||
366 | + for (let i = 1; i <= 20; i++) { | ||
367 | + mockData.push({ | ||
368 | + key: i.toString(), | ||
369 | + label: '内容' + i, | ||
370 | + description: '内容' + i + '的描述信息', | ||
371 | + disabled: Math.random() * 3 < 1 | ||
372 | + }); | ||
373 | + } | ||
374 | + return mockData; | ||
375 | + }, | ||
376 | + getTargetKeys () { | ||
377 | + return this.getMockData() | ||
378 | + .filter(() => Math.random() * 2 > 1) | ||
379 | + .map(item => item.key); | ||
380 | + }, | ||
381 | + render1 (item) { | ||
382 | + return item.label; | ||
383 | + }, | ||
384 | + handleChange1 (newTargetKeys, direction, moveKeys) { | ||
385 | + console.log(newTargetKeys); | ||
386 | + console.log(direction); | ||
387 | + console.log(moveKeys); | ||
388 | + this.form.targetKeys1 = newTargetKeys; | ||
349 | } | 389 | } |
350 | } | 390 | } |
351 | }; | 391 | }; |