Appearance
Gantt
甘特图
基础用法
vue
<template>
<ham-gantt :dataSource="dataSource" :fillMonthNull="1">
<template #column-head-project="{ row }">
<el-button v-bind="getIconProp(row)" size="small" circle />
<div class="link" :title="row.title">
{{ row.title }}
</div>
</template>
</ham-gantt>
</template>
<script setup>
import { CircleCheck, Warning } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import axios from 'axios'
// 获取图标配置
const getIconProp = row => {
const base = {}
base.icon = row.type === 'warning' ? Warning : CircleCheck
base.type = row.type
return base
}
// 初始化
const dataSource = ref([])
onMounted(async () => {
const result = await axios.post('/docApi/component/gantt')
dataSource.value = result?.data?.data || []
console.log(dataSource.value)
})
</script>
<style lang="scss" scoped>
.link {
cursor: pointer;
padding-left: 6px;
font-size: 14px;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 5;
align-items: center;
word-break: break-all;
text-overflow: ellipsis;
box-sizing: border-box;
&:hover {
color: var(--el-color-primary);
}
}
</style><template>
<ham-gantt :dataSource="dataSource" :fillMonthNull="1">
<template #column-head-project="{ row }">
<el-button v-bind="getIconProp(row)" size="small" circle />
<div class="link" :title="row.title">
{{ row.title }}
</div>
</template>
</ham-gantt>
</template>
<script setup>
import { CircleCheck, Warning } from '@element-plus/icons-vue'
import { ref, onMounted } from 'vue'
import axios from 'axios'
// 获取图标配置
const getIconProp = row => {
const base = {}
base.icon = row.type === 'warning' ? Warning : CircleCheck
base.type = row.type
return base
}
// 初始化
const dataSource = ref([])
onMounted(async () => {
const result = await axios.post('/docApi/component/gantt')
dataSource.value = result?.data?.data || []
console.log(dataSource.value)
})
</script>
<style lang="scss" scoped>
.link {
cursor: pointer;
padding-left: 6px;
font-size: 14px;
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 5;
align-items: center;
word-break: break-all;
text-overflow: ellipsis;
box-sizing: border-box;
&:hover {
color: var(--el-color-primary);
}
}
</style>属性
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| dataSource | 绑定数据源 | IGanttDataColumn[] | [] |
| rowWidth | 单元格的宽度 | number | 180 |
| columnWidth | 首行的宽度 | number | 136 |
| columnHeight | 每行的高度 | number | 108 |
| headerHeight | 标题的高度 | number | 72 |
| fillMonthNull | 首尾留白月 | number | 2 |
| title | 标题 | string | 项目 |
IGanttDataColumn
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| id | 唯一标识 | string | |
| title | 显示标题 | string | |
| data | 进度数据 | IGanttData[] | [] |
IGanttData
| 属性名 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|
| id | 唯一标识 | string | ||
| startTime | 开始时间 | number | ||
| endTime | 结束时间 | number | ||
| type | 进度数据 | string | warning | danger | primary | info | primary | |
| name | 显示标题 | string |