<template>
  <div style="overflow-y: auto">
    <h1>date</h1>
    <div>
      参数：input1，值：{{form.input1}} (默认format、value-format 为 YYYY-MM-DD)
      <CusFormColumn
          label="普通"
          link="date"
          v-model:param="form.input1"/>
    </div>
    <h2>类型  type</h2>
    <div>
      值：{{form.input2}}
      <CusFormColumn
          link="date"
          label="year"
          type="year"
          v-model:param="form.input2"/>
      值：{{form.input3}} (elementUI周选择器有问题，value-format报错，需要自己处理)
      <CusFormColumn
          link="date"
          label="week"
          type="week"
          v-model:param="form.input3"/>
      值：{{form.input4}}
      <CusFormColumn
          link="date"
          label="month"
          type="month"
          v-model:param="form.input4"/>
      值：{{form.input5}}
      <CusFormColumn
          link="date"
          label="dates"
          type="dates"
          v-model:param="form.input5"/>
      值：{{form.input6}}
      <CusFormColumn
          link="date"
          label="monthrange"
          type="monthrange"
          v-model:param="form.input6"/>
      值：{{form.input7}}
      <CusFormColumn
          link="date"
          label="daterange"
          type="daterange"
          v-model:param="form.input7"/>
    </div>
    <h2>插槽</h2>
    <div>
      值：{{form.input8}}
      <CusFormColumn
          label="插槽"
          link="date"
          v-model:param="form.input8">
        <template #default="cell">
          <div class="cell" :class="{ current: cell.isCurrent }">
            <span class="text">{{cell.text}}s</span>
            <span v-if="isCell(cell)" class="holiday" />
          </div>
        </template>
      </CusFormColumn>
    </div>
  </div>
</template>

<script lang="ts">
import {
  defineComponent,
  computed,
  onMounted,
  ref,
  reactive,
  watch,
  getCurrentInstance,
  ComponentInternalInstance,
  toRefs,
  nextTick
} from 'vue'
import {useStore} from 'vuex'
import {useRouter, useRoute} from 'vue-router'

export default defineComponent({
  name: '',
  components: {},
  setup() {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
    const state = reactive({
      form: {
        input1: null,
        input2: null,
      }
    })
    const isCell = (val) => {
      return val.timestamp < new Date().getTime()
    }
    return {
      ...toRefs(state),
      isCell
    }
  },
})
</script>

<style scoped lang="scss">
.cell {
  height: 30px;
  padding: 3px 0;
  box-sizing: border-box;
}
.cell .text {
  width: 24px;
  height: 24px;
  display: block;
  margin: 0 auto;
  line-height: 24px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
}
.cell.current .text {
  background: #626aef;
  color: #fff;
}
.cell .holiday {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--el-color-danger);
  border-radius: 50%;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
}
</style>
