|
@@ -45,15 +45,27 @@
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="right" ref="pdfFather">
|
|
<div class="right" ref="pdfFather">
|
|
|
- <ViewerPDFFromUrl
|
|
|
|
|
- v-if="showPdfViewer"
|
|
|
|
|
- ref="pdfViewer"
|
|
|
|
|
- class="pdf-viewer"
|
|
|
|
|
- :url="pdf_url"
|
|
|
|
|
- :doc_width="DOC_WIDTH"
|
|
|
|
|
- :positions="positions"
|
|
|
|
|
- >
|
|
|
|
|
- </ViewerPDFFromUrl>
|
|
|
|
|
|
|
+ <template v-if="showPdfViewer">
|
|
|
|
|
+ <ViewerPDFFromUrl
|
|
|
|
|
+ v-if="target_doc_type === 'pdf'"
|
|
|
|
|
+ ref="pdfViewer"
|
|
|
|
|
+ class="pdf-viewer"
|
|
|
|
|
+ :url="target_doc_url"
|
|
|
|
|
+ :doc_width="DOC_WIDTH"
|
|
|
|
|
+ :positions="positions"
|
|
|
|
|
+ >
|
|
|
|
|
+ </ViewerPDFFromUrl>
|
|
|
|
|
+
|
|
|
|
|
+ <ViewerDocxFromUrl
|
|
|
|
|
+ v-if="target_doc_type === 'doc'"
|
|
|
|
|
+ ref="pdfViewer"
|
|
|
|
|
+ class="pdf-viewer"
|
|
|
|
|
+ :url="target_doc_url"
|
|
|
|
|
+ :doc_width="DOC_WIDTH"
|
|
|
|
|
+ :positions="positions"
|
|
|
|
|
+ >
|
|
|
|
|
+ </ViewerDocxFromUrl>
|
|
|
|
|
+ </template>
|
|
|
</div>
|
|
</div>
|
|
|
</main>
|
|
</main>
|
|
|
</template>
|
|
</template>
|
|
@@ -61,6 +73,7 @@
|
|
|
import { onMounted, ref } from 'vue';
|
|
import { onMounted, ref } from 'vue';
|
|
|
|
|
|
|
|
import ViewerPDFFromUrl from '../viewer-pdf/ViewerPDFFromUrl.vue';
|
|
import ViewerPDFFromUrl from '../viewer-pdf/ViewerPDFFromUrl.vue';
|
|
|
|
|
+import ViewerDocxFromUrl from '../viewer-docx/ViewerDocxFromUrl.vue';
|
|
|
|
|
|
|
|
import { getDocumentUrl } from './document';
|
|
import { getDocumentUrl } from './document';
|
|
|
|
|
|
|
@@ -68,6 +81,29 @@ const props = defineProps({
|
|
|
targetDocument: Object
|
|
targetDocument: Object
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 文档类别:doc/pdf
|
|
|
|
|
+ */
|
|
|
|
|
+const getDocType = (doc_name) => {
|
|
|
|
|
+ if (!doc_name) {
|
|
|
|
|
+ return '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const arr = doc_name.split('.');
|
|
|
|
|
+ const len = arr.length;
|
|
|
|
|
+ const end_fix = arr[len - 1];
|
|
|
|
|
+
|
|
|
|
|
+ if (end_fix === 'pdf') {
|
|
|
|
|
+ return 'pdf';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (end_fix === 'docx' || end_fix === 'doc') {
|
|
|
|
|
+ return 'doc';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return '';
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
const emit = defineEmits(['back']);
|
|
const emit = defineEmits(['back']);
|
|
|
|
|
|
|
|
const userName = ref('当前登录的用户名');
|
|
const userName = ref('当前登录的用户名');
|
|
@@ -77,12 +113,15 @@ const showPdfViewer = ref(false);
|
|
|
const positions = ref([]);
|
|
const positions = ref([]);
|
|
|
const pdfFather = ref(null);
|
|
const pdfFather = ref(null);
|
|
|
const DOC_WIDTH = ref(1100);
|
|
const DOC_WIDTH = ref(1100);
|
|
|
-const pdf_url = ref('');
|
|
|
|
|
|
|
+
|
|
|
|
|
+const target_doc_url = ref('');
|
|
|
|
|
+const target_doc_type = ref('');
|
|
|
|
|
|
|
|
let target_doc_id = ref(props.targetDocument.id);
|
|
let target_doc_id = ref(props.targetDocument.id);
|
|
|
let target_chunk_id = ref('');
|
|
let target_chunk_id = ref('');
|
|
|
|
|
|
|
|
-pdf_url.value = getDocumentUrl(target_doc_id.value);
|
|
|
|
|
|
|
+target_doc_url.value = getDocumentUrl(props.targetDocument.id);
|
|
|
|
|
+target_doc_type.value = getDocType(props.targetDocument.doc_name);
|
|
|
|
|
|
|
|
const pdfViewer = ref(null);
|
|
const pdfViewer = ref(null);
|
|
|
const docData = props.targetDocument;
|
|
const docData = props.targetDocument;
|
|
@@ -101,7 +140,9 @@ const goBack = () => {
|
|
|
|
|
|
|
|
const handelChangePdf = (item) => {
|
|
const handelChangePdf = (item) => {
|
|
|
if (item.doc_id !== target_doc_id.value) {
|
|
if (item.doc_id !== target_doc_id.value) {
|
|
|
- pdf_url.value = getDocumentUrl(item.doc_id);
|
|
|
|
|
|
|
+ target_doc_url.value = getDocumentUrl(item.doc_id);
|
|
|
|
|
+ target_doc_type.value = getDocType(item.doc_name);
|
|
|
|
|
+
|
|
|
target_doc_id.value = item.doc_id;
|
|
target_doc_id.value = item.doc_id;
|
|
|
target_chunk_id.value = '';
|
|
target_chunk_id.value = '';
|
|
|
readLoadPdf();
|
|
readLoadPdf();
|
|
@@ -111,13 +152,19 @@ const handelChangePdf = (item) => {
|
|
|
const handlerClickFragment = (frag) => {
|
|
const handlerClickFragment = (frag) => {
|
|
|
target_chunk_id.value = frag.chunk_id;
|
|
target_chunk_id.value = frag.chunk_id;
|
|
|
if (frag.doc_id !== target_doc_id.value) {
|
|
if (frag.doc_id !== target_doc_id.value) {
|
|
|
- pdf_url.value = getDocumentUrl(frag.doc_id);
|
|
|
|
|
|
|
+ target_doc_url.value = getDocumentUrl(frag.doc_id);
|
|
|
|
|
+ target_doc_type.value = getDocType(frag.doc_name);
|
|
|
|
|
+
|
|
|
target_doc_id.value = frag.doc_id;
|
|
target_doc_id.value = frag.doc_id;
|
|
|
readLoadPdf();
|
|
readLoadPdf();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
positions.value = [...frag.positions] || [];
|
|
positions.value = [...frag.positions] || [];
|
|
|
- if (frag.positions && frag.positions.length) {
|
|
|
|
|
- pdfViewer.value.toPageIndex(positions.value[0][0], positions.value);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (target_doc_type.value === 'pdf') {
|
|
|
|
|
+ if (frag.positions && frag.positions.length) {
|
|
|
|
|
+ pdfViewer.value.toPageIndex(positions.value[0][0], positions.value);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -133,8 +180,14 @@ const readLoadPdf = () => {
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
DOC_WIDTH.value = pdfFather.value.getBoundingClientRect().width;
|
|
DOC_WIDTH.value = pdfFather.value.getBoundingClientRect().width;
|
|
|
|
|
|
|
|
- const doc_id = props.targetDocument.doc_id;
|
|
|
|
|
- pdf_url.value = getDocumentUrl(doc_id);
|
|
|
|
|
|
|
+ const target_doc = props.targetDocument;
|
|
|
|
|
+ const doc_id = target_doc.doc_id;
|
|
|
|
|
+ const doc_name = target_doc.doc_name;
|
|
|
|
|
+
|
|
|
|
|
+ // const doc_id = props.targetDocument.doc_id;
|
|
|
|
|
+ target_doc_url.value = getDocumentUrl(doc_id);
|
|
|
|
|
+ target_doc_type.value = getDocType(doc_name);
|
|
|
|
|
+
|
|
|
showPdfViewer.value = true;
|
|
showPdfViewer.value = true;
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|
|
@@ -161,6 +214,8 @@ main > div.left {
|
|
|
background: #e2e4eb;
|
|
background: #e2e4eb;
|
|
|
display: flex;
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
flex-direction: column;
|
|
|
|
|
+ /* height: calc(100vh - 48px - 65px); */
|
|
|
|
|
+ height: calc(100vh - 48px - 117px);
|
|
|
}
|
|
}
|
|
|
main > div.left > header {
|
|
main > div.left > header {
|
|
|
padding-right: 20px;
|
|
padding-right: 20px;
|
|
@@ -282,4 +337,8 @@ main .activeBox {
|
|
|
main .activeLink {
|
|
main .activeLink {
|
|
|
color: #00aea3 !important;
|
|
color: #00aea3 !important;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+.right {
|
|
|
|
|
+ height: calc(100vh - 48px - 65px);
|
|
|
|
|
+}
|
|
|
</style>
|
|
</style>
|