@ -211,6 +211,7 @@ const uploadingPareto = ref(false);
const paretoImage = ref ( { url : "" , name : "" } ) ;
const stepFour = ref ( createStepFour ( ) ) ;
const strategyRows = ref ( createStrategyRows ( ) ) ;
const dynamicStepAnswers = ref ( { } ) ;
const modules = [
{ name : "帕累托 / ABC 分析" , component : defineAsyncComponent ( ( ) => import ( "../portraitModel/components/abcAnalysis.vue" ) ) } ,
{ name : "购物篮分析" , component : defineAsyncComponent ( ( ) => import ( "../portraitModel/components/basketAnalysis.vue" ) ) } ,
@ -241,6 +242,7 @@ function buildStepTwoProgress() { return { version: 1, rows: categoryRows.value.
function buildStepThreeProgress ( ) { return { version : 1 , imageUrl : paretoImage . value . url , imageName : paretoImage . value . name , updatedAt : new Date ( ) . toISOString ( ) } ; }
function buildStepFourProgress ( ) { return { version : 1 , ... stepFour . value , updatedAt : new Date ( ) . toISOString ( ) } ; }
function buildStepFiveProgress ( ) { return { version : 1 , rows : strategyRows . value . map ( ( { layer , operationStrategy , inventoryStrategy , resourcePriority } ) => ( { layer , operationStrategy , inventoryStrategy , resourcePriority } ) ) , updatedAt : new Date ( ) . toISOString ( ) } ; }
function parseSavedJson ( value ) { try { const parsed = typeof value === "string" ? JSON . parse ( value ) : value ; return parsed && typeof parsed === "object" ? parsed : null ; } catch ( error ) { return null ; } }
function applyProgress ( value ) {
if ( ! value || typeof value !== "object" ) return ;
activeStep . value = normalizeActiveStep ( value . activeStep ) ;
@ -251,7 +253,7 @@ function applyStepTwoProgress(value) { const classifications = new Map((Array.is
function applyStepThreeProgress ( value ) { paretoImage . value = { url : String ( value ? . imageUrl || "" ) , name : String ( value ? . imageName || "" ) } ; }
function applyStepFourProgress ( value ) { stepFour . value = createStepFour ( value ) ; }
function applyStepFiveProgress ( value ) { strategyRows . value = createStrategyRows ( value ? . rows ) ; }
async function persistProgress ( saveAction = "SAVE" ) { await saveStudentTrainingAnswer ( TASK _KEY , { saveAction , currentStep : activeStep . value , step1Answer : JSON . stringify ( buildProgress ( ) ) , step2Answer : JSON . stringify ( buildStepTwoProgress ( ) ) , step3Answer : JSON . stringify ( buildStepThreeProgress ( ) ) , step4Answer : JSON . stringify ( buildStepFourProgress ( ) ) , step5Answer: JSON . stringify ( buildStepFiveProgress ( ) ) } ) ; }
async function persistProgress ( saveAction = "SAVE" ) { dynamicStepAnswers. value = { ... dynamicStepAnswers . value , step5 : buildStepFiveProgress ( ) } ; await saveStudentTrainingAnswer ( TASK _KEY , { saveAction , currentStep : activeStep . value , submitted : saveAction === "SUBMIT" , step1Answer : JSON . stringify ( buildProgress ( ) ) , step2Answer : JSON . stringify ( buildStepTwoProgress ( ) ) , step3Answer : JSON . stringify ( buildStepThreeProgress ( ) ) , step4Answer : JSON . stringify ( buildStepFourProgress ( ) ) , dynamicStepAnswers: JSON . stringify ( dynamicStepAnswers . value ) } ) ; }
function addRow ( ) { if ( categoryRows . value . length >= MAX _ROWS ) return ; categoryRows . value . push ( createRow ( ) ) ; }
function removeLastRow ( ) { categoryRows . value . pop ( ) ; }
async function validateStepOne ( ) {
@ -349,7 +351,7 @@ async function saveCurrentProgress() {
async function submitTask ( ) {
if ( saving . value || ! ( await validateStepOne ( ) ) || ( hasConfiguredSteps . value && configuredSteps . value . length > 1 && ! ( await validateStepTwo ( ) ) ) || ( hasConfiguredSteps . value && configuredSteps . value . length > 2 && ! ( await validateStepThree ( ) ) ) || ( hasConfiguredSteps . value && configuredSteps . value . length > 3 && ! ( await validateStepFour ( ) ) ) || ( hasConfiguredSteps . value && configuredSteps . value . length > 4 && ! ( await validateStepFive ( ) ) ) ) return ;
saving . value = true ;
try { await businessComponent . value ? . submitData ? . ( ) ; await persistProgress ( "S AVE ") ; ElMessage . success ( "任务已提交" ) ; } finally { saving . value = false ; }
try { await businessComponent . value ? . submitData ? . ( ) ; await persistProgress ( "S UBMIT ") ; ElMessage . success ( "任务已提交" ) ; } finally { saving . value = false ; }
}
async function resetTask ( ) {
if ( saving . value ) return ;
@ -374,7 +376,7 @@ function exportOutcome() {
}
onMounted ( async ( ) => {
try { const res = await getTrainingTaskByKey ( TASK _KEY ) ; taskConfig . value = res ? . data || null ; activeStep . value = normalizeActiveStep ( activeStep . value ) ; } catch ( error ) { taskConfig . value = null ; }
try { const res = await getStudentTrainingAnswer ( TASK _KEY ) ; if ( res ? . data ? . step1Answer ) applyProgress ( JSON . parse ( res . data . step1Answer ) ) ; if ( res ? . data ? . step2Answer ) applyStepTwoProgress ( JSON . parse ( res . data . step2Answer ) ) ; if ( res ? . data ? . step3Answer ) applyStepThreeProgress ( JSON . parse ( res . data . step3Answer ) ) ; if ( res ? . data ? . step4Answer ) applyStepFourProgress ( JSON . parse ( res . data . step4Answer ) ) ; if ( res ? . data ? . step5 Answer) applyStepFiveProgress ( JSON. parse ( res . data . step5Answer ) ) ; } catch ( error ) { }
try { const res = await getStudentTrainingAnswer ( TASK _KEY ) ; if ( res ? . data ? . step1Answer ) applyProgress ( JSON . parse ( res . data . step1Answer ) ) ; if ( res ? . data ? . step2Answer ) applyStepTwoProgress ( JSON . parse ( res . data . step2Answer ) ) ; if ( res ? . data ? . step3Answer ) applyStepThreeProgress ( JSON . parse ( res . data . step3Answer ) ) ; if ( res ? . data ? . step4Answer ) applyStepFourProgress ( JSON . parse ( res . data . step4Answer ) ) ; dynamicStepAnswers . value = parseSavedJson ( res ? . data ? . dynamicStepAn swers) || { } ; if ( dynamicS tepAnswers. value . step5 ) applyStepFiveProgress ( dynamicStepAnswers. value . step5 ) ; } catch ( error ) { }
} ) ;
< / script >