|
@@ -24,23 +24,25 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import { defineAsyncComponent } from "vue";
|
|
|
|
|
import Folder from "@/api/folder";
|
|
import Folder from "@/api/folder";
|
|
|
|
|
+import { fileTypes, officeOptions } from "./main";
|
|
|
|
|
+
|
|
|
|
|
+import { defineAsyncComponent } from "vue";
|
|
|
import vue_office_docx from "@vue-office/docx";
|
|
import vue_office_docx from "@vue-office/docx";
|
|
|
import vue_office_excel from "@vue-office/excel";
|
|
import vue_office_excel from "@vue-office/excel";
|
|
|
import vue_office_pdf from "@vue-office/pdf";
|
|
import vue_office_pdf from "@vue-office/pdf";
|
|
|
|
|
+import vue_office_txt from "@/components/Upload/txtViewer.vue";
|
|
|
|
|
|
|
|
import "@vue-office/docx/lib/index.css";
|
|
import "@vue-office/docx/lib/index.css";
|
|
|
import "@vue-office/excel/lib/index.css";
|
|
import "@vue-office/excel/lib/index.css";
|
|
|
|
|
|
|
|
-import { fileTypes, officeOptions } from "./main";
|
|
|
|
|
-
|
|
|
|
|
export default {
|
|
export default {
|
|
|
emits: ["closed"],
|
|
emits: ["closed"],
|
|
|
components: {
|
|
components: {
|
|
|
vue_office_docx,
|
|
vue_office_docx,
|
|
|
vue_office_excel,
|
|
vue_office_excel,
|
|
|
vue_office_pdf,
|
|
vue_office_pdf,
|
|
|
|
|
+ vue_office_txt,
|
|
|
yhImageViewer: defineAsyncComponent(() => import("@/components/Upload/imageViewer.vue"))
|
|
yhImageViewer: defineAsyncComponent(() => import("@/components/Upload/imageViewer.vue"))
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -63,18 +65,10 @@ export default {
|
|
|
this.filePath = uploadFile.path;
|
|
this.filePath = uploadFile.path;
|
|
|
this.fileType = fileTypes[uploadFile["fileType"]] || uploadFile["fileType"];
|
|
this.fileType = fileTypes[uploadFile["fileType"]] || uploadFile["fileType"];
|
|
|
if (!fileTypes[uploadFile["fileType"]]) {
|
|
if (!fileTypes[uploadFile["fileType"]]) {
|
|
|
- ElMessage.warning("当前只支持预览.docx、.pdf、excel文件,文件已下载");
|
|
|
|
|
|
|
+ ElMessage.warning("当前只支持预览.txt、.docx、.pdf、.xlsx(.xls)文件,文件已下载");
|
|
|
this.downloadFile();
|
|
this.downloadFile();
|
|
|
} else {
|
|
} else {
|
|
|
if (this.fileType == "image") this.showViewer = true;
|
|
if (this.fileType == "image") this.showViewer = true;
|
|
|
- else if (this.fileType == "txt") {
|
|
|
|
|
- this.downloadFile();
|
|
|
|
|
- // Folder.download(this.filePath, this.fileType).then(res => {
|
|
|
|
|
- // res.data.then(txt=>{
|
|
|
|
|
- // console.log(txt)
|
|
|
|
|
- // })
|
|
|
|
|
- // });
|
|
|
|
|
- }
|
|
|
|
|
else {
|
|
else {
|
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
this.visible = true;
|
|
this.visible = true;
|
|
@@ -88,7 +82,7 @@ export default {
|
|
|
Folder.download(this.filePath).then(res => {
|
|
Folder.download(this.filePath).then(res => {
|
|
|
const a = document.createElement("a");
|
|
const a = document.createElement("a");
|
|
|
const blob = new Blob([res.data], { type: this.fileType });
|
|
const blob = new Blob([res.data], { type: this.fileType });
|
|
|
- // a.download = this.fileName;
|
|
|
|
|
|
|
+ a.download = this.fileName;
|
|
|
a.href = URL.createObjectURL(blob);
|
|
a.href = URL.createObjectURL(blob);
|
|
|
a.click();
|
|
a.click();
|
|
|
});
|
|
});
|
|
@@ -99,49 +93,50 @@ export default {
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
.yh-file-viewer {
|
|
.yh-file-viewer {
|
|
|
---el-overlay-color-lighter: gray;
|
|
|
|
|
-:deep(.el-dialog) {
|
|
|
|
|
- --el-dialog-bg-color: transparent;
|
|
|
|
|
- padding: 0;
|
|
|
|
|
-
|
|
|
|
|
- .el-dialog__header {
|
|
|
|
|
|
|
+ --el-overlay-color-lighter: gray;
|
|
|
|
|
+ :deep(.el-dialog) {
|
|
|
|
|
+ --el-dialog-bg-color: transparent;
|
|
|
padding: 0;
|
|
padding: 0;
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- .el-dialog__body {
|
|
|
|
|
- height: 100%;
|
|
|
|
|
- padding: 0;
|
|
|
|
|
|
|
+ .el-dialog__header {
|
|
|
|
|
+ padding: 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .el-dialog__body {
|
|
|
|
|
+ height: 100%;
|
|
|
|
|
+ padding: 0;
|
|
|
|
|
|
|
|
- .yh-file-viewer__header {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: space-between;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- padding: var(--el-dialog-padding-primary);
|
|
|
|
|
- background: #fff;
|
|
|
|
|
|
|
+ .yh-file-viewer__header {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ padding: var(--el-dialog-padding-primary);
|
|
|
|
|
+ background: #fff;
|
|
|
|
|
|
|
|
- .yh-file-viewer__title {
|
|
|
|
|
- line-height: var(--el-dialog-font-line-height);
|
|
|
|
|
- font-size: var(--el-dialog-title-font-size);
|
|
|
|
|
- color: var(--el-text-color-primary);
|
|
|
|
|
|
|
+ .yh-file-viewer__title {
|
|
|
|
|
+ line-height: var(--el-dialog-font-line-height);
|
|
|
|
|
+ font-size: var(--el-dialog-title-font-size);
|
|
|
|
|
+ color: var(--el-text-color-primary);
|
|
|
|
|
|
|
|
- button {
|
|
|
|
|
- margin-left: var(--el-dialog-padding-primary);
|
|
|
|
|
|
|
+ button {
|
|
|
|
|
+ margin-left: var(--el-dialog-padding-primary);
|
|
|
|
|
|
|
|
- svg {
|
|
|
|
|
- margin-right: 6px;
|
|
|
|
|
|
|
+ svg {
|
|
|
|
|
+ margin-right: 6px;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- .el-button.is-link:hover {
|
|
|
|
|
- color: var(--el-color-primary);
|
|
|
|
|
|
|
+ .el-button.is-link:hover {
|
|
|
|
|
+ color: var(--el-color-primary);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- .yh-file-viewer__content {
|
|
|
|
|
- height: calc(100% - 64px - 2 * var(--el-dialog-padding-primary));
|
|
|
|
|
- padding: var(--el-dialog-padding-primary);
|
|
|
|
|
|
|
+ .yh-file-viewer__content {
|
|
|
|
|
+ height: calc(100% - 64px - 2 * var(--el-dialog-padding-primary));
|
|
|
|
|
+ padding: var(--el-dialog-padding-primary);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-}}
|
|
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|