mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
fix: 修复已打开文件需刷新网页才显示最新内容的情况
This commit is contained in:
parent
3c386eeaa9
commit
d0c7ee5e47
@ -43,7 +43,7 @@
|
|||||||
<DropdownItem name="pdf">{{$L('导出PDF文件')}}</DropdownItem>
|
<DropdownItem name="pdf">{{$L('导出PDF文件')}}</DropdownItem>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Button v-if="!file.only_view" :disabled="equalContent" :loading="loadIng > 0" class="header-button" size="small" type="primary" @click="handleClick('save')">{{$L('保存')}}</Button>
|
<Button v-if="!file.only_view" :disabled="equalContent" :loading="loadSave > 0" class="header-button" size="small" type="primary" @click="handleClick('save')">{{$L('保存')}}</Button>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="contentDetail" class="content-body">
|
<div v-if="contentDetail" class="content-body">
|
||||||
<template v-if="file.type=='document'">
|
<template v-if="file.type=='document'">
|
||||||
@ -92,10 +92,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
ready: false,
|
ready: false,
|
||||||
|
|
||||||
|
loadSave: 0,
|
||||||
loadContent: 0,
|
loadContent: 0,
|
||||||
loadIng: 0,
|
|
||||||
|
|
||||||
fileId: 0,
|
|
||||||
|
|
||||||
unsaveTip: false,
|
unsaveTip: false,
|
||||||
|
|
||||||
@ -135,25 +133,12 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
file: {
|
|
||||||
handler(info) {
|
|
||||||
if (this.fileId != info.id) {
|
|
||||||
this.fileId = info.id;
|
|
||||||
this.contentDetail = null;
|
|
||||||
this.getContent();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
immediate: true,
|
|
||||||
deep: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
value: {
|
value: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
this.editUser = [this.userId];
|
this.editUser = [this.userId];
|
||||||
} else {
|
this.getContent();
|
||||||
this.fileContent[this.fileId] = this.contentDetail;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
@ -189,7 +174,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['fileContent', 'wsMsg', 'userId']),
|
...mapState(['wsMsg', 'userId']),
|
||||||
|
|
||||||
|
fileId() {
|
||||||
|
return this.file.id || 0
|
||||||
|
},
|
||||||
|
|
||||||
equalContent() {
|
equalContent() {
|
||||||
return this.contentBak == $A.jsonStringify(this.contentDetail);
|
return this.contentBak == $A.jsonStringify(this.contentDetail);
|
||||||
@ -236,22 +225,17 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getContent() {
|
getContent() {
|
||||||
if (!this.fileId) {
|
if (this.fileId === 0) {
|
||||||
this.contentDetail = {};
|
this.contentDetail = {};
|
||||||
this.updateBak();
|
this.updateBak();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (typeof this.fileContent[this.fileId] !== "undefined") {
|
|
||||||
this.contentDetail = this.fileContent[this.fileId];
|
|
||||||
this.updateBak();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (['word', 'excel', 'ppt'].includes(this.file.type)) {
|
if (['word', 'excel', 'ppt'].includes(this.file.type)) {
|
||||||
this.contentDetail = $A.cloneJSON(this.file);
|
this.contentDetail = $A.cloneJSON(this.file);
|
||||||
this.updateBak();
|
this.updateBak();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loadIng++;
|
this.loadSave++;
|
||||||
this.loadContent++;
|
this.loadContent++;
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'file/content',
|
url: 'file/content',
|
||||||
@ -264,7 +248,7 @@ export default {
|
|||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
}).finally(_ => {
|
}).finally(_ => {
|
||||||
this.loadIng--;
|
this.loadSave--;
|
||||||
this.loadContent--;
|
this.loadContent--;
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -276,7 +260,7 @@ export default {
|
|||||||
handleClick(act) {
|
handleClick(act) {
|
||||||
switch (act) {
|
switch (act) {
|
||||||
case "saveBefore":
|
case "saveBefore":
|
||||||
if (!this.equalContent && this.loadIng == 0) {
|
if (!this.equalContent && this.loadSave == 0) {
|
||||||
this.handleClick('save');
|
this.handleClick('save');
|
||||||
} else {
|
} else {
|
||||||
$A.messageWarning('没有任何修改!');
|
$A.messageWarning('没有任何修改!');
|
||||||
@ -288,7 +272,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.updateBak();
|
this.updateBak();
|
||||||
this.loadIng++;
|
this.loadSave++;
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'file/content/save',
|
url: 'file/content/save',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -306,7 +290,7 @@ export default {
|
|||||||
$A.modalError(msg);
|
$A.modalError(msg);
|
||||||
this.getContent();
|
this.getContent();
|
||||||
}).finally(_ => {
|
}).finally(_ => {
|
||||||
this.loadIng--;
|
this.loadSave--;
|
||||||
})
|
})
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -321,7 +305,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
unSaveGive() {
|
unSaveGive() {
|
||||||
delete this.fileContent[this.fileId];
|
|
||||||
this.getContent();
|
this.getContent();
|
||||||
this.unsaveTip = false;
|
this.unsaveTip = false;
|
||||||
},
|
},
|
||||||
|
|||||||
1
resources/assets/js/store/state.js
vendored
1
resources/assets/js/store/state.js
vendored
@ -63,7 +63,6 @@ const stateData = {
|
|||||||
|
|
||||||
// 文件
|
// 文件
|
||||||
files: [],
|
files: [],
|
||||||
fileContent: {},
|
|
||||||
|
|
||||||
// 项目任务
|
// 项目任务
|
||||||
projectId: 0,
|
projectId: 0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user