Explorar o código

feat: 优化 PageFour 组件中的图片排序逻辑,确保与 PageThree 的 displayImages 顺序一致

Yannay hai 1 mes
pai
achega
e5e049abbb
Modificáronse 1 ficheiros con 15 adicións e 5 borrados
  1. 15 5
      pages/orderDetailRefactored/components/PageFour.vue

+ 15 - 5
pages/orderDetailRefactored/components/PageFour.vue

@@ -888,8 +888,7 @@ export default {
888 888
                 const brandId = brandObj ? brandObj.dictValue : ''
889 889
   
890 890
                 //建立入库data
891
-                // 获取 PageThree 的高清实物图的 fileUrl 数组
892
-                // 直接使用 imageUpload 获取图片列表,与 PageThree 保持一致
891
+                // 获取 PageThree 的高清实物图的 fileUrl 数组,顺序与 PageThree 的 displayImages 一致(按 fileIds 排序)
893 892
                 let goodPicFileUrls = []
894 893
                 if (this.currentReceipt.id && this.orderDetail.itemBrand) {
895 894
                   try {
@@ -900,9 +899,20 @@ export default {
900 899
                       this.orderDetail.itemBrand,
901 900
                       this.currentReceipt.clueId
902 901
                     )
903
-                    // 获取前6个图片的 fileUrl(与 PageThree 的 displayImages 保持一致)
904
-                    // goodPicFileUrls = (list || []).slice(0, 6).map(item => item.fileUrl).filter(url => url)
905
-                    goodPicFileUrls = (list || []).map(item => item.fileUrl).filter(url => url)
902
+                    // 按 currentReceipt.fileIds 排序,与 PageThree 的 loadDetailImages 逻辑一致
903
+                    let sortedList = list || []
904
+                    if (this.currentReceipt.fileIds && sortedList.length > 0) {
905
+                      const sortedIds = this.currentReceipt.fileIds.split(',')
906
+                      sortedList = [...sortedList].sort((a, b) => {
907
+                        const indexA = sortedIds.indexOf(a.id)
908
+                        const indexB = sortedIds.indexOf(b.id)
909
+                        if (indexA === -1 && indexB === -1) return 0
910
+                        if (indexA === -1) return 1
911
+                        if (indexB === -1) return -1
912
+                        return indexA - indexB
913
+                      })
914
+                    }
915
+                    goodPicFileUrls = sortedList.map(item => item.fileUrl).filter(url => url)
906 916
                   } catch (error) {
907 917
                     console.error('获取高清实物图失败:', error)
908 918
                   }