Commit cdcd8a1b authored by liujiangnan's avatar liujiangnan

feat: 区间调整完善

parent d3955af2
...@@ -1416,10 +1416,16 @@ new Vue({ ...@@ -1416,10 +1416,16 @@ new Vue({
let newStart = Number(region.start.toFixed(3)); let newStart = Number(region.start.toFixed(3));
let newEnd = Number(region.end.toFixed(3)); let newEnd = Number(region.end.toFixed(3));
const duration = newEnd - newStart; // 保存原始区间长度 const originalStart = group.start;
const originalEnd = group.end;
const duration = newEnd - newStart;
let needUpdate = false; let needUpdate = false;
// 检查并调整开始时间,同时保持区间长度 // 判断是拖拽整个区间还是调整大小
const isDragging = Math.abs((newEnd - newStart) - (originalEnd - originalStart)) < 0.001;
if (isDragging) {
// 拖拽整个区间的情况
if (newStart < this.lockedPageStart) { if (newStart < this.lockedPageStart) {
newStart = this.lockedPageStart; newStart = this.lockedPageStart;
newEnd = newStart + duration; newEnd = newStart + duration;
...@@ -1427,17 +1433,31 @@ new Vue({ ...@@ -1427,17 +1433,31 @@ new Vue({
this.$message.warning('已自动调整到页面开始时间'); this.$message.warning('已自动调整到页面开始时间');
} }
// 检查并调整结束时间,同时保持区间长度
if (newEnd > this.lockedPageEnd) { if (newEnd > this.lockedPageEnd) {
newEnd = this.lockedPageEnd; newEnd = this.lockedPageEnd;
newStart = newEnd - duration; newStart = newEnd - duration;
// 如果调整后的开始时间小于页面开始时间,则以页面开始时间为准
if (newStart < this.lockedPageStart) { if (newStart < this.lockedPageStart) {
newStart = this.lockedPageStart; newStart = this.lockedPageStart;
} }
needUpdate = true; needUpdate = true;
this.$message.warning('已自动调整到页面结束时间'); this.$message.warning('已自动调整到页面结束时间');
} }
} else {
// 调整区间大小的情况
if (newStart < this.lockedPageStart) {
// 如果是调整开始时间且超出边界,恢复到原始开始时间
newStart = originalStart;
needUpdate = true;
this.$message.warning('开始时间不能早于页面开始时间');
}
if (newEnd > this.lockedPageEnd) {
// 如果是调整结束时间且超出边界,恢复到原始结束时间
newEnd = originalEnd;
needUpdate = true;
this.$message.warning('结束时间不能晚于页面结束时间');
}
}
// 如果需要调整,更新区间位置 // 如果需要调整,更新区间位置
if (needUpdate) { if (needUpdate) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment