feat(data-process): 完善后台生成与失败重试
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { computed, nextTick, ref, type Reactive, type Ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useRoute } from 'vue-router'
|
||||
import {
|
||||
getDataProcessPreview,
|
||||
getDataProcessSourceContent,
|
||||
@@ -81,11 +81,11 @@ async function loadAllPreviews(taskId: string, mapPreviewItem: RegenerationBindi
|
||||
|
||||
export function useDataProcessRegeneration(bindings: RegenerationBindings) {
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const isRegeneration = computed(() => route.name === 'data-process-regenerate')
|
||||
const isWorkflowResume = computed(() => route.name === 'data-process-workflow')
|
||||
const sourceTaskId = computed(() => (
|
||||
route.name === 'data-process-regenerate' ? String(route.params.id || '') : ''
|
||||
isRegeneration.value || isWorkflowResume.value ? String(route.params.id || '') : ''
|
||||
))
|
||||
const isRegeneration = computed(() => Boolean(sourceTaskId.value))
|
||||
const originalProcessType = ref<ProcessType | null>(null)
|
||||
const originalTaskUpdatedAt = ref('')
|
||||
const regenerationPrepared = ref(false)
|
||||
@@ -138,7 +138,7 @@ export function useDataProcessRegeneration(bindings: RegenerationBindings) {
|
||||
try {
|
||||
const sourceTask = await getDataProcessTask(sourceTaskId.value)
|
||||
const sourceType = sourceTask.process_type as ProcessType
|
||||
originalProcessType.value = sourceType
|
||||
originalProcessType.value = isRegeneration.value ? sourceType : null
|
||||
originalTaskUpdatedAt.value = sourceTask.updated_at
|
||||
bindings.task.name = sourceTask.name
|
||||
bindings.task.description = sourceTask.description || ''
|
||||
@@ -151,6 +151,7 @@ export function useDataProcessRegeneration(bindings: RegenerationBindings) {
|
||||
await hydrateWorkspace(sourceTask, true)
|
||||
await nextTick()
|
||||
bindings.dirty.value = false
|
||||
return sourceTask
|
||||
} catch (error) {
|
||||
initializationError.value = error instanceof Error
|
||||
? error.message
|
||||
@@ -235,25 +236,10 @@ export function useDataProcessRegeneration(bindings: RegenerationBindings) {
|
||||
return true
|
||||
}
|
||||
|
||||
async function returnToDetail() {
|
||||
if (!sourceTaskId.value) return false
|
||||
await router.replace({ name: 'data-process-detail', params: { id: sourceTaskId.value } })
|
||||
return true
|
||||
}
|
||||
|
||||
function leaveWarning(generationStatus: string) {
|
||||
if (isRegeneration.value && regenerationPrepared.value && generationStatus === 'idle') {
|
||||
return '重新生成配置已保存,但尚未开始生成;现在返回详情不会替换原生成结果或已发布数据,可稍后继续。'
|
||||
}
|
||||
if (isRegeneration.value && regenerationPrepared.value) {
|
||||
return '重新生成已开始;离开页面不会停止服务端处理,已提交的修改不会撤销。'
|
||||
}
|
||||
return '当前存在未保存修改,离开后这些修改将不会保留。'
|
||||
}
|
||||
|
||||
return {
|
||||
sourceTaskId,
|
||||
isRegeneration,
|
||||
isWorkflowResume,
|
||||
originalProcessType,
|
||||
originalTaskUpdatedAt,
|
||||
regenerationPrepared,
|
||||
@@ -264,7 +250,5 @@ export function useDataProcessRegeneration(bindings: RegenerationBindings) {
|
||||
confirmPreviewConfigChange,
|
||||
prepareRegeneration,
|
||||
confirmStartGeneration,
|
||||
returnToDetail,
|
||||
leaveWarning,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user