|
@@ -2,76 +2,57 @@
|
|
* @Author: ChenYaJin
|
|
* @Author: ChenYaJin
|
|
* @Date: 2021-06-16 14:21:39
|
|
* @Date: 2021-06-16 14:21:39
|
|
* @LastEditors: LiZhiWei
|
|
* @LastEditors: LiZhiWei
|
|
- * @LastEditTime: 2025-04-16 10:21:48
|
|
|
|
|
|
+ * @LastEditTime: 2025-04-16 11:49:31
|
|
* @Description: 文件柜-预览文件
|
|
* @Description: 文件柜-预览文件
|
|
-->
|
|
-->
|
|
<template>
|
|
<template>
|
|
- <div class="">
|
|
|
|
- <w-header desc="预览文件详情。" class="header-rewrite">
|
|
|
|
- <template>
|
|
|
|
- <el-select
|
|
|
|
- v-model="downloadUrl"
|
|
|
|
- filterable
|
|
|
|
- allow-create
|
|
|
|
- default-first-option
|
|
|
|
- clearable
|
|
|
|
- placeholder="请选择或输入文件预览地址"
|
|
|
|
- class="input-with-button"
|
|
|
|
- >
|
|
|
|
- <el-option
|
|
|
|
- v-for="item in urlOptions"
|
|
|
|
- :key="item.value"
|
|
|
|
- :label="item.label"
|
|
|
|
- :value="item.value"
|
|
|
|
- >
|
|
|
|
- <span class="url-label">{{ item.label }}</span>
|
|
|
|
- <span class="url-value">{{ item.value }}</span>
|
|
|
|
- </el-option>
|
|
|
|
- </el-select>
|
|
|
|
- <el-button
|
|
|
|
- type="primary"
|
|
|
|
- :loading="downloading"
|
|
|
|
- @click="handleDownload"
|
|
|
|
- style="margin-left: 10px;"
|
|
|
|
- >
|
|
|
|
- 预览文件
|
|
|
|
- </el-button>
|
|
|
|
- </template>
|
|
|
|
- </w-header>
|
|
|
|
- <div class="modal-height">
|
|
|
|
- <div class="file-box">
|
|
|
|
- <p class="file-name">{{file.name}}</p>
|
|
|
|
- <div class="view-wrapper">
|
|
|
|
- <div class="preview-wrapper" ref="wrapper" v-if="isAbleView">
|
|
|
|
- <div v-if="renderLoading && !showError" class="loading-process">
|
|
|
|
- <el-progress class="file-progress" :text-inside="true" :stroke-width="15" :percentage="percentage"></el-progress>
|
|
|
|
- <span class="load-text">
|
|
|
|
- <template v-if="renderLoading && loadLoading">文件加载中....</template>
|
|
|
|
- <template v-else>加载完成,文件显示中....</template>
|
|
|
|
- </span>
|
|
|
|
- </div>
|
|
|
|
- <template v-if="!showError">
|
|
|
|
- <div class="preview-inner" ref="preview-inner">
|
|
|
|
- <div class="preview-mark" ref="bg-mark" id="bg-mark"></div>
|
|
|
|
- <div class="output" ref="output"></div>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div class="">
|
|
|
|
+ <w-header desc="预览文件详情。" class="header-rewrite">
|
|
|
|
+ <template>
|
|
|
|
+ <el-select v-model="downloadUrl" filterable allow-create default-first-option clearable
|
|
|
|
+ placeholder="请选择或输入文件预览地址" class="input-with-button">
|
|
|
|
+ <el-option v-for="item in urlOptions" :key="item.value" :label="item.label" :value="item.value">
|
|
|
|
+ <span class="url-label">{{ item.label }}</span>
|
|
|
|
+ <span class="url-value">{{ item.value }}</span>
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ <el-button type="primary" :loading="downloading" @click="handleDownload" style="margin-left: 10px;">
|
|
|
|
+ 预览文件
|
|
|
|
+ </el-button>
|
|
</template>
|
|
</template>
|
|
- <div class="error-wrapper" v-show="showError && !loadLoading">
|
|
|
|
- <wc-page-tip tip="未找到相应文件信息" type="errorData" />
|
|
|
|
|
|
+ </w-header>
|
|
|
|
+ <div class="modal-height">
|
|
|
|
+ <div class="file-box">
|
|
|
|
+ <p class="file-name">{{file.name}}</p>
|
|
|
|
+ <div class="view-wrapper">
|
|
|
|
+ <div class="preview-wrapper" ref="wrapper" v-if="isAbleView">
|
|
|
|
+ <div v-if="renderLoading && !showError" class="loading-process">
|
|
|
|
+ <el-progress class="file-progress" :text-inside="true" :stroke-width="15"
|
|
|
|
+ :percentage="percentage"></el-progress>
|
|
|
|
+ <span class="load-text">
|
|
|
|
+ <template v-if="renderLoading && loadLoading">文件加载中....</template>
|
|
|
|
+ <template v-else>加载完成,文件显示中....</template>
|
|
|
|
+ </span>
|
|
|
|
+ </div>
|
|
|
|
+ <template v-if="!showError">
|
|
|
|
+ <div class="preview-inner" ref="preview-inner">
|
|
|
|
+ <!-- <div class="preview-mark" ref="bg-mark" id="bg-mark"></div> -->
|
|
|
|
+ <div class="output" ref="output"></div>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ <div class="error-wrapper" v-show="showError && !loadLoading">
|
|
|
|
+ <wc-page-tip tip="未找到相应文件信息" type="errorData" />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <!-- <view-other-component v-else :file="currentFile" /> -->
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div>
|
|
|
|
+ <file-detail-modal :id="fileId" :loadingFile="loadingFile" :file="currentFile"
|
|
|
|
+ @updateSuccess="updateSuccess" @back="turnBack" />
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- <!-- <view-other-component v-else :file="currentFile" /> -->
|
|
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
- <div>
|
|
|
|
- <file-detail-modal :id="fileId"
|
|
|
|
- :loadingFile="loadingFile"
|
|
|
|
- :file="currentFile"
|
|
|
|
- @updateSuccess="updateSuccess"
|
|
|
|
- @back="turnBack"/>
|
|
|
|
- </div>
|
|
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
import { mapActions, mapState } from 'vuex'
|
|
import { mapActions, mapState } from 'vuex'
|
|
@@ -130,7 +111,12 @@ export default {
|
|
{
|
|
{
|
|
value: 'https://501351981.github.io/vue-office/examples/dist/static/test-files/test.xlsx',
|
|
value: 'https://501351981.github.io/vue-office/examples/dist/static/test-files/test.xlsx',
|
|
label: 'Excel示例文件'
|
|
label: 'Excel示例文件'
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ value: 'https://fastly.picsum.photos/id/641/800/600.jpg?hmac=DJCZbdxrCoJPFV0jAsSIG1Ny0oc48zL3iqeMFqtKlD4',
|
|
|
|
+ label: '图片示例文件'
|
|
|
|
+ },
|
|
]
|
|
]
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -296,7 +282,8 @@ export default {
|
|
// 从URL中获取文件名和类型
|
|
// 从URL中获取文件名和类型
|
|
const urlParts = this.downloadUrl.split('/')
|
|
const urlParts = this.downloadUrl.split('/')
|
|
const fileName = urlParts[urlParts.length - 1]
|
|
const fileName = urlParts[urlParts.length - 1]
|
|
- const fileType = fileName.split('.').pop().toLowerCase()
|
|
|
|
|
|
+ const fileNameWithParams = urlParts[urlParts.length - 1]
|
|
|
|
+ const fileType = fileNameWithParams.split('?')[0].match(/\.([^.]+)$/)?.[1]?.toLowerCase() || ''
|
|
//文件大小
|
|
//文件大小
|
|
const fileSize = res.headers['content-length']/1024
|
|
const fileSize = res.headers['content-length']/1024
|
|
// 更新文件信息
|
|
// 更新文件信息
|
|
@@ -307,24 +294,23 @@ export default {
|
|
size: fileSize
|
|
size: fileSize
|
|
}
|
|
}
|
|
this.currentFile = {...this.file }
|
|
this.currentFile = {...this.file }
|
|
-
|
|
|
|
return readBuffer(res.data).then(arrayBuffer => {
|
|
return readBuffer(res.data).then(arrayBuffer => {
|
|
return this.renderResult(arrayBuffer, fileType)
|
|
return this.renderResult(arrayBuffer, fileType)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
.then(() => {
|
|
.then(() => {
|
|
- const output = this.$refs['output']
|
|
|
|
- const mark = this.$refs['bg-mark']
|
|
|
|
- const isXlsx = ['xlsx'].includes(this.file.type)
|
|
|
|
|
|
+ // const output = this.$refs['output']
|
|
|
|
+ // const mark = this.$refs['bg-mark']
|
|
|
|
+ // const isXlsx = ['xlsx'].includes(this.file.type)
|
|
|
|
|
|
// if (isXlsx) {
|
|
// if (isXlsx) {
|
|
// this.$refs['preview-inner'].removeChild(mark)
|
|
// this.$refs['preview-inner'].removeChild(mark)
|
|
// commJs.addWaterMarker(output, this.currentFile.markMessage)
|
|
// commJs.addWaterMarker(output, this.currentFile.markMessage)
|
|
// }
|
|
// }
|
|
- if (mark && output) {
|
|
|
|
- mark.style.height = output.height + 'px'
|
|
|
|
- commJs.addWaterMarker(mark, this.currentFile.markMessage)
|
|
|
|
- }
|
|
|
|
|
|
+ // if (mark && output) {
|
|
|
|
+ // mark.style.height = output.height + 'px'
|
|
|
|
+ // commJs.addWaterMarker(mark, this.currentFile.markMessage)
|
|
|
|
+ // }
|
|
|
|
|
|
this.$message.success('文件加载成功')
|
|
this.$message.success('文件加载成功')
|
|
})
|
|
})
|
|
@@ -343,60 +329,70 @@ export default {
|
|
</script>
|
|
</script>
|
|
<style lang="less">
|
|
<style lang="less">
|
|
.docx-wrapper {
|
|
.docx-wrapper {
|
|
- background: unset !important;
|
|
|
|
- padding: 0 !important;
|
|
|
|
- &>section.docx {
|
|
|
|
background: unset !important;
|
|
background: unset !important;
|
|
- }
|
|
|
|
|
|
+ padding: 0 !important;
|
|
|
|
+
|
|
|
|
+ &>section.docx {
|
|
|
|
+ background: unset !important;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
@import './index.less';
|
|
@import './index.less';
|
|
-@deep:~'>>>';
|
|
|
|
|
|
+@deep: ~'>>>';
|
|
|
|
+
|
|
@{deep} .header-rewrite {
|
|
@{deep} .header-rewrite {
|
|
- margin-bottom: 0 !important;
|
|
|
|
|
|
+ margin-bottom: 0 !important;
|
|
}
|
|
}
|
|
|
|
+
|
|
.modal-height {
|
|
.modal-height {
|
|
- display: flex;
|
|
|
|
- justify-content: space-between;
|
|
|
|
- .file-box {
|
|
|
|
- flex: 1;
|
|
|
|
- padding: 15px 40px;
|
|
|
|
- overflow: scroll;
|
|
|
|
- text-align: center;
|
|
|
|
- .file-name {
|
|
|
|
- line-height: 36px;
|
|
|
|
- text-align: center;
|
|
|
|
- font-size: 16px;
|
|
|
|
- font-weight: 500;
|
|
|
|
- }
|
|
|
|
- .view-wrapper {
|
|
|
|
- position: relative;
|
|
|
|
- width: 100%;
|
|
|
|
- height: ~'calc(100% - 36px)';
|
|
|
|
- overflow: hidden;
|
|
|
|
- }
|
|
|
|
- .output {
|
|
|
|
- // border: 1px solid #ccc;
|
|
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-between;
|
|
|
|
+
|
|
|
|
+ .file-box {
|
|
|
|
+ flex: 1;
|
|
|
|
+ padding: 15px 40px;
|
|
|
|
+ overflow: scroll;
|
|
|
|
+ text-align: center;
|
|
|
|
+
|
|
|
|
+ .file-name {
|
|
|
|
+ line-height: 36px;
|
|
|
|
+ text-align: center;
|
|
|
|
+ font-size: 16px;
|
|
|
|
+ font-weight: 500;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .view-wrapper {
|
|
|
|
+ position: relative;
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: ~'calc(100% - 36px)';
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .output {
|
|
|
|
+ // border: 1px solid #ccc;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
.input-with-button {
|
|
.input-with-button {
|
|
- width: 400px;
|
|
|
|
- .url-label {
|
|
|
|
- float: left;
|
|
|
|
- color: #606266;
|
|
|
|
- }
|
|
|
|
- .url-value {
|
|
|
|
- float: right;
|
|
|
|
- color: #909399;
|
|
|
|
- font-size: 13px;
|
|
|
|
- }
|
|
|
|
|
|
+ width: 400px;
|
|
|
|
+
|
|
|
|
+ .url-label {
|
|
|
|
+ float: left;
|
|
|
|
+ color: #606266;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .url-value {
|
|
|
|
+ float: right;
|
|
|
|
+ color: #909399;
|
|
|
|
+ font-size: 13px;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@{deep} .el-select-dropdown__item {
|
|
@{deep} .el-select-dropdown__item {
|
|
- padding: 0 20px;
|
|
|
|
- height: 40px;
|
|
|
|
- line-height: 40px;
|
|
|
|
|
|
+ padding: 0 20px;
|
|
|
|
+ height: 40px;
|
|
|
|
+ line-height: 40px;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|