網站首頁 編程語言 正文
jQuery實現將一個ant-table的數據拖拽復制到另一個ant-table,供大家參考,具體內容如下
需求
1、ant-design-vue
2、將一個嵌套在drawer中的table數據拖拽復制到drawer外面的table中
效果
拖拽中
拖拽后
HTML
選擇字段 // 拖拽到table..... // 從drawer中拖拽數據
JS
initDrop() { ?? ??? ??? ?// initDrop在mounted中觸發,使table區域可以接受拖拽? ? ? ? ? ? ? let that = this ? ? ? ? ? ? $('.table_container').droppable({ ? ? ? ? ? ? ? ? scope: 'basic', // 設置兩個相同的scope接受拖拽信息 ? ? ? ? ? ? ? ? tolerance: 'fit', ? ? ? ? ? ? ? ? drop(e) { ? ? ? ? ? ? ? ? ? ? let dropFieldInfo = { ? ? ? ? ? ? ? ? ? ? ? ? enName: that.dragField.enname || '', ? ? ? ? ? ? ? ? ? ? ? ? cnName: that.dragField.name || '', ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? that.fieldInfoList.push(dropFieldInfo) ? ? ? ? ? ? ? ? ? ? that.repeatZhName() // 校驗字段是否重復的方法 ? ? ? ? ? ? ? ? } ? ? ? ? ? ? }) ? ? ? ? }, ?choseField() { ? ? ? ? ? ? this.$refs.fieldList.setShowState(true) ?//顯示drawer ? ? ? ? ? ? // 因為drawer中的dom對象實在打開抽屜時候才會被創建,所以不能再drawer組件中進行初始化 ? ? ? ? ? ? this.$nextTick(() => { ? ? ? ? ? ? ?? ?// sort-table為抽屜組件中ant-table的類名 ? ? ? ? ? ? ? ? $('.sort-table tbody tr').draggable({ ? ? ? ? ? ? ? ? ? ? scope: 'basic', ?//相同的scope name ? ? ? ? ? ? ? ? ? ? scroll: false, ? ? ? ? ? ? ? ? ? ? zIndex: 10000, ?// zindex設置更高避免拖拽的數據被drawer遮住,同時去除遮罩層樣式 ? ? ? ? ? ? ? ? ? ? helper: 'clone', ? ? ? ? ? ? ? ? ? ? appendTo: 'body', ?//避免遮蓋 ? ? ? ? ? ? ? ? ? ? containment: document.getElementById('app'), ? ? ? ? ? ? ? ? ? ? start: e => { ? ? ? ? ? ? ? ? ? ? ?? ?// rowIndex第一行是表頭,數據行的rowindex從1開始 ? ? ? ? ? ? ? ? ? ? ? ? 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('拖拽結束事件') ? ? ? ? ? ? ? ? ? ? ? ? console.log(e) ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? }) ? ? ? ? ? ? }) ? },
注意事項
1、drop和drag區域要配置相同的scope
2、為了避免拖拽的helper被遮住,drag要配置zIndex和appendTo
3、如果表格有翻頁或者查詢功能,列表數據會刷新,jq的拖拽會失效,在getList請求方法成功之后,在初始化一次拖拽事件即可,然后使用$emit讓父組件接收一下
原文鏈接:https://blog.csdn.net/weixin_44328764/article/details/116783360
相關推薦
- 2022-01-21 【每天一個 Linux 命令】Linux命令 mkdir,cat,touch,vi/vim
- 2023-07-14 react實現拖拽功能
- 2022-03-26 C++缺省參數的具體使用_C 語言
- 2023-02-23 淺談Go語言的高效編碼細節_Golang
- 2022-04-01 使用Git clone代碼失敗的解決方法
- 2022-06-17 Android?SearchView搜索控件使用方法詳解_Android
- 2022-08-30 MongoDB數據庫基礎知識整理_MongoDB
- 2022-07-19 macOS Docker 內存 CPU 占用過高,監控到 com.Docker.hyperkit 進
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支