Commit d1f1652e authored by wuyongsheng's avatar wuyongsheng

Merge branch 'feat-20220608-projectdata' into 'release'

fix: 查看文件跳转

See merge request !40
parents 8ea32fdc 6236ec07
......@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-13 17:00:19
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-06-16 02:15:55
* @LastEditTime: 2022-06-16 09:43:42
* @FilePath: /bkunyun/src/store/modules/upload.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -13,6 +13,7 @@ export interface IUploadInfo {
id: string,
file: File,
info: any,
path: string;
}
/** 存储地图派单websocket推送数据状态的store */
......
import useGlobalStore from "@/hooks/useGlobalStore";
import { toJS } from "mobx";
import * as tus from "tus-js-client";
import {
verifyLettersNumbersCertainChars4,
} from "../helper";
import useGlobalStore from "@/hooks/useGlobalStore";
import { getTokenInfo } from "../util";
const UseTusUpload = (uploadInfoStore: any) => {
......@@ -19,7 +19,7 @@ const UseTusUpload = (uploadInfoStore: any) => {
url: string,
fileToken: string,
filepath: any,
callBack: any
callBack?: any
) => {
if (!verifyLettersNumbersCertainChars4(file.name)) {
let json = {
......
import { toJS } from "mobx";
import { useNavigate } from "react-router-dom";
import { observer } from "mobx-react-lite";
import { useMemo } from "react";
import { LinearProgress } from "@mui/material";
import styles from "./index.module.css";
import { useMemo } from "react";
import { formatTime, storageUnitFromB } from "@/utils/util";
import useGlobalStore from "@/hooks/useGlobalStore";
import { observer } from "mobx-react-lite";
import { IUploadInfo } from "@/store/modules/fileList";
import { useMessage } from "@/components/MySnackbar";
import styles from "./index.module.css";
/*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-11 15:46:42
......@@ -28,7 +29,7 @@ const FileItem = observer((props: IProps) => {
const { statusMsg = "" } = itemInfo || {};
const uploadInfoStore = toJS(useGlobalStore("fileListStore"));
const Message = useMessage();
console.log(toJS(fileItemInfo), "11111");
const navigate = useNavigate();
/** 时间 */
const TimeText = useMemo(() => {
......@@ -71,10 +72,11 @@ const FileItem = observer((props: IProps) => {
});
}
if (text === "查看文件") {
console.log("跳转");
navigate(`/product/cadd/projectData`, {
state: { pathName: fileItemInfo?.path },
});
}
};
return (
<div className={styles.itemBox}>
<div className={styles.leftBox}>
......@@ -105,7 +107,7 @@ const FileItem = observer((props: IProps) => {
<>
<span style={{ color: "#8A9099" }}>已上传至</span>
<span style={{ color: "#565C66", marginLeft: 12 }}>
{itemInfo?.dir}
{fileItemInfo?.path}
</span>
</>
) : (
......
......@@ -20,7 +20,6 @@ import { storageUnitFromB } from "@/utils/util";
import { observer } from "mobx-react";
import { useStores } from "@/store";
import { toJS } from "mobx";
import { IResponse, useHttp } from "@/api/http";
import useGlobalStore from "@/hooks/useGlobalStore";
import { APIOPTION, urlToken } from "@/api/fileserver/raysyncApi";
import UseTusUpload from "@/utils/Upload/tusUpload";
......@@ -28,7 +27,6 @@ import UseTusUpload from "@/utils/Upload/tusUpload";
const UpLoaderFile = observer((props: any) => {
const { fileListStore } = useStores();
const message = useMessage();
const http = useHttp();
const [fileList, setFileList] = useState<any>([]);
// list 是项目数据table的数据
......@@ -89,18 +87,6 @@ const UpLoaderFile = observer((props: any) => {
[fileList, message, nowNameList]
);
// const getRepeatName = (fList: Array<any>, Alist: Array<any>) => {
// let repeatName = "";
// Alist.forEach((aItem) => {
// fList.forEach((fItem: any) => {
// if (fItem.name === aItem.name) {
// repeatName = fItem.name;
// }
// });
// });
// return repeatName;
// };
const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop });
const submitloading = false;
......@@ -109,34 +95,29 @@ const UpLoaderFile = observer((props: any) => {
const getFileToken = useCallback(
(newFileList: any) => {
http
.get<IResponse<any>>(
`/cpp/data/filetoken?id=${
currentProjectStore?.currentProjectInfo.id || ""
}`
)
.then((res: any) => {
let url =
APIOPTION() +
"/parallelupload/" +
urlToken(
res?.data || "",
currentProjectStore?.currentProjectInfo?.id as string
);
newFileList?.forEach((item: any) => {
uploadFile(
item,
item?.file,
url,
res.data,
"/",
(upload: any, filepath: string) =>
console.log(upload, filepath, 1111)
);
});
});
let url =
APIOPTION() +
"/parallelupload/" +
urlToken(
currentProjectStore?.currentProjectInfo?.filetoken || "",
currentProjectStore?.currentProjectInfo?.id as string
);
newFileList?.forEach((item: any) => {
uploadFile(
item,
item?.file,
url,
currentProjectStore?.currentProjectInfo?.filetoken || "",
path
);
});
},
[currentProjectStore?.currentProjectInfo.id, http, uploadFile]
[
currentProjectStore?.currentProjectInfo?.filetoken,
currentProjectStore?.currentProjectInfo?.id,
uploadFile,
]
);
const handleSubmit = () => {
......@@ -144,10 +125,9 @@ const UpLoaderFile = observer((props: any) => {
fileList?.map((item: any) => {
return {
id: uuid(),
open: false,
path,
list: [],
file: item,
isPermanence: true,
};
}) || [];
toJS(fileListStore?.setNewFileList)(newFileList);
......@@ -159,12 +139,12 @@ const UpLoaderFile = observer((props: any) => {
const showDialog = () => {
dialogRef.current.handleClickOpen();
initData()
initData();
};
const initData = ()=>{
setFileList([])
}
const initData = () => {
setFileList([]);
};
useImperativeHandle(props.onRef, () => {
return {
......
......@@ -13,7 +13,6 @@ import fileIcon from "@/assets/project/fileIcon.svg";
import folderIcon from "@/assets/project/folderIcon.svg";
import noFile from "@/assets/project/noFile.svg";
import { useMessage } from "@/components/MySnackbar";
import { getDataFileToken } from "@/api/project_api";
import AddFolder from "./AddFolder";
import MoveFile from "./MoveFile";
import UpLoaderFile from "./UpLoaderFile";
......@@ -31,6 +30,7 @@ import DialogTitle from "@mui/material/DialogTitle";
import NoProject from "@/components/NoProject";
import usePass from "@/hooks/usePass";
import { storageUnitFromB } from "@/utils/util";
import { useLocation } from "react-router-dom";
import {
getDataFind,
getDataFileSearch,
......@@ -75,8 +75,10 @@ const ProjectData = observer(() => {
// );
// return toJS(currentProjectStore.currentProjectInfo.id);
// }, [currentProjectStore]);
/** 路由信息 */
const location = useLocation();
// 当前文件路径
const [path, setPath] = useState("/");
const [path, setPath] = useState<String>("/");
const [tableLoadding, setTableLoadding] = useState(false);
// 防止用户连续点击文件夹造成路径显示错误
const [debounce, setDebounce] = useState(false);
......@@ -104,6 +106,11 @@ const ProjectData = observer(() => {
}
};
useEffect(() => {
const locationInfo: any = location?.state;
setPath(locationInfo?.pathName || "");
}, [location]);
// 列表展示的数据
const showList = useMemo(() => {
if (activeTab === 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment