diff --git a/.eslintrc.js b/.eslintrc.js
index 4aca68c..3ef7a83 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -10,7 +10,14 @@ module.exports = {
'plugin:vue/vue3-recommended',
'plugin:prettier/recommended'
],
- overrides: [],
+ overrides: [
+ {
+ files: ['*.vue'],
+ rules: {
+ 'no-undef': 'off'
+ }
+ }
+ ],
parserOptions: {
ecmaVersion: 'latest',
parser: '@typescript-eslint/parser',
diff --git a/demo/demo.vue b/demo/demo.vue
index ff49972..5a25057 100644
--- a/demo/demo.vue
+++ b/demo/demo.vue
@@ -52,7 +52,12 @@
ellipsis
/>
-
+
diff --git a/src/components/slider/index.vue b/src/components/slider/index.vue
index 4fe87d0..cb8eef5 100644
--- a/src/components/slider/index.vue
+++ b/src/components/slider/index.vue
@@ -6,7 +6,7 @@
left: `${sliderLeft}px`,
width: `${sliderWidth}px`,
maxHeight: `${$styleBox.rowHeight}px`,
- backgroundColor: props.bgColor,
+ backgroundColor: props?.bgColor,
height: height,
top:
height === '100%' ||
@@ -26,7 +26,17 @@
@pointerdown="onInAnchorDown"
>
+
+
+
+
props.label || (props.data?.data?.[props.prop ?? ''] ?? props.emptyData)
);
+const resizeColor = computed(() =>
+ blend({ r: 93, g: 68, b: 15, a: 40 }, props?.bgColor || '#eca710')
+);
+
// #region 计算滑块位置
const { toRowData } = useData();
const { ganttHeader } = useGanttHeader();
@@ -114,13 +138,17 @@ const sliderWidth = computed(
// #endregion
// #region 移动滑块
-const canMove = computed(() => {
- if (isBoolean(props.move)) return props.move;
- if (isFunction(props.move)) {
- return props.move(toRowData(props.data!));
+const calcMove = (p: boolean | ((data: RowData) => boolean)) => {
+ if (isBoolean(p)) return p;
+ if (isFunction(p)) {
+ return p(toRowData(props.data!));
}
return false;
+};
+
+const canMove = computed(() => {
+ return calcMove(props.move);
});
const disableMove = ref(false);
function handleDisableMove() {
@@ -133,33 +161,33 @@ onMounted(() => {
});
});
-const setStart = (() => {
- const startDate = props.data?.start.clone();
- return (x: number) => {
- props.data?.setStart(
- startDate!.getOffset(
- (x / ganttColumnWidth.value) * currentMillisecond.value
- ),
- ganttHeader.unit
- );
- };
-})();
-
-const setEnd = (() => {
- const endDate = props.data?.end.clone();
- return (x: number) =>
- props.data?.setEnd(
- endDate!.getOffset(
- (x / ganttColumnWidth.value) * currentMillisecond.value
- ),
- ganttHeader.unit
- );
-})();
+let startDate = props.data?.start.clone();
+const setStart = (x: number) => {
+ props.data?.setStart(
+ startDate!.getOffset(
+ (x / ganttColumnWidth.value) * currentMillisecond.value
+ ),
+ ganttHeader.unit
+ );
+};
+
+let endDate = props.data?.end.clone();
+const setEnd = (x: number) =>
+ props.data?.setEnd(
+ endDate!.getOffset((x / ganttColumnWidth.value) * currentMillisecond.value),
+ ganttHeader.unit
+ );
const sliderRef = ref(null) as Ref;
const { onDrag } = useDrag();
onDrag(sliderRef, {
disabled: () => !canMove.value || disableMove.value,
+ reset: true,
+
+ onStart: () => {
+ startDate = props.data?.start.clone();
+ endDate = props.data?.end.clone();
+ },
onMove: x => {
setStart(x);
@@ -168,6 +196,42 @@ onDrag(sliderRef, {
});
// #endregion
+// #region 左滑块移动
+function onResizeLeftDown() {
+ handleDisableMove();
+}
+const resizeLeftRef = ref(null) as Ref;
+onDrag(resizeLeftRef, {
+ reset: true,
+
+ onStart: () => {
+ startDate = props.data?.start.clone();
+ },
+
+ onMove: x => {
+ setStart(x);
+ }
+});
+// #endregion
+
+// #region 右滑块移动
+function onResizeRightDown() {
+ handleDisableMove();
+}
+const resizeRightRef = ref(null) as Ref;
+onDrag(resizeRightRef, {
+ reset: true,
+
+ onStart: () => {
+ endDate = props.data?.end.clone();
+ },
+
+ onMove: x => {
+ setEnd(x);
+ }
+});
+// #endregion
+
// #region inAnchor
function onInAnchorDown() {
handleDisableMove();
@@ -185,22 +249,44 @@ function onOutAnchorDown() {