<script lang="ts" setup>
import { useCronStore } from '@/pages/sys/task/cron/cron-store.ts'

const {hourState} = toRefs(useCronStore())
</script>

<template>
  <ElRadioGroup v-model="hourState.mode" class="select-panel">
    <ElRadio value="every">每小时</ElRadio>
    <ElRadio value="period1">
      <span>周期，从</span>
      <ElInputNumber v-model="hourState.period1.start" :controls="false" :max="23" :min="0" size="small"/>
      <span>时到</span>
      <ElInputNumber v-model="hourState.period1.end" :controls="false" :max="23" :min="hourState.period1.start" size="small"/>
      <span>时</span>
    </ElRadio>
    <ElRadio value="period2">
      <span>周期，从第</span>
      <ElInputNumber v-model="hourState.period2.start" :controls="false" :max="23" :min="0" size="small"/>
      <span>时开始，每</span>
      <ElInputNumber v-model="hourState.period2.end" :controls="false" :max="23" :min="0" size="small"/>
      <span>小时执行一次</span>
    </ElRadio>
    <ElRadio value="specify">
      <div>指定</div>
      <ElCheckboxGroup v-model="hourState.specify">
        <ElCheckbox v-for="i in 24" :key="'HourPanel' + i" :label="(i-1)+''" :value="i-1"/>
      </ElCheckboxGroup>
    </ElRadio>
  </ElRadioGroup>
</template>

<style lang="stylus" scoped>
.select-panel {
  flex-direction column
  align-items start
  gap 10px
  width 100%;
  flex-wrap nowrap

  :deep(.el-input-number) {
    margin 0 10px
    width: 80px
  }

  :deep(.el-checkbox-group) {
    position absolute
    top 0
    left 60px
    display flex
    flex-wrap wrap
    gap 10px
    width 500px

    .el-checkbox {
      width 40px;
      margin 0
    }
  }
}
</style>
