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

相关推荐
华玥作者21 小时前
[特殊字符] VitePress 对接 Algolia AI 问答(DocSearch + AI Search)完整实战(下)
前端·人工智能·ai
Mr Xu_21 小时前
告别冗长 switch-case:Vue 项目中基于映射表的优雅路由数据匹配方案
前端·javascript·vue.js
前端摸鱼匠21 小时前
Vue 3 的toRefs保持响应性:讲解toRefs在解构响应式对象时的作用
前端·javascript·vue.js·前端框架·ecmascript
sleeppingfrog21 小时前
zebra通过zpl语言实现中文打印(二)
javascript
lang2015092821 小时前
JSR-340 :高性能Web开发新标准
java·前端·servlet
好家伙VCC1 天前
### WebRTC技术:实时通信的革新与实现####webRTC(Web Real-TimeComm
java·前端·python·webrtc
未来之窗软件服务1 天前
未来之窗昭和仙君(六十五)Vue与跨地区多部门开发—东方仙盟练气
前端·javascript·vue.js·仙盟创梦ide·东方仙盟·昭和仙君
baidu_247438611 天前
Android ViewModel定时任务
android·开发语言·javascript
嘿起屁儿整1 天前
面试点(网络层面)
前端·网络
VT.馒头1 天前
【力扣】2721. 并行执行异步函数
前端·javascript·算法·leetcode·typescript