当前位置: 首页 > news >正文

vue 甘特图 vxe-gantt 设置每个进度条分为计划和实际两条,实现上下分布任务条

vue 甘特图 vxe-gantt 设置每个进度条分为计划和实际两条,实现上下分布任务条,实现方式是利用子任务的子视图渲染模式,来间每条任务拆分成2条子任务,就可以利用自带的子视图渲染功能来渲染。

https://gantt.vxeui.com

由于放2行超出默认高度,所以还需要通过 cell-config.height设置一下行高,再通过树形表格的子任务来渲染

image

<template><div><vxe-gantt v-bind="ganttOptions"></vxe-gantt></div>
</template><script setup>
import { reactive } from 'vue'
import { VxeGanttTaskType } from 'vxe-gantt'
import XEUtils from 'xe-utils'const ganttOptions = reactive({border: true,height: 500,loading: false,cellConfig: {height: 60},treeConfig: {transform: true,rowField: 'id',parentField: 'parentId'},taskConfig: {startField: 'start',endField: 'end',typeField: 'type'},taskBarSubviewConfig: {barStyle ({ row }) {if (row.flag === 1) {return {transform: 'translateY(-24px)','--vxe-ui-gantt-view-task-bar-completed-background-color': '#409eff'}}if (row.flag === 2) {return {transform: 'translateY(1px)','--vxe-ui-gantt-view-task-bar-completed-background-color': '#31d231'}}}},taskBarConfig: {showContent: true,barStyle: {round: true}},taskViewConfig: {tableStyle: {width: 480}},columns: [{ field: 'title', title: '任务名称', minWidth: 100 },{ field: 'planStartDate', title: '计划开始时间', width: 100 },{ field: 'planEndDate', title: '计划结束时间', width: 100 },{ field: 'actualStartDate', title: '实际开始时间', width: 100 },{ field: 'actualEndDate', title: '实际结束时间', width: 100 }],data: []
})// 模拟后端接口
const loadList = () => {ganttOptions.loading = truesetTimeout(() => {const list = [{ id: 10001, parentId: null, title: 'A项目', planStartDate: '2024-03-03', planEndDate: '2024-03-15', actualStartDate: '2024-03-03', actualEndDate: '2024-03-12' },{ id: 10002, parentId: null, title: 'B项目', planStartDate: '2024-03-10', planEndDate: '2024-03-25', actualStartDate: '2024-03-08', actualEndDate: '2024-03-16' },{ id: 10003, parentId: null, title: 'C项目', planStartDate: '2024-03-20', planEndDate: '2024-04-10', actualStartDate: '2024-03-22', actualEndDate: '2024-04-01' },{ id: 10004, parentId: null, title: 'D项目', planStartDate: '2024-03-28', planEndDate: '2024-04-19', actualStartDate: '2024-03-28', actualEndDate: '2024-04-12' },{ id: 10005, parentId: null, title: 'E项目', planStartDate: '2024-04-05', planEndDate: '2024-04-28', actualStartDate: '2024-04-01', actualEndDate: '2024-04-24' }]// 转成子任务视图const ganttData = []list.forEach(item => {const currRow = XEUtils.assign({}, item, { type: VxeGanttTaskType.Subview })const planRow = XEUtils.assign({}, item, {id: 10000000 + item.id,title: '计划',parentId: item.id,start: item.planStartDate,end: item.planEndDate,flag: 1})const actualRow = XEUtils.assign({}, item, {id: 20000000 + item.id,parentId: item.id,title: '实际',start: item.actualStartDate,end: item.actualEndDate,flag: 2})ganttData.push(currRow)ganttData.push(planRow)ganttData.push(actualRow)})ganttOptions.data = ganttDataganttOptions.loading = false}, 200)
}loadList()
</script>

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

http://www.jsqmd.com/news/367823/

相关文章:

  • 计算机Java毕设实战-基于springboot的慢性病健康知识科普管理系统的设计与实现【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • 计算机Java毕设实战-基于springboot的中医五行音乐失眠治疗小程序【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • 手机连接树莓派pico rp2040示波器 scoppy-pico
  • 域名卖不出去,要不要考虑委托或经纪出售?
  • 瑞幸咖啡 x 阿里云合作共创:AI 推荐让瑞幸咖啡“更懂你
  • 深圳众擎机器人开启全球首个双足机器人格斗联赛URKL:140万美元金腰带背后,双足格斗如何改写机器人行业未来?
  • DOS叙事环与意义行为原生论:一个智能时代意义哲学的重构、对话与导航
  • flask国内python招聘职位可视化数据分析vue_ka8v0爬虫可视化
  • 前端工程化 - gitlab - MT
  • Python SQLite3 查询结果返回字典的完整解决方案
  • 【每日一题】 LeetCode 3719. 最长平衡子数组 I
  • Flink时间语义全解析:Event Time、Processing Time和Ingestion Time
  • python+django图片相册推荐系统可视化大屏vue_sdtwv 爬虫可视化
  • 能源管理AI优化:从POC到规模化应用的完整路径
  • 大数据领域数据服务:优化业务决策的有效途径
  • Cesium进阶教程(1)在cesium后处理中使用shadertoy的代码
  • U-Net登上Nature封面!谷歌这波颠覆性改进太值得学习了
  • Cesium进阶教程(2)线性高度雾
  • JVM的内存结构
  • 《effective python》- python默认参数
  • 基于SpringBoot的海洋航运管理系统开题报告
  • 降AIGC率8款AI工具,赶due党速码!
  • 8款AI降AIGC率神器,赶due急救指南!
  • LeetCode 3719.最长平衡子数组 I:I先(几乎)暴力了
  • 农业遥感平台如何通过wangEditor实现GeoTIFF图像转存?
  • 2026 年招聘新趋势:AI 简历筛选工具成企业标配
  • 袁家界・天子山・金鞭溪:张家界一日精华叙事
  • 2026 年企业数字化转型必备!智慧人力系统核心功能与应用场景解析
  • 原始云杉林环绕的秘境,藏着丽江的干净与辽阔
  • 医院电子病历如何用TinyMCE处理PDF签名跨平台Word导入?