From e163bf51521d438d5d1ddd8d9312b4c8a7ce3921 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Fri, 13 Feb 2026 16:35:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(aiot):=20=E9=87=8D=E6=9E=84=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=80=89=E6=8B=A9=E5=99=A8=E4=B8=BA=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E7=9A=84TimePicker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 TimePicker.RangePicker 改为两个独立的 TimePicker - 使用 startTime 和 endTime 分别控制开始和结束时间 - 添加时间分隔符"至"提升可读性 - 修复编辑功能,现在可以正常编辑模板时间段 - 解决时间选择器无法显示和选择的问题 Co-Authored-By: Claude Opus 4.6 --- .../roi/components/WorkingHoursEditor.vue | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) 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 {
- + +