vue?table?甘特圖vxe-gantt?實(shí)現(xiàn)多個(gè)表格的任務(wù)互相拖拽數(shù)據(jù)功能
vue table 甘特圖 vxe-gantt 實(shí)現(xiàn)多個(gè)表格的任務(wù)互相拖拽數(shù)據(jù)
對(duì)于需要實(shí)現(xiàn)多表數(shù)據(jù)互相拖拽的場(chǎng)景就非常有用了,實(shí)現(xiàn)方式非常簡單
查看官網(wǎng):https://vxeui.com
Github:https://github.com/x-extends/vxe-gantt
Gitee:https://gitee.com/x-extends/vxe-gantt
效果

代碼
通過參數(shù) row-drag-config.isCrossTableDrag 啟用跨表格、多表格互相拖拽??绫硗献枰_保數(shù)據(jù)主鍵不重復(fù),通過 row-config.keyField 指定主鍵字段名
<template>
<div>
<vxe-button status="success" @click="resultEvent1">獲取數(shù)據(jù)1</vxe-button>
<vxe-gantt ref="ganttRef1" v-bind="ganttOptions1"></vxe-gantt>
<vxe-button status="success" @click="resultEvent2">獲取數(shù)據(jù)2</vxe-button>
<vxe-gantt ref="ganttRef2" v-bind="ganttOptions2"></vxe-gantt>
<vxe-button status="success" @click="resultEvent3">獲取數(shù)據(jù)3</vxe-button>
<vxe-gantt ref="ganttRef3" v-bind="ganttOptions3"></vxe-gantt>
</div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import { VxeUI } from 'vxe-pc-ui'
const ganttRef1 = ref()
const ganttOptions1 = reactive({
border: true,
height: 240,
rowConfig: {
drag: true,
keyField: 'id'
},
rowDragConfig: {
isCrossTableDrag: true // 允許跨表
},
columns: [
{ type: 'seq', width: 70 },
{ field: 'title', title: '任務(wù)名稱', minWidth: 160, dragSort: true },
{ field: 'start', title: '開始時(shí)間', width: 100 },
{ field: 'end', title: '結(jié)束時(shí)間', width: 100 }
],
data: [
{ id: 10001, title: 'A項(xiàng)目', start: '2024-03-01', end: '2024-03-04', progress: 3 },
{ id: 10002, title: '城市道路修理進(jìn)度', 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: '超級(jí)大工程', start: '2024-03-05', end: '2024-03-11', progress: 15 },
{ id: 10005, title: '地球凈化項(xiàng)目', start: '2024-03-08', end: '2024-03-15', progress: 100 },
{ id: 10006, title: '一個(gè)小目標(biāo)項(xiàng)目', start: '2024-03-10', end: '2024-03-21', progress: 0 }
]
})
const resultEvent1 = () => {
const $gantt = ganttRef1.value
if ($gantt) {
const { insertRecords, removeRecords } = $gantt.getRecordset()
const tableData = $gantt.getFullData()
VxeUI.modal.message({
content: `新增:${insertRecords.length} 刪除:${removeRecords.length} 現(xiàn)有:${tableData.length}`,
status: 'success'
})
}
}
const ganttRef2 = ref()
const ganttOptions2 = reactive({
border: true,
height: 240,
rowConfig: {
drag: true,
keyField: 'id'
},
rowDragConfig: {
isCrossTableDrag: true // 允許跨表
},
columns: [
{ type: 'seq', width: 70 },
{ field: 'title', title: '任務(wù)名稱', minWidth: 160, dragSort: true },
{ field: 'start', title: '開始時(shí)間', width: 100 },
{ field: 'end', title: '結(jié)束時(shí)間', width: 100 }
],
data: [
{ id: 10007, title: '某某計(jì)劃', start: '2024-03-15', end: '2024-03-24', progress: 70 },
{ id: 10008, title: '某某科技項(xiàng)目', start: '2024-03-20', end: '2024-03-29', progress: 50 },
{ id: 10009, title: '地鐵建設(shè)工程', start: '2024-03-19', end: '2024-03-20', progress: 5 },
{ id: 10010, title: '公寓裝修計(jì)劃2', start: '2024-03-12', end: '2024-03-20', progress: 30 },
{ id: 10011, title: '兩個(gè)小目標(biāo)工程', start: '2024-03-01', end: '2024-03-04', progress: 20 },
{ id: 10012, title: '藍(lán)天計(jì)劃', start: '2024-03-02', end: '2024-03-08', progress: 50 },
{ id: 10013, title: 'C大項(xiàng)目', start: '2024-03-08', end: '2024-03-11', progress: 10 },
{ id: 10014, title: 'H計(jì)劃', start: '2024-03-12', end: '2024-03-16', progress: 100 }
]
})
const resultEvent2 = () => {
const $gantt = ganttRef2.value
if ($gantt) {
const { insertRecords, removeRecords } = $gantt.getRecordset()
const tableData = $gantt.getFullData()
VxeUI.modal.message({
content: `新增:${insertRecords.length} 刪除:${removeRecords.length} 現(xiàn)有:${tableData.length}`,
status: 'success'
})
}
}
const ganttRef3 = ref()
const ganttOptions3 = reactive({
border: true,
height: 240,
rowConfig: {
drag: true,
keyField: 'id'
},
rowDragConfig: {
isCrossTableDrag: true // 允許跨表
},
columns: [
{ type: 'seq', width: 70 },
{ field: 'title', title: '任務(wù)名稱', minWidth: 160, dragSort: true },
{ field: 'start', title: '開始時(shí)間', width: 100 },
{ field: 'end', title: '結(jié)束時(shí)間', width: 100 }
],
data: [
{ id: 10015, title: '鐵路修建計(jì)劃', start: '2024-03-05', end: '2024-03-06', progress: 0 },
{ id: 10016, title: 'D項(xiàng)目', start: '2024-03-06', end: '2024-03-11', progress: 10 },
{ id: 10017, title: '海外改造工程', start: '2024-03-08', end: '2024-03-09', progress: 0 },
{ id: 10018, title: 'Z計(jì)劃', start: '2024-03-24', end: '2024-03-26', progress: 80 },
{ id: 10019, title: 'F工程', start: '2024-03-20', end: '2024-03-28', progress: 10 },
{ id: 10020, title: '投資大項(xiàng)目', start: '2024-03-23', end: '2024-03-28', progress: 60 },
{ id: 10021, title: 'X計(jì)劃', start: '2024-03-16', end: '2024-03-25', progress: 10 },
{ id: 10022, title: '上天計(jì)劃', start: '2024-03-05', end: '2024-03-24', progress: 0 },
{ id: 10023, title: 'G項(xiàng)目', start: '2024-03-08', end: '2024-03-28', progress: 5 },
{ id: 10024, title: '下地計(jì)劃', start: '2024-03-09', end: '2024-03-16', progress: 50 }
]
})
const resultEvent3 = () => {
const $gantt = ganttRef3.value
if ($gantt) {
const { insertRecords, removeRecords } = $gantt.getRecordset()
const tableData = $gantt.getFullData()
VxeUI.modal.message({
content: `新增:${insertRecords.length} 刪除:${removeRecords.length} 現(xiàn)有:${tableData.length}`,
status: 'success'
})
}
}
</script>
https://gitee.com/x-extends/vxe-gantt
到此這篇關(guān)于vue table 甘特圖vxe-gantt 實(shí)現(xiàn)多個(gè)表格的任務(wù)互相拖拽數(shù)據(jù)功能的文章就介紹到這了,更多相關(guān)vue table甘特圖 vxe-gantt內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
buildAdmin開源項(xiàng)目引入四種圖標(biāo)方式詳解
這篇文章主要為大家介紹了buildAdmin開源項(xiàng)目引入四種圖標(biāo)方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
安裝vue-cli報(bào)錯(cuò) -4058 的解決方法
這篇文章主要介紹了安裝vue-cli報(bào)錯(cuò) -4058 的解決方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-10-10
vue+Ant?Design進(jìn)度條滑塊與input聯(lián)動(dòng)效果實(shí)現(xiàn)
最近接到這樣一個(gè)需求滑塊進(jìn)度與輸入框?yàn)橐恢?默認(rèn)值為80,最小不能小于30,最大為100,怎么實(shí)現(xiàn)這個(gè)聯(lián)動(dòng)效果呢,下面小編給大家分享下基于vue+Ant?Design進(jìn)度條滑塊與input聯(lián)動(dòng)效果的實(shí)現(xiàn),感興趣的朋友跟隨小編一起看看吧2022-12-12
vue項(xiàng)目中使用websocket的實(shí)現(xiàn)
本文主要介紹了vue項(xiàng)目中使用websocket的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-01-01

