style: crontab

pull/2/head
xingyu4j 2022-11-29 14:24:33 +08:00
parent 583921112b
commit 58ef8a6b1d
1 changed files with 31 additions and 41 deletions

View File

@ -2,9 +2,6 @@
import { import {
ElInput, ElInput,
ElInputNumber, ElInputNumber,
ElDropdown,
ElDropdownMenu,
ElDropdownItem,
ElDialog, ElDialog,
ElTabs, ElTabs,
ElTabPane, ElTabPane,
@ -352,14 +349,19 @@ onMounted(() => {
defaultValue.value = props.modelValue defaultValue.value = props.modelValue
}) })
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const handleShortcuts = (command) => { const select = ref()
if (command == 'custom') { watch(
() => select.value,
() => {
console.info(select.value)
if (select.value == 'custom') {
open() open()
} else { } else {
defaultValue.value = command defaultValue.value = select.value
emit('update:modelValue', defaultValue.value) emit('update:modelValue', defaultValue.value)
} }
} }
)
const open = () => { const open = () => {
set() set()
dialogVisible.value = true dialogVisible.value = true
@ -510,37 +512,23 @@ const submit = () => {
} }
</script> </script>
<template> <template>
<el-input v-model="defaultValue" v-bind="$attrs"> <el-input v-model="defaultValue" v-bind="$attrs" class="input-with-select">
<template #append> <template #append>
<el-dropdown <el-select v-model="select" placeholder="生成器" style="width: 115px">
split-button <el-option label="每分钟" value="0 * * * * ?" />
type="text" <el-option label="每小时" value="0 0 * * * ?" />
@command="handleShortcuts" <el-option label="每天零点" value="0 0 0 * * ?" />
style="width: 35px; margin-left: 5px; margin-right: 2px" <el-option label="每月一号零点" value="0 0 0 1 * ?" />
> <el-option label="每月最后一天零点" value="0 0 0 L * ?" />
生成器 <el-option label="每周星期日零点" value="0 0 0 ? * 1" />
<template #dropdown> <el-option
<el-dropdown-menu>
<el-dropdown-item command="0 * * * * ?">每分钟</el-dropdown-item>
<el-dropdown-item command="0 0 * * * ?">每小时</el-dropdown-item>
<el-dropdown-item command="0 0 0 * * ?">每天零点</el-dropdown-item>
<el-dropdown-item command="0 0 0 1 * ?">每月一号零点</el-dropdown-item>
<el-dropdown-item command="0 0 0 L * ?">每月最后一天零点</el-dropdown-item>
<el-dropdown-item command="0 0 0 ? * 1">每周星期日零点</el-dropdown-item>
<el-dropdown-item
v-for="(item, index) in shortcuts" v-for="(item, index) in shortcuts"
:key="item.value" :key="index"
:divided="index == 0" :label="item.text"
:command="item.value" :value="item.value"
> />
{{ item.text }} <el-option label="自定义" value="custom" />
</el-dropdown-item> </el-select>
<el-dropdown-item divided command="custom">
<Icon icon="ep:menu" />自定义
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template> </template>
</el-input> </el-input>
@ -1015,8 +1003,10 @@ const submit = () => {
background: var(--el-color-primary); background: var(--el-color-primary);
color: #fff; color: #fff;
} }
[data-theme='dark'] .sc-cron-num h4 { [data-theme='dark'] .sc-cron-num h4 {
background: var(--el-color-white); background: var(--el-color-white);
} }
.input-with-select .el-input-group__prepend {
background-color: var(--el-fill-color-blank);
}
</style> </style>