This commit is contained in:
lcw
2026-01-14 17:49:38 +08:00
parent 8cce4acf48
commit 32d7076e89
52 changed files with 620 additions and 481 deletions

View File

@ -1,16 +1,16 @@
<template>
<div class="form-item-box" :style="{ width: width }">
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'date'" v-model="modelValue" type="date" value-format="YYYY-MM-DD" placeholder="请选择日期" style="width:100%" />
<el-time-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'time'" v-model="modelValue" placeholder="选择时间" style="width:100%" />
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'datetime'" v-model="modelValue" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择时间" style="width:100%" />
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'datetimerange'" v-model="modelValue" type="datetimerange" :shortcuts="shortcuts" range-separator="To" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="选择开始时间" end-placeholder="选择结束时间" style="width:100%" />
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'daterange'" v-model="modelValue" type="daterange" range-separator="To" value-format="YYYY-MM-DD" start-placeholder="选择开始日期" end-placeholder="选择开始日期" style="width:100%" />
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'date'" v-model="localValue" type="date" value-format="YYYY-MM-DD" placeholder="请选择日期" style="width:100%" />
<el-time-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'time'" v-model="localValue" placeholder="选择时间" style="width:100%" />
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'datetime'" v-model="localValue" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择时间" style="width:100%" />
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'datetimerange'" v-model="localValue" type="datetimerange" :shortcuts="shortcuts" range-separator="To" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="选择开始时间" end-placeholder="选择结束时间" style="width:100%" />
<el-date-picker v-bind="$attrs" @change="changeTime" v-if="props.type == 'daterange'" v-model="localValue" type="daterange" range-separator="To" value-format="YYYY-MM-DD" start-placeholder="选择开始日期" end-placeholder="选择开始日期" style="width:100%" />
</div>
</template>
<script setup>
import { COMPONENT_WIDTH } from "@/constant";
import { defineProps, defineEmits } from "vue";
import { defineProps, defineEmits, ref, watch } from "vue";
const props = defineProps({
//获取组件传值
placeholder: {
@ -33,6 +33,19 @@ const props = defineProps({
const emits = defineEmits(["update:modelValue"]);
// 创建本地 ref 来绑定值
const localValue = ref(props.modelValue);
// 监听本地值变化emit 事件
watch(localValue, (newVal) => {
emits("update:modelValue", newVal);
});
// 监听 props 变化,更新本地值
watch(() => props.modelValue, (newVal) => {
localValue.value = newVal;
});
const shortcuts = [
{
text: "今天",

View File

@ -1,6 +1,6 @@
<template>
<div class="form-item-box" :style="{ width: width }">
<el-input :placeholder="placeholder" v-bind="$attrs" v-model="modelValue" @input="onInput" ></el-input>
<el-input :placeholder="placeholder" v-bind="$attrs" :model-value="modelValue" @input="onInput" ></el-input>
</div>
</template>

View File

@ -1,7 +1,7 @@
<template>
<div class="Select-wrap" :style="{ width: width }">
<el-select :disabled="props.disabled" v-bind="$attrs" v-model="modelValue" @change="hanlderSelect" :popper-class="selectOption.length > 20 ? 'nation-select' : ''" :placeholder="placeholder">
<el-select :disabled="props.disabled" v-bind="$attrs" :model-value="modelValue" @change="hanlderSelect" :popper-class="selectOption.length > 20 ? 'nation-select' : ''" :placeholder="placeholder">
<el-option v-for="item in dictEnum" :key="item.value" :label="item.zdmc || item.label" :value="item.dm || item.value">
</el-option>
</el-select>