Files
sgxt_web/src/components/MyComponents/Date/index.vue

54 lines
1.1 KiB
Vue
Raw Normal View History

2025-04-12 14:54:02 +08:00
<template>
<div class="form-item-box" :style="{ width: width }">
2025-07-23 15:33:11 +08:00
<el-date-picker
style="width:100%"
v-model="localModelValue"
:type="props.type"
v-bind="$attrs"
@change="onInput"
:placeholder="placeholder"
:value-format="props.format"
/>
2025-04-12 14:54:02 +08:00
</div>
</template>
<script setup>
import { COMPONENT_WIDTH } from "@/constant";
2025-07-23 15:33:11 +08:00
import { ref, defineProps, defineEmits, defineExpose, computed } from "vue";
2025-04-12 14:54:02 +08:00
const props = defineProps({
//获取组件传值
placeholder: {
default: "请填写",
type: String
},
2025-07-10 17:59:39 +08:00
format:{
default: "YYYY-MM-DD",
type: String
},
2025-04-12 14:54:02 +08:00
modelValue: {
default: "",
type: String
},
width: {
default: COMPONENT_WIDTH,
type: String
},
2025-07-23 15:33:11 +08:00
type: {
default: "date",
type: String
}
2025-04-12 14:54:02 +08:00
});
const emits = defineEmits(["update:modelValue"]);
2025-07-23 15:33:11 +08:00
// 使用计算属性处理双向绑定
const localModelValue = computed({
get: () => props.modelValue,
set: (value) => emits("update:modelValue", value)
});
2025-04-12 14:54:02 +08:00
const onInput = (e) => {
emits("update:modelValue", e);
};
2025-07-23 15:33:11 +08:00
</script>