ソースを参照

Merge branch 'master' into test-dev

duy 1 ヶ月 前
コミット
3f6576ea03
1 ファイル変更11 行追加1 行削除
  1. 11 1
      src/views/data-fill/wbs.vue

+ 11 - 1
src/views/data-fill/wbs.vue

@@ -3149,7 +3149,7 @@ const setAttachmentListRef = (el) => {
 
 // 初始化拖拽功能
 const initDragAndDrop = () => {
-  attachmentListRefs.value.forEach((container) => {
+  attachmentListRefs.value.forEach((container, index) => {
     const items = container.querySelectorAll('.hc-attachment-item')
     
     items.forEach((item) => {
@@ -3170,6 +3170,15 @@ const initDragAndDrop = () => {
           i.classList.remove('dragging')
           i.style.display = ''
         })
+        
+        // 获取新的顺序
+        const newOrder = Array.from(container.querySelectorAll('.hc-attachment-item')).map(item => item.dataset.id)
+        
+        // 更新 attachmentList.value 中对应项的 fileList 顺序
+        const attachment = attachmentList.value[index]
+        if (attachment) {
+          attachment.fileList = attachment.fileList.sort((a, b) => newOrder.indexOf(a.id) - newOrder.indexOf(b.id))
+        }
       })
     })
     
@@ -3226,6 +3235,7 @@ const saveFileOrderLoad = ref(false)
 const saveFileOrder = async () => {
 
     saveFileOrderLoad.value = true
+ console.log(attachmentList.value, 'attachmentList.value')
  
     const { error, code, msg } = await wbsApi.sortPdf( attachmentList.value)
     saveFileOrderLoad.value = false