This commit is contained in:
@@ -155,9 +155,7 @@
|
||||
<div class="task-list-toolbar">
|
||||
<ElButton
|
||||
v-if="hasAuth(BULK_PURCHASE_PERMISSIONS.template)"
|
||||
tag="a"
|
||||
href="/templates/bulk-purchase-template.csv"
|
||||
download="批量订购套餐模板.csv"
|
||||
@click="downloadTemplate"
|
||||
>
|
||||
下载模板
|
||||
</ElButton>
|
||||
@@ -306,6 +304,21 @@
|
||||
() => submitting.value || voucherUploading.value || orderFileUploading.value
|
||||
)
|
||||
|
||||
const downloadTemplate = () => {
|
||||
try {
|
||||
const link = document.createElement('a')
|
||||
link.href = new URL('@/template/批量订购套餐模板.csv', import.meta.url).href
|
||||
link.download = '批量订购套餐模板.csv'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
ElMessage.success('模板下载成功')
|
||||
} catch (error) {
|
||||
console.error('下载模板失败:', error)
|
||||
ElMessage.error('模板下载失败')
|
||||
}
|
||||
}
|
||||
|
||||
const form = reactive<{
|
||||
series_id?: number
|
||||
package_id?: number
|
||||
@@ -526,6 +539,7 @@
|
||||
) => {
|
||||
stopTaskStatusPolling()
|
||||
const session = taskStatusPollSession
|
||||
let lastStatus = initialStatus
|
||||
|
||||
const poll = async () => {
|
||||
if (session !== taskStatusPollSession) return
|
||||
@@ -537,10 +551,22 @@
|
||||
})
|
||||
if (response.code === 0) {
|
||||
const task = response.data.items.find((item) => (item.task_id ?? item.id) === taskId)
|
||||
if (task && task.status !== initialStatus) {
|
||||
await loadTaskList()
|
||||
stopTaskStatusPolling()
|
||||
return
|
||||
if (task) {
|
||||
if (task.status !== lastStatus) {
|
||||
lastStatus = task.status
|
||||
await loadTaskList()
|
||||
}
|
||||
if (
|
||||
session === taskStatusPollSession &&
|
||||
[
|
||||
BulkPurchaseTaskStatus.COMPLETED,
|
||||
BulkPurchaseTaskStatus.FAILED,
|
||||
BulkPurchaseTaskStatus.CANCELED
|
||||
].includes(task.status)
|
||||
) {
|
||||
stopTaskStatusPolling()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -391,8 +391,8 @@
|
||||
const downloadTemplate = () => {
|
||||
try {
|
||||
const link = document.createElement('a')
|
||||
link.href = new URL('@/template/批量订购套餐模板.csv', import.meta.url).href
|
||||
link.download = '批量订购套餐模板.csv'
|
||||
link.href = new URL('@/template/设备批量任务.csv', import.meta.url).href
|
||||
link.download = '设备批量任务.csv'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
@@ -450,6 +450,7 @@
|
||||
) => {
|
||||
stopTaskStatusPolling()
|
||||
const session = taskStatusPollSession
|
||||
let lastStatus = initialStatus
|
||||
|
||||
const poll = async () => {
|
||||
if (session !== taskStatusPollSession) return
|
||||
@@ -461,10 +462,20 @@
|
||||
})
|
||||
if (response.code === 0) {
|
||||
const task = response.data.items.find((item) => item.id === taskId)
|
||||
if (task && task.status !== initialStatus) {
|
||||
await loadTaskList()
|
||||
stopTaskStatusPolling()
|
||||
return
|
||||
if (task) {
|
||||
if (task.status !== lastStatus) {
|
||||
lastStatus = task.status
|
||||
await loadTaskList()
|
||||
}
|
||||
if (
|
||||
session === taskStatusPollSession &&
|
||||
[DeviceImportTaskStatus.COMPLETED, DeviceImportTaskStatus.FAILED].includes(
|
||||
task.status
|
||||
)
|
||||
) {
|
||||
stopTaskStatusPolling()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user