Browse Source

修改附件

chensibo 3 weeks ago
parent
commit
7eea34268f

+ 9 - 0
src/api/wms/quality/iqcInspectionExecute.js

@@ -261,3 +261,12 @@ export function createAttachmentUpload(data) {
     data: data,
   });
 }
+
+// 附件
+export function getIqcInspectionDataDetailForPda(query) {
+  return request({
+    url: "/rtkqms/incoming-receipt-inspection/iqcInspectionDataDetailForPda",
+    method: "get",
+    params: query,
+  });
+}

+ 36 - 13
src/views/wms/quality/iqcInspection/components/InspectAttachmentUpload.vue

@@ -31,7 +31,10 @@
 
 <script>
 import FileUpload from "@/components/FileUpload/index.vue";
-import { createAttachmentUpload } from "@/api/wms/quality/iqcInspectionExecute";
+import {
+  createAttachmentUpload,
+  getIqcInspectionDataDetailForPda,
+} from "@/api/wms/quality/iqcInspectionExecute";
 
 export default {
   components: {
@@ -62,23 +65,43 @@ export default {
     };
   },
   methods: {
-    // onOpen() {
-    //   this.$nextTick(() => {
-    //     this.$refs.fileUpload.isUploadShow = this.isUploadShow
-    //     this.$refs.fileUpload.fileList = this.fileList
-    //   })
-    // },
     onOpen() {
       this.$nextTick(() => {
-        // 如果外部已经把 fileList 传进来,就不再调接口
-        if (this.fileList && this.fileList.length) {
+        // 总是使用行ID调用接口获取附件列表
+        if (this.rowData && this.rowData.id) {
+          const id = this.rowData.id;
+          getIqcInspectionDataDetailForPda({ id: id }).then((res) => {
+            console.log("打印一下返回的数据", res);
+            if (res.code === 0 && res.data) {
+              // 处理后端返回的数据,生成符合FileUpload组件要求的fileList
+              const urlList = res.data.urlList || [];
+              const fileIds = res.data.fileIds || [];
+              this.$refs.fileUpload.fileList = urlList.map((url, index) => {
+                // 清理URL中的额外空格和括号
+                const cleanUrl = url.trim().replace(/[`]/g, "");
+                // 从URL中提取文件名
+                const lastSlashIndex = cleanUrl.lastIndexOf("/");
+                const fileName =
+                  lastSlashIndex !== -1
+                    ? cleanUrl.substring(lastSlashIndex + 1)
+                    : cleanUrl;
+                console.log("打印一下fileName", fileName);
+                return {
+                  // name: fileName,
+                  sysName: fileName,
+                  url: {
+                    fileId: fileIds[index] || "",
+                    url: cleanUrl,
+                  },
+                };
+              });
+            }
+          });
+        } else {
+          // 暂时使用传入的fileList作为后备
           this.$refs.fileUpload.fileList = this.fileList;
-          this.$refs.fileUpload.isUploadShow = this.isUploadShow;
-          return;
         }
-        // 否则保持原有逻辑(兼容旧场景)
         this.$refs.fileUpload.isUploadShow = this.isUploadShow;
-        this.$refs.fileUpload.fileList = this.fileList;
       });
     },
     close() {

+ 6 - 0
src/views/wms/quality/iqcInspection/components/InspectDetail.vue

@@ -1488,6 +1488,12 @@ export default {
       this.$refs.inspectAttachmentUpload.isUploadShow = -1; // 9=仅查看
       this.$refs.inspectAttachmentUpload.visible = true;
     },
+    // openRowFile(row) {
+    //   // 把行内附件列表传给弹窗
+    //   this.$refs.inspectFileUpload.fileList = row.filesList || [];
+    //   this.$refs.inspectFileUpload.isUploadShow = 9; // 9=仅查看
+    //   this.$refs.inspectFileUpload.visible = true;
+    // },
   },
 };
 </script>