|
|
@@ -71,7 +71,7 @@
|
|
|
:underline="false"
|
|
|
type="primary"
|
|
|
size="small"
|
|
|
- @click="viewHazardFile(row.hazardFile)"
|
|
|
+ @click="viewFile(row.hazardFile)"
|
|
|
>查看</el-link
|
|
|
>
|
|
|
<span v-else>-</span>
|
|
|
@@ -87,7 +87,7 @@
|
|
|
:underline="false"
|
|
|
type="primary"
|
|
|
size="small"
|
|
|
- @click="viewRectifyFile(row.rectifyFile)"
|
|
|
+ @click="viewFile(row.rectifyFile)"
|
|
|
>查看</el-link
|
|
|
>
|
|
|
<span v-else>-</span>
|
|
|
@@ -243,6 +243,30 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <el-dialog v-model="dialogFileView" title="附件" width="500">
|
|
|
+ <div
|
|
|
+ v-for="(file, index) in fileList"
|
|
|
+ :key="index"
|
|
|
+ class="flex items-center justify-between mt-5"
|
|
|
+ >
|
|
|
+ <span class="file-name-text">{{ extractFileName(file) }}</span>
|
|
|
+ <div>
|
|
|
+ <el-button link type="primary" @click="viewFileInfo(file)">
|
|
|
+ <Icon icon="ep:view" class="mr-2px" />查看</el-button
|
|
|
+ >
|
|
|
+ <el-button link type="primary" @click="handleDownload(file)">
|
|
|
+ <Icon icon="ep:download" class="mr-2px" />下载</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer mt-10">
|
|
|
+ <el-button type="primary" @click="dialogFileView = false"> 确认 </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<FilePreviewDialog
|
|
|
v-model="filePreviewVisible"
|
|
|
:title="filePreviewTitle"
|
|
|
@@ -535,31 +559,21 @@ const submitFix = async () => {
|
|
|
}
|
|
|
|
|
|
// 下载文件函数
|
|
|
-const downloadFile = (response: any) => {
|
|
|
- const blob = new Blob([response], {
|
|
|
- type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
|
|
|
- })
|
|
|
-
|
|
|
- let fileName = '隐患排查.xlsx'
|
|
|
- const disposition = response.headers ? response.headers['content-disposition'] : ''
|
|
|
- if (disposition) {
|
|
|
- const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/
|
|
|
- const matches = filenameRegex.exec(disposition)
|
|
|
- if (matches != null && matches[1]) {
|
|
|
- fileName = matches[1].replace(/['"]/g, '')
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const url = window.URL.createObjectURL(blob)
|
|
|
- const link = document.createElement('a')
|
|
|
- link.href = url
|
|
|
- link.setAttribute('download', fileName)
|
|
|
+const handleDownload = async (url) => {
|
|
|
+ try {
|
|
|
+ const response = await fetch(url)
|
|
|
+ const blob = await response.blob()
|
|
|
+ const downloadUrl = window.URL.createObjectURL(blob)
|
|
|
|
|
|
- document.body.appendChild(link)
|
|
|
- link.click()
|
|
|
+ const link = document.createElement('a')
|
|
|
+ link.href = downloadUrl
|
|
|
+ link.download = url.split('/').pop() // 自动获取文件名:ml-citation{ref="3" data="citationList"}
|
|
|
+ link.click()
|
|
|
|
|
|
- document.body.removeChild(link)
|
|
|
- window.URL.revokeObjectURL(url)
|
|
|
+ URL.revokeObjectURL(downloadUrl)
|
|
|
+ } catch (error) {
|
|
|
+ console.error('下载失败:', error)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
let userList = ref([])
|
|
|
@@ -572,6 +586,35 @@ const handleDeptChange = async (value) => {
|
|
|
console.log('value>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', userList.value)
|
|
|
}
|
|
|
|
|
|
+let dialogFileView = ref(false)
|
|
|
+let fileList = ref([])
|
|
|
+const viewFile = (file) => {
|
|
|
+ fileList.value = file.split(',')
|
|
|
+ dialogFileView.value = true
|
|
|
+ // window.open(file)
|
|
|
+}
|
|
|
+
|
|
|
+const viewFileInfo = (file) => {
|
|
|
+ window.open(
|
|
|
+ 'http://doc.deepoil.cc:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(file))
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const extractFileName = (url: string): string => {
|
|
|
+ try {
|
|
|
+ // 移除查询参数和哈希
|
|
|
+ const cleanUrl = url.split('?')[0].split('#')[0]
|
|
|
+ // 获取最后一个斜杠后的内容
|
|
|
+ const parts = cleanUrl.split('/')
|
|
|
+ const fileName = parts[parts.length - 1]
|
|
|
+ // URL 解码
|
|
|
+ return decodeURIComponent(fileName) || url
|
|
|
+ } catch {
|
|
|
+ // 如果解析失败,返回原始 URL
|
|
|
+ return url
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
onMounted(async () => {
|
|
|
getList()
|
|
|
deptList2.value = handleTree(await DeptApi.getSimpleDeptList())
|