[新增] datePicker组件添加simple属性,用于快速交互

This commit is contained in:
castleiMac 2022-04-04 10:24:54 +08:00
parent 1e055e90b3
commit 015f49ceb0
2 changed files with 40 additions and 4 deletions

View File

@ -195,6 +195,35 @@ export default {
:::
::: title 一次性选择
:::
::: describe 只需要点击一次后自动关闭,无需点击确认按钮
:::
::: demo
<template>
<lay-date-picker v-model="endTime7" simple></lay-date-picker>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
const endTime7 = ref("2022-03-04 17:35:00");
return {
endTime7
}
}
}
</script>
:::
::: title Date Picker 属性
:::
@ -205,6 +234,7 @@ export default {
| v-model | 当前时间 | `string` | -- | — |
| type | 选择类型 | `string` | `date` | `date` `datetime` `year` `month` `time` `yearmonth` |
| disabled | 是否禁止修改 | `boolean` | false | — |
| simple | 一次性选择,无需点击确认按钮 | `boolean` | false | — |
:::

View File

@ -219,13 +219,15 @@ export interface LayDatePickerProps {
name?: string;
max?: string;
min?: string;
disabled?: boolean
disabled?: boolean;
simple?: boolean
}
const props = withDefaults(defineProps<LayDatePickerProps>(), {
modelValue: "",
type: "date",
disabled: false
disabled: false,
simple: false,
});
const dropdownRef = ref(null);
@ -316,6 +318,9 @@ const dateValue = computed<string>(() => {
break;
}
$emits("update:modelValue", momentVal);
if (props.simple) {
ok()
}
return momentVal;
});
@ -372,8 +377,9 @@ watch(
//
const ok = () => {
// @ts-ignore
dropdownRef.value.hide();
if (dropdownRef.value)
// @ts-ignore
dropdownRef.value.hide();
};
//