Commit d1f1652e authored by wuyongsheng's avatar wuyongsheng

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

fix: 查看文件跳转

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