riku
2025-09-18 c1d2051abc8ca88cd07f0d7c56c0dbf8165d5c33
src/components/search-option/FYOptionTime.vue
@@ -1,11 +1,14 @@
<template>
  <el-form-item label="时间" :prop="prop">
  <el-form-item :label="label" :prop="prop">
    <el-date-picker
      v-model="date"
      @change="handleChange"
      :type="type"
      placeholder="选择时间"
      start-placeholder="选择开始时间"
      end-placeholder="选择结束时间"
      style="width: 150px"
      v-bind="$attrs"
    />
  </el-form-item>
</template>
@@ -15,6 +18,8 @@
const MONTH = 'month';
const DATE = 'date';
const RANGE = 'datetimerange';
const RANGE2 = 'daterange';
export default {
  props: {
@@ -23,30 +28,37 @@
      default: MONTH
    },
    // 返回结果
    value: Date,
    value: Date || Array,
    // 是否默认返回初始选项
    initValue: {
      type: Boolean,
      default: true
    },
    prop: String
    label: {
      type: String,
      default: '时间'
    },
    prop: {
      type: String,
      default: 'time'
    }
  },
  emits: ['update:value'],
  emits: ['update:value', 'change'],
  data() {
    return {
      date: this.value
    };
  },
  computed:{
  },
  computed: {},
  methods: {
    handleChange(value) {
      this.$emit('update:value', value);
    },
      this.$emit('change', value);
    }
  },
  mounted() {
    if (this.initValue) {
      this.date = new Date()
      this.date = new Date();
      this.handleChange(this.date);
    }
  }