# -*- coding: utf-8 -*- import re p = r"d:\code\javaproject\huimv_tuzai_erp\ruoyi-ui\src\views\basic\waybill\components\WaybillDetail.vue" t = open(p, encoding="utf-8").read() new_attach = ( " attachments() {\n" " const raw = this.detail.attachment;\n" " const base = this.formatDateTime(this.detail.createTime) || \"\";\n" " const baseUrl = process.env.VUE_APP_BASE_API || \"\";\n" " if (!raw) return [];\n" " return String(raw).split(\",\").filter(Boolean).map((url) => {\n" " const path = url.trim();\n" " const name = path.lastIndexOf(\"/\") >= 0 ? path.substring(path.lastIndexOf(\"/\") + 1) : path;\n" " return { name, url: path, fullUrl: path.startsWith(\"http\") ? path : baseUrl + path, time: base };\n" " });\n" " }," ) new_preview = ( " previewFile(file) {\n" " const url = file.fullUrl || file.url;\n" " if (url) window.open(url, \"_blank\");\n" " else this.$modal.msgInfo(\"\u9884\u89c8\uff1a\" + file.name);\n" " },\n" " downloadFile(file) {\n" " const url = file.fullUrl || file.url;\n" " if (url) window.open(url, \"_blank\");\n" " else this.$modal.msgInfo(\"\u4e0b\u8f7d\uff1a\" + file.name);\n" " }" ) t = re.sub(r" attachments\(\) \{[\s\S]*? \},", new_attach, t, count=1) t = re.sub( r" previewFile\(file\) \{[\s\S]*? downloadFile\(file\) \{[\s\S]*? \}", new_preview, t, count=1, ) open(p, "w", encoding="utf-8", newline="\n").write(t) print("ok", "detail.attachment" in t)