新增useGetUrlQuery
parent
c985265364
commit
44ad43f9b3
|
|
@ -10,6 +10,7 @@ import { UPLOAD_FILE_TYPE_ENUM } from "../../../enum/uploadFile/gwj";
|
||||||
import useGetFile from "../../../hooks/useGetFile";
|
import useGetFile from "../../../hooks/useGetFile";
|
||||||
import { getLabelName } from "../../../utils";
|
import { getLabelName } from "../../../utils";
|
||||||
import { HIDDEN_SOURCE_ENUM, HIDDEN_STATE_ENUM } from "../../../enum/hidden/gwj";
|
import { HIDDEN_SOURCE_ENUM, HIDDEN_STATE_ENUM } from "../../../enum/hidden/gwj";
|
||||||
|
import useGetUrlQuery from "../../../hooks/useGetUrlQuery";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 隐患查看组件(港务局版本)
|
* 隐患查看组件(港务局版本)
|
||||||
|
|
@ -39,29 +40,27 @@ function HiddenInfo(props) {
|
||||||
const [rectificationPlanImageFiles, setRectificationPlanImageFiles] = useState([]);
|
const [rectificationPlanImageFiles, setRectificationPlanImageFiles] = useState([]);
|
||||||
const [acceptImageFiles, setAcceptImageFiles] = useState([]);
|
const [acceptImageFiles, setAcceptImageFiles] = useState([]);
|
||||||
const { getFile } = useGetFile();
|
const { getFile } = useGetFile();
|
||||||
|
const query = useGetUrlQuery();
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
request(`/hidden/hidden/${id || query[idKey]}`, "get").then((res) => {
|
||||||
const queryId = urlParams.get(idKey);
|
|
||||||
const queryHiddenId = urlParams.get(hiddenIdKey);
|
|
||||||
request(`/hidden/hidden/${id || queryId}`, "get").then((res) => {
|
|
||||||
setInfo(res.data);
|
setInfo(res.data);
|
||||||
});
|
});
|
||||||
const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || queryHiddenId });
|
const hiddenImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["3"], eqForeignKey: hiddenId || query[hiddenIdKey] });
|
||||||
setHiddenImageFiles(hiddenImageFiles);
|
setHiddenImageFiles(hiddenImageFiles);
|
||||||
const hiddenVideoFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["102"], eqForeignKey: hiddenId || queryHiddenId });
|
const hiddenVideoFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["102"], eqForeignKey: hiddenId || query[hiddenIdKey] });
|
||||||
setHiddenVideoFiles(hiddenVideoFiles);
|
setHiddenVideoFiles(hiddenVideoFiles);
|
||||||
const afterRectificationImageFiles = await getFile({
|
const afterRectificationImageFiles = await getFile({
|
||||||
eqType: UPLOAD_FILE_TYPE_ENUM["4"],
|
eqType: UPLOAD_FILE_TYPE_ENUM["4"],
|
||||||
eqForeignKey: hiddenId || queryHiddenId,
|
eqForeignKey: hiddenId || query[hiddenIdKey],
|
||||||
});
|
});
|
||||||
setAfterRectificationImageFiles(afterRectificationImageFiles);
|
setAfterRectificationImageFiles(afterRectificationImageFiles);
|
||||||
const rectificationPlanImageFiles = await getFile({
|
const rectificationPlanImageFiles = await getFile({
|
||||||
eqType: UPLOAD_FILE_TYPE_ENUM["8"],
|
eqType: UPLOAD_FILE_TYPE_ENUM["8"],
|
||||||
eqForeignKey: hiddenId || queryHiddenId,
|
eqForeignKey: hiddenId || query[hiddenIdKey],
|
||||||
});
|
});
|
||||||
setRectificationPlanImageFiles(rectificationPlanImageFiles);
|
setRectificationPlanImageFiles(rectificationPlanImageFiles);
|
||||||
const acceptImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["5"], eqForeignKey: hiddenId || queryHiddenId });
|
const acceptImageFiles = await getFile({ eqType: UPLOAD_FILE_TYPE_ENUM["5"], eqForeignKey: hiddenId || query[hiddenIdKey] });
|
||||||
setAcceptImageFiles(acceptImageFiles);
|
setAcceptImageFiles(acceptImageFiles);
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
/**
|
||||||
|
* 获取路由参数
|
||||||
|
*/
|
||||||
|
export default function useGetUrlQuery(): Record<string, any>;
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
/**
|
||||||
|
* 获取路由参数
|
||||||
|
*/
|
||||||
|
function useGetUrlQuery() {
|
||||||
|
const urlQuery = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
|
// 直接返回包含所有参数的对象
|
||||||
|
const queryParams = {};
|
||||||
|
for (const [key, value] of urlQuery.entries()) {
|
||||||
|
queryParams[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useGetUrlQuery;
|
||||||
Loading…
Reference in New Issue