1
This commit is contained in:
@@ -28,3 +28,16 @@ export const fetchList = (query?: any) => {
|
|||||||
params: query,
|
params: query,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载任务文件
|
||||||
|
* @param data 如 { id: 任务id }
|
||||||
|
*/
|
||||||
|
export const downloadTaskFile = (data?: any) => {
|
||||||
|
return request({
|
||||||
|
url: '/basic/basicAsyncTask/downloadTaskFile',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -28,7 +28,12 @@
|
|||||||
>
|
>
|
||||||
<el-table-column label="所属模块" prop="moduleName" width="120" show-overflow-tooltip />
|
<el-table-column label="所属模块" prop="moduleName" width="120" show-overflow-tooltip />
|
||||||
<el-table-column label="任务类型" prop="typeLabel" width="100" show-overflow-tooltip />
|
<el-table-column label="任务类型" prop="typeLabel" width="100" show-overflow-tooltip />
|
||||||
<el-table-column label="任务名称" prop="detailType" min-width="150" show-overflow-tooltip />
|
<el-table-column label="任务名称" prop="detailType" min-width="150" show-overflow-tooltip >
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button v-if="row.type==2" type="text" icon="Download" class="task-name-text" :loading="downloadingId === row.id" @click="handleDownloadFile(row)">{{row.detailType}}</el-button>
|
||||||
|
<span v-else class="task-name-text">{{row.detailType}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="任务状态" align="center" show-overflow-tooltip>
|
<el-table-column label="任务状态" align="center" show-overflow-tooltip>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag>{{ row.status }}</el-tag>
|
<el-tag>{{ row.status }}</el-tag>
|
||||||
@@ -58,7 +63,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, watch, computed } from 'vue'
|
import { ref, reactive, watch, computed } from 'vue'
|
||||||
import { fetchList } from '/@/api/basic/basicasynctask'
|
import { fetchList, downloadTaskFile } from '/@/api/basic/basicasynctask'
|
||||||
|
import { useMessage } from '/@/hooks/message'
|
||||||
|
|
||||||
type TaskTab = 'upload' | 'download' | 'other'
|
type TaskTab = 'upload' | 'download' | 'other'
|
||||||
|
|
||||||
@@ -87,6 +93,7 @@ const tableStyle = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const emptyText = computed(() => EMPTY_TEXT_MAP[activeTab.value])
|
const emptyText = computed(() => EMPTY_TEXT_MAP[activeTab.value])
|
||||||
|
const message = useMessage()
|
||||||
|
|
||||||
const loadList = async () => {
|
const loadList = async () => {
|
||||||
const type = activeTab.value
|
const type = activeTab.value
|
||||||
@@ -135,6 +142,34 @@ const open = () => {
|
|||||||
visible.value = true
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const downloadingId = ref<string | number | null>(null)
|
||||||
|
const handleDownloadFile = async (row: any) => {
|
||||||
|
if (!row?.id) return
|
||||||
|
downloadingId.value = row.id
|
||||||
|
try {
|
||||||
|
const response: any = await downloadTaskFile({ id: row.id })
|
||||||
|
const blob = (response && response.data instanceof Blob)
|
||||||
|
? response.data
|
||||||
|
: (response instanceof Blob ? response : new Blob([response]))
|
||||||
|
const dateStr = new Date().toISOString().slice(0, 10)
|
||||||
|
const baseName = row.detailType ? String(row.detailType).replace(/\s+/g, '_') : '下载文件'
|
||||||
|
const fileName = `${baseName}_${dateStr}.xls`
|
||||||
|
const elink = document.createElement('a')
|
||||||
|
elink.download = fileName
|
||||||
|
elink.style.display = 'none'
|
||||||
|
elink.href = URL.createObjectURL(blob)
|
||||||
|
document.body.appendChild(elink)
|
||||||
|
elink.click()
|
||||||
|
URL.revokeObjectURL(elink.href)
|
||||||
|
document.body.removeChild(elink)
|
||||||
|
message.success('下载成功')
|
||||||
|
} catch {
|
||||||
|
message.error('下载失败')
|
||||||
|
} finally {
|
||||||
|
downloadingId.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({ open })
|
defineExpose({ open })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -6,15 +6,15 @@
|
|||||||
show-icon
|
show-icon
|
||||||
style="margin-bottom: 20px;">
|
style="margin-bottom: 20px;">
|
||||||
<template #title>
|
<template #title>
|
||||||
<span>导入前请先下载字典文件,部分字段需严格按照字典值填写</span>
|
<span> 可先导出教职工信息,按照导出信息的模板填入职工数据,再执行导入</span>
|
||||||
</template>
|
</template>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
|
|
||||||
<div style="text-align: center; margin-bottom: 20px;">
|
<!-- <div style="text-align: center; margin-bottom: 20px;">-->
|
||||||
<a href="excel/dictlist.xlsx" rel="external nofollow" download="职工信息字典下载" style="text-decoration: none;">
|
<!-- <a href="excel/dictlist.xlsx" rel="external nofollow" download="职工信息字典下载" style="text-decoration: none;">-->
|
||||||
<el-button type="success" :icon="Download">下载字典文件</el-button>
|
<!-- <el-button type="success" :icon="Download">下载字典文件</el-button>-->
|
||||||
</a>
|
<!-- </a>-->
|
||||||
</div>
|
<!-- </div>-->
|
||||||
|
|
||||||
<el-upload
|
<el-upload
|
||||||
class="upload-demo"
|
class="upload-demo"
|
||||||
|
|||||||
Reference in New Issue
Block a user