|
|
@@ -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() {
|