diff --git a/app/Http/Controllers/Api/FileController.php b/app/Http/Controllers/Api/FileController.php
index 5bc234098..a77320c74 100755
--- a/app/Http/Controllers/Api/FileController.php
+++ b/app/Http/Controllers/Api/FileController.php
@@ -804,6 +804,46 @@ class FileController extends AbstractController
return Base::retSuccess('success', $data);
}
+ /**
+ * @api {get} api/file/content/restore 13. 恢复文件历史
+ *
+ * @apiDescription 需要token身份
+ * @apiVersion 1.0.0
+ * @apiGroup file
+ * @apiName content__restore
+ *
+ * @apiParam {Number} id 文件ID
+ * @apiParam {Number} history_id 历史数据ID
+ *
+ * @apiSuccess {Number} ret 返回状态码(1正确、0错误)
+ * @apiSuccess {String} msg 返回信息(错误描述)
+ * @apiSuccess {Object} data 返回数据
+ */
+ public function content__restore()
+ {
+ $user = User::auth();
+ //
+ $id = intval(Request::input('id'));
+ $history_id = intval(Request::input('history_id'));
+ //
+ $file = File::permissionFind($id);
+ //
+ $history = FileContent::whereFid($file->id)->whereId($history_id)->first();
+ if (empty($history)) {
+ return Base::retError('历史数据不存在或已被删除');
+ }
+ //
+ $content = $history->replicate();
+ $content->userid = $user->userid;
+ $content->save();
+ //
+ $file->size = $content->size;
+ $file->save();
+ $file->pushMsg('content');
+ //
+ return Base::retSuccess('还原成功');
+ }
+
/**
* @api {get} api/file/share 13. 获取共享信息
*
diff --git a/resources/assets/js/components/OnlyOffice.vue b/resources/assets/js/components/OnlyOffice.vue
index 245cbf6d1..7d0c1bd54 100644
--- a/resources/assets/js/components/OnlyOffice.vue
+++ b/resources/assets/js/components/OnlyOffice.vue
@@ -73,6 +73,10 @@ export default {
type: String,
default: ''
},
+ historyId: {
+ type: Number,
+ default: 0
+ },
value: {
type: [Object, Array],
default: function () {
@@ -178,14 +182,20 @@ export default {
break;
}
//
- let fileKey = this.code || this.value.id;
+ let codeId = this.code || this.value.id;
let fileName = $A.strExists(this.fileName, '.') ? this.fileName : (this.fileName + '.' + this.fileType);
+ let fileKey = `${this.fileType}-${fileKey}-${keyAppend}`;
+ let fileUrl = `http://nginx/api/file/content/?id=${codeId}&token=${this.userToken}`;
+ if (this.historyId > 0) {
+ fileKey += `-${this.historyId}`
+ fileUrl += `&history_id=${this.historyId}`
+ }
const config = {
"document": {
"fileType": this.fileType,
- "key": `${this.fileType}-${fileKey}-${keyAppend}`,
"title": fileName,
- "url": `http://nginx/api/file/content/?id=${fileKey}&token=${this.userToken}`,
+ "key": fileKey,
+ "url": fileUrl,
},
"editorConfig": {
"mode": "edit",
@@ -199,18 +209,21 @@ export default {
"forcesave": true,
"help": false,
},
- "callbackUrl": `http://nginx/api/file/content/office?id=${fileKey}&token=${this.userToken}`,
- }
+ "callbackUrl": `http://nginx/api/file/content/office?id=${codeId}&token=${this.userToken}`,
+ },
+ "events": {
+ "onDocumentReady": this.onDocumentReady,
+ },
};
if (/\/hideenOfficeTitle\//.test(window.navigator.userAgent)) {
config.document.title = " ";
}
- if ($A.leftExists(fileKey, "msgFile_")) {
- config.document.url = `http://nginx/api/dialog/msg/download/?msg_id=${$A.leftDelete(fileKey, "msgFile_")}&token=${this.userToken}`;
- } else if ($A.leftExists(fileKey, "taskFile_")) {
- config.document.url = `http://nginx/api/project/task/filedown/?file_id=${$A.leftDelete(fileKey, "taskFile_")}&token=${this.userToken}`;
+ if ($A.leftExists(codeId, "msgFile_")) {
+ config.document.url = `http://nginx/api/dialog/msg/download/?msg_id=${$A.leftDelete(codeId, "msgFile_")}&token=${this.userToken}`;
+ } else if ($A.leftExists(codeId, "taskFile_")) {
+ config.document.url = `http://nginx/api/project/task/filedown/?file_id=${$A.leftDelete(codeId, "taskFile_")}&token=${this.userToken}`;
}
- if (this.readOnly) {
+ if (this.readOnly || this.historyId > 0) {
config.editorConfig.mode = "view";
config.editorConfig.callbackUrl = null;
if (!config.editorConfig.user.id) {
@@ -226,6 +239,10 @@ export default {
this.$nextTick(() => {
this.docEditor = new DocsAPI.DocEditor(this.id, config);
})
+ },
+
+ onDocumentReady() {
+ this.$emit("on-document-ready", this.docEditor)
}
}
}
diff --git a/resources/assets/js/components/TableAction.vue b/resources/assets/js/components/TableAction.vue
index ed846c26a..dc210ecce 100644
--- a/resources/assets/js/components/TableAction.vue
+++ b/resources/assets/js/components/TableAction.vue
@@ -9,6 +9,7 @@