Commit ecaf8d51e05b2b18e3d72ba700f1c108ea2b0cbe
1 parent
595cfa72
Date add transfer prop
Showing
6 changed files
with
71 additions
and
38 deletions
Show diff stats
examples/routers/date.vue
1 | 1 | <template> |
2 | 2 | <div> |
3 | - <Date-picker type="daterange" placeholder="选择日期" style="width: 200px"></Date-picker> | |
3 | + <Date-picker transfer type="daterange" placeholder="选择日期" style="width: 200px"></Date-picker> | |
4 | 4 | <Date-picker type="daterange" placeholder="选择日期" style="width: 200px"></Date-picker> |
5 | 5 | <Date-picker type="daterange" placeholder="选择日期" style="width: 200px"></Date-picker> |
6 | 6 | </div> | ... | ... |
examples/routers/modal.vue
... | ... | @@ -5,7 +5,8 @@ |
5 | 5 | <Modal v-model="showModal" title="弹窗"> |
6 | 6 | <Tabs> |
7 | 7 | <Tab-pane label="演示" style="height: 80px;"> |
8 | - <i-select transfer> | |
8 | + <Date-picker transfer type="daterange" placement="bottom-end" placeholder="选择日期" style="width: 200px"></Date-picker> | |
9 | + <i-select transfer multiple v-model="m1"> | |
9 | 10 | <i-option v-for="item in options" :value="item.value" :key="item.value">{{ item.label }}</i-option> |
10 | 11 | </i-select> |
11 | 12 | </Tab-pane> |
... | ... | @@ -22,6 +23,7 @@ |
22 | 23 | export default { |
23 | 24 | data () { |
24 | 25 | return { |
26 | + m1: [], | |
25 | 27 | showModal: false, |
26 | 28 | showModal2: false, |
27 | 29 | options: [ | ... | ... |
examples/routers/select.vue
1 | 1 | <template> |
2 | - <Row> | |
3 | - <Col span="12" style="padding-right:10px"> | |
4 | - <Select | |
5 | - v-model="model13" | |
6 | - filterable | |
7 | - remote | |
8 | - :remote-method="remoteMethod1" | |
9 | - :loading="loading1"> | |
10 | - <Option v-for="(option, index) in options1" :value="option.value" :key="index">{{option.label}}</Option> | |
11 | - </Select> | |
12 | - </Col> | |
13 | - <Col span="12"> | |
14 | - <Select | |
15 | - v-model="model14" | |
16 | - multiple | |
17 | - filterable | |
18 | - remote | |
19 | - :remote-method="remoteMethod2" | |
20 | - :loading="loading2"> | |
21 | - <Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option> | |
22 | - </Select> | |
23 | - </Col> | |
24 | - </Row> | |
2 | + <i-select transfer multiple v-model="m1"> | |
3 | + <i-option v-for="item in options" :value="item.value" :key="item.value">{{ item.label }}</i-option> | |
4 | + </i-select> | |
25 | 5 | </template> |
26 | 6 | <script> |
27 | 7 | export default { |
28 | 8 | data () { |
29 | 9 | return { |
30 | - model13: '', | |
31 | - loading1: false, | |
32 | - options1: [], | |
33 | - model14: [], | |
34 | - loading2: false, | |
35 | - options2: [], | |
36 | - list: ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New hampshire', 'New jersey', 'New mexico', 'New york', 'North carolina', 'North dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode island', 'South carolina', 'South dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West virginia', 'Wisconsin', 'Wyoming'], | |
10 | + m1: [], | |
11 | + showModal: false, | |
12 | + showModal2: false, | |
13 | + options: [ | |
14 | + { | |
15 | + value: 'beijing', | |
16 | + label: '北京市' | |
17 | + }, | |
18 | + { | |
19 | + value: 'shanghai', | |
20 | + label: '上海市' | |
21 | + }, | |
22 | + { | |
23 | + value: 'shenzhen', | |
24 | + label: '深圳市' | |
25 | + }, | |
26 | + { | |
27 | + value: 'hangzhou', | |
28 | + label: '杭州市' | |
29 | + }, | |
30 | + { | |
31 | + value: 'nanjing', | |
32 | + label: '南京市' | |
33 | + }, | |
34 | + { | |
35 | + value: 'chongqing', | |
36 | + label: '重庆市' | |
37 | + } | |
38 | + ] | |
37 | 39 | } |
38 | 40 | }, |
39 | 41 | methods: { | ... | ... |
src/components/date-picker/picker.vue
1 | 1 | <template> |
2 | - <div | |
3 | - :class="[prefixCls]" | |
4 | - v-clickoutside="handleClose"> | |
2 | + <div :class="[prefixCls]" v-clickoutside="handleClose"> | |
5 | 3 | <div ref="reference" :class="[prefixCls + '-rel']"> |
6 | 4 | <slot> |
7 | 5 | <i-input |
... | ... | @@ -20,7 +18,14 @@ |
20 | 18 | </slot> |
21 | 19 | </div> |
22 | 20 | <transition :name="transition"> |
23 | - <Drop v-show="opened" :placement="placement" ref="drop"> | |
21 | + <Drop | |
22 | + @click.native="handleTransferClick" | |
23 | + v-show="opened" | |
24 | + :class="{ [prefixCls + '-transfer']: transfer }" | |
25 | + :placement="placement" | |
26 | + ref="drop" | |
27 | + :data-transfer="transfer" | |
28 | + v-transfer-dom> | |
24 | 29 | <div ref="picker"></div> |
25 | 30 | </Drop> |
26 | 31 | </transition> |
... | ... | @@ -31,6 +36,7 @@ |
31 | 36 | import iInput from '../../components/input/input.vue'; |
32 | 37 | import Drop from '../../components/select/dropdown.vue'; |
33 | 38 | import clickoutside from '../../directives/clickoutside'; |
39 | + import TransferDom from '../../directives/transfer-dom'; | |
34 | 40 | import { oneOf } from '../../utils/assist'; |
35 | 41 | import { formatDate, parseDate } from './util'; |
36 | 42 | import Emitter from '../../mixins/emitter'; |
... | ... | @@ -142,7 +148,7 @@ |
142 | 148 | name: 'CalendarPicker', |
143 | 149 | mixins: [ Emitter ], |
144 | 150 | components: { iInput, Drop }, |
145 | - directives: { clickoutside }, | |
151 | + directives: { clickoutside, TransferDom }, | |
146 | 152 | props: { |
147 | 153 | format: { |
148 | 154 | type: String |
... | ... | @@ -188,6 +194,10 @@ |
188 | 194 | }, |
189 | 195 | options: { |
190 | 196 | type: Object |
197 | + }, | |
198 | + transfer: { | |
199 | + type: Boolean, | |
200 | + default: false | |
191 | 201 | } |
192 | 202 | }, |
193 | 203 | data () { |
... | ... | @@ -198,6 +208,7 @@ |
198 | 208 | picker: null, |
199 | 209 | internalValue: '', |
200 | 210 | disableClickOutSide: false, // fixed when click a date,trigger clickoutside to close picker |
211 | + disableCloseUnderTransfer: false, // transfer 模式下,点击Drop也会触发关闭 | |
201 | 212 | currentValue: this.value |
202 | 213 | }; |
203 | 214 | }, |
... | ... | @@ -258,7 +269,15 @@ |
258 | 269 | } |
259 | 270 | }, |
260 | 271 | methods: { |
272 | + // 开启 transfer 时,点击 Drop 即会关闭,这里不让其关闭 | |
273 | + handleTransferClick () { | |
274 | + if (this.transfer) this.disableCloseUnderTransfer = true; | |
275 | + }, | |
261 | 276 | handleClose () { |
277 | + if (this.disableCloseUnderTransfer) { | |
278 | + this.disableCloseUnderTransfer = false; | |
279 | + return false; | |
280 | + } | |
262 | 281 | if (this.open !== null) return; |
263 | 282 | // if (!this.disableClickOutSide) this.visible = false; |
264 | 283 | this.visible = false; | ... | ... |
src/components/select/select.vue
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | </div> |
27 | 27 | <transition :name="transitionName"> |
28 | 28 | <Drop |
29 | - :class="{ [prefixCls + '-dropdown-transfer']: transfer }" | |
29 | + :class="dropdownCls" | |
30 | 30 | v-show="dropVisible" |
31 | 31 | :placement="placement" |
32 | 32 | ref="dropdown" |
... | ... | @@ -157,6 +157,12 @@ |
157 | 157 | } |
158 | 158 | ]; |
159 | 159 | }, |
160 | + dropdownCls () { | |
161 | + return { | |
162 | + [prefixCls + '-dropdown-transfer']: this.transfer, | |
163 | + [prefixCls + '-multiple']: this.multiple && this.transfer | |
164 | + }; | |
165 | + }, | |
160 | 166 | showPlaceholder () { |
161 | 167 | let status = false; |
162 | 168 | ... | ... |