vxe-gantt 甘特图使用右键菜单

vxe-gantt 甘特图使用右键菜单,支持表头菜单、内容菜单、表尾菜单,自定义样式,配置项 menu-config={header,body,footer},实现对按钮的控制,通过 visibleMethod 和 visible | disabled 属性来控制菜单选项的操作权限,可以精确到每一列每一行的显示隐藏与禁用控制

https://gantt.vxeui.com

菜单点击后会触发 menu-click 事件,可以对事件进行处理

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

<script setup>
import { reactive } from 'vue'
import { VxeUI } from 'vxe-pc-ui'

const ganttOptions = reactive({
  border: true,
  height: 400,
  rowConfig: {
    isCurrent: true
  },
  columnConfig: {
    resizable: true
  },
  taskBarConfig: {
    showProgress: true,
    showContent: true,
    barStyle: {
      round: true,
      bgColor: '#fca60b',
      completedBgColor: '#65c16f'
    }
  },
  taskViewConfig: {
    tableStyle: {
      width: 480
    }
  },
  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 }
  ],
  menuConfig: {
    header: {
    body: {
      options: [
        [
          { code: 'copy', name: '复制内容(Ctrl+C)', prefixConfig: { icon: 'vxe-icon-copy' }, visible: true, disabled: false },
          { code: 'clear', name: '清除内容', visible: true, disabled: false },
          { code: 'reload', name: '刷新表格', visible: true, disabled: false }
        ],
        [
          {
            code: 'fixed',
            name: '冻结列',
            children: [
              { code: 'cancelFixed', name: '取消冻结' },
              { code: 'fixedLeft', name: '冻结在左侧', prefixConfig: { icon: 'vxe-icon-fixed-left' } },
              { code: 'fixedRight', name: '冻结在右侧', prefixConfig: { icon: 'vxe-icon-fixed-right' } }
            ]
          }
        ],
        [
          { code: 'myPrint', name: '打印(Ctrl+P)', prefixConfig: { icon: 'vxe-icon-print' }, visible: true, disabled: false },
          { code: 'myExport', name: '导出.csv', prefixConfig: { icon: 'vxe-icon-download' }, visible: true, disabled: false }
        ]
      ]
    }
  }
})

const ganttEvents = {
  menuClick ({ menu }) {
    VxeUI.modal.message({ content: `点击了 ${menu.code}`, status: 'success' })
  }
}
</script>

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

相关推荐
Violet_YSWY10 分钟前
讲一下ruoyi-vue3的前端项目目录结构
前端·javascript·vue.js
C_心欲无痕13 分钟前
vue3 - toRaw获取响应式对象(如由reactive创建的)的原始对象
前端·javascript·vue.js
老华带你飞18 分钟前
学生宿舍管理|基于java + vue学生宿舍管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot·后端
OpenTiny社区20 分钟前
2025年OpenTiny年度人气贡献者评选正式开始
前端·javascript·vue.js
JosieBook22 分钟前
【Vue】04 Vue技术——Vue 模板语法详解:插值与指令
前端·javascript·vue.js
BD_Marathon23 分钟前
Router_编程式路由
vue.js
Mr.app25 分钟前
Vue3 + TS 动态路由系统实现总结
vue.js
贺今宵29 分钟前
el-table-v2element plus+大量数据展示虚拟表格实现自定义排序,选择样式调整行高亮
javascript·vue.js·ecmascript
计算机程序设计小李同学1 小时前
基于 Spring Boot 和 Vue.js 技术栈的网上订餐系统
vue.js·spring boot·后端
毕设十刻1 小时前
基于Vue的家教预约系统7fisz(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js