網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
jQuery實(shí)現(xiàn)將一個(gè)ant-table的數(shù)據(jù)拖拽復(fù)制到另一個(gè)ant-table,供大家參考,具體內(nèi)容如下
需求
1、ant-design-vue
2、將一個(gè)嵌套在drawer中的table數(shù)據(jù)拖拽復(fù)制到drawer外面的table中
效果
拖拽中
拖拽后
HTML
選擇字段 // 拖拽到table..... // 從drawer中拖拽數(shù)據(jù)
JS
initDrop() { ?? ??? ??? ?// initDrop在mounted中觸發(fā),使table區(qū)域可以接受拖拽? ? ? ? ? ? ? let that = this ? ? ? ? ? ? $('.table_container').droppable({ ? ? ? ? ? ? ? ? scope: 'basic', // 設(shè)置兩個(gè)相同的scope接受拖拽信息 ? ? ? ? ? ? ? ? tolerance: 'fit', ? ? ? ? ? ? ? ? drop(e) { ? ? ? ? ? ? ? ? ? ? let dropFieldInfo = { ? ? ? ? ? ? ? ? ? ? ? ? enName: that.dragField.enname || '', ? ? ? ? ? ? ? ? ? ? ? ? cnName: that.dragField.name || '', ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? that.fieldInfoList.push(dropFieldInfo) ? ? ? ? ? ? ? ? ? ? that.repeatZhName() // 校驗(yàn)字段是否重復(fù)的方法 ? ? ? ? ? ? ? ? } ? ? ? ? ? ? }) ? ? ? ? }, ?choseField() { ? ? ? ? ? ? this.$refs.fieldList.setShowState(true) ?//顯示drawer ? ? ? ? ? ? // 因?yàn)閐rawer中的dom對(duì)象實(shí)在打開(kāi)抽屜時(shí)候才會(huì)被創(chuàng)建,所以不能再drawer組件中進(jìn)行初始化 ? ? ? ? ? ? this.$nextTick(() => { ? ? ? ? ? ? ?? ?// sort-table為抽屜組件中ant-table的類(lèi)名 ? ? ? ? ? ? ? ? $('.sort-table tbody tr').draggable({ ? ? ? ? ? ? ? ? ? ? scope: 'basic', ?//相同的scope name ? ? ? ? ? ? ? ? ? ? scroll: false, ? ? ? ? ? ? ? ? ? ? zIndex: 10000, ?// zindex設(shè)置更高避免拖拽的數(shù)據(jù)被drawer遮住,同時(shí)去除遮罩層樣式 ? ? ? ? ? ? ? ? ? ? helper: 'clone', ? ? ? ? ? ? ? ? ? ? appendTo: 'body', ?//避免遮蓋 ? ? ? ? ? ? ? ? ? ? containment: document.getElementById('app'), ? ? ? ? ? ? ? ? ? ? start: e => { ? ? ? ? ? ? ? ? ? ? ?? ?// rowIndex第一行是表頭,數(shù)據(jù)行的rowindex從1開(kāi)始 ? ? ? ? ? ? ? ? ? ? ? ? let currentIndex = e.target.rowIndex - 1 ? ? ? ? ? ? ? ? ? ? ? ? // console.log(this.$refs.fieldList.tableData[currentIndex]) ? ? ? ? ? ? ? ? ? ? ? ? this.dragField = this.$refs.fieldList.tableData[currentIndex] ? ? ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? ? ? stop: e => { ? ? ? ? ? ? ? ? ? ? ? ? // this.eventType = 'CLICK' ? ? ? ? ? ? ? ? ? ? ? ? console.log('拖拽結(jié)束事件') ? ? ? ? ? ? ? ? ? ? ? ? console.log(e) ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? }) ? ? ? ? ? ? }) ? },
注意事項(xiàng)
1、drop和drag區(qū)域要配置相同的scope
2、為了避免拖拽的helper被遮住,drag要配置zIndex和appendTo
3、如果表格有翻頁(yè)或者查詢(xún)功能,列表數(shù)據(jù)會(huì)刷新,jq的拖拽會(huì)失效,在getList請(qǐng)求方法成功之后,在初始化一次拖拽事件即可,然后使用$emit讓父組件接收一下
原文鏈接:https://blog.csdn.net/weixin_44328764/article/details/116783360
相關(guān)推薦
- 2023-02-23 Go?routine使用方法講解_Golang
- 2022-07-06 pandas如何統(tǒng)計(jì)某一列或某一行的缺失值數(shù)目_python
- 2022-09-25 C++ sort比較函數(shù)的寫(xiě)法,最全面的總結(jié)
- 2022-04-09 SpringBoot 項(xiàng)目在Linux 環(huán)境下,日志文件logback撐爆云服務(wù)器
- 2022-10-31 Golang?template?包基本原理分析_Golang
- 2022-04-14 python實(shí)現(xiàn)購(gòu)物車(chē)小程序_python
- 2022-04-03 用Python實(shí)現(xiàn)控制電腦鼠標(biāo)_python
- 2022-12-10 OpenMP深入剖析reduction子句教程_C 語(yǔ)言
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支