vue vxe-gantt table 甘特图实现多个维度视图展示,支持切换年视图、月视图、周视图等

vue vxe-gantt table 甘特图实现多个维度视图展示,支持切换年视图、月视图、周视图等,通过 task-view-config 来配置日期轴。

https://gantt.vxeui.com

效果

代码

通过 task-view-config.scales 可以灵活的切换显示模式

html 复制代码
<template>
  <div>
    <vxe-radio-group v-model="viewMode" @change="changeViewEvent">
      <vxe-radio-button label="1" content="年视图"></vxe-radio-button>
      <vxe-radio-button label="2" content="季度视图"></vxe-radio-button>
      <vxe-radio-button label="3" content="月视图"></vxe-radio-button>
      <vxe-radio-button label="4" content="周视图"></vxe-radio-button>
      <vxe-radio-button label="5" content="日视图"></vxe-radio-button>
    </vxe-radio-group>

    <vxe-gantt v-bind="ganttOptions"></vxe-gantt>
  </div>
</template>

<script setup>
import { reactive, ref } from 'vue'

const viewMode = ref('1')

const taskViewConfig = reactive({
  scales: ['year']
})

const ganttOptions = reactive({
  border: true,
  taskBarConfig: {
    showProgress: true,
    barStyle: {
      round: true,
      bgColor: '#fca60b',
      completedBgColor: '#65c16f'
    }
  },
  taskViewConfig,
  columns: [
    { field: 'name', title: '任务名称' },
    { field: 'start', title: '开始时间', width: 100 },
    { field: 'end', title: '结束时间', width: 100 }
  ],
  data: [
    { id: 10001, name: 'A项目', start: '2023-08-01', end: '2024-11-15', progress: 3 },
    { id: 10002, name: '城市道路修理进度', start: '2024-01-03', end: '2024-03-08', progress: 10 },
    { id: 10003, name: 'B大工程', start: '2024-05-03', end: '2024-07-11', progress: 90 },
    { id: 10004, name: '超级大工程', start: '2024-04-05', end: '2024-06-11', progress: 15 },
    { id: 10005, name: '地球净化项目', start: '2024-07-08', end: '2024-08-15', progress: 100 },
    { id: 10006, name: '一个小目标项目', start: '2024-08-10', end: '2024-11-21', progress: 5 },
    { id: 10007, name: '某某计划', start: '2024-03-15', end: '2024-08-24', progress: 70 },
    { id: 10008, name: '某某科技项目', start: '2024-03-20', end: '2024-03-29', progress: 50 },
    { id: 10009, name: '地铁建设工程', start: '2025-01-19', end: '2025-03-18', progress: 5 },
    { id: 10010, name: '铁路修建计划', start: '2024-12-12', end: '2025-02-10', progress: 10 }
  ]
})

const changeViewEvent = () => {
  switch (viewMode.value) {
    case '1':
      taskViewConfig.scales = ['year']
      break
    case '2':
      taskViewConfig.scales = ['year', 'quarter']
      break
    case '3':
      taskViewConfig.scales = ['year', 'month']
      break
    case '4':
      taskViewConfig.scales = ['year', 'week']
      break
    case '5':
      taskViewConfig.scales = ['month', 'day', 'date']
      break
  }
}
</script>

https://gitee.com/x-extends/vxe-gantt

相关推荐
wulijuan88866621 小时前
ECharts图表性能优化的那些事
前端·javascript·echarts
❀͜͡傀儡师21 小时前
通过npm 手动安装、Docker 部署 OpenClaw小龙虾
前端·docker·npm
前端AI充电站21 小时前
Google 开始卷价格了:Gemini 3.1 Flash-Lite,会不会把 AI 应用成本真的打下来?
前端·人工智能
风止何安啊21 小时前
数字太长看花眼?一招教它排好队:千分位处理的实现
前端·javascript·面试
沙包大的拳头21 小时前
扩展运算符无法克隆 getBoundingClientRect() 获取的值
前端·javascript
忆江南21 小时前
# Flutter 语音房礼物下载方案(完整版)
前端
悟空瞎说21 小时前
React 19 带来了诸多创新
前端·react.js
im_AMBER21 小时前
高并发下的列表乱序与文档同步
前端·react.js·架构
游戏开发爱好者821 小时前
React Native iOS 代码如何加密,JS 打包 和 IPA 混淆
android·javascript·react native·ios·小程序·uni-app·iphone