<template>
  <TimePicker
    :key="key"
    :placeholder="info.form.placeholder"
    :type="info.form.formType"
    :format="info.form.format"
    :disabled="info.form.disabled||!info.isNew"
    :clearable="info.form.clearable"
    :separator="info.form.separator"
    :steps="steps"
    :size="size"
    v-model="info.defaultValue">
  </TimePicker>
</template>
<script>
import { baseComponentMixins } from '../mixins'

export default {
  name: 'BaseTimePicker',
  mixins: [ baseComponentMixins ],
  data() {
    return {
      key: 0,
    }
  },
  computed: {
    // 无法转换成 array 和 转换成字符串的 采用默认值
    steps() {
      try {
        const rst = JSON.parse(this.info.form.steps)
        return rst instanceof Array ? rst : [1, 1, 1]
      } catch {
        return [1, 1, 1]
      }
    },
  },
  watch: {
    //steps 变化及时生效  需要重新渲染
    'info.form.steps'() {
      this.key++
    },
    'info.form.formType'(v) {
      console.log(v, 455)
      if (v.includes('range')) {
        this.info.defaultValue = ['', '' ]
      } else {
        this.info.defaultValue = ''
      }
    },
  },
}
</script>