Skip to content

Commit

Permalink
refactor: 🎨gantt区域时间往左缩进1单位
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjone committed May 11, 2023
1 parent 3537a7a commit 373ebd2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/components/common/LinkPath.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script lang="ts" setup>
import useData from '@/composables/useData';
import useGanttHeader from '@/composables/useGanttHeader';
import useGanttWidth from '@/composables/useGanttWidth';
import useStyle from '@/composables/useStyle';
import { LinkItem } from '@/models/data/links';
Expand All @@ -16,13 +16,13 @@ const props = defineProps({
}
});
const { $data } = useData();
const { ganttHeader } = useGanttHeader();
const { ganttColumnWidth, currentMillisecond } = useGanttWidth();
const { rowHeight } = useStyle();
const x = computed(
() =>
(props.link.fromRow.end.intervalTo($data.start) /
(props.link.fromRow.end.intervalTo(ganttHeader.start) /
currentMillisecond.value) *
ganttColumnWidth.value
);
Expand All @@ -33,7 +33,7 @@ const y = computed(
const x2 = computed(
() =>
(props.link.toRow.start.intervalTo($data.start) /
(props.link.toRow.start.intervalTo(ganttHeader.start) /
currentMillisecond.value) *
ganttColumnWidth.value
);
Expand Down
7 changes: 4 additions & 3 deletions src/components/slider/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ const originData = computed(
);
// #region 计算滑块位置
const { $data, toRowData } = useData();
const { toRowData } = useData();
const { ganttHeader } = useGanttHeader();
const { ganttColumnWidth, currentMillisecond } = useGanttWidth();
const sliderLeft = computed(
() =>
(props.data!.start.intervalTo($data.start) / currentMillisecond.value) *
(props.data!.start.intervalTo(ganttHeader.start) /
currentMillisecond.value) *
ganttColumnWidth.value
);
Expand All @@ -108,7 +110,6 @@ const sliderWidth = computed(
// #endregion
// #region 移动滑块
const { ganttHeader } = useGanttHeader();
const canMove = computed(() => {
if (isBoolean(props.move)) return props.move;
if (isFunction(props.move)) {
Expand Down
4 changes: 1 addition & 3 deletions src/composables/useToday.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { XDate } from '@/models/param/date';
import { computed } from 'vue';
import useData from './useData';
import useGanttHeader from './useGanttHeader';
import useGanttWidth from './useGanttWidth';

export default () => {
const { ganttHeader } = useGanttHeader();
const { $data } = useData();
const { ganttColumnWidth, currentMillisecond } = useGanttWidth();

const today = new XDate();
today.startOf();

const todayLeft = computed(() => {
const start = $data.start?.clone();
const start = ganttHeader.start?.clone();
start?.startOf();
return (
(today.intervalTo(start) / currentMillisecond.value) *
Expand Down
4 changes: 2 additions & 2 deletions src/models/param/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ class GanttHeader extends Header {
end?: XDate,
unit: HeaderDateUnit = 'day'
) {
this.start = start;
this.end = end;
this.unit = unit;
this.start = start?.getOffset(-Variables.time.millisecondOf[this.unit]);
this.end = end;
this.minLength = minLen;

this.generate();
Expand Down

0 comments on commit 373ebd2

Please sign in to comment.