From b7fab5cd6d9f788ed5f834766d1c15ed2887011d Mon Sep 17 00:00:00 2001 From: yanminxing Date: Tue, 10 Oct 2023 14:54:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20GanttColumnSize=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AF=B9=E8=B1=A1=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/root/rootProps.ts | 10 ++++++++-- src/composables/useGanttWidth.ts | 4 +++- src/typings/size.d.ts | 9 ++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/components/root/rootProps.ts b/src/components/root/rootProps.ts index 151d7c5..ec16ff5 100644 --- a/src/components/root/rootProps.ts +++ b/src/components/root/rootProps.ts @@ -134,10 +134,16 @@ export default { * 甘特图表的每一列宽度 */ ganttColumnSize: { - type: String as PropType | number, + type: String as + | PropType + | object as PropType, default: 'normal', validator: (v: GanttColumnSize) => { - return typeof v === 'number' || ['small', 'normal', 'large'].includes(v); + return typeof v === 'string' + ? ['small', 'normal', 'large'].includes(v) + : !Object.keys(v).some( + k => !['hour', 'day', 'week', 'month'].includes(k) + ) && !['hour', 'day', 'week', 'month'].some(k => !v[k]); } }, diff --git a/src/composables/useGanttWidth.ts b/src/composables/useGanttWidth.ts index ee1063a..b7bc954 100644 --- a/src/composables/useGanttWidth.ts +++ b/src/composables/useGanttWidth.ts @@ -21,7 +21,9 @@ export default () => { const ganttColumnWidth = computed(() => { const size = store.$styleBox.ganttColumnSize; - if (typeof size === 'number') return size; + if (typeof size === 'object') { + return size[store.ganttHeader.unit]; + } return Variables.size.ganttColumnWidth[size][store.ganttHeader.unit]; }); diff --git a/src/typings/size.d.ts b/src/typings/size.d.ts index 0f524a6..29c0df4 100644 --- a/src/typings/size.d.ts +++ b/src/typings/size.d.ts @@ -1 +1,8 @@ -declare type GanttColumnSize = 'small' | 'normal' | 'large' | number; +// 对象方式设置甘特图列宽 +declare interface ColumnSizeObject { + hour: number; + day: number; + week: number; + month: number; +} +declare type GanttColumnSize = 'small' | 'normal' | 'large' | ColumnSizeObject;