Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature branch name #527

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/pages/datetimePicker/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<demo-block transparent>
<wd-cell-group border>
<wd-datetime-picker label="日期选择" v-model="value1" @confirm="handleConfirm1" />

<wd-datetime-picker label="年月日" v-model="value2" type="date" @confirm="handleConfirm2" />
<wd-datetime-picker label="年月" v-model="value3" type="year-month" @confirm="handleConfirm3" />
<wd-datetime-picker label="年" v-model="value16" type="year" @confirm="handleConfirm16" />
Expand Down Expand Up @@ -33,6 +34,13 @@
<demo-block title="范围tab展示格式" transparent>
<wd-datetime-picker label="日期选择" v-model="value15" @confirm="handleConfirm15" :display-format-tab-label="displayFormatTabLabel" />
</demo-block>
<demo-block title="清空日期" transparen>
<wd-datetime-picker label="清空日期" v-model="value18" @confirm="handleConfirm1" :use-icon-slot="Boolean(value18)">
<template #icon>
<wd-icon name="close" @click.stop="clear" v-if="value18"></wd-icon>
</template>
</wd-datetime-picker>
</demo-block>
</page-wraper>
</template>
<script lang="ts" setup>
Expand Down Expand Up @@ -62,6 +70,7 @@ const value14 = ref<any[]>(['', ''])
const value15 = ref<any[]>(['', Date.now()])
const value16 = ref(Date.now())
const value17 = ref(Date.now())
const value18 = ref(Date.now())

const minDate = ref<number>(Date.now())
const maxDate = ref<number>(new Date(new Date().getFullYear() + 1, new Date().getMonth(), new Date().getDate()).getTime())
Expand Down Expand Up @@ -160,5 +169,10 @@ function handleConfirm16({ value }: any) {
}
/** picker触发cancel事件,同步触发cancel事件 */
function onCancel() {}

/* */
function clear() {
value18.value = ''
}
</script>
<style lang="scss" scoped></style>
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ export const datetimePickerProps = {
/**
* 是否在手指松开时立即触发picker-view的 change 事件。若不开启则会在滚动动画结束后触发 change 事件,1.2.25版本起提供,仅微信小程序和支付宝小程序支持。
*/
immediateChange: makeBooleanProp(false)
immediateChange: makeBooleanProp(false),
/**
* 是否开启清空功能
*/
useIconSlot: makeBooleanProp(false)
}

export type DatetimePickerDisplayFormat = (items: Record<string, any>[]) => string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
{{ showValue ? showValue : placeholder || translate('placeholder') }}
</view>
</view>
<wd-icon v-if="!disabled && !readonly" custom-class="wd-picker__arrow" name="arrow-right" />
<slot v-if="useIconSlot" name="icon" custom-class="wd-picker__arrow"></slot>
<wd-icon v-if="!disabled && !readonly && !useIconSlot" custom-class="wd-picker__arrow" name="arrow-right" />
</view>
<view v-if="errorMessage" class="wd-picker__error-message">{{ errorMessage }}</view>
</view>
Expand Down