From 0ee9a5684f35c046647f602f525bd42eeb47a392 Mon Sep 17 00:00:00 2001 From: xpyjs Date: Wed, 24 May 2023 17:23:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=E5=88=9D=E5=A7=8B=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E8=A1=A8=E5=A4=B4?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/App.vue | 36 ++++++++++++++++++------------------ src/models/param/header.ts | 16 ++++++++-------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/demo/App.vue b/demo/App.vue index 04352b2..a7186b4 100644 --- a/demo/App.vue +++ b/demo/App.vue @@ -537,24 +537,24 @@ export default defineComponent({ // 添加2号数据 this.dataList2 = [ - { - index: INDEX++, - startDate: '2021-11-01', - endDate: '2021-11-10', - name: '2号数据: 1' - }, - { - index: INDEX++, - startDate: '2021-11-11', - endDate: '2021-11-20', - name: '2号数据: 2' - }, - { - index: INDEX++, - startDate: '2021-11-21', - endDate: '2021-11-30', - name: '2号数据: 3' - } + // { + // index: INDEX++, + // startDate: '2021-11-01', + // endDate: '2021-11-10', + // name: '2号数据: 1' + // }, + // { + // index: INDEX++, + // startDate: '2021-11-11', + // endDate: '2021-11-20', + // name: '2号数据: 2' + // }, + // { + // index: INDEX++, + // startDate: '2021-11-21', + // endDate: '2021-11-30', + // name: '2号数据: 3' + // } ]; // 添加3号数据 diff --git a/src/models/param/header.ts b/src/models/param/header.ts index 07a2dd2..fe23a45 100644 --- a/src/models/param/header.ts +++ b/src/models/param/header.ts @@ -210,12 +210,12 @@ class GanttHeader extends Header { /** * 甘特的起始时间(数据起始时间请使用 data.start) */ - start?: XDate; + start: XDate = new XDate(); /** * 甘特的结束时间(数据结束时间请使用 data.end) */ - end?: XDate; + end: XDate = new XDate().getOffset(Variables.time.millisecondOf.day); unit: HeaderDateUnit = 'day'; minLength: number = 0; @@ -249,8 +249,8 @@ class GanttHeader extends Header { return; this.unit = unit; - this.start = _start; - this.end = _end; + this.start = _start ?? new XDate(); + this.end = _end ?? new XDate().getOffset(Variables.time.millisecondOf.day); this.minLength = minLen; this.generate(); @@ -262,8 +262,8 @@ class GanttHeader extends Header { // 通过 start 和 end 以及 unit 来生成 columns const columns: GanttColumn[] = []; - const start = this.start!.date.getTime(); - const end = this.end!.date.getTime(); + const start = this.start.date.getTime(); + const end = this.end.date.getTime(); // TODO 这里可以优化一下,直接一次循环就可以组成 headers。因为是固定格式 let s: number; @@ -330,8 +330,8 @@ class GanttHeader extends Header { setDatesByUnit() { this.datesByUnit = []; - const start = this.start!.date.getTime(); - const end = this.end!.date.getTime(); + const start = this.start.date.getTime(); + const end = this.end.date.getTime(); let s: number; for (s = start; s <= end; ) {