From 0100d60d89f86756bb9956ab8967a1f1bc870d43 Mon Sep 17 00:00:00 2001 From: yicone Date: Tue, 23 Feb 2021 18:45:14 +0800 Subject: [PATCH] fix: forgot sort after adding bar --- src/GGanttRow.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/GGanttRow.vue b/src/GGanttRow.vue index 088ca92..914d2a8 100644 --- a/src/GGanttRow.vue +++ b/src/GGanttRow.vue @@ -134,10 +134,17 @@ export default { ) let bar = {} bar[this.ganttChartProps.barStartKey] = time.format() - bar[this.ganttChartProps.barEndKey] = time.add(this.getDefaultBarLength(), this.timeUnit).format() + bar[this.ganttChartProps.barEndKey] = time + .add(this.getDefaultBarLength(), this.timeUnit) + .format() bar.ganttBarConfig = { handles: true } this.bars.push(bar) + this.bars.sort((first, second) => + moment(first[this.ganttChartProps.barStartKey]).diff( + second[this.ganttChartProps.barStartKey] + ) + ) }, onMouseover() {