Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: GanttColumnSize支持自定义宽度 #65

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/root/rootProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ export default {
* 甘特图表的每一列宽度
*/
ganttColumnSize: {
type: String as PropType<GanttColumnSize>,
type: String as
| PropType<GanttColumnSize>
| object as PropType<ColumnSizeObject>,
default: 'normal',
validator: (v: GanttColumnSize) => {
return ['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]);
}
},

Expand Down
3 changes: 3 additions & 0 deletions src/composables/useGanttWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export default () => {

const ganttColumnWidth = computed(() => {
const size = store.$styleBox.ganttColumnSize;
if (typeof size === 'object') {
return size[store.ganttHeader.unit];
}
return Variables.size.ganttColumnWidth[size][store.ganttHeader.unit];
});

Expand Down
9 changes: 8 additions & 1 deletion src/typings/size.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
declare type GanttColumnSize = 'small' | 'normal' | 'large';
// 对象方式设置甘特图列宽
declare interface ColumnSizeObject {
hour: number;
day: number;
week: number;
month: number;
}
declare type GanttColumnSize = 'small' | 'normal' | 'large' | ColumnSizeObject;