部分下载文件功能添加

This commit is contained in:
2026-09-23 13:45:06 +08:00
parent 0e42842611
commit 86a3520ecb
6 changed files with 36 additions and 32 deletions
+15 -11
View File
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue';
import { ref, onMounted } from 'vue';
import { Icon } from '@iconify/vue'
import { useThemeStore } from '@/store/modules/theme';
import { useRouterPush } from '@/hooks/common/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 { systemConfigApi } from '@/service/api/system';
import { getChangeDetailApi } from '@/service/api/change';
@@ -103,8 +103,12 @@ const onUploadFile = async (type:string = '',files:any,index:number = -1) => {
}
// 下载文件
const downloadFile = (type:string) => {
window.$message?.info('还差接口')
const downloadFile = (file:any,type:string) => {
if(file){
downloadFileFun(file?.file_url, file?.doc_name || file?.file_name);
}else{
window.$message?.info('还差接口')
}
}
// 删除文件(真删)
const removeFileReal = async (type:string, fileIndex:number,index:number = -1) => {
@@ -300,7 +304,7 @@ onMounted(() => {
<Icon icon="akar-icons:file" class="size-12px" />
{{file.file_name}}
<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
positive-text="确定"
:positiveButtonProps="{ size: 'tiny' }"
@@ -315,7 +319,7 @@ onMounted(() => {
</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" />
下载培训签到表
</NButton>
@@ -349,7 +353,7 @@ onMounted(() => {
<Icon icon="akar-icons:file" class="size-12px" />
{{file.file_name}}
<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
positive-text="确定"
:positiveButtonProps="{ size: 'tiny' }"
@@ -364,7 +368,7 @@ onMounted(() => {
</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" />
下载PSSR检查表
</NButton>
@@ -421,7 +425,7 @@ onMounted(() => {
<Icon icon="akar-icons:file" class="size-12px" />
{{file.file_name}}
<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
positive-text="确定"
:positiveButtonProps="{ size: 'tiny' }"
@@ -436,7 +440,7 @@ onMounted(() => {
</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" />
下载验收表
</NButton>
@@ -502,7 +506,7 @@ onMounted(() => {
<Icon icon="akar-icons:file" class="size-12px" />
{{file.file_name}}
<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
positive-text="确定"
:positiveButtonProps="{ size: 'tiny' }"