<template>
  <el-form-item :label="i18nt('designer.setting.displayType')">
    <el-select v-model="optionModel.type" @change="changeType">
      <el-option label="datetime" value="datetime"></el-option>
      <el-option label="date" value="date"></el-option>
      <el-option label="dates" value="dates"></el-option>
      <el-option label="year" value="year"></el-option>
      <el-option label="month" value="month"></el-option>
      <el-option label="week" value="week"></el-option>
    </el-select>
  </el-form-item>
</template>

<script>
import i18n from "../../../../../../components/xform/utils/i18n";

export default {
  name: "date-type-editor",
  mixins: [i18n],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },
  methods: {
    changeType(val) {
      let formatMap = {
        datetime: "yyyy-MM-dd HH:mm:ss",
        date: "yyyy-MM-dd",
        dates: "yyyy-MM-dd",
        year: "yyyy",
        month: "yyyy-MM",
        week: "yyyy-MM-dd"
      }
      let value = formatMap[val];
      this.optionModel.format = value;
      this.optionModel.valueFormat = value;
    }
  }
}
</script>

<style scoped>

</style>
