初始版本提交

This commit is contained in:
yaoyn
2024-02-05 09:15:37 +08:00
parent b52d4414be
commit 445292105f
1848 changed files with 236859 additions and 75 deletions

View File

@ -0,0 +1,4 @@
import { withInstall } from '/@/utils/index';
import datepicker from './src/DatePicker.vue';
export const XjrDatePicker = withInstall(datepicker);

View File

@ -0,0 +1,58 @@
<template>
<a-date-picker
:size="size"
v-model:value="modelValue"
:placeholder="placeholder"
:format="format"
:valueFormat="format"
:allowClear="allowClear"
:disabled="disabled"
:showTime="format === 'YYYY-MM-DD HH:mm:ss'"
:picker="picker"
@change="handleChange"
/>
</template>
<script lang="ts" setup>
import dayjs from 'dayjs';
import { ref, watch, computed } from 'vue';
const props = defineProps({
value: [dayjs, String, Object],
size: String,
placeholder: String,
format: String,
allowClear: Boolean,
disabled: Boolean,
});
const modelValue = ref<string>();
const emit = defineEmits(['update:value']);
const picker = computed(() => {
let time = 'date';
switch (props.format) {
case 'YYYY-MM':
time = 'month';
break;
case 'YYYY':
time = 'year';
break;
}
return time;
});
watch(
() => props.value,
(val) => {
if (val && typeof val !== 'string') {
modelValue.value = val?.format(props.format);
} else {
modelValue.value = val || '';
}
},
{
immediate: true,
},
);
const handleChange = (time) => {
emit('update:value', time);
};
</script>