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

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

<template>
  <ElRadioGroup v-model="dayState.mode" class="select-panel">
    <ElRadio value="none">不指定</ElRadio>
    <ElRadio value="every">每天</ElRadio>
    <ElRadio value="last">每月最后一天</ElRadio>
    <ElRadio value="near">
      <span>每月</span>
      <ElInputNumber v-model="dayState.near" :controls="false" :max="31" :min="1" size="small"/>
      <span>号最近的那个工作日</span>
    </ElRadio>
    <ElRadio value="period1">
      <span>周期，从</span>
      <ElInputNumber v-model="dayState.period1.start" :controls="false" :max="30" :min="1" size="small"/>
      <span>号到</span>
      <ElInputNumber v-model="dayState.period1.end" :controls="false" :max="31" :min="dayState.period1.start" size="small"/>
      <span>号</span>
    </ElRadio>
    <ElRadio value="period2">
      <span>周期，从第</span>
      <ElInputNumber v-model="dayState.period2.start" :controls="false" :max="31" :min="1" size="small"/>
      <span>天开始，每</span>
      <ElInputNumber v-model="dayState.period2.end" :controls="false" :max="31" :min="1" size="small"/>
      <span>天执行一次</span>
    </ElRadio>
    <ElRadio value="specify">
      <div>指定</div>
      <ElCheckboxGroup v-model="dayState.specify">
        <ElCheckbox v-for="i in 31" :key="'DayPanel' + i" :label="i" :value="i"/>
      </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>
