From 53226e6a9e661ab258e36dd57ed482a40af567fc Mon Sep 17 00:00:00 2001 From: xpyjs Date: Thu, 1 Jun 2023 14:15:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(slider):=20=E2=9C=A8=20=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=A1=8C=E5=8F=AF=E4=BB=A5=E5=B0=86=20slider=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=88=B0=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/root.md | 6 ++++++ src/components/container/Row.vue | 7 +++++++ src/components/root/index.vue | 5 +++-- src/components/root/rootProps.ts | 8 ++++++++ src/composables/useElement.ts | 3 ++- src/composables/useStyle.ts | 1 + src/models/param/styles.ts | 9 +++++++++ src/store/index.ts | 19 +++++++++++++++++-- types/root/prop.d.ts | 8 ++++++++ 9 files changed, 61 insertions(+), 5 deletions(-) diff --git a/docs/docs/root.md b/docs/docs/root.md index 1a2470a..3acff21 100644 --- a/docs/docs/root.md +++ b/docs/docs/root.md @@ -308,6 +308,12 @@ const ganttLinks = reactive([ 设置是否显示甘特图中的 `周末` 时间线。 +### slider-into-view + + + +该属性将允许在点击行时,将当前行的甘特区域的 slider 滑块滑动到可视区域内(如果该行数据有日期属性)。 + ### unit diff --git a/src/components/container/Row.vue b/src/components/container/Row.vue index 89e231c..afbce26 100644 --- a/src/components/container/Row.vue +++ b/src/components/container/Row.vue @@ -31,6 +31,7 @@ diff --git a/src/components/root/rootProps.ts b/src/components/root/rootProps.ts index 5ba635a..2d16f7d 100644 --- a/src/components/root/rootProps.ts +++ b/src/components/root/rootProps.ts @@ -220,5 +220,13 @@ export default { highlightDate: { type: Boolean, default: false + }, + + /** + * 允许点击行时,将甘特进度条滚动到可视区域 + */ + sliderIntoView: { + type: Boolean, + default: false } }; diff --git a/src/composables/useElement.ts b/src/composables/useElement.ts index 615d2ff..7046620 100644 --- a/src/composables/useElement.ts +++ b/src/composables/useElement.ts @@ -4,7 +4,7 @@ import useParam from './useParam'; export default () => { const { $param } = useParam(); - const { tableHeaderRef, ganttHeaderRef, ganttBodyRef } = useStore(); + const { tableHeaderRef, ganttHeaderRef, ganttBodyRef, ganttRef } = useStore(); function getMaxHeaderHeight() { return Math.max( @@ -24,6 +24,7 @@ export default () => { tableHeaderRef, ganttHeaderRef, ganttBodyRef, + ganttRef, getMaxHeaderHeight, updateHeaderHeight }; diff --git a/src/composables/useStyle.ts b/src/composables/useStyle.ts index 34068be..7c06240 100644 --- a/src/composables/useStyle.ts +++ b/src/composables/useStyle.ts @@ -46,6 +46,7 @@ export default () => { store.$styleBox.headerStyle = props.headerStyle; store.$styleBox.bodyStyle = props.bodyStyle; store.$styleBox.primaryColor = props.primaryColor; + store.$styleBox.sliderIntoView = props.sliderIntoView; }; fn(); diff --git a/src/models/param/styles.ts b/src/models/param/styles.ts index 4509d44..73fb20b 100644 --- a/src/models/param/styles.ts +++ b/src/models/param/styles.ts @@ -132,4 +132,13 @@ export default class StyleBox { public set bodyStyle(v: BodyOptions) { this._bodyStyle = v; } + + private _sliderIntoView: boolean = false; + public get sliderIntoView(): boolean { + return this._sliderIntoView; + } + + public set sliderIntoView(v: boolean) { + this._sliderIntoView = v; + } } diff --git a/src/store/index.ts b/src/store/index.ts index 947c72c..eda7544 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -2,11 +2,18 @@ * @Author: JeremyJone * @Date: 2021-12-24 16:36:33 * @LastEditors: JeremyJone - * @LastEditTime: 2023-05-17 09:49:28 + * @LastEditTime: 2023-06-01 00:26:42 * @Description: 头部注释 */ -import { inject, provide, reactive, type Ref, ref } from 'vue'; +import { + inject, + provide, + reactive, + type Ref, + ref, + type DefineComponent +} from 'vue'; import EventBus from '@/utils/bus'; import { AllData, AllLinks } from '@/models/data'; import { GanttHeader, Param, SlotsBox, StyleBox } from '@/models/param'; @@ -49,6 +56,9 @@ export const initStore = (emit: any) => { const ganttBodyRef = ref(null); provide('ganttBodyRef', ganttBodyRef); + const ganttRef = ref(null); + provide('ganttRef', ganttRef); + const linking = reactive({ startPos: { x: 0, y: 0 }, endPos: { x: 0, y: 0 }, @@ -127,6 +137,11 @@ export const useStore = () => { */ ganttBodyRef: inject('ganttBodyRef') as Ref, + /** + * 甘特图ref + */ + ganttRef: inject('ganttRef') as Ref, + /** * 鼠标创建的连接中的连线数据 */ diff --git a/types/root/prop.d.ts b/types/root/prop.d.ts index 35ed648..63a3c74 100644 --- a/types/root/prop.d.ts +++ b/types/root/prop.d.ts @@ -236,6 +236,14 @@ export declare const props: { * @see https://docs.xiaopangying.com/gantt/root.html#highlight-date */ highlightDate: boolean; + + /** + * 点击行时,是否将当前行滚动到视图中 + * @default false + * + * @see https://docs.xiaopangying.com/gantt/root.html#slider-into-view + */ + sliderIntoView: boolean; }; export type RootProps = ExtractPropTypes;