Skip to content

Commit

Permalink
fix(header): 🐛 修复 月/周 下头部长度问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xpyjs committed Aug 17, 2023
1 parent cdaa7ca commit 29d9440
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/container/GanttHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
c.date.date,
i === 0
? 'after'
: ganttHeader.unit === 'month' && i === dateList[1].length - 1
: i === dateList[1].length - 1
? 'before'
: undefined
)}px`"
Expand Down
14 changes: 10 additions & 4 deletions src/composables/useGanttWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ export default () => {
if (condition === 'after') {
// 计算全量之前的日期长度
const d = new XDate(date);
const cur = d.getBy(headerShowUnit.value);
return full - cur + 1;
if (store.ganttHeader.unit === 'week') {
return full - day(date).weekday();
}

return full - d.getBy(headerShowUnit.value) + 1;
}

if (condition === 'before') {
// 计算全量之前的日期长度
const d = new XDate(date);
const cur = d.getBy(headerShowUnit.value);
return cur;
if (store.ganttHeader.unit === 'week') {
return day(date).weekday() + 1;
}

return d.getBy(headerShowUnit.value);
}

return full;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import IsoWeek from 'dayjs/plugin/isoWeek';
import localeData from 'dayjs/plugin/localeData';
import updateLocale from 'dayjs/plugin/updateLocale';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import weekday from 'dayjs/plugin/weekday';
import Variables from '@/constants/vars';
import './lang';

Expand All @@ -21,6 +22,7 @@ dayjs.extend(advancedFormat);
// 添加本地化
dayjs.extend(localeData);
dayjs.extend(updateLocale);
dayjs.extend(weekday);

export const day = dayjs;

Expand Down

0 comments on commit 29d9440

Please sign in to comment.