|
|
@ -13,7 +13,7 @@ const { adminData, menuTree, flag } = storeToRefs(adminStore) |
|
|
get() |
|
|
get() |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
import { onMounted, ref, watch, nextTick } from 'vue' |
|
|
|
|
|
|
|
|
import { onMounted, ref, watch, nextTick, onBeforeUnmount } from 'vue' |
|
|
import { ElMessage } from 'element-plus' |
|
|
import { ElMessage } from 'element-plus' |
|
|
import moment from 'moment' |
|
|
import moment from 'moment' |
|
|
import API from '@/util/http.js' |
|
|
import API from '@/util/http.js' |
|
|
@ -446,6 +446,8 @@ const exportExcelOnlyOne = async function () { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const exportListVisible = ref(false) |
|
|
const exportListVisible = ref(false) |
|
|
|
|
|
const EXPORT_LIST_POLL_INTERVAL = 3000 |
|
|
|
|
|
let exportListPollingTimer = null |
|
|
const selectWalletVisible = ref(false) |
|
|
const selectWalletVisible = ref(false) |
|
|
const selectWalletFormRef = ref(null) |
|
|
const selectWalletFormRef = ref(null) |
|
|
const selectWalletRules = { |
|
|
const selectWalletRules = { |
|
|
@ -502,7 +504,6 @@ const companyWalletList = ref([ |
|
|
]) |
|
|
]) |
|
|
// 打开导出列表弹窗 |
|
|
// 打开导出列表弹窗 |
|
|
const openExportList = () => { |
|
|
const openExportList = () => { |
|
|
getExportList() |
|
|
|
|
|
exportListVisible.value = true |
|
|
exportListVisible.value = true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -510,27 +511,80 @@ const openExportList = () => { |
|
|
const exportList = ref([]) |
|
|
const exportList = ref([]) |
|
|
// 导出列表加载状态 |
|
|
// 导出列表加载状态 |
|
|
const exportListLoading = ref(false) |
|
|
const exportListLoading = ref(false) |
|
|
|
|
|
const exportListRequesting = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const sortExportList = (list = []) => { |
|
|
|
|
|
return [...list].sort((a, b) => { |
|
|
|
|
|
return new Date(b.createTime).getTime() - new Date(a.createTime).getTime() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const hasPendingExportTask = (list = []) => { |
|
|
|
|
|
const latestTask = sortExportList(list)[0] |
|
|
|
|
|
return latestTask ? latestTask.state === 0 || latestTask.state === 1 : false |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const stopExportListPolling = () => { |
|
|
|
|
|
if (exportListPollingTimer) { |
|
|
|
|
|
clearInterval(exportListPollingTimer) |
|
|
|
|
|
exportListPollingTimer = null |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const startExportListPolling = () => { |
|
|
|
|
|
if (exportListPollingTimer) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
exportListPollingTimer = setInterval(() => { |
|
|
|
|
|
if (!exportListVisible.value) { |
|
|
|
|
|
stopExportListPolling() |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
getExportList({ showLoading: false, silentError: true }) |
|
|
|
|
|
}, EXPORT_LIST_POLL_INTERVAL) |
|
|
|
|
|
} |
|
|
// 获取导出列表 |
|
|
// 获取导出列表 |
|
|
const getExportList = async () => { |
|
|
|
|
|
exportListLoading.value = true |
|
|
|
|
|
try { |
|
|
|
|
|
const result = await API({ url: '/export/export' }) |
|
|
|
|
|
if (result.code === 200) { |
|
|
|
|
|
|
|
|
const getExportList = async ({ showLoading = true, silentError = false } = {}) => { |
|
|
|
|
|
if (exportListRequesting.value) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (showLoading) { |
|
|
|
|
|
exportListLoading.value = true |
|
|
|
|
|
} |
|
|
|
|
|
exportListRequesting.value = true |
|
|
|
|
|
try { |
|
|
|
|
|
const result = await API({ url: '/export/export' }) |
|
|
|
|
|
if (result.code === 200) { |
|
|
// 过滤只显示type为16和17的导出记录 |
|
|
// 过滤只显示type为16和17的导出记录 |
|
|
const filteredData = result.data.filter(item => { |
|
|
const filteredData = result.data.filter(item => { |
|
|
return item.type === 16 || item.type === 17; |
|
|
return item.type === 16 || item.type === 17; |
|
|
}); |
|
|
}); |
|
|
exportList.value = filteredData |
|
|
|
|
|
} else { |
|
|
|
|
|
ElMessage.error(result.msg || t('elmessage.getExportListError')) |
|
|
|
|
|
|
|
|
exportList.value = sortExportList(filteredData) |
|
|
|
|
|
if (exportListVisible.value && hasPendingExportTask(exportList.value)) { |
|
|
|
|
|
startExportListPolling() |
|
|
|
|
|
} else { |
|
|
|
|
|
stopExportListPolling() |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
stopExportListPolling() |
|
|
|
|
|
if (!silentError) { |
|
|
|
|
|
ElMessage.error(result.msg || t('elmessage.getExportListError')) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('获取导出列表出错:', error) |
|
|
|
|
|
stopExportListPolling() |
|
|
|
|
|
if (!silentError) { |
|
|
|
|
|
ElMessage.error(t('elmessage.getExportListError')) |
|
|
|
|
|
} |
|
|
|
|
|
} finally { |
|
|
|
|
|
exportListRequesting.value = false |
|
|
|
|
|
if (showLoading) { |
|
|
|
|
|
exportListLoading.value = false |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
|
|
|
console.error('获取导出列表出错:', error) |
|
|
|
|
|
ElMessage.error(t('elmessage.getExportListError')) |
|
|
|
|
|
} finally { |
|
|
|
|
|
exportListLoading.value = false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 下载导出文件 |
|
|
// 下载导出文件 |
|
|
const downloadExportFile = (item) => { |
|
|
const downloadExportFile = (item) => { |
|
|
if (item.state === 2) { |
|
|
if (item.state === 2) { |
|
|
@ -626,6 +680,18 @@ const format3 = (num) => { |
|
|
return num.toLocaleString('en-US') |
|
|
return num.toLocaleString('en-US') |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
watch(exportListVisible, (visible) => { |
|
|
|
|
|
if (visible) { |
|
|
|
|
|
getExportList() |
|
|
|
|
|
} else { |
|
|
|
|
|
stopExportListPolling() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => { |
|
|
|
|
|
stopExportListPolling() |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<template> |
|
|
<template> |
|
|
|