陈瑞芝 發表於 2025-12-8 11:42:00

vue 如何实现 vxe-gantt table 甘特图的任务拖拽后调整日期的二次确认提示

<p>vue 如何实现 vxe-gantt table 甘特图的任务拖拽后调整日期的二次确认提示</p>
<p>查看官网:https://gantt.vxeui.com/<br>
gitbub:https://github.com/x-extends/vxe-gantt<br>
gitee:https://gitee.com/x-extends/vxe-gantt</p>
<h2 id="效果">效果</h2>
<p><img src="https://img2024.cnblogs.com/blog/3563285/202512/3563285-20251208114120933-750503899.gif"></p>
<h2 id="代码">代码</h2>
<p>通过设置 task-bar-drag-config.dragEndMethod 对拖拽后的行为进行二次确认</p>
<pre><code class="language-html">&lt;template&gt;
&lt;div&gt;
    &lt;vxe-gantt v-bind="ganttOptions"&gt;&lt;/vxe-gantt&gt;
&lt;/div&gt;
&lt;/template&gt;

&lt;script setup&gt;
import { reactive } from 'vue'
import { VxeUI } from 'vxe-pc-ui'

const ganttOptions = reactive({
border: true,
height: 500,
taskBarConfig: {
    showProgress: true, // 是否显示进度条
    showContent: true, // 是否在任务条显示内容
    move: true, // 是否允许拖拽任务调整日期
    barStyle: {
      round: true, // 圆角
      bgColor: '#fca60b', // 任务条的背景颜色
      completedBgColor: '#65c16f' // 已完成部分任务条的背景颜色
    }
},
taskViewConfig: {
    tableStyle: {
      width: 480 // 表格宽度
    }
},
taskBarDragConfig: {
    async dragEndMethod () {
      const type = await VxeUI.modal.confirm({
      content: '请是否确认调整顺序?'
      })
      if (type === 'confirm') {
      return true
      } else {
      VxeUI.modal.message({
          content: '操作已取消',
          status: 'warning'
      })
      }
      return false
    }
},
columns: [
    { type: 'seq', width: 70 },
    { field: 'title', title: '任务名称' },
    { field: 'start', title: '开始时间', width: 100 },
    { field: 'end', title: '结束时间', width: 100 },
    { field: 'progress', title: '进度(%)', width: 80 }
],
data: [
    { id: 10001, title: '任务1', start: '2024-03-01', end: '2024-03-04', progress: 3 },
    { id: 10002, title: '任务2', start: '2024-03-03', end: '2024-03-08', progress: 10 },
    { id: 10003, title: '任务3', start: '2024-03-03', end: '2024-03-11', progress: 90 },
    { id: 10004, title: '任务4', start: '2024-03-05', end: '2024-03-11', progress: 15 },
    { id: 10005, title: '任务5', start: '2024-03-08', end: '2024-03-15', progress: 100 },
    { id: 10006, title: '任务6', start: '2024-03-10', end: '2024-03-21', progress: 5 },
    { id: 10007, title: '任务7', start: '2024-03-15', end: '2024-03-24', progress: 70 },
    { id: 10008, title: '任务8', start: '2024-03-05', end: '2024-03-15', progress: 50 },
    { id: 10009, title: '任务9', start: '2024-03-19', end: '2024-03-20', progress: 5 },
    { id: 10010, title: '任务10', start: '2024-03-12', end: '2024-03-20', progress: 10 },
    { id: 10011, title: '任务11', start: '2024-03-01', end: '2024-03-08', progress: 90 },
    { id: 10012, title: '任务12', start: '2024-03-03', end: '2024-03-06', progress: 60 },
    { id: 10013, title: '任务13', start: '2024-03-02', end: '2024-03-05', progress: 50 },
    { id: 10014, title: '任务14', start: '2024-03-04', end: '2024-03-15', progress: 0 },
    { id: 10015, title: '任务15', start: '2024-03-01', end: '2024-03-05', progress: 30 }
]
})
&lt;/script&gt;
</code></pre>
<p>https://gitee.com/x-extends/vxe-gantt</p><br><br>
来源:https://www.cnblogs.com/qaz666/p/19320855
頁: [1]
查看完整版本: vue 如何实现 vxe-gantt table 甘特图的任务拖拽后调整日期的二次确认提示