Date add transfer prop
This commit is contained in:
parent
595cfa72fe
commit
ecaf8d51e0
6 changed files with 71 additions and 38 deletions
|
@ -1,7 +1,5 @@
|
|||
<template>
|
||||
<div
|
||||
:class="[prefixCls]"
|
||||
v-clickoutside="handleClose">
|
||||
<div :class="[prefixCls]" v-clickoutside="handleClose">
|
||||
<div ref="reference" :class="[prefixCls + '-rel']">
|
||||
<slot>
|
||||
<i-input
|
||||
|
@ -20,7 +18,14 @@
|
|||
</slot>
|
||||
</div>
|
||||
<transition :name="transition">
|
||||
<Drop v-show="opened" :placement="placement" ref="drop">
|
||||
<Drop
|
||||
@click.native="handleTransferClick"
|
||||
v-show="opened"
|
||||
:class="{ [prefixCls + '-transfer']: transfer }"
|
||||
:placement="placement"
|
||||
ref="drop"
|
||||
:data-transfer="transfer"
|
||||
v-transfer-dom>
|
||||
<div ref="picker"></div>
|
||||
</Drop>
|
||||
</transition>
|
||||
|
@ -31,6 +36,7 @@
|
|||
import iInput from '../../components/input/input.vue';
|
||||
import Drop from '../../components/select/dropdown.vue';
|
||||
import clickoutside from '../../directives/clickoutside';
|
||||
import TransferDom from '../../directives/transfer-dom';
|
||||
import { oneOf } from '../../utils/assist';
|
||||
import { formatDate, parseDate } from './util';
|
||||
import Emitter from '../../mixins/emitter';
|
||||
|
@ -142,7 +148,7 @@
|
|||
name: 'CalendarPicker',
|
||||
mixins: [ Emitter ],
|
||||
components: { iInput, Drop },
|
||||
directives: { clickoutside },
|
||||
directives: { clickoutside, TransferDom },
|
||||
props: {
|
||||
format: {
|
||||
type: String
|
||||
|
@ -188,6 +194,10 @@
|
|||
},
|
||||
options: {
|
||||
type: Object
|
||||
},
|
||||
transfer: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
|
@ -198,6 +208,7 @@
|
|||
picker: null,
|
||||
internalValue: '',
|
||||
disableClickOutSide: false, // fixed when click a date,trigger clickoutside to close picker
|
||||
disableCloseUnderTransfer: false, // transfer 模式下,点击Drop也会触发关闭
|
||||
currentValue: this.value
|
||||
};
|
||||
},
|
||||
|
@ -258,7 +269,15 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
// 开启 transfer 时,点击 Drop 即会关闭,这里不让其关闭
|
||||
handleTransferClick () {
|
||||
if (this.transfer) this.disableCloseUnderTransfer = true;
|
||||
},
|
||||
handleClose () {
|
||||
if (this.disableCloseUnderTransfer) {
|
||||
this.disableCloseUnderTransfer = false;
|
||||
return false;
|
||||
}
|
||||
if (this.open !== null) return;
|
||||
// if (!this.disableClickOutSide) this.visible = false;
|
||||
this.visible = false;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
<transition :name="transitionName">
|
||||
<Drop
|
||||
:class="{ [prefixCls + '-dropdown-transfer']: transfer }"
|
||||
:class="dropdownCls"
|
||||
v-show="dropVisible"
|
||||
:placement="placement"
|
||||
ref="dropdown"
|
||||
|
@ -157,6 +157,12 @@
|
|||
}
|
||||
];
|
||||
},
|
||||
dropdownCls () {
|
||||
return {
|
||||
[prefixCls + '-dropdown-transfer']: this.transfer,
|
||||
[prefixCls + '-multiple']: this.multiple && this.transfer
|
||||
};
|
||||
},
|
||||
showPlaceholder () {
|
||||
let status = false;
|
||||
|
||||
|
|
|
@ -191,6 +191,10 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
&-transfer{
|
||||
z-index: @zindex-transfer;
|
||||
max-height: none;
|
||||
}
|
||||
}
|
||||
|
||||
.@{picker-prefix-cls} {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue