Ver a proveniência

历史版本管理代码

dev-remain
revive há 4 anos
ascendente
cometimento
42f86a9051
8 ficheiros alterados com 327 adições e 64 eliminações
  1. +43
    -0
      src/services/system.js
  2. +3
    -1
      src/utils/request.js
  3. +7
    -0
      src/views/main_web/workspace/components/file-item.vue
  4. +90
    -28
      src/views/main_web/workspace/components/file-milestone.vue
  5. +66
    -30
      src/views/main_web/workspace/components/version-item.vue
  6. +26
    -1
      src/views/main_web/workspace/service.js
  7. +91
    -3
      src/views/main_web/workspace/workspace.new.vue
  8. +1
    -1
      vue.config.js

+ 43
- 0
src/services/system.js Ver ficheiro

@@ -627,6 +627,49 @@ const system = {
onErrorHandler(e, file);
});
}),
/**
* 查看历史版本
*/
queryCommitHistory: safeCall((path, hash, getData)=>{
const socket = io('queryCommitHistory');
socket.on('open', ()=>{
socket.send([path, hash].join('|'));
})
socket.on('message', (e) => {
if(e.data === '-1') {
notify.error('查询历史文件失败');
return;
}else{
const data = JSON.parse(e.data);
let dataArray = [];
for (let key in data) {
dataArray.push(data[key]);
}
console.log('wb', dataArray)
getData(dataArray);
}
})

}),
/**
* 里程碑
*/
editCommitHistoryMilestone: safeCall((filePath, commitHistoryHash, hash, milestone, callback) => {
const socket = io('editCommitHistoryMilestone');
socket.on('open', ()=>{
socket.send([filePath, commitHistoryHash, hash, milestone ].join('|'));
})
socket.on('message', (e) => {
if(e.data === '-1') {
notify.error('设置里程碑失败');
return;
}else{
const data = e.data;
console.log('lcb', data)
callback(data);
}
})
}),
/**
* 系统打开文件
*/


+ 3
- 1
src/utils/request.js Ver ficheiro

@@ -129,8 +129,10 @@ function mapApiPathToFullPath(path) {
case "file/addArchMilesStone":
case "file/addFile":
case "file/updateFile":
case "file/fileCoordinationChange":
case "file/fileCoordinationChange":
case "file/setShareFile":
case "operation/record":
case "file/updateProjArchiveHistory":
// case 'template/deleteTemplateNodeModelFile':
method = 'POST';
break;


+ 7
- 0
src/views/main_web/workspace/components/file-item.vue Ver ficheiro

@@ -166,6 +166,8 @@
<li v-if="!isClient && oneOf(file.extension,filePreviewList)"
@click.stop="filePreview">在线预览</li>
<li v-else-if="!isClient && !(oneOf(file.extension,filePreviewList))" class="function-disabled" title="暂时不支持此类文件的预览">在线预览</li>
<!-- 查看历史版本 -->
<li v-if="isClient && isInWorkFolder && !otherUserIsWorking" @click.stop="checkMilestoneClick">查看历史版本</li>
</ul>
</div>

@@ -439,6 +441,11 @@ export default {
this.isFileRightMenuVisible = false;
this.$emit('deleteFileClick', this.file.id, this.file.createUserId, this.file.archName, this.file.ipfsCid);
},
checkMilestoneClick() {
this.isFileRightMenuVisible = false;
this.$emit('checkMilestoneClick', this.file);

},
filePreview(){
//office:1 img/txt:2 vedio:3
let type;


+ 90
- 28
src/views/main_web/workspace/components/file-milestone.vue Ver ficheiro

@@ -1,7 +1,7 @@
<template>
<div class="milestone_panel">
<!-- 选择旗帜颜色 -->
<transition name="fade">
<!-- <transition name="fade">
<div class="toolbox" v-if="toolboxShow" :style="{top: toolboxTop + 'px'}">
<div class="toolbox_content">
<div class="toolbox_top">
@@ -21,7 +21,7 @@
<div class="triangle-down">
</div>
</div>
</transition>
</transition> -->

<!-- 用户中心弹窗模块 -->
<div :class="yiyunAnimated + ' flex_right_pain'">
@@ -46,15 +46,21 @@
<div class="pxline"></div>
<div class="flex_right_pain_body" ref="milestoneManageRef">
<div class="yiyun_app_itemClasss">
<!-- 当前版本 -->
<version-item
nowVersion
:file="fileNowVersion"
></version-item>
<!-- 分割线 -->
<div class="title">里程碑</div>
<!-- 历史版本 -->
<version-item @getToolboxTop="getToolboxTop" :flagcolor="color"></version-item>
<version-item @getToolboxTop="getToolboxTop" :flagcolor="color"></version-item>
<version-item @getToolboxTop="getToolboxTop" :flagcolor="color"></version-item>
<!-- 里程碑版本 -->
<version-item
v-for="(fileInfo, index) in fileOtherVersion"
:key ="fileInfo.currentHash"
:file="fileInfo"
:fileId ="file.id"
>
</version-item>
</div>
</div>
<div class="bottombtnitem">
@@ -91,10 +97,14 @@
</div>
<div class="pxline"></div>
<div class="flex_right_pain_body" ref="milestoneCheckRef">
<div class="yiyun_app_itemClasss">
<version-item @getToolboxTop="getToolboxTop"></version-item>
<version-item @getToolboxTop="getToolboxTop"></version-item>
<version-item @getToolboxTop="getToolboxTop"></version-item>
<div class="yiyun_app_itemClasss">
<version-item
v-for="(fileInfo, index) in fileHistoryList"
:key ="fileInfo.currentHash"
:file="fileInfo"
:fileId ="file.id"
>
</version-item>
</div>
</div>
</div>
@@ -110,41 +120,62 @@ export default {
components: {
VersionItem
},
props: {
fileMilestoneInfo :{
type : Object,
default: () => ({}),
},
fileHistoryList: {
type : Array,
default: () => ([]),
},
file : {
type : Object,
default: () => ({}),
}
},
mounted() {
// const userInfo = await getUserInfo(this.$store.state.accountId);
// this.user = userInfo;
this.milestoneManageRefEl = this.$refs.milestoneManageRef;
this.milestoneManageRefEl && this.milestoneManageRefEl.addEventListener('scroll', ()=> {
this.toolboxShow = false;
})
this.milestoneCheckRefEl = this.$refs.milestoneCheckRefEl;
this.milestoneCheckRefEl && this.milestoneCheckRefEl.addEventListener('scroll', ()=>{
this.toolboxShow = false;
})
// this.milestoneManageRefEl = this.$refs.milestoneManageRef;
// this.milestoneManageRefEl && this.milestoneManageRefEl.addEventListener('scroll', ()=> {
// this.toolboxShow = false;
// })
// this.milestoneCheckRefEl = this.$refs.milestoneCheckRefEl;
// this.milestoneCheckRefEl && this.milestoneCheckRefEl.addEventListener('scroll', ()=>{
// this.toolboxShow = false;
// })
this.getFileMilestoneList(this.fileHistoryList);
this.getFileNowVersion(this.fileHistoryList);
this.getFileOtherVersion();
},
data() {
return {
milestoneManageRefEl:null,
milestoneCheckRefEl:null,
yiyunAnimated: "", //设置面板默认动画为空 AnimatedRightIn动画右边进入
yiyunAnimated: "AnimatedRightIn", //设置面板默认动画为空 AnimatedRightIn动画右边进入
isCloseHover: false,
//添加的
clickedVersion:'',
isFileNameShow:false,
remarks:'备注内容,默认显示两行。备注内容,默认显示两行。',
isEdit:false,
colorList:['#7850FF','#4AE2A6','#FFBE00',
'#3C7DFF','#D6243A','#FF6634',
'#14A3FF','#7DE217'
],//颜色盘
selectedColor:'#7850FF',
toolboxShow:false,
color:'#7850FF', //标记icon的颜色
// isEdit:false,
// colorList:['#7850FF','#4AE2A6','#FFBE00',
// '#3C7DFF','#D6243A','#FF6634',
// '#14A3FF','#7DE217'
// ],
// selectedColor:'#7850FF',
// toolboxShow:false,
// color:'#7850FF',
milestoneManage:true,
milestoneCheck:false,
toolboxTop:0,
//监听是否滚动
milestoneManageRefScroll:''
milestoneManageRefScroll:'',
//里程碑信息
fileMilestoneList:[],
fileNowVersion:{},
fileOtherVersion:[],
};
},
methods: {
@@ -188,6 +219,7 @@ export default {
*/
closeSetPain: function () {
this.yiyunAnimated = "";
this.$emit('closeMilestonePain',false);
},
// 打开设置颜色
setColor(){
@@ -215,6 +247,36 @@ export default {
this.toolboxShow = false;
this.color = this.selectedColor;
},
//获取里程碑文件
getFileMilestoneList(fileHistoryList) {
this.fileMilestoneList = fileHistoryList.filter((file)=> {
return file.milestone ;
})
},

//获取当前版本
getFileNowVersion(fileHistoryList) {
let fileNowVersion = fileHistoryList.filter((file)=>{
return (file.currentHash == this.file.ipfsCid);
})
this.fileNowVersion = fileNowVersion[0];
console.log('now',this.fileNowVersion)
},
//获取除当前版本的里程碑
getFileOtherVersion() {
this.fileOtherVersion = this.fileMilestoneList.filter((file)=>{
return file.currentHash != this.file.ipfsCid;
})
},
//刷新里程碑界面
refresh(){
}



},
};


+ 66
- 30
src/views/main_web/workspace/components/version-item.vue Ver ficheiro

@@ -3,21 +3,22 @@
<transition name="info-fade">
<!-- 版本信息详细 -->
<div class="version_item" v-if="nowVersion || selectedVersion" :class="{set_item_position:false}">
<i class="el-icon-circle-close close_btn"></i>
<i class="iconfont icon-shanchu close_btn"></i>
<div class="content">
<div class="content_header">
<i class="iconfont icon-zhiding" alt="" v-if="nowVersion"></i>
<p :class="[nowVersion ? 'version_title' :'title' ]">当前协同-版本9</p>
<p :class="[nowVersion ? 'version_title' :'title' ]">当前协同-版本{{file.version}}</p>
</div>
<div class="content_icon">
<div class="icon_box" @click.stop="setColor" :style="{color:`${flagcolor}`}">
<div class="icon_box">
<i class="iconfont icon-lichengbei-qizhi"></i>
</div>
<p>里程碑</p>
<div class="switch_btn">
<el-switch
v-model="switchValue"
v-model="file.milestone"
@change="setMileStoneClick"
active-color="#7850FF"
inactive-color="#fff">
</el-switch>
@@ -27,9 +28,9 @@
<div class="file_name">文件名</div>
<div class="file_info">
<ul>
<li><span>提交人:</span><span class="left" style="color:#2869E6"></span></li>
<li><span>基于版本:</span><span class="left">用户名 提交的版本X</span></li>
<li><span>协同于:</span><span class="left">2020年11月18日 下午12:15</span></li>
<li><span>提交人:</span><span class="left" style="color:#2869E6">{{showAccountName}}</span></li>
<li><span>基于版本:</span><span class="left">{{file.creator}} 提交的版本{{file.version}}</span></li>
<li><span>协同于:</span><span class="left">{{showTime}}</span></li>
</ul>
<div class="btn_box">
<div class="btn" v-if="!nowVersion">
@@ -38,7 +39,7 @@
<div class="edit_btn btn" v-if="nowVersion">
继续编辑
</div>
<div class="set_btn btn" v-if="!nowVersion">
<div class="set_btn btn" v-if="!nowVersion" @click.stop="setShare">
<i class="iconfont icon-zhiding"></i>
设为协同版本
</div>
@@ -57,12 +58,8 @@
<div class="myremarks" :class="{'set_position':!isShowOpenIcon,'set-border':isRemarksEdit}">
<div :class="{myremarks_content:!isShowAll}"
ref="remarksText"
v-html="remarks"
:contenteditable="true"
@focus="editRemarks"
@blur="finishEditRemarks"
@input="changeRemarks"
>
{{file.note ? "无备注" : file.note }}
</div>
</div>
</div>
@@ -85,12 +82,12 @@
<!-- 版本信息简略 -->
<div class="version_item_brief" v-if="!selectedVersion && !nowVersion" @click.stop="clickVersion">
<div class="header">
<p>版本6</p>
<p class="header_time">2020年11月18日 下午12:32</p>
<p>版本{{file.version}}</p>
<p class="header_time">{{showTime}}</p>
</div>
<div class="remarks_brief">
<div class="icon_box"><span class="iconfont icon-lichengbei-qizhi"></span></div>
<div class="remarks_brief_content" :class="{noremarks:true}">备注内容</div>
<div class="remarks_brief_content" :class="{noremarks:true}">{{file.note ? file.note: "无备注"}}</div>
<div class="remarks_icon">
<i class="iconfont icon-beizhu"></i>
</div>
@@ -102,19 +99,28 @@
</template>

<script>
import moment from 'dayjs';
import 'dayjs/locale/zh-cn';
moment.locale('zh-cn');
import {setShareFile} from '../service'
export default {
props:{
nowVersion:Boolean,
// selectedVersion:Boolean,
flagcolor: {
type:String,
default:'#7850FF'
}
// flagcolor: {
// type:String,
// default:'#7850FF'
// }
file :{
type:Object,
default: ()=>({})
},
fileId : String
},
mounted() {
this.remarkEl = this.$refs.remarksText;
this.isShowOpenIcon = this.remarkEl && this.remarkEl.clientHeight > 22;

},
data(){
return{
@@ -123,15 +129,16 @@ export default {
isRemarksEdit: false,
isShowAll:false,
isShowOpenIcon: false,
remarks:'我去上学校天天不迟到,爱学习爱劳动长大要为人民立功劳。 小鸟说早早早,你为什么背上小书包。我去上学校。 天天不迟到,爱学习,爱劳动,长大要为人民立功劳。',
newremarks:'',
colorList:['#7850FF','#4AE2A6','#FFBE00',
'#3C7DFF','#D6243A','#FF6634',
'#14A3FF','#7DE217'
],//颜色盘
selectedColor:'#7850FF',
toolboxShow:false,//选择颜色盘显示
// remarks:'我去上学校天天不迟到,爱学习爱劳动长大要为人民立功劳。 小鸟说早早早,你为什么背上小书包。我去上学校。 天天不迟到,爱学习,爱劳动,长大要为人民立功劳。',
// newremarks:'',
// colorList:['#7850FF','#4AE2A6','#FFBE00',
// '#3C7DFF','#D6243A','#FF6634',
// '#14A3FF','#7DE217'
// ],
// selectedColor:'#7850FF',
// toolboxShow:false,
selectedVersion:false,
accountName:'',
}
},
@@ -177,6 +184,28 @@ export default {
closeSetColor(){
this.toolboxShow = false;
},
async setShare() {
const res = await setShareFile (this.fileId,this.file.currentHash,sessionStorage.userId);
if(res.Code == 0) {
this.$notify({
type:'success',
message: '设置协同版本成功'
})
}else{
this.$notify({
type:'error',
message: res.Msg,
})
}

},
setMileStoneClick(val) {
this.$bus.$emit('setMileStoneClick', val, this.file);
}






@@ -184,10 +213,16 @@ export default {
},

computed: {
showAccountName() {
return this.file.creator && sessionStorage.accountName == this.file.creator ? '我': this.file.creator;
},
showTime() {
return this.file.createTime && moment(this.file.createTime*1000).format('YYYY年MM月DD日 A HH:mm');
}
},

watch: {
//备注的箭头显示
newremarks() {
this.remarkEl = this.$refs.remarksText;
this.isShowOpenIcon = this.remarkEl && this.remarkEl.clientHeight > 22;
@@ -215,6 +250,7 @@ export default {
position: absolute;
top: 8px;
right: 8px;
color: #dedede;

}
.content{


+ 26
- 1
src/views/main_web/workspace/service.js Ver ficheiro

@@ -175,4 +175,29 @@ export async function deleteFile(fileId) {
export async function searchFileListByFolderIdAndFileName(folderId, fileName){
const res = await fetchApi('file/searchFileListByFolderIdAndFileName', { folderId, fileName});
return res;
}
}

/**
* 查看历史版本管理文件
*/
export async function queryProjArchiveHistory(archId) {
const res = await fetchApi('file/queryProjArchiveHistoryTbByArchId', {archId});
return res;
}

/**
* 设为协同版本
*/
export async function setShareFile(Id,IpfsCid,ModifyUserId) {
const res = await fetchApi('file/setShareFile', {Id,IpfsCid,ModifyUserId});
return res;
}

/**
* 更新里程碑
*/

export async function updateProjArchiveHistory(params) {
const res = await fetchApi('file/updateProjArchiveHistory', params);
return res;
}

+ 91
- 3
src/views/main_web/workspace/workspace.new.vue Ver ficheiro

@@ -60,6 +60,7 @@
@copyFileBtnClick="copyWorkFileBtnClick(file)"
@oneFileRightBtnClick="oneFileRightBtnClick"
@deleteFileClick="deleteFileClick"
@checkMilestoneClick="checkMilestoneClick"
:tempRightFileId="tempRightFileId"
:localFileHashMap="localFileHashMap"
:loadingState="localFileLoadStateMap[file.id]"
@@ -197,6 +198,7 @@
@copyFileBtnClick="copyWorkFileBtnClick(file)"
@oneFileRightBtnClick="oneFileRightBtnClick"
@deleteFileClick="deleteFileClick"
@checkMilestoneClick="checkMilestoneClick"
:tempRightFileId="tempRightFileId"
:localFileHashMap="localFileHashMap"
:loadingState="localFileLoadStateMap[file.id]"
@@ -471,6 +473,15 @@
<el-button @click.stop="createTemplateFile()" type="primary">完成创建</el-button>
</div>
</el-dialog>
<!-- 查看历史版本 -->
<file-milestone v-if="checkMilestoneShow"
:fileMilestoneInfo = "fileMilestoneInfo"
@closeMilestonePain="closeMilestonePain"
:fileHistoryList ="fileHistoryList"
:file = "currentFile"
>

</file-milestone>
</div>
</template>

@@ -480,6 +491,7 @@ import AppHeader from "@/components/app-header";
import SearchBar from "@/components/search-bar/search-bar";
import ChangeBtn from "@/components/change-btn/change-btn";
import commonJs from "@/common/webCommon";

// import forgeview from "@/views/components/forgeview/forgeview.vue";
// import gismap from "@/views/components/gismap/gismap.vue";
// import officeview from "@/views/components/officeview/officeview.vue";
@@ -498,6 +510,7 @@ import * as services from './service';
import * as tempalteService from '@/services/template.js';
import { firstCharToLowerCase, firstCharToUpperCase, notify } from '@/utils/tool';
import FileItem from './components/file-item';
import FileMilestone from "./components/file-milestone"
import FolderItem from './components/folder-item';
import { FileWorkStatus, getFileStoreKey, injectionFileLocalStatus, LoadingEnum, VirtualFolder, analyzeRelativePath, imgExtensionList, RecExtensionList, VideoExtensionList, office, filePreviewList } from './helper';
import { propertyOf, uniqBy, throttle, flatten, debounce, cloneDeep } from 'lodash';
@@ -556,6 +569,7 @@ export default {
// draggable,
FileItem,
FolderItem,
FileMilestone,
},
data(){
return {
@@ -650,11 +664,15 @@ export default {
hackWorkLine: null,

nestTemplateLists: [],

checkMilestoneShow: false,//历史版本查看
fileMilestoneInfo:{},
fileHistoryList:[],
currentFile:{},
};
},
mounted: function () {
//监听version-item 设置里程碑文件的点击事件
this.$bus.$on('setMileStoneClick',this.handleMileStoneBtnClick);
sessionStorage.pageTitle = '工作空间';
this.hackWorkLine = this.$refs.hackworkline;
// window.addEventListener("scroll", this.onscroll, true);
@@ -690,7 +708,7 @@ export default {
// window.removeEventListener("scroll", this.onscroll);
// window.removeEventListener("resize", this.listenBottomHeight);
// window.removeEventListener("mouseenter", this.setIconMouseEnter);
this.$bus.$off('setMileStoneClick', this.handleMileStoneBtnClick)
window.clearTimeout(this.timerIns);
this.timerIns = null;
system.leaveProject(this.socketIns);
@@ -727,6 +745,48 @@ export default {
}
},
methods: {
//接收某个文件设置是否为里程碑文件的点击事件的值
async handleMileStoneBtnClick(val, historyFile) {
const localWorkspacePrefix = this.localWorkspacePrefix;
const fileStoreKey = getFileStoreKey(this.currentFile, this.currentNodeFolder);

if(!this.localFileHashMap[fileStoreKey]) return;

const filePath = `${localWorkspacePrefix}\\${fileStoreKey}`;

const fileId = this.currentFile.id;
//查询文件的历史版本管理文件的hash值
let commitHistoryHash = "";
const res = await services.queryProjArchiveHistory(fileId);
if(res.Code == 0){
commitHistoryHash = res.Data.CurrentIpfsCid;
}
// console.log('isMileStone', val);
// console.log('commitHistoryHash', commitHistoryHash);
// console.log('hash', currentHash);
// editCommitHistoryMilestone: safeCall((filePath, commitHistoryHash, hash, milestone)
let currentIpfsCid = "";
system.editCommitHistoryMilestone(filePath, commitHistoryHash, historyFile.currentHash, val, async (ipfsCid)=> {
currentIpfsCid = ipfsCid;
console.log('currentIpfsCid', currentIpfsCid);
const time = new Date().getTime();
const params = {
"ArchId": this.currentFile.id,
"CreateTime": historyFile.createTime,
"CreateUserId": historyFile.creator,
"CurrentIpfsCid": currentIpfsCid,
"Id": historyFile.currentHash,
"ModifyTime": time,
"ModifyUserId": sessionStorage.userId,
"PrevIpfsCid": historyFile.parentHash
}
console.log('parms',params)
const editRes = await services.updateProjArchiveHistory(params);
console.log('editRes', editRes);

});
},
// 返回协作文件区域一开始入口的制定文件夹下的文件list
getRealChildFileLists(folder) {
return this.exchangeNodeInfoMap[folder.id] && this.exchangeNodeInfoMap[folder.id].realChildFileLists || [];
@@ -1714,6 +1774,15 @@ export default {
errorHandler,
);
},
/**
* 获得历史版本
*/
getHistoryFileList(fileMilestoneInfo) {
const getData = (data) =>{
this.fileHistoryList = data;
}
system.queryCommitHistory(fileMilestoneInfo.path, fileMilestoneInfo.hash, getData);
},
commitFolder(folder) {
const path = `${this.localWorkspacePrefix}\\${this.currentNodeFolder.folderName}${folder.folderPath ? `\\${folder.folderPath}`:''}`.replace(/\//g, '\\');
this.clientUpload([path]);
@@ -1926,7 +1995,26 @@ export default {
thisApp.fetchFolderFiles();
}
})
},
async checkMilestoneClick(file) {
this.checkMilestoneShow = true;
const localWorkspacePrefix = this.localWorkspacePrefix;
const fileStoreKey = getFileStoreKey(file, this.currentNodeFolder);
if(!this.localFileHashMap[fileStoreKey]) return;
const filePath = `${localWorkspacePrefix}\\${fileStoreKey}`;
this.fileMilestoneInfo.path = filePath;
const res = await services.queryProjArchiveHistory(file.id);
if(res.Code == 0){
this.fileMilestoneInfo.hash = res.Data.CurrentIpfsCid;
}
this.getHistoryFileList(this.fileMilestoneInfo);
this.currentFile = file;
console.log(this.currentFile)
},
//关闭查看历史版本
closeMilestonePain(close) {
this.checkMilestoneShow = close;
}
},
watch: {
isShowSearchBar(val) {


+ 1
- 1
vue.config.js Ver ficheiro

@@ -45,7 +45,7 @@ module.exports = {
// secure: false,
// },
'/api': {
target: 'http://www.lockingos.org:9000',
target: 'http://www.lockingos.org:9003',
//target: 'http://192.168.8.114:8082',
changeOrigin: true,
secure: false,


Carregando…
Cancelar
Guardar