diff --git a/jjb.config.js b/jjb.config.js index 06f0f31..23bd438 100644 --- a/jjb.config.js +++ b/jjb.config.js @@ -9,7 +9,7 @@ module.exports = { // 应用后端分支名称,部署上线需要 javaGitBranch: "", // 接口服务地址 - API_HOST: "http://192.168.20.100:30140", + API_HOST: "https://gbs-gateway.qhdsafety.com", // API_HOST: "http://127.0.0.1", }, production: { @@ -25,7 +25,7 @@ module.exports = { contextInject: { // 应用Key appKey: "", - fileUrl: "附件地址", + fileUrl: "https://jpfz.qhdsafety.com/gbsFileTest/", }, // public/index.html注入全局变量 windowInject: { diff --git a/src/pages/Container/BranchCompany/ControlRoom/View/index.js b/src/pages/Container/BranchCompany/ControlRoom/View/index.js index 180ce28..d1d81a1 100644 --- a/src/pages/Container/BranchCompany/ControlRoom/View/index.js +++ b/src/pages/Container/BranchCompany/ControlRoom/View/index.js @@ -1,12 +1,14 @@ import { Permission } from "@cqsjjb/jjb-common-decorator/permission"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; -import { Button, Card, Descriptions, Image, message, Space, Table } from "antd"; +import { Button, Card, Descriptions, message, Table } from "antd"; import { useEffect, useState } from "react"; import Page from "zy-react-library/components/Page"; +import PreviewImg from "zy-react-library/components/PreviewImg"; import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj"; import useDictionary from "zy-react-library/hooks/useDictionary"; import useGetFile from "zy-react-library/hooks/useGetFile"; import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery"; +import { getFileUrl } from "zy-react-library/utils"; import { NS_CONTROL_ROOM } from "~/enumerate/namespace"; function View(props) { @@ -18,18 +20,38 @@ function View(props) { const { loading: dictLoading, getDictionary } = useDictionary(); const { loading: getFileLoading, getFile } = useGetFile(); + const normalizeFiles = (files = []) => { + const baseUrl = getFileUrl() || ""; + return files.filter(Boolean).map((file) => { + if (typeof file === "string") { + const normalizedPath = baseUrl && file.startsWith(baseUrl) + ? file.slice(baseUrl.length) + : file; + return { filePath: normalizedPath }; + } + const rawPath = file.filePath || file.path || file.fileUrl || file.url || file.file; + if (!rawPath) { + return file; + } + const normalizedPath = baseUrl && rawPath.startsWith(baseUrl) + ? rawPath.slice(baseUrl.length) + : rawPath; + return { ...file, filePath: normalizedPath }; + }); + }; + const getData = async () => { setLoading(true); try { const { data } = await props["controlRoomDetail"]({ id: query.id }); - + console.log("dadada" + data) // 获取图片文件 if (data.roomId) { const files = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM[302], eqForeignKey: data.roomId, }); - data.roomImages = files; + data.roomImages = normalizeFiles(files); } setDetail(data); @@ -187,20 +209,7 @@ function View(props) { label: "消防控制室图片", children: detail.roomImages && detail.roomImages.length > 0 ? ( - - - {detail.roomImages.map((img, index) => ( - {`消防控制室图片${index - ))} - - + ) : "-", span: 2, diff --git a/src/pages/Container/BranchCompany/PumpRoom/View/index.js b/src/pages/Container/BranchCompany/PumpRoom/View/index.js index d4c9cc4..6fa2694 100644 --- a/src/pages/Container/BranchCompany/PumpRoom/View/index.js +++ b/src/pages/Container/BranchCompany/PumpRoom/View/index.js @@ -1,13 +1,15 @@ import { Permission } from "@cqsjjb/jjb-common-decorator/permission"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; -import { Button, Card, Descriptions, Image, message, Space, Table } from "antd"; +import { Button, Card, Descriptions, message, Table } from "antd"; import { useEffect, useState } from "react"; import Page from "zy-react-library/components/Page"; import { UPLOAD_FILE_TYPE_ENUM } from "zy-react-library/enum/uploadFile/gwj"; import useDictionary from "zy-react-library/hooks/useDictionary"; import useGetFile from "zy-react-library/hooks/useGetFile"; import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery"; +import { getFileUrl } from "zy-react-library/utils"; import { NS_PUMP_ROOM } from "~/enumerate/namespace"; +import PreviewImg from "zy-react-library/components/PreviewImg"; function View(props) { const query = useGetUrlQuery(); @@ -18,6 +20,26 @@ function View(props) { const { getDictionary } = useDictionary(); const { loading: getFileLoading, getFile } = useGetFile(); + const normalizeFiles = (files = []) => { + const baseUrl = getFileUrl() || ""; + return files.filter(Boolean).map((file) => { + if (typeof file === "string") { + const normalizedPath = baseUrl && file.startsWith(baseUrl) + ? file.slice(baseUrl.length) + : file; + return { filePath: normalizedPath }; + } + const rawPath = file.filePath || file.path || file.fileUrl || file.url || file.file; + if (!rawPath) { + return file; + } + const normalizedPath = baseUrl && rawPath.startsWith(baseUrl) + ? rawPath.slice(baseUrl.length) + : rawPath; + return { ...file, filePath: normalizedPath }; + }); + }; + useEffect(() => { const fetchDict = async () => { try { @@ -53,7 +75,7 @@ function View(props) { eqType: UPLOAD_FILE_TYPE_ENUM[302], eqForeignKey: roomKey, }); - data.roomImages = files; + data.roomImages = normalizeFiles(files); } setDetail(data); @@ -174,20 +196,8 @@ function View(props) { label: "消防泵房图片", children: detail.roomImages && detail.roomImages.length > 0 ? ( - - - {detail.roomImages.map((img, index) => ( - {`消防泵房图片${index - ))} - - + + ) : "-", span: 2,