vxe-gantt table 甘特图如何设置任务视图每一行的背景色

vxe-gantt table 甘特图如何设置任务视图每一行的背景色,例如给不同任务设置不同背景色。

查看官网:gantt.vxeui.com/

gitbub:github.com/x-extends/v...

gitee:gitee.com/x-extends/v...

效果

代码

通过 task-view-config.viewStyle.cellStyle 设置任务视图行样式,也可以用 task-view-config.viewStyle.rowClassName 设置任务视图行附加 className

html 复制代码
<template>
  <div>
    <vxe-gantt v-bind="ganttOptions"></vxe-gantt>
  </div>
</template>

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

gitee.com/x-extends/v...

相关推荐
晓晓莺歌1 小时前
vue3某一个路由切换,导致所有路由页面均变成空白页
前端·vue.js
web打印社区6 小时前
web-print-pdf:突破浏览器限制,实现专业级Web静默打印
前端·javascript·vue.js·electron·html
Amumu121387 小时前
Vuex介绍
前端·javascript·vue.js
css趣多多8 小时前
Vue过滤器
前端·javascript·vue.js
这是个栗子9 小时前
【Vue代码分析】前端动态路由传参与可选参数标记:实现“添加/查看”模式的灵活路由配置
前端·javascript·vue.js
刘一说10 小时前
Vue 动态路由参数丢失问题详解:为什么 `:id` 拿不到值?
前端·javascript·vue.js
方也_arkling10 小时前
elementPlus按需导入配置
前端·javascript·vue.js
David凉宸10 小时前
vue2与vue3的差异在哪里?
前端·javascript·vue.js
css趣多多11 小时前
this.$watch
前端·javascript·vue.js
有来技术12 小时前
ASP.NET Core 权限管理系统(RBAC)设计与实现|vue3-element-admin .NET 后端
vue.js·后端·c#·asp.net·.net