部分下载文件功能添加
This commit is contained in:
+1
-1
@@ -238,8 +238,8 @@ export function getTimeRangeStamp(timeRange: string){
|
|||||||
export function downloadFileFun(url: string, name: string) {
|
export function downloadFileFun(url: string, name: string) {
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.target = '_blank';
|
|
||||||
a.download = name;
|
a.download = name;
|
||||||
|
a.style.display = 'none';
|
||||||
document.body.appendChild(a)
|
document.body.appendChild(a)
|
||||||
a.click()
|
a.click()
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Icon } from '@iconify/vue'
|
|||||||
import { useThemeStore } from '@/store/modules/theme';
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
import { useRouterPush } from '@/hooks/common/router';
|
import { useRouterPush } from '@/hooks/common/router';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { getColorWithOpacity, tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common';
|
import { getColorWithOpacity, tagTextColor, tagBgColor, tagBorderColor, downloadFileFun } from '@/utils/common';
|
||||||
import { AiError, aiTypeJudge } from "@/service/api/ai";
|
import { AiError, aiTypeJudge } from "@/service/api/ai";
|
||||||
import { systemConfigApi } from '@/service/api/system';
|
import { systemConfigApi } from '@/service/api/system';
|
||||||
import { getChangeDetailApi } from '@/service/api/change';
|
import { getChangeDetailApi } from '@/service/api/change';
|
||||||
@@ -268,12 +268,11 @@ const exportFile = (type: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 变更附带资料下载/一键下载
|
// 变更附带资料下载/一键下载
|
||||||
const downloadFile = (type: string) => {
|
const downloadFile = (file:any,type: string) => {
|
||||||
window.$message?.info('还差接口')
|
|
||||||
if(type === 'all'){
|
if(type === 'all'){
|
||||||
window.$message?.success('打包下载全部附件');
|
window.$message?.info('还差接口')
|
||||||
}else{
|
}else{
|
||||||
window.$message?.success('下载当前附件成功');
|
downloadFileFun(file?.file_url, file?.doc_name || file?.file_name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 变更附带资料预览
|
// 变更附带资料预览
|
||||||
@@ -560,7 +559,7 @@ onMounted(() => {
|
|||||||
class="rounded-sm bg-[var(--theme-color)] px-3 py-1 text-xs font-semibold text-white"
|
class="rounded-sm bg-[var(--theme-color)] px-3 py-1 text-xs font-semibold text-white"
|
||||||
:style="{'--theme-color': themeStore.themeColor}"
|
:style="{'--theme-color': themeStore.themeColor}"
|
||||||
>变更附带资料</p>
|
>变更附带资料</p>
|
||||||
<NButton ghost size="small" class="text-xs" @click="downloadFile('all')"><Icon icon="material-symbols:download" class="size-16px" />一键下载</NButton>
|
<NButton ghost size="small" class="text-xs" @click="downloadFile(null,'all')"><Icon icon="material-symbols:download" class="size-16px" />一键下载</NButton>
|
||||||
</div>
|
</div>
|
||||||
<NTable size="small">
|
<NTable size="small">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -587,7 +586,7 @@ onMounted(() => {
|
|||||||
<td>
|
<td>
|
||||||
<div class="flex items-center justify-center gap-2">
|
<div class="flex items-center justify-center gap-2">
|
||||||
<NButton text type="primary" class="text-xs" @click="openPreview(doc)">预览</NButton>
|
<NButton text type="primary" class="text-xs" @click="openPreview(doc)">预览</NButton>
|
||||||
<NButton text type="primary" class="text-xs" @click="downloadFile('single')">下载</NButton>
|
<NButton text type="primary" class="text-xs" @click="downloadFile(doc,'single')">下载</NButton>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, computed } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { Icon } from '@iconify/vue'
|
import { Icon } from '@iconify/vue'
|
||||||
import { useThemeStore } from '@/store/modules/theme';
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
import { useRouterPush } from '@/hooks/common/router';
|
import { useRouterPush } from '@/hooks/common/router';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { getColorWithOpacity, tagTextColor, tagBgColor, tagBorderColor, formatTimestamp, anyToTimestamp } from '@/utils/common';
|
import { formatTimestamp, downloadFileFun } from '@/utils/common';
|
||||||
import { uploadFileApi, deleteFileApi, fileListApi } from "@/service/api/file";
|
import { uploadFileApi, deleteFileApi, fileListApi } from "@/service/api/file";
|
||||||
import { systemConfigApi } from '@/service/api/system';
|
import { systemConfigApi } from '@/service/api/system';
|
||||||
import { getChangeDetailApi } from '@/service/api/change';
|
import { getChangeDetailApi } from '@/service/api/change';
|
||||||
@@ -103,8 +103,12 @@ const onUploadFile = async (type:string = '',files:any,index:number = -1) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 下载文件
|
// 下载文件
|
||||||
const downloadFile = (type:string) => {
|
const downloadFile = (file:any,type:string) => {
|
||||||
|
if(file){
|
||||||
|
downloadFileFun(file?.file_url, file?.doc_name || file?.file_name);
|
||||||
|
}else{
|
||||||
window.$message?.info('还差接口')
|
window.$message?.info('还差接口')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 删除文件(真删)
|
// 删除文件(真删)
|
||||||
const removeFileReal = async (type:string, fileIndex:number,index:number = -1) => {
|
const removeFileReal = async (type:string, fileIndex:number,index:number = -1) => {
|
||||||
@@ -300,7 +304,7 @@ onMounted(() => {
|
|||||||
<Icon icon="akar-icons:file" class="size-12px" />
|
<Icon icon="akar-icons:file" class="size-12px" />
|
||||||
{{file.file_name}}
|
{{file.file_name}}
|
||||||
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
||||||
<NButton text type="primary" class="text-11px" @click="downloadFile('pssr')">下载</NButton>
|
<NButton text type="primary" class="text-11px" @click="downloadFile(file,'train')">下载</NButton>
|
||||||
<NPopconfirm
|
<NPopconfirm
|
||||||
positive-text="确定"
|
positive-text="确定"
|
||||||
:positiveButtonProps="{ size: 'tiny' }"
|
:positiveButtonProps="{ size: 'tiny' }"
|
||||||
@@ -315,7 +319,7 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NButton ghost type="primary" size="small" class="text-xs" @click="downloadFile('pssr')">
|
<NButton ghost type="primary" size="small" class="text-xs" @click="downloadFile(null,'train')">
|
||||||
<Icon icon="akar-icons:download" class="size-14px mr-1" />
|
<Icon icon="akar-icons:download" class="size-14px mr-1" />
|
||||||
下载培训签到表
|
下载培训签到表
|
||||||
</NButton>
|
</NButton>
|
||||||
@@ -349,7 +353,7 @@ onMounted(() => {
|
|||||||
<Icon icon="akar-icons:file" class="size-12px" />
|
<Icon icon="akar-icons:file" class="size-12px" />
|
||||||
{{file.file_name}}
|
{{file.file_name}}
|
||||||
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
||||||
<NButton text type="primary" class="text-11px" @click="downloadFile('pssr')">下载</NButton>
|
<NButton text type="primary" class="text-11px" @click="downloadFile(file,'pssr')">下载</NButton>
|
||||||
<NPopconfirm
|
<NPopconfirm
|
||||||
positive-text="确定"
|
positive-text="确定"
|
||||||
:positiveButtonProps="{ size: 'tiny' }"
|
:positiveButtonProps="{ size: 'tiny' }"
|
||||||
@@ -364,7 +368,7 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NButton ghost type="primary" size="small" class="text-xs" @click="downloadFile('pssr')">
|
<NButton ghost type="primary" size="small" class="text-xs" @click="downloadFile(null,'pssr')">
|
||||||
<Icon icon="akar-icons:download" class="size-14px mr-1" />
|
<Icon icon="akar-icons:download" class="size-14px mr-1" />
|
||||||
下载PSSR检查表
|
下载PSSR检查表
|
||||||
</NButton>
|
</NButton>
|
||||||
@@ -421,7 +425,7 @@ onMounted(() => {
|
|||||||
<Icon icon="akar-icons:file" class="size-12px" />
|
<Icon icon="akar-icons:file" class="size-12px" />
|
||||||
{{file.file_name}}
|
{{file.file_name}}
|
||||||
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
||||||
<NButton text type="primary" class="text-11px" @click="downloadFile('pssr')">下载</NButton>
|
<NButton text type="primary" class="text-11px" @click="downloadFile(file,'accept')">下载</NButton>
|
||||||
<NPopconfirm
|
<NPopconfirm
|
||||||
positive-text="确定"
|
positive-text="确定"
|
||||||
:positiveButtonProps="{ size: 'tiny' }"
|
:positiveButtonProps="{ size: 'tiny' }"
|
||||||
@@ -436,7 +440,7 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<NButton ghost type="primary" size="small" class="text-xs" @click="downloadFile('accept')">
|
<NButton ghost type="primary" size="small" class="text-xs" @click="downloadFile(null,'accept')">
|
||||||
<Icon icon="akar-icons:download" class="size-14px mr-1" />
|
<Icon icon="akar-icons:download" class="size-14px mr-1" />
|
||||||
下载验收表
|
下载验收表
|
||||||
</NButton>
|
</NButton>
|
||||||
@@ -502,7 +506,7 @@ onMounted(() => {
|
|||||||
<Icon icon="akar-icons:file" class="size-12px" />
|
<Icon icon="akar-icons:file" class="size-12px" />
|
||||||
{{file.file_name}}
|
{{file.file_name}}
|
||||||
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
<NButton text type="primary" class="text-11px" @click="preview(file)">预览</NButton>
|
||||||
<NButton text type="primary" class="text-11px" @click="downloadFile('accept')">下载</NButton>
|
<NButton text type="primary" class="text-11px" @click="downloadFile(file,'close')">下载</NButton>
|
||||||
<NPopconfirm
|
<NPopconfirm
|
||||||
positive-text="确定"
|
positive-text="确定"
|
||||||
:positiveButtonProps="{ size: 'tiny' }"
|
:positiveButtonProps="{ size: 'tiny' }"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Icon } from '@iconify/vue'
|
|||||||
import { useThemeStore } from '@/store/modules/theme';
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
import { useRouterPush } from '@/hooks/common/router';
|
import { useRouterPush } from '@/hooks/common/router';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { getColorWithOpacity, tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common';
|
import { tagTextColor, tagBgColor, tagBorderColor, downloadFileFun } from '@/utils/common';
|
||||||
import { AiError, aiTypeJudge } from "@/service/api/ai";
|
import { AiError, aiTypeJudge } from "@/service/api/ai";
|
||||||
import { systemConfigApi } from '@/service/api/system';
|
import { systemConfigApi } from '@/service/api/system';
|
||||||
import { getChangeDetailApi } from '@/service/api/change';
|
import { getChangeDetailApi } from '@/service/api/change';
|
||||||
@@ -183,12 +183,11 @@ const exportFile = (type: string) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 变更附带资料下载/一键下载
|
// 变更附带资料下载/一键下载
|
||||||
const downloadFile = (type: string) => {
|
const downloadFile = (file:any,type: string) => {
|
||||||
window.$message?.info('还差接口')
|
if(file){
|
||||||
if(type === 'all'){
|
downloadFileFun(file?.file_url, file?.doc_name || file?.file_name);
|
||||||
window.$message?.success('打包下载全部附件');
|
|
||||||
}else{
|
}else{
|
||||||
window.$message?.success('下载当前附件成功');
|
window.$message?.info('还差接口')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// 变更附带资料预览
|
// 变更附带资料预览
|
||||||
@@ -443,7 +442,7 @@ onMounted(() => {
|
|||||||
class="rounded-sm bg-[var(--theme-color)] px-3 py-1 text-xs font-semibold text-white"
|
class="rounded-sm bg-[var(--theme-color)] px-3 py-1 text-xs font-semibold text-white"
|
||||||
:style="{'--theme-color': themeStore.themeColor}"
|
:style="{'--theme-color': themeStore.themeColor}"
|
||||||
>变更附带资料</p>
|
>变更附带资料</p>
|
||||||
<NButton ghost size="small" class="text-xs" @click="downloadFile('all')"><Icon icon="material-symbols:download" class="size-16px" />一键下载</NButton>
|
<NButton ghost size="small" class="text-xs" @click="downloadFile(null,'all')"><Icon icon="material-symbols:download" class="size-16px" />一键下载</NButton>
|
||||||
</div>
|
</div>
|
||||||
<NTable size="small">
|
<NTable size="small">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -470,7 +469,7 @@ onMounted(() => {
|
|||||||
<td>
|
<td>
|
||||||
<div class="flex items-center justify-center gap-2">
|
<div class="flex items-center justify-center gap-2">
|
||||||
<NButton text type="primary" class="text-xs" @click="openPreview(doc)">预览</NButton>
|
<NButton text type="primary" class="text-xs" @click="openPreview(doc)">预览</NButton>
|
||||||
<NButton text type="primary" class="text-xs" @click="downloadFile('single')">下载</NButton>
|
<NButton text type="primary" class="text-xs" @click="downloadFile(doc,'single')">下载</NButton>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { ref, computed, h, watch } from 'vue';
|
import { ref, computed, h, watch } from 'vue';
|
||||||
import { Icon } from '@iconify/vue'
|
import { Icon } from '@iconify/vue'
|
||||||
import { useThemeStore } from '@/store/modules/theme';
|
import { useThemeStore } from '@/store/modules/theme';
|
||||||
import { tagTextColor, tagBgColor, tagBorderColor } from '@/utils/common';
|
import { tagTextColor, tagBgColor, tagBorderColor, downloadFileFun } from '@/utils/common';
|
||||||
import { localStg } from '@/utils/storage';
|
import { localStg } from '@/utils/storage';
|
||||||
import { useChangeStore } from '@/store/modules/change';
|
import { useChangeStore } from '@/store/modules/change';
|
||||||
import { AiError, aiTypeJudge, aiLevelScore, aiApplication } from "@/service/api/ai";
|
import { AiError, aiTypeJudge, aiLevelScore, aiApplication } from "@/service/api/ai";
|
||||||
@@ -346,8 +346,10 @@ const handleScoreChange = (val:number,index:number) => {
|
|||||||
totalScore.value = score;
|
totalScore.value = score;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载PDF
|
// 下载
|
||||||
const downloadPdf = () => window.$message?.success(`演示:${previewFile.value} 已下载`);
|
const downloadFile = (file:any) => {
|
||||||
|
downloadFileFun(file?.file_url, file?.doc_name || file?.file_name);
|
||||||
|
};
|
||||||
// 自定义渲染展开图标
|
// 自定义渲染展开图标
|
||||||
const renderSwitcherIcon = (node:any) => {
|
const renderSwitcherIcon = (node:any) => {
|
||||||
// 如果节点没有 children 或 children 为空数组,则不显示图标
|
// 如果节点没有 children 或 children 为空数组,则不显示图标
|
||||||
@@ -794,7 +796,7 @@ defineExpose({form, questions, applyAiResult, generateLevel: useAiLevel})
|
|||||||
</template>
|
</template>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<div class="flex justify-end gap-[10px]">
|
<div class="flex justify-end gap-[10px]">
|
||||||
<NButton ghost size="small" @click="downloadPdf">
|
<NButton ghost size="small" @click="downloadFile(previewFile)">
|
||||||
<Icon icon="material-symbols:download" class="size-16px" /> 下载
|
<Icon icon="material-symbols:download" class="size-16px" /> 下载
|
||||||
</NButton>
|
</NButton>
|
||||||
<NButton size="small" type="primary" @click="previewFile = null">关闭</NButton>
|
<NButton size="small" type="primary" @click="previewFile = null">关闭</NButton>
|
||||||
|
|||||||
Reference in New Issue
Block a user