diff --git a/web/src/api/fileSynchronization/index.ts b/web/src/api/fileSynchronization/index.ts index fcedbc1..dd2cd3f 100644 --- a/web/src/api/fileSynchronization/index.ts +++ b/web/src/api/fileSynchronization/index.ts @@ -70,4 +70,28 @@ export function obtainUrl(params:any) { method: 'post', params:params, }); -} \ No newline at end of file +} +//文件差异-新增 +export function compareLocal(params:any) { + return request({ + url: '/experimentalData/ts-files/compareLocal', + method: 'post', + params:params, + }); +} +//文件差异变更 +export function compareMd5(params:any) { + return request({ + url: '/experimentalData/ts-files/compareMd5', + method: 'post', + params:params, + }); +} +//文件差异-缺失 +export function compareMinio(params:any) { + return request({ + url: '/experimentalData/ts-files/compareMinio', + method: 'post', + params:params, + }); +} diff --git a/web/src/views/testdata/fileSynchronization/index.vue b/web/src/views/testdata/fileSynchronization/index.vue index 353c53d..cf0344b 100644 --- a/web/src/views/testdata/fileSynchronization/index.vue +++ b/web/src/views/testdata/fileSynchronization/index.vue @@ -9,8 +9,9 @@ import { ref, onMounted, nextTick, defineAsyncComponent, onBeforeUnmount } from import { Search } from '@element-plus/icons-vue' import { ElMessageBox, ElMessage } from "element-plus"; import { tstaskList, getTsNodesTree, tsFilesPage, deleteTsFilesByIds } from "@/api/datamanagement"; -import { listLocalAndBackup, compare, uploadToBackup, downloadToLocal, deleteTsFilesById,automaticFileBackup,obtainUrl } from "@/api/fileSynchronization"; +import { listLocalAndBackup, compare, compareLocal, compareMd5, compareMinio, uploadToBackup, downloadToLocal, deleteTsFilesById, automaticFileBackup, obtainUrl, listBackupTree, listLocalTree } from "@/api/fileSynchronization"; import { debounce } from 'lodash-es'; +import Page from '@/components/Pagination/page.vue'; //text文件编辑功能 import textEdit from '@/components/textEditing/index.vue' import txtexl from '@/components/textEditing/txtexl.vue' @@ -69,38 +70,73 @@ function diffFile() { comparearr.value = comparearr.value.filter(item => { return seen.has(item.id) ? false : seen.add(item.id); }); + tabs.value = 1 differential.value = true - getchayi() + // getchayi() + diffSure() + diffChange() + diffMiss() } -function backups(){ +function backups() { ElMessageBox.confirm( - '您确定要将文件/文件夹自动备份到备份空间吗?', - '警告', - { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', + '您确定要将文件/文件夹自动备份到备份空间吗?', + '警告', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + } + ) + .then(() => { + worktree.value = true + worktree1.value = true + automaticFileBackup({ nodeId: pathid.value, taskId: projectId.value }).then((res: any) => { + if (res.code == 0) { + ElMessage.success(res.msg) + getlocaltree() + getminiotree() } - ) - .then(() => { - worktree.value = true - automaticFileBackup({ nodeId: pathid.value, taskId: projectId.value }).then((res: any) => { - if(res.code == 0){ - ElMessage.success(res.msg) - getWorkData() - } - }) - }) - + }) + }) + } //文件差异性对比结果 const comparearr: any = ref([]) const localOnlyFiles: any = ref([]) const md5MismatchedFiles: any = ref([]) const minioOnlyFiles: any = ref([]) -const loading = ref(false) -function getchayi() { - loading.value = true +const loading1 = ref(false) +const loading2 = ref(false) +const loading3 = ref(false) +// function getchayi() { +// loading.value = true +// const ids = [] +// const params: any = {} +// if (comparearr.value.length > 0) { +// comparearr.value.forEach((item: any) => { +// ids.push(item.id) +// }) +// params.id = ids.join(',') +// } else { +// params.nodeId = pathid.value +// params.taskId = projectId.value +// } + + +// compare(params).then((res: any) => { +// localOnlyFiles.value = res.data.localOnlyFiles +// md5MismatchedFiles.value = res.data.md5MismatchedFiles +// minioOnlyFiles.value = res.data.minioOnlyFiles +// loading.value = false +// diffColor() +// }) +// } +//文件对比-新增内容 +const sureSize = ref(10) +const sureTotal = ref() +const sureCurrent = ref(1) +function diffSure() { + loading1.value = true const ids = [] const params: any = {} if (comparearr.value.length > 0) { @@ -112,13 +148,70 @@ function getchayi() { params.nodeId = pathid.value params.taskId = projectId.value } - - - compare(params).then((res: any) => { - localOnlyFiles.value = res.data.localOnlyFiles - md5MismatchedFiles.value = res.data.md5MismatchedFiles - minioOnlyFiles.value = res.data.minioOnlyFiles - loading.value = false + params.size = sureSize.value + params.current = sureCurrent.value + compareLocal(params).then((res: any) => { + loading1.value = false + localOnlyFiles.value = res.data.records + sureSize.value = res.data.size + sureTotal.value = res.data.total + sureCurrent.value = res.data.current + diffColor() + }) +} +//文件对比-变更内容 +const ChangeSize = ref(10) +const ChangeTotal = ref() +const ChangeCurrent = ref(1) +function diffChange() { + loading2.value = true + const ids = [] + const params: any = {} + if (comparearr.value.length > 0) { + comparearr.value.forEach((item: any) => { + ids.push(item.id) + }) + params.id = ids.join(',') + } else { + params.nodeId = pathid.value + params.taskId = projectId.value + } + params.size = ChangeSize.value + params.current = ChangeCurrent.value + compareMd5(params).then((res: any) => { + md5MismatchedFiles.value = res.data.records + loading2.value = false + ChangeSize.value = res.data.size + ChangeTotal.value = res.data.total + ChangeCurrent.value = res.data.current + diffColor() + }) +} +//文件对比-缺失内容 +const MisseSize = ref(10) +const MissTotal = ref() +const MissCurrent = ref(1) +function diffMiss() { + loading3.value = true + const ids = [] + const params: any = {} + if (comparearr.value.length > 0) { + comparearr.value.forEach((item: any) => { + ids.push(item.id) + }) + params.id = ids.join(',') + } else { + params.nodeId = pathid.value + params.taskId = projectId.value + } + params.size = MisseSize.value + params.current = MissCurrent.value + compareMinio(params).then((res: any) => { + minioOnlyFiles.value = res.data.records + loading3.value = false + MisseSize.value = res.data.size + MissTotal.value = res.data.total + MissCurrent.value = res.data.current diffColor() }) } @@ -152,9 +245,19 @@ function changeColor(data: any, data2: any, type: any) { return data } +function gettabletable(){ + sureSize.value = 100 + ChangeSize.value = 100 + MisseSize.value = 100 + diffSure() + diffChange() + diffMiss() +} function diffClose() { + // gettabletable() differential.value = false - getWorkData() + getlocaltree() + getminiotree() } //获取所有项目 @@ -173,7 +276,7 @@ function gettreedata() { treedata.value = res.data treeloading.value = false if (treedata.value[0].nodeId) { - pathid.value = treedata.value[0].nodeId + // pathid.value = treedata.value[0].nodeId // nextTick(() => { // treeRef.value?.setCurrentKey(pathid.value); // }); @@ -187,14 +290,17 @@ function gettreedata() { } function handleNodeClick(data: any, node: any) { pathid.value = data.nodeId - getWorkData() + getlocaltree() + getminiotree() } //工作空间树点击 -const handleCheckChange = debounce(( +const handleCheckChange = ( data: any, checked: boolean, indeterminate: boolean ) => { + console.log(data) + // debugger if (checked === true && indeterminate === false) { workall.value.push(data) } else { @@ -202,7 +308,7 @@ const handleCheckChange = debounce(( } comparearr.value = getclickdata(workall.value) beifentree.value!.setCheckedNodes(comparearr.value, false) -}, 300) +} //递归整理点击参数 function getclickdata(data: any) { data.forEach((item: any) => { @@ -219,21 +325,46 @@ function getclickdata(data: any) { } //工作空间树获取 //获取工作空间数据 -function getWorkData() { +// function getWorkData() { +// worktree.value = true +// listLocalAndBackup({ taskId: projectId.value, nodeId: pathid.value }).then((res: any) => { +// workdata.value = res.data.localTrees +// backupsdata.value = res.data.minioTrees +// if (workdata.value.length > 0) { +// assignment(workdata.value, 'local') +// } +// if (backupsdata.value.length > 0) { +// assignment(backupsdata.value, 'minio') +// } +// worktree.value = false +// diffColor() +// }) + +// } +//获取本地树 +function getlocaltree() { worktree.value = true - listLocalAndBackup({ taskId: projectId.value, nodeId: pathid.value }).then((res: any) => { + listLocalTree({ taskId: projectId.value, nodeId: pathid.value }).then((res: any) => { workdata.value = res.data.localTrees - backupsdata.value = res.data.minioTrees if (workdata.value.length > 0) { assignment(workdata.value, 'local') } - if (backupsdata.value.length > 0) { - assignment(backupsdata.value, 'minio') - } worktree.value = false diffColor() }) - +} +const worktree1 = ref(false) +//获取minio树 +function getminiotree() { + worktree1.value = true + listBackupTree({ taskId: projectId.value, nodeId: pathid.value }).then((res: any) => { + backupsdata.value = res.data.minioTrees + if (backupsdata.value.length > 0) { + assignment(backupsdata.value, 'minio') + } + worktree1.value = false + diffColor() + }) } //数据递归赋值 function assignment(data: any, difference: any) { @@ -247,7 +378,7 @@ function assignment(data: any, difference: any) { } //备份空间 const beifentree = ref() -const backupsChange = debounce(( +const backupsChange = ( data: any, checked: boolean, indeterminate: boolean @@ -257,9 +388,10 @@ const backupsChange = debounce(( } else { workall.value = workall.value.filter(item => item.id !== data.id); } + comparearr.value = getclickdata(workall.value) workref.value!.setCheckedNodes(comparearr.value, false) -}, 300) +} //右键菜单 const handleRightClick = (event: Event, data: any, node: any) => { if (data.station != '0') { @@ -312,7 +444,8 @@ const handleMenuClick = (action: string, type: any) => { ElMessage.success("恢复成功") minioOnlyFiles.value = minioOnlyFiles.value.filter((item: any) => item.id !== currentNode.value.id) md5MismatchedFiles.value = md5MismatchedFiles.value.filter((item: any) => item.id !== currentNode.value.id) - getWorkData() + getlocaltree() + getminiotree() } }) }) @@ -340,7 +473,8 @@ const handleMenuClick = (action: string, type: any) => { ElMessage.success("上传成功") localOnlyFiles.value = localOnlyFiles.value.filter((item: any) => item.id !== currentNode.value.id) md5MismatchedFiles.value = md5MismatchedFiles.value.filter((item: any) => item.id !== currentNode.value.id) - getWorkData() + getlocaltree() + getminiotree() // getchayi() } }) @@ -351,14 +485,15 @@ const handleMenuClick = (action: string, type: any) => { deleteTsFilesById({ id: currentNode.value.id, type: type }).then((res: any) => { if (res.code == '0') { ElMessage.success("删除成功") - getWorkData() + getlocaltree() + getminiotree() } }) break case 'preview': // 处理预览逻辑 - openPreview(currentNode.value,type) + openPreview(currentNode.value, type) break } } @@ -381,10 +516,10 @@ function tableBeifen(row: any) { ) .then(() => { const params = [{ - path: '/' + pathid.value + row.path, - name: row.name, - size: row.size, - type: row.type + path: '/' + pathid.value + row.workPath, + name: row.fileName, + size: row.fileSize, + type: row.isFile }] uploadToBackup({ parameterLists: params }).then((res: any) => { if (res.code == '0') { @@ -411,11 +546,13 @@ function moretableBeifen() { } ) .then(() => { + let beifenArr3 = [] let beifenArr2 = JSON.parse(JSON.stringify(beifenArr.value)) beifenArr2.forEach((items: any) => { - items.path = '/' + pathid.value + items.path + beifenArr3.push({ path: '/' + pathid.value + items.workPath, name: items.fileName, size: items.fileSize, type: items.isFile }) + // items.path = '/' + pathid.value + items.path }) - uploadToBackup({ parameterLists: beifenArr2 }).then((res: any) => { + uploadToBackup({ parameterLists: beifenArr3 }).then((res: any) => { if (res.code == '0') { ElMessage.success("上传成功") beifenArr.value.forEach((items: any) => { @@ -441,10 +578,10 @@ function tablerestore(row: any) { ) .then(() => { const params = [{ - path: '/' + pathid.value + row.path, - name: row.name, - size: row.size, - type: row.type + path: '/' + pathid.value + row.backupPath, + name: row.fileName, + size: row.fileSize, + type: row.isFile }] downloadToLocal({ parameterLists: params }).then((res: any) => { if (res.code == '0') { @@ -470,11 +607,13 @@ function moretablerestore() { } ) .then(() => { + let restoreArr3 = [] + let restoreArr2 = JSON.parse(JSON.stringify(restoreArr.value)) restoreArr2.forEach((items: any) => { - items.path = '/' + pathid.value + items.path + restoreArr3.push({ path: '/' + pathid.value + items.backupPath, name: items.fileName, size: items.fileSize, type: items.isFile }) }) - downloadToLocal({ parameterLists: restoreArr2 }).then((res: any) => { + downloadToLocal({ parameterLists: restoreArr3 }).then((res: any) => { if (res.code == '0') { ElMessage.success("恢复成功") restoreArr.value.forEach((items: any) => { @@ -535,11 +674,12 @@ function bfclick(type: any) { ) .then(() => { if (type == 'bf') { + let beifenArr3 = [] let beifenArr2 = JSON.parse(JSON.stringify(changeclick.value)) beifenArr2.forEach((items: any) => { - items.path = '/' + pathid.value + items.path + beifenArr3.push({ path: '/' + pathid.value + items.workPath, name: items.fileName, size: items.fileSize, type: items.isFile }) }) - uploadToBackup({ parameterLists: beifenArr2 }).then((res: any) => { + uploadToBackup({ parameterLists: beifenArr3 }).then((res: any) => { if (res.code == '0') { ElMessage.success("上传成功") changeclick.value.forEach((items: any) => { @@ -548,11 +688,12 @@ function bfclick(type: any) { } }) } else { + let restoreArr3 = [] let restoreArr2 = JSON.parse(JSON.stringify(changeclick.value)) restoreArr2.forEach((items: any) => { - items.path = '/' + pathid.value + items.path + restoreArr3.push({ path: '/' + pathid.value + items.backupPath, name: items.fileName, size: items.fileSize, type: items.isFile }) }) - downloadToLocal({ parameterLists: restoreArr2 }).then((res: any) => { + downloadToLocal({ parameterLists: restoreArr3 }).then((res: any) => { if (res.code == '0') { ElMessage.success("恢复成功") changeclick.value.forEach((items: any) => { @@ -570,9 +711,9 @@ onMounted(() => { getProject() }); // 组件卸载时取消防抖(可选) -onBeforeUnmount(() => { - handleCheckChange.cancel() -}) +// onBeforeUnmount(() => { +// handleCheckChange.cancel() +// }) //拖动条 const vMove = { mounted(el: any) { @@ -619,35 +760,35 @@ const Three3dPreview = defineAsyncComponent({ }) //单击预览 const filePreview: any = ref({}) -const ViewfileUrl:any = ref("") +const ViewfileUrl: any = ref("") const title1 = ref('') const isViewfile = ref(false) const fileType = ref('') -function openPreview(row: any,type:any) { +function openPreview(row: any, type: any) { if (getFileExtension(row.fileName) == 'pdf' || getFileExtension(row.fileName) == 'pptx' || getFileExtension(row.fileName) == 'xlsx' || getFileExtension(row.fileName) == 'xls' || getFileExtension(row.fileName) == 'docx' || getFileExtension(row.fileName) == 'doc' || getFileExtension(row.fileName) == 'bin') { title1.value = row.fileName - geturl(row.id,type,true) + geturl(row.id, type, true) isViewfile.value = true fileType.value = getFileExtension(row.fileName) } else { row.fileType = getFileType(row.fileName) filePreview.value = row - geturl(row.id,type,false) + geturl(row.id, type, false) console.log(filePreview.value) localStorage.setItem('videorow', JSON.stringify(row)); openRow(row) } } -function geturl(row:any,type1:any,pan:any){ - obtainUrl({id:row,type:type1}).then((res:any)=>{ - if(pan){ +function geturl(row: any, type1: any, pan: any) { + obtainUrl({ id: row, type: type1 }).then((res: any) => { + if (pan) { ViewfileUrl.value = res.data.url - }else{ + } else { filePreview.value.url = res.data.url } - - + + }) } @@ -753,16 +894,17 @@ const tabs = ref(1)
- 文件自动备份 - 文件差异性对比 - 查看本次差异性对比 + 文件自动备份 + 文件差异性对比 + 查看本次差异性对比
工作空间:
- @@ -798,7 +940,7 @@ const tabs = ref(1)