|
|
|
|
@ -119,7 +119,7 @@
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>策略类型</th>
|
|
|
|
|
<th>组合逻辑(自动生成)</th>
|
|
|
|
|
<th>第 2 步补充信息</th>
|
|
|
|
|
<th>具体策略建议</th>
|
|
|
|
|
<th>预期效果</th>
|
|
|
|
|
</tr>
|
|
|
|
|
@ -304,7 +304,7 @@ async function loadSavedAnswer() { try { const answer = (await getStudentTrainin
|
|
|
|
|
function restoreOutcome(value, target, field = "swot") { try { const parsed = typeof value === "string" ? JSON.parse(value) : value; target.value = { ...createForm(), ...(parsed?.[field] || parsed || {}) }; if (field === "swot") { const structured = parsed?.choiceAnswers && typeof parsed.choiceAnswers === "object" ? parsed.choiceAnswers : null; if (structured && Object.keys(structured).length) stepOneChoiceAnswers.value = structured; else { /* 兜底:工具栏 DOM 快照 legacy-training-snapshot-v3,教师端评阅预览返回的就是这类数据 */ const legacyAnswers = parseLegacySnapshotChoiceAnswers(parsed, stepOneQuestions.value); if (legacyAnswers) stepOneChoiceAnswers.value = legacyAnswers } } } catch (error) { target.value = createForm() } }
|
|
|
|
|
function restoreStrategyOutcome(value) { try { const parsed = typeof value === "string" ? JSON.parse(value) : value; const source = parsed?.strategies || parsed || {}; strategyForm.value = Object.fromEntries(strategyDefinitions.map((row) => [row.key, { ...createStrategyRow(), ...(source[row.key] || {}) }])) } catch (error) { strategyForm.value = createStrategyForm() } }
|
|
|
|
|
function restoreFinalOutcome(value) { try { const parsed = typeof value === "string" ? JSON.parse(value) : value; const source = parsed?.decision || parsed || {}; const priorities = source.priorities || {}; finalForm.value = { ...createFinalForm(), ...source, priorities: Object.fromEntries(strategyDefinitions.map((row) => [row.key, { priority: null, reason: "", ...(priorities[row.key] || {}) }])) } } catch (error) { finalForm.value = createFinalForm() } }
|
|
|
|
|
function getCombinedLogic(row) { return [{ label: `${row.firstLabel}(第1步)· `, value: form.value[row.first] }, { label: `${row.firstLabel}(第2步补充)· `, value: supplementForm.value[row.first] }, { label: `${row.secondLabel}(第1步)· `, value: form.value[row.second] }, { label: `${row.secondLabel}(第2步补充)· `, value: supplementForm.value[row.second] }] }
|
|
|
|
|
function getCombinedLogic(row) { return [{ label: `${row.firstLabel}· `, value: supplementForm.value[row.first] }, { label: `${row.secondLabel}· `, value: supplementForm.value[row.second] }] }
|
|
|
|
|
function buildStepOneOutcome() { return { title: taskTitle.value, swot: { ...form.value }, choiceAnswers: { ...stepOneChoiceAnswers.value } } } function buildStepTwoOutcome() { return { title: taskTitle.value, supplements: { ...supplementForm.value } } } function buildStepThreeOutcome() { return { title: taskTitle.value, strategies: JSON.parse(JSON.stringify(strategyForm.value)) } } function buildStepFourOutcome() { return { title: taskTitle.value, decision: JSON.parse(JSON.stringify(finalForm.value)) } } function buildDraft() { return { step1: buildStepOneOutcome(), step2: buildStepTwoOutcome(), step3: buildStepThreeOutcome(), step4: buildStepFourOutcome(), currentStep: currentStep.value } } function getLocalDraftKey() { const info = userStore.userInfo || {}; return `${TASK_KEY}:draft:${info.userId || info.user_id || info.username || info.userName || "anonymous"}` } function persistDraft() { if (!draftReady.value) return; try { localStorage.setItem(getLocalDraftKey(), JSON.stringify(buildDraft())) } catch (error) { /* Optional browser draft. */ } } function loadDraft() { try { const raw = localStorage.getItem(getLocalDraftKey()); if (raw) { const draft = JSON.parse(raw); restoreOutcome(draft?.step1 || draft, form); restoreOutcome(draft?.step2, supplementForm, "supplements"); restoreStrategyOutcome(draft?.step3); restoreFinalOutcome(draft?.step4); if (Number(draft?.currentStep) > 0) currentStep.value = Number(draft.currentStep) } } catch (error) { clearDraft() } } function clearDraft() { try { localStorage.removeItem(getLocalDraftKey()) } catch (error) { /* Ignore storage failures. */ } }
|
|
|
|
|
function switchStep(step) { if (step === 2 && !stepOnePassed.value) { proxy?.$modal?.msgWarning("请先完成并保存第 1 步"); return } if (step === 3 && !stepTwoPassed.value) { proxy?.$modal?.msgWarning("请先完成并保存第 2 步"); return } if (step === 4 && !stepThreePassed.value) { proxy?.$modal?.msgWarning("请先完成并保存第 3 步"); return } currentStep.value = step }
|
|
|
|
|
function prevStep() { if (currentStep.value > 1) currentStep.value -= 1 }
|
|
|
|
|
|