diff --git a/demo/demo.vue b/demo/demo.vue
index a574663..6de1e7f 100644
--- a/demo/demo.vue
+++ b/demo/demo.vue
@@ -4,8 +4,15 @@
-
-
+
+ n1
diff --git a/src/components/column/index.vue b/src/components/column/index.vue
index 47abfce..cf4f556 100644
--- a/src/components/column/index.vue
+++ b/src/components/column/index.vue
@@ -12,7 +12,7 @@
@@ -32,9 +32,10 @@
diff --git a/src/components/column/props.ts b/src/components/column/props.ts
index f4c3178..bc34244 100644
--- a/src/components/column/props.ts
+++ b/src/components/column/props.ts
@@ -1,5 +1,6 @@
import Variables from '@/constants/vars';
import RowItem from '@/models/data/row';
+import { type PropType } from 'vue';
export default {
/**
@@ -20,6 +21,15 @@ export default {
*/
label: String,
+ /**
+ * 是否合并,一个函数,抛出当前数据,接收true / false,true为合并当前行,与前置列合并
+ */
+ merge: {
+ type: [Function, Boolean] as PropType boolean)>,
+ default: () => false
+ },
+
// ********* 内部参数 ********* //
- data: RowItem
+ data: RowItem,
+ __index: Number
};
diff --git a/src/components/column/util.ts b/src/components/column/util.ts
index bafd7a7..19f1800 100644
--- a/src/components/column/util.ts
+++ b/src/components/column/util.ts
@@ -1,3 +1,3 @@
export const getColumnWidth = (width: number | string) => {
- return `${typeof width === 'number' ? width : Number.parseInt(width)}px`;
+ return typeof width === 'number' ? width : Number.parseInt(width);
};
diff --git a/src/components/common/TableBody.vue b/src/components/common/TableBody.vue
index ae23c1e..b0b5351 100644
--- a/src/components/common/TableBody.vue
+++ b/src/components/common/TableBody.vue
@@ -43,8 +43,13 @@
...$styleBox.getBorderColor()
}"
>
-
-
+
+
@@ -64,7 +69,7 @@ import useStyle from '@/composables/useStyle';
const props = defineProps<{ gap: number }>();
-const { $slotsBox } = useSlotsBox();
+const { $slotsBox, isMerge } = useSlotsBox();
const { bodyHeight, rowHeight, $styleBox } = useStyle();
const { inView } = useInView();
diff --git a/src/components/common/TableHeader.vue b/src/components/common/TableHeader.vue
index 70a51b6..612e53a 100644
--- a/src/components/common/TableHeader.vue
+++ b/src/components/common/TableHeader.vue
@@ -4,7 +4,9 @@
diff --git a/src/composables/useData.ts b/src/composables/useData.ts
index 9e0ec7e..48ca816 100644
--- a/src/composables/useData.ts
+++ b/src/composables/useData.ts
@@ -1,3 +1,4 @@
+import type RowItem from '@/models/data/row';
import { useStore } from '@/store';
import { computed, watch, type Ref } from 'vue';
import useGanttWidth from './useGanttWidth';
@@ -36,10 +37,18 @@ export default () => {
);
}
+ function toRowData(data: RowItem) {
+ return {
+ row: data.data,
+ $index: data.flatIndex
+ };
+ }
+
return {
$data: store.$data,
initData,
dateList: computed(() => store.ganttHeader.headers),
- setGanttHeaders
+ setGanttHeaders,
+ toRowData
};
};
diff --git a/src/composables/useSlotsBox.ts b/src/composables/useSlotsBox.ts
index 609381a..510270c 100644
--- a/src/composables/useSlotsBox.ts
+++ b/src/composables/useSlotsBox.ts
@@ -1,5 +1,7 @@
+import type RowItem from '@/models/data/row';
import { useStore } from '@/store';
import { type Slots } from 'vue';
+import useData from './useData';
import useTableWidth from './useTableWidth';
export default () => {
@@ -14,5 +16,14 @@ export default () => {
setTableWidth(store.$slotsBox.cols);
}
- return { $slotsBox: store.$slotsBox, setSlots };
+ const { toRowData } = useData();
+
+ function isMerge(
+ m: boolean | undefined | ((data: any) => boolean),
+ data: RowItem
+ ) {
+ return typeof m === 'function' ? m(toRowData(data)) : !!m;
+ }
+
+ return { $slotsBox: store.$slotsBox, setSlots, isMerge };
};