설명 없음

fix_detail_attach.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. import re
  3. p = r"d:\code\javaproject\huimv_tuzai_erp\ruoyi-ui\src\views\basic\waybill\components\WaybillDetail.vue"
  4. t = open(p, encoding="utf-8").read()
  5. new_attach = (
  6. " attachments() {\n"
  7. " const raw = this.detail.attachment;\n"
  8. " const base = this.formatDateTime(this.detail.createTime) || \"\";\n"
  9. " const baseUrl = process.env.VUE_APP_BASE_API || \"\";\n"
  10. " if (!raw) return [];\n"
  11. " return String(raw).split(\",\").filter(Boolean).map((url) => {\n"
  12. " const path = url.trim();\n"
  13. " const name = path.lastIndexOf(\"/\") >= 0 ? path.substring(path.lastIndexOf(\"/\") + 1) : path;\n"
  14. " return { name, url: path, fullUrl: path.startsWith(\"http\") ? path : baseUrl + path, time: base };\n"
  15. " });\n"
  16. " },"
  17. )
  18. new_preview = (
  19. " previewFile(file) {\n"
  20. " const url = file.fullUrl || file.url;\n"
  21. " if (url) window.open(url, \"_blank\");\n"
  22. " else this.$modal.msgInfo(\"\u9884\u89c8\uff1a\" + file.name);\n"
  23. " },\n"
  24. " downloadFile(file) {\n"
  25. " const url = file.fullUrl || file.url;\n"
  26. " if (url) window.open(url, \"_blank\");\n"
  27. " else this.$modal.msgInfo(\"\u4e0b\u8f7d\uff1a\" + file.name);\n"
  28. " }"
  29. )
  30. t = re.sub(r" attachments\(\) \{[\s\S]*? \},", new_attach, t, count=1)
  31. t = re.sub(
  32. r" previewFile\(file\) \{[\s\S]*? downloadFile\(file\) \{[\s\S]*? \}",
  33. new_preview,
  34. t,
  35. count=1,
  36. )
  37. open(p, "w", encoding="utf-8", newline="\n").write(t)
  38. print("ok", "detail.attachment" in t)