fix: bug#16404

This commit is contained in:
XieYongHong 2023-07-15 13:51:28 +08:00
parent 1baa346733
commit 6bfba98db6
1 changed files with 12 additions and 10 deletions

View File

@ -101,7 +101,7 @@
import type { PropType } from 'vue' import type { PropType } from 'vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import WhenOption from './WhenOption.vue' import WhenOption from './WhenOption.vue'
import { cloneDeep } from 'lodash-es' import {cloneDeep, pick} from 'lodash-es'
import type { OperationTimer } from '../../../typings' import type { OperationTimer } from '../../../typings'
import { isCron } from '@/utils/regular' import { isCron } from '@/utils/regular'
import { defineExpose } from 'vue' import { defineExpose } from 'vue'
@ -109,7 +109,7 @@ import { defineExpose } from 'vue'
type NameType = string[] | string type NameType = string[] | string
type Emit = { type Emit = {
(e: 'update:value', data: OperationTimer): void (e: 'update:value', data: Partial<OperationTimer>): void
} }
const props = defineProps({ const props = defineProps({
@ -175,18 +175,20 @@ const showPeriod = computed(() => {
const updateValue = () => { const updateValue = () => {
const cloneValue = cloneDeep(formModel) const cloneValue = cloneDeep(formModel)
let keys: string[] = ['trigger']
if (cloneValue.trigger === 'cron') { if (cloneValue.trigger === 'cron') {
delete cloneValue.when keys.push('cron')
} else { } else {
delete cloneValue.cron keys = keys.concat(['mod', 'when'])
if (cloneValue.mod === 'period') {
keys.push('once')
} else {
keys.push('period')
}
} }
if (cloneValue.mod === 'period') { emit('update:value', pick(cloneValue, keys))
delete cloneValue.once
} else {
delete cloneValue.period
}
emit('update:value', cloneValue)
} }
const triggerChange = () => { const triggerChange = () => {