<template>
  <LabelBox
    :label="formItems.attrs?.label"
    :need-star="formItems.attrs?.needStar"
    :width="formItems.attrs?.width"
  >
    <el-date-picker
      class="datePicker"
      size="mini"
      :value="value"
      :placeholder="formItems.attrs?.placeholder || '选择日期'"
      v-bind="formItems.attrs"
      format="yyyy-MM-dd"
      value-format="yyyyMMdd"
      style="width:100%"
      v-on="formItems.events"
      @input="handleInput"
    />
  </LabelBox>
</template>

<script>
import LabelBox from '../labelBox/index.vue';

export default {
  components: {
    LabelBox,
  },
  props: {
    formItems: {
      type: Object,
      default: () => {},
    },
    value: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      formItems: {},
    };
  },
  watch: {
    formItems(newval) {
      this.formItems = newval;
    },
  },
  methods: {
    handleInput(val) {
      console.log('我是val', val);
      this.$emit('input', val);
      this.$emit('outOperation', val);
    },
  },
};
</script>
<style lang="scss" scoped>
// ::v-deep.el-range-editor {
//   height: 20px;
// }

::v-deep.el-range-editor.el-input__inner {
  height: 24px;
}

::v-deep.el-date-editor--daterange.el-input__inner,
.eui-theme-default .el-date-editor--timerange.el-input,
.eui-theme-default .el-date-editor--timerange.el-input__inner {
  width: 100%;
}

::v-deep.el-range-editor--mini .el-range-separator {
  line-height: 16px;
}
::v-deep.el-range-editor--mini .el-range__icon {
  line-height: 16px;
}

// 修复placeholder与日期图标重合的样式
::v-deep.el-input .el-input__icon {
  height: 24px;
  line-height: 25px;
  margin-left: -6px;
}

::v-deep.el-input .el-input-group__prepend {
  box-sizing: border-box;
  padding: 0 10px;
  height: 24px;
  line-height: 24px;
  border: none;
}

::v-deep.el-input .el-input__inner {
  height: 24px;
  line-height: 24px;
}

::v-deep.el-input--prefix .el-input__inner {
  padding-left: 19px;
}
</style>

