Date Picker

ADempiereMarch 21, 2023
About 2 min

Use `format` to control displayed text's `format` in the input box. Use `value-format` to control binding value's format.

By default, the component accepts and emits a Date object.

Check the list here of all available formats of Day.js.

Note

Pay attention to capitalization

Emits Date object
Value:
Use value-format
Value๏ผš
Timestamp
Value๏ผš

Viwer Source

<template>
  <div class="demo-date-picker">
    <div class="block">
      <span class="demonstration">Emits Date object</span>
      <div class="demonstration">Value: {{ value1 }}</div>
      <field-date-picker
        v-model="value1"
        type="date"
        placeholder="Pick a Date"
        format="YYYY/MM/DD"
      />
    </div>
    <div class="block">
      <span class="demonstration">Use value-format</span>
      <div class="demonstration">Value๏ผš{{ value2 }}</div>
      <field-date-picker
        v-model="value2"
        type="date"
        placeholder="Pick a Date"
        format="YYYY/MM/DD"
        value-format="YYYY-MM-DD"
      />
    </div>
    <div class="block">
      <span class="demonstration">Timestamp</span>
      <div class="demonstration">Value๏ผš{{ value3 }}</div>
      <field-date-picker
        v-model="value3"
        type="date"
        placeholder="Pick a Date"
        format="YYYY/MM/DD"
        value-format="x"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

const value1 = ref('')
const value2 = ref('')
const value3 = ref('')
</script>
<style scoped>
.demo-date-picker {
  display: flex;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
}
.demo-date-picker .block {
  padding: 30px 0;
  text-align: center;
  border-right: solid 1px var(--el-border-color);
  flex: 1;
}
.demo-date-picker .block:last-child {
  border-right: none;
}
.demo-date-picker .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
</style>

Props

NameDescriptionTypeMandatory
typetype of the pickerstringTrue

Attributes

NameDescriptionTypeDefault
valuebinding value, if it is an array, the length should be 2Date / number / string / Arrayโ€”โ€”โ€”โ€”โ€”โ€”
formatformat of the displayed value in the input boxstringYYYY-MM-DD
shortcutsan object array to set shortcut optionsArrayโ€”โ€”โ€”โ€”โ€”โ€”
placeholderplaceholder in non-range modestringโ€”โ€”โ€”โ€”โ€”โ€”
startPlaceholderplaceholder in non-range modestringโ€”โ€”โ€”โ€”โ€”โ€”
endPlaceholderplaceholder in non-range modestringโ€”โ€”โ€”โ€”โ€”โ€”
disabledwhether Switch is disabledbooleanFalse
clearablewhether to show clear buttonbooleanFalse
sizesize of Switch large / default / smallstringdefault

Slots

NameDescription
headerCustomize Default Content Top
footerCustomize Default Content Bottom

Example for Developer

Open in StackBlitzopen in new window

Directory

  โ””โ”€ src                                            # Main source code.
      โ””โ”€โ”€ Components                                # Global components
              โ””โ”€โ”€ Atoms                             # Atom components
                  โ””โ”€โ”€ FieldDatePicker               # Field DatePicker specific components.