diff --git a/apps/web-antd/src/views/aiot/device/roi/components/WorkingHoursEditor.vue b/apps/web-antd/src/views/aiot/device/roi/components/WorkingHoursEditor.vue index 1149e78ac..a0869b270 100644 --- a/apps/web-antd/src/views/aiot/device/roi/components/WorkingHoursEditor.vue +++ b/apps/web-antd/src/views/aiot/device/roi/components/WorkingHoursEditor.vue @@ -30,7 +30,8 @@ const emit = defineEmits<{ }>(); // 当前编辑的时间段 -const currentRange = ref<[Dayjs, Dayjs] | null>(null); +const startTime = ref(null); +const endTime = ref(null); // 正在编辑的时间段索引 const editingIndex = ref(null); @@ -78,15 +79,14 @@ const templates = [ // 添加或更新时间段 function addPeriod() { - if (!currentRange.value) { - message.warning('请先选择时间段'); + if (!startTime.value || !endTime.value) { + message.warning('请选择开始时间和结束时间'); return; } - const [start, end] = currentRange.value; const newPeriod: WorkingHourPeriod = { - start: start.format('HH:mm'), - end: end.format('HH:mm'), + start: startTime.value.format('HH:mm'), + end: endTime.value.format('HH:mm'), }; // 校验:结束时间必须晚于开始时间 @@ -132,22 +132,22 @@ function addPeriod() { message.success('时间段已添加'); } - currentRange.value = null; + startTime.value = null; + endTime.value = null; } // 编辑时间段 function editPeriod(index: number) { const period = periods.value[index]; - currentRange.value = [ - dayjs(period.start, 'HH:mm'), - dayjs(period.end, 'HH:mm'), - ]; + startTime.value = dayjs(period.start, 'HH:mm'); + endTime.value = dayjs(period.end, 'HH:mm'); editingIndex.value = index; } // 取消编辑 function cancelEdit() { - currentRange.value = null; + startTime.value = null; + endTime.value = null; editingIndex.value = null; } @@ -229,11 +229,19 @@ function getDuration(period: WorkingHourPeriod): string {
- + +