ソースを参照

完成创建文件副本功能

dev
kim131 4年前
コミット
7b6e1ba64c
3個のファイルの変更34行の追加29行の削除
  1. +13
    -7
      src/views/main_web/workspace/components/file-milestone.vue
  2. +4
    -9
      src/views/main_web/workspace/components/version-item.vue
  3. +17
    -13
      src/views/main_web/workspace/workspace.new.vue

+ 13
- 7
src/views/main_web/workspace/components/file-milestone.vue ファイルの表示

@@ -50,6 +50,7 @@
<version-item <version-item
nowVersion nowVersion
:file="fileNowVersion" :file="fileNowVersion"
@makeCopy="onMakeCopy"
></version-item> ></version-item>
<!-- 分割线 --> <!-- 分割线 -->
<div class="title">里程碑</div> <div class="title">里程碑</div>
@@ -59,6 +60,7 @@
:key ="fileInfo.currentHash" :key ="fileInfo.currentHash"
:file="fileInfo" :file="fileInfo"
:fileId ="file.id" :fileId ="file.id"
@makeCopy="onMakeCopy"
> >
</version-item> </version-item>
</div> </div>
@@ -103,6 +105,7 @@
:key ="fileInfo.currentHash" :key ="fileInfo.currentHash"
:file="fileInfo" :file="fileInfo"
:fileId ="file.id" :fileId ="file.id"
@makeCopy="onMakeCopy"
> >
</version-item> </version-item>
</div> </div>
@@ -115,6 +118,7 @@


<script> <script>
import VersionItem from './version-item.vue'; import VersionItem from './version-item.vue';
import { cloneDeep } from 'lodash';


export default { export default {
components: { components: {
@@ -136,7 +140,7 @@ export default {
}, },
watch: { watch: {
fileHistoryList(...args){ fileHistoryList(...args){
// console.log('fileHistoryList: ', this.fileHistoryList, args);
console.log('fileHistoryList: ', this.fileHistoryList, args);
this.getFileMilestoneList(this.fileHistoryList); this.getFileMilestoneList(this.fileHistoryList);
this.getFileNowVersion(this.fileHistoryList); this.getFileNowVersion(this.fileHistoryList);
this.getFileOtherVersion(); this.getFileOtherVersion();
@@ -156,6 +160,7 @@ export default {
// this.getFileMilestoneList(this.fileHistoryList); // this.getFileMilestoneList(this.fileHistoryList);
// this.getFileNowVersion(this.fileHistoryList); // this.getFileNowVersion(this.fileHistoryList);
// this.getFileOtherVersion(); // this.getFileOtherVersion();
}, },
data() { data() {
return { return {
@@ -187,6 +192,13 @@ export default {
}; };
}, },
methods: { methods: {
onMakeCopy(commitInfo){
console.log('asdasda:', commitInfo, this.fileMilestoneInfo, this.file);
const newFile = cloneDeep(this.file);
// newFile.archName = `${newFile.archName}-${}`
newFile.ipfsCid = commitInfo.currentHash;
this.$emit('makeCopy', newFile, commitInfo.version);
},
//点击某一版本 //点击某一版本
clickVersion(){ clickVersion(){
this.isFileNameShow = true; this.isFileNameShow = true;
@@ -280,12 +292,6 @@ export default {
refresh(){ refresh(){
} }



}, },
}; };
</script> </script>


+ 4
- 9
src/views/main_web/workspace/components/version-item.vue ファイルの表示

@@ -69,7 +69,7 @@
</div> </div>
</div> </div>
<!-- 创建副本 --> <!-- 创建副本 -->
<div class="create_copy">
<div class="create_copy" @click="onMakeCopy" v-if="!nowVersion">
<div class="create_copy_content"> <div class="create_copy_content">
<img src="static/img/文件.svg" alt=""> <img src="static/img/文件.svg" alt="">
<p>从该版本创建副本</p> <p>从该版本创建副本</p>
@@ -144,6 +144,9 @@ export default {
}, },


methods:{ methods:{
onMakeCopy(){
this.$emit('makeCopy', this.file);
},
//选择某一版本 //选择某一版本
clickVersion(){ clickVersion(){
if(!this.nowVersion){ if(!this.nowVersion){
@@ -202,14 +205,6 @@ export default {
setMileStoneClick(val) { setMileStoneClick(val) {
this.$bus.$emit('setMileStoneClick', val, this.file); this.$bus.$emit('setMileStoneClick', val, this.file);
} }







}, },


computed: { computed: {


+ 17
- 13
src/views/main_web/workspace/workspace.new.vue ファイルの表示

@@ -486,6 +486,7 @@
<file-milestone v-if="checkMilestoneShow" <file-milestone v-if="checkMilestoneShow"
:fileMilestoneInfo="fileMilestoneInfo" :fileMilestoneInfo="fileMilestoneInfo"
@closeMilestonePain="closeMilestonePain" @closeMilestonePain="closeMilestonePain"
@makeCopy="copyWorkFileBtnClick"
:fileHistoryList ="fileHistoryList" :fileHistoryList ="fileHistoryList"
:file = "currentFile" :file = "currentFile"
> >
@@ -1970,12 +1971,12 @@ export default {


if(isCooperationFile) { system.clientOpenFileWith(filePath); return; } if(isCooperationFile) { system.clientOpenFileWith(filePath); return; }
// 将文件状态设置为编辑中 // 将文件状态设置为编辑中
const flagRes = await services.changeFileWorkStatus(fileId, 2);
if(flagRes.Code !== 0) return;
file.workStatus = 2;
file.modifyUserId = sessionStorage.userId;
// const flagRes = await services.changeFileWorkStatus(fileId, 2);
// if(flagRes.Code !== 0) return;
// file.workStatus = 2;
// file.modifyUserId = sessionStorage.userId;
system.clientOpenFileWith(filePath); system.clientOpenFileWith(filePath);
this.fetchFolderFiles();
// this.fetchFolderFiles();
}, },
/** /**
* 点击文件事件:直接打开文件 * 点击文件事件:直接打开文件
@@ -2101,16 +2102,20 @@ export default {
/** /**
* 点击了复制文件副本的按钮 * 点击了复制文件副本的按钮
*/ */
async copyWorkFileBtnClick(targetFile) {
const copyFile = {...targetFile};
async copyWorkFileBtnClick(targetFile, version) {
// console.log(targetFile, version);
const copyFile = cloneDeep(targetFile);
let nowNum = 1, tempName = ""; let nowNum = 1, tempName = "";
if(version) {
copyFile.archName = `${copyFile.archName}-版本${version}`;
}


//先添加 - 副本字样 再判断是否重复 如果重复就修改版本信息 //先添加 - 副本字样 再判断是否重复 如果重复就修改版本信息
tempName = targetFile.archName + '-副本';
tempName = copyFile.archName + '-副本';
let isExists = this.workFileList.find(file => file.archName === tempName); let isExists = this.workFileList.find(file => file.archName === tempName);
while(isExists) { while(isExists) {
// - 副本存在 -》修改为 -副本(x) 的字样 // - 副本存在 -》修改为 -副本(x) 的字样
tempName = targetFile.archName + `-副本(${ ++ nowNum})`;
tempName = copyFile.archName + `-副本(${ ++ nowNum})`;
isExists = this.workFileList.find(file => file.archName === tempName); isExists = this.workFileList.find(file => file.archName === tempName);
} }
let hour = '0' + new Date().getHours(); let hour = '0' + new Date().getHours();
@@ -2125,9 +2130,8 @@ export default {
copyFile.modifyTime = new Date(); copyFile.modifyTime = new Date();
copyFile.createUserId = sessionStorage.userId; copyFile.createUserId = sessionStorage.userId;
copyFile.createTime = new Date(); copyFile.createTime = new Date();
// console.log(copyFile);

const addFileRes = await services.addFile(copyFile);
copyFile.historyCurrentIpfsCid = '';
await services.addFile(copyFile);
this.fetchFolderFiles(); this.fetchFolderFiles();
}, },
deleteFileClick(fileId, createUserId, archName, ipfscid) { deleteFileClick(fileId, createUserId, archName, ipfscid) {
@@ -2168,7 +2172,7 @@ export default {
this.checkMilestoneShow = true; this.checkMilestoneShow = true;
const localWorkspacePrefix = this.localWorkspacePrefix; const localWorkspacePrefix = this.localWorkspacePrefix;
const fileStoreKey = getFileStoreKey(file, this.currentNodeFolder); const fileStoreKey = getFileStoreKey(file, this.currentNodeFolder);
if(!this.localFileHashMap[fileStoreKey]) return;
if(!this.localFileHashMap[fileStoreKey]) return;
const filePath = `${localWorkspacePrefix}\\${fileStoreKey}`; const filePath = `${localWorkspacePrefix}\\${fileStoreKey}`;
this.fileMilestoneInfo.path = filePath; this.fileMilestoneInfo.path = filePath;
const res = await services.queryProjArchiveHistory(file.id); const res = await services.queryProjArchiveHistory(file.id);


読み込み中…
キャンセル
保存